/* ==========================================================================
   ABRAK DIGITAL — Design System
   Emerald brand · Dark-first · Tri-lingual (fa/ar RTL, en LTR)
   ========================================================================== */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&family=Instrument+Sans:wght@400;500;600;700&display=swap');

/* ==========================================================================
   TOKENS
   ========================================================================== */
:root {
  /* Brand — Abrak "Aurora" cyan scale (from abrak-hub theme: --abrak-aurora #6ee7ff) */
  --brand-50:  #ecfeff;
  --brand-100: #cff7fe;
  --brand-200: #a4eefd;
  --brand-300: #6ee7ff;   /* the aurora accent token */
  --brand-400: #22d3ee;
  --brand-500: #06b6d4;   /* primary (light theme) */
  --brand-600: #0891b2;
  --brand-700: #0e7490;
  --brand-800: #155e75;
  --brand-900: #164e63;

  --brand: var(--brand-600);
  --brand-strong: var(--brand-700);
  --on-brand: #ffffff;

  /* Aurora secondary accents (used sparingly) */
  --pulse: #8b5cf6;   /* violet */
  --ember: #f4b26b;   /* amber */

  /* Semantic */
  --info:    #6ee7ff;
  --warning: #f4b26b;
  --danger:  #f87171;
  --success: #34d399;

  /* Radius (tweakable) — Abrak brand is generously rounded (1.25rem base) */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --s-9: 96px; --s-10: 128px;

  /* Density multiplier (tweakable) */
  --density: 1;

  /* Typography — Vazirmatn (fa/ar) + Instrument Sans (latin), per abrak-hub */
  --font-sans: 'Vazirmatn', 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: var(--font-sans);
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', monospace;

  --fs-xs: 12px; --fs-sm: 14px; --fs-base: 16px; --fs-md: 18px;
  --fs-lg: 22px; --fs-xl: 28px; --fs-2xl: 36px; --fs-3xl: 48px;
  --fs-4xl: 62px; --fs-5xl: 80px;

  --lh-tight: 1.12;
  --lh-snug: 1.3;
  --lh-normal: 1.65;

  /* Layout */
  --maxw: 1200px;
  --maxw-narrow: 760px;
  --header-h: 68px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

/* ---------- LIGHT THEME (warm cream, per abrak --abrak-bg #f7f5f0) ---------- */
:root,
[data-theme="light"] {
  --bg: #f7f5f0;
  --bg-subtle: #f1eee6;
  --bg-inset: #ebe7dd;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --surface-hover: #f3f0e8;
  --border: rgba(30,41,59,.14);
  --border-strong: rgba(30,41,59,.24);
  --text: #0b1220;
  --text-secondary: #3a4358;
  --text-muted: #45506a;
  --text-faint: #8b94a8;
  --shadow-sm: 0 1px 2px rgba(2,6,23,.06), 0 1px 3px rgba(2,6,23,.05);
  --shadow-md: 0 8px 24px rgba(2,6,23,.08), 0 2px 6px rgba(2,6,23,.05);
  --shadow-lg: 0 18px 60px rgba(2,6,23,.12), 0 8px 18px rgba(2,6,23,.07);
  --ring: color-mix(in oklab, var(--brand) 32%, transparent);
  --brand-tint: color-mix(in oklab, var(--brand) 10%, var(--bg));
  --code-bg: #0b0d14;
  --code-text: #cff7fe;
  color-scheme: light;
}

/* ---------- DARK THEME (near-black, per abrak --abrak-bg #07080d) ---------- */
[data-theme="dark"] {
  --bg: #07080d;
  --bg-subtle: #0b0d14;
  --bg-inset: #0e1018;
  --surface: #0f1119;
  --surface-2: #141722;
  --surface-hover: #1a1e2b;
  --border: rgba(148,163,184,.16);
  --border-strong: rgba(148,163,184,.28);
  --text: #f4f6fb;
  --text-secondary: #c3ccdf;
  --text-muted: #9aa6c0;
  --text-faint: #6b7794;
  --brand: var(--brand-300);
  --brand-strong: var(--brand-200);
  --on-brand: #04121a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow-md: 0 8px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 90px rgba(0,0,0,.55), 0 8px 18px rgba(0,0,0,.45);
  --ring: color-mix(in oklab, var(--brand) 42%, transparent);
  --brand-tint: color-mix(in oklab, var(--brand) 14%, var(--bg));
  --code-bg: #04050a;
  --code-text: #cff7fe;
  color-scheme: dark;
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}
[dir="rtl"] body { letter-spacing: 0; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: color-mix(in oklab, var(--brand) 30%, transparent); }

h1,h2,h3,h4 { line-height: var(--lh-tight); font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
p { text-wrap: pretty; }

/* ==========================================================================
   LAYOUT HELPERS
   ========================================================================== */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(20px, 5vw, 40px); }
.container.narrow { max-width: var(--maxw-narrow); }
.section { padding-block: clamp(56px, 9vw, 112px); }
.section.tight { padding-block: clamp(40px, 6vw, 72px); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em;
  color: var(--brand); text-transform: uppercase;
}
[dir="rtl"] .eyebrow { letter-spacing: 0; }
.lead { font-size: var(--fs-md); color: var(--text-secondary); line-height: var(--lh-normal); }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.grid { display: grid; gap: var(--s-5); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  --btn-pad-y: calc(11px * var(--density));
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--btn-pad-y) calc(20px * var(--density));
  font-size: var(--fs-sm); font-weight: 700; line-height: 1.2;
  border-radius: var(--r-md); border: 1px solid transparent;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), color var(--transition);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-strong); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-lg { padding: calc(15px * var(--density)) calc(28px * var(--density)); font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-sm { padding: calc(7px * var(--density)) calc(14px * var(--density)); font-size: var(--fs-xs); }
.btn-block { display: flex; width: 100%; }

/* ==========================================================================
   BADGES / PILLS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.4;
  background: var(--brand-tint); color: var(--brand);
  border: 1px solid color-mix(in oklab, var(--brand) 22%, transparent);
}
.badge.neutral { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge.warning { background: color-mix(in oklab, var(--warning) 14%, var(--bg)); color: var(--warning); border-color: color-mix(in oklab, var(--warning) 30%, transparent); }
.badge.info { background: color-mix(in oklab, var(--info) 14%, var(--bg)); color: var(--info); border-color: color-mix(in oklab, var(--info) 30%, transparent); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: calc(var(--s-5) * var(--density));
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card.interactive:hover { transform: translateY(-3px); border-color: color-mix(in oklab, var(--brand) 40%, var(--border)); box-shadow: var(--shadow-lg); }
.card-icon {
  width: 46px; height: 46px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: var(--s-4);
  background: var(--brand-tint); color: var(--brand);
}
.card-icon svg { width: 24px; height: 24px; }
.card h3 { font-size: var(--fs-lg); margin-bottom: var(--s-2); }
.card p { color: var(--text-muted); font-size: var(--fs-sm); }

/* ==========================================================================
   FORMS
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); }
.req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  padding: calc(11px * var(--density)) 14px;
  font-size: var(--fs-sm); line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}
.textarea { resize: vertical; min-height: 96px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23859690' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 38px;
}
[dir="ltr"] .select { background-position: right 14px center; padding-left: 14px; padding-right: 38px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-inline-start: 42px; }
.input-group .icon { position: absolute; inset-inline-start: 14px; color: var(--text-faint); pointer-events: none; }
.input-group .icon svg { width: 18px; height: 18px; }

/* Checkbox & radio */
.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--fs-sm); }
.check input { accent-color: var(--brand); width: 18px; height: 18px; }

/* Choice cards (radio/check styled as cards) */
.choice {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: 14px 16px; border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md); cursor: pointer; background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
}
.choice:hover { border-color: var(--text-faint); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.choice input { accent-color: var(--brand); margin-top: 3px; width: 18px; height: 18px; }
.choice .choice-title { font-weight: 600; font-size: var(--fs-sm); }
.choice .choice-desc { font-size: var(--fs-xs); color: var(--text-muted); }

/* ==========================================================================
   CODE
   ========================================================================== */
code.inline {
  font-family: var(--font-mono); font-size: .9em;
  background: var(--bg-inset); padding: 2px 7px; border-radius: var(--r-xs);
  border: 1px solid var(--border);
}
.codeblock {
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--r-md); padding: var(--s-4) var(--s-5);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.7;
  overflow-x: auto; direction: ltr; text-align: left;
}

/* ==========================================================================
   DIVIDER / MISC
   ========================================================================== */
.divider { height: 1px; background: var(--border); border: 0; }
.kbd {
  font-family: var(--font-mono); font-size: 12px; padding: 2px 7px;
  border-radius: var(--r-xs); border: 1px solid var(--border-strong);
  background: var(--surface-2); box-shadow: 0 1.5px 0 var(--border-strong);
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.hide-mobile { }
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}
.only-mobile { display: none !important; }
@media (max-width: 768px) {
  .only-mobile { display: revert !important; }
}
[hidden] { display: none !important; }

/* Reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
/* settled: applied shortly after reveal so content can never stay hidden even if
   the document timeline is frozen (e.g. background tab / preview) */
.reveal.shown { opacity: 1 !important; transform: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
