/* chrono.games - Victorian Horological Palace with Dopamine-Maximalism */

:root {
    --graphite: #1c1f26;
    --slate: #2a2d33;
    --ash: #3a3d44;
    --platinum: #e2e2e2;
    --silver: #9ca3af;
    --lime: #a3e635;
    --violet: #8b5cf6;
    --teal: #5eead4;
    --text-dark: #4b5563;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--graphite);
    color: var(--platinum);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* ===== FIXED CLOCK ICON ===== */
#clock-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 24px;
    height: 24px;
    animation: pulse-clock 3s ease-in-out infinite;
}

@keyframes pulse-clock {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ===== PENDULUM CURSOR ===== */
#pendulum {
    position: fixed;
    width: 2px;
    height: 20px;
    background-color: var(--lime);
    pointer-events: none;
    z-index: 99;
    transform: translate(-50%, -50%);
    transition: none;
    opacity: 0;
}

body:hover #pendulum {
    opacity: 1;
}

/* ===== CHAMBERS (SECTIONS) ===== */
.chamber {
    min-height: 100vh;
    padding: clamp(2rem, 5vw, 5rem) clamp(1rem, 3vw, 3rem);
    position: relative;
}

.chamber-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.01em;
    color: var(--platinum);
    text-align: center;
    margin-bottom: clamp(2rem, 4vw, 4rem);
}

/* ===== CHAMBER 1: THE GRAND HALL ===== */
#grand-hall {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    background-color: var(--graphite);
    background-image: radial-gradient(circle at 50% 50%, var(--slate) 0%, var(--graphite) 70%);
}

.clock-dial {
    position: relative;
    width: min(80vw, 500px);
    height: min(80vw, 500px);
}

#clock-dial-svg {
    width: 100%;
    height: 100%;
}

.dial-text {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: 24px;
    fill: var(--platinum);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.radial-lines line {
    opacity: 0.4;
}

/* Botanical drawing animation */
.botanical-drawing .draw-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: draw-stroke 2.5s ease-in-out forwards;
}

.botanical-drawing .draw-path:nth-child(1) { animation-delay: 0.5s; }
.botanical-drawing .draw-path:nth-child(2) { animation-delay: 0.7s; }
.botanical-drawing .draw-path:nth-child(3) { animation-delay: 0.9s; }
.botanical-drawing .draw-path:nth-child(4) { animation-delay: 1.1s; }
.botanical-drawing .draw-path:nth-child(5) { animation-delay: 1.3s; }
.botanical-drawing .draw-path:nth-child(6) { animation-delay: 1.5s; }
.botanical-drawing .draw-path:nth-child(7) { animation-delay: 1.7s; }
.botanical-drawing .draw-path:nth-child(8) { animation-delay: 1.9s; }
.botanical-drawing .draw-path:nth-child(9) { animation-delay: 2.1s; }
.botanical-drawing .draw-path:nth-child(10) { animation-delay: 2.3s; }
.botanical-drawing .draw-path:nth-child(11) { animation-delay: 2.5s; }
.botanical-drawing .draw-path:nth-child(12) { animation-delay: 2.7s; }
.botanical-drawing .draw-path:nth-child(13) { animation-delay: 2.9s; }
.botanical-drawing .draw-path:nth-child(14) { animation-delay: 3.1s; }

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

.hero-counter {
    margin-top: 2rem;
    text-align: center;
}

.hero-counter .counter-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.08em;
    color: var(--lime);
    font-variant-numeric: tabular-nums;
}

/* ===== CHAMBER 2: THE SPECIMEN GALLERY ===== */
#specimen-gallery {
    background-color: var(--graphite);
    max-width: 1280px;
    margin: 0 auto;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.card {
    background-color: var(--slate);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    position: relative;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.card.revealed {
    transform: scale(1);
    opacity: 1;
}

/* Card size variants */
.card-2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

.card-2x1 {
    grid-column: span 2;
}

.card-1x2 {
    grid-row: span 2;
}

.card-1x1 {
    grid-column: span 1;
    grid-row: span 1;
}

/* Gear tooth border */
.gear-border {
    background-image:
        repeating-linear-gradient(90deg, var(--ash) 0px, var(--ash) 4px, transparent 4px, transparent 8px),
        repeating-linear-gradient(90deg, var(--ash) 0px, var(--ash) 4px, transparent 4px, transparent 8px),
        repeating-linear-gradient(0deg, var(--ash) 0px, var(--ash) 4px, transparent 4px, transparent 8px),
        repeating-linear-gradient(0deg, var(--ash) 0px, var(--ash) 4px, transparent 4px, transparent 8px);
    background-size:
        100% 2px,
        100% 2px,
        2px 100%,
        2px 100%;
    background-position:
        0 0,
        0 100%,
        0 0,
        100% 0;
    background-repeat: no-repeat;
}

.gear-border:hover {
    background-position:
        4px 0,
        4px 100%,
        0 4px,
        100% 4px;
}

.card-illustration {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.card-illustration.tall {
    min-height: 280px;
}

.botanical-svg {
    width: 100%;
    max-height: 160px;
}

.botanical-svg.wide {
    max-height: 120px;
}

.card-illustration .tall .botanical-svg {
    max-height: 300px;
}

.card .draw-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2.5s ease-in-out;
}

.card.revealed .draw-path {
    stroke-dashoffset: 0;
}

.card-content {
    padding: 1rem 1.5rem 1.5rem;
}

.specimen-label {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    letter-spacing: 0.01em;
    color: var(--platinum);
    margin-bottom: 0.25rem;
}

.specimen-meta {
    /* Color used for text on light surfaces: #4b5563 */
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: 0.875rem;
    color: var(--silver);
    margin-bottom: 0.5rem;
}

.mono-accent {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.75rem, 1vw, 0.875rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lime);
    font-variant-numeric: tabular-nums;
    display: block;
    margin-top: 0.5rem;
}

.mono-accent.large {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
}

/* ===== CHAMBER 3: THE OBSERVATORY ===== */
#observatory {
    background-color: var(--graphite);
    background-image: radial-gradient(circle at 50% 40%, var(--slate) 0%, var(--graphite) 60%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.observatory-card {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    background-color: var(--slate);
    border-radius: 2px;
    padding: clamp(1.5rem, 3vw, 3rem);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.elevation-svg {
    width: 100%;
    height: auto;
    max-height: 300px;
}

.draw-ridgeline {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 4s ease-in-out;
}

.observatory-card.revealed .draw-ridgeline {
    stroke-dashoffset: 0;
}

.peak-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--lime);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.observatory-card.revealed .peak-label[data-delay='0'] { opacity: 1; transition-delay: 1.5s; }
.observatory-card.revealed .peak-label[data-delay='1'] { opacity: 1; transition-delay: 2.0s; }
.observatory-card.revealed .peak-label[data-delay='2'] { opacity: 1; transition-delay: 2.5s; }
.observatory-card.revealed .peak-label[data-delay='3'] { opacity: 1; transition-delay: 3.0s; }

.observatory-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    color: var(--silver);
    text-align: center;
    max-width: 62ch;
    margin: 2rem auto 0;
    line-height: 1.72;
}

/* ===== CHAMBER 4: THE WORKSHOP ===== */
#workshop {
    background-color: var(--graphite);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.workshop-layout {
    display: grid;
    grid-template-columns: 60fr 40fr;
    gap: clamp(2rem, 4vw, 4rem);
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    align-items: center;
}

.workshop-left {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.gear-mechanism {
    position: relative;
    width: min(50vw, 400px);
    height: min(50vw, 400px);
}

.gear {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--ash);
    top: 50%;
    left: 50%;
}

.gear-outer {
    width: 90%;
    height: 90%;
    transform: translate(-50%, -50%);
    animation: rotate-cw 20s linear infinite;
    border-color: var(--ash);
    border-width: 2px;
    border-style: dashed;
}

.gear-middle {
    width: 65%;
    height: 65%;
    transform: translate(-50%, -50%);
    animation: rotate-ccw 14s linear infinite;
    border-color: var(--violet);
    border-width: 1px;
    border-style: dashed;
}

.gear-inner {
    width: 40%;
    height: 40%;
    transform: translate(-50%, -50%);
    animation: rotate-cw 8s linear infinite;
    border-color: var(--teal);
    border-width: 1px;
    border-style: dashed;
}

.gear-center {
    width: 12%;
    height: 12%;
    transform: translate(-50%, -50%);
    background-color: var(--lime);
    opacity: 0.3;
    border: none;
}

@keyframes rotate-cw {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes rotate-ccw {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(-360deg); }
}

.workshop-right {
    padding: clamp(1rem, 2vw, 2rem) 0;
}

.measurement-stack {
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 3vw, 2.5rem);
}

.measurement {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.measurement.revealed {
    opacity: 1;
    transform: translateX(0);
}

.measurement-label {
    font-family: 'Zilla Slab', serif;
    font-weight: 400;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--silver);
    letter-spacing: 0.01em;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

/* ===== CHAMBER 5: THE CLOSING BELL ===== */
#closing-bell {
    background-color: var(--graphite);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.closing-card {
    text-align: center;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.closing-border {
    position: relative;
    padding: clamp(3rem, 6vw, 6rem) clamp(2rem, 4vw, 4rem);
    border: 1px solid var(--ash);
    border-radius: 2px;
}

.border-botanicals {
    position: absolute;
    left: 10%;
    width: 80%;
    height: 20px;
}

.top-border {
    top: -10px;
}

.bottom-border {
    bottom: -10px;
}

.border-motif-group .draw-path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.closing-card.revealed .border-motif-group .draw-path {
    stroke-dashoffset: 0;
}

.border-motif-group .draw-path:nth-child(1) { transition-delay: 0s; }
.border-motif-group .draw-path:nth-child(2) { transition-delay: 0.1s; }
.border-motif-group .draw-path:nth-child(3) { transition-delay: 0.2s; }
.border-motif-group .draw-path:nth-child(4) { transition-delay: 0.3s; }
.border-motif-group .draw-path:nth-child(5) { transition-delay: 0.4s; }
.border-motif-group .draw-path:nth-child(6) { transition-delay: 0.5s; }
.border-motif-group .draw-path:nth-child(7) { transition-delay: 0.6s; }
.border-motif-group .draw-path:nth-child(8) { transition-delay: 0.7s; }
.border-motif-group .draw-path:nth-child(9) { transition-delay: 0.8s; }
.border-motif-group .draw-path:nth-child(10) { transition-delay: 0.9s; }

.closing-content {
    position: relative;
    z-index: 1;
}

.closing-domain {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4rem);
    color: var(--platinum);
    letter-spacing: 0.01em;
    margin-bottom: 1.5rem;
}

.live-clock {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--lime);
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
}

.clock-sep {
    color: var(--teal);
    animation: blink-sep 1s step-end infinite;
}

@keyframes blink-sep {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-2x2 {
        grid-column: span 2;
        grid-row: span 1;
    }

    .card-2x1 {
        grid-column: span 2;
    }

    .card-1x2 {
        grid-row: span 1;
    }

    .workshop-layout {
        grid-template-columns: 1fr;
    }

    .workshop-left {
        min-height: 300px;
    }
}

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

    .card-2x2,
    .card-2x1,
    .card-1x2 {
        grid-column: span 1;
        grid-row: span 1;
    }

    .clock-dial {
        width: min(90vw, 350px);
        height: min(90vw, 350px);
    }

    .gear-mechanism {
        width: min(70vw, 280px);
        height: min(70vw, 280px);
    }

    .peak-label {
        font-size: 7px;
    }
}
