/* Costat — design tokens (VibeFarsi rules: RTL, Vazirmatn, Persian digits, token colors only)
   Theme: medical crimson — a deep clinical red, rose-tinted neutrals, one teal accent
   for the callout, one emerald accent for the golden key point. No emoji anywhere;
   icons are inline SVG (Lucide-style strokes). */
:root {
  --background: #fdf7f7;
  --surface: #ffffff;
  --surface-soft: #fdecef;
  --foreground: #221114;
  --muted: #7c5b62;
  --border: #efd9dd;
  --border-strong: #e3c3c9;
  --primary: #c2102e;
  --primary-deep: #8f0b20;
  --primary-soft: #fdecef;
  --primary-foreground: #ffffff;
  --teal: #0f766e;
  --teal-soft: #eefaf8;
  --emerald: #047857;
  --emerald-soft: #ecfdf5;
  --amber: #b45309;
  --radius: 0.625rem;
  --radius-card: calc(var(--radius) + 8px);
  --radius-control: calc(var(--radius) - 2px);
  --motion: 200ms;
  --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.7) inset, 0 10px 30px -18px rgba(143, 11, 32, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

.container { max-width: 1180px; margin-inline: auto; padding-inline: 20px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(253, 247, 247, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 64px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px -6px rgba(194, 16, 46, 0.55);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-size: 20px; font-weight: 800; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 8px 12px; border-radius: var(--radius-control);
  transition: color var(--motion), background var(--motion);
}
.site-nav a:hover { color: var(--primary); background: var(--primary-soft); }
@media (max-width: 640px) { .site-nav a:not(:last-child) { display: none; } }

/* ---------- buttons (VibeFarsi button: variants, press scale) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 700; line-height: 1;
  padding: 0 18px; height: 44px; border-radius: var(--radius-control);
  border: 1px solid transparent; transition: transform var(--motion), filter var(--motion), background var(--motion);
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); color: var(--primary-foreground); box-shadow: 0 8px 20px -8px rgba(194, 16, 46, 0.6); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: var(--surface); color: var(--foreground); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- hero (VibeFarsi hero: grid bg + radial mask, headline 48-60px) ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 72px 0 56px;
  background-image: radial-gradient(rgba(194, 16, 46, 0.10) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 90% 90% at 50% 0%, #000 55%, transparent 100%);
  mask-image: radial-gradient(ellipse 90% 90% at 50% 0%, #000 55%, transparent 100%);
}
.hero-inner { max-width: 760px; margin-inline: auto; text-align: center; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 20px;
}
.hero-eyebrow svg { width: 15px; height: 15px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); font-weight: 800; line-height: 1.25; margin-bottom: 16px; }
.hero h1 .accent { color: var(--primary); }
.hero p.lead { font-size: 17px; color: var(--muted); max-width: 60ch; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 36px; }
.hero-stats {
  display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.stat-chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 12px 20px; min-width: 130px; box-shadow: var(--shadow-card);
}
.stat-chip b { display: block; font-size: 24px; font-weight: 800; color: var(--primary); line-height: 1.3; }
.stat-chip span { font-size: 12.5px; color: var(--muted); }

/* ---------- search ---------- */
.search-wrap { max-width: 640px; margin: -8px auto 0; position: relative; }
.search-wrap svg { position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.search-input {
  width: 100%; height: 52px; font-size: 16px;
  padding-inline: 48px 16px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--foreground);
  box-shadow: var(--shadow-card);
}
.search-input::placeholder { color: var(--muted); }

/* ---------- sections ---------- */
.section { padding: 48px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.section-head h2 { font-size: 24px; font-weight: 800; }
.section-head p { color: var(--muted); font-size: 14px; max-width: 62ch; }
.section-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ---------- category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .cat-grid { grid-template-columns: 1fr; } }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  overflow: hidden; box-shadow: var(--shadow-card); text-align: start;
  transition: transform var(--motion), border-color var(--motion), box-shadow var(--motion);
  display: flex; flex-direction: column;
}
.cat-card:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--primary); }
.cat-card:disabled { cursor: default; opacity: 0.92; }
.cat-art {
  height: 168px; display: grid; place-items: center; padding: 18px;
  background: linear-gradient(180deg, var(--primary-soft), #fff);
  border-bottom: 1px solid var(--border);
}
.cat-art img { max-height: 132px; width: auto; object-fit: contain; }
.cat-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cat-body h3 { font-size: 17px; font-weight: 800; }
.cat-body p { font-size: 13px; color: var(--muted); line-height: 1.7; flex: 1; }
.cat-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.count-badge {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--border);
}
.count-badge.empty { background: #f6f1f1; color: var(--muted); }
.cat-link { font-size: 13px; font-weight: 700; color: var(--primary); display: inline-flex; align-items: center; gap: 4px; }
.cat-link svg { width: 15px; height: 15px; }

/* ---------- question list ---------- */
.q-list { display: flex; flex-direction: column; gap: 14px; }
.q-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 20px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color var(--motion);
}
.q-card:hover { border-color: var(--primary); }
.q-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--border);
}
.badge.teal { background: var(--teal-soft); color: var(--teal); border-color: #c8e6e2; }
.badge.ghost { background: transparent; color: var(--muted); }
.q-card h3 { font-size: 19px; font-weight: 800; }
.q-card .key { font-size: 14px; color: var(--foreground); background: var(--emerald-soft); border: 1px solid #bfe8d4; border-radius: 10px; padding: 10px 12px; line-height: 1.8; }
.q-card .key b { color: var(--emerald); }
.q-card .exp { font-size: 13.5px; color: var(--muted); line-height: 1.85; }
.q-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.empty-state {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-card);
  padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px;
  background: var(--surface);
}

/* ---------- how it works ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr; } }
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 20px; box-shadow: var(--shadow-card);
}
.step-num {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; margin-bottom: 12px;
}
.step h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.step p { font-size: 13.5px; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); padding: 32px 0 40px; color: var(--muted); font-size: 13px; }
.site-footer .container { display: flex; flex-direction: column; gap: 10px; }
.site-footer h4 { color: var(--foreground); font-size: 14px; }
.site-footer a { color: var(--primary); font-weight: 600; }

/* ---------- question page (mindmap studio) ---------- */
.page-bar { padding: 20px 0 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--primary); }
.back-link svg { width: 16px; height: 16px; }
.q-title { font-size: clamp(24px, 4vw, 32px); font-weight: 800; line-height: 1.35; margin: 10px 0 4px; }
.q-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.app-shell {
  max-width: 1500px; margin: 0 auto; padding: 0 20px 40px;
  display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start;
}
@media (max-width: 1100px) { .app-shell { grid-template-columns: 1fr; } }
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.bento-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 18px; box-shadow: var(--shadow-card);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.key-point-box {
  background: linear-gradient(135deg, rgba(4, 120, 87, 0.10), rgba(4, 120, 87, 0.03));
  border: 1px solid rgba(4, 120, 87, 0.30);
  border-radius: 12px; padding: 12px; margin-bottom: 12px; font-size: 13px; line-height: 1.8;
}
.key-point-box strong { color: var(--emerald); display: block; margin-bottom: 4px; }
.explanation-box { font-size: 13px; line-height: 1.85; color: var(--muted); text-align: justify; }
.json-input {
  width: 100%; height: 180px; background: var(--background); color: var(--foreground);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  font-family: ui-monospace, monospace; font-size: 12px; direction: ltr; resize: vertical; margin-bottom: 10px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-success { background: linear-gradient(135deg, #059669, #10b981); color: #fff; border: none; }
.btn-quiz { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; border: none; }

.canvas-container {
  background-color: #fcfdfe;
  background-image: radial-gradient(rgba(15, 23, 42, 0.06) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  border: 1px solid var(--border); border-radius: var(--radius-card);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-card);
}
.canvas-topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.canvas-topbar strong { font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.canvas-topbar strong svg { width: 18px; height: 18px; color: var(--primary); }
.svg-viewport { width: 100%; overflow: auto; display: flex; justify-content: center; align-items: center; min-height: 680px; padding: 20px; }
.svg-viewport svg { display: block; max-width: 100%; height: auto; }
.mm-node { cursor: pointer; transition: opacity 0.2s, filter 0.2s; }
.mm-node:hover { filter: brightness(1.08); }
.mm-node.blurred text { filter: blur(5px); user-select: none; transition: filter 0.25s ease; }
.mm-node.blurred:hover text { filter: blur(3px); }

/* dark canvas theme (question page toggle) */
body.dark-canvas { --background: #0b0f19; --surface: #111827; --foreground: #f8fafc; --muted: #94a3b8; --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.14); --surface-soft: #1a2333; --primary-soft: rgba(194, 16, 46, 0.22); }
body.dark-canvas .canvas-container { background-color: #0f172a; background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1.5px, transparent 1.5px); }
body.dark-canvas .key-point-box { background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.05)); }
body.dark-canvas .site-header { background: rgba(11, 15, 25, 0.9); }
body.dark-canvas .explanation-box { color: var(--muted); }
