/* Learn to Look — bright & playful design tokens (docs/visual_design_plan.md).
   Baloo 2 (headlines/labels only) + Atkinson Hyperlegible (all body text —
   built by the Braille Institute for low-vision readers) load via Google
   Fonts in templates/base.html. Old variable names are kept as aliases so
   nothing that already shipped breaks mid-rollout. */

:root {
  /* New tokens (docs/visual_design_plan.md Section 2) */
  --sky: #1D6FE0;
  --sky-dark: #144D9F;
  --sun: #F5A800;
  --sun-light: #FFE9B8;
  --grass: #1E9E5A;
  --coral: #E8483A;
  --navy: #16233F;
  --paper: #FFFBF3;
  --paper-card: #FFFFFF;
  --ink-grey: #5B6472;
  --border: #E7E0D2;

  /* Old names, aliased so existing inline styles (var(--danger) etc.) keep working */
  --accent: var(--sky);
  --light: var(--sun-light);
  --grey: var(--ink-grey);
  --danger: var(--coral);
  --success: var(--grass);

  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  margin: 0;
  color: var(--navy);
  background: var(--paper);
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
}

a { color: var(--sky); }

@media (prefers-reduced-motion: no-preference) {
  .btn, .app-tile, .card { transition: transform 0.12s ease, box-shadow 0.12s ease; }
  .btn:hover { transform: translateY(-1px); }
  .app-tile:hover { transform: translateY(-2px); }
}

.messages { list-style: none; margin: 0; padding: 0; }
.message {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
}
.message-success { background: #E5F6EC; color: #16693D; }
.message-error { background: #FDE7E4; color: #A62E22; }

/* ---- Site header (teacher/admin/public pages) ---- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  background: var(--paper-card);
  border-bottom: 1px solid var(--border);
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--navy);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}
.site-header-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.site-header-welcome {
  color: var(--ink-grey);
  font-size: 0.9rem;
}
.site-header-logout { margin: 0; }
.site-header-logout .btn { padding: 0.4rem 1rem; font-size: 0.85rem; }

/* ---- Teacher portal ---- */

.portal {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.portal-header h1 { margin: 0; color: var(--navy); font-size: 1.6rem; }

.btn {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 2px solid var(--sky);
  background: var(--sky);
  color: white;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-secondary { background: white; color: var(--sky); }
.btn-danger { background: white; color: var(--coral); border-color: var(--coral); }

.badge {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
}
.badge-success { background: #E5F6EC; color: #16693D; }
.badge-accent { background: var(--sun-light); color: #7A4E00; }
.badge-neutral { background: var(--paper); color: var(--ink-grey); border: 1px solid var(--border); }
.badge-danger { background: #FDE7E4; color: #A62E22; }

.card {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.stat-row { display: flex; gap: 2rem; flex-wrap: wrap; }
.stat-row .stat-value { font-family: var(--font-display); font-size: 1.7rem; color: var(--sky-dark); display: block; }
.stat-row .stat-label { color: var(--ink-grey); font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--ink-grey); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

form.inline { display: inline; }

label { display: block; font-weight: 700; margin-bottom: 0.25rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"],
input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  background: white;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--sun);
  outline-offset: 1px;
}

input[type="checkbox"] { width: auto; margin: 0; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.checkbox-row label { margin-bottom: 0; font-weight: 400; }

/* ---- Admin console tabs (Subscribers / Applications / Reporting) ---- */

.console-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.console-tab {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink-grey);
}
.console-tab:hover { background: var(--paper); color: var(--navy); }
.console-tab-active { background: var(--sky); color: white; }
.console-tab-active:hover { background: var(--sky); color: white; }

.section-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ---- Category-tree grouping (teacher "available applications" page) ---- */

.category-row { margin-bottom: 1.5rem; }
.category-row:last-child { margin-bottom: 0; }
.category-row-nested {
  border-left: 2px solid var(--border);
  padding-left: 0.9rem;
}
.category-row-heading {
  margin: 0 0 0.5rem;
  color: var(--navy);
  font-size: 1.05rem;
}
.category-row-nested .category-row-heading {
  font-size: 0.95rem;
  color: var(--sky-dark);
}

.link-box-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}
.link-box {
  flex: 1;
  background: var(--sun-light);
  border: 1px solid #F0D28F;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: monospace;
  color: #5A3D00;
  word-break: break-all;
}
.link-box-open {
  flex-shrink: 0;
  align-self: center;
  white-space: nowrap;
}

/* Empty states — mascot + friendly copy, never just a bare sentence */
.empty-state {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  color: var(--ink-grey);
}
.empty-state .empty-state-text { margin: 0; }
.empty-state a { font-weight: 700; }

/* ---- Admin console (/console/) ---- */

.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.console-tile {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  margin-bottom: 0;
}
.console-tile h3 { margin: 0 0 0.25rem; color: var(--navy); }
.console-tile p { margin: 0; color: var(--grey); font-size: 0.9rem; }
@media (prefers-reduced-motion: no-preference) {
  .console-tile:hover { transform: translateY(-2px); }
}

/* Restore confirmation (apps/ops/templates/ops/console/restore_confirm.html)
   — the one console action that overwrites existing data outright, so it
   gets its own visually distinct warning treatment rather than the plain
   .card every other page uses. */
.notice-warning {
  background: #FDE7E4;
  border: 2px solid var(--coral);
}
.notice-warning h3 { color: #A62E22; }

/* ---- Login / public-facing ---- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sky);
  padding: 1.5rem;
}
.auth-card {
  background: var(--paper-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 30px rgba(20, 77, 159, 0.25);
  text-align: center;
}
.auth-card h1 {
  color: var(--navy);
  font-size: 1.5rem;
  margin: 0.75rem 0 0.25rem;
}
.auth-card .tagline {
  color: var(--ink-grey);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}
.auth-card form { text-align: left; }

/* ---- Student launcher — touch-first, large targets, high contrast ---- */

.launcher {
  min-height: 100vh;
  background: var(--sky-dark);
  padding: 2rem 1rem;
}

.launcher-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto 2rem;
  flex-wrap: wrap;
  text-align: left;
}
.launcher-head h1 {
  color: white;
  font-size: 1.7rem;
  margin: 0;
}
.launcher-head p {
  color: #CFE0FA;
  margin: 0.15rem 0 0;
  font-size: 1rem;
}

.launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 160px;
  background: white;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  padding: 1.5rem;
  border: 4px solid transparent;
  position: relative;
}
.app-tile:active, .app-tile:focus {
  border-color: var(--sun);
  outline: none;
}

.app-tile-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  background: var(--tile-accent, var(--sky));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-tile-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--sun);
  color: var(--navy);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 2px solid white;
}

.launcher-empty {
  color: white;
  text-align: center;
  max-width: 420px;
  margin: 0 auto;
}
.launcher-empty p {
  font-size: 1.1rem;
  margin-top: 1rem;
}

/* ---- Student "play" wrapper: iframes the running app full-bleed, with a
   small floating way back to the launcher — no browser chrome (back
   button, address bar) required. Semi-transparent until hovered/focused
   so it doesn't compete with the app's own content, but still a full-size
   touch target per the launcher's touch-target guidelines. ---- */

.play-wrap {
  position: fixed;
  inset: 0;
  background: var(--navy);
}
.play-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.play-home {
  position: fixed;
  bottom: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-card);
  box-shadow: 0 2px 10px rgba(22, 35, 63, 0.35);
  opacity: 0.82;
  text-decoration: none;
}
.play-home:hover,
.play-home:focus-visible {
  opacity: 1;
}
.play-home.is-holding { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .play-home { transition: opacity 0.15s ease, transform 0.12s ease; }
  .play-home:hover, .play-home:focus-visible { transform: translateY(-1px); }
}

/* Press-and-hold confirmation ring (apps/students/templates/students/
   launcher/play.html) — a quick brush of the home button during play
   shouldn't exit the app, so it only navigates once held for
   PLAY_HOME_HOLD_MS (see the inline script). The ring is purely a visual
   progress cue; the real timer is JS, not this CSS transition. */
.play-home-ring {
  position: absolute;
  inset: -4px;
  transform: rotate(-90deg);
  pointer-events: none;
}
.play-home-ring-track,
.play-home-ring-fill {
  fill: none;
  stroke-width: 4;
}
.play-home-ring-track { stroke: rgba(22, 35, 63, 0.12); }
.play-home-ring-fill {
  stroke: var(--sun);
  stroke-linecap: round;
  stroke-dasharray: 175.9;
  stroke-dashoffset: 175.9;
}

/* "Tap to start" cover (apps/students/templates/students/launcher/
   play.html) — sits over the whole play-wrap until tapped. Exists so
   entering fullscreen can happen inside a real user gesture (browsers
   refuse a bare, unrequested requestFullscreen() call), and doubles as a
   "get ready" beat before the app itself appears. */
.play-start {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
  border: 0;
  background: var(--navy);
  color: white;
  cursor: pointer;
}
.play-start-label {
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-align: center;
  padding: 0 2rem;
}
.play-start-dismissed {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .play-start { transition: opacity 0.2s ease; }
}

/* ---- Public marketing site (home, contact) ---- */

.logo-wordmark { font-family: var(--font-display); }

.public-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem 2rem;
}
.public-header-brand { text-decoration: none; display: inline-flex; }
.public-header-nav { display: flex; align-items: center; gap: 1.5rem; font-weight: 700; }
.public-header-nav a { text-decoration: none; color: var(--navy); }
.public-header-teacher-login { color: var(--sky); }

.hero {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
  flex-wrap: wrap;
}
.hero-copy { flex: 1 1 380px; }
.hero-copy h1 { font-size: 2.2rem; line-height: 1.15; margin: 0 0 1rem; color: var(--navy); }
.hero-sub { font-size: 1.05rem; color: var(--ink-grey); margin: 0 0 1.5rem; max-width: 480px; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hero-art-wrap { flex: 1 1 320px; display: flex; justify-content: center; }
.hero-art { width: 100%; max-width: 380px; height: auto; }

.btn-hero { background: var(--sky-dark); border-color: var(--sky-dark); padding: 0.75rem 1.6rem; font-size: 1.05rem; }

.section { max-width: 1100px; margin: 0 auto; padding: 3rem 2rem; }
.section-alt { background: var(--paper-card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { text-align: center; font-size: 1.6rem; color: var(--navy); margin: 0 0 2rem; }

.feature-grid, .steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}
.feature-card, .step-card {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}
.feature-card h3, .step-card h3 { margin: 0 0 0.4rem; font-size: 1.1rem; color: var(--navy); }
.feature-card p, .step-card p { margin: 0; color: var(--ink-grey); font-size: 0.95rem; }

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--sun);
  color: var(--navy);
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.cta-banner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1000px;
  margin: 0 auto;
  padding: 3rem 2rem;
}
.cta-banner h2 { margin: 0 0 0.25rem; font-size: 1.4rem; color: var(--navy); }
.cta-banner p { margin: 0; color: var(--ink-grey); }

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--ink-grey);
  font-size: 0.85rem;
}
.site-footer nav { display: flex; gap: 1.25rem; flex-wrap: wrap; justify-content: center; }
.site-footer nav a { color: var(--ink-grey); text-decoration: none; font-weight: 700; }

.contact-section {
  display: flex;
  gap: 2.5rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
  flex-wrap: wrap;
}
.contact-intro { flex: 1 1 280px; }
.contact-intro h1 { font-size: 1.8rem; color: var(--navy); margin: 0.75rem 0 0.75rem; }
.contact-intro p { color: var(--ink-grey); }
.contact-card { flex: 1 1 320px; align-self: flex-start; }

textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  resize: vertical;
}
textarea:focus { outline: 3px solid var(--sun); outline-offset: 1px; }

.field-error { color: var(--danger); font-size: 0.85rem; margin: -0.75rem 0 1rem; }
