/* TerraPrinter Global — a blueprint planet.
   Ink-blue night, two filament colours that mean something:
   glacier = a model made, filament orange = a model downloaded to print. */
:root {
    --ink: #04101F;
    --ink-2: #0A1D36;
    --glacier: #8BE9FF;
    --filament: #FF9A3C;
    --paper: #E9F1FA;
    --muted: #8DA2BC;
    --line: rgba(139, 233, 255, 0.16);
    --font: 'Bricolage Grotesque', system-ui, sans-serif;
    --gutter: clamp(16px, 3vw, 36px);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--glacier); outline-offset: 3px; border-radius: 6px; }
.g-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#gGlobe {
    position: fixed; inset: 0;
    width: 100vw; height: 100vh; height: 100dvh;
    display: block;
    cursor: grab;
    touch-action: none;
}
#gGlobe:active { cursor: grabbing; }

/* ---- Title ------------------------------------------------------------ */
.g-head {
    position: fixed; top: var(--gutter); left: var(--gutter);
    max-width: 34ch;
    pointer-events: none;
}
.g-head > * { pointer-events: auto; }
.g-brand {
    display: inline-flex; align-items: center; gap: 10px;
    text-decoration: none; font-weight: 600; font-size: 15px;
    color: var(--paper); opacity: 0.85;
}
.g-brand:hover { opacity: 1; }
.g-brand img { width: 28px; height: 28px; }
.g-head h1 {
    margin: 18px 0 8px;
    font-weight: 600;
    font-size: clamp(30px, 3.4vw, 46px);
    line-height: 1.02;
    letter-spacing: -0.02em;
    font-variation-settings: 'opsz' 96;
}
.g-head p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---- The clock: the hero type ----------------------------------------- */
.g-clock {
    position: fixed; right: var(--gutter); top: var(--gutter);
    text-align: right;
    pointer-events: none;
}
.g-date {
    font-weight: 300;
    font-stretch: 75%;
    font-variation-settings: 'wdth' 75, 'opsz' 96;
    font-size: clamp(40px, 6.4vw, 96px);
    line-height: 0.92;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--paper);
    text-shadow: 0 0 40px rgba(139, 233, 255, 0.25);
}
.g-counts {
    margin: 12px 0 0;
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 18px;
    color: var(--muted);
    font-size: 15px;
}
.g-counts b {
    color: var(--glacier);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 19px;
}
.g-counts b.is-down { color: var(--filament); }
.g-counts span:last-child b { color: var(--paper); }

/* ---- Country race ----------------------------------------------------- */
.g-race {
    position: fixed; right: var(--gutter);
    top: calc(var(--gutter) + clamp(150px, 15vw, 210px));
    width: 260px;
}
.g-race h2 {
    margin: 0 0 10px;
    font-size: 15px; font-weight: 600;
    color: var(--paper);
}
.g-race-toggle { display: none; }
.g-race-list {
    list-style: none; margin: 0; padding: 0;
    position: relative;
    height: calc(10 * 30px);
}
.g-race-list li {
    position: absolute; left: 0; right: 0; top: 0;
    height: 26px;
    display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px;
    font-size: 14px;
    transition: transform 0.55s cubic-bezier(.2,.8,.2,1), opacity 0.35s;
    will-change: transform;
}
.g-race-list .g-flag { font-size: 16px; line-height: 1; }
.g-race-list .g-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; z-index: 1; }
.g-race-list .g-num { font-variant-numeric: tabular-nums; color: var(--muted); position: relative; z-index: 1; }
.g-race-list .g-bar {
    position: absolute; left: 30px; top: 3px; bottom: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(139, 233, 255, 0.24), rgba(139, 233, 255, 0.04));
    transition: width 0.6s cubic-bezier(.2,.8,.2,1);
}

/* ---- Legend + make CTA ------------------------------------------------ */
.g-legend {
    position: fixed; left: var(--gutter);
    bottom: calc(var(--gutter) + 92px);
    display: flex; flex-wrap: wrap; gap: 6px 18px;
    font-size: 14px; color: var(--muted);
}
.g-legend span { display: inline-flex; align-items: center; gap: 8px; }
.g-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--glacier);
    box-shadow: 0 0 10px var(--glacier);
}
.g-dot.is-down { background: var(--filament); box-shadow: 0 0 10px var(--filament); }
.g-legend-tip { opacity: 0.75; }

/* ---- Timeline: the ridge ---------------------------------------------- */
.g-time {
    position: fixed; left: 0; right: 0; bottom: 0;
    padding: 14px var(--gutter) max(var(--gutter), env(safe-area-inset-bottom));
    display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 18px;
    background: linear-gradient(to top, rgba(4, 16, 31, 0.92) 30%, rgba(4, 16, 31, 0));
}
.g-play {
    width: 52px; height: 52px; border-radius: 50%;
    border: 1px solid rgba(139, 233, 255, 0.4);
    background: rgba(139, 233, 255, 0.08);
    display: grid; place-items: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.g-play:hover { background: rgba(139, 233, 255, 0.18); border-color: var(--glacier); }
.g-play svg { width: 22px; height: 22px; fill: var(--glacier); }
.g-play .g-ico-pause { display: none; }
.g-play.is-playing .g-ico-play { display: none; }
.g-play.is-playing .g-ico-pause { display: inline; }
.g-ridge-wrap { position: relative; height: 64px; }
#gRidge { width: 100%; height: 64px; display: block; cursor: ew-resize; touch-action: none; }
.g-ridge-tip {
    position: absolute; bottom: 70px;
    transform: translateX(-50%);
    padding: 6px 10px; border-radius: 8px;
    background: rgba(10, 29, 54, 0.95);
    border: 1px solid var(--line);
    font-size: 13px; white-space: nowrap;
    pointer-events: none;
}
.g-ridge-tip b { font-weight: 600; }
.g-tools { display: flex; align-items: center; gap: 10px; }
.g-speed select {
    appearance: none;
    background: rgba(139, 233, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 14px;
    cursor: pointer;
}
.g-speed option { background: var(--ink-2); }
.g-live {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--line); border-radius: 999px;
    background: transparent; padding: 7px 14px;
    cursor: pointer;
}
.g-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.g-live[aria-pressed="true"] { border-color: rgba(255, 154, 60, 0.6); color: var(--paper); }
.g-live[aria-pressed="true"] i { background: var(--filament); box-shadow: 0 0 0 0 rgba(255, 154, 60, 0.7); animation: g-beat 1.6s infinite; }
@keyframes g-beat {
    0% { box-shadow: 0 0 0 0 rgba(255, 154, 60, 0.7); }
    70% { box-shadow: 0 0 0 9px rgba(255, 154, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 154, 60, 0); }
}
.g-make {
    padding: 9px 16px; border-radius: 999px;
    background: var(--filament); color: #241200;
    text-decoration: none; font-weight: 600;
    white-space: nowrap;
}
.g-make:hover { background: #ffad61; }

/* ---- Click-to-make popover -------------------------------------------- */
.g-pop {
    position: fixed; z-index: 5;
    transform: translate(-50%, calc(-100% - 14px));
    padding: 10px 12px; border-radius: 10px;
    background: rgba(10, 29, 54, 0.96);
    border: 1px solid var(--line);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    font-size: 13px;
    text-align: center;
}
.g-pop-where { color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.g-pop-go { color: var(--filament); font-weight: 600; text-decoration: none; }
.g-pop-go:hover { text-decoration: underline; }

/* ---- Loading ---------------------------------------------------------- */
.g-loading {
    position: fixed; inset: 0;
    display: grid; place-content: center; justify-items: center; gap: 16px;
    background: var(--ink);
    transition: opacity 0.8s;
    z-index: 10;
}
.g-loading.is-done { opacity: 0; pointer-events: none; }
.g-loading p { margin: 0; color: var(--muted); }
.g-loading-ring {
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px solid rgba(139, 233, 255, 0.15);
    border-top-color: var(--glacier);
    animation: g-spin 1s linear infinite;
}
@keyframes g-spin { to { transform: rotate(360deg); } }
.g-noscript { position: fixed; inset: auto 0 50% 0; text-align: center; }

/* Intro: the copy arrives with the camera. */
.g-head, .g-clock, .g-race, .g-legend, .g-time { transition: opacity 1.2s ease 0.4s; }
body.is-intro .g-head, body.is-intro .g-clock, body.is-intro .g-race,
body.is-intro .g-legend, body.is-intro .g-time { opacity: 0; }

/* ---- Small screens ---------------------------------------------------- */
@media (max-width: 820px) {
    .g-head { max-width: none; right: var(--gutter); }
    .g-head h1 { font-size: 28px; margin-top: 12px; }
    .g-head p { display: none; }
    .g-clock { top: auto; bottom: calc(var(--gutter) + 120px); right: var(--gutter); left: var(--gutter); text-align: left; }
    .g-date { font-size: 44px; }
    .g-counts { justify-content: flex-start; gap: 2px 14px; font-size: 13px; }
    .g-counts b { font-size: 16px; }
    .g-legend { display: none; }
    .g-race { top: 112px; left: auto; width: auto; }
    .g-race h2 { display: none; }
    .g-race-toggle {
        display: inline-block;
        border: 1px solid var(--line); border-radius: 999px;
        background: rgba(10, 29, 54, 0.8); padding: 6px 12px; font-size: 13px;
        cursor: pointer;
    }
    .g-race-list { display: none; width: 240px; margin-top: 8px; padding: 10px; border-radius: 12px; background: rgba(10, 29, 54, 0.92); box-sizing: content-box; }
    .g-race.is-open .g-race-list { display: block; }
    .g-time { grid-template-columns: auto 1fr; gap: 12px; }
    .g-tools { grid-column: 1 / -1; justify-content: space-between; }
    .g-play { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .g-race-list li, .g-race-list .g-bar { transition: none; }
    .g-live[aria-pressed="true"] i { animation: none; }
    body.is-intro .g-head, body.is-intro .g-clock, body.is-intro .g-race,
    body.is-intro .g-legend, body.is-intro .g-time { opacity: 1; }
}
