/* ==========================================================================
   SCROLL-DRIVEN FURNITURE ASSEMBLY
   Axonometric exploded-view animation triggered by scroll position.
   Designed for reuse — any SVG with .assembly-comp and .assembly-layer
   groups + data-* attributes will work.
   ========================================================================== */

/* --------------------------------------------------------------------------
   SCROLL CONTAINER — creates the scroll runway (5 screens)
   -------------------------------------------------------------------------- */

.assembly-scroll {
    position: relative;
    height: 500vh;
}

.assembly-viewport {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.assembly-viewport__inner {
    position: relative;
    width: min(70vw, 600px);
    height: min(85vh, 900px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --------------------------------------------------------------------------
   SVG DEFAULTS — initial assembled state (no-JS fallback)
   -------------------------------------------------------------------------- */

.assembly-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.assembly-comp {
    transition: transform 0.05s linear, opacity 0.05s linear;
    will-change: transform, opacity;
}

.assembly-layer {
    opacity: 0;
    transition: opacity 0.05s linear;
    will-change: opacity;
}

/* No-JS: show everything assembled, all annotations visible */
.no-js .assembly-comp {
    transform: translate(0, 0) !important;
    opacity: 1 !important;
}

.no-js .assembly-layer {
    opacity: 1 !important;
}

.no-js .assembly-layer[data-phase="labels"],
.no-js .assembly-layer[data-phase="dimensions"],
.no-js .assembly-layer[data-phase="joinery"] {
    opacity: 0 !important;
}

.no-js .assembly-layer[data-phase="completion"] {
    opacity: 1 !important;
}

/* --------------------------------------------------------------------------
   PROGRESS INDICATOR — thin line along left edge
   -------------------------------------------------------------------------- */

.assembly-progress {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.assembly-progress__bar {
    width: 100%;
    height: 0%;
    background: var(--accent-warm, #c8956c);
    transition: height 0.05s linear;
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   SECTION FRAMING — text above/below the assembly
   -------------------------------------------------------------------------- */

.assembly-section {
    padding: 0;
}

.assembly-header {
    text-align: center;
    padding: var(--section-gap, 6rem) 1.5rem 2rem;
}

.assembly-header__title {
    font-family: var(--font-heading, 'Cormorant Garamond', serif);
    font-size: 2.4rem;
    font-weight: 300;
    color: var(--text-primary, #e8e4df);
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.assembly-header__subtitle {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.95rem;
    color: var(--text-secondary, #9a958e);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.7;
}

/* --------------------------------------------------------------------------
   HERO MODE — background assembly, subtle, non-interactive
   -------------------------------------------------------------------------- */

.assembly-scroll--hero {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.assembly-scroll--hero .assembly-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.assembly-scroll--hero .assembly-viewport__inner {
    width: min(50vw, 500px);
    height: min(70vh, 700px);
    opacity: 0.15;
}

/* Hide annotations in hero mode */
.assembly-scroll--hero .assembly-layer {
    display: none;
}

.assembly-scroll--hero .assembly-progress {
    display: none;
}

/* --------------------------------------------------------------------------
   JOINERY ZOOM — SVG transform during phase 3
   -------------------------------------------------------------------------- */

.assembly-svg[data-zoomed="true"] {
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* --------------------------------------------------------------------------
   CSS SCROLL-DRIVEN ANIMATIONS (Chrome 115+, Safari 18+)
   Progressive enhancement — JS handles Firefox
   -------------------------------------------------------------------------- */

@supports (animation-timeline: scroll()) {
    .assembly-scroll {
        timeline-scope: --assembly-scroll;
    }

    .assembly-scroll {
        scroll-timeline: --assembly-scroll block;
    }
}

/* --------------------------------------------------------------------------
   RESPONSIVE — MOBILE
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .assembly-scroll {
        height: 300vh;
    }

    .assembly-viewport__inner {
        width: min(90vw, 400px);
        height: min(70vh, 600px);
    }

    /* Hide dimension + label layers on mobile — too small to read */
    .assembly-layer[data-phase="dimensions"],
    .assembly-layer[data-phase="labels"] {
        display: none;
    }

    .assembly-header__title {
        font-size: 1.8rem;
    }

    .assembly-header__subtitle {
        font-size: 0.85rem;
    }

    .assembly-scroll--hero .assembly-viewport__inner {
        width: min(80vw, 300px);
        opacity: 0.1;
    }
}

@media (max-width: 480px) {
    .assembly-scroll {
        height: 250vh;
    }

    .assembly-viewport__inner {
        width: 92vw;
        height: 60vh;
    }
}

/* --------------------------------------------------------------------------
   REDUCED MOTION — show fully assembled, no animation
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .assembly-scroll {
        height: auto !important;
    }

    .assembly-viewport {
        position: relative !important;
        height: auto !important;
        min-height: 80vh;
    }

    .assembly-comp {
        transform: translate(0, 0) !important;
        opacity: 1 !important;
        transition: none !important;
    }

    .assembly-layer {
        transition: none !important;
    }

    .assembly-layer[data-phase="completion"] {
        opacity: 1 !important;
    }

    .assembly-layer[data-phase="dimensions"],
    .assembly-layer[data-phase="labels"],
    .assembly-layer[data-phase="joinery"] {
        opacity: 0 !important;
    }

    .assembly-progress {
        display: none;
    }
}
