@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Flow engine — the "Decision Guide" explainer format.

   A top-down decision tree: one question at a time in the centre column,
   a live path rail on the left showing the answers given so far, and a
   terminal "determination" card with its own standards and sources.

   Shares the Society & AI token set with engine.css / timeline-engine.css
   so all three explainer formats read as one product. */

:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #d2d2d7;
  --line-soft: rgba(0, 0, 0, 0.08);
  --surface: #ffffff;
  --surface-alt: #f5f5f7;
  --brand: #005EA2;
  --brand-soft: rgba(0, 94, 162, 0.08);

  /* Determination colours, by how constrained the answer is. */
  --verdict-stop: #b3261e;
  --verdict-stop-soft: rgba(179, 38, 30, 0.08);
  --verdict-caution: #9a6700;
  --verdict-caution-soft: rgba(154, 103, 0, 0.09);
  --verdict-clear: #1d8a4d;
  --verdict-clear-soft: rgba(29, 138, 77, 0.09);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;

  --topbar-height: 68px;
  --rail-width: 268px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.fl-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.fl-topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}

.fl-topbar-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.fl-topbar-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  letter-spacing: -0.005em;
  color: var(--muted);
}

.fl-topbar-lead { min-width: 0; flex: 1 1 auto; }
.fl-topbar-lead .fl-topbar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.fl-btn {
  font-family: var(--font);
  font-size: 0.84375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: 980px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.fl-btn:hover { background: #ebebef; }
.fl-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fl-btn[hidden] { display: none; }

.fl-btn--primary { background: var(--brand); color: #fff; }
.fl-btn--primary:hover { background: #004c85; }

/* ---------- Body: rail + stage ---------- */
.fl-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
}

/* ---------- Path rail ---------- */
.fl-rail {
  border-right: 1px solid var(--line-soft);
  background: var(--surface-alt);
  padding: 1.25rem 1.1rem 1.5rem;
  overflow-y: auto;
}

.fl-rail-label {
  margin: 0 0 0.9rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.fl-progress-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
  margin-bottom: 1.2rem;
}
.fl-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.32s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.fl-path { list-style: none; margin: 0; padding: 0; }

.fl-path-item {
  position: relative;
  padding: 0 0 1rem 1.4rem;
}
/* The connecting spine between answered steps. */
.fl-path-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: -2px;
  width: 1px;
  background: var(--line);
}
.fl-path-item:last-child::before { display: none; }

.fl-path-dot {
  position: absolute;
  left: 0;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
}
.fl-path-item--current .fl-path-dot {
  background: var(--surface);
  border: 2px solid var(--brand);
}

.fl-path-q {
  display: block;
  margin: 0 0 0.2rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.fl-path-a {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.fl-path-a:hover { color: var(--brand); text-decoration: underline; }
.fl-path-a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
.fl-path-item--current .fl-path-a { color: var(--muted); font-weight: 400; font-style: italic; cursor: default; }
.fl-path-item--current .fl-path-a:hover { text-decoration: none; color: var(--muted); }

.fl-rail-note {
  margin: 1.4rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------- Stage ---------- */
.fl-stage {
  overflow-y: auto;
  padding: clamp(1.75rem, 4vw, 3rem) clamp(1.25rem, 4vw, 3rem) 4rem;
}

/* Each screen fades up as it replaces the last. */
.fl-screen {
  max-width: 720px;
  margin: 0 auto;
  animation: fl-rise 0.3s cubic-bezier(0.25, 0.1, 0.25, 1) both;
}
@keyframes fl-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* The engine moves focus to each new screen's heading so keyboard and
   screen-reader users land on the question rather than on a button that no
   longer exists. It is a programmatic target, not a control, so it should
   not paint a focus ring — the announcement is the point, not the outline. */
.fl-screen h2[tabindex="-1"]:focus { outline: none; }

/* ---------- Question ---------- */
.fl-step-index {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brand);
}

.fl-question {
  margin: 0 0 0.85rem;
  font-size: clamp(1.45rem, 3vw, 1.95rem);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.026em;
  text-wrap: pretty;
}

.fl-question-help {
  margin: 0 0 1.9rem;
  max-width: 62ch;
  font-size: 1rem;
  line-height: 1.62;
  letter-spacing: -0.008em;
  color: var(--muted);
}
.fl-question-help strong { color: var(--ink); font-weight: 600; }

.fl-options { display: grid; gap: 0.75rem; }

.fl-option {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.05rem 1.2rem;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.fl-option:hover {
  border-color: rgba(0, 94, 162, 0.5);
  background: var(--brand-soft);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}
.fl-option:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.fl-option-label {
  display: block;
  font-size: 1.0125rem;
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: -0.013em;
  margin-bottom: 0.25rem;
}

.fl-option-detail {
  display: block;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
}

/* An expandable footnote under a question, for the definitional detail
   that would otherwise bloat the help text. */
.fl-aside {
  margin-top: 1.6rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface-alt);
  overflow: hidden;
}
.fl-aside summary {
  cursor: pointer;
  padding: 0.8rem 1rem;
  font-size: 0.84375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  list-style: none;
}
.fl-aside summary::-webkit-details-marker { display: none; }
.fl-aside summary::before { content: '＋  '; color: var(--brand); font-weight: 600; }
.fl-aside[open] summary::before { content: '－  '; }
.fl-aside summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.fl-aside-body {
  padding: 0 1rem 1rem;
  font-size: 0.875rem;
  line-height: 1.62;
  color: var(--muted);
}
.fl-aside-body p { margin: 0 0 0.7rem; }
.fl-aside-body p:last-child { margin-bottom: 0; }
.fl-aside-body strong { color: var(--ink); font-weight: 600; }

/* ---------- Determination (terminal node) ---------- */
.fl-verdict-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.fl-verdict-tag::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.fl-verdict--stop .fl-verdict-tag { color: var(--verdict-stop); background: var(--verdict-stop-soft); }
.fl-verdict--caution .fl-verdict-tag { color: var(--verdict-caution); background: var(--verdict-caution-soft); }
.fl-verdict--clear .fl-verdict-tag { color: var(--verdict-clear); background: var(--verdict-clear-soft); }

.fl-verdict-title {
  margin: 0 0 0.9rem;
  font-size: clamp(1.5rem, 3.1vw, 2.05rem);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.028em;
  text-wrap: pretty;
}

.fl-verdict-lede {
  margin: 0 0 1.8rem;
  max-width: 64ch;
  font-size: 1.0625rem;
  line-height: 1.62;
  letter-spacing: -0.009em;
  color: var(--muted);
}
.fl-verdict-lede strong { color: var(--ink); font-weight: 600; }

.fl-block { margin-bottom: 1.9rem; }

.fl-block-label {
  margin: 0 0 0.85rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.fl-steps { margin: 0; padding: 0; list-style: none; counter-reset: fl-step; }
.fl-steps li {
  counter-increment: fl-step;
  position: relative;
  padding: 0 0 0.9rem 2.1rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  letter-spacing: -0.006em;
}
.fl-steps li::before {
  content: counter(fl-step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fl-steps li:last-child { padding-bottom: 0; }
.fl-steps strong { font-weight: 600; }

/* A named rule or standard the determination rests on. */
.fl-standard {
  border-left: 2px solid var(--brand);
  padding: 0.1rem 0 0.1rem 1rem;
  margin-bottom: 1.1rem;
}
.fl-standard:last-child { margin-bottom: 0; }
.fl-standard h4 {
  margin: 0 0 0.3rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.fl-standard p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}

/* Attribution / disclosure line the reader can copy verbatim. */
.fl-snippet {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
.fl-snippet-note {
  margin: 0.55rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--faint);
}

.fl-sources { margin: 0; padding: 0; list-style: none; }
.fl-sources li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.84375rem;
  line-height: 1.55;
}
.fl-sources li:last-child { border-bottom: 0; }
.fl-sources a { color: var(--brand); text-decoration: none; font-weight: 500; }
.fl-sources a:hover { text-decoration: underline; }
.fl-sources-cite { color: var(--muted); }

.fl-verdict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2.2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line-soft);
}

/* ---------- Scope note shown on the first screen ---------- */
.fl-scope {
  margin: 0 0 1.9rem;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--brand);
  border-radius: 0 10px 10px 0;
  background: var(--surface-alt);
  font-size: 0.84375rem;
  line-height: 1.6;
  color: var(--muted);
}
.fl-scope strong { color: var(--ink); font-weight: 600; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .fl-body { grid-template-columns: 1fr; }
  .fl-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: 0.9rem 1.25rem 1rem;
    max-height: 38vh;
  }
  .fl-rail-note { display: none; }

  /* Let the bar wrap to two rows rather than squeezing a long title into a
     three-line column beside the buttons. */
  .fl-topbar {
    height: auto;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.8rem 1.25rem;
  }
  .fl-topbar-title { font-size: 1.0625rem; }
  .fl-topbar-subtitle { display: none; }
  .fl-topbar-actions { flex-wrap: wrap; gap: 0.4rem; }
  .fl-btn { font-size: 0.8125rem; padding: 0.42rem 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fl-screen { animation: none; }
  .fl-option, .fl-progress-fill { transition: none; }
  .fl-option:hover { transform: none; }
}

@media print {
  .fl-rail, .fl-topbar-actions, .fl-verdict-actions { display: none; }
  .fl-body { display: block; }
  .fl-stage { overflow: visible; padding: 0; }
}
