/* ============================================================================
   Trionic Courses — base.css
   Governs: PLAN.md §7 (Design System) + §11 (Build Contract)
   Contents: reset, design tokens (light + dark), typography, a11y primitives.
   Other CSS files (components/landing/lesson) consume these tokens.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Noto+Sans+Gujarati:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* `hidden` attribute must defeat any `display: *` rule from component CSS. */
[hidden] { display: none !important; }

/* ----------------------------------------------------------------------------
   Reduced motion — site-wide override (declared early so the intent is obvious
   to readers; `!important` wins regardless of position, but components.css and
   landing.css inherit this baseline before defining their own animations).
   ---------------------------------------------------------------------------- */

@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;
  }

  html {
    scroll-behavior: auto;
  }

  body {
    transition: none;
  }
}

/* ----------------------------------------------------------------------------
   1. Modern reset
   ---------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
}

body {
  min-height: 100vh;
  line-height: 1.65;
  letter-spacing: 0.005em; /* Quicksand reads cleanest with slightly opened tracking */
  font-feature-settings: "ss01", "kern"; /* Quicksand stylistic alternates (rounder "a") + proper kerning */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--brand-strong);
}

/* ----------------------------------------------------------------------------
   2. Design tokens — light theme (default)
   ---------------------------------------------------------------------------- */

:root {
  /* Brand */
  --brand: #0891b2;
  --brand-strong: #0e7490;
  --brand-soft: #ecfeff;

  /* Text */
  --ink: #0f172a;
  --ink-muted: #475569;

  /* Surfaces */
  --paper: #ffffff;
  --paper-soft: #f8fafc;
  --paper-sunken: #f1f5f9;

  /* Lines */
  --border: #e2e8f0;

  /* Status */
  --success: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;

  /* Focus */
  --focus-ring: #2563eb;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Spacing scale (4 / 8 / 12 / 16 / 24 / 32 / 48 / 64) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Shadows (kept subtle) */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);

  /* Layout */
  --container: 1120px;
  --reading-column: 680px;

  /* Motion tokens — consumed by components.css, landing.css, lesson.css.
     Easing curves cover: standard exits, balanced in/out, springy overshoot,
     and material-style soft. Durations form a 5-step ladder from micro tap
     feedback up to deliberate hero entrances. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --dur-1: 120ms;    /* tap / press / micro */
  --dur-2: 200ms;    /* hover, color change */
  --dur-3: 320ms;    /* entrance, layout shift */
  --dur-4: 500ms;    /* hero entrance, big shifts */
  --dur-5: 800ms;    /* deliberate stagger entrances */
}

/* ----------------------------------------------------------------------------
   3. Design tokens — dark theme
   ---------------------------------------------------------------------------- */

[data-theme="dark"] {
  --brand: #22d3ee;
  --brand-strong: #67e8f9;
  --brand-soft: #0e3a44;

  --ink: #e2e8f0;
  --ink-muted: #94a3b8;

  --paper: #0b1220;
  --paper-soft: #111a2e;
  --paper-sunken: #0a1426;

  --border: #1e293b;

  --success: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;

  --focus-ring: #60a5fa;

  /* Slightly stronger shadows on dark, but still gentle */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* ----------------------------------------------------------------------------
   4. Typography
   ---------------------------------------------------------------------------- */

body {
  font-family: 'Quicksand', 'Noto Sans Gujarati', system-ui, -apple-system, sans-serif;
  font-size: 17px; /* mobile baseline */
  color: var(--ink);
  background-color: var(--paper);
  transition: background-color 0.2s ease, color 0.2s ease;
}

@media (min-width: 768px) {
  body {
    font-size: 18px; /* desktop baseline */
  }
}

code,
pre,
kbd,
samp {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9375em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.25rem; /* mobile */
  font-weight: 700; /* Quicksand maxes at 700; reads heavier than Inter 800 already */
  letter-spacing: -0.015em; /* Quicksand is rounded; too-tight tracking gets muddy */
}

h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

h3 {
  font-size: 1.375rem;
  font-weight: 600;
}

@media (min-width: 768px) {
  h1 {
    font-size: 2.75rem;
  }
  h2 {
    font-size: 2rem;
  }
}

p {
  color: var(--ink);
}

small {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

::selection {
  background-color: var(--brand-soft);
  color: var(--ink);
}

/* ----------------------------------------------------------------------------
   5. Bilingual visibility (English / Gujarati)
   ---------------------------------------------------------------------------- */

[data-lang="en"] .lang-gu {
  display: none;
}

[data-lang="gu"] .lang-en {
  display: none;
}

/* ----------------------------------------------------------------------------
   6. Focus, accessibility utilities
   ---------------------------------------------------------------------------- */

*:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Hide the default focus ring only on mouse interactions where :focus-visible
   already hides itself — we never strip without replacement. */

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-3);
  inset-block-start: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background-color: var(--paper);
  color: var(--ink);
  border: 2px solid var(--focus-ring);
  border-radius: var(--radius-md);
  font-weight: 600;
  z-index: 1000;
  /* visually hidden until focused */
  transform: translateY(-200%);
  transition: transform 0.15s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------------------
   7. Global motion keyframes — consumed by components.css, landing.css, lesson.css
   ----------------------------------------------------------------------------
   These are bare definitions. Consumers wrap their actual animation usage in
   `@media (prefers-reduced-motion: no-preference)` so motion is opt-in.
   The site-wide `prefers-reduced-motion: reduce` override at the top of this
   file collapses any remaining animation-duration to 0.001ms as a safety net.

   Every keyframe is namespaced `trionic-*` to avoid collisions with any
   third-party CSS or sibling agent's animations.
   ---------------------------------------------------------------------------- */

/* Fade up — primary entrance for cards, paragraphs, list items */
@keyframes trionic-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in — for background layers, modals, soft reveals */
@keyframes trionic-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Brand ring pulse — for "correct answer" feedback, streak milestones */
@keyframes trionic-pulse-brand {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 55%, transparent);
  }
  100% {
    box-shadow: 0 0 0 12px color-mix(in srgb, var(--brand) 0%, transparent);
  }
}

/* Shimmer — skeleton loaders, course-card cover sheen */
@keyframes trionic-shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}

/* SVG line draw-on — for progress rings, illustration strokes */
@keyframes trionic-draw-line {
  from { stroke-dashoffset: var(--draw-length, 1000); }
  to   { stroke-dashoffset: 0; }
}

/* Gentle vertical float — hero blobs, decorative orbs */
@keyframes trionic-float-y {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

/* Gentle horizontal float — paired decorative motion */
@keyframes trionic-float-x {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/* Bounce in — badge unlocks, persona-badge entry */
@keyframes trionic-bounce-in {
  0%   { opacity: 0; transform: scale(0.85); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

/* Flicker — streak flame, candle-like accents */
@keyframes trionic-flicker {
  0%   { opacity: 1; }
  35%  { opacity: 0.85; }
  60%  { opacity: 1; }
  85%  { opacity: 0.92; }
  100% { opacity: 1; }
}

/* Slow spin — decorative orbs, idle background ornaments */
@keyframes trionic-spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
