/* ============================================
   lovable.dev - Victorian Instrument Catalog
   Deep Burgundy Chamber with Crystalline Motifs
   ============================================ */

/* --- Palette Reference ---
   #1A0A12 - Claret Darkness (Primary Background)
   #2A1520 - Mahogany Shadow (Secondary Background)
   #5C1A2A - Garnet Depth (Accent Surface)
   #F2E8DC - Aged Parchment (Primary Text)
   #C4A882 - Warm Brass (Secondary Text)
   #8B6F5E - Antique Bronze (Ornamental Lines)
   #B8736A - Rose Gold (Accent Highlight)
   #6B5548 - Deep Walnut (Deep Accent)
   #E8D5C4 - Facet White (Crystal Flash)
   --- */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #1A0A12;
    color: #F2E8DC;
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
.section-heading {
    font-family: 'Oswald', 'Arial Narrow', sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    color: #F2E8DC;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.section-label {
    font-family: 'Yanone Kaffeesatz', 'Arial Narrow', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: #8B6F5E;
    margin-bottom: 0.75rem;
}

.body-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: #C4A882;
    max-width: 38em;
    margin-bottom: 1.25rem;
}

.caption-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    color: #6B5548;
    margin-top: 1rem;
}

/* --- Threshold Title (Hero) --- */
.threshold-title {
    font-family: 'Oswald', 'Arial Narrow', sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #F2E8DC;
    position: absolute;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 5;
}

.threshold-title .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.threshold-title .char.visible {
    opacity: 1;
}

/* --- Exhibition Sections --- */
.exhibition-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* --- Crystal Lattice Background --- */
.crystal-lattice-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(30deg, rgba(139, 111, 94, 0.03) 1px, transparent 1px),
        linear-gradient(150deg, rgba(139, 111, 94, 0.03) 1px, transparent 1px),
        linear-gradient(270deg, rgba(139, 111, 94, 0.02) 1px, transparent 1px);
    background-size: 80px 140px, 80px 140px, 120px 120px;
    background-position: 0 0, 40px 70px, 20px 20px;
}

/* --- Ornamental Frame (Full Section) --- */
.ornamental-frame {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    z-index: 1;
    pointer-events: none;
}

.ornamental-frame .frame-line {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
}

.ornamental-frame.frame-animate .frame-line {
    animation: drawFrame 3s cubic-bezier(0.25, 0.1, 0.25, 1.0) forwards;
}

.ornamental-frame .frame-rosette {
    opacity: 0;
}

.ornamental-frame.frame-animate .frame-rosette {
    animation: fadeInRosette 0.5s cubic-bezier(0.25, 0.1, 0.25, 1.0) 2.8s forwards;
}

@keyframes drawFrame {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes fadeInRosette {
    to {
        opacity: 1;
    }
}

/* --- Inline Ornamental Frames (Content Containers) --- */
.ornamental-frame-inline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.ornamental-frame-inline .frame-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s linear;
}

.reveal-element.revealed .ornamental-frame-inline .frame-line {
    stroke-dashoffset: 0;
}

/* --- Content Islands --- */
.content-island {
    position: relative;
    max-width: 55vw;
    padding: 3rem 3.5rem;
    z-index: 2;
}

/* --- Ornamental Rules --- */
.ornamental-rule {
    width: 100%;
    max-width: 200px;
    margin: 1rem 0 1.5rem;
}

.ornamental-rule svg {
    width: 100%;
    height: auto;
}

.chamber-rule {
    max-width: 300px;
    margin: 1.5rem auto;
}

/* --- Scroll Progress Indicator --- */
#scroll-indicator {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

#scroll-indicator:hover {
    opacity: 1;
}

#scroll-indicator svg {
    animation: pulseIndicator 3s cubic-bezier(0.25, 0.1, 0.25, 1.0) infinite;
}

@keyframes pulseIndicator {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

#scroll-progress-fill {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 0%;
    background: #B8736A;
    transition: height 0.2s linear;
    max-height: 36px;
}

/* --- Navigation Overlay --- */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2A1520;
    background: rgba(42, 21, 32, 0.96);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.nav-overlay-content {
    position: relative;
    width: 400px;
    max-width: 90vw;
    padding: 3rem;
}

.nav-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}

.nav-link {
    font-family: 'Yanone Kaffeesatz', 'Arial Narrow', sans-serif;
    font-weight: 400;
    font-size: 1.3rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #C4A882;
    text-decoration: none;
    transition: color 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    padding: 0.25rem 0;
}

.nav-link:hover {
    color: #E8D5C4;
}

/* ===========================================
   SECTION 1: THE THRESHOLD
   =========================================== */
.threshold-section {
    background-color: #1A0A12;
    flex-direction: column;
}

.threshold-crystal {
    position: relative;
    width: clamp(180px, 25vw, 300px);
    height: clamp(180px, 25vw, 300px);
    z-index: 3;
    margin-top: -5vh;
}

.threshold-crystal .crystal-svg {
    width: 100%;
    height: 100%;
    animation: rotateCrystal 30s linear infinite;
}

@keyframes rotateCrystal {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===========================================
   SECTION 2: THE VITRINE HALL
   =========================================== */
.vitrine-section {
    background-color: #1A0A12;
}

.vitrine-content {
    text-align: left;
}

.vitrine-text {
    position: relative;
    z-index: 1;
}

/* Crystal shards */
.crystal-shards {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.shard {
    position: absolute;
    opacity: 0;
    transition: opacity 1s cubic-bezier(0.25, 0.1, 0.25, 1.0), transform 1s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.vitrine-section.in-view .shard {
    opacity: 1;
}

.shard-1 {
    top: 5%;
    left: 3%;
    width: 80px;
    transform: rotate(-15deg) translate(-20px, -20px);
}
.vitrine-section.in-view .shard-1 {
    transform: rotate(-15deg) translate(0, 0);
}

.shard-2 {
    top: 15%;
    right: 5%;
    width: 60px;
    transform: rotate(25deg) translate(20px, -10px);
}
.vitrine-section.in-view .shard-2 {
    transform: rotate(25deg) translate(0, 0);
}

.shard-3 {
    bottom: 20%;
    left: 6%;
    width: 90px;
    transform: rotate(-40deg) translate(-15px, 15px);
}
.vitrine-section.in-view .shard-3 {
    transform: rotate(-40deg) translate(0, 0);
}

.shard-4 {
    bottom: 10%;
    right: 4%;
    width: 70px;
    transform: rotate(10deg) translate(20px, 20px);
}
.vitrine-section.in-view .shard-4 {
    transform: rotate(10deg) translate(0, 0);
}

.shard-5 {
    top: 40%;
    left: 2%;
    width: 50px;
    transform: rotate(35deg) translate(-25px, 0);
}
.vitrine-section.in-view .shard-5 {
    transform: rotate(35deg) translate(0, 0);
}

.shard-6 {
    top: 50%;
    right: 3%;
    width: 65px;
    transform: rotate(-20deg) translate(25px, 0);
}
.vitrine-section.in-view .shard-6 {
    transform: rotate(-20deg) translate(0, 0);
}

/* ===========================================
   SECTION 3: THE INSTRUMENT ROOM
   =========================================== */
.instrument-section {
    background-color: #1A0A12;
}

.instrument-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5vw;
    width: 85%;
    max-width: 1200px;
    z-index: 2;
    position: relative;
}

.tilt-crystal-container {
    flex: 0 0 auto;
    width: clamp(250px, 30vw, 400px);
    height: clamp(250px, 30vw, 400px);
    perspective: 1000px;
    cursor: grab;
}

.tilt-crystal-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
    transition: transform 0.1s linear;
    transform: perspective(1000px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
}

.interactive-crystal-svg {
    width: 100%;
    height: 100%;
}

.refraction-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.refraction-line {
    position: absolute;
    width: 200%;
    height: 1px;
    transform-origin: center center;
    opacity: 0;
    transition: opacity 0.3s linear;
}

.instrument-content {
    flex: 1;
    max-width: 500px;
}

.instrument-text {
    position: relative;
    z-index: 1;
}

/* ===========================================
   SECTION 4: THE ARCHIVE
   =========================================== */
.archive-section {
    background-color: #1A0A12;
    min-height: 100vh;
    padding: 10vh 0;
    border-top: 1px solid #5C1A2A;
    border-bottom: 1px solid #5C1A2A;
}

.archive-frames {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4vw;
    width: 70%;
    max-width: 900px;
    z-index: 2;
    position: relative;
}

.archive-frame {
    position: relative;
    padding: 2rem 2.5rem;
}

.archive-frame.frame-1 {
    transform: translateY(2vh);
}

.archive-frame.frame-2 {
    transform: translateY(-2vh);
}

.archive-frame.frame-3 {
    transform: translateY(3vh);
}

.archive-frame.frame-4 {
    transform: translateY(-1vh);
}

.archive-text {
    position: relative;
    z-index: 1;
}

.archive-text .body-text {
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
}

/* Abstract shape compositions */
.abstract-shapes {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.archive-shapes {
    bottom: 8%;
    right: 5%;
    width: 200px;
    height: 200px;
    opacity: 0.5;
}

.shape-composition {
    width: 100%;
    height: 100%;
}

/* ===========================================
   SECTION 5: THE INNER CHAMBER
   =========================================== */
.chamber-section {
    background-color: #1A0A12;
    flex-direction: column;
    gap: 3rem;
}

.chamber-crystal-cluster {
    position: relative;
    width: clamp(280px, 35vw, 450px);
    height: clamp(280px, 35vw, 450px);
    z-index: 2;
}

.cluster-svg {
    width: 100%;
    height: 100%;
}

.chamber-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.chamber-statement {
    font-family: 'Oswald', 'Arial Narrow', sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: #F2E8DC;
    margin-bottom: 1rem;
}

/* Domain seal */
.domain-seal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.seal-svg {
    width: 80px;
    height: 80px;
}

.seal-text {
    font-family: 'Oswald', 'Arial Narrow', sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.9rem;
    color: #8B6F5E;
}

/* ===========================================
   TRANSITION BANDS
   =========================================== */
.transition-band {
    position: relative;
    height: 30vh;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1A0A12;
    overflow: hidden;
}

.filigree-svg {
    width: 100%;
    height: 100%;
    max-height: 200px;
}

.filigree-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s linear;
}

.transition-band.in-view .filigree-line {
    stroke-dashoffset: 0;
}

/* ===========================================
   REVEAL ANIMATION
   =========================================== */
.reveal-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0), transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.reveal-element.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 900px) {
    .instrument-layout {
        flex-direction: column;
        gap: 3rem;
    }

    .instrument-content {
        max-width: 90vw;
    }

    .content-island {
        max-width: 85vw;
        padding: 2rem;
    }

    .archive-frames {
        grid-template-columns: 1fr;
        width: 85%;
    }

    .archive-frame {
        transform: none !important;
    }

    .ornamental-frame {
        top: 2%;
        left: 2%;
        width: 96%;
        height: 96%;
    }

    .tilt-crystal-container {
        width: 250px;
        height: 250px;
    }
}

@media (max-width: 600px) {
    .threshold-title {
        letter-spacing: 0.12em;
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .content-island {
        max-width: 92vw;
        padding: 1.5rem;
    }

    .archive-frames {
        width: 92%;
        gap: 2rem;
    }

    .chamber-crystal-cluster {
        width: 250px;
        height: 250px;
    }
}
