/* web/shell/site.css -- the page around the game: loading screen, start gate, settings, controls help, toasts.
   Colours from the game's own UI: silver menu text and frames, the logo's gold, the "2049" blue. */
:root {
  --ink: #05070c;
  --panel: rgba(9, 12, 19, 0.86);
  --silver: #e3e6ec;
  --muted: #8f96a4;
  --frame-hi: #a9b0bc;
  --frame-lo: #3b404b;
  --gold: #f5c211;
  --gold-hi: #fff0a0;
  --gold-lo: #c86a00;
  --blue: #3a6bff;
  --blue-glow: rgba(80, 140, 255, 0.45);
  --red: #ff4d5e;
  --cut: 12px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: "Exo 2", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--silver); }
body { font: 500 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
body:not(.dev) .dev-only { display: none !important; }
kbd { font: 600 0.85em var(--font); padding: 0.05em 0.4em; border: 1px solid var(--frame-lo); border-radius: 3px; color: var(--silver); }

/* ---- the game: full-bleed, letterboxed by the canvas itself when its shape differs (Original graphics: 4:3) */
#stage { position: fixed; inset: 0; background: #000; }
#stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; outline: none; background: #000; }
body.cursor-idle, body.cursor-idle #stage > canvas { cursor: none; }

/* ---- the game's frames: chamfered corners, a silver edge, a dark glass face */
.frame { position: relative; isolation: isolate; }
.frame::before, .frame::after { content: ""; position: absolute; z-index: -1; pointer-events: none; }
.frame::before { inset: 0; background: linear-gradient(165deg, var(--frame-hi), var(--frame-lo) 38%, #2a2e37 62%, #6f7582); clip-path: var(--chamfer); }
.frame::after { inset: 1.5px; background: var(--panel); clip-path: var(--chamfer-inner); }
.frame {
  --chamfer: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
  --c2: calc(var(--cut) - 0.6px);
  --chamfer-inner: polygon(var(--c2) 0, calc(100% - var(--c2)) 0, 100% var(--c2), 100% calc(100% - var(--c2)), calc(100% - var(--c2)) 100%, var(--c2) 100%, 0 calc(100% - var(--c2)), 0 var(--c2));
}

/* ---- loading screen and start gate */
#loader { position: fixed; inset: 0; z-index: 20; background: var(--ink); overflow: hidden; transition: opacity 0.9s var(--ease), visibility 0s linear 0.9s; }
#loader.leaving { opacity: 0; visibility: hidden; }
.loader-art { position: absolute; inset: 0; background: url(title.webp) center top / cover no-repeat; filter: brightness(0.94) saturate(1.05); transform-origin: 50% 20%; animation: drift 40s ease-out both; }
.loader-art::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to bottom, rgba(5, 7, 12, 0) 45%, rgba(5, 7, 12, 0.78) 72%, var(--ink) 92%),
    radial-gradient(ellipse at 50% 35%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%);
}
@keyframes drift { from { transform: scale(1.0); opacity: 0; } 4% { opacity: 1; } to { transform: scale(1.06); opacity: 1; } }
.loader-foot { position: absolute; left: 50%; bottom: max(7vh, 40px); width: min(520px, calc(100vw - 32px)); transform: translateX(-50%); display: grid; justify-items: center; gap: 18px; text-align: center; }

.progress { width: 100%; transition: opacity 0.5s var(--ease); }
.progress.done { opacity: 0; }
.progress-track { height: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold) 70%, var(--gold-hi)); box-shadow: 0 0 12px rgba(245, 194, 17, 0.65); transition: width 0.35s var(--ease); }
.progress-label { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
#loader-bytes { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }

.gate { appearance: none; background: none; border: 0; padding: 8px 16px; cursor: pointer; display: grid; gap: 8px; animation: rise 0.7s var(--ease) both; }
.gate:focus, .gate:focus-visible { outline: none; }
.gate-text {
  font: italic 800 clamp(22px, 3.2vw, 34px)/1 var(--font); letter-spacing: 0.06em; text-transform: uppercase;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.6)) drop-shadow(0 0 18px rgba(245, 194, 17, 0.25));
  animation: pulse 2.2s ease-in-out infinite;
}
.gate-sub { font-size: 12px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.notice { width: 100%; padding: 22px 24px; text-align: left; animation: rise 0.5s var(--ease) both; }
.notice h2 { margin: 0 0 6px; font-size: 17px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--silver); }
.notice p { margin: 0; color: var(--muted); }
.notice-error h2 { color: #ffb3ba; }
.notice-actions { margin-top: 16px; display: flex; gap: 10px; }

/* ---- buttons */
.button {
  --cut: 7px; position: relative; isolation: isolate; appearance: none; border: 0; background: none; cursor: pointer;
  padding: 9px 18px; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--silver);
  transition: color 0.15s;
}
.button::before, .button::after { content: ""; position: absolute; z-index: -1; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); }
.button::before { inset: 0; background: linear-gradient(165deg, var(--frame-hi), var(--frame-lo)); }
.button::after { inset: 1.5px; background: #10141d; transition: background 0.15s; }
.button:hover, .button:focus-visible { color: var(--gold); outline: none; }
.button:hover::after, .button:focus-visible::after { background: #161b27; }
.button-small { padding: 6px 12px; font-size: 12px; }

.icon-button { --cut: 8px; position: relative; isolation: isolate; width: 42px; height: 42px; display: grid; place-items: center; border: 0; padding: 0; background: none; cursor: pointer; color: var(--silver); }
.icon-button::before, .icon-button::after { content: ""; position: absolute; z-index: -1; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); }
.icon-button::before { inset: 0; background: linear-gradient(165deg, rgba(169, 176, 188, 0.7), rgba(59, 64, 75, 0.7)); }
.icon-button::after { inset: 1.5px; background: rgba(9, 12, 19, 0.78); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover, .icon-button:focus-visible { color: var(--gold); outline: none; }
#open-fullscreen .leave { display: none; }
body.fullscreen #open-fullscreen .enter { display: none; }
body.fullscreen #open-fullscreen .leave { display: inline; }

/* ---- the corner controls: shown while the pointer moves */
.chrome { position: fixed; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 10; display: flex; gap: 8px; opacity: 0; transform: translateY(-4px); transition: opacity 0.35s var(--ease), transform 0.35s var(--ease); pointer-events: none; }
body.pointer-active .chrome, .chrome:focus-within { opacity: 1; transform: none; pointer-events: auto; }

/* ---- controls help */
.glyph { width: 34px; height: 34px; flex: none; fill: url(#glyph-metal) var(--silver); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.8)) drop-shadow(0 0 6px var(--blue-glow)); }
.glyph-wide { width: 44px; }
.controls { display: grid; grid-template-columns: auto auto auto; gap: 6px 22px; align-items: center; }
.controls .head { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.controls .action { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--silver); white-space: nowrap; }
.controls .keys { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; }
.controls .or { padding: 0 4px; font-size: 11px; color: var(--muted); }
.controls-card { position: fixed; left: max(20px, env(safe-area-inset-left)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 9; padding: 16px 20px 14px; transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.controls-card.leaving { opacity: 0; transform: translateY(6px); }
.controls-card h2 { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); }
.controls-card .hint { margin: 10px 0 0; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }

/* ---- settings */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(2, 3, 6, 0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fade 0.25s var(--ease) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel { --cut: 16px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 26px 18px; animation: rise 0.35s var(--ease) both; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h2 { margin: 0; font: italic 800 22px/1 var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--silver); }
.panel-head h2::after { content: ""; display: block; width: 44px; height: 2px; margin-top: 10px; background: linear-gradient(90deg, var(--gold), transparent); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.setting:first-of-type { border-top: 0; }
.setting-stack { display: block; }
.setting-label h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.setting-label p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.setting-stack .setting-label { margin-bottom: 14px; }
.setting-restart { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -6px 0 10px; padding: 10px 14px; font-size: 13px; color: var(--gold); background: rgba(245, 194, 17, 0.07); }
.segmented { display: flex; gap: 2px; padding: 3px; background: rgba(255, 255, 255, 0.05); }
.segmented button { appearance: none; border: 0; background: none; cursor: pointer; padding: 8px 14px; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); transition: color 0.15s, background 0.15s; }
.segmented button:hover { color: var(--silver); }
.segmented button[aria-checked="true"] { color: var(--ink); background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, #e0a400); }
.segmented button:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }
.panel-foot { margin-top: 6px; font-size: 11px; letter-spacing: 0.06em; color: #5d6370; }

/* ---- the race menu of an online match (web/online/src/browser/race-menu.ts): over the race, which runs on underneath */
.race-menu { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(2, 3, 6, 0.55), rgba(2, 3, 6, 0.2) 70%); animation: fade 0.2s var(--ease) both; }
.race-menu[hidden] { display: none; }
.race-menu-panel { --cut: 14px; width: min(340px, 100%); padding: 20px 24px 22px; text-align: center; animation: rise 0.25s var(--ease) both; }
.race-menu-panel h2 { margin: 0; font: italic 800 24px/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: var(--silver); }
.race-menu-panel h2::after { content: ""; display: block; width: 44px; height: 2px; margin: 10px auto 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.race-menu-note { margin: 10px 0 16px; font-size: 12px; line-height: 1.45; letter-spacing: 0.04em; color: var(--muted); }
.race-menu-list { display: grid; gap: 8px; }
.race-menu-choice { width: 100%; padding: 11px 18px; font: italic 700 15px/1 var(--font); letter-spacing: 0.14em; }
.race-menu-choice.selected { color: var(--ink); }
.race-menu-choice.selected::after { background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, #e0a400); }

/* ---- toasts */
.toasts { position: fixed; top: max(18px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 40; display: grid; gap: 10px; width: min(460px, calc(100vw - 32px)); pointer-events: none; }
.toast { --cut: 10px; padding: 14px 18px 14px 22px; pointer-events: auto; animation: drop 0.45s var(--ease) both; transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); }
.toast.leaving { opacity: 0; transform: translateY(-8px); }
.toast .bar { position: absolute; left: 9px; top: 14px; bottom: 14px; width: 3px; background: var(--blue); box-shadow: 0 0 10px var(--blue-glow); }
.toast.success .bar { background: var(--gold); box-shadow: 0 0 10px rgba(245, 194, 17, 0.6); }
.toast.error .bar { background: var(--red); box-shadow: 0 0 10px rgba(255, 77, 94, 0.5); }
.toast strong { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.toast.success strong { color: var(--gold); }
.toast span { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---- developer controls (?dev=1): the old status line and texture pack picker */
#status { position: fixed; left: 0; bottom: 0; z-index: 50; max-width: 70vw; padding: 3px 10px; font: 12px/1.5 ui-monospace, Menlo, monospace; color: #9aa; background: rgba(0, 0, 0, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#texture-pack { position: fixed; right: 0; bottom: 0; z-index: 50; display: flex; gap: 8px; align-items: center; padding: 4px 10px; font: 12px ui-monospace, Menlo, monospace; color: #9aa; background: rgba(0, 0, 0, 0.6); }
#texture-pack button { font: inherit; color: #ddd; background: #1a1a1a; border: 1px solid #333; border-radius: 3px; padding: 1px 7px; cursor: pointer; }

@media (max-width: 640px) {
  .setting { flex-direction: column; align-items: flex-start; }
  .controls { gap: 6px 12px; }
  .panel { padding: 18px 16px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (max-aspect-ratio: 1/1) {
  .loader-art { background-size: 170vw auto; background-position: 56% 8vh; }
}

/* ---- the room link (web/online browser/room-invite.ts): "Copy invite" over the ONLINE screens while the player is in a room; bottom-right, where the 4:3 lobby has only background art */
#copy-invite { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); right: max(16px, env(safe-area-inset-right)); z-index: 10; animation: rise 0.35s var(--ease) both; }
#copy-invite[hidden] { display: none; }
