/* =========================================================
   SDS — Size / Frame / Subframe Dropdown System
   Claude Design spec: owner-approved colors/radii/animation
   ========================================================= */

/* ── Hide real select (still in DOM for WC/ms3 events) ─── */
select.sds-active {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 1px !important;
    height: 1px !important;
    border: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
}

/* ── Wrapper ─────────────────────────────────────────────── */
.sds {
    position: relative;
    font-family: "Jost", -apple-system, BlinkMacSystemFont, sans-serif;
    width: 100%;
    margin-bottom: 4px;
}

/* ── Trigger ─────────────────────────────────────────────── */
.sds__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 14px;
    background: #fff;
    border: 1.5px solid #e2e2dd;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    gap: 8px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}

.sds__trigger:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-color: #b9b9b2;
}

.sds.is-open .sds__trigger {
    border-color: #9a6c33;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 0 0 2px rgba(154, 108, 51, 0.12);
}

/* ── Trigger current-value area ───────────────────────────── */
.sds__current {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.sds__current .o-size {
    font-size: 15px;
    font-weight: 500;
    color: #1a1a18;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sds__current .o-price {
    font-size: 13px;
    font-weight: 400;
    color: #a4a49d;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Chevron ─────────────────────────────────────────────── */
.sds__chevron {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #b9b9b2;
    transition: transform 0.22s ease;
    display: block;
}

.sds.is-open .sds__chevron {
    transform: rotate(180deg);
    color: #9a6c33;
}

/* ── Floating panel ──────────────────────────────────────── */
.sds__panel {
    position: absolute;
    top: calc(100% - 2px);
    left: 0;
    right: 0;
    z-index: 1200;
    background: #fff;
    border: 1.5px solid #e2e2dd;
    border-top: none;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.11), 0 2px 6px rgba(0, 0, 0, 0.06);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.26s cubic-bezier(.4,0,.2,1),
                opacity    0.18s ease;
}

.sds.is-open .sds__panel {
    max-height: 540px;
    opacity: 1;
    pointer-events: auto;
}

/* ── Scrollable list ─────────────────────────────────────── */
.sds__list {
    list-style: none;
    margin: 0;
    padding: 6px 0 8px;
    max-height: 522px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sds__list::-webkit-scrollbar { width: 4px; }
.sds__list::-webkit-scrollbar-track { background: transparent; }
.sds__list::-webkit-scrollbar-thumb {
    background: #e2e2dd;
    border-radius: 2px;
}
.sds__list::-webkit-scrollbar-thumb:hover { background: #b9b9b2; }

/* ── Option rows ─────────────────────────────────────────── */
.sds__option {
    list-style: none;
    display: flex;
    align-items: stretch;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sds__option-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px 10px 11px;
    gap: 14px;
}

.sds__option:hover {
    background: #f7f7f4;
}

.sds__option.is-selected {
    background: #faf6ef;
    border-left-color: #9a6c33;
}

/* ── Left: size + meta row ───────────────────────────────── */
.o-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.sds__option .o-size {
    font-size: 15px;
    font-weight: 500;
    color: #1a1a18;
    white-space: nowrap;
    line-height: 1.3;
}

.o-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    line-height: 1;
}

.o-deliv {
    font-size: 12px;
    color: #a4a49d;
    line-height: 1.3;
}

/* ── Right: price ────────────────────────────────────────── */
.sds__option .o-price {
    font-size: 15px;
    font-weight: 500;
    color: #1a1a18;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
}

/* ── Zaloga badge ────────────────────────────────────────── */
.sds__badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    color: #2f7d4f;
    background: #ecf3ed;
    border: 1px solid #cfe4d2;
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 767px) {
    .sds__trigger {
        padding: 13px 14px;
    }
    .sds__option-inner {
        padding: 13px 14px 13px 11px;
        min-height: 52px;
    }
    .sds__option .o-size {
        font-size: 14px;
    }
    .sds__option .o-price {
        font-size: 14px;
    }
}

/* =========================================================
   ACCESSIBILITY
   - .sds-visually-hidden: field label read by screen readers
     (referenced via aria-labelledby on the trigger + listbox),
     never shown visually.
   - Visible keyboard focus: previously there were NO :focus styles
     anywhere, so keyboard focus was invisible. The trigger gets a
     focus ring; the listbox holds DOM focus while the highlighted
     ("active") option is the visible cursor (aria-activedescendant).
   ========================================================= */
.sds-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.sds__trigger:focus-visible {
    outline: none;
    border-color: #9a6c33;
    box-shadow: 0 0 0 3px rgba(154, 108, 51, 0.35);
}

.sds__list:focus,
.sds__list:focus-visible {
    outline: none;
}

/* Active-descendant cursor: a subtle tint always marks the active option
   (distinct from is-selected #faf6ef and hover #f7f7f4). */
.sds__option.is-active {
    background: #f2ece1;
}

/* Strong accent ring only when navigating by KEYBOARD (list focus-visible),
   so mouse hover stays clean. */
.sds__list:focus-visible .sds__option.is-active {
    box-shadow: inset 0 0 0 2px #9a6c33;
}

/* ── Frame thumbnail in Okvir rows ──────────────────────── */
.o-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    display: block;
}

.o-thumb--trigger {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 2px;
}

/* Row layout when thumbnail is present */
.sds__option--with-thumb .sds__option-inner {
    align-items: center;
}

.o-left--row {
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
}

/* Okvir panel — slightly wider max-height for long frame list */
.sds--okvir .sds__panel {
    max-height: 0;
}
.sds--okvir.is-open .sds__panel {
    max-height: 480px;
}
.sds--okvir .sds__list {
    max-height: 466px;
}

/* Podokvir panel — only 2 options, compact */
.sds--podokvir .sds__panel {
    max-height: 0;
}
.sds--podokvir.is-open .sds__panel {
    max-height: 130px;
}
.sds--podokvir .sds__list {
    max-height: 120px;
}

/* ── Trigger separator between size and price ────────────── */
.sds__current .o-sep {
    font-size: 13px;
    color: #c8c8c0;
    flex-shrink: 0;
}

/* ── Multi-panel pod-okvir static badge ──────────────────── */
.sds--pod-okvir-badge {
    pointer-events: none;
    user-select: none;
}

.sds__badge-static {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    background: #f7f7f4;
    border: 1.5px solid #e2e2dd;
    border-radius: 12px;
    box-sizing: border-box;
}

.sds__pod-label {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a18;
    white-space: nowrap;
}

.sds__pod-value {
    font-size: 14px;
    font-weight: 400;
    color: #6a6a64;
    white-space: nowrap;
}

/* Podokvir + Okvir: slightly smaller trigger text to differentiate from Dimenzija */
.sds--podokvir .sds__current .o-size,
.sds--okvir .sds__current .o-size {
    font-size: 14px;
}
.sds--podokvir .sds__option .o-size,
.sds--okvir .sds__option .o-size {
    font-size: 14px;
}

/* =========================================================
   BUG B FIX — mobile overflow
   On translated pages a wide label column ("Abmessungen",
   "Bilderrahmen", "Hilfs-Rahmen") shoved the value cell — and the
   absolutely-positioned .sds__panel + its right-aligned price — off
   the right edge of the screen, where an ancestor clips it.
   Fix: stack the variation rows below 575px (Goya's Bootstrap-sm
   mobile breakpoint) so the value cell gets the full row width, and
   clamp the panel so it can never exceed the viewport.
   Desktop (>=576px) is untouched. Internal .sds flex rules unchanged.
   ========================================================= */
@media (max-width: 575px) {
    .et-product-detail .summary .variations_form .variations,
    .et-product-detail .summary .variations_form .variations tbody,
    .et-product-detail .summary .variations_form .variations tr,
    .et-product-detail .summary .variations_form .variations td {
        display: block;
        width: 100%;
    }
    /* Label sits as a block above its control; drop the divider so the
       value cell's own border-bottom stays the single row separator. */
    .et-product-detail .summary .variations_form .variations td.label {
        border: 0;
        padding: 0 0 2px;
    }
    .et-product-detail .summary .variations_form .variations td.value {
        padding-top: 0;
    }
}

/* Belt-and-suspenders: the floating panel can never exceed the viewport,
   even if some ancestor still constrains its containing block.
   No effect on desktop, where the value cell is narrower than this. */
.sds__panel {
    max-width: calc(100vw - 24px);
}
