/* Kenora Funding Navigator.
   Theme A "archive": white ground, black ink, Fraunces headings, the 1948–72 floatplane photo.
   Theme B "night": true black ground, Saira headings, the 2026 aerial. One blue for links in both;
   red only for refusals and programs a source says are closed. */

:root {
  --paper: #ffffff;
  --ink: #111113;
  --ink-2: #44444a;
  --ink-3: #6e6e76;
  --line: #e4e4e8;
  --line-2: #cdcdd3;
  --wash: #f4f4f6;
  --blue: #1f3fe0;
  --blue-soft: #edf0ff;
  --red: #d63a1e;
  --red-soft: #fff1ec;
  --head: "Fraunces", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1200px;
}
.theme-b {
  --paper: #0b0b0d;
  --ink: #f3f3f5;
  --ink-2: #c4c4cc;
  --ink-3: #8d8d97;
  --line: #24242a;
  --line-2: #3a3a42;
  --wash: #141418;
  --blue: #7d93ff;
  --blue-soft: #1a2150;
  --red: #ff7357;
  --red-soft: #2a1410;
  --head: "Saira", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
::selection { background: var(--blue); color: #fff; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
img { max-width: 100%; display: block; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-3); font-size: 14px; }

h1, h2, h3 { font-family: var(--head); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
.theme-a h1, .theme-a h2 { font-variation-settings: "opsz" 96; }
.theme-b h1, .theme-b h2 { font-stretch: 82%; font-weight: 650; letter-spacing: 0; }

/* ─── Header ─── */
.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 60px; }
.mark { font-weight: 600; font-size: 16px; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; }
.mark i { width: 10px; height: 10px; background: var(--blue); display: inline-block; }
.nav { display: flex; gap: 24px; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

/* ─── Intro ─── */
.intro { padding: clamp(36px, 6vw, 72px) 0 clamp(28px, 4vw, 48px); }
.intro-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.intro h1 { font-size: clamp(36px, 4.6vw, 60px); line-height: 1.04; max-width: 13em; }
.lede { font-size: clamp(17px, 1.45vw, 19px); color: var(--ink-2); margin: 20px 0 28px; max-width: 34em; }

.askbox { display: flex; border: 1.5px solid var(--ink); background: var(--paper); border-radius: 4px; overflow: hidden; }
.askbox:focus-within { box-shadow: 0 0 0 4px var(--blue-soft); border-color: var(--blue); }
.askbox textarea { flex: 1; border: 0; resize: none; font: 400 18px/1.45 var(--sans); padding: 16px 18px; min-height: 58px; color: var(--ink); background: transparent; }
.askbox textarea:focus { outline: none; }
.askbox textarea::placeholder { color: var(--ink-3); }
.btn { appearance: none; border: 0; cursor: pointer; background: var(--ink); color: var(--paper); font: 600 16px/1 var(--sans); padding: 0 26px; }
.btn:hover { background: var(--blue); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: progress; }
.try { margin: 14px 0 0; font-size: 15px; color: var(--ink-3); line-height: 1.9; }
.try button, .qlist button { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.try button:hover, .qlist button:hover { text-decoration-thickness: 2px; }
.try .sep { margin: 0 8px; color: var(--line-2); }

.photo { margin: 0; }
.photo img { width: 100%; height: auto; border-radius: 3px; }
.photo figcaption { font-size: 13px; color: var(--ink-3); margin-top: 10px; line-height: 1.45; }

/* Theme B intro: the 2026 aerial behind the question. */
.theme-b .intro { position: relative; padding: clamp(56px, 9vw, 120px) 0 clamp(40px, 6vw, 72px); background: #000; overflow: hidden; }
.theme-b .intro::before { content: ""; position: absolute; inset: 0; background: url(/photos/kenora-aerial.webp) center 40% / cover no-repeat; filter: grayscale(1) contrast(1.1) brightness(0.55); }
.theme-b .intro::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(11,11,13,0.96) 0%, rgba(11,11,13,0.8) 45%, rgba(20,34,140,0.35) 100%); }
.theme-b .intro > * { position: relative; z-index: 1; }
.theme-b .intro-grid { grid-template-columns: minmax(0, 720px); }
.theme-b .intro h1 { font-size: clamp(42px, 6vw, 84px); line-height: 0.98; max-width: 11em; }
.theme-b .photo-credit { position: absolute; right: var(--gutter); bottom: 14px; z-index: 1; font-size: 12px; color: #9a9aa4; }
.theme-b .askbox { border-color: #fff; background: #fff; }
.theme-b .askbox textarea { color: #111; }
.theme-b .btn { background: var(--blue); color: #0b0b0d; }
.theme-b .btn:hover { background: #fff; color: #0b0b0d; }

/* ─── Working + answer ─── */
.answer-sec .result { margin: 0 0 clamp(32px, 5vw, 56px); scroll-margin-top: 20px; }
.theme-b .answer-sec .result { margin-top: 32px; }
.result:empty { display: none; }
.status { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 16px; padding: 18px 0; border-top: 1px solid var(--line); }
.status .bar { flex: 0 0 120px; height: 3px; background: var(--line); position: relative; overflow: hidden; border-radius: 2px; }
.status .bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--blue); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .status .bar::after { animation: none; width: 100%; opacity: 0.4; } }

.answer { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; border-top: 1px solid var(--line); padding-top: 24px; }
.answer-q { font-size: 14px; color: var(--ink-3); margin: 0 0 10px; }
.answer-text { font-size: 19px; line-height: 1.6; }
.theme-a .answer-text { font-family: var(--head); font-variation-settings: "opsz" 18; font-size: 20px; }
.answer-text p { margin: 0 0 0.8em; }
.answer-text ul { padding-left: 1.2em; margin: 0 0 0.8em; }
.answer-text li { margin: 0.2em 0; }
.answer-text strong { font-weight: 600; }
sup.fn { font: 600 12px/1 var(--sans); margin-left: 2px; }
sup.fn a { text-decoration: none; padding: 1px 4px; border-radius: 3px; background: var(--blue-soft); }
sup.fn a:hover, sup.fn a.lit { background: var(--blue); color: #fff; }
.meta { margin-top: 18px; font-size: 14px; color: var(--ink-3); }
.meta b { color: var(--ink-2); font-weight: 500; }
.meta .warn { color: var(--red); }

.refs { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.ref { display: grid; grid-template-columns: 26px 1fr; gap: 0 12px; padding: 14px 16px 14px 12px; border: 1px solid var(--line); border-radius: 4px; scroll-margin-top: 20px; transition: border-color 0.15s, background 0.15s; }
.ref.has-cover { grid-template-columns: 26px 1fr 64px; }
.ref.lit, .ref:target { border-color: var(--blue); background: var(--blue-soft); }
.ref-n { font: 600 14px/1.5 var(--sans); color: var(--blue); }
.ref h3 { font: 600 15.5px/1.4 var(--sans); margin: 0; }
.ref h3 a { color: var(--ink); text-decoration: none; }
.ref h3 a:hover { text-decoration: underline; }
.ref .src { font-size: 13.5px; color: var(--ink-3); margin: 3px 0 8px; }
.ref blockquote { margin: 0 0 6px; padding-left: 10px; border-left: 2px solid var(--line-2); font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.ref .cover { grid-row: 1 / span 3; grid-column: 3; width: 64px; border: 1px solid var(--line); border-radius: 2px; align-self: start; }
.flag { display: inline-block; font-size: 13px; font-weight: 500; color: var(--red); background: var(--red-soft); padding: 3px 7px; border-radius: 3px; margin: 0 0 8px; }

.refusal { border-top: 1px solid var(--line); padding-top: 22px; max-width: 46em; }
.refusal h2 { font-size: clamp(26px, 3vw, 34px); }
.refusal h2 span { color: var(--red); }
.refusal p { color: var(--ink-2); margin: 12px 0 0; }
.error { border: 1px solid var(--red); background: var(--red-soft); padding: 14px 16px; border-radius: 4px; }

/* ─── Sections ─── */
.sec { padding: clamp(40px, 6vw, 80px) 0; border-top: 1px solid var(--line); }
.sec h2 { font-size: clamp(26px, 2.8vw, 36px); line-height: 1.15; margin-bottom: 8px; }
.sec .intro-p { color: var(--ink-2); max-width: 44em; margin: 0 0 28px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 3vw, 40px); margin-top: 28px; }
.fact { margin: 0; display: grid; grid-template-columns: 76px 1fr; gap: 16px; align-items: start; }
.fact img { width: 76px; border: 1px solid var(--line); border-radius: 2px; box-shadow: 0 6px 16px -10px rgba(0,0,0,0.35); }
.fact blockquote { margin: 0; font-family: var(--head); font-size: 20px; line-height: 1.35; }
.theme-a .fact blockquote { font-variation-settings: "opsz" 36; }
.theme-b .fact blockquote { font-family: var(--sans); font-size: 18px; }
.fact figcaption { font-size: 13.5px; color: var(--ink-3); margin-top: 10px; }

.qgroups { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; margin-top: 24px; }
.qgroups h3 { font: 600 15px/1.3 var(--sans); margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.qlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: 15.5px; line-height: 1.45; }

.shelf-track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 24px 20px; margin-top: 8px; }
.shelf-end { margin: 28px 0 0; color: var(--ink-2); }
.shelf a { text-decoration: none; color: var(--ink); display: block; }
.shelf img { width: 100%; aspect-ratio: 8.5 / 11; object-fit: contain; object-position: bottom; background: transparent; border: 1px solid var(--line); border-radius: 2px; box-shadow: 0 10px 24px -14px rgba(0,0,0,0.45); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.shelf a:hover img { transform: translateY(-4px); box-shadow: 0 16px 28px -14px rgba(0,0,0,0.5); }
.shelf span { display: block; font-size: 13.5px; line-height: 1.35; margin-top: 10px; }
.shelf small { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.note { max-width: 46em; color: var(--ink-2); }

/* ─── Sources page ─── */
.page-head { padding: clamp(36px, 5vw, 64px) 0 24px; }
.page-head h1 { font-size: clamp(34px, 4vw, 52px); }
.page-head p { color: var(--ink-2); max-width: 44em; margin: 14px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; }
.filters button { appearance: none; cursor: pointer; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2); font: 500 14px/1 var(--sans); padding: 9px 12px; border-radius: 20px; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.filters button span { opacity: 0.6; margin-left: 4px; }
.srcs { width: 100%; border-collapse: collapse; margin: 16px 0 72px; }
.srcs th { text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-3); padding: 0 16px 10px 0; border-bottom: 1px solid var(--ink); }
.srcs td { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 15px; }
.srcs td.t a { font-weight: 600; color: var(--ink); text-decoration: none; }
.srcs td.t a:hover { color: var(--blue); text-decoration: underline; }
.srcs td.t .pub { display: block; font-size: 13.5px; color: var(--ink-3); margin-top: 3px; }
.srcs td.m { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.srcs td .flag { margin: 6px 0 0; }
.srcs tr[hidden] { display: none; }

/* ─── About ─── */
.prose { max-width: 42em; padding-bottom: 80px; }
.prose h2 { font-size: clamp(24px, 2.6vw, 30px); margin: 44px 0 10px; }
.prose p, .prose li { color: var(--ink-2); }
.prose strong { color: var(--ink); }
.prose ol { padding-left: 1.2em; }
.prose li { margin: 6px 0; }
.gloss { display: grid; grid-template-columns: 96px 1fr; margin: 14px 0 0; border-top: 1px solid var(--line); }
.gloss dt, .gloss dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; font-size: 15px; }
.gloss dt { font-weight: 600; color: var(--ink); }
.gloss dd { color: var(--ink-2); }

/* ─── Footer ─── */
.foot { border-top: 1px solid var(--line); padding: 28px 0 40px; font-size: 14px; color: var(--ink-3); }
.foot .wrap { display: flex; justify-content: space-between; gap: 12px 32px; flex-wrap: wrap; }
.foot p { margin: 0; max-width: 46em; }

/* ─── Tap targets: a 44px hit area around small links and buttons, without moving anything. ─── */
.nav a, .foot a, .try button, .qlist button, .filters button, .meta a, .gap a { position: relative; }
.nav a::after, .foot a::after, .try button::after, .qlist button::after, .filters button::after, .meta a::after, .gap a::after {
  content: ""; position: absolute; left: -6px; right: -6px; top: 50%; height: 44px; min-height: 100%; transform: translateY(-50%);
}
.foot a::after, .meta a::after, .gap a::after { left: -2px; right: -2px; }

/* ─── What the documents did not cover, and the shared-link prompt ─── */
.gap { margin: 4px 0 0; padding: 10px 0 10px 14px; border-left: 3px solid var(--blue); font-size: 16px; color: var(--ink-2); max-width: 40em; }
.gap b { color: var(--ink); font-weight: 600; }
.status.shared { padding: 14px 0; }

/* ─── Small screens ─── */
@media (max-width: 960px) {
  .intro-grid { grid-template-columns: 1fr; }
  .theme-a .photo { order: -1; }
  .answer { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .qgroups { grid-template-columns: 1fr 1fr; }
  .shelf-track { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .nav { gap: 16px; }
  .askbox { flex-direction: column; }
  .askbox textarea { flex: none; } /* in a column, flex-basis 0 would override the auto-grow height */
  .askbox .btn { padding: 15px; }
  .try { line-height: 1.5; }
  .try .sep { display: none; }
  .try button { display: block; margin: 8px 0 0; }
  .qgroups { grid-template-columns: 1fr; }
  .shelf-track { display: flex; overflow-x: auto; gap: 14px; padding-bottom: 8px; scroll-snap-type: x mandatory; margin-right: calc(-1 * var(--gutter)); }
  .shelf-track a { flex: 0 0 116px; scroll-snap-align: start; }
  .srcs thead { display: none; }
  .srcs tr { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .srcs td { display: block; border: 0; padding: 2px 0; }
  .srcs td.m { white-space: normal; }
  .ref.has-cover { grid-template-columns: 26px 1fr 52px; }
  .ref .cover { width: 52px; }
  .theme-b .photo-credit { position: static; padding: 0 var(--gutter); margin-top: 16px; }
}

/* ─── The one scroll act: the report shelf as a pinned pan rail (desktop, motion allowed) ───
   app.js adds .is-pan; without JS, on phones, or with reduced motion the grid above stands. */
@media (min-width: 1081px) and (prefers-reduced-motion: no-preference) {
  .rail.is-pan { min-height: calc(100svh + 12 * 24vh); padding: 0; }
  .rail.is-pan .rail-stage { position: sticky; top: 0; height: 100svh; max-width: none; padding: 0; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
  .rail.is-pan .shelf { display: flex; align-items: center; gap: 48px; width: max-content; padding-left: max(48px, calc((100vw - 1200px) / 2 + 48px)); padding-right: 10vw; will-change: transform; }
  .rail.is-pan .shelf-head { width: min(30vw, 440px); flex: none; }
  .rail.is-pan .shelf-head .intro-p { margin-bottom: 0; }
  .rail.is-pan .shelf-track { display: flex; gap: 36px; margin: 0; }
  .rail.is-pan .shelf-track a { flex: none; width: calc(54svh * 8.5 / 11); }
  .rail.is-pan .shelf-track img { height: 54svh; width: 100%; }
  .rail.is-pan .shelf-end { width: min(22vw, 320px); flex: none; margin: 0; font-family: var(--head); font-size: 24px; line-height: 1.3; color: var(--ink); }
  .rail.is-pan .shelf-end a { display: block; margin-top: 12px; font-family: var(--sans); font-size: 16px; }
}
