/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Every CSS custom-property definition of the browser pages lives here; the other stylesheets only use var(--x).
   Loaded directly by every page that styles from it (login, train, game, lobby3d, chart, pad-test). Order is the old cascade order
   (training, menu, phone-menu, touch, play, lobby, tool pages) inside each section. Selectors are the ones the properties
   were defined under; a property defined twice (--menu-row-h, --ch, --cw, --gut, --gutv, --ta-top) keeps its relative order. */

/* ---- Palette ---- */

/* phone-menu.css: the one menu style */
.menu:not(body) { /* body.menu is the page's settings flag */
  --menu-gap: 2px; --menu-accent: #5ab4ff; --menu-fg: #f2f2ec; --menu-dim: #a4abb6;
  --menu-bg: #15171d; --menu-bg-focus: #1d2027;
}

/* training.css: L-cancel readout colours */
#lcancel {
  --hit: #4ade80; --early: #fbbf24; --late: #ff5c8a; --none: #aab2bd; --muted: #a4abb6;
  --cell: #2a2e37; --band: rgba(74,222,128,.6); --band-edge: #4ade80;
}

/* phone-menu.css and play.css share one palette */
#phone-menu, #play-ui, #song-results, #pl-dialog, .pm-list-page, .pw, .as-page {
  --pm-bg: #0b0d10; --pm-panel: #14171c; --pm-border: #2a2e35; --pm-line: #1d2128; --pm-text: #ece9e0; --pm-dim: #8d93a0; --pm-blue: #5ab4ff;
  --pm-amber: #ffb35c;
}
#phone-menu { --pm-sel: #1e3a55; --pm-on: #2f7d4a; --pm-quit: #ff7a7a; }
.pw, .as-page { --pm-quit: #ff7a7a; --sel: #1e3a55; --on: #2f7d4a; --r: 8px; }
/* The pause ring: ring-top is the strip above it (the song bar sets it); ring-cx/cy/fw/fh (the free middle box) are written by phone-menu.mjs from the root (the whole viewport). */
#phone-menu { --ring-top: 0px; --ring-cx: 50%; --ring-cy: 50%; --ring-fw: 60vw; --ring-fh: 60vh; --ring-dim: rgba(0, 0, 0, .35); --ring-glass: rgba(11, 13, 16, .55); --ring-glass-sel: rgba(30, 58, 85, .7); --ring-panel: rgba(20, 23, 28, .94); }
#phone-menu:has(#song-bar:not([hidden])) { --ring-top: 52px; }
.pm-dp { --dp-ground: #121218; --dp-card: #1A1A21; --dp-line: #26262F; --dp-gold: #FFC83D; --dp-green: #5BD07A; --dp-red: #FF8A8A; }
#play-ui { --pm-green: #7fe08a; --pm-red: #ff7a7a; }

/* lobby3d.html */
:root { --bg: #0b0b10; --fg: #ddd; --dim: #888; --lobby: #4c8; --game: #e8c349; }

/* chart.html and pad-test.html (renamed from --bg --fg --card --line, which lobby3d's :root uses with other values) */
:root { --tool-bg: #111; --tool-fg: #e8e8ec; --tool-card: #1b1d26; --tool-line: #2a2c36; }
@media (prefers-color-scheme: light) { :root { --tool-bg: #f6f6f8; --tool-fg: #16161a; --tool-card: #fff; --tool-line: #ccd; } }

/* ---- Layout geometry ---- */

/* phone-menu.css: row height, tighter on a short phone in landscape */
.menu:not(body) { --menu-row-h: 2.2em; }
@media (max-height: 520px) {
  .menu:not(body) { --menu-row-h: 1.9em; }
}

/* training.css: the 4:3 picture is centred in the viewport; --gut/--gutv are the side or top/bottom bars around it, --ch/--cw its height and width */
:root { --gut: calc((100vw - min(100vw, 100dvh * 4 / 3)) / 2); --gutv: calc((100dvh - min(100dvh, 100vw * 3 / 4)) / 2); }
#lcancel { --ch: min(100dvh, 100vw * 3 / 4); --cw: min(100vw, 100dvh * 4 / 3); }

/* touch.css */
@media (min-aspect-ratio: 2/1) {
  body[data-touch-layout="columns"]:not(.tier1) { --c: max(44px, calc((var(--gut) - 24px) / 2)); }
}
#touch { --ta-top: calc(68px + env(safe-area-inset-top)); --sl: env(safe-area-inset-left); --sr: env(safe-area-inset-right); --sb: env(safe-area-inset-bottom); }

/* play.css: the play screen, one layout at every size. --gh = 4:3 picture height: 75vw wide-fit, or what is left under the bar and strip. */
body.play-screen.playing { --pt: calc(52px + env(safe-area-inset-top)); --gh: min(75vw, calc(100dvh - var(--pt) - 40px)); --gb: calc(var(--pt) + var(--gh)); --padtop: calc(var(--gb) + 40px); }
body.play-screen.playing #lcancel { --ch: var(--gh); --cw: calc(var(--gh) * 4 / 3); --gut: calc((100vw - var(--cw)) / 2); --gutv: var(--pt); }
@media (orientation: portrait) {
  body.play-screen.playing #touch { --ta-top: 4px; }
}

/* ---- Component-local ---- */

/* training.css: L-cancel readout. The place (#356): --fx --fy are 0..1 of the picture, --s scales around that anchor (small undocked, full size docked) */
#lcancel {
  --bw: 4px;
  --display: "Arial Narrow", system-ui, sans-serif;
  --cellh: clamp(36px, min(calc(var(--ch) * .09), calc(var(--cw) * .11)), 96px);
  --small: clamp(10px, min(calc(var(--ch) * .018), calc(var(--cw) * .03)), 18px);
  --count: clamp(11px, min(calc(var(--ch) * .025), calc(var(--cw) * .034)), 28px);
  --fx: .5; --fy: .22; --s: .5;
}
#lcancel[data-dock=left], #lcancel[data-dock=right] { --s: 1; }
#lcancel[data-k=hit] { --vc: var(--hit); } #lcancel[data-k=early] { --vc: var(--early); }
#lcancel[data-k=late] { --vc: var(--late); } #lcancel[data-k=none] { --vc: var(--none); }
#lcancel .lane { --chiph: clamp(24px, min(calc(var(--ch) * .06), calc(var(--cw) * .08)), 60px);
  --chipw: clamp(50px, min(calc(var(--ch) * .11), calc(var(--cw) * .16)), 130px); }
#hud-input .cstick { --t: 12px; }

/* Planned UI (store/planned.mjs): author CSS that sets display must not un-hide it on the public site */
[data-planned][hidden] { display: none !important; }
