/*
 * game-ui.css 1.4.0 — the shared game components of the «وش؟» family (nhmsv docs/GAMES_PHASE2_SPEC.md §2).
 * Copied byte for byte into every game (public/game-ui/), checked by check.sh. Never edit a copy: a change ships as a
 * new version from nhmsv/nhmsv shared/game-ui.
 *
 * Colours come from the game's own tokens (brand.example.css lists the names): --brand, --brand-ink, --on-brand,
 * --accent, --on-accent, --surface, --bg, --ink, --muted, --line, --ok, --bad. This file holds no colour value.
 * Every class starts with gu-. Sizes: icons 24/40/64, touch targets >= 44px, spacing 4/8/12/16/24/32.
 * Fonts: Tajawal (Arabic) and Poppins (Latin, digits in codes), self-hosted by each game (no third-party host).
 */

:root {
  --gu-s1: 4px;
  --gu-s2: 8px;
  --gu-s3: 12px;
  --gu-s4: 16px;
  --gu-s5: 24px;
  --gu-s6: 32px;
  --gu-radius: 14px;
  --gu-radius-lg: 20px;
  --gu-touch: 44px;
  --gu-font: 'Tajawal', 'Poppins', system-ui, sans-serif;
  --gu-font-latin: 'Poppins', 'Tajawal', system-ui, sans-serif;
}

.gu-hidden, [hidden].gu-btn, [hidden].gu-note, [hidden].gu-badge { display: none !important; }
[class^="gu-"], [class*=" gu-"], .gu-code input, .gu-avatar img, .gu-avatar span { box-sizing: border-box; }

/* ---- Icons: 24 / 40 / 64 only, drawn from game-ui-icons.svg (<svg class="gu-icon"><use href="…#gu-i-name"/></svg>). ---- */
.gu-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gu-icon-40 { width: 40px; height: 40px; }
.gu-icon-64 { width: 64px; height: 64px; }

/* ---- Buttons: primary, secondary, danger; a small and a wide form; an icon-only form. ---- */
.gu-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--gu-s2); min-height: var(--gu-touch); min-width: var(--gu-touch);
  padding: 0 var(--gu-s5); border: 1.5px solid var(--line); border-radius: var(--gu-radius); background: var(--surface); color: var(--ink);
  font: inherit; font-family: var(--gu-font); font-weight: 800; font-size: 16px; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform .08s ease, filter .15s ease; }
.gu-btn:hover { filter: brightness(.97); }
.gu-btn:active { transform: translateY(1px); }
.gu-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.gu-btn:disabled, .gu-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.gu-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 3px 0 var(--brand-ink); }
.gu-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.gu-danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.gu-danger.gu-solid { background: var(--bad); color: var(--surface); }
.gu-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.gu-small { min-height: var(--gu-touch); padding: 0 var(--gu-s4); font-size: 14px; }
.gu-wide { width: 100%; }
.gu-icon-btn { padding: 0; width: var(--gu-touch); }
/* 1.4.0: gu-compact, for dense control panels that must fit a short phone without scrolling: 40px, and only when the
   screen is short (max-height 700px); everywhere else the 44px touch target stays. */
@media (max-height: 700px) {
  .gu-btn.gu-compact, .gu-dock .gu-btn.gu-compact { min-height: 40px; padding-inline: var(--gu-s3); }
  .gu-icon-btn.gu-compact { width: 40px; min-width: 40px; }
}

/* ---- Card and badge. ---- */
.gu-card { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--gu-radius-lg); padding: var(--gu-s4);
  display: flex; flex-direction: column; gap: var(--gu-s3); min-width: 0; }
.gu-badge { display: inline-flex; align-items: center; gap: var(--gu-s1); min-height: 24px; padding: 0 var(--gu-s2); border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-family: var(--gu-font); font-weight: 800; font-size: 13px; line-height: 1; white-space: nowrap; }
.gu-badge.gu-ok { background: var(--ok); color: var(--surface); }
.gu-badge.gu-muted { background: var(--line); color: var(--ink); }

/* ---- Bottom sheet: a <dialog class="gu-sheet"> opened by game-ui.js; closed by a tap outside, the back button, Esc or
   its [data-gu-close] button. Wide screens get it centred. ---- */
.gu-sheet { width: 100%; max-width: 640px; max-height: 90dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: var(--gu-radius-lg) var(--gu-radius-lg) 0 0;
  background: var(--bg); color: var(--ink); overflow: hidden; }
.gu-sheet[open] { display: flex; flex-direction: column; animation: gu-up .22s ease-out both; }
.gu-sheet::backdrop { background: var(--ink); opacity: .45; }
.gu-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gu-s3); padding: var(--gu-s4) var(--gu-s4) var(--gu-s2); }
.gu-sheet-head h2 { margin: 0; font-family: var(--gu-font); font-weight: 800; font-size: 20px; }
.gu-sheet-body { display: flex; flex-direction: column; gap: var(--gu-s4); padding: var(--gu-s2) var(--gu-s4) calc(var(--gu-s4) + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 760px) { .gu-sheet { margin: auto; border-radius: var(--gu-radius-lg); } }
@keyframes gu-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Code field: the field, «لصق» and «مسح QR» (both shown by game-ui.js only where they work). ---- */
.gu-code { display: flex; flex-direction: column; gap: var(--gu-s2); }
.gu-code input { width: 100%; min-height: 56px; border: 1.5px solid var(--line); border-radius: var(--gu-radius); background: var(--surface); color: var(--ink);
  padding: 0 var(--gu-s4); font-family: var(--gu-font-latin); font-weight: 800; font-size: 28px; letter-spacing: .25em; text-align: center; direction: ltr; }
.gu-code input:focus { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.gu-code-tools { display: flex; flex-wrap: wrap; gap: var(--gu-s2); }
.gu-code-tools:not(:has(> :not([hidden]))) { display: none; }
/* 1.5.0 (nhmsv docs/GAMES_UNIFIED.md §1, Nasser 2026-11-21, as in the «وش؟» app): the icons sit inside the
   field's two ends, the code centred between them: «مسح QR» at the start (right in Arabic), «لصق» at the end. */
.gu-code-field { position: relative; }
.gu-code-field input { padding-inline: calc(var(--gu-touch) + 8px); }
.gu-code-icon { position: absolute; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center;
  width: var(--gu-touch); height: var(--gu-touch); padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.gu-code-icon[hidden] { display: none; }
.gu-code-icon:hover { color: var(--ink); }
.gu-code-icon:focus-visible { outline: 3px solid var(--brand); outline-offset: 0; }
.gu-code-scan { inset-inline-start: 4px; }
.gu-code-paste { inset-inline-end: 4px; }
.gu-code-hint { margin: 0; color: var(--muted); font-size: 14px; }
.gu-scan { display: grid; gap: var(--gu-s3); text-align: center; }
.gu-scan video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--gu-radius); background: var(--ink); }

/* ---- Avatar row: one row, the taken ones disabled, «المزيد» opens the rest. Radio inputs, so it works without script. ---- */
.gu-avatars { display: flex; gap: var(--gu-s2); overflow: hidden; flex-wrap: nowrap; align-items: center; padding: 6px; }
.gu-avatars.gu-all { flex-wrap: wrap; }
/* 1.2.0: a long open row scrolls inside a box when the game sets --gu-avatars-max (e.g. 264px); no limit by default. */
.gu-avatars.gu-all { max-height: var(--gu-avatars-max, none); overflow-y: auto; overscroll-behavior: contain; }
.gu-avatar { position: relative; flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.gu-avatar input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.gu-avatar img, .gu-avatar span { width: 100%; height: 100%; border-radius: 50%; border: 3px solid transparent; display: grid; place-items: center; font-size: 30px; background: var(--surface); }
.gu-avatar input:checked + img, .gu-avatar input:checked + span { border-color: var(--brand); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand); }
.gu-avatar input:focus-visible + img, .gu-avatar input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.gu-avatar input:disabled + img, .gu-avatar input:disabled + span { opacity: .3; filter: grayscale(1); cursor: not-allowed; }
.gu-avatars:not(.gu-all) .gu-avatar.gu-extra { display: none; }

/* ---- Thumb dock: fixed at the bottom while playing; the phase's step first, «المزيد» beside it. ---- */
.gu-dock { position: fixed; z-index: 20; inset-inline: 0; bottom: 0; max-width: 980px; margin-inline: auto; display: flex; gap: var(--gu-s2); align-items: stretch;
  padding: var(--gu-s3) var(--gu-s3) calc(var(--gu-s3) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  border-radius: var(--gu-radius-lg) var(--gu-radius-lg) 0 0; }
.gu-dock > .gu-dock-main { flex: 1 1 auto; display: flex; gap: var(--gu-s2); min-width: 0; }
.gu-dock > .gu-dock-main > * { flex: 1 1 0; min-width: 0; }
.gu-dock .gu-btn { min-height: 52px; }
.gu-dock-space { height: 96px; }

/* ---- Floating note: a short message that goes by itself (role="status"), for «نُسخ», «حُفظ»…; 1.4.0: shown as a
   manual popover over an open sheet, so the popover's own defaults (inset 0, margin auto, a border) are undone here. ---- */
.gu-note { position: fixed; z-index: 40; inset-inline: var(--gu-s4); top: auto; bottom: calc(var(--gu-s5) + env(safe-area-inset-bottom)); margin: 0 auto; border: 0; overflow: visible; max-width: 420px; width: fit-content;
  padding: var(--gu-s3) var(--gu-s5); border-radius: 999px; background: var(--ink); color: var(--surface); font-family: var(--gu-font); font-weight: 700; font-size: 15px;
  text-align: center; box-shadow: 0 6px 20px color-mix(in srgb, var(--ink) 25%, transparent); animation: gu-up .2s ease-out both; }
.gu-dock ~ .gu-note { bottom: calc(110px + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  .gu-sheet[open], .gu-note { animation: none; }
  .gu-btn { transition: none; }
}
