/* Base: reset, page frame, header/nav, footer, typography, focus. */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12px 12px, rgba(255, 210, 63, 0.22) 3px, transparent 4px),
    radial-gradient(circle at 36px 36px, rgba(63, 169, 245, 0.14) 3px, transparent 4px);
  background-size: 48px 48px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

img, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 var(--space-3); letter-spacing: 0.01em; }
h1 { font-size: var(--fs-xl); font-weight: 900; }
h2 { font-size: var(--fs-l); font-weight: 800; }
h3 { font-size: var(--fs-m); font-weight: 800; }
p { margin: 0 0 var(--space-3); }
a { color: var(--blue-deep); text-underline-offset: 3px; }
a:hover { color: var(--purple-deep); }

/* Big, obvious focus ring for keyboard users. */
:focus { outline: none; }
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 4px;
  border-radius: 10px;
}

.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;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-s);
  font-weight: 800;
}
.skip-link:focus { top: var(--space-3); color: #fff; }

[hidden] { display: none !important; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--gutter);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 0 var(--line), 0 6px 18px rgba(43, 45, 66, 0.06);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.logo:hover { color: var(--ink); }
.logo__sun { width: 44px; height: 44px; }
.logo__sun .rays { transform-origin: 50% 50%; transform-box: fill-box; animation: spin 18s linear infinite; animation-play-state: var(--loops); }
.logo__kids { color: var(--orange-deep); }
.logo__zone { color: var(--blue-deep); }

.site-nav { margin-left: auto; }
.site-nav ul {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  transition: transform var(--dur-2) var(--ease-spring), background-color var(--dur-2);
}
.nav-link:hover { background: #fff3c4; color: var(--ink); transform: translateY(-2px); }
.nav-link:active { transform: scale(0.94); }
.nav-link[aria-current="page"] { background: var(--sun); box-shadow: inset 0 -4px 0 var(--sun-deep); }
.nav-link__icon { font-size: 1.5rem; line-height: 1; }

.header-tools { display: flex; align-items: center; gap: var(--space-2); }

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 48px;
  padding: 0 var(--space-3) 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: #fff6d6;
  font-weight: 900;
  font-size: var(--fs-m);
  box-shadow: inset 0 0 0 2px #ffe08a;
}
.star-counter svg { width: 32px; height: 32px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: #eef6ff;
  font-size: 1.6rem;
  box-shadow: inset 0 0 0 2px #cfe6ff;
  transition: transform var(--dur-2) var(--ease-spring);
}
.icon-btn:hover { transform: rotate(20deg) scale(1.06); }
.icon-btn:active { transform: scale(0.9); }

/* The Menu button and its scrim exist for phones only (see the 720px block below). */
.menu-btn, .menu-scrim { display: none; }

/* six to eight groups (site-header--many, set by _Layout): compact tabs with the picture over the
   word, all in one row next to the logo on a laptop; below 1180px the tabs get a row of their own.
   On phones (720px and narrower) the tabs become the Menu panel instead - see below. */
.site-header--many .nav-link { flex-direction: column; justify-content: center; gap: 0; min-width: 76px; padding: 0 var(--space-2); font-size: var(--fs-s); line-height: 1.1; }
@media (max-width: 1180px) {
  .site-header--many { justify-content: space-between; }
  .site-header--many .site-nav { order: 3; width: 100%; margin: 0; }
  .site-header--many .site-nav ul { justify-content: center; }
  .site-header--many .site-nav li { flex: 1 1 0; max-width: 132px; }
  .site-header--many .nav-link { width: 100%; min-width: 0; }
}

/* ---------- phones: one slim header row + a Menu panel ----------
   logo | Menu button (the group you are in) | stars | settings, about 64px tall in all. The Menu opens a
   panel of big group tiles under the header (js/core/menu.js sets .is-open and aria-expanded). The header
   stays on screen (sticky) because it is slim, but not on a short landscape phone, where it would cover too much.
   Without JavaScript <noscript> loads css/nojs.css, which puts the plain list back in the page. */
@media (max-width: 720px) {
  html { scroll-padding-top: 72px; }
  .site-header, .site-header--many {
    position: sticky;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--gutter);
  }
  .logo { flex: 0 1 auto; min-width: 0; margin-right: auto; min-height: var(--tap-compact); gap: var(--space-1); font-size: 1.15rem; }
  .logo__sun { width: 36px; height: 36px; flex: none; }

  .site-header .site-nav, .site-header--many .site-nav { order: 0; width: auto; margin: 0; flex: none; }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--tap-compact);
    padding: 0 var(--space-3) 0 var(--space-2);
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--sun);
    color: var(--ink);
    font-weight: 900;
    font-size: var(--fs-s);
    line-height: 1.1;
    box-shadow: inset 0 -3px 0 var(--sun-deep);
    touch-action: manipulation;
  }
  .menu-btn:active { transform: scale(0.95); }
  .menu-btn__icon { font-size: 1.4rem; line-height: 1; }
  .menu-btn__bars { width: 24px; height: 24px; }
  .menu-btn__bars, .menu-btn__chevron { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  .menu-btn__chevron { width: 16px; height: 16px; transition: transform var(--dur-2) var(--ease-out); }
  .menu-btn[aria-expanded="true"] .menu-btn__chevron { transform: rotate(180deg); }

  /* the panel: closed unless the button opened it; scrolls if the screen is short */
  .site-nav ul,
  .site-header--many .site-nav ul { display: none; }
  .site-nav.is-open ul,
  .site-header--many .site-nav.is-open ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-3) var(--gutter) var(--space-4);
    background: #fff;
    box-shadow: 0 14px 24px rgba(43, 45, 66, 0.22);
    animation: var(--enter-rise) var(--dur-2) var(--ease-out) both;
  }
  html.calm .site-nav.is-open ul { animation: none; }
  .site-nav li,
  .site-header--many .site-nav li { max-width: none; }
  .site-header .site-nav .nav-link {
    width: 100%;
    min-width: 0;
    min-height: var(--tap);
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-m);
    background: var(--paper);
    box-shadow: inset 0 0 0 3px #e3dccb;
    font-size: var(--fs-s);
    line-height: 1.15;
  }
  .site-header .site-nav .nav-link:hover { transform: none; }
  .site-header .site-nav .nav-link[aria-current="page"] { background: var(--sun); box-shadow: inset 0 -4px 0 var(--sun-deep); }
  .site-header .site-nav .nav-link__icon { font-size: 1.9rem; }

  .menu-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(30, 40, 70, 0.4); }
  .menu-scrim:not([hidden]) { display: block; animation: fade-in var(--dur-2) ease-out; }
  html.calm .menu-scrim:not([hidden]) { animation: none; }

  .header-tools { gap: var(--space-1); flex: none; }
  .star-counter { min-height: var(--tap-compact); padding: 0 var(--space-2) 0 var(--space-1); font-size: var(--fs-s); }
  .star-counter svg { width: 26px; height: 26px; }
  .icon-btn { width: var(--tap-compact); height: var(--tap-compact); font-size: 1.4rem; }
}
@media (max-width: 720px) and (max-height: 520px) {
  .site-header, .site-header--many { position: static; }
}
/* the smallest phones: the word beside the sun gives way, so the Menu button keeps its name */
@media (max-width: 380px) {
  .logo__word { display: none; }
  .logo { min-width: var(--tap-compact); justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .site-nav.is-open ul, .menu-scrim:not([hidden]) { animation: none !important; }
}

/* ---------- main + footer ---------- */
.page {
  flex: 1;
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-5) var(--gutter) 140px; /* bottom room for the mascot */
}
.page--wide { max-width: none; padding-top: 0; padding-left: 0; padding-right: 0; }

.site-footer {
  padding: var(--space-5) var(--gutter) 120px;
  text-align: center;
  font-size: var(--fs-s);
  color: var(--ink-soft);
}
/* grown-up links: smaller than child targets, but never below 48 px */
.site-footer a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 var(--space-2); font-weight: 700; }
.site-footer p { margin: var(--space-1) 0; }

.page-head { margin-bottom: var(--space-5); animation: var(--enter-rise) var(--dur-3) var(--ease-out) both; }
.page-head p { font-size: var(--fs-m); color: var(--ink-soft); max-width: 60ch; }
.page-head__title { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.page-head__emoji { font-size: 1.2em; line-height: 1; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
/* an approved gallery fact (Content/reviewed-content.json) - same look as a game's 💡 line */
.page-head .gallery-fact {
  display: inline-flex; align-items: center; gap: var(--space-3);
  margin-top: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: var(--radius-m); background: #fff8db; box-shadow: inset 0 0 0 2px #ffe08a;
  color: var(--ink);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  margin-bottom: var(--space-2);
  padding: 0 var(--space-4) 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: var(--shadow-1);
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  transition: transform var(--dur-2) var(--ease-spring);
}
.back-link:hover { color: var(--ink); transform: translateX(-4px); }
.back-link:active { transform: scale(0.95); }

.section-title { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-6); }

/* ---------- Hindi (lang="hi") ---------- */
/* Hindi words and letters use the Devanagari fonts that come with the device (no web fonts are loaded);
   the line-height keeps the vowel signs above and below the letters from being clipped */
:lang(hi) { font-family: 'Nirmala UI', 'Noto Sans Devanagari', 'Mangal', 'Kohinoor Devanagari', 'Devanagari Sangam MN', var(--font); }
.nav-link :lang(hi), .door__label:lang(hi), .page-head__title :lang(hi) { line-height: 1.4; }

/* the home button on a group page: its picture shows on phones only (where the word is hidden) */
.back-link__home { display: none; }
