/* MathSchools site.css - shared look for every page.
   Plain CSS, no frameworks. Colors live in variables so they are easy to change. */
:root {
  --ink: #0E1E3A; --bg: #FFFFFF; --soft: #EEF4FF; --primary: #1F5FD1;
  --primary-dark: #174AA6; --line: #C9D8F5; --card: #FFFFFF; --accent: #FFB800;
  --good: #1E9E5A; --bad: #D93A3A;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(14,30,58,.06), 0 6px 18px rgba(31,95,209,.08);
  --shadow-hover: 0 2px 4px rgba(14,30,58,.08), 0 12px 28px rgba(31,95,209,.16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.55; color: var(--ink); background: var(--bg); }
img, svg { max-width: 100%; height: auto; }
a { color: var(--primary-dark); text-underline-offset: 3px; }
a:hover { color: var(--primary); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
ul { padding-left: 1.2rem; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary-dark); color: #fff; padding: .6rem 1rem; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

/* Layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.1rem 3rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-tight { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* Type */
.h1 { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 800; letter-spacing: -.02em; }
.h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); font-weight: 750; letter-spacing: -.01em; margin-top: 2.5rem; }
.lead { font-size: 1.15rem; color: #34466b; max-width: 60ch; }

/* Cards */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.tag { display: inline-block; background: var(--soft); color: var(--primary-dark); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .65rem; font-size: .8rem; font-weight: 650; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.2rem; font: inherit; font-weight: 700; color: var(--primary-dark); background: #fff; border: 1.5px solid var(--primary); border-radius: var(--radius); cursor: pointer; text-decoration: none; transition: transform .12s, background .12s; }
.btn:hover { background: var(--soft); color: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

/* Game card: a thumbnail on top, text below. The whole card is one link. */
.game-card { display: flex; flex-direction: column; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); color: var(--ink); }
.game-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--soft); display: block; }
.game-card .body { padding: .8rem .9rem 1rem; }
.game-card h3 { font-size: 1.05rem; margin: 0 0 .25rem; }
.game-card p { margin: 0 0 .5rem; font-size: .92rem; color: #34466b; }
.game-card .tags { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Header */
.site-header { background: #fff; border-bottom: 1.5px solid var(--line); position: sticky; top: 0; z-index: 50; }
.site-header .bar { max-width: 1080px; margin: 0 auto; padding: .55rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-header .logo img { display: block; height: 36px; width: auto; }
.menu-btn { display: none; min-height: 44px; padding: 0 1rem; font: inherit; font-weight: 700; color: var(--primary-dark); background: var(--soft); border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; }
#site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
#site-nav a { display: block; padding: .5rem .8rem; border-radius: 8px; color: var(--ink); font-weight: 650; text-decoration: none; }
#site-nav a:hover, #site-nav a[aria-current="page"] { background: var(--soft); color: var(--primary-dark); }
@media (max-width: 760px) {
  .menu-btn { display: inline-block; }
  #site-nav { display: none; width: 100%; }
  #site-nav.open { display: block; }
  #site-nav ul { flex-direction: column; padding-bottom: .5rem; }
}

/* Footer */
.site-footer { background: var(--soft); border-top: 1.5px solid var(--line); padding: 2rem 1.1rem; font-size: .9rem; }
.site-footer .inner { max-width: 1080px; margin: 0 auto; }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1.2rem; padding: 0; margin: 0 0 1rem; }
.site-footer p { margin: .3rem 0; color: #34466b; }

/* Homepage pieces */
.hero { display: grid; gap: 2rem; align-items: center; padding: 3rem 0 1rem; grid-template-columns: 1.2fr .8fr; }
.hero .actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.4rem; }
.hero-art { background: var(--soft); border: 1.5px solid var(--line); border-radius: 24px; padding: 1.5rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.hero-art span { aspect-ratio: 1; display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: var(--primary); background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); }
.hero-art span:nth-child(5) { background: var(--primary); color: #fff; border-color: var(--primary); }
.hero-art span:nth-child(3) { color: var(--accent); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; padding-top: 1.5rem; } .hero-art { display: none; } }
.grade-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .6rem; }
.grade-picker a { display: flex; flex-direction: column; align-items: center; min-height: 72px; justify-content: center; background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--primary-dark); font-size: 1.5rem; font-weight: 800; }
.grade-picker a small { font-size: .7rem; font-weight: 650; color: #34466b; }
.grade-picker a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.grade-picker a:hover small { color: #fff; }
.topic-tile { min-width: 0; display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); font-weight: 700; }
.topic-tile:hover { background: var(--soft); }
.topic-tile img { width: 36px; height: 36px; flex: none; }
.topic-tile span { min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.topic-tile small { display: block; font-weight: 600; font-size: .78rem; color: #34466b; }
.grid-topics { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.h3 { font-size: 1rem; font-weight: 750; margin: 1.1rem 0 .5rem; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.potd { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 1.2rem; align-items: center; background: var(--soft); border: 1.5px solid var(--line); border-radius: 20px; padding: 1rem; margin-top: 1.2rem; }
.potd img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); display: block; background: #fff; }
.potd h3 { font-size: 1.5rem; }
.potd .kicker { color: var(--primary-dark); font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
@media (max-width: 640px) { .potd { grid-template-columns: 1fr; } }
.prose { max-width: 70ch; }
.prose h2 { font-size: 1.35rem; margin-top: 2rem; }
.prose li { margin-bottom: .4rem; }

/* Advertisement slots: fixed sizes so the page never shifts. Hidden unless
   site.js adds class "ads-on" to <html> (see ADS_ENABLED in js/site.js). */
.ad-wrap { display: none; }
.ads-on .ad-wrap { display: block; }
.ad-slot { display: flex; align-items: center; justify-content: center; margin: 0 auto; background: #F7FAFF; border: 1px dashed var(--line); border-radius: 8px; color: #5a6b8c; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.ad-leader { width: 728px; height: 90px; max-width: 100%; }
.ad-rect { width: 300px; height: 250px; }
.ad-leader-wrap { padding: .5rem 1rem; background: #fff; }
.ad-rect-wrap { margin-top: 1rem; }
@media (max-width: 760px) { .ad-leader { width: 320px; height: 50px; } }
.teaser { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; background: var(--primary); color: #fff; border-radius: 20px; padding: 1.8rem; }
.teaser h2 { margin: 0 0 .3rem; }
.teaser p { margin: 0; }
.teaser .btn { border-color: #fff; }
.trust { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.trust h3 { font-size: 1.05rem; margin-bottom: .3rem; }
.trust p { margin: 0; font-size: .95rem; }
.empty-note { color: #34466b; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Game player (play.html and arcade-play.html) ----------
   .game-stage holds the iframe (.game-frame) and a Close button.
   - Desktop: a large 16:9 frame that never grows taller than the window.
   - Phones / portrait: a tall frame (about the whole screen minus the header, at least 520px).
   - Full screen: the browser's Fullscreen API when it works, otherwise the
     .is-overlay class turns the stage into a fixed layer covering the page. */
.game-stage { position: relative; width: 100%; background: #000; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.game-frame { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; min-height: 420px; max-height: calc(100dvh - 130px); border: 0; background: #000; }
@media (max-width: 760px), (orientation: portrait) {
  .game-frame { aspect-ratio: auto; max-height: none; height: max(520px, calc(100dvh - 150px)); min-height: 520px; }
}
.game-close { display: none; position: absolute; top: 8px; right: 8px; z-index: 2; min-height: 40px; padding: .35rem .9rem; opacity: .92; }
.game-stage:fullscreen, .game-stage.is-overlay { border: 0; border-radius: 0; }
.game-stage:fullscreen .game-frame, .game-stage.is-overlay .game-frame { width: 100%; height: 100%; max-height: none; min-height: 0; aspect-ratio: auto; }
.game-stage:fullscreen .game-close, .game-stage.is-overlay .game-close { display: inline-flex; }
.game-stage.is-overlay { position: fixed; inset: 0; z-index: 1000; width: auto; height: 100dvh; }
body.game-overlay-open { overflow: hidden; }
