/* ===================================
   renai.quest — Surreal Coastal Architecture
   Color Palette:
     Ground Dark:    #1C2D3A (Ocean Deep)
     Ground Mid:     #2A3F54 (Brine Slate)
     Ground Light:   #F0EBE3 (Driftwood Pale)
     Ground Warm:    #E2C9B3 (Bleached Sand)
     Accent Primary: #D35B3E (Coastal Ember)
     Accent Sec:     #7B9BA8 (Storm Copper)
     Accent Tert:    #A8BDC4 (Fog Line)
     Text Dark:      #0F1C26 (Ink Tide)
     Text Mid:       #3D4E5C
     Text Warm:      #C8BEAF
=================================== */

/* === CSS Custom Properties === */
:root {
    --dark-deep:    #1C2D3A;
    --dark-mid:     #2A3F54;
    --light-pale:   #F0EBE3;
    --light-warm:   #E2C9B3;
    --ember:        #D35B3E;
    --storm:        #7B9BA8;
    --fog:          #A8BDC4;
    --ink:          #0F1C26;
    --slate-mid:    #3D4E5C;
    --text-warm:    #C8BEAF;

    --font-display: 'Unbounded', sans-serif;
    --font-body:    'Barlow Condensed', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background: var(--dark-deep);
    color: var(--light-pale);
    font-family: var(--font-body);
    font-weight: 300;
    overflow-x: hidden;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

/* === Navigation === */
#nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    overflow: hidden;
}

.nav-bg {
    position: absolute;
    inset: 0;
    background: var(--dark-deep);
    transform: skewX(-6deg);
    transform-origin: left center;
    opacity: 0.92;
    width: 110%;
    left: -5%;
}

.nav-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 48px;
    z-index: 1;
}

.nav-logo {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--light-pale);
}

.nav-logo-quest {
    font-weight: 200;
    color: var(--ember);
    margin-left: 1px;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-link {
    font-family: var(--font-display);
    font-weight: 200;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--text-warm);
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--ember);
}

/* === Chamber Background Number Decoration === */
.chamber-bg-number {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 180px;
    color: var(--dark-mid);
    opacity: 0.35;
    pointer-events: none;
    user-select: none;
    writing-mode: vertical-lr;
    transform: rotate(-180deg);
    right: -20px;
    top: 50%;
    transform: rotate(-180deg) translateY(50%);
    line-height: 1;
    z-index: 0;
}

/* === Common Chamber === */
.chamber {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

/* ===================================
   CHAMBER 1: Entry Void
=================================== */
.chamber-entry {
    background: var(--dark-deep);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    clip-path: polygon(0 0, 100% 0, 100% 92%, 95% 100%, 0 100%);
}

/* Ocean texture overlay */
.entry-ocean-texture {
    position: absolute;
    inset: 0;
    background: var(--dark-deep);
    filter: url(#ocean-texture);
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

.ocean-filter-svg {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Lottie / SVG container: impossible staircase */
.entry-lottie {
    position: absolute;
    right: 8vw;
    top: 50%;
    transform: translateY(-50%);
    width: min(480px, 45vw);
    z-index: 1;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.entry-lottie.visible {
    opacity: 1;
}

.staircase-drawing {
    width: 100%;
    height: auto;
    display: block;
}

/* Domain wordmark — right-aligned, bleeds 8vw past edge */
.entry-wordmark {
    position: relative;
    z-index: 2;
    padding: 0 0 0 12vw;
    padding-top: 100px;
}

.wordmark-main {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(64px, 10vw, 96px);
    letter-spacing: -0.02em;
    color: var(--light-pale);
    text-align: right;
    margin-right: -8vw;
    line-height: 1;
}

.wordmark-suffix {
    font-family: var(--font-display);
    font-weight: 200;
    font-size: clamp(36px, 5.5vw, 56px);
    letter-spacing: 0.04em;
    color: var(--ember);
    text-align: left;
    margin-left: 2vw;
    margin-top: 8px;
    line-height: 1;
}

.entry-tagline {
    position: absolute;
    bottom: 80px;
    left: 12vw;
    z-index: 2;
}

.entry-tagline-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-warm);
}

/* Decorative slash accent line */
.entry-slash-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--ember);
    transform: rotate(-0.8deg);
    transform-origin: left center;
    z-index: 3;
}

/* Draw-on SVG animation */
.staircase-drawing .line-1 { stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: drawLine 0.6s ease forwards 0.2s; }
.staircase-drawing .line-2 { stroke-dasharray: 500; stroke-dashoffset: 500; animation: drawLine 0.5s ease forwards 0.5s; }
.staircase-drawing .line-3 { stroke-dasharray: 1100; stroke-dashoffset: 1100; animation: drawLine 0.6s ease forwards 0.7s; }
.staircase-drawing .line-4 { stroke-dasharray: 800; stroke-dashoffset: 800; animation: drawLine 0.7s ease forwards 0.9s; }
.staircase-drawing .line-5 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawLine 0.3s ease forwards 1.1s; }
.staircase-drawing .line-6 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawLine 0.3s ease forwards 1.2s; }
.staircase-drawing .line-7 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawLine 0.3s ease forwards 1.3s; }
.staircase-drawing .line-8 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawLine 0.3s ease forwards 1.4s; }
.staircase-drawing .line-9 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawLine 0.3s ease forwards 1.5s; }
.staircase-drawing .line-10 { stroke-dasharray: 500; stroke-dashoffset: 500; animation: drawLine 0.4s ease forwards 1.6s; }
.staircase-drawing .line-11 { stroke-dasharray: 500; stroke-dashoffset: 500; animation: drawLine 0.4s ease forwards 1.7s; }
.staircase-drawing .line-accent-1 { stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawLine 0.3s ease forwards 2.0s; }
.staircase-drawing .line-accent-2 { stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawLine 0.3s ease forwards 2.1s; }

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

/* ===================================
   CHAMBER 2: Broken Statement
=================================== */
.chamber-statement {
    background: var(--light-pale);
    min-height: 80vh;
    display: flex;
    align-items: center;
    padding: 80px 0;
    clip-path: polygon(0 8%, 100% 0, 100% 100%, 0 100%);
    margin-top: -80px;
    position: relative;
    z-index: 2;
}

.chamber-statement .chamber-bg-number {
    color: var(--light-warm);
    opacity: 0.5;
}

/* Three staggered background rectangles */
.stmt-rect {
    position: absolute;
    background: var(--dark-mid);
    pointer-events: none;
    z-index: 0;
}

.stmt-rect-1 {
    width: 280px;
    height: 200px;
    top: 15%;
    left: -40px;
    transform: rotate(4deg);
    opacity: 0.18;
}

.stmt-rect-2 {
    width: 220px;
    height: 160px;
    top: 30%;
    left: 80px;
    transform: rotate(8deg);
    opacity: 0.12;
}

.stmt-rect-3 {
    width: 180px;
    height: 260px;
    top: 20%;
    left: 160px;
    transform: rotate(-6deg);
    opacity: 0.1;
}

/* Overflow marquee statement */
.stmt-overflow-container {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    overflow: hidden;
    z-index: 1;
    transform: translateY(-50%);
    pointer-events: none;
}

.stmt-marquee-text {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(36px, 5.5vw, 64px);
    color: var(--slate-mid);
    opacity: 0.1;
    white-space: nowrap;
    width: 140%;
    position: relative;
    left: -5%;
    line-height: 1.1;
}

/* Body text column — at left: 22% */
.stmt-body-col {
    position: relative;
    z-index: 2;
    left: 22%;
    width: 340px;
    padding: 20px 0;
}

.stmt-body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.65;
    color: var(--slate-mid);
    margin-bottom: 24px;
}

/* Decorative rotated rule line */
.stmt-rule-line {
    position: absolute;
    bottom: 60px;
    right: 10%;
    width: 200px;
    height: 2px;
    background: var(--ember);
    transform: rotate(-12deg);
    transform-origin: right center;
    z-index: 2;
}

/* ===================================
   CHAMBER 3: Grid-Shatter Gallery
=================================== */
.chamber-gallery {
    background: var(--dark-deep);
    min-height: 120vh;
    padding: 100px 48px 80px;
    clip-path: polygon(0 0, 100% 5%, 100% 100%, 0 95%);
    margin-top: -60px;
    position: relative;
    z-index: 3;
}

.gallery-header {
    position: relative;
    z-index: 2;
    margin-bottom: 60px;
    padding-left: 4vw;
}

.gallery-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: -0.02em;
    color: var(--light-pale);
}

/* Shatter grid — asymmetric column sizes */
.gallery-grid {
    display: grid;
    grid-template-columns: 2.3fr 1fr 1.7fr;
    grid-template-rows: auto auto;
    gap: 24px;
    position: relative;
    z-index: 2;
    padding: 0 2vw;
}

.gallery-cell {
    background: var(--dark-mid);
    padding: 24px;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

/* Odd cells light, even cells dark for alternating stroke */
.gallery-cell-1,
.gallery-cell-3,
.gallery-cell-5 {
    background: var(--dark-mid);
}

.gallery-cell-2,
.gallery-cell-4,
.gallery-cell-6 {
    background: var(--light-warm);
}

/* Grid cell placement */
.gallery-cell-1 { grid-column: 1; grid-row: 1; }
.gallery-cell-2 { grid-column: 2; grid-row: 1; }
.gallery-cell-3 { grid-column: 3; grid-row: 1; }
.gallery-cell-4 { grid-column: 1; grid-row: 2; }
.gallery-cell-5 { grid-column: 2 / 4; grid-row: 2; }
.gallery-cell-6 { grid-column: 1; grid-row: 2; display: none; } /* redistributed */

/* Actually lay out 6 cells differently */
.gallery-grid {
    grid-template-columns: 2.3fr 1fr 1.7fr;
}

.gallery-cell-4 { grid-column: 1; grid-row: 2; }
.gallery-cell-5 { grid-column: 2; grid-row: 2; }
.gallery-cell-6 { grid-column: 3; grid-row: 2; display: block; }

/* Hover tilt */
.gallery-cell:hover {
    z-index: 10;
}

.gallery-cell-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 8px;
}

.gallery-svg {
    width: 100%;
    max-height: 200px;
    height: auto;
    display: block;
}

/* Cell 4 (light background) - dark strokes */
.gallery-cell-2 .gallery-svg g,
.gallery-cell-4 .gallery-svg g,
.gallery-cell-6 .gallery-svg g {
    stroke: var(--ink);
}

.gallery-label {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-warm);
    text-align: center;
}

.gallery-cell-2 .gallery-label,
.gallery-cell-4 .gallery-label,
.gallery-cell-6 .gallery-label {
    color: var(--slate-mid);
}

/* Gallery draw-on animations (triggered by JS intersection observer) */
.gallery-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.2s ease;
}

.gallery-cell.in-view .gallery-draw {
    stroke-dashoffset: 0;
}

/* ===================================
   CHAMBER 4: Text-Dense Manifesto
=================================== */
.chamber-manifesto {
    background: var(--light-pale);
    min-height: 60vh;
    padding: 100px 48px 80px;
    clip-path: polygon(0 0, 100% 8%, 100% 88%, 12% 100%);
    margin-top: -60px;
    position: relative;
    z-index: 4;
}

.chamber-manifesto .chamber-bg-number {
    color: var(--light-warm);
    opacity: 0.5;
}

.manifesto-layout {
    display: grid;
    grid-template-columns: 68% 52%;
    position: relative;
    z-index: 2;
    /* columns overlap by 20% */
    margin-left: -8vw;
}

.manifesto-col-1 {
    grid-column: 1;
    padding-right: 40px;
}

.manifesto-col-2 {
    grid-column: 2;
    margin-left: -15%;
    padding-top: 80px;
}

.manifesto-heading {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(28px, 3.5vw, 40px);
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.1;
    margin-bottom: 32px;
}

/* Overlap zone — most important line in ember */
.manifesto-overlap-zone {
    position: relative;
    z-index: 3;
    margin: 0 -60px 32px 0;
}

.manifesto-overlap-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    letter-spacing: -0.01em;
    color: var(--ember);
    line-height: 1.2;
}

.manifesto-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 16px;
    line-height: 1.7;
    color: var(--slate-mid);
    margin-bottom: 20px;
}

.manifesto-body-col2 {
    color: var(--dark-mid);
}

.manifesto-pullquote {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 600;
    font-size: 22px;
    line-height: 1.4;
    color: var(--dark-deep);
    border-left: 3px solid var(--ember);
    padding-left: 20px;
    margin-top: 32px;
}

/* Sharp 45° background clip decoration */
.manifesto-clip-bg {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 40%;
    height: 100%;
    background: var(--light-warm);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    z-index: 0;
    opacity: 0.5;
}

.manifesto-rule-accent {
    position: absolute;
    top: 40%;
    right: 5%;
    width: 160px;
    height: 2px;
    background: var(--ember);
    transform: rotate(9deg);
    z-index: 2;
}

/* ===================================
   CHAMBER 5: Exit Frame
=================================== */
.chamber-exit {
    background: var(--dark-deep);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 48px;
    clip-path: polygon(5% 0, 95% 5%, 100% 100%, 0 100%);
    margin-top: -60px;
    position: relative;
    z-index: 5;
}

.exit-bg-number {
    right: auto;
    left: 50%;
    transform: translateX(-50%) rotate(-90deg);
    top: 20px;
    writing-mode: horizontal-tb;
    font-size: 120px;
    opacity: 0.15;
}

/* Lottie arc container */
.exit-arc-container {
    width: min(500px, 50vw);
    height: auto;
    position: relative;
    margin-bottom: 60px;
    z-index: 2;
    opacity: 0;
    transition: opacity 1.4s ease;
}

.exit-arc-container.visible {
    opacity: 1;
}

.horizon-drawing {
    width: 100%;
    height: auto;
    display: block;
}

/* Arc draw-on animation */
.arc-line-1 { stroke-dasharray: 700; stroke-dashoffset: 700; }
.arc-line-2 { stroke-dasharray: 700; stroke-dashoffset: 700; }
.arc-line-3 { stroke-dasharray: 700; stroke-dashoffset: 700; }
.arc-line-4 { stroke-dasharray: 500; stroke-dashoffset: 500; }
.arc-line-5 { stroke-dasharray: 400; stroke-dashoffset: 400; }
.arc-line-6 { stroke-dasharray: 350; stroke-dashoffset: 350; }
.arc-ray-1, .arc-ray-2, .arc-ray-3, .arc-ray-4, .arc-ray-5 {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}
.arc-center { opacity: 0; }
.arc-center-inner { opacity: 0; }

.exit-arc-container.in-view .arc-line-1 { animation: drawLine 0.6s ease forwards 0.1s; }
.exit-arc-container.in-view .arc-line-2 { animation: drawLine 0.6s ease forwards 0.3s; }
.exit-arc-container.in-view .arc-line-3 { animation: drawLine 0.6s ease forwards 0.5s; }
.exit-arc-container.in-view .arc-line-4 { animation: drawLine 0.5s ease forwards 0.7s; }
.exit-arc-container.in-view .arc-line-5 { animation: drawLine 0.5s ease forwards 0.8s; }
.exit-arc-container.in-view .arc-line-6 { animation: drawLine 0.5s ease forwards 0.9s; }
.exit-arc-container.in-view .arc-ray-1 { animation: drawLine 0.4s ease forwards 1.1s; }
.exit-arc-container.in-view .arc-ray-2 { animation: drawLine 0.4s ease forwards 1.2s; }
.exit-arc-container.in-view .arc-ray-3 { animation: drawLine 0.4s ease forwards 1.3s; }
.exit-arc-container.in-view .arc-ray-4 { animation: drawLine 0.4s ease forwards 1.4s; }
.exit-arc-container.in-view .arc-ray-5 { animation: drawLine 0.4s ease forwards 1.5s; }
.exit-arc-container.in-view .arc-center { animation: fadeIn 0.6s ease forwards 1.6s; }
.exit-arc-container.in-view .arc-center-inner { animation: fadeIn 0.6s ease forwards 1.7s; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.exit-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.exit-heading {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(28px, 4.5vw, 40px);
    letter-spacing: 0.06em;
    color: var(--light-pale);
    line-height: 1;
}

.exit-subtext {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 16px;
    letter-spacing: 0.04em;
    color: var(--text-warm);
    max-width: 420px;
}

/* CTA button — hexagonal chamfer cut */
.exit-cta {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.14em;
    color: var(--light-pale);
    background: var(--ember);
    padding: 16px 48px;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
    margin-top: 8px;
}

.exit-cta:hover {
    background: var(--storm);
    transform: translateY(-2px);
}

/* Exit footer social links */
.exit-footer {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    z-index: 2;
}

.exit-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.exit-link {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0.06em;
    color: var(--text-warm);
    transition: color 0.3s ease;
}

.exit-link:hover {
    color: var(--ember);
}

.exit-divider {
    color: var(--storm);
    font-size: 18px;
}

/* ===================================
   Scroll Reveal Utility
=================================== */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===================================
   Responsive Adjustments
=================================== */
@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: 1fr 1fr;
    }

    .gallery-cell-1 { grid-column: 1 / 3; }
    .gallery-cell-2 { grid-column: 1; }
    .gallery-cell-3 { grid-column: 2; }
    .gallery-cell-4 { grid-column: 1; }
    .gallery-cell-5 { grid-column: 2; }
    .gallery-cell-6 { grid-column: 1 / 3; }

    .manifesto-layout {
        grid-template-columns: 1fr;
        margin-left: 0;
    }

    .manifesto-col-2 {
        margin-left: 0;
        padding-top: 32px;
    }

    .stmt-body-col {
        left: 8%;
        width: calc(90% - 8%);
    }

    .wordmark-main {
        margin-right: -4vw;
        font-size: clamp(48px, 10vw, 80px);
    }

    .nav-inner {
        padding: 14px 24px;
    }

    .entry-wordmark {
        padding-left: 6vw;
    }

    .entry-lottie {
        width: 35vw;
        right: 2vw;
    }
}

@media (max-width: 600px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .gallery-cell-1,
    .gallery-cell-2,
    .gallery-cell-3,
    .gallery-cell-4,
    .gallery-cell-5,
    .gallery-cell-6 {
        grid-column: 1;
        grid-row: auto;
    }

    .entry-lottie {
        display: none;
    }

    .wordmark-main {
        font-size: clamp(52px, 14vw, 72px);
        margin-right: 0;
        text-align: left;
    }

    .chamber-manifesto {
        clip-path: none;
    }

    .chamber-statement {
        clip-path: polygon(0 4%, 100% 0, 100% 100%, 0 100%);
    }
}
