/* ============================================================
   lowest.dev v2 - styles.css
   Cinematic candle-lit descent through stratified depths.
   Palette: Void Black, Candle Amber, Ember Glow, Smoke Gray,
            Parchment Light, Deep Indigo, Flame Core.
   ============================================================ */

:root {
    /* Palette - exact hex values from DESIGN.md */
    --void-black: #0A0A0A;
    --void-black-1: #0A0A12;
    --void-black-2: #0A0A1E;
    --candle-amber: #E6A817;
    --ember-glow: #D4763A;
    --smoke-gray: #3A3A3A;
    --parchment: #F5E6CC;
    --deep-indigo: #1A1A3E;
    --flame-core: #FFFFFF;

    /* Scroll-driven depth color - mutated by JS */
    --bg-current: var(--void-black);
    --accent-current: var(--candle-amber);

    /* Typography */
    --font-serif: "Cinzel", "Lora", Georgia, serif;
    --font-sans: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "Menlo", monospace;

    /* Layout */
    --col-max: 640px;
    --rail-width: 56px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-current);
    color: var(--parchment);
    font-family: var(--font-sans);
    font-weight: 300;
    font-size: clamp(16px, 1.2vw, 20px);
    line-height: 1.8;
    letter-spacing: 0.02em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.6s ease;
    min-height: 100vh;
}

main#page {
    position: relative;
    z-index: 1;
}

/* ============================================================
   Depth rail - vertical scroll position indicator
   ============================================================ */

#depth-rail {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--rail-width);
    height: 100vh;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8vh;
    padding-bottom: 8vh;
}

.rail-track {
    position: absolute;
    left: 50%;
    top: 12vh;
    bottom: 18vh;
    width: 1px;
    transform: translateX(-50%);
    background: linear-gradient(
        180deg,
        var(--candle-amber) 0%,
        var(--ember-glow) 35%,
        var(--smoke-gray) 70%,
        var(--deep-indigo) 100%
    );
    opacity: 0.55;
}

.rail-marker {
    position: absolute;
    left: 50%;
    top: 12vh;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--candle-amber);
    box-shadow: 0 0 12px 2px rgba(230, 168, 23, 0.55);
    transform: translate(-50%, -50%);
    transition: top 0.18s ease-out, background 0.6s ease, box-shadow 0.6s ease;
}

.rail-readout {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--smoke-gray);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.rail-label {
    color: var(--ember-glow);
    opacity: 0.7;
}

.rail-value {
    color: var(--parchment);
    font-size: 11px;
    letter-spacing: 0.1em;
}

.rail-unit {
    opacity: 0.55;
}

/* ============================================================
   Particle dust container - drifting embers/sparks
   ============================================================ */

#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.particle {
    position: absolute;
    top: -10px;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--candle-amber);
    box-shadow: 0 0 4px 1px rgba(230, 168, 23, 0.55);
    opacity: 0;
    will-change: transform, opacity;
    animation-name: drift-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.particle.large {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 6px 1.5px rgba(230, 168, 23, 0.6);
}

@keyframes drift-fall {
    0%   { transform: translate3d(0, 0, 0);              opacity: 0; }
    8%   {                                                opacity: 0.85; }
    50%  { transform: translate3d(8px, 50vh, 0);         opacity: 0.7; }
    92%  {                                                opacity: 0.5; }
    100% { transform: translate3d(-6px, 110vh, 0);       opacity: 0; }
}

/* ============================================================
   Sections
   ============================================================ */

.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 14vh 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

/* ---------- Hero ---------- */

.section--hero {
    background: var(--void-black);
    text-align: center;
    overflow: hidden;
}

.section--hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 380px 480px at 50% 50%, rgba(230, 168, 23, 0.10) 0%, rgba(230, 168, 23, 0) 70%),
        radial-gradient(ellipse 800px 600px at 50% 60%, rgba(212, 118, 58, 0.05) 0%, rgba(212, 118, 58, 0) 75%);
    pointer-events: none;
}

.hero-stage {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
}

.hero-flame {
    width: 130px;
    height: 220px;
    position: relative;
    opacity: 0;
    transform: translateY(8px);
    animation: hero-flame-in 0.8s ease-out forwards;
    animation-delay: 0.3s;
}

@keyframes hero-flame-in {
    to { opacity: 1; transform: translateY(0); }
}

.flame-svg {
    width: 100%;
    height: 100%;
    display: block;
    transform-origin: 50% 100%;
    animation: flame-sway 3.2s ease-in-out infinite alternate;
}

@keyframes flame-sway {
    0%   { transform: translateX(-2px) rotate(-0.6deg) scaleY(1); }
    35%  { transform: translateX(1px)  rotate(0.4deg)  scaleY(1.02); }
    70%  { transform: translateX(2px)  rotate(0.7deg)  scaleY(0.99); }
    100% { transform: translateX(-1px) rotate(-0.3deg) scaleY(1.01); }
}

.flame-glow {
    transform-origin: 60px 110px;
    animation: glow-pulse 2.6s ease-in-out infinite alternate;
}

@keyframes glow-pulse {
    0%   { opacity: 0.65; transform: scale(0.96); }
    100% { opacity: 1;    transform: scale(1.06); }
}

.flame-mid,
.flame-core {
    opacity: 0;
    animation: flame-fill 0.8s ease-out forwards;
}
.flame-mid  { animation-delay: 1.5s; }
.flame-core { animation-delay: 1.9s; }

@keyframes flame-fill {
    to { opacity: 1; }
}

.flame-outline {
    stroke-dasharray: 520;
    stroke-dashoffset: 520;
    animation: flame-draw 1.2s ease-out forwards;
    animation-delay: 0.3s;
}

@keyframes flame-draw {
    to { stroke-dashoffset: 0; }
}

.wick {
    opacity: 0;
    animation: wick-in 0.4s ease-out forwards;
    animation-delay: 1.4s;
}

@keyframes wick-in {
    to { opacity: 1; }
}

/* ---------- Logotype kinetic typography ---------- */

.logotype {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: clamp(36px, 6vw, 72px);
    letter-spacing: 0.12em;
    color: var(--parchment);
    text-transform: lowercase;
    line-height: 1;
    text-shadow: 0 0 24px rgba(230, 168, 23, 0.18);
}

.logotype .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    animation: char-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    animation-delay: calc(2.3s + var(--i) * 0.08s);
}

.logotype .char.dot {
    color: var(--candle-amber);
    margin: 0 0.04em;
    text-shadow: 0 0 14px rgba(230, 168, 23, 0.55);
}

@keyframes char-rise {
    to { opacity: 1; transform: translateY(0); }
}

.hero-tagline {
    margin: 4px 0 0;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--ember-glow);
    opacity: 0;
    animation: fade-in-soft 0.9s ease forwards;
    animation-delay: 3.4s;
}

.tagline-rule {
    display: inline-block;
    width: 36px;
    height: 1px;
    background: var(--smoke-gray);
}

.tagline-text {
    opacity: 0.85;
}

@keyframes fade-in-soft {
    to { opacity: 1; }
}

.scroll-cue {
    margin-top: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--candle-amber);
    opacity: 0;
    animation: fade-in-soft 0.9s ease forwards, scroll-bob 1.8s ease-in-out infinite;
    animation-delay: 3.7s, 4s;
}

@keyframes scroll-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(6px); }
}

.scroll-cue svg {
    display: block;
}

/* ============================================================
   Stratum sections (descent)
   ============================================================ */

.section--stratum {
    text-align: center;
    overflow: hidden;
}

.section--stratum::before {
    /* faint stratum band marker */
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(
        180deg,
        rgba(58, 58, 58, 0.16) 0%,
        rgba(58, 58, 58, 0) 12%,
        rgba(58, 58, 58, 0) 88%,
        rgba(58, 58, 58, 0.16) 100%
    );
    pointer-events: none;
    z-index: 0;
}

.stratum-pool {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 900px);
    height: min(90vh, 900px);
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(ellipse 60% 55% at 50% 45%, rgba(230, 168, 23, 0.10) 0%, rgba(230, 168, 23, 0) 70%),
        radial-gradient(ellipse 80% 70% at 50% 50%, rgba(212, 118, 58, 0.06) 0%, rgba(212, 118, 58, 0) 80%);
    filter: blur(2px);
    opacity: 0;
    transition: opacity 1.2s ease;
}

.section--stratum.is-revealed .stratum-pool {
    opacity: 1;
}

.stratum-inner {
    position: relative;
    z-index: 4;
    width: 100%;
    max-width: var(--col-max);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity 1.1s cubic-bezier(0.2, 0.8, 0.2, 1),
        transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.section--stratum.is-revealed .stratum-inner {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Stratum marker (numeral + label) ---------- */

.stratum-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.marker-numeral {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 28px;
    color: var(--candle-amber);
    letter-spacing: 0.2em;
    line-height: 1;
}

.marker-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    color: var(--smoke-gray);
}

/* ---------- Path-draw heading ---------- */

.section-heading {
    position: relative;
    margin: 0;
    width: 100%;
    height: 80px;
}

.section-heading .heading-line {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.draw-text {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.section--stratum.is-revealed .draw-text {
    stroke-dashoffset: 0;
}

.heading-fill {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: clamp(28px, 4vw, 44px);
    letter-spacing: 0.06em;
    color: var(--parchment);
    opacity: 0;
    transition: opacity 0.9s ease;
    transition-delay: 1.2s;
}

.section--stratum.is-revealed .heading-fill {
    opacity: 1;
}

.heading-fill--core {
    font-weight: 700;
    color: var(--flame-core);
    text-shadow: 0 0 20px rgba(245, 230, 204, 0.35);
}

/* ---------- Body text ---------- */

.body-text {
    margin: 0;
    color: var(--parchment);
    opacity: 0.92;
    font-size: clamp(15px, 1.15vw, 18px);
    line-height: 1.85;
    letter-spacing: 0.015em;
    max-width: 580px;
}

/* ---------- Code slab ---------- */

.code-slab {
    width: 100%;
    margin: 0;
    padding: 22px 24px;
    background: rgba(10, 10, 18, 0.72);
    border: 1px solid var(--smoke-gray);
    border-left: 2px solid var(--candle-amber);
    border-radius: 2px;
    text-align: left;
    overflow-x: auto;
    box-shadow:
        inset 0 0 60px rgba(230, 168, 23, 0.04),
        0 0 30px rgba(0, 0, 0, 0.5);
}

.mono-text {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.7;
    color: var(--parchment);
    letter-spacing: 0;
}

.code-comment { color: var(--smoke-gray); font-style: italic; }
.code-keyword { color: var(--ember-glow); }
.code-name    { color: var(--parchment); }
.code-string  { color: var(--candle-amber); }
.code-num     { color: var(--candle-amber); }

/* ---------- Strata list ---------- */

.strata-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--parchment);
    font-size: 13px;
    line-height: 1.7;
}

.strata-list li {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(58, 58, 58, 0.4);
}
.strata-list li:last-child {
    border-bottom: none;
}

.list-mark {
    color: var(--candle-amber);
    opacity: 0.7;
    flex-shrink: 0;
}

/* ---------- Stratum divider ---------- */

.stratum-divider {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.dot-cluster {
    display: inline-flex;
    gap: 14px;
    align-items: center;
}

.dot-cluster span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--smoke-gray);
}

.dot-cluster span:nth-child(2) {
    background: var(--candle-amber);
    box-shadow: 0 0 6px rgba(230, 168, 23, 0.5);
}

/* ============================================================
   Terminal section
   ============================================================ */

.section--terminal {
    background: linear-gradient(180deg, var(--void-black-2) 0%, var(--deep-indigo) 100%);
    position: relative;
    overflow: hidden;
}

.terminal-glow {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10vh;
    height: 60vh;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 100% at 50% 100%, rgba(230, 168, 23, 0.22) 0%, rgba(230, 168, 23, 0) 70%),
        radial-gradient(ellipse 100% 80% at 50% 100%, rgba(212, 118, 58, 0.14) 0%, rgba(212, 118, 58, 0) 80%);
    filter: blur(2px);
    opacity: 0.85;
    animation: terminal-breathe 6s ease-in-out infinite alternate;
}

@keyframes terminal-breathe {
    0%   { opacity: 0.65; transform: scale(0.98); }
    100% { opacity: 1;    transform: scale(1.04); }
}

.terminal-inner {
    text-align: center;
    align-items: center;
    gap: 22px;
}

.section-heading--terminal {
    height: 90px;
}

.terminal-message {
    margin: 6px 0 0;
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: clamp(20px, 2.2vw, 28px);
    color: var(--parchment);
    letter-spacing: 0.06em;
    line-height: 1.5;
    text-shadow: 0 0 16px rgba(245, 230, 204, 0.18);
}

.terminal-sub {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--ember-glow);
    opacity: 0.85;
}

.terminal-flame {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    opacity: 0.85;
    transform-origin: 50% 100%;
    animation: flame-sway 3.6s ease-in-out infinite alternate;
}

/* ============================================================
   Reduced motion - safety
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.05ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
    :root {
        --rail-width: 44px;
    }

    .section {
        padding: 12vh 18px;
    }

    .hero-flame {
        width: 110px;
        height: 180px;
    }

    .logotype {
        font-size: clamp(30px, 11vw, 56px);
    }

    .section-heading {
        height: 64px;
    }

    .heading-fill {
        font-size: clamp(22px, 6vw, 34px);
    }

    .rail-readout {
        font-size: 8px;
    }

    .rail-value {
        font-size: 10px;
    }

    .strata-list {
        font-size: 12px;
    }
}

@media (max-width: 460px) {
    #depth-rail {
        opacity: 0.65;
    }
    .rail-readout {
        display: none;
    }
}
