/* ============================================
   thefirst.quest — Cinematic Gold-Black Experience
   ============================================ */


/* Color Palette Reference:
   #0a0a0a - Obsidian Black (Primary BG)
   #141414 - Charcoal Depth (Secondary BG)
   #1e1e1e - Smoke (Tertiary BG)
   #c9a84c - Antique Gold (Primary Accent)
   #e8d5a3 - Pale Gold (Secondary Accent)
   #f5c518 - Bright Gold (Highlight)
   #f0ece4 - Parchment White (Text Primary)
   #8a8578 - Muted Stone (Text Secondary)
   #6b1d1d - Oxblood (Error/Alert)
   #fff    - Pure White (Fallback)
*/
/* --- Film Grain SVG Filter (inline) --- */
@keyframes grain-shift {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2%, -3%); }
    20% { transform: translate(3%, 1%); }
    30% { transform: translate(-1%, 2%); }
    40% { transform: translate(2%, -2%); }
    50% { transform: translate(-3%, 3%); }
    60% { transform: translate(1%, -1%); }
    70% { transform: translate(-2%, 2%); }
    80% { transform: translate(3%, -3%); }
    90% { transform: translate(-1%, 1%); }
}

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

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

body {
    background: #0a0a0a;
    color: #f0ece4;
    font-family: 'Libre Baskerville', serif;
    font-size: 1.125rem;
    line-height: 1.85;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
    overflow: hidden;
}

/* --- Film Grain Overlay --- */
#film-grain {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    animation: grain-shift 0.8s steps(8) infinite;
}

/* --- Section: Threshold (Hero) --- */
.section-threshold {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0a0a0a;
    z-index: 1;
}

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    pointer-events: none;
}

.hero-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(3.5rem, 8vw, 7rem);
    letter-spacing: 0.08em;
    color: #c9a84c;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.hero-title.visible {
    opacity: 1;
}

.hero-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #8a8578;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
    margin-top: 1.5rem;
}

.hero-subtitle.visible {
    opacity: 1;
}

/* Scroll Chevron */
.scroll-chevron {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.scroll-chevron.visible {
    animation: chevron-pulse 2s ease-in-out infinite;
}

@keyframes chevron-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

/* --- Section: Chronicle (Descent) --- */
.section-chronicle {
    position: relative;
    min-height: 200vh;
    background: #0a0a0a;
    z-index: 1;
    padding: 10vh 0;
}

.perspective-container {
    position: relative;
    perspective: 1200px;
    transform-style: preserve-3d;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2rem;
}

.depth-plane {
    transform-style: preserve-3d;
}

/* Background Plane */
.depth-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.depth-bg.active {
    opacity: 1;
}

.gen-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
}

.gen-circle {
    border: 1px solid #1e1e1e;
    background: transparent;
}

.circle-1 {
    width: 400px;
    height: 400px;
    top: 15%;
    left: -5%;
}

.circle-2 {
    width: 250px;
    height: 250px;
    top: 55%;
    right: 5%;
    left: auto;
}

.gen-arc {
    border: 1px solid #1e1e1e;
    border-bottom-color: transparent;
    border-left-color: transparent;
    background: transparent;
}

.arc-1 {
    width: 350px;
    height: 350px;
    top: 35%;
    right: -10%;
    left: auto;
    transform: rotate(30deg);
}

.arc-2 {
    width: 200px;
    height: 200px;
    top: 70%;
    left: 10%;
    transform: rotate(-20deg);
}

/* Midground Plane */
.depth-mid {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.mid-text {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    color: #c9a84c;
    opacity: 0;
    font-size: clamp(3rem, 6vw, 5rem);
    letter-spacing: 0.15em;
    transform: translateZ(-200px);
    transition: opacity 0.8s ease;
    user-select: none;
}

.mid-text.visible {
    opacity: 0.15;
}

.mid-001 {
    top: 5vh;
    right: -5%;
}

.mid-origin {
    top: 55vh;
    left: -8%;
}

.mid-genesis {
    top: 105vh;
    right: -3%;
}

.mid-prime {
    top: 150vh;
    left: -5%;
}

/* Foreground Plane */
.depth-fg {
    position: relative;
    z-index: 2;
}

.prose-block {
    margin-bottom: 30vh;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.prose-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.prose-text {
    font-family: 'Libre Baskerville', serif;
    font-size: 1.125rem;
    line-height: 1.85;
    color: #f0ece4;
    max-width: 600px;
}

.prose-1 { padding-top: 15vh; }
.prose-2 { margin-left: auto; }
.prose-2 .prose-text { margin-left: auto; }
.prose-3 { padding-bottom: 10vh; }

/* Gilded Lines */
.gilded-line {
    display: block;
    width: 200px;
    height: 40px;
    margin-bottom: 1.5rem;
    overflow: visible;
}

.gilded-line path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.5s ease;
}

.prose-block.visible .gilded-line path {
    stroke-dashoffset: 0;
}

.gilded-line-2 {
    margin-left: auto;
}

/* --- Section: Declaration --- */
.section-declaration {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    z-index: 1;
    transition: background-color 0.6s ease;
    overflow: hidden;
}

.declaration-text {
    text-align: center;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.06em;
    line-height: 1.3;
    background: linear-gradient(135deg, #c9a84c, #f5c518, #e8d5a3, #c9a84c);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gold-gradient-shift 8s ease-in-out infinite;
}

@keyframes gold-gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
}

.decl-word {
    display: inline-block;
    transition: transform 0.2s ease-out;
    cursor: default;
    padding: 0 0.15em;
}

.decl-word:hover {
    transform: scale(1.05);
}

/* --- Section: Seal --- */
.section-seal {
    /* Secondary BG: #141414 used for depth variation */
    position: relative;
    width: 100%;
    height: 40vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #141414;
    z-index: 1;
    overflow: hidden;
}

.seal-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.05) 0%, transparent 70%);
    animation: seal-pulse 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes seal-pulse {
    0%, 100% { transform: scale(0.95); opacity: 0.6; }
    50% { transform: scale(1.05); opacity: 1; }
}

.seal-monogram {
    position: relative;
    z-index: 1;
    animation: seal-rotate 120s linear infinite;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.seal-monogram.visible {
    opacity: 1;
}

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

/* Keep TFQ text upright while seal rotates */
.seal-monogram text {
    animation: seal-counter-rotate 120s linear infinite;
    transform-origin: 100px 100px;
}

@keyframes seal-counter-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

.seal-domain {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: #8a8578;
    margin-top: 2rem;
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.2s ease 0.3s;
}

.seal-domain.visible {
    opacity: 1;
}

/* --- Responsive (Mobile) --- */
@media (max-width: 768px) {
    .hero-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .hero-subtitle {
        font-size: 0.75rem;
        letter-spacing: 0.15em;
    }

    .perspective-container {
        perspective: none;
        padding: 0 1.5rem;
    }

    .mid-text {
        font-size: clamp(2rem, 8vw, 3rem);
        opacity: 0;
    }

    .mid-text.visible {
        opacity: 0.1;
    }

    .prose-block {
        margin-bottom: 20vh;
    }

    .prose-2 {
        margin-left: 0;
    }

    .prose-2 .prose-text {
        margin-left: 0;
    }

    .declaration-text {
        font-size: clamp(1.8rem, 8vw, 3rem);
        padding: 0 1.5rem;
    }

    .gen-shape {
        display: none;
    }

    .section-chronicle {
        min-height: 180vh;
    }

    .seal-monogram {
        width: 120px;
        height: 120px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(1.8rem, 12vw, 2.5rem);
    }

    .prose-text {
        font-size: 1rem;
        line-height: 1.75;
    }

    .declaration-text {
        font-size: clamp(1.5rem, 9vw, 2.5rem);
    }
}
/* --- Selection / Accent Colors --- */
::selection {
    background: #6b1d1d;
    color: #fff;
}

::-moz-selection {
    background: #6b1d1d;
    color: #fff;
}
