/* ============================================================
   Component styles — ported from GetScreened/DesignSystem
   (Components.swift, ListenBar.swift, Illustrations.swift) and the
   per-screen SwiftUI layouts. Logical properties throughout so the
   Arabic RTL mirror is automatic.
   ============================================================ */

/* ---------- Navigation bar (NavigationStack chrome) ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: calc(var(--safe-top) + 6px) 8px 8px;
  background: var(--canvas);
  border-bottom: 1px solid var(--wash);
}
.navbar-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--secondary);
  font-size: 1rem;
  font-weight: 500;
  padding: 8px 6px;
  cursor: pointer;
}
.navbar-back svg { width: 20px; height: 20px; transform: scaleX(-1); }
html[dir="rtl"] .navbar-back svg { transform: none; }
.navbar-title {
  flex: 1;
  text-align: center;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  padding-inline: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navbar-spacer { width: 56px; flex: none; }

/* ---------- Screen scaffold (ScreenContainer) ---------- */
.screen-scroll {
  min-height: 100%;
}
.screen {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px var(--screen-padding) calc(40px + var(--safe-bottom));
}
.screen.has-footer { padding-bottom: 18px; }

/* page-push transition */
@keyframes screen-in {
  from { opacity: 0; transform: translateX(var(--push-from, 18px)); }
  to   { opacity: 1; transform: translateX(0); }
}
.page-enter { animation: screen-in var(--spring) both; }
html[dir="rtl"] .page-enter { --push-from: -18px; }

/* ---------- Buttons (Components.swift button styles) ---------- */
.btn {
  font: inherit;
  border: none;
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: opacity 120ms ease, transform 120ms ease;
}
.btn:active { transform: scale(0.985); }
.btn-primary {
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  padding: 15px 24px;
  border-radius: var(--button-corner);
}
.btn-primary:active { opacity: 0.75; }
.btn-secondary {
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  padding: 14px 24px;
  border-radius: var(--button-corner);
  border: 1.5px solid rgba(33, 29, 22, 0.25);
}
.btn-secondary:active { background: rgba(255,255,255,0.5); }
.btn-quiet {
  width: auto;
  background: none;
  color: var(--secondary);
  font-size: 0.94rem;
  font-weight: 500;
  padding: 6px 4px;
}
.btn-quiet:active { opacity: 0.6; }
.btn-block-quiet { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn-destructive { color: var(--alert); }

/* ---------- Cards & containers ---------- */
.card {
  background: var(--card);
  border-radius: var(--corner);
  padding: var(--card-padding);
  width: 100%;
}
.card--accent-soft   { background: var(--accent-soft); }
.card--secondary-soft{ background: var(--secondary-soft); }
.card--alert-soft    { background: var(--alert-soft); }
.card--wash          { background: var(--wash); }
.card--wash-soft     { background: rgba(240, 232, 216, 0.6); }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--secondary);
  background: var(--secondary-soft);
  white-space: nowrap;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Section heading ---------- */
.section-heading {
  font-size: 1.24rem;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Stat callouts ---------- */
.stat-callout, .hero-stat {
  background: var(--card);
  border-radius: var(--corner);
  padding: var(--card-padding);
}
.stat-figure {
  font-family: var(--font-serif);
  font-weight: 800;
  color: var(--accent-deep);
  line-height: 1;
}
.stat-callout .stat-figure { font-size: 2.4rem; }
.hero-stat .stat-figure { font-size: 3.2rem; }
.stat-caption { color: var(--ink); margin-top: 6px; }
.stat-callout .stat-caption { font-size: 0.94rem; }

/* ---------- Scene banner ---------- */
.scene-banner {
  width: 100%;
  object-fit: cover;
  border-radius: var(--corner);
  display: block;
  background: var(--wash);
}

/* ---------- Fact rows (the source guardrail) ---------- */
.fact-row { display: flex; flex-direction: column; gap: 4px; }
.fact-main { display: flex; align-items: flex-start; gap: 10px; }
.fact-bullet {
  flex: none;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
}
.fact-text { color: var(--ink); }
.fact-source-btn {
  align-self: flex-start;
  margin-inline-start: 17px;
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.72rem;
  text-align: start;
  padding: 8px 0;
  line-height: 1.35;
}
.fact-source-btn svg { width: 13px; height: 13px; flex: none; margin-top: 1px; }

/* ---------- Journey progress + footer ---------- */
.progress-bar { display: flex; align-items: center; gap: 6px; }
.progress-seg {
  height: 5px;
  flex: 1;
  border-radius: 999px;
  background: var(--wash);
  transition: background var(--spring), max-width var(--spring);
}
.progress-seg.filled { background: var(--accent); }
.progress-seg.active { max-width: 34px; }

.journey-footer {
  position: sticky;
  bottom: 0;
  z-index: 30;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 10px var(--screen-padding) calc(4px + var(--safe-bottom));
  background: var(--canvas);
  border-top: 1px solid var(--wash);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.journey-footer .footer-hint {
  font-size: 0.84rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Home: wordmark, language, tiles ---------- */
.wordmark { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.wordmark-chip {
  width: 16px; height: 16px;
  border-radius: 3px;
  background: var(--accent);
  flex: none;
}
.wordmark-text {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.wordmark-spacer { flex: 1; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: var(--card);
  color: var(--secondary);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn svg { width: 16px; height: 16px; }

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  text-align: start;
  background: var(--card);
  border: none;
  border-radius: var(--corner);
  padding: 12px;
  min-height: 74px;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
}
.tile img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }
.tile-title { font-size: 0.94rem; font-weight: 600; }

.center-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.84rem; color: var(--ink-soft); text-align: center;
}
.center-note svg { width: 15px; height: 15px; flex: none; }
.full-center { width: 100%; display: flex; justify-content: center; }

/* ---------- Test glyph (cream disc) ---------- */
.glyph {
  flex: none;
  border-radius: 50%;
  background: var(--canvas);
  display: grid;
  place-items: center;
  border: 1px solid var(--wash);
}
.glyph img { width: 82%; height: 82%; object-fit: contain; }

/* ---------- Test row / list item ---------- */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: start;
  background: var(--card);
  border: none;
  border-radius: var(--corner);
  padding: 14px;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
}
.list-item.outlined { border: 2px solid var(--accent); }
.list-item-body { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.list-item-title { font-size: 1rem; font-weight: 600; }
.list-item-sub { font-size: 0.84rem; color: var(--ink-soft); }
.chev { flex: none; color: var(--ink-soft); }
.chev svg { width: 15px; height: 15px; }
html[dir="rtl"] .chev svg { transform: scaleX(-1); }

/* ---------- Diagrams (Illustrations.swift) ---------- */
.polyp-diagram img { width: 100%; border-radius: 10px; display: block; }
.polyp-stages { display: flex; gap: 8px; margin-top: 10px; }
.polyp-stages span { flex: 1; text-align: center; font-size: 0.78rem; color: var(--ink-soft); }

.stepflow { display: flex; align-items: flex-start; gap: 12px; }
.stepflow-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.flow-box {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(33,29,22,0.12);
  font-size: 0.94rem; font-weight: 600; color: var(--ink);
}
.flow-box img { width: 26px; height: 26px; border-radius: 50%; }
.flow-box span { white-space: pre-line; }
.flow-cap { font-size: 0.78rem; color: var(--ink-soft); white-space: pre-line; }
.flow-warn { font-size: 0.78rem; font-weight: 600; color: var(--alert); }
.flow-icon { color: var(--secondary); }
.flow-icon svg { width: 18px; height: 18px; }

/* ---------- Listen bar (ListenBar.swift) ---------- */
.listen-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: var(--corner);
  background: var(--card);
  border: 1px solid var(--wash);
  cursor: pointer;
}
.listen-btn {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}
.listen-btn.disabled { background: var(--wash); color: rgba(107,99,83,0.4); cursor: default; }
.listen-btn svg { width: 18px; height: 18px; }
.listen-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.listen-title { font-size: 0.94rem; font-weight: 600; color: var(--ink); }
.listen-track { height: 6px; border-radius: 999px; background: var(--wash); overflow: hidden; }
.listen-fill { height: 100%; background: var(--accent-deep); border-radius: 999px; width: 0%; min-width: 6px; }
.listen-caption { font-size: 0.78rem; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.listen-voice {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  color: var(--secondary); font-size: 0.78rem; padding: 0;
}
.listen-voice svg { width: 9px; height: 9px; }
.listen-transcript {
  flex: none; background: none; border: none; cursor: pointer;
  color: var(--secondary); font-size: 0.94rem; font-weight: 500; padding: 4px;
}

/* ---------- Choice rows & chips (Due / Chooser) ---------- */
.choice-row { display: flex; gap: 8px; }
.choice {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 0.94rem; font-weight: 600;
  color: var(--ink-soft);
  background: var(--canvas);
  border: 1px solid var(--wash);
  border-radius: 999px;
  padding: 11px 8px;
  cursor: pointer;
  text-align: center;
}
.choice svg { width: 15px; height: 15px; }
.choice.selected { color: var(--on-accent); background: var(--accent); border-color: rgba(138,99,0,0.4); }

.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px;
  font-size: 0.84rem; font-weight: 600;
  color: var(--ink-soft);
  background: var(--canvas);
  border: 1px solid var(--wash);
  border-radius: 11px;
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
}
.chip svg { width: 13px; height: 13px; }
.chip.selected { color: var(--ink); background: var(--accent); border-color: rgba(138,99,0,0.4); }

.chooser-chip {
  flex: 1;
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.84rem; font-weight: 600;
  color: var(--ink-soft);
  background: var(--canvas);
  border: 1px solid var(--wash);
  border-radius: 14px;
  padding: 12px 4px;
  cursor: pointer;
  text-align: center;
}
.chooser-chip svg { width: 13px; height: 13px; }
.chooser-chip.selected { color: var(--on-accent); background: var(--accent); border-color: rgba(138,99,0,0.4); }

/* ---------- Forms (RequestCallView) ---------- */
.field-row { display: flex; align-items: center; gap: 12px; }
.field-label { font-size: 0.94rem; color: var(--ink-soft); flex: none; }
.field-input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 1rem;
  border: none; background: none; color: var(--ink);
  text-align: end;
  padding: 2px 0;
}
.field-input:focus { outline: none; }
.field-divider { height: 1px; background: var(--wash); border: none; margin: 0; }
.dob-group { display: flex; align-items: center; gap: 6px; }
.dob-field {
  text-align: center; font: inherit; font-size: 1rem;
  border: none; border-radius: 8px; background: var(--canvas);
  padding: 8px 4px; color: var(--ink);
}
.dob-field:focus { outline: 2px solid var(--secondary-soft); }
.consent { display: flex; align-items: flex-start; gap: 12px; }
.consent-body { flex: 1; }
.req-tag { font-size: 0.72rem; font-weight: 700; color: var(--accent-deep); text-transform: uppercase; letter-spacing: 0.5px; }

/* iOS-style toggle */
.switch { flex: none; position: relative; width: 51px; height: 31px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--wash-deep); transition: background var(--gentle);
}
.switch .knob {
  position: absolute; top: 2px; inset-inline-start: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform var(--gentle);
}
.switch input:checked + .track { background: var(--secondary); }
.switch input:checked ~ .knob { transform: translateX(20px); }
html[dir="rtl"] .switch input:checked ~ .knob { transform: translateX(-20px); }

/* dropdown trigger (Menu) */
.menu-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  width: 100%;
  background: var(--canvas);
  border: none; border-radius: 10px;
  padding: 12px;
  color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; text-align: start;
}
.menu-trigger.inline {
  width: auto; background: none; padding: 0; color: var(--ink);
}
.menu-trigger svg { width: 14px; height: 14px; color: var(--ink-soft); flex: none; }

/* ---------- About / sources list ---------- */
.source-item { display: flex; flex-direction: column; gap: 3px; }
.source-title { font-size: 0.94rem; font-weight: 600; color: var(--ink); }
.source-ref { font-size: 0.78rem; color: var(--ink-soft); }
.divider { height: 1px; background: var(--wash); border: none; margin: 0; }
.disclaimer-row { display: flex; align-items: flex-start; gap: 10px; }
.disclaimer-row .dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 8px; }

.staff-link {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: rgba(240,232,216,0.6); border: none; border-radius: var(--corner);
  padding: 14px; color: var(--ink-soft); font: inherit; font-size: 0.84rem; font-weight: 500;
  cursor: pointer;
}
.staff-link .label { flex: 1; display: inline-flex; align-items: center; gap: 8px; }
.staff-link svg { width: 16px; height: 16px; }

.staff-detail { display: flex; gap: 8px; align-items: baseline; }
.staff-detail .k { font-size: 0.78rem; color: var(--ink-soft); width: 76px; flex: none; }
.staff-detail .v { font-size: 0.78rem; font-weight: 500; color: var(--ink); }

/* ---------- Generic icon-titled labels ---------- */
.icon-label { display: inline-flex; align-items: center; gap: 8px; }
.icon-label svg { width: 18px; height: 18px; flex: none; }
.icon-label.small svg { width: 15px; height: 15px; }
.next-step { display: flex; align-items: flex-start; gap: 12px; }
.next-step .ns-icon { flex: none; width: 24px; color: var(--secondary); display: grid; place-items: center; }
.next-step .ns-icon svg { width: 20px; height: 20px; }
.meanwhile { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: none; cursor: pointer; font: inherit; text-align: start; color: var(--ink); }
.meanwhile .mw-icon { flex: none; width: 28px; color: var(--secondary); display: grid; place-items: center; }
.meanwhile .mw-icon svg { width: 20px; height: 20px; }
.meanwhile .mw-body { flex: 1; }

/* ---------- Bottom sheet / modal (TranscriptSheet, menus) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(33,29,22,0.32);
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: fade-in var(--gentle) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet {
  background: var(--canvas);
  border-radius: 16px 16px 0 0;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: sheet-up var(--spring) both;
  padding-bottom: var(--safe-bottom);
}
.sheet-grip { width: 38px; height: 5px; border-radius: 999px; background: var(--wash-deep); margin: 8px auto 4px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 8px; }
.sheet-title { font-size: 1.02rem; font-weight: 600; }
.sheet-done { background: none; border: none; color: var(--secondary); font: inherit; font-weight: 600; cursor: pointer; padding: 6px; }
.sheet-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 24px; }
.transcript-line { padding: 7px 10px; border-radius: 10px; line-height: 1.5; }
.transcript-line.active { background: var(--accent-soft); }

.menu-sheet-list { padding: 8px 12px 12px; display: flex; flex-direction: column; }
.menu-option {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; font: inherit; font-size: 1.05rem;
  color: var(--ink); padding: 14px 8px; text-align: start; width: 100%;
  border-bottom: 1px solid var(--wash);
}
.menu-option:last-child { border-bottom: none; }
.menu-option svg { width: 18px; height: 18px; color: var(--secondary); flex: none; }
.menu-option .spacer { flex: 1; }

/* ---------- Validation / alert cards ---------- */
.problem { display: flex; align-items: flex-start; gap: 8px; color: var(--alert); font-size: 0.84rem; }
.problem svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ---------- Toast / spinner ---------- */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(33,29,22,0.25); border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Staggered reveal ---------- */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.shown { opacity: 1; transform: translateY(0); transition: opacity var(--spring), transform var(--spring); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

.alert-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-bottom)); z-index: 120;
  background: var(--ink); color: var(--canvas);
  padding: 12px 18px; border-radius: 12px; font-size: 0.9rem;
  max-width: 88%; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  animation: fade-in var(--gentle) both;
}
