/* =====================================================================
   SYNAPSE.EXE DESIGN SYSTEM -- shared tokens and page shells.

   Every colour here was sampled from the brand reference image (deep royal
   blue, electric-cyan glow, and the green / orange / amber / sky badges).
   The reference implementation of every screen lives in
   tools/design-preview/preview.src.html -- open tools/design-preview/index.html
   to see it.

   Two modes share one palette. A page opts in with a class on <body>:

     body.mode-clinician  screens a clinician uses alone: sign-in, PIN, Client
                          Portal, Schedule, Data Entry, Progress Monitoring,
                          Record, Settings. Cool-mist background, white cards,
                          flat controls, ONE action colour (orange).
     body.mode-play       the activity hubs a child plays from: Game Hub,
                          Articulation, Language, Flashcards, Puzzles, Social
                          Skills. Deep-blue neural backdrop, glass cards,
                          glowing badges, big rounded playful buttons.

   The older --app-* names are kept as aliases of the new palette, so any
   stylesheet that still reads var(--app-*) picks up the new look. New code
   should prefer the --sx-* names below.
   ===================================================================== */

:root {
  /* ---- brand blues (image background + neuron glow) ---- */
  --sx-navy-950: #050f3a;
  --sx-navy-900: #071751;
  --sx-navy-800: #0b2a6f;
  --sx-royal: #114488;
  /* Play Mode backdrop (hubs, Social Skills): top and bottom of the page gradient.
     Lighter than the old navy; white text stays >= 4.5:1 on the lightest part. */
  --sx-play-top: #2565cc;
  --sx-play-bottom: #123f8f;
  --sx-blue-600: #1860a8;
  --sx-blue-500: #3376d9;
  --sx-cyan: #2ad0f1;
  --sx-cyan-200: #b8f0fb;

  /* ---- signal colours (the five icon badges) ---- */
  --sx-green: #38b49c;
  --sx-green-lt: #a1e58f;
  --sx-orange: #fb5a45;
  --sx-record: #d33e26;   /* recording / live indicator: stays red */
  --sx-orange-lt: #fda640;
  --sx-amber: #fca642;
  --sx-amber-lt: #fed94c;
  --sx-sky: #33a3e6;

  /* ---- clinician surfaces and ink ---- */
  --sx-bg: #f2f6fc;
  --sx-surface: #ffffff;
  --sx-surface-2: #f7f9fd;
  --sx-line: #dde5f1;
  --sx-line-strong: #c3cfe4;
  --sx-ink: #0b1b46;          /* 16:1 on white */
  --sx-ink-2: #3f4f78;        /* 8:1 on white  */
  --sx-ink-3: #5c6a8e;        /* 5.2:1 on white */

  /* ---- the action colour: blue. White text on it is 6:1. ---- */
  --sx-primary: #1b5fd1;
  --sx-primary-hover: #144db0;
  --sx-primary-ink: #1450b0;  /* blue as small text on white */
  --sx-primary-tint: #e6efff;

  /* ---- soft chip tints (background / text) ---- */
  --sx-t-blue: #e6efff;   --sx-t-blue-ink: #1450b0;
  --sx-t-green: #e3f6ef;  --sx-t-green-ink: #0f6b58;
  --sx-t-orange: #ffece8; --sx-t-orange-ink: #b2351f;
  --sx-t-amber: #fff2cf;  --sx-t-amber-ink: #84550a;
  --sx-t-cyan: #dcf7fd;   --sx-t-cyan-ink: #0a6479;

  /* ---- shape, depth, type ---- */
  --sx-radius: 14px;
  --sx-radius-sm: 10px;
  --sx-shadow-sm: 0 1px 2px rgba(11, 27, 70, 0.06);
  --sx-shadow: 0 1px 2px rgba(11, 27, 70, 0.05), 0 8px 24px rgba(11, 27, 70, 0.07);
  --sx-focus: #2ad0f1;
  --sx-font-display: 'Space Grotesk', 'Sora', 'Segoe UI', system-ui, sans-serif;
  --sx-font-body: 'Sora', 'Segoe UI', system-ui, sans-serif;

  /* ---- legacy --app-* aliases (clinician defaults) ---- */
  --app-bg-start: var(--sx-bg);
  --app-bg-mid: var(--sx-bg);
  --app-bg-end: var(--sx-bg);
  --app-shell-start: var(--sx-surface);
  --app-shell-end: var(--sx-surface);
  --app-line: var(--sx-line);
  --app-line-strong: var(--sx-line-strong);
  --app-surface: var(--sx-surface);
  --app-surface-strong: var(--sx-surface);
  --app-text: var(--sx-ink);
  --app-muted: var(--sx-ink-2);
  --app-accent: var(--sx-primary);
  --app-accent-strong: var(--sx-primary-hover);
  --app-accent-solid: var(--sx-primary);
  --app-accent-tint: var(--sx-primary-tint);
  --app-warm: var(--sx-orange-lt);
  --app-yellow: var(--sx-amber-lt);
  --app-sky: var(--sx-sky);
  --app-mint: var(--sx-green);
  --app-purple: var(--sx-blue-500);
  --app-radius: var(--sx-radius);
  --app-panel-radius: var(--sx-radius);
  --app-pill-radius: var(--sx-radius-sm);
  --app-shadow-soft: var(--sx-shadow);
  --app-shadow-pop: 0 0 0 rgba(0, 0, 0, 0);
  --app-hover-lift: translateY(0);
  color-scheme: light;
}

/* ===================================================================
   PLAY MODE token overrides. Inside a play page every legacy --app-*
   reader flips to a dark-backdrop reading: white text, glass surfaces,
   round playful buttons, a soft cyan glow and a real hover lift.
   =================================================================== */
body.mode-play {
  --app-text: #ffffff;
  --app-muted: #e6eeff;
  --app-line: rgba(255, 255, 255, 0.2);
  --app-line-strong: rgba(255, 255, 255, 0.3);
  --app-shell-start: rgba(255, 255, 255, 0.08);
  --app-shell-end: rgba(255, 255, 255, 0.05);
  --app-surface: rgba(255, 255, 255, 0.08);
  --app-surface-strong: rgba(255, 255, 255, 0.12);
  --app-accent: var(--sx-cyan);
  --app-accent-strong: var(--sx-cyan-200);
  --app-accent-solid: var(--sx-blue-500);
  --app-accent-tint: rgba(42, 208, 241, 0.16);
  --app-radius: 24px;
  --app-panel-radius: 20px;
  --app-pill-radius: 999px;
  --app-shadow-soft: 0 18px 40px rgba(3, 10, 40, 0.35);
  --app-shadow-pop: 0 10px 24px rgba(42, 208, 241, 0.35);
  --app-hover-lift: translateY(-3px);
  --landing-line: var(--app-line);
  --landing-text: var(--app-text);
  --landing-muted: var(--app-muted);
  --section-pill-border: rgba(255, 255, 255, 0.24);
  --section-pill-glow: rgba(42, 208, 241, 0.2);
  --section-pill-text: #ffffff;
  color-scheme: dark;
}

/* ===================================================================
   PAGE BACKGROUNDS
   =================================================================== */
body.mode-clinician {
  min-height: 100vh;
  margin: 0;
  background: var(--sx-bg);
  color: var(--sx-ink);
  font-family: var(--sx-font-body);
  -webkit-font-smoothing: antialiased;
}

body.mode-play {
  min-height: 100vh;
  margin: 0;
  color: #ffffff;
  font-family: var(--sx-font-body);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(42, 208, 241, 0.34), transparent 62%),
    radial-gradient(800px 460px at 105% 5%, rgba(96, 160, 255, 0.4), transparent 60%),
    radial-gradient(700px 400px at 50% 120%, rgba(56, 180, 156, 0.2), transparent 60%),
    linear-gradient(180deg, var(--sx-play-top), var(--sx-play-bottom));
  background-color: var(--sx-play-bottom);
}

/* faint constellation dots behind play content, fading out downwards */
body.mode-play::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.5px);
  background-size: 34px 34px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 75%);
  mask-image: linear-gradient(180deg, #000, transparent 75%);
}

/* pages that predate the mode classes fall back to the clinician look */
body.hub-ambient:not(.mode-play):not(.mode-clinician),
body.hub-landing:not(.mode-play):not(.mode-clinician) {
  min-height: 100vh;
  margin: 0;
  background: var(--sx-bg);
  color: var(--sx-ink);
  font-family: var(--sx-font-body);
}

/* ===================================================================
   PAGE SHELLS
   =================================================================== */
body.hub-ambient .main-content,
body.hub-landing .main-content {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  padding: clamp(24px, 4vw, 40px) clamp(14px, 2.8vw, 32px) 56px;
}

/* clinician: no outer card -- the page's own cards sit straight on the mist */
body.mode-clinician .main-content > .tool-shell,
body.mode-clinician .main-content > .landing-shell {
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--sx-ink);
}

/* play: no container at all -- every hub's content sits straight on the neural
   backdrop inside a .hub-page wrapper (see template/HubLayout.css). */
body.mode-play .main-content > .tool-shell,
body.mode-play .main-content > .landing-shell {
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #ffffff;
}

body.page-session-recorder #session-recorder-section {
  padding-top: clamp(22px, 4vw, 34px);
}

/* headings */
body.hub-landing .landing-hero h1,
body.hub-ambient .tool-header h1 {
  color: var(--app-text);
  font-family: var(--sx-font-display);
  letter-spacing: -0.01em;
}

body.hub-landing .landing-hero p,
body.hub-ambient .tool-subtitle {
  color: var(--app-muted);
}

/* ---- hub landing chips / groups ---- */
body.hub-landing .section-eyebrow {
  border-color: var(--section-pill-border, var(--sx-line-strong));
  background: var(--app-accent-tint);
  color: var(--app-accent-strong);
  box-shadow: none;
}

body.mode-clinician.hub-landing .section-eyebrow {
  border-color: rgba(27, 95, 209, 0.28);
  color: var(--sx-primary-ink);
}

body.hub-landing .section-pill {
  border-color: var(--app-line-strong);
  background: var(--app-surface);
  color: var(--app-muted);
}

body.hub-landing .game-group {
  border: 1px solid var(--app-line);
  border-radius: var(--app-panel-radius);
  background: var(--app-surface);
  box-shadow: none;
}

body.hub-landing .game-card,
body.hub-landing .speech-game-entry {
  border-color: var(--app-line);
  border-radius: var(--app-panel-radius);
}

body.page-socialskills .landing-shell,
body.page-language .landing-shell,
body.page-articulation .landing-shell,
body.page-puzzles .landing-shell,
body.page-gamehub .landing-shell {
  border-color: var(--app-line);
  color: var(--app-text);
}

body.page-socialskills .section-eyebrow,
body.page-language .section-eyebrow,
body.page-articulation .section-eyebrow,
body.page-puzzles .section-eyebrow,
body.page-gamehub .section-eyebrow {
  border: 1px solid var(--section-pill-border, var(--sx-line-strong));
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--app-accent-tint);
  color: var(--app-accent-strong);
}

body.page-socialskills .section-eyebrow::after {
  content: none;
}

body.page-socialskills .section-pill,
body.page-language .section-pill,
body.page-articulation .section-pill,
body.page-puzzles .section-pill,
body.page-gamehub .section-pill {
  padding: 9px 14px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  background: var(--app-surface);
  color: var(--app-muted);
}

/* ---- data entry ---- */
body.page-data-entry .de-card {
  border: 1px solid var(--app-line);
  border-radius: var(--sx-radius);
  background: var(--sx-surface);
  box-shadow: var(--sx-shadow);
  color: var(--sx-ink);
}

body.page-data-entry .de-client-row h2,
body.page-data-entry .de-count,
body.page-data-entry .de-net-value {
  color: var(--sx-ink);
}

body.page-data-entry .de-hint,
body.page-data-entry .de-tally-label,
body.page-data-entry .de-net-label,
body.page-data-entry .de-notes-label {
  color: var(--sx-ink-2);
}

body.page-data-entry .de-tally-card,
body.page-data-entry .de-net-row {
  border-color: var(--sx-line);
  background: var(--sx-surface-2);
}

body.page-data-entry .de-select,
body.page-data-entry .de-notes {
  border-color: var(--sx-line-strong);
  background: var(--sx-surface);
  color: var(--sx-ink);
}

@media (max-width: 600px) {
  body.hub-ambient .main-content,
  body.hub-landing .main-content {
    padding: calc(72px + env(safe-area-inset-top, 0px)) 0 32px;
  }

  body.mode-play .main-content > .tool-shell,
  body.mode-play .main-content > .landing-shell {
    padding: 0 14px;
  }

  body.page-session-recorder #session-recorder-section {
    padding-top: 18px;
  }
}

/* ---- Legal footer, first-launch consent and link gate ----
   LegalConsent.js injects these three pieces at runtime with its own dark-teal
   defaults. They are re-skinned here on every page that loads this stylesheet
   (the leading `body` out-ranks the runtime-injected <style> without
   !important). The consent and gate cards are white with a flat orange button
   in both modes. */
body .sx-legal-footer {
  background: var(--sx-surface);
  color: var(--sx-ink-2);
  border-top: 1px solid var(--sx-line);
}

body .sx-legal-footer a {
  color: var(--sx-primary-ink);
  font-weight: 600;
}

body .sx-legal-footer a:hover,
body .sx-legal-footer a:focus-visible {
  color: var(--sx-primary);
}

body .sx-legal-footer a:focus-visible {
  outline: 2px solid var(--sx-focus);
}

body .sx-consent-overlay,
body .sx-gate-overlay {
  background: rgba(7, 23, 81, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

body .sx-consent-card,
body .sx-gate-card {
  border: 1px solid var(--sx-line);
  border-radius: var(--sx-radius);
  background: var(--sx-surface);
  color: var(--sx-ink);
  box-shadow: 0 24px 60px rgba(7, 23, 81, 0.28);
}

body .sx-consent-card p,
body .sx-gate-card p {
  color: var(--sx-ink-2);
}

body .sx-consent-links a {
  color: var(--sx-primary-ink);
  font-weight: 600;
  text-decoration: underline;
}

body .sx-consent-agree,
body .sx-gate-submit {
  border-radius: var(--sx-radius-sm);
  background: var(--sx-primary);
  color: #fff;
  box-shadow: none;
  transform: none;
  transition: background-color 0.12s ease;
}

body .sx-consent-agree:hover,
body .sx-gate-submit:hover {
  background: var(--sx-primary-hover);
  transform: none;
  box-shadow: none;
}

body .sx-consent-agree:focus-visible,
body .sx-gate-input:focus-visible,
body .sx-gate-actions button:focus-visible {
  outline: 3px solid var(--sx-focus);
  outline-offset: 2px;
}

body .sx-gate-input {
  border-color: var(--sx-line-strong);
  background: var(--sx-surface);
  color: var(--sx-ink);
}

body .sx-gate-error {
  color: #b42318;
}

body .sx-gate-cancel {
  border: 1px solid var(--sx-line-strong) !important;
  border-radius: var(--sx-radius-sm);
  color: var(--sx-ink-2);
}

/* play pages keep the footer readable on the dark backdrop */
body.mode-play .sx-legal-footer {
  background: rgba(5, 15, 58, 0.72);
  color: #c5d3ff;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

body.mode-play .sx-legal-footer a {
  color: var(--sx-cyan-200);
}

@media (prefers-reduced-motion: reduce) {
  body .sx-consent-agree,
  body .sx-gate-submit {
    transition: none;
  }
}
