/**
 * @package     Pixed.Module.Pixlmscart
 *
 * @copyright   (C) 2026 Pixed. All rights reserved.
 * @license     GNU General Public License version 2 or later
 *
 * Framework-neutral styling (works under UIkit / Bootstrap / YOOtheme).
 * All values are overridable via CSS custom properties.
 */

.pixlmscart {
    /* Semantic accents kept (primary CTA / cart-count badge) — legible on any theme. */
    --pixlmscart-accent: #2563eb;
    --pixlmscart-accent-contrast: #ffffff;
    --pixlmscart-badge-bg: #dc2626;
    --pixlmscart-badge-color: #ffffff;
    /* Floating panel surface: a near-black sheet with light text (requested look).
       Only the panel interior uses these; the toggle/icon keep `inherit` so they
       still follow the active theme. Overridable via these custom properties. */
    --pixlmscart-panel-bg: rgba(12, 12, 12, 0.97);
    --pixlmscart-panel-color: rgba(255, 255, 255, 0.92);
    --pixlmscart-border: rgba(255, 255, 255, 0.16);
    --pixlmscart-radius: 10px;
    --pixlmscart-shadow: 0 12px 32px rgba(0, 0, 0, .16);

    position: relative;
    display: inline-block;
    font-size: 1rem;
    line-height: 1.4;
}

/* ---- toggle button + badge -------------------------------------------- */

.pixlmscart__toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: var(--pixlmscart-radius);
}

.pixlmscart__toggle:hover {
    color: var(--pixlmscart-accent);
}

.pixlmscart__toggle:focus-visible {
    outline: 2px solid var(--pixlmscart-accent);
    outline-offset: 2px;
}

.pixlmscart__icon {
    display: block;
}

.pixlmscart__badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--pixlmscart-badge-bg);
    color: var(--pixlmscart-badge-color);
    font-size: .7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
}

.pixlmscart__badge.is-empty {
    display: none;
}

/* Screen-reader-only helper text. */
.pixlmscart__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---- dropdown panel --------------------------------------------------- */

.pixlmscart__panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 1050;
    width: 320px;
    max-width: calc(100vw - 24px);
    padding: 16px;
    background: var(--pixlmscart-panel-bg);
    color: var(--pixlmscart-panel-color);
    /* Frosting makes the translucent neutral fill read as an opaque surface over
       any page content, on both light and dark themes. */
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--pixlmscart-border);
    border-radius: var(--pixlmscart-radius);
    box-shadow: var(--pixlmscart-shadow);
    box-sizing: border-box;
}

.pixlmscart__panel[hidden] {
    display: none;
}

.pixlmscart__panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.pixlmscart__panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.pixlmscart__close {
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 6px;
}

.pixlmscart__close:focus-visible {
    outline: 2px solid var(--pixlmscart-accent);
    outline-offset: 2px;
}

/* ---- empty state ------------------------------------------------------ */

.pixlmscart__empty {
    margin: 0;
    padding: 16px 0;
    opacity: 0.7;
    text-align: center;
}

/* ---- items ------------------------------------------------------------ */

.pixlmscart__items {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}

.pixlmscart__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--pixlmscart-border);
}

.pixlmscart__item:first-child {
    padding-top: 0;
}

.pixlmscart__thumb {
    flex: 0 0 auto;
    display: block;
}

.pixlmscart__thumb img {
    display: block;
    width: 56px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

.pixlmscart__item-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pixlmscart__item-title {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pixlmscart__item-title:hover {
    text-decoration: underline;
}

.pixlmscart__item-price {
    opacity: 0.7;
    font-size: .875rem;
}

.pixlmscart__remove {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.pixlmscart__remove:hover {
    color: var(--pixlmscart-badge-bg);
    opacity: 1;
    background: rgba(127, 127, 127, .15);
}

.pixlmscart__remove:focus-visible {
    outline: 2px solid var(--pixlmscart-accent);
    outline-offset: 2px;
}

/* ---- total ------------------------------------------------------------ */

.pixlmscart__total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0;
    font-size: .95rem;
}

.pixlmscart__total strong {
    font-size: 1.05rem;
}

/* ---- actions ---------------------------------------------------------- */

.pixlmscart__actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.pixlmscart__btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: var(--pixlmscart-radius);
    font-size: .9rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}

.pixlmscart__btn--ghost {
    border: 1px solid var(--pixlmscart-border);
    background: transparent;
    color: var(--pixlmscart-panel-color);
}

.pixlmscart__btn--ghost:hover {
    border-color: var(--pixlmscart-accent);
    color: var(--pixlmscart-accent);
}

.pixlmscart__btn--primary {
    background: var(--pixlmscart-accent);
    color: var(--pixlmscart-accent-contrast);
    border: 1px solid var(--pixlmscart-accent);
}

.pixlmscart__btn--primary:hover {
    filter: brightness(.94);
    color: var(--pixlmscart-accent-contrast);
}

.pixlmscart__btn:focus-visible {
    outline: 2px solid var(--pixlmscart-accent);
    outline-offset: 2px;
}

.is-hidden {
    display: none !important;
}

/* ---- responsive: full-width sheet on small screens ------------------- */

@media (max-width: 575px) {
    .pixlmscart__panel {
        position: fixed;
        top: auto;
        bottom: 0;
        inset-inline: 0;
        width: 100%;
        max-width: 100%;
        border-radius: var(--pixlmscart-radius) var(--pixlmscart-radius) 0 0;
        animation: pixlmscart-slide-up .2s ease-out;
    }

    .pixlmscart__items {
        max-height: 50vh;
    }
}

@keyframes pixlmscart-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .pixlmscart__panel {
        animation: none;
    }
}
