/* ============================================
   genpatsu.quest - Japanese-Minimal Nuclear
   ============================================ */

:root {
    --frost-white: #F0F4F8;
    --ice-lattice: #C8D6E5;
    --graphite-ink: #2C3A47;
    --slate-vapor: #7F8C9B;
    --reactor-amber: #D4A76A;
    --coolant-blue: #6B9ECE;
    --panel-frost: rgba(240, 244, 248, 0.72);
    --caution-rose: #C7727A;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    background: var(--frost-white);
    color: var(--graphite-ink);
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.85;
    overflow-x: hidden;
}

/* --- Grid Substrate --- */
.grid-substrate {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    transition: opacity 1s ease;
}

/* --- Cherry Blossom Canvas --- */
#petalCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* --- Chapter Sections --- */
.chapter {
    position: relative;
    min-height: 100vh;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: clamp(2rem, 4vw, 4rem);
    padding: clamp(3rem, 8vw, 8rem);
    align-content: center;
}

/* --- Z-Pattern Positions --- */
.z-top-left {
    grid-column: 1;
    grid-row: 1;
    max-width: 38em;
}

.z-top-right {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
}

.z-floating-labels {
    grid-column: 1 / -1;
    grid-row: 2;
    position: relative;
    height: 100px;
}

/* --- Site Title --- */
.site-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2.4rem, 5.5vw, 5rem);
    letter-spacing: 0.06em;
    line-height: 1.12;
    color: var(--graphite-ink);
}

.title-rule {
    width: 0;
    height: 1px;
    background: var(--graphite-ink);
    margin: 16px 0;
    animation: ruleGrow 1.2s ease-out 0.6s forwards;
}

@keyframes ruleGrow {
    to { width: 120px; }
}

.site-sub {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    color: var(--slate-vapor);
    opacity: 0;
    animation: fadeIn 1s ease-out 1.2s forwards;
}

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

/* --- Chapter Headings --- */
.chapter-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--slate-vapor);
    display: block;
    margin-bottom: 12px;
}

.chapter-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.02em;
    color: var(--graphite-ink);
    margin-bottom: 20px;
}

.chapter-body {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.85;
    color: var(--graphite-ink);
    max-width: 38em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.chapter-body.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Frost Panels --- */
.frost-panel {
    background: var(--panel-frost);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border-radius: 12px;
    padding: clamp(20px, 3vw, 32px);
    border: 1px solid rgba(200, 214, 229, 0.3);
    width: clamp(200px, 30vw, 320px);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

@supports not (backdrop-filter: blur(12px)) {
    .frost-panel {
        background: rgba(240, 244, 248, 0.92);
    }
}

.frost-panel.visible {
    opacity: 1;
    transform: translateX(0);
}

.frost-cool {
    border-color: rgba(107, 158, 206, 0.2);
}

.frost-warm {
    border-color: rgba(212, 167, 106, 0.2);
}

/* --- Diagrams --- */
.diagram {
    width: 100%;
    height: auto;
}

.diagram-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    fill: var(--slate-vapor);
    letter-spacing: 0.08em;
}

.diagram-reactor {
    animation: slowRotate 200s linear infinite;
}

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

/* --- Floating Labels --- */
.float-label {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--slate-vapor);
    opacity: 0;
    animation: floatDown 8s ease-in-out infinite;
}

.fl-1 { left: 30%; top: 0; animation-delay: 0s; }
.fl-2 { left: 55%; top: 20%; animation-delay: 2s; }
.fl-3 { left: 40%; top: 40%; animation-delay: 4s; }

@keyframes floatDown {
    0% { opacity: 0; transform: translateY(-10px); }
    20% { opacity: 0.6; }
    80% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(30px); }
}

/* --- Interstitials --- */
.interstitial {
    position: relative;
    z-index: 2;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.interstitial-motif {
    width: 120px;
    height: 120px;
    opacity: 0.5;
}

/* --- Warm Chapter --- */
.chapter-warm .chapter-heading {
    color: var(--reactor-amber);
}

/* --- Cool Chapter --- */
.chapter-cool .chapter-heading {
    color: var(--coolant-blue);
}

/* --- Colophon --- */
.chapter-colophon {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 40px;
}

.colophon-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    color: var(--slate-vapor);
    opacity: 0.4;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chapter {
        grid-template-columns: 1fr;
        padding: clamp(2rem, 6vw, 4rem);
    }

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

    .z-floating-labels {
        grid-column: 1;
        grid-row: 3;
    }

    .frost-panel {
        width: 100%;
        max-width: 320px;
    }
}

@media (max-width: 480px) {
    .chapter {
        padding: clamp(1.5rem, 4vw, 3rem);
    }

    .frost-panel {
        max-width: 100%;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .title-rule {
        animation: none;
        width: 120px;
    }

    .site-sub {
        animation: none;
        opacity: 1;
    }

    .float-label {
        animation: none;
        opacity: 0.6;
    }

    .diagram-reactor {
        animation: none;
    }

    .chapter-body,
    .frost-panel {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
