/* Christmas Arcade: shared theme. Palette, type, buttons, panels, sheets, toasts
   and the in-game chrome. Every page loads this first. */

@font-face {
  font-family: 'Fredoka';
  src: url('./fonts/fredoka.woff2') format('woff2-variations'), url('./fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito';
  src: url('./fonts/nunito.woff2') format('woff2-variations'), url('./fonts/nunito.woff2') format('woff2');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --night: #14213d;
  --night-2: #1d2d50;
  --night-3: #273a63;
  --snow: #f7f4ee;
  --snow-dim: rgba(247, 244, 238, 0.72);
  --cranberry: #c8102e;
  --cranberry-dark: #9a0c23;
  --pine: #1f6f4a;
  --pine-dark: #165237;
  --gold: #f2c14e;
  --cocoa: #6b4226;
  --frost: #bfe3f2;

  --font-display: 'Fredoka', 'Baloo 2', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(5, 10, 25, 0.45);
  --tap: 44px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  color-scheme: dark;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--snow);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; line-height: 1.1; }

button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

[hidden] { display: none !important; }

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

/* ---------- Buttons ---------- */
.xa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0.6em 1.2em;
  border: 0; border-radius: 999px;
  background: var(--night-3);
  color: var(--snow);
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 80ms ease, filter 120ms ease;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.xa-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.xa-btn-primary { background: var(--cranberry); box-shadow: 0 3px 0 var(--cranberry-dark); }
.xa-btn-primary:active { box-shadow: 0 1px 0 var(--cranberry-dark); }
.xa-btn-secondary { background: var(--pine); box-shadow: 0 3px 0 var(--pine-dark); }
.xa-btn-secondary:active { box-shadow: 0 1px 0 var(--pine-dark); }
.xa-btn-ghost { background: transparent; box-shadow: inset 0 0 0 2px rgba(247, 244, 238, 0.25); }
.xa-btn-block { display: flex; width: 100%; }

.xa-icon-btn {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%;
  background: rgba(20, 33, 61, 0.72);
  color: var(--snow);
  font-size: 1.3rem; line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 0 0 1.5px rgba(247, 244, 238, 0.18);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation;
}
.xa-icon-btn:active { transform: scale(0.94); }
.xa-icon-btn svg { width: 22px; height: 22px; }

/* ---------- Panels ---------- */
.xa-panel {
  background: var(--night-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1.5px rgba(242, 193, 78, 0.18);
  padding: 20px;
}

/* ---------- Sheets / dialogs ---------- */
.xa-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  background: rgba(8, 14, 30, 0.62);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: xa-fade 160ms ease-out;
}
.xa-sheet {
  width: min(360px, 100%);
  max-height: 100%;
  overflow: auto;
  display: flex; flex-direction: column; gap: 12px;
  text-align: center;
  animation: xa-pop 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.xa-sheet h2 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 600; font-size: 1.7rem; line-height: 1.1; color: var(--gold); text-shadow: none; }
.xa-sheet p { margin: 0 0 4px; color: var(--snow-dim); }
.xa-row { display: flex; gap: 10px; }
.xa-row > * { flex: 1; }

@keyframes xa-fade { from { opacity: 0; } }
@keyframes xa-pop { from { opacity: 0; transform: scale(0.92) translateY(8px); } }

/* ---------- Toggle rows (settings) ---------- */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap);
  padding: 4px 0;
  text-align: left;
  cursor: pointer;
}
.toggle-row + .toggle-row { border-top: 1px solid rgba(247, 244, 238, 0.08); }
.toggle-row .label { font-weight: 700; }
.toggle-row .sub { display: block; font-size: 0.82rem; font-weight: 400; color: var(--snow-dim); }

.switch {
  position: relative; flex: none;
  width: 54px; height: 32px;
  appearance: none; -webkit-appearance: none;
  margin: 0; border-radius: 999px;
  background: rgba(247, 244, 238, 0.18);
  cursor: pointer;
  transition: background 160ms ease;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--snow);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 160ms ease;
}
.switch:checked { background: var(--pine); }
.switch:checked::after { transform: translateX(22px); }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 999px; background: rgba(247, 244, 238, 0.12);
}
.segmented button {
  min-height: 38px; min-width: 52px; padding: 0 12px;
  border: 0; border-radius: 999px; background: transparent;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
}
.segmented button[aria-pressed='true'] { background: var(--gold); color: var(--night); }

/* ---------- Toast ---------- */
.xa-toast {
  position: fixed; z-index: 1100;
  left: 50%; bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 0; border-radius: 999px;
  background: var(--snow); color: var(--night);
  font-family: var(--font-display); font-weight: 600; font-size: 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: xa-toast-in 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes xa-toast-in { from { opacity: 0; transform: translate(-50%, 20px); } }

/* ---------- In-game chrome ---------- */
/* Games may redefine palette variables (e.g. --snow, --gold) for their own art.
   The Arcade's chrome resets them on its own elements so it always looks the same. */
.xa-overlay, .xa-chrome-btn, .xa-rotate, .xa-toast {
  --snow: #f7f4ee;
  --gold: #f2c14e;
  --night: #14213d;
  --night-2: #1d2d50;
  --night-3: #273a63;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  -webkit-font-smoothing: auto;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
  pointer-events: auto;
}

.xa-chrome-btn {
  position: fixed; z-index: 900;
  top: calc(8px + var(--safe-top));
}
.xa-chrome-home { left: calc(8px + var(--safe-left)); }
.xa-chrome-pause { right: calc(8px + var(--safe-right)); }

/* "Turn your phone" card (chrome.js orientation option) */
.xa-rotate {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px;
  background: var(--night);
  color: var(--snow);
  font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; text-align: center;
}
.xa-rotate p { margin: 0; }
.xa-rotate-phone {
  width: 46px; height: 78px;
  border: 4px solid var(--gold); border-radius: 10px;
  animation: xa-rotate-to-portrait 1.8s ease-in-out infinite;
}
.xa-rotate-phone.landscape { animation-name: xa-rotate-to-landscape; }
@keyframes xa-rotate-to-portrait { 0%, 25% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@keyframes xa-rotate-to-landscape { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

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