/* ==========================================================================
   Hey Hoolo — shared design tokens
   Loaded by the student page, the Teacher workspace and the Admin console so
   all three surfaces speak the same visual language.

   Contents
   1. Typography
   2. Colour system (light default + dark theme for the student toggle)
   3. Shape, elevation, spacing
   4. Motion
   5. Shared primitives (skip link, screen-reader text, focus ring, scrollbar)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Typography
   Display  : Nunito  — large headings, the owl's personality
   UI / body: DM Sans — highly legible interface copy
   Both have strong local fallbacks so the pages never depend on the CDN.
   -------------------------------------------------------------------------- */
:root {
  --hh-font-display: 'Nunito', 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --hh-font-ui: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --hh-font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   2. Colour system — Accolaide brand mapped onto --hh-* roles
   Soft White / Deep Ink grounds · Deep Blue action (--hh-purple*) · coral
   energy via amber · cyans for success/info. Token names kept for compat.
   Board coral #FE8B6D is not used as a white-label fill on light (AA fail).
   -------------------------------------------------------------------------- */
:root {
  /* Canvas + surfaces — Soft White family */
  --hh-canvas: #f7faff;
  --hh-canvas-tint: #e8f3ff;
  --hh-surface: #ffffff;
  --hh-surface-sunk: #e6f8f7;
  --hh-surface-raised: #ffffff;

  /* Ink — Deep Ink ladder (hue-tinted, not grey) */
  --hh-ink: #0b1b2d;
  --hh-ink-soft: #3a4d63;
  --hh-ink-muted: #5a6b7f;
  --hh-ink-on-accent: #ffffff;

  /* Brand / action — Accolaide Deep Blue (token name --hh-purple retained) */
  --hh-purple: #386eec;
  --hh-purple-strong: #2f5cd4; /* text links on Soft White ~5.6:1 */
  --hh-purple-deep: #2448b0;
  --hh-purple-soft: #dcebff;
  --hh-purple-ring: rgba(56, 110, 236, 0.36);

  /* Status — success from Deep Cyan (AA solid fill, not board #00A7CA+white) */
  --hh-mint: #087a98;
  --hh-mint-strong: #066a84;
  --hh-mint-soft: #d4f3f2;
  --hh-mint-ring: rgba(8, 122, 152, 0.28);

  /* Status — warn / rare energy (coral family) */
  --hh-amber: #c44b18; /* AA white-on-fill ~4.8:1 */
  --hh-amber-bright: #fe8b6d; /* board coral — icons/charts, not body text on light */
  --hh-amber-soft: #fff0eb;
  --hh-amber-ring: rgba(196, 75, 24, 0.28);

  /* Status — information */
  --hh-blue: #087a98; /* text-safe cyan; board #15B0CD fails AA on Soft White */
  --hh-blue-bright: #4786f5;
  --hh-blue-soft: #e8f3ff;
  --hh-blue-ring: rgba(8, 122, 152, 0.26);

  /* Status — red (off-board; Accolaide has no critical red) */
  --hh-red: #c02626;
  --hh-red-soft: #fdeaea;
  --hh-red-ring: rgba(192, 38, 38, 0.28);

  /* Lines + focus */
  --hh-line: #d5deea;
  --hh-line-strong: #a8b6c8;
  --hh-focus: #386eec;

  /* Navy — Teacher / Admin sidebars aligned to Deep Ink */
  --hh-navy-900: #0b1b2d;
  --hh-navy-800: #12263b;
  --hh-navy-700: #16324a;
  --hh-navy-600: #1a3a56;
  --hh-navy-ink: #f7faff;
  --hh-navy-ink-muted: #a8b6c8;
  --hh-navy-line: rgba(247, 250, 255, 0.12);
}

/* Dark theme — composed elevation on Deep Ink (not a mechanical invert).
   The toggle lives in index.html and flips body[data-theme]. */
body[data-theme='dark'] {
  --hh-canvas: #0b1b2d;
  --hh-canvas-tint: #12263b;
  --hh-surface: #16324a;
  --hh-surface-sunk: #12263b;
  --hh-surface-raised: #1a3a56;

  --hh-ink: #f7faff;
  --hh-ink-soft: #d5deea;
  --hh-ink-muted: #a8b6c8;
  --hh-ink-on-accent: #ffffff;

  --hh-purple: #4786f5;
  --hh-purple-strong: #8fc4fc;
  --hh-purple-deep: #b3c9ff;
  --hh-purple-soft: rgba(71, 134, 245, 0.18);
  --hh-purple-ring: rgba(143, 196, 252, 0.45);

  --hh-mint: #6fd8db;
  --hh-mint-strong: #93e8e1;
  --hh-mint-soft: rgba(111, 216, 219, 0.16);
  --hh-mint-ring: rgba(111, 216, 219, 0.36);

  --hh-amber: #fe8b6d;
  --hh-amber-bright: #ffb08f;
  --hh-amber-soft: rgba(254, 139, 109, 0.16);
  --hh-amber-ring: rgba(254, 139, 109, 0.36);

  --hh-blue: #8fc4fc;
  --hh-blue-bright: #93e8e1;
  --hh-blue-soft: rgba(143, 196, 252, 0.16);
  --hh-blue-ring: rgba(143, 196, 252, 0.36);

  --hh-red: #ff9b9b;
  --hh-red-soft: rgba(255, 155, 155, 0.16);
  --hh-red-ring: rgba(255, 155, 155, 0.36);

  --hh-line: rgba(247, 250, 255, 0.12);
  --hh-line-strong: rgba(247, 250, 255, 0.22);
  --hh-focus: #8fc4fc;
}

/* --------------------------------------------------------------------------
   3. Shape, elevation, spacing
   -------------------------------------------------------------------------- */
:root {
  --hh-radius-sm: 8px;
  --hh-radius: 12px;
  --hh-radius-md: 16px;
  --hh-radius-lg: 22px;
  --hh-radius-xl: 28px;
  --hh-radius-pill: 999px;

  --hh-shadow-xs: 0 1px 2px rgba(11, 27, 45, 0.06);
  --hh-shadow-sm: 0 2px 8px rgba(11, 27, 45, 0.07);
  --hh-shadow: 0 8px 24px rgba(11, 27, 45, 0.09);
  --hh-shadow-md: 0 14px 34px rgba(11, 27, 45, 0.12);
  --hh-shadow-lg: 0 24px 56px rgba(11, 27, 45, 0.16);

  --hh-space-1: 4px;
  --hh-space-2: 8px;
  --hh-space-3: 12px;
  --hh-space-4: 16px;
  --hh-space-5: 20px;
  --hh-space-6: 24px;
  --hh-space-8: 32px;
  --hh-space-10: 40px;
  --hh-space-12: 48px;
  --hh-space-16: 64px;

  --hh-tap: 44px; /* minimum comfortable touch target */
}

/* --------------------------------------------------------------------------
   4. Motion — 150–220 ms, gentle easing, fully reversible
   -------------------------------------------------------------------------- */
:root {
  --hh-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --hh-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --hh-t-fast: 150ms;
  --hh-t: 180ms;
  --hh-t-slow: 220ms;
}

/* --------------------------------------------------------------------------
   5. Shared primitives
   -------------------------------------------------------------------------- */

/* Keyboard-only skip link — the first focusable element on teacher/admin,
   and available on the student page too. */
.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 5000;
  background: var(--hh-purple);
  color: #fff;
  font-family: var(--hh-font-ui);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.7rem 1.1rem;
  border-radius: 0 0 var(--hh-radius) var(--hh-radius);
  text-decoration: none;
  transition: top var(--hh-t) var(--hh-ease);
}
.skip-link:focus {
  top: 0;
  outline: 3px solid var(--hh-focus);
  outline-offset: 2px;
}

/* Content available to assistive tech only. */
.hh-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* One consistent, always-visible focus ring. Never remove focus outlines. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--hh-focus);
  outline-offset: 2px;
  border-radius: var(--hh-radius-sm);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--hh-line-strong);
  border-radius: var(--hh-radius-pill);
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   Reduced motion — remove loops, lifts and staggering, keep the UI usable.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Shared animations
   ========================================================================== */

/* The owl's gentle float. Decorative only, slow enough not to distract. */
@keyframes hh-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-9px);
  }
}

/* Soft breathing glow behind the companion. */
@keyframes hh-breathe {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* Staggered entrance for the primary sections. */
@keyframes hh-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hh-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

@keyframes hh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Respect reduced motion for the decorative loops specifically. */
@media (prefers-reduced-motion: reduce) {
  .hh-owl-figure,
  .hh-owl-glow {
    animation: none !important;
  }
  .hh-rise {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ==========================================================================
   6. Hoolo stage aliases — same Accolaide system as the rest of the site.
   Legacy --hh-warm-* names kept so companion CSS keeps working; values mirror
   --hh-* light/dark (no separate cream/orange world).

   IMPORTANT: these aliases must be re-declared on body[data-theme='dark'].
   Custom properties resolve var() at computed-value time on the element that
   *defines* them. If --hh-warm-* only live on :root, they freeze to the light
   Soft White values and inherit that way — so immersive stage backgrounds
   (which use --hh-warm-stage-gradient) stay light even when --hh-canvas is
   remapped to Deep Ink on body. Re-declaring on the dark body rule forces
   them to resolve against the dark --hh-* tokens.
   ========================================================================== */
:root {
  --hh-warm-canvas: var(--hh-canvas);
  --hh-warm-surface: var(--hh-surface);
  --hh-warm-sunk: var(--hh-surface-sunk);
  --hh-warm-surface-raised: var(--hh-surface-raised);
  --hh-warm-border: var(--hh-line);
  --hh-warm-border-strong: var(--hh-line-strong);
  --hh-warm-ink: var(--hh-ink);
  --hh-warm-ink-soft: var(--hh-ink-soft);
  --hh-warm-ink-muted: var(--hh-ink-muted);
  --hh-warm-accent: var(--hh-purple);
  --hh-warm-accent-strong: var(--hh-purple-strong);
  --hh-warm-accent-hover: var(--hh-purple-deep);
  --hh-warm-user-bubble: var(--hh-blue-soft);
  --hh-warm-user-border: var(--hh-line);
  --hh-warm-hoolo-bubble: var(--hh-surface-sunk);
  --hh-warm-hoolo-border: transparent;
  --hh-warm-check: var(--hh-blue-bright);
  --hh-warm-halo: var(--hh-purple-ring);
  --hh-warm-stage-gradient: linear-gradient(
    180deg,
    var(--hh-canvas-tint) 0%,
    var(--hh-canvas) 48%,
    var(--hh-surface-sunk) 100%
  );
}

body[data-theme='dark'] {
  --hh-warm-canvas: var(--hh-canvas);
  --hh-warm-surface: var(--hh-surface);
  --hh-warm-sunk: var(--hh-surface-sunk);
  --hh-warm-surface-raised: var(--hh-surface-raised);
  --hh-warm-border: var(--hh-line);
  --hh-warm-border-strong: var(--hh-line-strong);
  --hh-warm-ink: var(--hh-ink);
  --hh-warm-ink-soft: var(--hh-ink-soft);
  --hh-warm-ink-muted: var(--hh-ink-muted);
  --hh-warm-accent: var(--hh-purple);
  --hh-warm-accent-strong: var(--hh-purple-strong);
  --hh-warm-accent-hover: var(--hh-purple-deep);
  --hh-warm-user-bubble: var(--hh-blue-soft);
  --hh-warm-user-border: var(--hh-line);
  --hh-warm-hoolo-bubble: var(--hh-surface-sunk);
  --hh-warm-hoolo-border: transparent;
  --hh-warm-check: var(--hh-blue-bright);
  --hh-warm-halo: var(--hh-purple-ring);
  --hh-warm-stage-gradient: linear-gradient(
    180deg,
    var(--hh-canvas-tint) 0%,
    var(--hh-canvas) 48%,
    var(--hh-surface-sunk) 100%
  );
}

/* Hoolo companion animations */
@keyframes hoolo-bounce-dot {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes hoolo-fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes hoolo-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(56, 110, 236, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(56, 110, 236, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 110, 236, 0); }
}

@keyframes hoolo-sparkle-float {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(0.5); }
}

@keyframes hoolo-zzz-float {
  0%, 100% { opacity: 0.7; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-6px); }
}
