/* QAForm — «گفت‌وگو» (visual-language Pattern B): a pale colour field carrying
   the section, cut by an organic wave into the white answer area. Tokens are
   copied from the binahayat kit; this page is standalone by design and must
   not fetch anything at runtime (the Iran rule). */

@font-face {
  font-family: "Vazirmatn";
  src: url("vazirmatn.woff2") format("woff2 supports variations"),
       url("vazirmatn.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --c-primary: #4636D9;
  --c-primary-press: #3A2BB8;
  --c-primary-tint: #EEEBFF;
  --c-primary-fg: #4636D9;
  --c-accent: #00C48C;
  --c-accent-text: #00815A;
  --c-reward: #FFB020;
  --c-danger: #F2544B;
  --c-danger-text: #B3372E;
  --c-danger-tint: #FDECEB;
  --c-ink: #171533;
  --c-ink-2: #4A4670;
  --c-ink-3: #6E6A94;
  --c-line: #E4E1F7;
  --c-bg: #F5F4FF;
  --c-surface: #FFFFFF;
  --on-primary: #FFFFFF;

  --font: "Vazirmatn", system-ui, sans-serif;
  --fs-h1: 24px; --fs-h2: 20px; --fs-h3: 17px;
  --fs-body: 17px; --fs-label: 14px; --fs-caption: 12.5px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-pill: 999px;
  --e-sm: 0 1px 2px rgba(23,21,51,.07);
  --e-md: 0 4px 14px rgba(23,21,51,.11);
  --e-lg: 0 12px 30px rgba(23,21,51,.16);
  --t-fast: 120ms; --t-base: 200ms; --ease: cubic-bezier(.2,.8,.2,1);
  --touch-min: 52px;
  --page-pad: 16px;
  --content-max: 560px;

  --focus-ring: 0 0 0 2px var(--c-surface), 0 0 0 5px var(--c-primary-fg);

  /* the five section hues — decorative, free to use (visual-language §2) */
  --hue: var(--c-primary);
}

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

/* load-bearing: the HTML `hidden` attribute is only `display:none` from the
   UA sheet, so ANY author `display` (our .center is a flex column) wins and
   every screen renders at once — walk-found on the first full-page shot. */
[hidden] { display: none !important; }

html { direction: rtl; }

body {
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

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

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

.wrap { inline-size: 100%; max-inline-size: var(--content-max); margin-inline: auto; }
.pad { padding-inline: var(--page-pad); }
@media (min-width: 390px) { :root { --page-pad: 20px; } }
@media (min-width: 768px) { :root { --page-pad: 24px; --content-max: 640px; } }

/* ── the colour field + wave ─────────────────────────────────────────── */

.field {
  position: relative;
  background: color-mix(in srgb, var(--hue) 30%, var(--c-surface));
  padding-block: var(--s-6) 0;
}

.field .wave { display: block; inline-size: 100%; block-size: 48px; }
.field .wave path { fill: var(--c-surface); }

.kicker {
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .3px;
  color: color-mix(in srgb, var(--hue) 72%, var(--c-ink));
}

.field h1 { font-size: var(--fs-h1); font-weight: 800; line-height: 1.4; margin-block: var(--s-2) 0; }
.field p.lead { color: var(--c-ink-2); font-size: var(--fs-label); margin-block-start: var(--s-2); }

/* the colour takes the leftover height, never a white void below the wave
   (visual-language Pattern B) */
.field.fill { flex: 1; display: flex; flex-direction: column; }
.field.fill .wave { margin-block-start: auto; }

.illus { display: block; inline-size: min(78%, 260px); block-size: auto; margin: var(--s-5) auto var(--s-2); }

/* ── header ──────────────────────────────────────────────────────────── */

.bar {
  position: sticky; inset-block-start: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--page-pad);
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-block-end: 1px solid var(--c-line);
}
.brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 800; font-size: var(--fs-label); }
.savechip {
  margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-caption); color: var(--c-ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-inline-size: 0;
}
.savechip .dot { inline-size: 8px; block-size: 8px; border-radius: var(--r-pill); background: var(--c-line); }
.savechip[data-state="saving"] .dot { background: var(--c-reward); }
.savechip[data-state="saved"] .dot { background: var(--c-accent); }
.savechip[data-state="error"] .dot { background: var(--c-danger); }
.savechip[data-state="saved"] { color: var(--c-accent-text); }
.savechip[data-state="error"] { color: var(--c-danger-text); }

.logout {
  flex: 0 0 auto;
  min-block-size: 36px; padding-inline: var(--s-3);
  border: 1px solid var(--c-line); border-radius: var(--r-pill);
  background: var(--c-surface); color: var(--c-ink-2);
  font: inherit; font-size: var(--fs-caption); font-weight: 600;
  cursor: pointer;
}
.logout:hover { color: var(--c-danger-text); border-color: var(--c-danger-line, #F7BDB9); }

/* ── progress ────────────────────────────────────────────────────────── */

.prog { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--page-pad) 0; }
.prog .label { font-size: var(--fs-caption); color: var(--c-ink-2); white-space: nowrap; }
.prog .track { flex: 1; block-size: 6px; border-radius: var(--r-pill); background: var(--c-line); overflow: hidden; }
.prog .fill { display: block; block-size: 100%; border-radius: var(--r-pill);
              background: var(--hue); transition: inline-size var(--t-base) var(--ease); }

/* ── question card ───────────────────────────────────────────────────── */

.cards { display: flex; flex-direction: column; gap: var(--s-4); padding-block: var(--s-5) var(--s-8); }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--e-sm);
  padding: var(--s-4);
  /* the 4px top edge in the section hue — the tile grammar from Pattern A,
     the one place this page borrows from it */
  border-block-start: 4px solid var(--hue);
}
.card.answered { border-block-start-color: var(--c-accent); }

.q-head { display: flex; gap: var(--s-2); align-items: baseline; }
.q-no { font-weight: 800; color: var(--hue); font-size: var(--fs-h3); }
.q-title { font-size: var(--fs-h3); font-weight: 700; line-height: 1.55; }
.q-ref {
  margin-block-start: var(--s-2);
  font-size: var(--fs-caption); line-height: 1.75; color: var(--c-ink-3);
  background: color-mix(in srgb, var(--hue) 7%, var(--c-surface));
  border-inline-start: 3px solid color-mix(in srgb, var(--hue) 45%, var(--c-surface));
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: var(--s-2) var(--s-3);
}
.q-ref b { color: color-mix(in srgb, var(--hue) 75%, var(--c-ink)); font-weight: 700; }
.q-intro { margin-block-start: var(--s-3); color: var(--c-ink-2); font-size: var(--fs-label); line-height: 1.85; }

.f-label { display: block; margin-block: var(--s-4) var(--s-2); font-size: var(--fs-label);
           font-weight: 600; line-height: 1.7; color: var(--c-ink); }

/* choices — stacked pills, the check floats to the inline end */
.opts { display: flex; flex-direction: column; gap: var(--s-2); border: 0; }
.opt {
  display: flex; align-items: center; gap: var(--s-3);
  min-block-size: var(--touch-min);
  padding: var(--s-2) var(--s-3);
  border: 1.5px solid var(--c-line);
  border-radius: 13px;
  background: var(--c-surface);
  cursor: pointer;
  font-size: var(--fs-label); line-height: 1.6;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.opt:hover { border-color: color-mix(in srgb, var(--hue) 40%, var(--c-line)); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .txt { flex: 1; }
.opt .tick { inline-size: 22px; block-size: 22px; flex: 0 0 22px; opacity: 0; }
.opt:has(input:checked) {
  border-color: var(--c-accent);
  background: color-mix(in srgb, var(--c-accent) 8%, var(--c-surface));
  font-weight: 600;
}
.opt:has(input:checked) .tick { opacity: 1; }
.opt:has(input:focus-visible) { box-shadow: var(--focus-ring); }

textarea, input[type="text"], input[type="password"] {
  inline-size: 100%;
  font: inherit; font-size: var(--fs-label);
  color: var(--c-ink);
  background: var(--c-surface);
  border: 1.5px solid var(--c-line);
  border-radius: 13px;
  padding: var(--s-3);
  resize: vertical;
}
input[type="text"], input[type="password"] { min-block-size: var(--touch-min); }
textarea { min-block-size: 96px; line-height: 1.8; }
textarea:focus, input:focus { outline: none; border-color: var(--c-primary-fg); box-shadow: var(--focus-ring); }
::placeholder { color: #767199; }

.count { text-align: end; font-size: var(--fs-caption); color: var(--c-ink-3); margin-block-start: 4px; }
.count.over { color: var(--c-danger-text); font-weight: 700; }

/* ── buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-block-size: 54px; padding-inline: var(--s-6);
  border: 0; border-radius: var(--r-lg);
  font: inherit; font-size: var(--fs-h3); font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--c-primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--c-primary-press); }
.btn-primary:disabled { background: #9990EA; cursor: default; }
.btn-ghost { background: transparent; color: var(--c-primary-fg); border: 1.5px solid var(--c-line); }
.btn-ghost:hover { background: var(--c-primary-tint); }
.btn-full { inline-size: 100%; }

.nav { display: flex; gap: var(--s-3); padding-block-end: var(--s-8); }
.nav .btn { flex: 1; }

/* ── review + done ───────────────────────────────────────────────────── */

.rev { display: flex; flex-direction: column; gap: var(--s-3); padding-block: var(--s-5) var(--s-6); }
.rev-item { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); padding: var(--s-3); }
.rev-q { font-size: var(--fs-label); font-weight: 700; display: flex; gap: var(--s-2); }
.rev-a { margin-block-start: var(--s-2); font-size: var(--fs-label); color: var(--c-ink-2); white-space: pre-wrap; }
.rev-a.empty { color: var(--c-ink-3); }
.rev-edit { margin-block-start: var(--s-2); background: none; border: 0; font: inherit;
            font-size: var(--fs-caption); font-weight: 700; color: var(--c-primary-fg); cursor: pointer; padding: 6px 0; }

.note {
  background: color-mix(in srgb, var(--c-reward) 16%, var(--c-surface));
  border-radius: var(--r-md); padding: var(--s-3);
  font-size: var(--fs-label); line-height: 1.8;
}

.err {
  background: var(--c-danger-tint); color: var(--c-danger-text);
  border-radius: var(--r-md); padding: var(--s-3);
  font-size: var(--fs-label); font-weight: 600;
}

.center { min-block-size: 100dvh; display: flex; flex-direction: column; }
.center .grow { flex: 1; display: flex; flex-direction: column; justify-content: center; }
/* flex items shrink by default: on a short viewport the colour field squeezed
   the form until the password input sat under the button (owner-found). The
   form area never shrinks; the colour absorbs the difference. */
.center > .onsurface { flex: 0 0 auto; }
.field.fill { min-block-size: 0; }

.hidden { display: none !important; }
.sr {
  position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ── utilities ────────────────────────────────────────────────────────
   These exist because the page ships under `style-src 'self'` with no
   'unsafe-inline': a style="" attribute is refused by the browser, so every
   one-off rule lives here instead. That is the right trade — this page is
   full of confidential text and a strict CSP costs us nothing. */
.hue-violet { --hue: #4636D9; }
.hue-mint   { --hue: #00C48C; }
.onsurface  { background: var(--c-surface); }
.mark-lg    { overflow: visible; display: block; margin-inline: auto; }
.mark-sm    { overflow: visible; }
.tcenter    { text-align: center; }
.mt0 { margin-block-start: 0; }
.mt3 { margin-block-start: var(--s-3); }
.mt4 { margin-block-start: var(--s-4); }
.formcol { display: flex; flex-direction: column; gap: var(--s-3); padding-block: var(--s-5) var(--s-8); }
.formcol.tight { gap: 0; padding-block: var(--s-4) var(--s-8); }
.pad-block { padding-block: var(--s-5) var(--s-8); }

/* the attribution card on the review screen keeps the card grammar but has no
   question number, so it needs the label spacing to start flush */
.card > .f-label.mt0 { margin-block-start: 0; }
.btn:disabled { opacity: .45; cursor: default; }

/* The section heading is focused on every screen change so screen readers
   announce the new page. It is not a control, so it must not wear a focus
   ring — the ring belongs to things you can operate. */
#sec-title:focus, #sec-title:focus-visible { outline: none; box-shadow: none; }
