/* ==========================================================
   School Games & Tools — shared site styles
   ========================================================== */

:root {
  --bg: #0a0e1a;
  --bg-2: #111729;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.09);
  --surface-solid: #151c31;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1f8;
  --muted: #8f9ab5;
  --accent: #7c8cff;
  --accent-2: #2ee6b8;
  --accent-grad: linear-gradient(135deg, #7c8cff 0%, #2ee6b8 100%);
  --on-accent: #0a0e1a;

  --land: #28324f;
  --land-hover: #3b4a7c;
  --land-stroke: #0a0e1a;
  --inactive: #1a2137;

  --perfect: #2ee6a0;
  --ok: #f5c84b;
  --close: #ff9a4d;
  --missed: #ff4d6d;

  /* Subject / tool colours, used to tell sections apart at a glance */
  --c-blue: #6f8bff;
  --c-teal: #2ee6b8;
  --c-pink: #ff6fae;
  --c-orange: #ff9a4d;
  --c-yellow: #f5c84b;
  --c-purple: #b48cff;
  --c-green: #4fd97a;

  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  --radius: 20px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", var(--font);
  color-scheme: dark;
}

/* Light theme: follows the device unless the visitor picked one with the theme button.
   (Projectors and smartboards in bright rooms are much easier to read in light mode.) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5fb;
    --bg-2: #ffffff;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-2: #ffffff;
    --surface-solid: #ffffff;
    --border: rgba(20, 30, 60, 0.1);
    --border-strong: rgba(20, 30, 60, 0.2);
    --text: #111829;
    --muted: #5d6782;
    --accent: #5566f0;
    --accent-2: #12b48d;
    --accent-grad: linear-gradient(135deg, #5566f0 0%, #12b48d 100%);
    --on-accent: #ffffff;
    --land: #cfd6e8;
    --land-hover: #a9b6dc;
    --land-stroke: #f3f5fb;
    --inactive: #e4e8f2;
    --perfect: #14c27f;
    --ok: #e8b322;
    --close: #f37b2a;
    --missed: #ec3456;
    --c-blue: #4a63e8;
    --c-teal: #0fa982;
    --c-pink: #e0408a;
    --c-orange: #ec6f1c;
    --c-yellow: #d9a514;
    --c-purple: #8a5cf0;
    --c-green: #22a653;
    --shadow: 0 24px 60px -28px rgba(30, 40, 80, 0.35);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-2: #ffffff;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-2: #ffffff;
  --surface-solid: #ffffff;
  --border: rgba(20, 30, 60, 0.1);
  --border-strong: rgba(20, 30, 60, 0.2);
  --text: #111829;
  --muted: #5d6782;
  --accent: #5566f0;
  --accent-2: #12b48d;
  --accent-grad: linear-gradient(135deg, #5566f0 0%, #12b48d 100%);
  --on-accent: #ffffff;
  --land: #cfd6e8;
  --land-hover: #a9b6dc;
  --land-stroke: #f3f5fb;
  --inactive: #e4e8f2;
  --perfect: #14c27f;
  --ok: #e8b322;
  --close: #f37b2a;
  --missed: #ec3456;
  --c-blue: #4a63e8;
  --c-teal: #0fa982;
  --c-pink: #e0408a;
  --c-orange: #ec6f1c;
  --c-yellow: #d9a514;
  --c-purple: #8a5cf0;
  --c-green: #22a653;
  --shadow: 0 24px 60px -28px rgba(30, 40, 80, 0.35);
  color-scheme: light;
}

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

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

.container {
  width: min(1120px, 100% - 32px);
  margin-inline: auto;
}

/* ---------- Nav ---------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  color: var(--on-accent);
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}

.nav-links { display: flex; gap: 6px; }

.nav-links a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: color .2s, background .2s;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, background .2s, border-color .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-grad);
  color: var(--on-accent);
  border-color: transparent;
  box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover { box-shadow: 0 14px 36px -10px color-mix(in srgb, var(--accent) 90%, transparent); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 20px; height: 20px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ---------- Touch screens & smartboards ---------- */

/* No double-tap zoom or tap delay on controls; no accidental text selection when dragging */
button, a, .mode-card, .choice, [role="button"] { touch-action: manipulation; }
button { -webkit-user-select: none; user-select: none; }

/* Clear way back to the list of everything */
.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 800;
  font-size: .92rem;
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}
.home-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.home-btn svg { width: 20px; height: 20px; color: var(--accent); }

/* Theme toggle shows the icon for the theme you'd switch to */
.theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: block; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .ico-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .ico-moon { display: none; }
}
.fs-btn .ico-exit { display: none; }
:root.is-fullscreen .fs-btn .ico-enter { display: none; }
:root.is-fullscreen .fs-btn .ico-exit { display: block; }

/* ---------- "Add to home screen" card (phones) ---------- */

.install-card {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 60;
  max-width: 440px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 18px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: installIn .4s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes installIn { from { opacity: 0; transform: translateY(20px); } }
.install-card img { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; font-size: .88rem; line-height: 1.3; }
.install-text strong { display: block; font-size: .95rem; }
.install-text span { color: var(--muted); }
.install-text .share-ico { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
.install-card .btn { padding: 10px 14px; border-radius: 12px; }
.install-close {
  width: 32px; height: 32px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 1.3rem; cursor: pointer; border-radius: 8px; flex-shrink: 0;
}

/* ---------- "Learn" article under each game ---------- */

.learn { padding: 56px 0 40px; max-width: 820px; }
.learn h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 14px;
}
.learn h2 { font-family: var(--font-display); font-size: 1.4rem; letter-spacing: -0.02em; margin: 36px 0 12px; }
.learn h3 { font-size: 1rem; margin: 20px 0 8px; color: var(--muted); }
.learn p, .learn li { color: var(--muted); }
.learn strong { color: var(--text); }
.learn-intro { font-size: 1.1rem; }
.learn .how { padding-left: 20px; display: grid; gap: 8px; }
.answer-list {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 4 160px;
  column-gap: 20px;
  font-size: .92rem;
}
.answer-list li { padding: 3px 0; break-inside: avoid; }
.table-wrap { overflow-x: auto; }
.answer-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.answer-table th, .answer-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.answer-table th { color: var(--text); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.answer-table td { color: var(--muted); }
.answer-table td:first-child { color: var(--text); font-weight: 600; }
.faq {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.faq summary { cursor: pointer; font-weight: 700; color: var(--text); }
.faq p { margin: 8px 0 2px; }
.related { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.related a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
}
.related a:hover { border-color: var(--border-strong); }
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 40px; color: var(--muted); font-size: .9rem; }
.site-footer a { text-decoration: underline; }
.site-footer a:hover, footer .footer-row a:hover { color: var(--text); }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
footer .footer-row a { text-decoration: underline; }

/* Privacy policy */
.privacy { padding-top: 24px; }
.privacy ul { padding-left: 20px; display: grid; gap: 6px; }
.privacy a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }
.privacy code { font-size: .9em; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }

/* ---------- Ad slots (collapsed unless ads are on) ---------- */

.ad-slot { display: none; }
.ads-on .ad-slot,
.ads-preview .ad-slot {
  display: block;
  position: relative;
  width: 100%;
  margin-inline: auto;
  padding-top: 16px;
  text-align: center;
}
.ads-on .ad-slot::before,
.ads-preview .ad-slot::before {
  content: "Advertisement";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .6;
}
.ad-banner { max-width: 728px; min-height: 66px; }
.ad-compact { max-width: 320px; min-height: 66px; margin-top: 16px; }
.ad-placeholder {
  display: grid;
  place-items: center;
  height: 50px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}
@media (min-width: 760px) { .ad-banner .ad-placeholder { height: 90px; } }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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