/* The public estimate page: mobile first, right to left, one design system (the tokens below).
   The Vazir font (FD: Persian digits) is served from site/fonts by our own server; nothing is loaded from the internet.
   Inside Bale and Telegram the colours come from the app's theme (site.js sets the variables and adds .themed).
   No emoji or symbol characters: marks such as ticks and checkboxes are drawn with CSS. */
@font-face { font-family: "Vazir"; src: url("/fonts/Vazir-Regular-FD.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazir"; src: url("/fonts/Vazir-Medium-FD.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazir"; src: url("/fonts/Vazir-Bold-FD.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Vazir"; src: url("/fonts/Vazir-Black-FD.woff2") format("woff2"); font-weight: 900; font-display: swap; }

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --hint: #64748b;
  --accent: #1d5fe0;
  --accent-text: #ffffff;
  --border: #e4e9f1;
  --soft: #eef3fd;
  --danger: #c2410c;
  --danger-soft: #fff4ed;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --hero-from: #2f7bf5;
  --hero-to: #173b8f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 24px rgba(15, 23, 42, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not(.themed) {
    --bg: #0d1117; --card: #161b24; --text: #e8edf3; --hint: #94a3b8; --accent: #5b8cff; --border: #263040;
    --soft: #1a2436; --danger: #fb923c; --danger-soft: #2a1a12; --ok: #4ade80; --ok-soft: #0f2418;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

/* ---- base ---------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.85 "Vazir", Tahoma, "Segoe UI", system-ui, sans-serif;
  padding-bottom: 104px;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
h1, h2, h3 { line-height: 1.6; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: .98rem; font-weight: 700; margin: 0 0 6px; }
p { margin: 0 0 8px; }
.muted { color: var(--hint); font-size: .9rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* ---- header -------------------------------------------------------------------------------- */
.top {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff;
  padding: 22px 0 56px; margin-bottom: -40px;
}
.top h1 { display: flex; align-items: center; gap: 12px; font-size: 1.3rem; font-weight: 900; margin: 0 0 6px; }
.logo { width: 44px; height: 44px; flex: none; border-radius: 12px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.sub { margin: 0; color: rgba(255, 255, 255, .85); font-size: .9rem; line-height: 1.8; }

/* ---- cards and notices --------------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 18px;
        margin-bottom: 14px; box-shadow: var(--shadow); }
.notice { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 14px; font-size: .92rem;
          background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }

/* ---- intro --------------------------------------------------------------------------------- */
.intro .lead { font-size: 1.1rem; font-weight: 900; margin: 0 0 14px; }
.block-title { font-weight: 700; font-size: .92rem; margin: 0 0 6px; }
.steps { list-style: none; counter-reset: step; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 12px; font-size: .92rem;
            background: var(--soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.steps li::before { content: counter(step, persian); flex: none; width: 28px; height: 28px; border-radius: 50%;
                    display: grid; place-items: center; background: var(--accent); color: var(--accent-text);
                    font-weight: 700; font-size: .85rem; }
.points { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; font-size: .9rem; color: var(--hint); }
.points li, .check { position: relative; padding-right: 22px; }
.points li::before, .check::before {
  content: ""; position: absolute; right: 3px; top: .55em; width: 6px; height: 11px;
  border: solid var(--ok); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.disclaimer { font-weight: 700; font-size: .9rem; background: var(--soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: .9rem; font-weight: 500; }

/* ---- buttons ------------------------------------------------------------------------------- */
button, input, select { font: inherit; color: inherit; line-height: 1.6; }
button { cursor: pointer; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card);
         padding: 10px 16px; font-weight: 500; transition: background .15s, border-color .15s, transform .05s; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
.ghost { background: transparent; }
.ghost:hover:not(:disabled) { border-color: var(--accent); }
.wide { width: 100%; margin-bottom: 12px; }
.small { padding: 6px 14px; font-size: .9rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- claims -------------------------------------------------------------------------------- */
.claims-help { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: .88rem; color: var(--hint); }
.claims-help strong { color: var(--text); font-weight: 700; }
.claims { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.claim { display: flex; align-items: center; gap: 10px; text-align: right; padding: 14px 12px; border-radius: 14px; font-weight: 500; }
.claim.on { background: var(--soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.box { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); position: relative; background: var(--card); }
.claim.on .box { background: var(--accent); border-color: var(--accent); }
.claim.on .box::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
                        border: solid var(--accent-text); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

/* ---- questions ----------------------------------------------------------------------------- */
.q { padding: 18px 0; border-top: 1px solid var(--border); }
.q:first-of-type { border-top: 0; padding-top: 0; }
.pick { color: var(--accent); font-size: .86rem; font-weight: 500; margin: 0 0 4px; }
.q-text { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 4px; font-size: 1rem; font-weight: 700; }
.q-num { flex: none; min-width: 26px; height: 26px; margin-top: 2px; padding: 0 6px; border-radius: 13px; display: grid; place-items: center;
         background: var(--soft); color: var(--accent); font-size: .8rem; font-weight: 700; transition: background .2s, color .2s; }
.q.answered .q-num { background: var(--ok); color: #fff; }  /* answered: the number turns green */
.q-help { margin: 0 0 12px; padding-right: 36px; color: var(--hint); font-size: .86rem; line-height: 1.8; white-space: pre-line; }
.options { display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: 8px; }
.option { display: flex; align-items: center; gap: 10px; width: 100%; text-align: right; padding: 11px 14px; font-weight: 500; }
.option.on { background: var(--soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.radio { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); background: var(--card); }
.option.on .radio { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--card); }
.option.unknown { margin-top: 8px; border-style: dashed; color: var(--hint); font-weight: 400; }
.option.unknown.on { color: var(--text); }
.q-error { color: var(--danger); font-size: .86rem; margin-top: 8px; white-space: pre-line; }
.date { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
select, input { width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); }
.date-extra { margin-top: 8px; display: grid; gap: 8px; }
#outcome input { flex: 1; min-width: 150px; width: auto; }

/* ---- preview and payment ------------------------------------------------------------------- */
.lines { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.lines li { background: var(--soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.warn { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 8px 12px; margin-top: 8px; font-size: .88rem; }
.pay-way { margin-bottom: 10px; }
.card-box { background: var(--soft); border-radius: 14px; padding: 16px; margin-top: 8px; }
.card-box .big { font-size: 1.2rem; font-weight: 900; }
.card-box .ltr { direction: ltr; text-align: right; letter-spacing: 1px; unicode-bidi: isolate; }
.waiting { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.waiting::before { content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%;
                   border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- result -------------------------------------------------------------------------------- */
.total, .claim-result { border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.total { background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; }
.total .words { color: rgba(255, 255, 255, .8); }
.claim-result { border: 1px solid var(--border); }
.claim-result h3, .total h3 { font-size: .95rem; margin: 0 0 4px; }
.range { font-size: 1.2rem; font-weight: 900; line-height: 1.7; }
.claim-result > .range { color: var(--accent); }
.words { color: var(--hint); font-size: .86rem; margin: 0 0 6px; }
.block { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.block .lines li { background: none; padding: 0 16px 0 0; position: relative; }
.block .lines li::before { content: ""; position: absolute; right: 2px; top: .8em; width: 6px; height: 6px; border-radius: 50%; background: var(--hint); }
.section { font-size: .95rem; margin: 18px 0 4px; }
.feedback { margin-top: 12px; }
.case-list { list-style: none; padding: 0; margin: 0; }
.case-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }

/* ---- FAQ and privacy ----------------------------------------------------------------------- */
.faq h2 { font-size: 1.1rem; margin-bottom: 4px; }
.faq h3 { margin: 18px 0 4px; padding-top: 16px; border-top: 1px solid var(--border); }
.faq h2 + h3 { border-top: 0; padding-top: 4px; }
.faq p { color: var(--hint); font-size: .92rem; margin: 0; }
.privacy summary { cursor: pointer; font-weight: 500; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.privacy summary::-webkit-details-marker { display: none; }
.privacy summary::after { content: ""; width: 8px; height: 8px; border: solid var(--hint); border-width: 0 0 2px 2px;
                          transform: rotate(-45deg); transition: transform .2s; margin-top: -4px; }
.privacy[open] summary::after { transform: rotate(135deg); margin-top: 4px; }
.privacy ul { margin: 10px 0 0; padding: 0 18px 0 0; color: var(--hint); font-size: .9rem; }

/* ---- the bottom bar ------------------------------------------------------------------------ */
.bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
       background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
       border-top: 1px solid var(--border); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }
.bar-in { display: flex; align-items: center; gap: 12px; }
.progress { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .25s; }
#progress-text { white-space: nowrap; font-size: .85rem; }
#submit { padding: 11px 20px; }

/* ---- the guide (guide.py, guide.html) ------------------------------------------------------ */
body.guide { padding-bottom: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin-bottom: 10px; font-size: .82rem;
          color: rgba(255, 255, 255, .75); }
.crumbs a { color: rgba(255, 255, 255, .9); text-decoration: none; }
.crumbs a::after { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 9px 2px; transform: rotate(45deg);
                   border: solid rgba(255, 255, 255, .6); border-width: 0 0 1.5px 1.5px; }
.prose { font-size: 1rem; }
.prose h2 { font-size: 1.12rem; margin: 26px 0 8px; }
.prose h3 { font-size: 1rem; margin: 18px 0 6px; }
.prose p, .prose li { line-height: 2; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 14px; padding: 0 22px 0 0; }
.prose li { margin-bottom: 4px; }
.prose .meta { color: var(--hint); font-size: .82rem; margin: 0 0 4px; }
.note { background: var(--soft); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 14px; font-size: .94rem; }
.table { overflow-x: auto; margin: 0 0 14px; }
.table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: right; padding: 8px 10px; border: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--soft); font-weight: 700; }
.cta { margin: 22px 0; padding: 18px; border-radius: var(--radius); color: #fff;
       background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); }
.cta p { color: rgba(255, 255, 255, .88); font-size: .92rem; }
.cta .cta-title { color: #fff; font-weight: 900; font-size: 1.05rem; margin-bottom: 6px; }
.button { display: inline-block; text-decoration: none; text-align: center; border-radius: var(--radius-sm);
          padding: 11px 22px; font-weight: 700; }
.cta .button { background: #fff; color: var(--hero-to); margin-top: 4px; }
.related { margin-top: 8px; }
.related h2 { margin-top: 8px; }
.small-note { margin-top: 16px; }
.hub { list-style: none; margin: 0; padding: 0; }
.hub li { padding: 12px 0; border-top: 1px solid var(--border); }
.hub li:first-child { border-top: 0; padding-top: 0; }
.hub a { font-weight: 700; text-decoration: none; }
.hub p { color: var(--hint); font-size: .9rem; margin: 4px 0 0; }
.guide-links { margin: 0 0 10px; padding: 0 20px 0 0; }
.guide-links li { margin-bottom: 4px; }
.calc { margin: 18px 0; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.calc label { display: block; font-weight: 500; font-size: .92rem; margin: 12px 0 6px; }
.calc .row { flex-wrap: nowrap; }
.calc .row input { flex: 1; min-width: 0; }
.calc .row select { width: auto; }
.calc .wide { margin: 16px 0 0; }
.calc-result { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.calc-result .range { color: var(--accent); }
.foot { padding: 8px 0 32px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .88rem; }
.foot a { color: var(--hint); }

@media (min-width: 640px) {
  .top { padding: 32px 0 64px; }
  .top h1 { font-size: 1.55rem; }
  .card { padding: 24px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .steps li { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
