/* =====================================================================
   BASE.CSS: colors, fonts, and shared pieces used on every page
   =====================================================================

   To change a color everywhere, change it once in :root below.
   The dark theme (used when the phone/computer is in dark mode)
   has its own colors a little further down.
   ===================================================================== */


/* ---------- Fonts (stored in assets/fonts, never loaded from Google) ---------- */

@font-face {
  font-family: "Bangers";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/bangers-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../assets/fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Extra letters (e.g. Romanian ă, ș, ț). Only downloaded when needed. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../assets/fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Cyrillic letters (Russian, Ukrainian). Only downloaded when needed. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../assets/fonts/nunito-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}


/* ---------- Design tokens: light theme ---------- */

:root {
  --paper: #FFF6E5;                        /* page background */
  --paper-dots: rgba(27, 27, 31, 0.07);    /* halftone dots on the background */
  --surface: #FFFFFF;                      /* cards */
  --surface-muted: #F6EBD6;                /* inactive controls */
  --text: #1B1B1F;                         /* main text */
  --text-soft: #5C564C;                    /* secondary text */
  --line: #1B1B1F;                         /* comic outlines and hard shadows */

  --red: #E5322D;                          /* hero red: the button */
  --red-strong: #DC2F2A;                   /* buttons with white text (readable enough) */
  --red-dark: #A11D19;
  --red-light: #FF7B6B;
  --yellow: #FFD23F;                       /* bursts and highlights */
  --blue: #2F6FDB;                         /* info, focus, timer */
  --on-color: #FFFFFF;                     /* text on red or blue */

  --outline-width: 3px;
  --shadow: 4px 4px 0 var(--line);
  --shadow-small: 2px 2px 0 var(--line);
  --radius: 20px;
  --radius-small: 14px;

  --font-display: "Bangers", Impact, "Arial Black", sans-serif;
  --font-body: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: light dark;
}


/* ---------- Design tokens: dark theme ---------- */

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1D1B21;
    --paper-dots: rgba(255, 246, 229, 0.05);
    --surface: #2C2932;
    --surface-muted: #36323D;
    --text: #FFF6E5;
    --text-soft: #BDB5A8;
    --line: #09080B;
    --blue: #5E9BF5;
  }
}


/* ---------- Reset & page ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image: radial-gradient(var(--paper-dots) 1.2px, transparent 1.7px);
  background-size: 14px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, ol, dl, dd, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

img, svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}


/* ---------- Accessibility helpers ---------- */

/* Hidden on screen, still read aloud by screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* A clear ring around whatever the keyboard is on */
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}


/* ---------- Shared components ---------- */

/* A comic card: white panel, thick outline, hard shadow */
.card {
  background: var(--surface);
  border: var(--outline-width) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Comic text button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 0.6em 1.4em;
  border: var(--outline-width) solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  text-decoration: none;
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--line);
}

.btn--primary {
  background: var(--red-strong);
  color: var(--on-color);
}

/* Small round icon button (at least 44 × 44 for fingers) */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: var(--outline-width) solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-small);
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  touch-action: manipulation;
}

.icon-button:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--line);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

/* Modal window (Personal Bests, share sheet, pause). Uses the <dialog> element. */
.modal {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: var(--outline-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 6px 6px 0 var(--line);
  overflow: auto;
  overscroll-behavior: contain;
}

.modal[open] {
  animation: modal-in 220ms var(--ease-spring);
}

.modal::backdrop {
  background: rgba(24, 22, 28, 0.55);
}

@keyframes modal-in {
  0% { opacity: 0; transform: translateY(12px) scale(0.96); }
  100% { opacity: 1; transform: none; }
}

/* Everything inside the modal sits in here, so a tap on the dark area outside can close it */
.modal__inner {
  padding: 18px 18px 20px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.04em;
}

/* Short message at the bottom of the screen, e.g. "Copied!" */
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  padding: 10px 18px;
  border: var(--outline-width) solid var(--line);
  border-radius: 999px;
  background: var(--yellow);
  color: #1B1B1F;
  box-shadow: var(--shadow-small);
  font-weight: 900;
  opacity: 0;                     /* invisible until a message is shown */
  transform: translateX(-50%);
  pointer-events: none;
}

.toast.is-showing {
  animation: toast-life 1800ms var(--ease-out) forwards;
}

@keyframes toast-life {
  0% { opacity: 0; transform: translate(-50%, 12px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}

/* Small Easy / Hard label */
.difficulty-badge {
  display: inline-block;
  padding: 1px 9px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--yellow);
  color: #1B1B1F;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1.4;
}

.difficulty-badge--hard {
  background: var(--red-strong);
  color: #FFFFFF;
}

/* Comic burst shape (the spiky star behind POW!, KRAK!, v1.0) */
.burst-shape {
  fill: var(--yellow);
  stroke: var(--line);
  stroke-width: 4;
  stroke-linejoin: round;
}


/* ---------- Animations ---------- */

/* A gentle "no" shake, e.g. when tapping something locked */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.is-shaking {
  animation: shake 320ms var(--ease-out);
}

/* Respect players who asked their device for less motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }

  .is-shaking,
  .modal[open] {
    animation: none;
  }
}
