/* Anas Design System · v7.1 — Tokens + Primitives
 *
 * Mirror of packages/ui/src/tokens.ts. Single source of truth for the landing
 * site. v6.4.0 (2026-06-09): migrated off v2 t-shirt token names to the canonical
 * scales — spacing --sp-N, radii --rad-N, type --ft-NN, motion --t-N; committee
 * chat tokens own their role; +info; derived button states; dropped the banned
 * concierge chat token, the off-scale 30px radius, and the snug/label line-heights;
 * fixed the cookie-banner undefined-border bug.
 * v7.1 (2026-07-05): +--brand-ink — brand-colored text on brand tint/wash surfaces.
 */

/* ─────────────────────────── Fonts ─────────────────────────── */
/* Inter from Google (multi-weight). Arabic + Mono are self-hosted from /fonts. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
@import url('tokens.generated.css');

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('fonts/IBMPlexSansArabic-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('fonts/IBMPlexSansArabic-Medium.ttf') format('truetype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('fonts/IBMPlexSansArabic-SemiBold.ttf') format('truetype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('fonts/IBMPlexSansArabic-Bold.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-Medium.ttf') format('truetype');
  font-weight: 500; font-style: normal; font-display: swap;
}

/* ─────────────────────────── Tokens ─────────────────────────── */
:root {
  /* Cool-neutral ramp — pick by role, not by memory */
  --n-0:   #FFFFFF;
  --n-25:  #FAFBFC;
  --n-50:  #F7F8FA;
  --n-100: #F0F2F5;
  --n-200: #E6E9EE;
  --n-300: #D4D8DE;
  --n-400: #B0B5BD;
  --n-500: #8B919C;
  --n-600: #6B7280;
  --n-700: #394150;
  --n-800: #1A2233;   /* v5 · ramp completed */
  --n-900: #0B1220;

  /* Role aliases */
  --ink-1: var(--n-900);
  --ink-2: var(--n-700);
  --ink-3: var(--n-600);
  --ink-4: var(--n-500);
  --ink-inverse:        #FFFFFF;
  --ink-inverse-soft:   rgba(255,255,255,0.8);
  --ink-inverse-muted:  rgba(255,255,255,0.6);

  --bg-card:    var(--n-0);
  --bg-page:    var(--n-50);
  --bg-surface: var(--n-100);

  --line-hairline: var(--n-200);
  --line:          var(--n-300);
  --line-strong:   var(--n-400);

  /* Brand — 3 stops + ink + 2 tints */
  --brand-deep:    #0F4D80;
  --brand-ink:     var(--brand-deep);   /* v7.1 · brand-colored TEXT on tint/wash (IS deep; --brand is 4.24:1 on tint, AA fail) */
  --brand:         #1c75bc;
  --brand-soft:    #4EA0D4;
  --brand-tint:    #E6F1F9;
  --brand-wash:    #F5FAFD;
  --brand-wash-08: rgba(28,117,188,0.08);
  --brand-wash-12: rgba(28,117,188,0.12);

  /* Status — fg + bg pairs. Light fg's at WCAG AA (≥4.5:1 on tint) per DS v6.8.0.
     Landing is light-only; --success-hover/-pressed color-mix off --success-fg, so they track. */
  --success-fg: #15803D;   --success-bg: #DCFCE7;
  --warning-fg: #B45309;   --warning-bg: #FEF3C7;
  --warning-border: #FDE68A;  --warning-text: #92400E;  --warning-text-light: #B45309;
  --warning-ink: var(--warning-text);   /* v5 alias */
  --committee-fg: #92400E;   --committee-bg: var(--warning-bg);   /* v5 · own channel */
  --danger-fg:  #B91C1C;   --danger-bg:  #FEE2E2;
  --danger-border-soft: #DC262640;
  --info-fg:    #0369A1;   --info-bg:    #E0F2FE;   /* v6.4 · sky — info ≠ brand */

  /* Derived interactive states (v6.4 · was hardcoded hex on button :hover/:active) */
  --brand-hover:     color-mix(in oklab, var(--brand), #000 8%);
  --brand-pressed:   var(--brand-deep);
  --success-hover:   color-mix(in oklab, var(--success-fg), #000 8%);
  --success-pressed: color-mix(in oklab, var(--success-fg), #000 16%);

  /* Avatar palette — 8 hues, hash-indexed */
  --av-1: #1c75bc; --av-2: #16A34A; --av-3: #D97706; --av-4: #7C3AED;
  --av-5: #DC2626; --av-6: #0891B2; --av-7: #DB2777; --av-8: #4F46E5;

  /* Specialty palette — non-semantic icon hues */
  --specialty-purple: #7C3AED;
  --specialty-cyan:   #0891B2;
  --specialty-pink:   #DB2777;
  --specialty-indigo: #4F46E5;

  /* MIME palette — file attachment chip tints */
  --mime-pdf:      #EF4444;
  --mime-audio:    #8B5CF6;
  --mime-video:    #F59E0B;
  --mime-doc:      #3B82F6;
  --mime-sheet:    #10B981;
  --mime-fallback: #6B7280;

  /* Chat semantics */
  --chat-bubble-sent:     var(--brand);
  --chat-bubble-received: var(--bg-card);
  --chat-doctor:          var(--brand-tint);
  --chat-committee:       var(--committee-bg);
  --chat-committee-text:  var(--committee-fg);

  /* Overlay scale — opacity stops for distinct surfaces */
  --o-white:          rgba(255,255,255,0.15);
  --o-glass:          rgba(255,255,255,0.22);
  --o-glass-border:   rgba(255,255,255,0.35);
  --o-frosted:        rgba(255,255,255,0.96);
  --o-frosted-border: rgba(255,255,255,0.50);
  --o-white-muted:    rgba(255,255,255,0.40);
  --o-white-high:     rgba(255,255,255,0.85);
  --o-separator:      rgba(0,0,0,0.12);
  --o-tint-low:       rgba(0,0,0,0.04);
  --o-sheet:          rgba(0,0,0,0.30);
  --o-scrim:          rgba(0,0,0,0.50);
  --o-scrim-low:      rgba(0,0,0,0.20);
  --o-scrim-light:    rgba(0,0,0,0.35);
  --o-scrim-mid:      rgba(0,0,0,0.55);
  --o-blackout:       rgba(0,0,0,0.97);

  /* The grid unit every space and radius derives from. v8.2 · landing used to
     hardcode 4px/8px/12px… while admin already derived them from --u, so the
     "everything is N × 4" axiom was only true on one surface. Same computed
     values — this makes the derivation visible here too. */
  --u: 4px;

  /* Spacing — canonical sp-N scale (v6.4 · migrated off v2 t-shirt names) */
  --sp-0:   0;
  --sp-1:   calc(var(--u) * 1);    /*   4 */
  --sp-2:   calc(var(--u) * 2);    /*   8 */
  --sp-3:   calc(var(--u) * 3);    /*  12 */
  --sp-4:   calc(var(--u) * 4);    /*  16 */
  --sp-5:   calc(var(--u) * 5);    /*  20 */
  --sp-6:   calc(var(--u) * 6);    /*  24 */
  --sp-8:   calc(var(--u) * 8);    /*  32 */
  --sp-10:  calc(var(--u) * 10);   /*  40 */
  --sp-12:  calc(var(--u) * 12);   /*  48 */
  --sp-16:  calc(var(--u) * 16);   /*  64 */
  --sp-20:  calc(var(--u) * 20);   /*  80 */
  --sp-24:  calc(var(--u) * 24);   /*  96 · hero sections */
  --sp-30:  calc(var(--u) * 30);   /* 120 · marketing rhythm */

  /* Radii — canonical rad-N scale (v6.4 · migrated off v2 names; off-scale 30px radius dropped) */
  --rad-1:   calc(var(--u) * 1);   /*  4 */
  --rad-2:   calc(var(--u) * 2);   /*  8 */
  --rad-3:   calc(var(--u) * 3);   /* 12 */
  --rad-4:   calc(var(--u) * 4);   /* 16 */
  --rad-5:   calc(var(--u) * 5);   /* 20 */
  --rad-6:   calc(var(--u) * 6);   /* 24 */
  --rad-pill: 9999px;
  --rad-bubble-tail: 6px;   /* chat-bubble tail corners only */

  /* Shadows — two-layer ambient+key */
  --elev-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.03);
  --elev-2: 0 2px 4px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.05);
  --elev-3: 0 6px 12px rgba(15,23,42,.06), 0 12px 28px rgba(15,23,42,.08);
  --elev-4: 0 10px 18px rgba(15,23,42,.08), 0 24px 48px rgba(15,23,42,.14);

  --shadow-brand-glow:       0 1px 0 rgba(15,23,42,.08), 0 4px 12px rgba(28,117,188,.26), inset 0 1px 0 rgba(255,255,255,.18);
  --shadow-brand-glow-hover: 0 1px 0 rgba(15,23,42,.08), 0 6px 16px rgba(28,117,188,.32), inset 0 1px 0 rgba(255,255,255,.22);
  --shadow-success-button:   0 4px 12px rgba(22,163,74,.22);
  --shadow-nav:              0 -2px 6px rgba(15,23,42,.04);
  --shadow-input-area:       0 -4px 12px rgba(15,23,42,.04);
  --ring-focus:              0 0 0 2px var(--n-0), 0 0 0 4px var(--brand-soft);

  /* Type */
  --font-sans:   'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Type scale — canonical ft-NN (v6.4 · migrated off the old role-named sizes; +ft-24/34/48) */
  --ft-10: 10px;
  --ft-12: 12px;
  --ft-13: 13px;
  --ft-14: 14px;
  --ft-15: 15px;
  --ft-17: 17px;
  --ft-20: 20px;
  --ft-24: 24px;
  --ft-28: 28px;
  --ft-34: 34px;
  --ft-40: 40px;
  --ft-48: 48px;

  /* Line height — 4 canonical tiers (v6.4 · snug/label deleted) */
  --lh-tight:   1.05;
  --lh-heading: 1.25;
  --lh-body:    1.5;
  --lh-relaxed: 1.6;

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

  --ls-hero:       -1.2px;
  --ls-display:    -0.9px;
  --ls-title-lg:   -0.7px;
  --ls-title:      -0.5px;
  --ls-heading-lg: -0.4px;
  --ls-heading:    -0.3px;
  --ls-subhead:    -0.2px;    /* v6.4 · was stale 0 */
  --ls-label:   -0.1px;
  --ls-body:    0;          /* v5 · completes scale */
  --ls-meta:    0;          /* v5 · completes scale */
  --ls-eyebrow: 0.14em;
  --ls-mono:    -0.3px;

  /* Stacking — v5 */
  --z-base:      0;
  --z-sticky:    100;
  --z-dropdown:  1000;
  --z-overlay:   1100;
  --z-modal:     1200;
  --z-slideover: 1300;
  --z-sheet:     1400;
  --z-toast:     1500;
  --z-tooltip:   1600;
  --z-popover:   1700;
  --z-debug:     9999;

  /* Motion — canonical τ-scale (v6.4 · migrated off --dur-* names) */
  --t-1:  80ms;
  --t-2:  120ms;
  --t-3:  160ms;
  --t-4:  240ms;
  --t-5:  320ms;
  --t-6:  480ms;
  --ease-standard:   cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.3, 0, 0, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.4, 0, 1, 1);
}

/* ─────────────────────────── Base ─────────────────────────── */
html, body {
  font-family: var(--font-sans);
  color: var(--ink-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}
*, *::before, *::after { box-sizing: border-box; }
:focus-visible { outline: none; box-shadow: var(--ring-focus); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  html { scroll-behavior: auto !important; }
}

/* ─────────────────────────── Semantic type roles ─────────────────────────── */
.t-hero       { font-size: var(--ft-48); font-weight: var(--fw-black); line-height: var(--lh-tight); letter-spacing: var(--ls-hero); color: var(--ink-1); }
.t-display { font-size: var(--ft-40); font-weight: var(--fw-black); line-height: var(--lh-tight); letter-spacing: var(--ls-display); color: var(--ink-1); }
.t-title-lg   { font-size: var(--ft-34); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--ls-title-lg); color: var(--ink-1); }
.t-heading-lg { font-size: var(--ft-24); font-weight: var(--fw-bold); line-height: var(--lh-heading); letter-spacing: var(--ls-heading-lg); color: var(--ink-1); }
.t-title   { font-size: var(--ft-28);   font-weight: var(--fw-bold);  line-height: var(--lh-tight);   letter-spacing: var(--ls-title);   color: var(--ink-1); }
.t-heading { font-size: var(--ft-20); font-weight: var(--fw-bold);  line-height: var(--lh-heading);letter-spacing: var(--ls-heading); color: var(--ink-1); }
.t-subhead { font-size: var(--ft-17); font-weight: var(--fw-semibold); line-height: var(--lh-heading); letter-spacing: var(--ls-subhead); color: var(--ink-1); }
.t-label   { font-size: var(--ft-15);   font-weight: var(--fw-medium); line-height: var(--lh-heading); letter-spacing: var(--ls-label); color: var(--ink-1); }
.t-body    { font-size: var(--ft-14);    font-weight: var(--fw-regular); line-height: var(--lh-body); color: var(--ink-1); }
.t-meta    { font-size: var(--ft-13);    font-weight: var(--fw-regular); line-height: var(--lh-body); color: var(--ink-3); }
.t-micro   { font-size: var(--ft-12);   font-weight: var(--fw-medium);  color: var(--ink-3); }
.t-eyebrow { font-size: var(--ft-10); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--ls-eyebrow); color: var(--ink-3); }

.t-mono     { font-family: var(--font-mono); font-size: var(--ft-12); font-weight: var(--fw-medium); letter-spacing: var(--ls-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.t-currency { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

[lang="ar"], [lang="ku"] { font-family: var(--font-arabic); }
.t-rtl { font-family: var(--font-arabic); direction: rtl; }

/* ─────────────────────────── HTML element defaults ─────────────────────────── */
h1 { font-size: var(--ft-28);   font-weight: var(--fw-bold); line-height: var(--lh-tight);   margin: 0 0 var(--sp-4); letter-spacing: var(--ls-title); }
h2 { font-size: var(--ft-20); font-weight: var(--fw-bold); line-height: var(--lh-heading); margin: var(--sp-6) 0 var(--sp-3); letter-spacing: var(--ls-heading); }
h3 { font-size: var(--ft-17); font-weight: var(--fw-semibold); margin: var(--sp-5) 0 var(--sp-2); }
h4 { font-size: var(--ft-15);   font-weight: var(--fw-semibold); margin: var(--sp-4) 0 var(--sp-2); }
p  { font-size: var(--ft-14);    line-height: var(--lh-body); margin: 0 0 var(--sp-3); }

/* ─────────────────────────── Component primitives ─────────────────────────── */

.ds-card {
  background: var(--bg-card);
  border-radius: var(--rad-4);
  padding: var(--sp-4);
  box-shadow: var(--elev-1);
  border: 1px solid var(--line-hairline);
}

.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 13px 22px;
  border-radius: var(--rad-3);
  border: 0;
  font: var(--fw-semibold) var(--ft-15)/1.2 var(--font-sans);
  letter-spacing: var(--ls-label);
  cursor: pointer;
  transition: background var(--t-3) var(--ease-standard),
              box-shadow var(--t-3) var(--ease-standard),
              transform var(--t-1) var(--ease-standard);
  min-height: 44px;
}
.ds-btn-primary { background: var(--brand); color: var(--ink-inverse); box-shadow: var(--shadow-brand-glow); }
.ds-btn-primary:hover  { background: var(--brand-hover); box-shadow: var(--shadow-brand-glow-hover); }
.ds-btn-primary:active { background: var(--brand-pressed); transform: translateY(0.5px); }

.ds-btn-success { background: var(--success-fg); color: var(--ink-inverse); box-shadow: var(--shadow-success-button); }
.ds-btn-success:hover  { background: var(--success-hover); }
.ds-btn-success:active { background: var(--success-pressed); transform: translateY(0.5px); }

.ds-btn-secondary {
  background: var(--bg-card);
  color: var(--ink-1);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--elev-1);
}
.ds-btn-secondary:hover  { background: var(--bg-page); border-color: var(--line); }
.ds-btn-secondary:active { background: var(--bg-surface); transform: translateY(0.5px); }

.ds-btn-ghost { background: transparent; color: var(--brand); padding: 12px 14px; box-shadow: none; }
.ds-btn-ghost:hover { background: var(--brand-wash); }

.ds-btn-danger { background: var(--bg-card); color: var(--danger-fg); border: 1px solid var(--danger-bg); }
.ds-btn-danger:hover { background: var(--danger-bg); }

/* Input */
.ds-input {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--rad-3);
  padding: 12px 14px;
  font: var(--fw-regular) var(--ft-15)/1.2 var(--font-sans);
  color: var(--ink-1);
  width: 100%;
  outline: none;
  min-height: 44px;
  transition: border-color var(--t-3) var(--ease-standard),
              box-shadow var(--t-3) var(--ease-standard);
}
.ds-input::placeholder { color: var(--ink-4); }
.ds-input:hover { border-color: var(--line-strong); }
.ds-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

/* Badge — pill + status dot */
.ds-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--rad-pill);
  font-size: var(--ft-12);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
}
.ds-badge::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.ds-badge--brand   { background: var(--brand-tint); color: var(--brand-ink); }   /* v7.1 · ink on tint (AA) */
.ds-badge--open    { background: var(--warning-bg); color: var(--warning-fg); }
.ds-badge--done    { background: var(--success-bg); color: var(--success-fg); }
.ds-badge--danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.ds-badge--neutral { background: var(--n-100);      color: var(--ink-3); }

.ds-metapill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: var(--rad-pill);
  background: var(--bg-surface);
  color: var(--ink-2);
  font-size: var(--ft-12);
  font-weight: var(--fw-medium);
}

.ds-unread {
  background: var(--danger-fg);
  color: var(--ink-inverse);
  border-radius: var(--rad-pill);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--bg-card);
  box-sizing: content-box;
}

/* Presence dot — exact spec from branding.md */
.ds-presence {
  width: 12px; height: 12px;
  border-radius: var(--rad-pill);
  background: var(--success-fg);
  border: 2px solid var(--bg-page);
  display: inline-block;
}

/* Reference chip */
.ds-ref {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  background: var(--bg-surface);
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: var(--rad-1);
}

/* ─────────────────────────── Frosted surfaces (mobile) ─────────────────────────── */
.ds-frosted {
  background: var(--o-frosted);
  border: 1px solid var(--o-frosted-border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Tab bar (mobile) — exact spec from branding.md */
.ds-tabbar {
  height: 88px;
  padding: var(--sp-2) 0 32px;
  background: rgba(255,255,255,0.92);
  border-top-left-radius: var(--rad-6);
  border-top-right-radius: var(--rad-6);
  box-shadow: var(--shadow-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ─────────────────────────── Cookie notice ─────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 1.25rem));
  inset-inline-end: 1.25rem;
  width: min(340px, calc(100vw - 2.5rem));
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--rad-6);
  box-shadow: var(--elev-3);
  padding: var(--sp-4) var(--sp-5);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: opacity 0.3s ease;
}
.cookie-banner[hidden] { display: none !important; }
.cookie-banner p { margin: 0; font-size: var(--ft-13); color: var(--ink-2); line-height: 1.55; }
.cb-actions { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.cb-btn-primary {
  background: var(--brand); color: #fff; border: none; border-radius: var(--rad-2);
  padding: 6px 16px; font-size: var(--ft-13); font-weight: var(--fw-semibold);
  cursor: pointer; line-height: 1.5; font-family: inherit;
}
.cb-btn-primary:hover { opacity: 0.88; }
.cb-btn-text {
  font-size: var(--ft-13); color: var(--ink-3); text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer; background: none; border: none;
  font-family: inherit; padding: 0;
}
[data-lang="en"] .cb-ar { display: none; }
[data-lang="ar"] .cb-en { display: none; }
@media (max-width: 480px) {
  .cookie-banner {
    inset-inline-end: 0; inset-inline-start: 0; width: 100%; border-radius: 0; bottom: 0;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
  }
}
