/* ==========================================================================
   Gonit Ongon — Design System  (গণিত অঙ্গন ডিজাইন সিস্টেম)
   --------------------------------------------------------------------------
   Canonical design tokens. This is the single source of truth for colour,
   type, spacing, radius, elevation and motion. Every other stylesheet must
   reference these tokens — never hard-coded hex, px shadows or ad-hoc radii.

   Token groups:
     1. Fonts            5. Spacing scale (4px base)
     2. Colour primitives 6. Radius
     3. Semantic colour   7. Elevation
     4. Typography scale  8. Motion
                          9. Layout + z-index
   Theming: light is the default; dark is applied via
   `@media (prefers-color-scheme: dark)` and `:root[data-theme="dark"]`.
   ========================================================================== */

/* Latin (Inter) + Bangla (Hind Siliguri). Per-glyph fallback means Bangla
   characters automatically pick Hind Siliguri even inside Inter runs. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Hind+Siliguri:wght@400;500;600;700&display=swap');

:root {
  /* ----------------------------------------------------------------------
     1. FONTS
     ---------------------------------------------------------------------- */
  --font-sans: 'Inter', 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI',
    Roboto, Helvetica, Arial, sans-serif;
  --font-bn: 'Hind Siliguri', 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo,
    Consolas, monospace;

  /* ----------------------------------------------------------------------
     2. COLOUR PRIMITIVES  (raw palette — do not use directly in components;
        use the semantic roles in §3)
     ---------------------------------------------------------------------- */
  /* Deep Slate Navy — structure, header, ink */
  --slate-950: #0F172A;
  --slate-900: #1E293B;
  --slate-800: #334155;
  --slate-700: #475569;
  --slate-600: #52637a;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;

  /* Mathematical Emerald — brand / primary action / success */
  --emerald-800: #065F46;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-500: #10B981;
  --emerald-200: #A7F3D0;
  --emerald-100: #D1FAE5;
  --emerald-50:  #ECFDF5;

  /* Warm Amber — selective badges / daily challenge / step alerts */
  --amber-600: #D97706;
  --amber-500: #F59E0B;
  --amber-100: #FEF3C7;

  /* Terracotta Rose — difficulty "Hard" / destructive / critical alerts */
  --rose-600: #E11D48;
  --rose-500: #F43F5E;
  --rose-100: #FFE4E6;

  /* Sky — informational (non-brand accent, used sparingly) */
  --sky-600: #0284C7;
  --sky-100: #E0F2FE;

  --white: #FFFFFF;
  --black: #020617;

  /* ----------------------------------------------------------------------
     3. SEMANTIC COLOUR ROLES  (light theme — the default)
     ---------------------------------------------------------------------- */
  --color-bg:            var(--slate-50);   /* page canvas — clean, non-glare */
  --color-surface:       var(--white);      /* cards, panels */
  --color-surface-2:     var(--slate-100);  /* insets, subtle fills, hover */
  --color-surface-inset: var(--slate-100);
  --color-border:        var(--slate-200);  /* resting borders */
  --color-border-strong: var(--slate-300);  /* dividers that must read */

  --color-ink:     var(--slate-950);  /* headings + running text (full ink) */
  --color-ink-2:   var(--slate-700);  /* secondary text (still accessible) */
  --color-muted:   var(--slate-500);  /* captions, meta, disabled labels */
  --color-on-dark: var(--slate-50);   /* text on slate/dark surfaces */
  --color-on-dark-muted: var(--slate-400);

  /* Header / key structural containers are grounded in deep slate */
  --color-header:    var(--slate-950);
  --color-header-2:  var(--slate-900);

  /* Brand accent — primary action, active nav, success */
  --color-accent:          var(--emerald-600);
  --color-accent-hover:    var(--emerald-700);
  --color-accent-active:   var(--emerald-800);
  --color-accent-contrast: var(--white);
  --color-accent-soft:     var(--emerald-100);
  --color-accent-ring:     rgba(5, 150, 105, 0.35);

  /* Status */
  --color-success:       var(--emerald-600);
  --color-success-soft:  var(--emerald-100);
  --color-warning:       var(--amber-600);
  --color-warning-soft:  var(--amber-100);
  --color-danger:        var(--rose-600);
  --color-danger-soft:   var(--rose-100);
  --color-info:          var(--sky-600);
  --color-info-soft:     var(--sky-100);

  /* Difficulty tags */
  --tag-easy:   var(--emerald-600);
  --tag-easy-soft:   var(--emerald-100);
  --tag-medium: var(--amber-600);
  --tag-medium-soft: var(--amber-100);
  --tag-hard:   var(--rose-600);
  --tag-hard-soft:   var(--rose-100);

  /* ----------------------------------------------------------------------
     4. TYPOGRAPHY SCALE  (fluid where it helps the hero; fixed for UI)
        Two or three sizes do the visible work — one very large, one small.
     ---------------------------------------------------------------------- */
  --text-xs:   0.75rem;    /* 12 */
  --text-sm:   0.875rem;   /* 14 */
  --text-base: 1rem;       /* 16 — running text floor */
  --text-lg:   1.125rem;   /* 18 */
  --text-xl:   1.25rem;    /* 20 */
  --text-2xl:  1.5rem;     /* 24 */
  --text-3xl:  clamp(1.75rem, 1.25rem + 2vw, 2.25rem);
  --text-4xl:  clamp(2.25rem, 1.4rem + 3.2vw, 3.25rem);
  --text-5xl:  clamp(2.75rem, 1.3rem + 5.2vw, 4.5rem);

  --leading-tight:  1.1;   /* display */
  --leading-snug:   1.25;  /* headings */
  --leading-normal: 1.6;   /* body */
  --tracking-tight: -0.02em;
  --tracking-display: -0.035em;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semibold:600;
  --weight-bold:    700;
  --weight-black:   800;

  /* ----------------------------------------------------------------------
     5. SPACING SCALE  (4px base — all layout padding/margins reference this)
     ---------------------------------------------------------------------- */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4  */
  --space-2: 0.5rem;    /* 8  */
  --space-3: 0.75rem;   /* 12 */
  --space-4: 1rem;      /* 16 */
  --space-5: 1.25rem;   /* 20 */
  --space-6: 1.5rem;    /* 24 */
  --space-8: 2rem;      /* 32 */
  --space-10: 2.5rem;   /* 40 */
  --space-12: 3rem;     /* 48 */
  --space-16: 4rem;     /* 64 */
  --space-20: 5rem;     /* 80 */
  --space-24: 6rem;     /* 96 */
  --section-gap: clamp(3.5rem, 2rem + 6vw, 7.5rem);

  /* ----------------------------------------------------------------------
     6. RADIUS  (crisp, slightly rounded rectangles — never oval pills on UI)
     ---------------------------------------------------------------------- */
  --radius-sm:   4px;
  --radius:      6px;
  --radius-md:   8px;   /* buttons, inputs */
  --radius-lg:   12px;  /* cards, panels */
  --radius-xl:   16px;  /* feature surfaces */
  --radius-2xl:  22px;
  --radius-full: 9999px;

  /* ----------------------------------------------------------------------
     7. ELEVATION  (tone-steps at rest; shadows reserved for things that
        truly float — menus, dialogs, drawers, and interactive lift)
     ---------------------------------------------------------------------- */
  --shadow-none: none;
  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:     0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-pop: 0 4px 12px rgba(15, 23, 42, 0.10), 0 2px 4px rgba(15, 23, 42, 0.06);
  --shadow-lg:  0 12px 32px rgba(15, 23, 42, 0.14), 0 4px 8px rgba(15, 23, 42, 0.06);

  /* Tactile button tokens (per brief) */
  --btn-inset:        inset 0 -2px 0 rgba(0, 0, 0, 0.22);
  --btn-inset-light:  inset 0 -2px 0 rgba(0, 0, 0, 0.10);
  --shadow-accent-hover: 0 4px 12px rgba(5, 150, 105, 0.25);

  --focus-ring: 0 0 0 3px var(--color-accent-ring);

  /* ----------------------------------------------------------------------
     8. MOTION  (spring physics for drawers/modals/step reveals)
     ---------------------------------------------------------------------- */
  --ease-spring:   cubic-bezier(0.16, 1, 0.3, 1);   /* snappy overshoot-free */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:      cubic-bezier(0.22, 1, 0.36, 1);
  --dur-instant: 90ms;
  --dur-fast:    140ms;
  --dur:         220ms;
  --dur-slow:    360ms;
  --dur-slower:  560ms;
  --transition-base:   all var(--dur) var(--ease-standard);
  --transition-spring: all var(--dur-slow) var(--ease-spring);

  /* ----------------------------------------------------------------------
     9. LAYOUT + Z-INDEX
     ---------------------------------------------------------------------- */
  --container:      1200px;
  --container-wide: 1320px;
  --container-prose:  68ch;
  --page-pad: clamp(1rem, 4vw, 2rem);

  --z-base: 1;
  --z-sticky: 100;
  --z-drawer: 900;
  --z-nav: 1000;
  --z-modal: 1100;
  --z-toast: 1200;
}

/* ==========================================================================
   DARK THEME  (auto by system pref, overridable with [data-theme])
   Deep slate becomes the ground; emerald stays the accent.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg:            var(--slate-950);
    --color-surface:       var(--slate-900);
    --color-surface-2:     var(--slate-800);
    --color-surface-inset: #16233b;
    --color-border:        #243450;
    --color-border-strong: var(--slate-700);

    --color-ink:     var(--slate-50);
    --color-ink-2:   var(--slate-300);
    --color-muted:   var(--slate-400);

    --color-header:   #0b1222;
    --color-header-2: var(--slate-900);

    --color-accent:        var(--emerald-500);
    --color-accent-hover:  var(--emerald-600);
    --color-accent-soft:   rgba(16, 185, 129, 0.16);

    --color-success-soft: rgba(16, 185, 129, 0.16);
    --color-warning-soft: rgba(217, 119, 6, 0.18);
    --color-danger-soft:  rgba(225, 29, 72, 0.18);
    --color-info-soft:    rgba(2, 132, 199, 0.18);

    --tag-easy-soft:   rgba(16, 185, 129, 0.16);
    --tag-medium-soft: rgba(217, 119, 6, 0.18);
    --tag-hard-soft:   rgba(225, 29, 72, 0.18);

    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:     0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg:  0 12px 32px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --color-bg:            var(--slate-950);
  --color-surface:       var(--slate-900);
  --color-surface-2:     var(--slate-800);
  --color-surface-inset: #16233b;
  --color-border:        #243450;
  --color-border-strong: var(--slate-700);
  --color-ink:     var(--slate-50);
  --color-ink-2:   var(--slate-300);
  --color-muted:   var(--slate-400);
  --color-header:   #0b1222;
  --color-header-2: var(--slate-900);
  --color-accent:        var(--emerald-500);
  --color-accent-hover:  var(--emerald-600);
  --color-accent-soft:   rgba(16, 185, 129, 0.16);
  --color-success-soft: rgba(16, 185, 129, 0.16);
  --color-warning-soft: rgba(217, 119, 6, 0.18);
  --color-danger-soft:  rgba(225, 29, 72, 0.18);
  --color-info-soft:    rgba(2, 132, 199, 0.18);
  --tag-easy-soft:   rgba(16, 185, 129, 0.16);
  --tag-medium-soft: rgba(217, 119, 6, 0.18);
  --tag-hard-soft:   rgba(225, 29, 72, 0.18);
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:     0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg:  0 12px 32px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   GLOBAL NICETIES  (no visual "look" of its own — just honest defaults)
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv05' 1, 'ss01' 1; /* Inter: nicer 'l', single-story a */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Explicit Bangla runs (optional helper): <span lang="bn"> or class .bn */
:lang(bn), .bn {
  font-family: var(--font-bn);
  font-feature-settings: normal;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-accent-active);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Shared surface primitive — crisp card with a tone-step, not a float shadow */
.ds-surface {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* Difficulty / status chips (used by dashboard + tutorials) */
.ds-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-sm);
  line-height: 1.4;
  letter-spacing: 0;
}
.ds-tag--easy   { color: var(--tag-easy);   background: var(--tag-easy-soft); }
.ds-tag--medium { color: var(--tag-medium); background: var(--tag-medium-soft); }
.ds-tag--hard   { color: var(--tag-hard);   background: var(--tag-hard-soft); }

/* Touch ergonomics: kill the 300ms tap delay / double-tap zoom on controls */
button, .btn, a, input[type="range"], input[type="checkbox"], input[type="radio"],
select, [role="tab"], [role="button"] {
  touch-action: manipulation;
}

/* Honour reduced-motion everywhere (keeps content, drops travel) */
@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;
  }
}
