/* ============================================
   chrono.games - Styles
   Bauhaus temporal gaming experience
   ============================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
    --deep-forest: #1B4332;
    --canopy-green: #2D6A4F;
    --patina-bright: #52B788;
    --verdigris-gold: #B5A642;
    --parchment: #F5F0E8;
    --aged-linen: #E8DFD0;
    --charcoal-ink: #1A1A1A;
    --stone-gray: #6B7B6E;
    --rust-clock: #C44536;
    --midnight-moss: #0A1F14;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;

    --ease-mechanical: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-bounce: cubic-bezier(0.36, 0, 0.66, -0.56);
    --ease-wipe: cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: var(--charcoal-ink);
    background: var(--midnight-moss);
    overflow-x: hidden;
    cursor: none;
}

/* --- Custom Cursor --- */
#cursor-crosshair {
    position: fixed;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-16px, -16px);
    will-change: transform;
}

#cursor-crosshair svg {
    animation: cursorRotate 60s linear infinite;
}

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

/* --- Cursor-Follow Tokens --- */
.cursor-token {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-10px, -10px);
    will-change: transform;
    transition: opacity 0.3s var(--ease-mechanical);
}

#cursor-token-circle {
    transition: transform 0.08s linear;
}

#cursor-token-triangle {
    transition: transform 0.16s linear;
}

#cursor-token-square {
    transition: transform 0.24s linear;
}

.cursor-token.collapsed {
    transition: transform 0.2s var(--ease-mechanical);
}

.cursor-token.burst {
    transition: transform 0.15s var(--ease-mechanical);
}

/* --- Time-Dust Particles --- */
#time-dust {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9990;
    overflow: hidden;
}

.dust-particle {
    position: absolute;
    border-radius: 50%;
    background: var(--patina-bright);
    pointer-events: none;
    will-change: transform, opacity;
}

/* --- Timeline Scrubber Navigation --- */
#timeline-scrubber {
    position: fixed;
    right: 0;
    top: 0;
    width: 80px;
    height: 100vh;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.4s var(--ease-mechanical), transform 0.4s var(--ease-mechanical);
    cursor: none;
}

#timeline-scrubber.visible {
    opacity: 1;
    transform: translateX(0);
}

.scrubber-track {
    position: relative;
    width: 40px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.scrubber-track::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--patina-bright);
    opacity: 0.4;
    transform: translateX(-50%);
}

.scrubber-hand {
    position: absolute;
    left: 50%;
    top: 0;
    width: 3px;
    height: 20px;
    background: var(--patina-bright);
    transform: translateX(-50%);
    transition: top 0.5s var(--ease-mechanical);
    border-radius: 2px;
}

.scrubber-tick {
    position: relative;
    width: 30px;
    height: 30px;
    background: none;
    border: 1px solid var(--patina-bright);
    border-radius: 50%;
    cursor: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s var(--ease-mechanical), transform 0.3s var(--ease-mechanical);
    z-index: 1;
}

.scrubber-tick:hover {
    background: rgba(82, 183, 136, 0.2);
    transform: scale(1.15);
}

.scrubber-tick.active {
    background: var(--patina-bright);
}

.scrubber-tick.active .tick-label {
    color: var(--deep-forest);
}

.tick-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--patina-bright);
    letter-spacing: 0;
}

/* --- Section Base --- */
.time-zone {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.dark-zone {
    background: var(--deep-forest);
    color: var(--parchment);
}

.light-zone {
    background: var(--parchment);
    color: var(--charcoal-ink);
}

/* --- Urban Texture Overlays --- */
.dark-zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(10, 31, 20, 0.08) 3px,
            rgba(10, 31, 20, 0.08) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 50px,
            rgba(45, 106, 79, 0.03) 50px,
            rgba(45, 106, 79, 0.03) 51px
        );
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

.light-zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(232, 223, 208, 0.15) 4px,
            rgba(232, 223, 208, 0.15) 5px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 60px,
            rgba(107, 123, 110, 0.04) 60px,
            rgba(107, 123, 110, 0.04) 61px
        );
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

/* --- Clock Wipe Transition --- */
.clock-wipe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
}

/* --- Parallax Container --- */
.parallax-container {
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 1200px;
    overflow: hidden;
}

/* --- Depth Layers --- */
.depth-bg {
    position: absolute;
    top: -20%;
    left: -5%;
    width: 110%;
    height: 140%;
    z-index: 1;
    will-change: transform;
}

.depth-bg svg {
    width: 100%;
    height: 100%;
    opacity: 0.35;
}

.depth-content {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 8%;
}

.depth-fg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    will-change: transform;
}

/* --- Geometric Shapes (Foreground) --- */
.geo-shape {
    position: absolute;
    opacity: 0.15;
    will-change: transform;
}

.geo-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--patina-bright);
    animation: geoRotate 20s linear infinite;
}

.geo-square {
    width: 100px;
    height: 100px;
    border: 2px solid var(--verdigris-gold);
    animation: geoScale 12s var(--ease-mechanical) infinite alternate;
}

.geo-triangle {
    width: 0;
    height: 0;
    border-left: 55px solid transparent;
    border-right: 55px solid transparent;
    border-bottom: 95px solid transparent;
    border-bottom-color: rgba(196, 69, 54, 0.3);
    animation: geoTranslate 15s var(--ease-mechanical) infinite alternate;
}

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

@keyframes geoScale {
    0% { transform: scale(1); }
    100% { transform: scale(1.25); }
}

@keyframes geoTranslate {
    0% { transform: translateY(0); }
    100% { transform: translateY(30px); }
}

/* --- Section Content --- */
.section-content {
    max-width: 650px;
}

.anchor-left .section-content,
.anchor-left {
    margin-right: auto;
}

.anchor-right .section-content,
.anchor-right {
    margin-left: auto;
}

.anchor-center {
    margin: 0 auto;
    text-align: center;
}

/* --- Mono Label (DM Mono) --- */
.mono-label {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Section Label --- */
.section-label {
    color: var(--patina-bright);
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.light-zone .section-label {
    color: var(--canopy-green);
}

/* --- Hero Title --- */
.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin-bottom: 1.5rem;
    color: var(--parchment);
}

.hero-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(40px);
}

.hero-title .char.animated {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s var(--ease-mechanical), transform 0.5s var(--ease-mechanical);
}

.hero-title .char-space {
    display: inline-block;
    width: 0.3em;
}

/* --- Section Title --- */
.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.dark-zone .section-title {
    color: var(--parchment);
}

.light-zone .section-title {
    color: var(--deep-forest);
}

.section-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(40px);
}

.section-title .char.animated {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s var(--ease-mechanical), transform 0.5s var(--ease-mechanical);
}

.section-title .char-space {
    display: inline-block;
    width: 0.3em;
}

/* --- Hero Subtitle --- */
.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(1.1rem, 1.4vw, 1.35rem);
    line-height: 1.72;
    color: var(--aged-linen);
    margin-bottom: 2.5rem;
    max-width: 540px;
}

/* --- Hero CTA Area --- */
.hero-cta-area {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.timestamp {
    color: var(--patina-bright);
    font-size: clamp(0.85rem, 1.1vw, 1.05rem);
}

.clock-divider {
    width: 40px;
    height: 1px;
    background: var(--stone-gray);
}

.game-status {
    color: var(--stone-gray);
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
}

/* --- Section Body Text --- */
.section-body {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.72;
    margin-bottom: 2.5rem;
    max-width: 520px;
}

.dark-zone .section-body {
    color: var(--aged-linen);
}

.light-zone .section-body {
    color: var(--charcoal-ink);
}

/* --- Info Block (Section 2) --- */
.info-block {
    display: flex;
    gap: 2.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.info-number {
    font-size: clamp(1.4rem, 2vw, 1.8rem);
    color: var(--deep-forest);
    font-weight: 500;
}

.info-desc {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--stone-gray);
}

/* --- Token Showcase (Section 3) --- */
.token-showcase {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.token-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 1.5rem 1.2rem;
    border: 1px solid rgba(82, 183, 136, 0.2);
    background: rgba(10, 31, 20, 0.4);
    transition: transform 0.3s var(--ease-mechanical), border-color 0.3s var(--ease-mechanical), box-shadow 0.3s var(--ease-mechanical);
    cursor: none;
}

.token-card:hover {
    transform: translateY(-2px);
    border-color: var(--patina-bright);
    box-shadow: 0 4px 20px rgba(82, 183, 136, 0.12);
}

.token-card:active {
    transform: translateY(1px);
    transition: transform 50ms var(--ease-bounce);
}

.token-name {
    color: var(--patina-bright);
    font-size: 0.75rem;
}

.token-power {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--aged-linen);
}

/* --- District Grid (Section 4) --- */
.district-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.district-cell {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.8rem;
    border: 1px solid rgba(107, 123, 110, 0.3);
    background: rgba(232, 223, 208, 0.5);
    transition: transform 0.3s var(--ease-mechanical), border-color 0.3s var(--ease-mechanical), box-shadow 0.3s var(--ease-mechanical);
    cursor: none;
}

.district-cell:hover {
    transform: translateY(-2px);
    border-color: var(--canopy-green);
    box-shadow: 0 4px 16px rgba(45, 106, 79, 0.1);
}

.district-cell:active {
    transform: translateY(1px);
    transition: transform 50ms var(--ease-bounce);
}

.district-cell.active {
    border-color: var(--patina-bright);
    background: rgba(82, 183, 136, 0.08);
}

.district-num {
    font-size: 0.7rem;
    color: var(--stone-gray);
}

.district-bar {
    height: 4px;
    background: var(--aged-linen);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.district-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--canopy-green);
    border-radius: 2px;
    transition: width 1.2s var(--ease-mechanical);
}

.district-bar.animated::after {
    width: var(--fill);
}

.district-cell.active .district-bar::after {
    background: var(--patina-bright);
}

.district-time {
    font-size: 0.7rem;
    color: var(--deep-forest);
}

/* --- Rift Display (Section 5) --- */
.rift-display {
    display: flex;
    align-items: center;
    gap: 3rem;
}

.rift-clock svg {
    filter: drop-shadow(0 0 20px rgba(82, 183, 136, 0.3));
}

.rift-hand-1 {
    transform-origin: 100px 100px;
    animation: riftHand1 4s linear infinite;
}

.rift-hand-2 {
    transform-origin: 100px 100px;
    animation: riftHand2 7s linear infinite reverse;
}

.rift-hand-3 {
    transform-origin: 100px 100px;
    animation: riftHand3 3s linear infinite;
}

.rift-hand-4 {
    transform-origin: 100px 100px;
    animation: riftHand4 11s linear infinite reverse;
}

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

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

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

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

.rift-data {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.rift-stat {
    font-size: 0.8rem;
    color: var(--stone-gray);
}

.rift-value {
    color: var(--patina-bright);
}

.rift-value.warning {
    color: var(--verdigris-gold);
}

.rift-value.critical {
    color: var(--rust-clock);
    animation: criticalPulse 1.5s var(--ease-mechanical) infinite;
}

@keyframes criticalPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Endgame Display (Section 6) --- */
.endgame-text {
    margin-left: auto;
    margin-right: auto;
    max-width: 580px;
}

.endgame-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin-top: 1rem;
}

.final-clock svg {
    filter: drop-shadow(0 0 30px rgba(82, 183, 136, 0.15));
}

#final-hour-hand {
    transform-origin: 120px 120px;
}

#final-minute-hand {
    transform-origin: 120px 120px;
}

#final-second-hand {
    transform-origin: 120px 120px;
}

.convergence-label {
    font-size: 0.9rem;
    color: var(--canopy-green);
    letter-spacing: 0.12em;
}

/* --- Interactive Element Hover/Active States --- */
.interactive-element {
    position: relative;
    transition: transform 0.3s var(--ease-mechanical);
    cursor: none;
}

.interactive-element::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--patina-bright);
    transition: width 0.3s var(--ease-mechanical);
}

.interactive-element:hover {
    transform: translateY(-2px);
}

.interactive-element:hover::after {
    width: 100%;
}

.interactive-element:active {
    transform: translateY(1px);
    transition: transform 50ms var(--ease-bounce);
}

/* --- Gear Diagram (Section 2 BG) --- */
.gear-diagram {
    opacity: 0.2;
    animation: gearSpin 60s linear infinite;
}

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

/* --- Clock Mechanism Large (Section 5 BG) slow rotation --- */
.clock-mechanism-large {
    animation: gearSpin 120s linear infinite;
}

/* --- Section Visibility Animations --- */
.time-zone .depth-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--ease-mechanical), transform 0.8s var(--ease-mechanical);
}

.time-zone.in-view .depth-content {
    opacity: 1;
    transform: translateY(0);
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--midnight-moss);
}

::-webkit-scrollbar-thumb {
    background: var(--canopy-green);
    border-radius: 2px;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .depth-content {
        padding: 0 5% !important;
    }

    .hero-cta-area {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }

    .info-block {
        flex-direction: column;
        gap: 1.5rem;
    }

    .token-showcase {
        flex-direction: column;
        gap: 1rem;
    }

    .district-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rift-display {
        flex-direction: column;
        gap: 1.5rem;
    }

    .anchor-right {
        margin-left: 0;
    }

    .anchor-center {
        text-align: left;
    }

    #timeline-scrubber {
        display: none;
    }

    .geo-shape {
        display: none;
    }
}

@media (max-width: 480px) {
    .district-grid {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }
}

/* --- Selection Styling --- */
::selection {
    background: var(--patina-bright);
    color: var(--deep-forest);
}
