/* The public website on top of app.css (D-47): website forms, the homepage's
   community gallery and "Have your say". Loaded by templates/base.html only;
   the portal shell does not need it. Tokens only, no new colours, so both
   themes and the contrast tests in tests/test_palette.py still hold. */

/* ---- Website forms ------------------------------------------------------- */
/* The trap field for scripts: clipped rather than display:none, which some
   bots skip. aria-hidden keeps it from screen readers; tabindex=-1 from the keyboard.
   Not left: -10000px -- under right-to-left that made every Farsi form page
   11,366px wide (same lesson as .skip in app.css). */
.hp { position: absolute; inset-inline-start: 0; top: 0; width: 1px; height: 1px; margin: -1px;
      overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-form-page { max-width: 860px; }
.site-form-head { margin-bottom: 24px; }
.site-form-head h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 4px 0 10px; }
.site-form { display: grid; gap: 6px; }
.site-form .sf-item[hidden] { display: none !important; }
.sf-section { font-size: 20px; margin: 18px 0 2px; padding-top: 14px; border-top: 1px solid var(--border); }
.sf-item:first-of-type .sf-section { border-top: 0; padding-top: 0; margin-top: 0; }
.sf-content { color: var(--fg-muted); font-size: 15px; }
.sf-content p:last-child { margin-bottom: 0; }
.sf-submit { display: grid; gap: 8px; justify-items: start; margin-top: 14px; }
.sf-likert legend { font-weight: 600; margin-bottom: 6px; }
.sf-likert table { min-width: 520px; }
.sf-likert th[scope="row"] { font-weight: 500; text-align: start; }
.sf-likert td { text-align: center; }
.sf-likert tr.has-error th { color: var(--danger); }
.sf-cell { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.sf-signature canvas { height: 150px; }
.site-form-done { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.site-form-done .tile { width: 48px; height: 48px; }
.sf-embed { margin-top: 28px; }
.sf-embed h2 { font-size: 22px; }

/* ---- Form builder parity (D-48) ------------------------------------------ */
/* Widths: WPForms' field sizes and layout columns, as a 12-column grid. One
   column under 640px, whatever the width chosen. */
.sf-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 18px; row-gap: 6px; }
.sf-grid > .sf-item { grid-column: span 12; min-width: 0; }
.sf-grid > .sf-w-half { grid-column: span 6; }
.sf-grid > .sf-w-third { grid-column: span 4; }
.sf-grid > .sf-w-two_thirds { grid-column: span 8; }
.sf-grid > .sf-w-quarter { grid-column: span 3; }
.sf-item { margin-block-end: 12px; }
.sf-item > label, .sf-item > fieldset > legend { font-weight: 600; }
.sf-item input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .sf-item select, .sf-item textarea { width: 100%; }
.sf-alt { display: block; font-weight: 400; color: var(--fg-muted); font-size: .95em; }
.sf-alt[dir="rtl"] { font-family: "Vazirmatn", Tahoma, sans-serif; }
/* A form fixed to Dari on an English page (or the reverse) brings its own face. */
.site-form-page[lang="fa"], .sf-embed[lang="fa"], .site-form[lang="fa"] {
  font-family: 'Vazirmatn', 'IRANSans', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', 'Geeza Pro', Arial, sans-serif; line-height: 1.85; }
.sf-alt-block { margin-block-start: 10px; padding-block-start: 10px; border-block-start: 1px dashed var(--border); }

/* Choices: one, two or three columns, or in a row. */
.sf-choices { display: grid; gap: 8px; }
.sf-cols-2 .sf-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sf-cols-3 .sf-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sf-cols-inline .sf-choices { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.sf-choice { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 400; }
.sf-choice:hover { border-color: var(--border-strong); }
.sf-choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-fg); }
.sf-choice input { margin-block-start: 3px; flex: none; }
.sf-choice.has-image { flex-direction: column; align-items: stretch; }
.sf-choice.has-image img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: calc(var(--radius) - 2px); }
.sf-price { font-weight: 600; white-space: nowrap; }
.sf-label-text { font-weight: 600; }
.sf-step-t:empty { display: none; }
.sf-poll { margin-block-start: 18px; padding-block-start: 14px; border-block-start: 1px solid var(--border); }
.sf-bar-label { overflow-wrap: anywhere; }
.sf-other-text { margin-block-start: 4px; }
.sf-other-text[hidden] { display: none; }

/* Name and address parts, date and time side by side. */
.sf-parts { border: 0; padding: 0; margin: 0; min-width: 0; }
.sf-parts-row { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.sf-part { flex: 1 1 160px; min-width: 0; }
.sf-part-line1, .sf-part-line2 { flex-basis: 100%; }
.sf-sublabel { display: block; font-size: 13px; color: var(--fg-muted); font-weight: 400; margin-block-start: 3px; }

/* Rating, Net Promoter Score. */
.sf-scale { border: 0; padding: 0; margin: 0; }
.sf-scale-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sf-scale-cell { position: relative; }
.sf-scale-cell input { position: absolute; inset-inline-start: 0; top: 0; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
.sf-scale-cell > span { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 600; }
.sf-scale-cell input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.sf-scale-cell input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.sf-rating .sf-scale-cell > span { border-color: transparent; background: transparent; font-size: 28px; color: var(--fg-muted); }
.sf-star::before { content: "\2606"; }
.sf-rating .sf-scale-row:has(input:checked) .sf-scale-cell:has(~ .sf-scale-cell input:checked) .sf-star::before,
.sf-rating .sf-scale-cell input:checked + span .sf-star::before { content: "\2605"; color: var(--fg); }
.sf-rating .sf-scale-cell input:checked + span { background: transparent; color: var(--fg); }
.sf-nps-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--fg-muted); margin-block-start: 4px; }

.sf-slider-value { font-weight: 600; margin: 4px 0 0; }
.sf-money { display: flex; align-items: center; gap: 6px; }
.sf-money input { max-width: 220px; }
.sf-item-price { display: flex; justify-content: space-between; gap: 12px; margin: 0; }
.sf-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 18px; }
.sf-count { text-align: end; }
.sf-count.over { color: var(--danger); font-weight: 600; }
.sf-captcha-q { font-weight: 700; unicode-bidi: isolate; }

/* Pages and the progress indicator. */
.sf-page[hidden] { display: none; }
.sf-page-title { font-size: 22px; margin: 6px 0 10px; }
.sf-nav { display: flex; gap: 10px; justify-content: space-between; margin-block: 8px 4px; }
.sf-nav [data-sf-next], .sf-nav [data-sf-cnext] { margin-inline-start: auto; }
.sf-nav[hidden], .sf-submit[hidden] { display: none; }
.sf-progress { list-style: none; padding: 0; margin: 0 0 8px; display: flex; gap: 8px; flex-wrap: wrap; counter-reset: sf; }
.sf-progress li[hidden] { display: none; }
.sf-progress li { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 14px; }
.sf-progress .sf-step-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--border-strong); font-weight: 700; background: var(--surface); color: var(--fg); }
.sf-progress li.active { color: var(--fg); font-weight: 600; }
.sf-progress li.active .sf-step-n, .sf-progress li.done .sf-step-n { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.sf-progress-connector li:not(:last-child)::after { content: ""; width: 28px; height: 2px; background: var(--border-strong); }
.sf-progress-bar, .sf-progress-none { display: none; }
.sf-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-block-end: 4px; }
.sf-bar > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .25s ease; }
.site-form:has(.sf-progress-circles) .sf-bar, .site-form:has(.sf-progress-connector) .sf-bar,
.site-form:has(.sf-progress-none) .sf-bar, .site-form:has(.sf-progress-none) .sf-step-of { display: none; }
.sf-step-of { font-size: 14px; color: var(--fg-muted); margin: 0 0 8px; }

/* Conversational: one question at a time, large. */
.sf-display-conversational .sf-item { display: none; }
.sf-display-conversational .sf-item.sf-current { display: block; grid-column: span 12; padding: 24px 0; }
.sf-display-conversational .sf-item.sf-current > label,
.sf-display-conversational .sf-item.sf-current > fieldset > legend { font-size: clamp(1.25rem, 3vw, 1.7rem); }
.sf-display-conversational .sf-progress { display: none; }

/* "Form page" display: the form is the page. */
.sf-page-page { max-width: 760px; }
.sf-page-page .site-form-head { text-align: center; }

.sf-review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 6px 16px; margin-block-start: 14px; }
.sf-review dt { font-weight: 600; }
.sf-review dd { margin: 0; overflow-wrap: anywhere; }
.sf-resume-link { overflow-wrap: anywhere; font-weight: 600; }

/* Survey and poll results: plain bars, no chart library. */
.sf-result { margin-block-end: 22px; }
.sf-result h4 { margin: 0 0 8px; }
.sf-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sf-bars li { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: 10px; align-items: center; }
.sf-bar-track { height: 12px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.sf-bar-fill { display: block; height: 100%; width: var(--w, 0); background: var(--primary); }
.sf-bar-n { font-variant-numeric: tabular-nums; font-size: 14px; }

@media (max-width: 640px) {
  .sf-grid > .sf-item { grid-column: span 12; }
  .sf-cols-2 .sf-choices, .sf-cols-3 .sf-choices { grid-template-columns: minmax(0, 1fr); }
  .sf-review { grid-template-columns: minmax(0, 1fr); }
  .sf-bars li { grid-template-columns: minmax(0, 1fr) auto; }
  .sf-bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* The Dari halves of the surveys brought across from WordPress carry these
   classes (it was a Code Snippet there): right to left, Persian face. */
.survey-question-dari, .survey-section-header-dari {
  direction: rtl; text-align: start; unicode-bidi: isolate;
  font-family: 'Vazirmatn', 'IRANSans', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', 'Geeza Pro', Arial, sans-serif; }

/* ---- "Have your say" and the forms index --------------------------------- */
.sf-band {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 32px; align-items: center;
  background: var(--primary-soft); color: var(--primary-soft-fg);
  border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 36px 40px;
}
.sf-band h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin: 4px 0 8px; color: var(--fg); }
.sf-band p { color: var(--fg); margin: 0; }
.sf-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sf-links a {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 14px 16px; min-height: 44px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--fg);
  font-weight: 600; text-decoration: none;
}
.sf-links a:hover { border-color: var(--primary); }
.sf-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--fg); }
.sf-card h2 { font-size: 19px; margin: 0; }
.sf-card .meta { margin-top: auto; font-weight: 600; color: var(--primary); font-size: 14px; }
a.sf-card:hover { border-color: var(--primary); }

/* A programme card's own action, under its meta line. */
.program-card .card-link { font-size: 14px; font-weight: 600; color: var(--primary); text-decoration: none; padding-top: 4px; }
.program-card .card-link:hover { text-decoration: underline; }

/* ---- Our community in action --------------------------------------------- */
.moments { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 210px; gap: 14px; }
.moment { position: relative; margin: 0; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-3); }
.moment.wide { grid-column: span 2; grid-row: span 2; }
.moment img { width: 100%; height: 100%; object-fit: cover; display: block; }
.moment figcaption {
  position: absolute; inset: auto 0 0 0; padding: 28px 14px 12px;
  /* Solid enough at the text line that white stays above 4.5:1 on any photo. */
  background: linear-gradient(to top, rgba(10, 18, 32, .92) 0%, rgba(10, 18, 32, .82) 55%, rgba(10, 18, 32, 0) 100%);
  color: #fff; font-size: 13px; line-height: 1.4;
}
.moment figcaption strong { display: block; font-size: 15px; }

@media (max-width: 900px) {
  .moments { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 170px; }
  .sf-band { grid-template-columns: minmax(0, 1fr); padding: 24px; }
}
@media (max-width: 560px) {
  .moments { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 220px; }
  .moment.wide { grid-column: auto; grid-row: auto; }
  .site-form-done { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Programme cards without a photo ------------------------------------- */
/* Services that have no photo of their own (career support, civic courses,
   New American support) show the programme's icon on a soft panel, the same
   size as a photo, so the grid keeps one rhythm. */
.program-card .shot.shot-icon { display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-soft-fg); }
.program-card .shot.shot-icon svg { width: 64px; height: 64px; }

/* ---- Member votes (D-49) -------------------------------------------------- */
.sf-vote { max-width: 560px; }
.sf-vote input[name="code"] { font-size: 1.4rem; letter-spacing: .3em; max-width: 12ch; }
.sf-voter { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.sf-voter p { margin: 0; }
.sf-turnout strong { font-size: 1.2rem; }
