/* =============================================
   Sparsh — Mattress Layer Visualizer
   Full-viewport modal that opens on demand,
   placed directly over the page background
   (no separate card / panel inside).
   ============================================= */

/* ---- Hide the legacy explainer CTA — replaced by .view-inside-btn ---- */
.explainer-cta {
    display: none !important;
}

/* Disable click-to-explode on the explainer mattress image so it doesn't
   compete with the new visualizer modal. The image, hover lift, and
   cover label stay visible — only the click handler is short-circuited. */
.explainer .explainer-mattress {
    cursor: default !important;
}
.explainer .explainer-mattress,
.explainer .explainer-cover-label {
    pointer-events: none;
}

/* ---- Centered variant when the button sits under the product image ---- */
.view-inside-btn--centered {
    display: inline-flex;
    margin: 28px auto 0;
}

/* The image side needs to be a column so the centered button can sit below */
.hero-image-side {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---- Trigger button on the PDP ---- */
.view-inside-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.86rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition:
        transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        background 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.4s ease;
    text-decoration: none;
}

.view-inside-btn i {
    color: var(--accent-gold, #61B564);
    font-size: 1rem;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.view-inside-btn:hover {
    transform: translateY(-2px);
    background: rgba(97, 181, 100, 0.08);
    border-color: rgba(97, 181, 100, 0.45);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.view-inside-btn:hover i {
    transform: translateX(2px) scale(1.08);
}

/* ---- Modal shell ---- */
.lv-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    pointer-events: none;
    /* No card / panel — modal sits directly on the page background.
       The dim layer just deepens the existing aurora behind it. */
}

.lv-modal.is-open {
    display: block;
    pointer-events: auto;
}

.lv-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 6, 14, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.lv-modal.is-open .lv-modal-backdrop {
    opacity: 1;
}

/* ---- Modal stage (no inner card — content sits on the dim) ---- */
.lv-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "canvas panel";
    column-gap: 48px;
    padding: 80px 64px 56px;
    box-sizing: border-box;
    opacity: 0;
    transform: translateY(20px);
    transition:
        opacity 0.55s ease,
        transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lv-modal.is-open .lv-stage {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Header (title + tagline + close) ---- */
.lv-header {
    grid-area: header;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.lv-header-text {
    flex: 1;
}

.lv-eyebrow {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-gold, #61B564);
    margin-bottom: 10px;
}

.lv-title {
    font-family: 'Inter', sans-serif;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    font-style: italic;
    letter-spacing: -0.01em;
    color: #fff;
    margin: 0 0 4px;
    line-height: 1.15;
}

.lv-tagline {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.lv-close {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.lv-close:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(90deg);
}

/* ---- 3D canvas area ---- */
.lv-canvas-wrap {
    grid-area: canvas;
    position: relative;
    min-height: 0;
}

.lv-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

.lv-fallback-mode .lv-canvas,
.lv-fallback-mode .lv-tooltip {
    display: none;
}

.lv-fallback-stack {
    position: absolute;
    inset: 14% 12%;
    transform: translateY(-6%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
}

.lv-fallback-layer {
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
        var(--layer-color, #7aa6b3);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
    display: grid;
    place-items: center;
    text-align: center;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0;
    padding: 6px 12px;
}

.lv-canvas:active {
    cursor: grabbing;
}

.lv-instruction {
    position: absolute;
    bottom: 18px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.lv-instruction i {
    margin: 0 4px;
    color: var(--accent-gold, #61B564);
}

.lv-instruction.is-fading {
    opacity: 0;
}

/* Floating tooltip projected from a layer's 3D position */
.lv-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(97, 181, 100, 0.35);
    padding: 12px 16px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    color: #fff;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translate(-50%, -110%) translateY(6px);
    transition: opacity 0.2s ease, transform 0.25s ease;
    white-space: nowrap;
    z-index: 5;
}

.lv-tooltip.is-visible {
    opacity: 1;
    transform: translate(-50%, -110%);
}

.lv-tooltip-name {
    font-size: 0.92rem;
    font-weight: 600;
    margin: 0 0 2px;
}

.lv-tooltip-meta {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.62);
    margin: 0;
}

/* ---- Side panel: layer list with functions ---- */
.lv-panel {
    grid-area: panel;
    overflow-y: auto;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-content: start;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.lv-panel::-webkit-scrollbar { width: 6px; }
.lv-panel::-webkit-scrollbar-track { background: transparent; }
.lv-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 4px;
}

.lv-panel-heading {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-gold, #61B564);
    margin: 0 0 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lv-row {
    display: flex;
    gap: 14px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
    transition: all 0.3s ease;
    align-items: flex-start;
}

.lv-row:hover,
.lv-row.is-active {
    border-color: rgba(97, 181, 100, 0.5);
    background: rgba(97, 181, 100, 0.06);
    transform: translateX(2px);
}

.lv-row-swatch {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 6px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.lv-row-body {
    flex: 1;
    min-width: 0;
}

.lv-row-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.lv-row-thickness {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.lv-row-material {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    margin: 0 0 8px;
}

.lv-row-function {
    font-family: 'Inter', sans-serif;
    font-size: 0.86rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.78);
    margin: 0;
}

/* ---- Expand/collapse toggle ---- */
.lv-expand-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 10px 18px;
    background: rgba(97, 181, 100, 0.1);
    border: 1px solid rgba(97, 181, 100, 0.4);
    color: var(--accent-gold, #61B564);
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    align-self: flex-start;
    transition: all 0.3s ease;
}

.lv-expand-toggle:hover {
    background: rgba(97, 181, 100, 0.18);
    color: #fff;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .lv-stage {
        padding: 64px 40px 40px;
        column-gap: 32px;
    }
}

@media (max-width: 880px) {
    .lv-stage {
        grid-template-columns: 1fr;
        grid-template-rows: auto 320px 1fr;
        grid-template-areas:
            "header"
            "canvas"
            "panel";
        padding: 56px 22px 28px;
        row-gap: 24px;
    }
    .lv-header {
        margin-bottom: 0;
    }
    .lv-canvas-wrap {
        min-height: 320px;
    }
    .lv-panel {
        max-height: 100%;
    }
}

/* Narrow phones (iPhone SE / 13 mini at 375px and below) — tighter
   padding, smaller canvas so the layer list below stays scrollable. */
@media (max-width: 420px) {
    .lv-stage {
        grid-template-rows: auto 240px 1fr;
        padding: 44px 14px 18px;
        row-gap: 16px;
    }
    .lv-canvas-wrap {
        min-height: 240px;
    }
    .lv-title {
        font-size: 1.25rem;
    }
    .lv-tagline {
        font-size: 0.78rem;
    }
    .lv-close {
        top: 10px;
        right: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lv-modal-backdrop,
    .lv-stage,
    .lv-row,
    .view-inside-btn {
        transition-duration: 0.01s;
    }
}

/* Light Mode Global Overrides */
:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-modal-backdrop {
    background: rgba(255, 255, 255, 0.98) !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    opacity: 1 !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-panel {
    background: rgba(255, 255, 255, 0.6) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-left: 1px solid rgba(0, 0, 0, 0.1) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-title {
    color: #1a1a2e !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) :is(.lv-tagline, .lv-instruction) {
    color: rgba(26, 26, 46, 0.7) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-close {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #1a1a2e !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-panel-heading {
    color: #166534 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-row {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-row-name {
    color: #1a1a2e !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) :is(.lv-row-material, .lv-row-thickness) {
    color: rgba(26, 26, 46, 0.6) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-row-function {
    color: #374151 !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-row:hover,
:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-row.is-active {
    background: #f0fdf4 !important;
    border-color: #61b564 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-tooltip {
    background: #ffffff !important;
    color: #1a1a2e !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-tooltip-meta {
    color: rgba(26, 26, 46, 0.7) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1) !important;
}

:is(body.light-mode .lv-modal, .lv-modal.light-mode) .lv-expand-toggle {
    background: #61b564 !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(97, 181, 100, 0.3) !important;
}


