/* genpatsu.io — Cinematic Reactor-Glow Storytelling */

/* ===== CSS Custom Properties ===== */
:root {
    --reactor-dark: #1a1410;
    --charcoal-warm: #2a2118;
    --sienna-dusk: #3d2e1f;
    --reactor-amber: #e8803a;
    --sunset-gold: #f0b366;
    --horizon-coral: #d4594a;
    --parchment-white: #f5e6d3;
    --warm-sandstone: #d4c4b0;
    --ash-gray: #8a7e72;
    --instrument-teal: #4a9e8e;
    --font-mono: 'Share Tech Mono', monospace;
    --font-body: 'Nunito Sans', sans-serif;
    --padding-h: clamp(2rem, 5vw, 6rem);
    --max-content: 1400px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--reactor-dark);
    color: var(--parchment-white);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.85;
    overflow-x: hidden;
}

/* ===== Fixed Wordmark ===== */
.fixed-mark {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.fixed-mark.visible {
    opacity: 1;
}

.fixed-hex {
    animation: rotate 60s linear infinite;
}

/* ===== Zone Base ===== */
.zone {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* ===== Zone 0 — The Horizon ===== */
.zone-0 {
    height: 100vh;
    background: var(--reactor-dark);
}

.zone-0-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 70% 30%, rgba(232, 128, 58, 0.15) 0%, transparent 70%);
    animation: drift-glow 30s ease-in-out infinite alternate;
}

@keyframes drift-glow {
    0% { background-position: 70% 30%; }
    100% { background-position: 40% 60%; }
}

.zone-0-content {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 100%;
    padding: var(--padding-h);
    max-width: var(--max-content);
    margin: 0 auto;
}

.zone-0-top-left {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 2rem;
}

.wordmark {
    font-family: var(--font-mono);
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--parchment-white);
    text-shadow: 0 0 40px rgba(232, 128, 58, 0.3);
}

.wordmark span {
    display: inline-block;
    opacity: 0;
    animation: letter-fade 0.4s ease forwards;
}

.wordmark span:nth-child(1) { animation-delay: 0.1s; }
.wordmark span:nth-child(2) { animation-delay: 0.2s; }
.wordmark span:nth-child(3) { animation-delay: 0.3s; }
.wordmark span:nth-child(4) { animation-delay: 0.4s; }
.wordmark span:nth-child(5) { animation-delay: 0.5s; }
.wordmark span:nth-child(6) { animation-delay: 0.6s; }
.wordmark span:nth-child(7) { animation-delay: 0.7s; }
.wordmark span:nth-child(8) { animation-delay: 0.8s; }
.wordmark span:nth-child(9) { animation-delay: 0.9s; }
.wordmark span:nth-child(10) { animation-delay: 1.0s; }
.wordmark span:nth-child(11) { animation-delay: 1.1s; }

@keyframes letter-fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.zone-0-top-right {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-top: 2rem;
}

.hex-wireframe {
    animation: rotate 60s linear infinite;
}

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

.zone-0-bottom-left {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding-bottom: 3rem;
}

.mission-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.4vw, 1.35rem);
    color: var(--warm-sandstone);
    letter-spacing: 0.02em;
    line-height: 1.6;
}

.zone-0-bottom-right {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding-bottom: 3rem;
}

.scroll-indicator {
    animation: pulse-border 2s ease-in-out infinite;
    border: 1px solid var(--reactor-amber);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--reactor-amber); box-shadow: 0 0 0 0 rgba(232, 128, 58, 0.4); }
    50% { border-color: var(--sunset-gold); box-shadow: 0 0 15px 3px rgba(232, 128, 58, 0.2); }
}

/* ===== Zone 1 — The Core ===== */
.zone-1 {
    min-height: 120vh;
    background: var(--charcoal-warm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.zone-bg-numeral {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: clamp(8rem, 18vw, 22rem);
    font-weight: 400;
    color: rgba(245, 230, 211, 0.06);
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

.zone-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--max-content);
    margin: 0 auto;
    padding: var(--padding-h);
}

/* Z-Pattern Grid */
.z-pattern {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: clamp(2rem, 4vw, 4rem);
    align-items: start;
}

.z-top-left { grid-column: 1; grid-row: 1; }
.z-top-right { grid-column: 2; grid-row: 1; }
.z-bottom-left { grid-column: 1; grid-row: 2; display: flex; justify-content: center; }
.z-bottom-right { grid-column: 2; grid-row: 2; }

.z-pattern-inverted {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: clamp(2rem, 4vw, 4rem);
    align-items: center;
}

.z-pattern-inverted .z-top-right { grid-column: 1 / -1; grid-row: 1; max-width: 700px; justify-self: end; }
.z-pattern-inverted .z-center { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
.z-pattern-inverted .z-bottom-left { grid-column: 1 / -1; grid-row: 3; max-width: 700px; }

/* Zone Label */
.zone-label {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 0.85vw, 0.95rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--reactor-amber);
    margin-bottom: 0.5rem;
}

.zone-sublabel {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--parchment-white);
    text-shadow: 0 0 40px rgba(232, 128, 58, 0.3);
    line-height: 1.1;
}

.display-heading {
    font-family: var(--font-mono);
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--parchment-white);
    text-shadow: 0 0 40px rgba(232, 128, 58, 0.3);
    margin-bottom: 1rem;
    line-height: 1.1;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.1vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--warm-sandstone);
}

/* Sweep Border Animation */
.observe-target {
    position: relative;
    padding: clamp(1.5rem, 2.5vw, 2.5rem);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.observe-target.visible {
    opacity: 1;
}

.observe-target[data-animate="sweep-border"]::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--reactor-amber);
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.observe-target[data-animate="sweep-border"].visible::before {
    clip-path: inset(0 0 0 0);
}

/* Reactor Diagram */
.reactor-diagram {
    max-width: 100%;
    height: auto;
    animation: rotate 90s linear infinite;
    transform-origin: center center;
}

.core-pulse {
    animation: core-breathe 4s ease-in-out infinite;
    transform-origin: 150px 150px;
}

@keyframes core-breathe {
    0%, 100% { transform: rotate(60deg) scale(0.98); }
    50% { transform: rotate(60deg) scale(1.02); }
}

/* ===== Zone 2 — The Cooling Basin ===== */
.zone-2 {
    min-height: 100vh;
    background: var(--sienna-dusk);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topo-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.topo-contours {
    width: 100%;
    height: 100%;
}

/* Gauge Arc */
.gauge-arc {
    max-width: clamp(200px, 40vw, 350px);
    height: auto;
}

.gauge-fill {
    transition: stroke-dashoffset 2s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-fill.filled {
    stroke-dashoffset: 135;
}

/* Particles */
.particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: var(--reactor-amber);
    opacity: 0.15;
    animation: drift-up linear infinite;
}

@keyframes drift-up {
    0% {
        transform: translateY(100vh) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.15;
    }
    90% {
        opacity: 0.15;
    }
    100% {
        transform: translateY(-20px) translateX(30px);
        opacity: 0;
    }
}

/* ===== Zone 3 — The Archive ===== */
.zone-3 {
    min-height: 130vh;
    background: var(--sienna-dusk);
    display: flex;
    align-items: center;
    justify-content: center;
}

.archive-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(1.5rem, 3vw, 3rem);
}

/* Glow Border Cards */
.archive-card {
    position: relative;
    padding: clamp(2rem, 3vw, 3rem);
    background: rgba(42, 33, 24, 0.6);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.archive-card.visible {
    opacity: 1;
}

.archive-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid transparent;
    transition: border-color 0.6s ease;
}

.archive-card.visible::before {
    border-color: var(--reactor-amber);
    background: linear-gradient(90deg, var(--reactor-amber), var(--sunset-gold), var(--horizon-coral), var(--reactor-amber)) border-box;
    background-size: 300% 100%;
    animation: border-sweep 8s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

@keyframes border-sweep {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

.card-label {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 0.85vw, 0.95rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--reactor-amber);
    margin-bottom: 0.75rem;
}

.card-numeral {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(3.5rem, 7vw, 6rem);
    font-weight: 400;
    color: var(--parchment-white);
    text-shadow: 0 0 40px rgba(232, 128, 58, 0.3);
    line-height: 1;
    margin-bottom: 1rem;
}

.card-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 1vw, 1.1rem);
    line-height: 1.75;
    color: var(--warm-sandstone);
}

/* ===== Zone 4 — The Horizon Line ===== */
.zone-4 {
    min-height: 80vh;
    background: var(--reactor-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.zone-4-border-frame {
    position: absolute;
    inset: clamp(1rem, 2vw, 2rem);
    pointer-events: none;
}

.dash-march-border {
    width: 100%;
    height: 100%;
}

.march-rect {
    animation: dash-march 12s linear infinite;
}

@keyframes dash-march {
    to { stroke-dashoffset: -48; }
}

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

.closing-text {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--parchment-white);
    text-shadow: 0 0 60px rgba(232, 128, 58, 0.2);
}

.zone-4-mark {
    position: absolute;
    bottom: clamp(1.5rem, 3vw, 2.5rem);
    right: clamp(2rem, 4vw, 3rem);
    z-index: 2;
}

.footer-mark {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ash-gray);
}

/* ===== Grid Point Background ===== */
.zone-3::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--reactor-amber) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.04;
    pointer-events: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .zone-0-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto auto;
    }

    .zone-0-top-right {
        justify-content: center;
    }

    .zone-0-bottom-left {
        align-items: center;
        padding-bottom: 1rem;
    }

    .zone-0-bottom-right {
        justify-content: center;
        padding-bottom: 2rem;
    }

    .z-pattern {
        grid-template-columns: 1fr;
    }

    .z-top-left, .z-top-right, .z-bottom-left, .z-bottom-right {
        grid-column: 1;
    }

    .z-top-left { grid-row: 1; }
    .z-top-right { grid-row: 2; }
    .z-bottom-left { grid-row: 3; }
    .z-bottom-right { grid-row: 4; }

    .z-pattern-inverted {
        grid-template-columns: 1fr;
    }

    .z-pattern-inverted .z-top-right {
        max-width: 100%;
        justify-self: start;
    }

    .z-pattern-inverted .z-bottom-left {
        max-width: 100%;
    }

    .archive-grid {
        grid-template-columns: 1fr;
    }

    .hex-wireframe {
        width: 140px;
        height: 140px;
    }

    .reactor-diagram {
        width: 200px;
        height: 200px;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}