/*
 * Shared structure for all themes. Themes set the tokens below in
 * public/themes/<theme>/theme.css and may add their own flourishes.
 * Only logical properties, so Persian (RTL) works in every theme.
 */
:root {
  --bg: #EEF2F1;
  --surface: #FBFCFC;
  --ink: #13203B;
  --muted: #51607A;
  --line: #CFD8DA;
  --accent: #17827F;
  --accent-ink: #FFFFFF;
  --accent-2: #D99A1B;
  --highlight: #9B2439;
  --verse: #1E3A78;
  --header-bg: color-mix(in srgb, var(--bg) 90%, transparent);
  --radius: 16px;
  --shadow: 0 1px 2px rgba(19, 32, 59, .06), 0 8px 24px rgba(19, 32, 59, .08);
  --font-body: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-display-fa: "Vazirmatn", sans-serif;
  --font-verse: "Noto Nastaliq Urdu", "Vazirmatn", serif;
  /* Clear lining digits for anything people read as numbers, in every theme. */
  --font-num: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--font-body);
  padding-inline: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.15; text-wrap: balance; margin: 0; }
:lang(fa) h1, :lang(fa) h2, :lang(fa) h3 { font-family: var(--font-display-fa); }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1120px; margin-inline: auto; width: 100%; }
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 20; }
.decor { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* Header (shared, rule 9) */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  margin-inline: -16px; padding-inline: 16px;
  background: var(--header-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 20px; padding-block: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 22px/1 var(--font-body); letter-spacing: .01em; direction: ltr; }
.logo svg { width: 30px; height: 30px; }
.logo b { color: var(--accent); }
.logo-a { fill: var(--accent); } .logo-b { fill: var(--accent-2); opacity: .85; } .logo-c { fill: var(--surface); }
.main-nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 15px; }
.main-nav a { color: var(--ink); text-decoration: none; opacity: .8; }
.main-nav a:hover, .main-nav a[aria-current] { opacity: 1; color: var(--accent); }
.langs { margin-inline-start: auto; display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.langs a { font: 500 13px/1 var(--font-body); color: var(--muted); text-decoration: none; padding: 8px 11px; }
.langs a[aria-current] { background: var(--ink); color: var(--bg); }

/* Page */
.page { flex: 1; padding-block: 40px 56px; display: grid; gap: 48px; align-content: start; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--highlight); }
:lang(fa) .eyebrow { letter-spacing: 0; }
.lead { font-size: 18px; color: var(--muted); max-width: 60ch; }
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(36px, 5.2vw, 62px); margin-block: 12px 18px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.page-title h1 { font-size: clamp(32px, 4.4vw, 52px); margin-block: 8px 12px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-head h2 { font-size: clamp(26px, 3.2vw, 36px); }
.ctas { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.btn {
  font: 600 15px/1 var(--font-body); border-radius: 999px; padding: 13px 20px;
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--bg);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn.accent { background: var(--accent-2); border-color: var(--accent-2); color: #1B1405; }
.btn.ghost { background: transparent; color: var(--ink); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.tag.soon { background: color-mix(in srgb, var(--accent-2) 22%, transparent); color: color-mix(in srgb, var(--accent-2) 60%, var(--ink)); }
.note { font-size: 13px; color: var(--muted); }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: grid; gap: 8px; align-content: start; color: var(--ink); text-decoration: none;
}
a.card:hover { border-color: var(--accent); }
.card h3 { font-size: 21px; }
.card p { color: var(--muted); font-size: 15px; }
.card.is-soon { opacity: .7; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* Fal card */
.fal { display: grid; gap: 16px; }
.fal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fal-head h2 { font-size: 26px; }
.fal-no { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.verse { font-family: var(--font-verse); direction: rtl; text-align: center; font-size: clamp(19px, 2.3vw, 24px); line-height: 2.3; color: var(--verse); padding-block: 6px; border-block: 1px solid var(--line); }
.verse p { margin: 0; }
.verse .beyt { margin: 0; }
.verse .beyt + .beyt { margin-top: .4em; }
.verse .beyt span { display: block; }
/* Classic layout: second hemistich indented, so each beyt reads as a pair. */
.verse .beyt span:first-child { padding-inline-end: 12%; }
.verse .beyt span:last-child { padding-inline-start: 12%; }
.interp-label { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
:lang(fa) .interp-label { letter-spacing: 0; }
.fal-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fal.is-revealing .verse, .fal.is-revealing .interp { animation: rise .6s ease both; }
@keyframes rise { from { opacity: .15; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Lists and tables */
.ghazal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; padding: 0; list-style: none; margin: 0; }
.ghazal-list a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; }
.ghazal-list small { color: var(--muted); font-variant-numeric: tabular-nums; }
.ghazal-list span[lang="fa"] { font-size: 17px; }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 13px; color: var(--muted); font-weight: 700; }
table.data tr.is-off td:first-child { color: var(--highlight); font-weight: 700; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea, .field output {
  font: 16px/1.5 var(--font-body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.field textarea { min-height: 120px; resize: vertical; }
.field output[lang="fa"], .fa-out { direction: rtl; text-align: right; font-size: 21px; line-height: 1.8; min-height: 120px; display: block; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; align-items: end; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Calendar */
.today { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.today-day { font-family: var(--font-display); font-size: 96px; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.today-main { font-size: 26px; font-weight: 700; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month .wd { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding-block: 4px; }
.month .d { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; align-content: space-between; background: var(--surface); font-variant-numeric: tabular-nums; min-width: 0; }
.month .d b { font-size: 18px; }
.month .d small { font-size: 11px; color: var(--muted); }
.month .d.is-today { outline: 2px solid var(--accent); }
.month .d.is-off b { color: var(--highlight); }
.month .d.is-empty { border: 0; background: none; }

/* Countdown */
.countdown { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.countdown strong { font-family: var(--font-display); font-size: 72px; line-height: 1; color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* Prose */
/* Yalda illustration (module yalda); colours come from theme tokens with fallbacks. */
.yalda-art { width: min(340px, 80vw); margin-inline: auto; margin-block-end: 8px; }
.yalda-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.ya-flame { transform-origin: 46px 44px; animation: ya-flicker 2.4s ease-in-out infinite; }
@keyframes ya-flicker { 0%, 100% { transform: scale(1, 1); } 40% { transform: scale(.94, 1.06); } 70% { transform: scale(1.04, .95); } }
@media (prefers-reduced-motion: reduce) { .ya-flame { animation: none; } }
.prose { display: grid; gap: 14px; max-width: 68ch; }
.prose h2 { font-size: 28px; margin-top: 12px; }
.prose ul { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-inline: -16px; padding-inline: 16px; }
.footer-bar { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 22px 32px; font-size: 14px; color: var(--muted); }
.footer-bar nav { display: flex; gap: 16px; }
.footer-bar a { color: var(--muted); }

@media (max-width: 900px) {
  .hero, .two-col { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 600px) {
  .main-nav { order: 3; width: 100%; gap: 14px; overflow-x: auto; white-space: nowrap; }
  .langs { margin-inline-start: auto; }
  .today { grid-template-columns: 1fr; }
  .today-day { font-size: 72px; }
  .month { gap: 3px; } .month .d { padding: 3px; border-radius: 6px; } .month .d small { display: none; }
  .verse .beyt span { padding-inline: 0 !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Calculator (module hesab) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.calc-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 24px; align-items: start; margin-block: 24px; }
.calc { display: grid; gap: 12px; }
.calc-expr { font: 500 26px/1.3 var(--font-body); padding: 14px 16px; border: 1px solid var(--line); border-radius: calc(var(--radius) / 2); background: var(--bg); color: var(--ink); width: 100%; text-align: end; }
.calc-result { display: block; min-height: 1.4em; font: 700 clamp(30px, 6vw, 44px)/1.2 var(--font-body); text-align: end; color: var(--accent); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.calc-result.is-error { color: var(--highlight); font-size: 18px; font-weight: 500; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad[hidden] { display: none; }
.key { font: 600 22px/1 var(--font-body); padding: 16px 0; border-radius: calc(var(--radius) / 2); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.key:hover { border-color: var(--accent); }
.key:active { transform: translateY(1px); }
.key.op { color: var(--accent); }
.key.fn { color: var(--highlight); }
.key.eq { grid-column: span 2; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.calc-history { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; text-align: end; }
.calc-history button { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 2px 0; }
.calc-side { display: grid; gap: 16px; }
.mini { display: grid; gap: 10px; }
.mini h2 { font-size: 22px; }
.mini-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-out { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.mini-out span { color: var(--muted); font-size: 14px; }
.mini-out output { font-weight: 700; font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
@media (max-width: 820px) { .calc-layout { grid-template-columns: 1fr; } }

/* Exchange rates (module arz) */
.arz-conv { display: grid; grid-template-columns: 1fr 1.4fr auto 1.4fr; gap: 16px; align-items: end; margin-block: 24px; }
.arz-swap { padding-inline: 14px; font-size: 20px; }
.arz-result { grid-column: 1 / -1; font: 700 clamp(28px, 5vw, 40px)/1.2 var(--font-body); color: var(--accent); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.arz-table-wrap { overflow-x: auto; margin-block-end: 24px; }
.arz-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.arz-table caption { text-align: start; font: 400 24px/1.2 var(--font-display); padding-block-end: 12px; }
:lang(fa) .arz-table caption { font-family: var(--font-display-fa); }
.arz-table th, .arz-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: start; }
.arz-table td { text-align: end; white-space: nowrap; }
.arz-table thead th { font-size: 13px; color: var(--muted); }
.arz-table thead th:not(:first-child) { text-align: end; }
.arz-table tbody th { font-weight: 400; }
.arz-table .code { display: inline-block; min-width: 3.2em; font-weight: 700; color: var(--accent); direction: ltr; }
@media (max-width: 820px) { .arz-conv { grid-template-columns: 1fr; } .arz-swap { justify-self: center; } }

/* Free-market headline on /arz */
.arz-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-block: 24px 8px; }
.arz-big { display: grid; gap: 4px; }
.arz-big-toman { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; font: 700 clamp(34px, 6vw, 48px)/1.1 var(--font-num); color: var(--accent); font-variant-numeric: lining-nums tabular-nums; }
.arz-big-toman span { font-size: .45em; font-weight: 500; color: var(--ink); }
.arz-big-rial { font: 500 17px/1.4 var(--font-num); color: var(--muted); }
.arz-hero-note { grid-column: 1 / -1; }
.arz-result { display: grid; gap: 2px; }
.arz-toman { font-size: .55em; font-weight: 500; color: var(--ink); }

/* Numbers: always the clear number font, never old-style figures of a display font. */
.calc-expr, .calc-result, .key, .mini-out output, .mini input, .arz-conv input, .arz-conv select, .arz-result, .arz-table td, .arz-table .code {
  font-family: var(--font-num);
  font-variant-numeric: lining-nums tabular-nums;
}
.arz-table td { font-size: 17px; }
.page-arz .note, .page-hesab .note { font-family: var(--font-num); }

