/* ============================================
   chrono.games - Ethereal Blue Editorial
   ============================================ */

/* --- Palette Reference ---
   #0B1929 - Midnight Abyss (primary bg)
   #122640 - Deep Chronos (secondary bg, card surfaces)
   #1A3A5C - Twilight Steel (borders)
   #2E6B8A - Horological Blue (interactive/hover)
   #8FB8D4 - Ice Mist (subheadings)
   #E8F0F5 - Frost White (body text)
   #FFFFFF - Pure White (headlines)
   #C9A96E - Gilded Hand (gold accent)
   #E8D5A3 - Pale Gold (hover glows)
   #2C3E50 - Body text on light bg
*/

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

html {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: #0B1929;
    color: #E8F0F5;
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Scroll Progress Bar --- */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background-color: #C9A96E;
    z-index: 1000;
    transition: width 0.1s linear;
}

/* --- Bezel Tick Marks --- */
.bezel-ticks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999;
}

#bezel-svg {
    width: 100%;
    height: 100%;
}

.bezel-tick {
    stroke: #1A3A5C;
    stroke-width: 0.15;
}

/* --- Sweep Hand Clock --- */
#sweep-clock {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    z-index: 998;
}

#sweep-canvas {
    width: 48px;
    height: 48px;
}

/* --- Elapsed Time Display --- */
#elapsed-time {
    position: fixed;
    bottom: 28px;
    right: 82px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    color: #A3C4D4;
    background-color: rgba(26, 50, 72, 0.7);
    padding: 4px 10px;
    border-radius: 3px;
    z-index: 998;
    letter-spacing: 0.02em;
}

/* --- Scroll Container --- */
#scroll-container {
    width: 100%;
}

/* --- Spread (Full-Viewport Section) --- */
.spread {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
    background-color: #0B1929;
}

.spread:nth-child(even) {
    background-color: #122640;
}

.spread-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    max-width: 66.666vw;
    width: 100%;
    padding: 0 40px;
    align-items: center;
    /* Optical center: 38% from top */
    margin-top: -12vh;
}

.spread-text {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- Section Labels --- */
.section-label {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5B8BA0;
    display: inline-block;
    margin-bottom: 8px;
}

/* --- Typography --- */
.spread-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 72px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #FFFFFF;
    margin: 0;
}

.spread-subtitle {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 28px;
    line-height: 1.4;
    color: #8FB8D4;
    margin: 0;
}

.spread-body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: #C8DCE8;
    margin: 0;
    max-width: 560px;
}

/* --- Timestamp Badge --- */
.timestamp-badge {
    margin-top: 12px;
}

.mono-accent {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    color: #A3C4D4;
    background-color: #1A3248;
    padding: 4px 12px;
    border-radius: 3px;
    display: inline-block;
}

/* --- 3D Render Areas --- */
.spread-render {
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifact-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
    opacity: 0;
    transform: scale(0.92) translateX(40px);
    transition: opacity 0.6s, transform 0.6s;
}

.render-left .artifact-svg {
    transform: scale(0.92) translateX(-40px);
}

.spread.in-view .artifact-svg {
    opacity: 1;
    transform: scale(1) translateX(0);
}

/* Alternating render positions */
.render-right {
    order: 2;
}

.render-left {
    order: -1;
}

/* --- Spread Divider (Tick Mark) --- */
.spread-divider {
    width: 60%;
    height: 1px;
    background-color: #3A5A7C;
    margin: 0 auto;
    flex-shrink: 0;
}

/* --- Pull Quote Spread --- */
.pull-quote-spread {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    scroll-snap-align: start;
    padding: 0 16.666vw;
}

.pull-quote {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 72px;
    line-height: 1.15;
    color: #FFFFFF;
    text-align: center;
    max-width: 66.666vw;
}

.pull-quote .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(4px);
}

.pull-quote .char.visible {
    opacity: 1;
    transform: translateY(0);
}

.pull-quote .char-space {
    display: inline;
    width: 0.3em;
}

/* --- Chapter Numerals (Ghost Watermark) --- */
.chapter-numeral {
    position: absolute;
    bottom: 40px;
    right: 60px;
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 200px;
    line-height: 1;
    color: #0E2035;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

/* --- Temporal Grid (Concentric Circles Background) --- */
.spread::before {
    content: '';
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120vh;
    height: 120vh;
    border-radius: 50%;
    border: 0.5px solid #0E2035;
    opacity: 0.04;
    pointer-events: none;
    box-shadow:
        0 0 0 80px transparent,
        0 0 0 160px rgba(14, 32, 53, 0.03),
        0 0 0 240px rgba(14, 32, 53, 0.02),
        0 0 0 320px rgba(14, 32, 53, 0.01);
}

/* --- Colophon --- */
.colophon {
    margin-top: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.colophon .section-label {
    font-size: 14px;
    letter-spacing: 0.2em;
}

/* --- Interactive States --- */
.section-label:hover {
    color: #2E6B8A;
}

.mono-accent:hover {
    color: #E8D5A3;
}

/* --- Light Spread Text --- */
.spread-light .spread-body {
    color: #2C3E50;
}

/* --- Word Animation --- */
.spread-title .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s, transform 0.4s;
    margin-right: 0.25em;
}

.spread-title .word:last-child {
    margin-right: 0;
}

.spread.in-view .spread-title .word {
    opacity: 1;
    transform: translateY(0);
}

/* --- Subtitle and Body Animation --- */
.spread-subtitle,
.spread-body {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.spread.in-view .spread-subtitle {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.4s;
}

.spread.in-view .spread-body {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.6s;
}

/* Section label animation */
.section-label {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.spread.in-view .section-label {
    opacity: 1;
    transition-delay: 0s;
}

/* Timestamp badge animation */
.timestamp-badge {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.spread.in-view .timestamp-badge {
    opacity: 1;
    transition-delay: 0.8s;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    .spread-content {
        grid-template-columns: 1fr;
        max-width: 90vw;
        gap: 30px;
        padding: 0 20px;
        margin-top: 0;
    }

    .render-left,
    .render-right {
        order: 0;
    }

    .spread-title {
        font-size: 42px;
    }

    .spread-subtitle {
        font-size: 22px;
    }

    .pull-quote {
        font-size: 48px;
        max-width: 90vw;
        padding: 0;
    }

    .pull-quote-spread {
        padding: 0 5vw;
    }

    .chapter-numeral {
        font-size: 120px;
        bottom: 20px;
        right: 20px;
    }

    .bezel-ticks {
        display: none;
    }

    #sweep-clock {
        bottom: 20px;
        right: 50%;
        transform: translateX(50%);
        width: 64px;
        height: 64px;
    }

    #sweep-canvas {
        width: 64px;
        height: 64px;
    }

    #elapsed-time {
        bottom: 90px;
        right: 50%;
        transform: translateX(50%);
    }

    .artifact-svg {
        max-width: 300px;
    }
}

/* --- Responsive: Tablet --- */
@media (min-width: 769px) and (max-width: 1024px) {
    .spread-content {
        max-width: 80vw;
        gap: 40px;
    }

    .spread-title {
        font-size: 56px;
    }

    .pull-quote {
        font-size: 56px;
    }

    .chapter-numeral {
        font-size: 160px;
    }
}

/* --- Spring animation keyframes --- */
@keyframes spring-in {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    60% {
        transform: translateY(-2px);
        opacity: 1;
    }
    80% {
        transform: translateY(1px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spring-scale {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }
    60% {
        transform: scale(1.03);
        opacity: 1;
    }
    80% {
        transform: scale(0.99);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
