/* Phone first, one column (40rem on desktop); system fonts; logical properties, so Arabic and Hebrew mirror.
   White paper, navy ink, one cobalt accent; one scheme (v0.1.42). Tokens: tests/contrast.test.js. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f4f6fa;
  --text: #0c1626;
  --muted: #55627a;
  --accent: #1447c8;
  --on-accent: #ffffff;
  --link: #1447c8;
  --border: #66758a;
  --focus: #b4440c;
  --ok-bg: #e3f2ec;
  --ok-text: #0b4a3b;
  --no-bg: #fbe9e7;
  --no-text: #8a1c12;
  --unc-bg: #fff4d6;
  --unc-text: #6b4a00;
  --line: #dfe4ec; /* decorative separators only */
  --tabs: calc(3.5rem + 1px + env(safe-area-inset-bottom)); /* the bottom bar's whole height, at any text size */
  --shadow: 0 1px 2px rgba(12, 22, 38, .05), 0 8px 24px rgba(12, 22, 38, .07);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: auto;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.wrap {
  max-width: 40rem;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

main.wrap { padding-bottom: env(safe-area-inset-bottom); }

/* Bottom bar: empty, so gone, on a question */
#tabs { position: fixed; inset: auto 0 0; z-index: 2; background: var(--bg); border-block-start: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs:empty { display: none; }
.tabrow { display: flex; }
.tab {
  flex: 1 1 0; min-width: 0; height: 3.5rem; line-height: 3.5rem; overflow: hidden; white-space: nowrap; text-align: center;
  font-size: .8125rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tab[aria-current] { color: var(--link); box-shadow: inset 0 3px var(--accent); }
main.tabbed { padding-bottom: calc(var(--tabs) + 1rem); }
.tabbed .actionbar { bottom: var(--tabs); padding-bottom: 12px; }

#bar { padding-top: env(safe-area-inset-top); border-block-end: 1px solid var(--line); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding-block: 4px;
  font-weight: 700; font-size: 1.0625rem; letter-spacing: .01em; white-space: nowrap; color: var(--text); text-decoration: none;
}
.brand::before { content: ""; inline-size: 26px; block-size: 26px; border-radius: 8px; background: var(--accent); }
.brand::after {
  content: ""; position: absolute; inset-inline-start: 9px; top: calc(50% - 9px); inline-size: 6px; block-size: 12px;
  border: solid var(--on-accent); border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.langs { display: flex; gap: 4px; }
.langbtn {
  min-height: 44px; min-width: 44px; padding: 6px 12px; margin-block: 6px;
  font: inherit; font-weight: 600; color: var(--text); background: none;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.langbtn[aria-pressed="true"] { color: var(--link); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.banner {
  margin: 0; padding-block: 10px; color: var(--unc-text); background: var(--unc-bg); font-size: 0.9375rem;
}

h1 { font-size: 1.625rem; line-height: 1.2; letter-spacing: -.01em; margin-block: 24px 10px; }
h2 { font-size: 1.1875rem; line-height: 1.3; margin-block: 24px 8px; }
h3 { font-size: 1.0625rem; line-height: 1.35; margin-block: 16px 4px; }
h1:focus:not(:focus-visible) { outline: none; }
p { margin-block: 0 12px; }
.lead { font-size: 1.0625rem; color: var(--muted); }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.note, .notice {
  padding: 12px; border-radius: 10px; background: var(--bg); border-inline-start: 4px solid var(--accent);
}
.notes { margin-block-start: 24px; color: var(--muted); font-size: 0.9375rem; }
.notes .srclink { font-size: 1.0625rem; margin-block-end: 12px; }
a { color: var(--link); text-underline-offset: 0.15em; }
.err { color: var(--no-text); font-weight: 600; margin-block: 6px 0; }
.err[hidden] { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* a visible label whose hidden file input has the focus (About: Restore) */
label:has(+ .sr-only:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
/* forced colours: a pressed button is marked by its border, not by colour alone */
@media (forced-colors: active) { [aria-pressed="true"] { border-block-end: 4px double ButtonText; } .tab[aria-current] { text-decoration: underline; } }

.stack { display: flex; flex-direction: column; gap: 12px; margin-block: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; margin-block: 8px; }
.row { display: flex; gap: 12px; align-items: stretch; }
.row > * { flex: 1 1 0; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 12px 16px; width: 100%;
  font: inherit; font-weight: 600; line-height: 1.25; text-decoration: none;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: background-color 150ms, border-color 150ms;
}
.btn.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); box-shadow: var(--shadow); }
.btn.danger { color: var(--no-text); border-color: var(--no-text); background: var(--no-bg); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.navbtn {
  display: flex; flex-direction: column; gap: 2px; min-height: 48px; padding: 16px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); text-decoration: none; transition: border-color 150ms;
}
.navbtn-title { font-weight: 700; color: var(--link); }
.navbtn { position: relative; padding-inline-end: 40px; }
.navbtn::after {
  content: ""; position: absolute; inset-inline-end: 18px; top: calc(50% - 5px); inline-size: 8px; block-size: 8px;
  border: solid var(--border); border-width: 2px 2px 0 0; transform: rotate(45deg);
}
[dir="rtl"] .navbtn::after { transform: rotate(-135deg); }
.navbtn-hint { color: var(--muted); font-size: 0.9375rem; }
#next { margin-block: 16px 20px; }
#next.has { min-height: 20rem; }

.actionbar {
  position: sticky; bottom: 0; z-index: 1;
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-block: 20px 0; margin-inline: -16px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-block-start: 1px solid var(--line);
}
.actionbar > .btn { flex: 1 1 0; min-width: 0; }
.actionbar.is-warning { flex-direction: column; background: var(--no-bg); border-block-start: 2px solid var(--no-text); }
.actionbar .warn-text { margin: 0; color: var(--no-text); font-weight: 600; }
.ask { display: flex; flex-direction: column; gap: 12px; }

.form { margin-block: 8px 0; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend { padding: 0; margin-block-end: 8px; font-weight: 700; max-width: 100%; white-space: normal; }
.group > .choice + .choice { margin-block-start: 8px; }
.field { margin-block: 0 16px; }
.field > label { display: block; font-weight: 600; margin-block-end: 6px; }
input[type="text"], input[type="email"], select {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; font-size: max(1rem, 16px); color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border: 2px solid var(--no-text); }
input[type="radio"], input[type="checkbox"] {
  flex: none; width: 1.25rem; height: 1.25rem; margin: 0.15em 0 0; accent-color: var(--accent);
}
.choice, .check {
  display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}
.choice:has(input:checked) { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice .key { flex: none; font-weight: 700; min-width: 1.25em; }
.check { font-weight: 400; }

.facts { padding-inline-start: 1.25em; }
.facts li { margin-block-end: 8px; }

/* Badges: text always carries the meaning, colour only adds to it */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.875rem; font-weight: 700;
  line-height: 1.5; vertical-align: baseline;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.no { background: var(--no-bg); color: var(--no-text); }
.badge.unc { background: var(--unc-bg); color: var(--unc-text); }
.badge.est { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.outcome { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.card {
  padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); margin-block: 12px;
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-block-start: 0; }
.warn {
  padding: 12px 16px; margin-block: 12px; border: 2px solid var(--no-text); border-radius: 10px;
  color: var(--no-text); background: var(--no-bg);
}
.warn > p { font-weight: 600; }
.source { display: flex; flex-direction: column; gap: 8px; margin-block-start: 8px; }
.srclink {
  display: block; min-height: 44px; padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--link); background: var(--bg); overflow-wrap: anywhere;
}
.srclink-label { display: block; font-weight: 600; }
.srclink-url { display: block; font-size: 0.875rem; }
.warn .srclink { color: var(--link); }
.quote { margin: 0; }
.quote figcaption { font-size: 0.875rem; color: var(--muted); font-weight: 600; }
.warn .quote figcaption { color: inherit; }
blockquote {
  margin: 4px 0 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--border); color: var(--text);
}
.fold { margin-block: 12px; }
.fold > summary {
  min-height: 48px; padding-block: 12px; cursor: pointer; font-weight: 600; color: var(--link);
}

.status:empty { display: none; }
.status { margin-block: 12px; display: flex; flex-direction: column; gap: 8px; }
.status-text { margin: 0; padding: 12px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-text); font-weight: 600; }

@media (hover: hover) {
  .btn:hover, .navbtn:hover, .choice:hover { border-color: var(--accent); }
  .btn.primary:hover { filter: brightness(1.08); }
}

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