/* Shared pieces of the shell: page defaults, buttons and fields. Every value comes from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--obsidian);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: rgba(var(--cyan-rgb), 0.35); color: var(--ink-title); }

* { scrollbar-width: thin; scrollbar-color: rgba(var(--cyan-rgb), 0.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(var(--cyan-rgb), 0.35); }
::-webkit-scrollbar-track { background: transparent; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }

.ico { width: 1em; height: 1em; flex: none; vertical-align: -0.14em; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1, 'zero' 0; }

.bevel {
  clip-path: polygon(var(--bevel) 0, 100% 0, 100% calc(100% - var(--bevel)), calc(100% - var(--bevel)) 100%, 0 100%, 0 var(--bevel));
}

/* Buttons: beveled plates lit from the top-left. The cut corners catch the light, so there is no outline.
   --b is the bevel's perpendicular distance, used to put a highlight exactly on each diagonal edge.
   The primary is the gold "go" plate; colors carry meaning in a duel. */
.btn {
  --bg: var(--stage-2);
  --fg: var(--ink);
  --face: linear-gradient(var(--bg), var(--bg));
  --sheen: 0.2;
  --edge: 0.6;
  --b: calc(var(--bevel) * 0.7071);
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 48px; padding: 0.7em 1.2em; border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, var(--edge)) var(--b), rgba(255, 255, 255, 0) calc(var(--b) + 1.5px)),
    linear-gradient(315deg, rgba(0, 0, 0, 0.4) var(--b), rgba(0, 0, 0, 0) calc(var(--b) + 1.5px)),
    linear-gradient(180deg, rgba(255, 255, 255, var(--sheen)), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.14)),
    var(--face);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -2px 0 rgba(0, 0, 0, 0.22);
  color: var(--fg);
  font-family: var(--display); font-weight: 700; letter-spacing: calc(0.02em * var(--track));
  clip-path: polygon(var(--bevel) 0, 100% 0, 100% calc(100% - var(--bevel)), calc(100% - var(--bevel)) 100%, 0 100%, 0 var(--bevel));
  transition: transform 280ms var(--spring), filter 160ms var(--ease-out);
  user-select: none; -webkit-user-select: none;
}
/* A flash of light under the label on press, then it settles back with a little overshoot. */
.btn::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(110% 100% at 50% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 70%);
  opacity: 0; transition: opacity 260ms var(--ease-out);
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(2px) scale(0.965); transition-duration: 50ms, 160ms; transition-timing-function: ease-out; }
.btn:active:not(:disabled)::after { opacity: 0.55; transition-duration: 40ms; }
/* A clipped element would crop its own focus ring, so the ring takes the plate's square for as long as it is focused. */
.btn:focus-visible { clip-path: none; }
.btn:disabled { opacity: 0.4; filter: saturate(0.4); }
.btn.gold { --bg: var(--gold); --fg: var(--on-gold); --face: var(--gold-metal); --sheen: 0.1; --edge: 0.85; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -2px 0 rgba(var(--gold-shade-rgb), 0.45); }
.btn.cyan { --bg: var(--cyan); --fg: var(--on-cyan); }
.btn.green { --bg: var(--green); --fg: var(--on-green); }
.btn.lemon { --bg: var(--lemon); --fg: var(--on-lemon); }
.btn.ghost { --bg: rgba(var(--cyan-rgb), 0.08); --fg: var(--ink); --sheen: 0.06; --edge: 0.3; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -16px 18px -16px rgba(var(--cyan-rgb), 0.3); }
.btn.danger { --bg: rgba(var(--red-rgb), 0.14); --fg: var(--red-soft); --sheen: 0.05; --edge: 0.22; }

/* Fields: a recessed slot with a lit lower edge instead of a box outline. */
.field {
  width: 100%; min-height: 48px; padding: 0.6em 0.8em;
  background-color: rgba(var(--obsidian-rgb), 0.7); color: var(--ink);
  border: 0; border-radius: var(--radius);
  box-shadow: inset 0 7px 9px -7px rgba(0, 0, 0, 0.75), inset 0 -2px 0 rgba(var(--cyan-rgb), 0.4);
  font-family: var(--display); font-weight: 600;
  transition: box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.field::placeholder { color: var(--ink-3); opacity: 1; }
.field:focus-visible { outline-offset: 0; background-color: rgba(var(--surface-glass-rgb), 0.9); box-shadow: inset 0 7px 9px -7px rgba(0, 0, 0, 0.75), inset 0 -3px 0 var(--cyan), 0 8px 18px -10px rgba(var(--cyan-rgb), calc(0.7 * var(--glow))); }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2.4em; }
select.field option { background: var(--stage); color: var(--ink); }

/* A player's face (GC.avatar): their color as a tile with their doodle on it, or their initial. The ink is the dark
   ink every look keeps for writing on paper (--paper-ink), since a pen line in the look's own outline would vanish
   on the brighter player colors. Round caps, so a tap reads as a dot: an eye. */
.avatar { display: block; flex: none; overflow: hidden; border-radius: var(--radius); }
.avatar .av-tile { fill: rgb(var(--pc, 160, 170, 190)); }
.avatar .av-ink { fill: none; stroke: var(--paper-ink); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.avatar .av-initial { fill: var(--paper-ink); font-family: var(--display); font-weight: 700; font-size: 64px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A screen on its way out (GC.ghost): a still copy laid over the page while the next one comes in under it. Its
   animations jump to where they ended, so a headline that already landed doesn't land again on the way out. */
.gc-ghost { position: fixed; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.gc-ghost *, .gc-ghost *::before, .gc-ghost *::after { animation-delay: -60s !important; animation-play-state: paused !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
