/**
 * DEV-16 V2 — Scoped Styles for Hybrid BTP Variant Selector & Comparative Table
 * Note: CMESMAT root uses `html { font-size: 62.5%; }` (`1rem = 10px`).
 */

.product-variants__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   1. Hero Variant Container & Header
   ========================================================================== */
.product-variants {
    width: 100%;
    margin: 1.4rem 0 1.6rem;
    padding: 1.4rem 1.6rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    box-sizing: border-box;
}

.product-variants__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.product-variants__title {
    font-size: 1.35rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.35;
}

.product-variants__current-val {
    color: #0f172a;
    font-weight: 700;
    margin-inline-start: 0.3rem;
}

.product-variants__count {
    font-size: 1.2rem;
    font-weight: 600;
    color: #475569;
    background: #e2e8f0;
    padding: 0.25rem 0.85rem;
    border-radius: 999px;
}

.product-variants__jump-link {
    font-size: 1.25rem;
    font-weight: 600;
    color: #166534;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.product-variants__jump-link:hover,
.product-variants__jump-link:focus-visible {
    color: #14532d;
}

/* ==========================================================================
   2. Tactile BTP Card-Pills Mode (`2` to `6` variants ONLY)
   ========================================================================== */
.product-variants__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.8rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.product-variants__item {
    margin: 0;
    padding: 0;
}

.product-variants__pill {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    min-height: 4.8rem;
    padding: 0.8rem 1.1rem;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 0.8rem;
    color: #1e293b;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.product-variants__pill:hover {
    border-color: #65a30d;
    background: #f7fee7;
    color: #0f172a;
    text-decoration: none;
}

.product-variants__pill:focus-visible {
    outline: 2.5px solid #15803d;
    outline-offset: 2px;
}

.product-variants__pill.is-current {
    background: #f0fdf4;
    border-color: #16a34a;
    box-shadow: 0 0 0 1px #16a34a;
}

.product-variants__pill-top {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.product-variants__pill-label {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
}

.product-variants__pill-sub {
    font-size: 1.15rem;
    font-weight: 600;
    color: #166534;
    line-height: 1.2;
}

.product-variants__pill-sub--quote {
    color: #64748b;
    font-weight: 500;
}

.product-variants__pill-dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
    background-color: #16a34a;
    flex-shrink: 0;
}

.product-variants__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin: 0.9rem 0 0;
    font-size: 1.15rem;
    color: #475569;
}

.product-variants__legend-muted {
    color: #64748b;
}

/* ==========================================================================
   3. Drawer Trigger Card (`>= 7` variants — Leroy Merlin Benchmark)
   ========================================================================== */
.pdp-drawer-trigger {
    width: 100%;
    min-height: 5.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    padding: 1rem 1.4rem;
    background: #ffffff;
    border: 1.5px solid #94a3b8;
    border-radius: 0.8rem;
    color: #0f172a;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.pdp-drawer-trigger:hover {
    border-color: #16a34a;
    background: #f8fafc;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.pdp-drawer-trigger:focus-visible {
    outline: 2.5px solid #15803d;
    outline-offset: 2px;
}

.pdp-drawer-trigger__main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.pdp-drawer-trigger__selected {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.5rem;
    color: #0f172a;
}

.pdp-drawer-trigger__meta {
    font-size: 1.25rem;
    color: #166534;
    font-weight: 600;
}

.pdp-drawer-trigger__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    background: #0f172a;
    color: #ffffff;
    border-radius: 0.6rem;
    font-size: 1.25rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.pdp-drawer-trigger__cta svg {
    width: 1.6rem;
    height: 1.6rem;
}

/* ==========================================================================
   4. Right-Hand Slide-Over Drawer (Native <dialog> + CSS Scroll Snap)
   ========================================================================== */
dialog.pdp-drawer:modal {
    overscroll-behavior: contain;
}

dialog.pdp-drawer::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background: #0f172a;
    opacity: calc(var(--drawer-backdrop, 0) * 0.55);
}

.pdp-drawer {
    --drawer-width: min(48rem, 88dvw, calc(100dvw - 24px));
    --drawer-backdrop: 0;
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    overflow: visible;
}

.pdp-drawer__scroller {
    position: relative;
    display: grid;
    /* Spacer on the left (100% viewport = closed stop), Sheet on the right */
    grid-template-columns: 100% var(--drawer-width);
    width: 100%;
    height: 100svh;
    overflow-x: scroll;
    overflow-y: hidden;
    overscroll-behavior: none;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
}

.pdp-drawer__scroller::-webkit-scrollbar {
    display: none;
}

@media (prefers-reduced-motion: no-preference) {
    .pdp-drawer__scroller {
        scroll-behavior: smooth;
    }
}

.pdp-drawer__scroller::before {
    content: '';
    scroll-snap-align: start;
    scroll-initial-target: nearest;
}

.pdp-drawer__sheet {
    display: flex;
    flex-direction: column;
    height: 100svh;
    background: #ffffff;
    color: #0f172a;
    box-shadow: -12px 0 36px rgba(15, 23, 42, 0.22);
    scroll-snap-align: end;
    overflow: hidden;
}

@supports (animation-timeline: scroll()) {
    @property --drawer-backdrop {
        syntax: '<number>';
        inherits: true;
        initial-value: 0;
    }

    .pdp-drawer {
        timeline-scope: --drawer-fade;
        animation: fade-pdp-drawer-backdrop linear both;
        animation-timeline: --drawer-fade;
    }

    .pdp-drawer__scroller {
        scroll-timeline: --drawer-fade x;
    }

    @keyframes fade-pdp-drawer-backdrop {
        0% { --drawer-backdrop: 0; }
        100% { --drawer-backdrop: 1; }
    }
}

.pdp-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.2rem;
    padding: 1.8rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.pdp-drawer__title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
}

.pdp-drawer__subtitle {
    margin: 0.3rem 0 0;
    font-size: 1.25rem;
    color: #64748b;
}

.pdp-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 3.8rem;
    min-block-size: 3.8rem;
    padding: 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.8rem;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
}

.pdp-drawer__close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.pdp-drawer__close:focus-visible {
    outline: 2.5px solid #15803d;
    outline-offset: 2px;
}

.pdp-drawer__close svg {
    width: 2rem;
    height: 2rem;
}

.pdp-drawer__search-bar {
    padding: 1.2rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    flex-shrink: 0;
}

.pdp-drawer__search-input {
    width: 100%;
    height: 4.2rem;
    padding: 0 1.4rem;
    font-size: 1.4rem;
    color: #0f172a;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 0.8rem;
    box-sizing: border-box;
}

.pdp-drawer__search-input:focus {
    outline: 2px solid #16a34a;
    border-color: #16a34a;
    background: #ffffff;
}

.pdp-drawer__body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.4rem 2rem 2.4rem;
}

.pdp-drawer__list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pdp-drawer__item {
    margin: 0;
    padding: 0;
}

.pdp-drawer__item[hidden] {
    display: none !important;
}

.pdp-drawer-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    padding: 1.2rem 1.4rem;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 1rem;
    text-decoration: none;
    color: #0f172a;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.pdp-drawer-card:hover {
    border-color: #65a30d;
    background: #f8fafc;
    text-decoration: none;
}

.pdp-drawer-card:focus-visible {
    outline: 2.5px solid #15803d;
    outline-offset: 2px;
}

.pdp-drawer-card.is-current {
    border-color: #16a34a;
    background: #f0fdf4;
    box-shadow: 0 0 0 1px #16a34a;
}

.pdp-drawer-card__thumb {
    width: 5.2rem;
    height: 5.2rem;
    border-radius: 0.6rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.pdp-drawer-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pdp-drawer-card__info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    flex: 1 1 auto;
}

.pdp-drawer-card__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.pdp-drawer-card__label {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.pdp-drawer-card__selected-tag {
    font-size: 1.1rem;
    font-weight: 700;
    color: #166534;
    background: #dcfce7;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
}

.pdp-drawer-card__ref {
    font-size: 1.2rem;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.pdp-drawer-card__pricing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    text-align: right;
    flex-shrink: 0;
}

.pdp-drawer-card__price-main {
    font-size: 1.45rem;
    font-weight: 800;
    color: #0f172a;
}

.pdp-drawer-card__price-sub {
    font-size: 1.15rem;
    color: #475569;
}

.pdp-drawer-card__price-sub--stock {
    color: #166534;
    font-weight: 600;
}

.pdp-drawer__empty {
    margin: 2rem 0;
    text-align: center;
    font-size: 1.4rem;
    color: #64748b;
}

/* ==========================================================================
   5. Below-the-Fold Comparative Variants Table (`#product-variants-table`)
   ========================================================================== */
.product-variants-section {
    margin: 2.4rem 0 4rem;
}

.product-variants-section .block__container {
    max-width: 128rem;
    display: block;
}

.product-variants-section__header {
    margin-bottom: 1.4rem;
}

.product-variants-section__heading {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.4rem;
}

.product-variants-section__note {
    font-size: 1.3rem;
    color: #64748b;
    margin: 0;
}

.product-variants-table__wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #ffffff;
}

.product-variants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.35rem;
    text-align: left;
}

.product-variants-table thead th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    padding: 1.2rem 1.4rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.product-variants-table tbody th,
.product-variants-table tbody td {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.product-variants-table__row:last-child th,
.product-variants-table__row:last-child td {
    border-bottom: 0;
}

.product-variants-table__row:hover {
    background-color: #f8fafc;
}

.product-variants-table__row.is-current {
    background-color: #f0fdf4;
}

.product-variants-table__variant-link {
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
}

.product-variants-table__variant-link:hover {
    color: #166534;
    text-decoration: underline;
}

.product-variants-table__ref code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.25rem;
    background: #f1f5f9;
    padding: 0.25rem 0.6rem;
    border-radius: 0.4rem;
    color: #334155;
}

.product-variants__badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
}

.product-variants__badge--cart {
    background: #dcfce7;
    color: #166534;
}

.product-variants__badge--quote {
    background: #f1f5f9;
    color: #475569;
}

.product-variants__current-tag {
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #166534;
}

.product-variants-table__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.4rem;
    padding: 0.5rem 1.2rem;
    border: 1px solid #16a34a;
    border-radius: 0.6rem;
    background: #ffffff;
    color: #166534;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.product-variants-table__cta:hover {
    background: #16a34a;
    color: #ffffff;
    text-decoration: none;
}

/* Mobile stacked table (`< 48em`) */
@media (max-width: 47.99em) {
    .product-variants-table__wrapper {
        border: 0;
        background: transparent;
        overflow-x: visible;
    }

    .product-variants-table,
    .product-variants-table tbody {
        display: block;
    }

    .product-variants-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .product-variants-table__row {
        display: block;
        border: 1px solid #e2e8f0;
        border-radius: 1rem;
        margin-bottom: 1rem;
        padding: 1.2rem;
        background: #ffffff;
    }

    .product-variants-table tbody th.product-variants-table__variant {
        display: block;
        padding: 0 0 0.8rem;
        margin-bottom: 0.6rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: 1.5rem;
    }

    .product-variants-table tbody td {
        display: grid;
        grid-template-columns: 10rem 1fr;
        gap: 0.8rem;
        padding: 0.45rem 0;
        border-bottom: 0;
    }

    .product-variants-table__ref::before { content: var(--col-ref); font-weight: 600; color: #64748b; }
    .product-variants-table__name::before { content: var(--col-name); font-weight: 600; color: #64748b; }
    .product-variants-table__avail::before { content: var(--col-avail); font-weight: 600; color: #64748b; }
    .product-variants-table__action::before { content: var(--col-action); font-weight: 600; color: #64748b; }
}
