/* FAB Games · core: tokens, fonts, reset and shared components.  Direction A (Night Vault) with B's cut geometry. */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 700 900;
  font-stretch: 125%;
  font-display: swap;
}

@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/geistmono-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --ink-950: #05080f;
  --ink-900: #080c18;
  --ink-800: #0d1426;
  --ink-700: #151f3a;
  --line: rgba(157, 190, 255, 0.14);
  --line-strong: rgba(157, 190, 255, 0.3);

  --blue-600: #1f5bd1;
  --blue-500: #2972f5;
  --blue-400: #5b94ff;
  --blue-300: #9dbeff;

  --text-1: #f4f7ff;
  --text-2: #a9b4cc;
  --text-3: #7c88a6;
  --ember: #e8a15c;
  --danger: #ff6b7a;
  --ok: #6fe3b0;

  --font-display: "Archivo", "Arial Black", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.3, 0.64, 1);

  --r-tile: 20px;
  --r-panel: 14px;
  --gutter: clamp(16px, 4vw, 56px);

  /* The logo's steep cut, reused for plates, banners and focus brackets. */
  --cut: 12px;
  --cut-shape: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));

  --glass-bg: rgba(13, 20, 38, 0.62);
  --glass-blur: blur(18px) saturate(1.2);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.18 6%, 0.52 13%, 0.86 22%, 1.04 31%, 1.07 38%, 1.03 47%, 0.995 58%, 1.003 72%, 1);
  }
}

* {
  box-sizing: border-box;
}

/* Big screens (TVs, desktops) get proportionally bigger type and controls: rem-based sizes scale with this. */
@media (min-width: 1600px) {
  html { font-size: 112.5%; }
}

@media (min-width: 2200px) {
  html { font-size: 137.5%; }
}

html {
  min-height: 100%;
  background: var(--ink-950);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text-1);
  background: transparent;
  font: 400 1rem/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p {
  margin: 0;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--blue-600);
  color: #fff;
  transition: top 0.15s var(--ease-snap);
}

.skip-link:focus {
  top: 12px;
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 0.875rem;
}

.display {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.02em;
  line-height: 0.98;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  text-wrap: balance;
}

.display--md {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ───────── Focus: a ring that follows the last input ───────── */

:focus {
  outline: none;
}

:focus-visible,
html[data-input="keyboard"] :focus,
html[data-input="gamepad"] :focus {
  outline: 2px solid var(--blue-400);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(41, 114, 245, 0.22);
}

html[data-input="mouse"] :focus:not(:focus-visible),
html[data-input="touch"] :focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* ───────── Atmosphere: shared backdrop with crossfading key art ───────── */

.atmos {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--ink-950);
  --px: 0;
  --py: 0;
}

.atmos__bg {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: 55% 50%;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
  transform: translate3d(calc(var(--px) * -14px), calc(var(--py) * -10px), 0) scale(1.04);
  animation: atmos-drift 40s ease-in-out infinite alternate;
  will-change: opacity;
}

.atmos__bg.is-on {
  opacity: 0.8;
}

.atmos__bg--chess {
  background-image: url("/img/covers/chess.webp");
}

.atmos__bg--checkers {
  background-image: url("/img/covers/checkers.webp");
}

.atmos__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 100%, rgba(5, 8, 15, 0.1), rgba(5, 8, 15, 0.82) 80%),
    linear-gradient(180deg, rgba(5, 8, 15, 0.6), rgba(5, 8, 15, 0) 28%, rgba(5, 8, 15, 0.55));
}

.atmos__dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.9;
}

@keyframes atmos-drift {
  from { scale: 1; }
  to { scale: 1.06; }
}

/* ───────── Buttons ───────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-height: 48px;
  padding: 0.7em 1.5em;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: #fff;
  background: transparent;
  transition: transform 0.18s var(--ease-snap), background-color 0.18s var(--ease-snap), border-color 0.18s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn--primary {
  background: var(--blue-600);
  box-shadow: 0 10px 28px -10px rgba(41, 114, 245, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn--primary:hover {
  background: #2467e3;
}

.btn--glass {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn--glass:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn--ghost {
  color: var(--text-2);
}

.btn--ghost:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
}

.btn--danger {
  background: rgba(255, 107, 122, 0.14);
  border-color: rgba(255, 107, 122, 0.4);
  color: #ffd5da;
}

.btn--sm {
  min-height: 40px;
  padding: 0.45em 1.1em;
  font-size: 0.9rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.3em 0.9em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  font-size: 0.85rem;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  padding: 0 0.85em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-1);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  transition: background-color 0.18s, transform 0.18s var(--ease-snap);
}

.chip-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chip-btn:active {
  transform: scale(0.96);
}

.sound-toggle .icon--off,
#sound-toggle .icon--off { display: none; }

.sound-toggle[aria-pressed="false"] .icon--on,
#sound-toggle[aria-pressed="false"] .icon--on { display: none; }

.sound-toggle[aria-pressed="false"] .icon--off,
#sound-toggle[aria-pressed="false"] .icon--off { display: block; color: var(--text-3); }

/* ───────── Surfaces ───────── */

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}

html[data-lite] .glass {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: rgba(13, 20, 38, 0.92);
}

.panel {
  border-radius: var(--r-panel);
  padding: clamp(18px, 3vw, 28px);
}

.panel__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 125%;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.avatar {
  border-radius: 50%;
  background: var(--ink-700);
  object-fit: cover;
}

.avatar--sm { width: 40px; height: 40px; }
.avatar--md { width: 56px; height: 56px; }

/* ───────── Forms ───────── */

.field {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field__label {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 0;
}

.field__hint {
  font-size: 0.85rem;
  color: var(--text-3);
}

.input {
  width: 100%;
  min-height: 52px;
  padding: 0.7em 1em;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(5, 8, 15, 0.6);
  color: var(--text-1);
  font-size: 1.05rem;
}

.input::placeholder {
  color: var(--text-3);
}

.input--code {
  text-align: center;
  font-size: 1.75rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  padding-left: 1.35em;
}

.form-error {
  margin: 0 0 1rem;
  color: #ffb3bb;
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented__item {
  min-height: 46px;
  padding: 0 1.1em;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-2);
  font-weight: 600;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s, transform 0.18s var(--ease-snap);
}

.segmented__item[aria-checked="true"] {
  background: var(--blue-600);
  border-color: var(--blue-400);
  color: #fff;
}

.segmented__item:active {
  transform: scale(0.97);
}

.switch {
  position: relative;
  width: 56px;
  height: 32px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
  transition: background-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.22s var(--spring);
}

.switch[aria-checked="true"] {
  background: var(--blue-600);
}

.switch[aria-checked="true"]::after {
  transform: translateX(24px);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.setting:last-of-type {
  margin-bottom: 1rem;
}

/* ───────── Dialogs (native <dialog>) ───────── */

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 0;
  border-radius: 22px;
  color: var(--text-1);
}

.dialog::backdrop {
  background: rgba(3, 5, 10, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.dialog[open] {
  animation: dialog-in 0.28s var(--ease-out);
}

.dialog[open]::backdrop {
  animation: fade-in 0.28s var(--ease-out);
}

.dialog__body {
  padding: clamp(20px, 4vw, 32px);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.how-list {
  margin: 0 0 1.25rem;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.75rem;
  color: var(--text-2);
}

/* ───────── Toasts ───────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 90;
  display: grid;
  gap: 10px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(13, 20, 38, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px -20px #000;
  animation: toast-in 0.32s var(--ease-out);
}

.toast--error {
  border-color: rgba(255, 107, 122, 0.5);
}

.toast--trophy {
  border-color: rgba(232, 161, 92, 0.6);
}

.toast--trophy .icon {
  color: var(--ember);
  width: 1.6em;
  height: 1.6em;
}

.toast__text small {
  display: block;
  color: var(--text-2);
}

.toast.is-leaving {
  animation: toast-out 0.2s var(--ease-snap) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

.error-page {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 1rem;
  text-align: center;
  padding: var(--gutter);
}

/* ───────── Motion preferences ───────── */

/* Reduced motion means fades only: no transforms, parallax, drift or particles. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-property: opacity, color, background-color, border-color, fill, stroke !important;
    scroll-behavior: auto !important;
  }

  @keyframes dialog-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes toast-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .atmos__bg {
    animation: none;
    transform: scale(1.04);
  }

  .atmos__dust {
    display: none;
  }
}

html[data-lite] .atmos__dust {
  display: none;
}

html[data-lite] .atmos__bg {
  animation: none;
}
