/*
 * THERMAL.
 *
 * Three layers, the same structure the weather console uses (core.css:76-91):
 *   0  #sky    the live WebGL sky, opaque, owns every pixel it covers
 *   1  #stage  a transparent 2D canvas: terrain, glider, cumulus
 *   2  .hud    text, pointer-events:none except on controls
 *
 * The sky canvas is created with alpha:false and draws a full-screen triangle
 * with no clear and no blend, so nothing can be composited underneath it and a
 * separate 2D canvas is the only way to draw over it.
 */

@font-face {
    font-family: 'Chakra Petch';
    src: url('/weather/assets/fonts/chakrapetch-600.woff2') format('woff2');
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/weather/assets/fonts/jetbrainsmono-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

:root {
    --ink: #eaf4ff;
    --dim: #9fb6c8;
    --faint: #5b7288;
    --cy: #00eaff;
    --am: #ffb02e;
    --lm: #6dff4a;
    --rd: #ff3b57;
    --panel: rgba(4, 10, 20, .72);
    --edge: rgba(0, 234, 255, .28);
    --cut: 10px;
    --ui: 'Chakra Petch', ui-sans-serif, system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #06101d;
    color: var(--ink);
    font-family: var(--ui);
}

/* Sky.resize() reads clientWidth/clientHeight. Without an explicit layout size
   it silently produces a 2x2 framebuffer and renders nothing at all. */
#sky, #stage {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Also the no-WebGL fallback: init() returns false rather than throwing, and
   this gradient is what stands in. */
#sky {
    z-index: 0;
    background: linear-gradient(#0a1830 0%, #1b3a5c 55%, #35506b 65%, #101c28 100%);
}

#stage {
    z-index: 1;
    /* Without this a drag to dive scrolls the page and the game is unplayable
       on a phone. */
    touch-action: none;
}

#stage:focus-visible { outline: 2px solid var(--cy); outline-offset: -4px; }

.hud {
    position: relative;
    z-index: 2;
    height: 100%;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.hud button, .hud a { pointer-events: auto; }

.back-link {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--dim);
    text-decoration: none;
    font-size: .72rem;
    letter-spacing: .08em;
    padding: 6px 11px;
    border: 1px solid var(--edge);
    background: var(--panel);
}

.back-link:hover, .back-link:focus { color: var(--cy); }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus {
    left: 8px; top: 8px; z-index: 200;
    background: var(--cy); color: #04121d; padding: 10px 16px; font-weight: 600;
}

.top { text-align: left; }

.title {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: .3em;
    color: var(--cy);
    text-shadow: 0 0 8px rgba(0, 234, 255, .45);
}

.sub {
    margin: 3px 0 0;
    font-family: var(--mono);
    font-size: .66rem;
    letter-spacing: .14em;
    color: var(--dim);
    text-transform: uppercase;
}

.dot { color: var(--faint); margin: 0 5px; }

.gauges { display: flex; gap: 8px; max-width: 430px; }

.gauge {
    flex: 1;
    padding: 6px 10px;
    background: var(--panel);
    border: 1px solid var(--edge);
    clip-path: polygon(0 var(--cut), var(--cut) 0, 100% 0,
        100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
}

.g-k { display: block; font-size: .55rem; letter-spacing: .2em; color: var(--faint); }

.g-v {
    display: block;
    font-family: var(--mono);
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
}

.vario-bar {
    margin-top: 4px;
    height: 3px;
    background: rgba(255, 255, 255, .12);
    position: relative;
}

/* Centre-zero: lift grows right and green, sink grows left and red. */
.vario-bar i {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 0;
    background: var(--lm);
    transition: none;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
    font-family: var(--mono);
    font-size: .62rem;
    letter-spacing: .1em;
    color: var(--dim);
    padding: 4px 8px;
    background: var(--panel);
    border: 1px solid var(--edge);
}

#b-source.live { color: var(--lm); }

.card[hidden] { display: none; }

.card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 380px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    text-align: center;
    background: rgba(3, 8, 16, .9);
    border: 1px solid var(--edge);
    pointer-events: auto;
}

.card-title { margin: 0; font-size: 1.3rem; letter-spacing: .12em; color: var(--cy); }
.card-line { margin: 0; font-family: var(--mono); font-size: .76rem; color: var(--dim); line-height: 1.6; }

.card-teach[hidden] { display: none; }

.card-teach {
    margin: 2px 0 0;
    max-width: 30ch;
    font-family: var(--mono);
    font-size: .68rem;
    line-height: 1.7;
    color: var(--lm);
}

.card-share {
    margin: 4px 0 0;
    padding: 9px 12px;
    font-family: var(--mono);
    font-size: .7rem;
    line-height: 1.6;
    background: rgba(0, 0, 0, .45);
    border: 1px solid var(--edge);
    white-space: pre;
    text-align: left;
}

.card-share[hidden] { display: none; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 4px; }
.card-next { margin: 2px 0 0; font-family: var(--mono); font-size: .64rem; color: var(--faint); }

button {
    font-family: var(--ui);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink);
    background: rgba(6, 14, 26, .9);
    border: 1px solid var(--edge);
    padding: 9px 16px;
    cursor: pointer;
}

button[hidden] { display: none; }
button:hover:not(:disabled) { color: var(--cy); border-color: var(--cy); }
button.primary { color: #04121d; background: var(--cy); border-color: var(--cy); }
button.primary:hover { background: #6df3ff; }

.hint, .say {
    margin: 0;
    font-family: var(--mono);
    font-size: .64rem;
    color: var(--faint);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.say { color: var(--dim); min-height: 1.4em; margin-top: auto; }

/*
 * Reduced motion strips decoration, not the game: the sky keeps rendering (with
 * no clear, stopping it just freezes the last frame, and a frozen sky under a
 * moving glider is worse than a slow one) and the glider keeps flying, because
 * the flight IS the mechanic.
 */
@media (prefers-reduced-motion: reduce) {
    .title { text-shadow: none; }
    * { transition: none !important; }
}

@media (max-width: 420px) {
    .title { font-size: 1.05rem; }
    .g-v { font-size: .9rem; }
    .hud { padding: 10px; }
}
