/* The Quiet Soldier: exhibition styles
   Settings are applied as data attributes on <html>:
   data-tint, data-font, data-size, data-spacing, data-motion */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=IM+Fell+English:ital@0;1&family=Lexend:wght@400;600&display=swap');

:root {
  /* Paper and ink */
  --paper: #F3EDE2;
  --paper-deep: #E6DECB;
  --card: #FFFDF8;
  --ink: #1F1B16;
  --ink-soft: #3A352B;
  --muted: #5A5147;
  --rule: #D6CCB4;
  --rule-strong: #8C8169;
  /* Accents */
  --khaki: #4A5230;      /* done, guided route */
  --poppy: #A3261C;      /* primary action, you are here */
  --link: #8A2A1E;
  --link-hover: #5E1C14;
  --focus: #1F4E8C;
  --gold: #F0C24B;
  /* Badges */
  --badge-archival: #E3DCC6;
  --badge-family: #E9D8C8;
  --badge-unit: #D8DFE6;
  --badge-ai: #F0C24B;
  /* Type */
  --font-body: 'Atkinson Hyperlegible', Verdana, sans-serif;
  --font-display: 'IM Fell English', Georgia, serif;
  --scale: 1;
  --leading: 1.55;
  --measure: 66ch;
  --radius: 10px;
  --tap: 48px;
  color-scheme: light;
}

/* Page tints */
html[data-tint="blue"]   { --paper: #DCE8F0; --paper-deep: #C9DAE6; --card: #F4F9FC; --rule: #B5C6D2; }
html[data-tint="yellow"] { --paper: #F7F0C6; --paper-deep: #EDE3A8; --card: #FFFCE8; --rule: #D9CD8E; }
html[data-tint="green"]  { --paper: #E1EDD9; --paper-deep: #CFE0C4; --card: #F6FBF2; --rule: #B8CCAA; }
html[data-tint="rose"]   { --paper: #F2E1DE; --paper-deep: #E6CCC7; --card: #FCF5F4; --rule: #D4B6B0; }
html[data-tint="night"] {
  --paper: #16140F; --paper-deep: #22201A; --card: #2A261D;
  --ink: #F3EDE2; --ink-soft: #D9CFBC; --muted: #B8AE9C;
  --rule: #3A352B; --rule-strong: #6B6252;
  --link: #F0C24B; --link-hover: #FFD86B; --focus: #F0C24B;
  --poppy: #C2392D; --khaki: #8E9A5B; --on-khaki: #16140F;
  color-scheme: dark;
}
/* "Same as my device": follows the system or viewer theme */
@media (prefers-color-scheme: dark) { html[data-tint="auto"]:not([data-theme="light"]) {
  --paper: #16140F; --paper-deep: #22201A; --card: #2A261D;
  --ink: #F3EDE2; --ink-soft: #D9CFBC; --muted: #B8AE9C;
  --rule: #3A352B; --rule-strong: #6B6252;
  --link: #F0C24B; --link-hover: #FFD86B; --focus: #F0C24B;
  --poppy: #C2392D; --khaki: #8E9A5B; --on-khaki: #16140F;
  color-scheme: dark;
} }
html[data-tint="auto"][data-theme="dark"] {
  --paper: #16140F; --paper-deep: #22201A; --card: #2A261D;
  --ink: #F3EDE2; --ink-soft: #D9CFBC; --muted: #B8AE9C;
  --rule: #3A352B; --rule-strong: #6B6252;
  --link: #F0C24B; --link-hover: #FFD86B; --focus: #F0C24B;
  --poppy: #C2392D; --khaki: #8E9A5B; --on-khaki: #16140F;
  color-scheme: dark;
}


/* Fonts */
html[data-font="plain"]   { --font-display: 'Atkinson Hyperlegible', Verdana, sans-serif; }
html[data-font="lexend"]  { --font-body: 'Lexend', Verdana, sans-serif; --font-display: 'Lexend', Verdana, sans-serif; }

/* Text size and spacing */
html[data-size="125"] { --scale: 1.25; }
html[data-size="150"] { --scale: 1.5; }
html[data-size="175"] { --scale: 1.75; }
html[data-size="200"] { --scale: 2; }
html[data-spacing="wide"] { --leading: 1.9; letter-spacing: 0.02em; word-spacing: 0.08em; }

/* Motion */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) *, html:not([data-motion="full"]) *::before, html:not([data-motion="full"]) *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(112.5% * var(--scale)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); line-height: var(--leading);
  display: flex; flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; margin: 0; text-wrap: balance; }
p { margin: 0; max-width: var(--measure); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 12px; color: var(--paper); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px; border-radius: 8px;
  font: inherit; font-size: 1rem; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
}
.btn:hover { background: var(--paper-deep); color: var(--ink); }
.btn--primary { background: var(--poppy); border-color: var(--poppy); color: #FFFFFF; }
.btn--primary:hover { background: #82201A; border-color: #82201A; color: #FFFFFF; }
.btn--dark { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn--dark:hover { background: var(--ink-soft); color: var(--paper); }
.btn svg { flex-shrink: 0; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule-strong); background: var(--card); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--paper-deep); }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-header__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.site-title { font-family: var(--font-display); font-size: 1.45rem; color: var(--ink); text-decoration: none; white-space: nowrap; min-width: 0; }
@media (max-width: 400px) { .site-title { white-space: normal; } }
.site-title:hover { color: var(--ink); text-decoration: underline; }
.site-header__right { display: flex; align-items: center; gap: 14px; }
.saved-note { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }
.visitor-chip { font-size: 0.9rem; color: var(--muted); }
@media (max-width: 640px) { .saved-note, .visitor-chip { display: none; } .site-title { font-size: 1.2rem; } }

main { flex: 1 0 auto; }
.wrap { width: min(1180px, 100%); margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }

/* Truth badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; justify-self: start;
  padding: 3px 12px 3px 8px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; color: #1F1B16; line-height: 1.4;
}
.badge--archival { background: var(--badge-archival); }
.badge--family { background: var(--badge-family); }
.badge--unit { background: var(--badge-unit); }
.badge--place { background: var(--badge-unit); }
.badge--ai { background: var(--badge-ai); outline: 2px dashed #1F1B16; outline-offset: -2px; }

/* Settings dialog */
.settings {
  width: min(640px, calc(100% - 32px)); max-height: calc(100% - 32px);
  padding: 0; border: 1px solid var(--rule-strong); border-radius: 14px;
  background: var(--card); color: var(--ink);
}
.settings::backdrop { background: rgba(22, 20, 15, 0.6); }
.settings__head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; background: var(--card); border-bottom: 1px solid var(--rule);
}
.settings__head h2 { font-size: 1.8rem; }
.settings__body { padding: 8px 24px 24px; display: grid; gap: 8px; }
.settings fieldset { border: 0; padding: 16px 0 8px; margin: 0; border-bottom: 1px solid var(--rule); }
.settings fieldset:last-of-type { border-bottom: 0; }
.settings legend { font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: 4px; }
.settings .hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 10px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border: 2px solid var(--rule-strong); border-radius: 23px;
  cursor: pointer; background: var(--card);
}
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--ink); background: var(--paper-deep); font-weight: 700; }
.choice:has(input:checked)::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid #5A5147; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 46px; cursor: pointer; }
.toggle input { width: 24px; height: 24px; margin: 0; accent-color: var(--khaki); flex-shrink: 0; }
.settings__foot { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 16px 24px; border-top: 1px solid var(--rule); }
.settings__status { color: var(--muted); font-size: 0.95rem; min-height: 1.5em; }

/* Welcome */
.welcome { background: #16140F; color: #F3EDE2; flex: 1 0 auto; display: flex; flex-direction: column; }
.welcome a { color: #F0C24B; }
.welcome :focus-visible { outline-color: #F0C24B; }
.welcome .site-header { background: #16140F; border-color: #3A352B; }
.welcome .site-title, .welcome .site-title:hover { color: #F3EDE2; }
.welcome .icon-btn { background: transparent; color: #F3EDE2; border-color: #6B6252; }
.welcome .icon-btn:hover { background: #2A261D; }
.welcome__grid {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(24px, 5vw, 64px);
  align-items: center; padding-block: clamp(28px, 6vw, 64px);
}
@media (max-width: 860px) { .welcome__grid { grid-template-columns: 1fr; } .portrait { order: -1; max-width: 220px; justify-self: start; } }
.welcome__dates { color: #B8AE9C; font-size: 1.05rem; margin-bottom: 18px; }
.welcome h1 { font-size: clamp(3rem, 9vw, 5.6rem); line-height: 0.95; margin-bottom: 22px; }
.welcome__lede { font-size: 1.2rem; line-height: 1.5; max-width: 32ch; margin-bottom: 30px; }
.welcome__family { font-size: 1.05rem; line-height: 1.6; max-width: 46ch; margin: -12px 0 28px; padding-left: 14px; border-left: 4px solid #6B6252; color: #D9D0BF; }
.visitor { border: 0; padding: 0; margin: 0 0 26px; }
.visitor legend { color: #B8AE9C; padding: 0; margin-bottom: 10px; font-size: 1rem; }
.visitor .choice { background: transparent; border-color: #6B6252; color: #F3EDE2; }
.visitor .choice:has(input:checked) { background: #2A261D; border-color: #F0C24B; }
.visitor .choice:has(input:checked)::before { background: #F0C24B; }
.visitor .choice:has(input:focus-visible) { outline-color: #F0C24B; }
.welcome__actions { display: flex; flex-wrap: wrap; gap: 14px; }
.welcome .btn { border-color: #F3EDE2; color: #F3EDE2; }
.welcome .btn:hover { background: #2A261D; color: #F3EDE2; }
.welcome .btn--primary { border-color: var(--poppy); color: #FFFFFF; }
.welcome .btn--primary:hover { background: #82201A; }
.portrait { margin: 0; justify-self: center; width: 100%; max-width: 380px; display: grid; gap: 14px; }
.portrait__frame { padding: 16px; background: #EDE6D3; border-radius: 4px; }
.portrait__photo { display: block; width: 100%; height: auto; max-width: 100%; filter: sepia(0.15); }
.portrait__inner { height: 100%; background: #CFC4A8; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; overflow: hidden; color: #3A352B; }
.portrait__inner span { font-weight: 700; margin-bottom: auto; padding-top: 20px; }
.portrait figcaption { display: grid; gap: 8px; color: #B8AE9C; font-size: 0.95rem; }
.key { border-top: 1px solid #3A352B; padding-block: 24px 32px; }
.key h2 { font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; color: #B8AE9C; margin-bottom: 14px; }
.key__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px 28px; }
.key__item { display: grid; gap: 8px; justify-items: start; }
.key__item p { font-size: 0.98rem; line-height: 1.45; }

/* Journey */
.journey { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0; flex: 1 0 auto; }
@media (max-width: 980px) { .journey { grid-template-columns: minmax(0, 1fr); } }
.journey__map { padding: 20px clamp(16px, 3vw, 32px) 28px; display: grid; gap: 14px; align-content: start; }
.journey__map h1 { font-size: clamp(2rem, 4vw, 2.6rem); }
.journey__map p.note { color: var(--muted); }
.map-svg { width: 100%; height: auto; display: block; }
.map-stop { cursor: pointer; }
.map-stop:hover circle.stop { stroke: var(--ink); stroke-width: 4; }
.journey__side { background: var(--card); border-left: 1px solid var(--rule); padding: 24px 28px; display: grid; gap: 14px; align-content: start; }
@media (max-width: 980px) { .journey__side { border-left: 0; border-top: 1px solid var(--rule); } }
.journey__side h2 { font-size: 1.9rem; }
.side-label { color: var(--muted); font-weight: 700; font-size: 0.95rem; }
.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-list a {
  display: grid; grid-template-columns: 2.2em 1fr auto; align-items: center; gap: 8px;
  min-height: 52px; padding: 6px 8px; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none;
}
.chapter-list a:hover { background: var(--paper-deep); }
.chapter-list a[aria-current] { background: #F6E3DF; font-weight: 700; }
html[data-tint="night"] .chapter-list a[aria-current] { background: #3A1F1B; }
@media (prefers-color-scheme: dark) { html[data-tint="auto"]:not([data-theme="light"]) .chapter-list a[aria-current] { background: #3A1F1B; } }
html[data-tint="auto"][data-theme="dark"] .chapter-list a[aria-current] { background: #3A1F1B; }
.chapter-list .n { font-family: var(--font-display); font-size: 1.3rem; color: var(--muted); }
.status { font-size: 0.88rem; color: var(--muted); text-align: right; }
.status--done { color: var(--khaki); font-weight: 700; }
.status--here { color: var(--link); font-weight: 700; }

/* Chapter page */
.chapter-intro { padding-block: clamp(28px, 6vw, 64px); display: grid; gap: 22px; }
.chapter-intro .kicker { color: var(--muted); font-size: 1.05rem; }
.chapter-intro h1 { font-size: clamp(2.6rem, 7vw, 4.4rem); }
.chapter-intro .lede { font-size: 1.25rem; line-height: 1.5; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; color: var(--ink-soft); padding: 0; margin: 0; list-style: none; }
.facts li { display: block; }
.record {
  background: var(--card); border: 1px solid var(--rule-strong); border-radius: 4px;
  padding: 20px 24px; max-width: 760px; display: grid; gap: 12px;
}
.record h2 { font-size: 1.5rem; }
.record table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.record th, .record td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px dotted var(--rule-strong); }
.record th { font-weight: 700; white-space: nowrap; }
.record thead th:first-child { width: 10em; }
@media (max-width: 520px) { .record th { white-space: normal; } .record thead th:first-child { width: 6.5em; } }
.record caption { text-align: left; color: var(--muted); font-size: 0.95rem; padding-bottom: 6px; }
.pending {
  border-left: 4px solid var(--khaki); background: var(--paper-deep);
  padding: 16px 20px; border-radius: 0 8px 8px 0; max-width: 760px;
}
.chapter-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-block: 8px 48px; }

.site-footer { border-top: 1px solid var(--rule); padding: 18px clamp(16px, 3vw, 32px); color: var(--muted); font-size: 0.9rem; }
.welcome + .site-footer { background: #16140F; border-color: #3A352B; color: #B8AE9C; }

/* Print */
@media print {
  .site-header, .settings, .chapter-nav, .site-footer { display: none; }
  body { background: #FFFFFF; color: #000000; }
}

/* Side trips on the journey page */
.side-trips { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.side-trips a { font-weight: 700; }

/* Menu drawer */
.menu-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 24px; background: var(--card); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.menu-btn:hover { background: var(--paper-deep); }
.welcome .menu-btn { background: transparent; color: #F3EDE2; border-color: #6B6252; }
.welcome .menu-btn:hover { background: #2A261D; }
.menu { margin: 0; margin-right: auto; width: min(440px, 100%); max-width: 100%; height: 100%; max-height: none; padding: 0; border: 0; border-right: 1px solid var(--rule-strong); background: var(--card); color: var(--ink); }
.menu[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.menu::backdrop { background: rgba(22, 20, 15, 0.6); }
.menu__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.menu__head h2 { font-size: 1.6rem; }
.menu__body { overflow: auto; padding: 8px 16px 32px; display: grid; gap: 20px; align-content: start; }
.menu__body h3 { font-family: var(--font-body); font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 8px 0 4px; }
.menu__list { list-style: none; margin: 0; padding: 0; display: grid; }
.menu__list a { display: grid; gap: 2px; padding: 10px 8px; min-height: 48px; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.menu__list a:hover { background: var(--paper-deep); }
.menu__list a:hover .menu__t, .menu__list a:focus-visible .menu__t { text-decoration: underline; }
.menu__list a[aria-current="page"] { box-shadow: inset 4px 0 0 var(--poppy); }
.menu__t { font-weight: 700; }
.menu__m { color: var(--muted); font-size: 0.9rem; }
.menu details > summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; padding: 0 8px; font-weight: 700; border: 1px solid var(--rule); border-radius: 8px; }
.menu details[open] > summary { margin-bottom: 4px; }

/* Use it like an app (menu) */
.app-box { display: grid; gap: 10px; padding: 4px 8px 8px; }
.app-box p { margin: 0; }
.app-box .btn { justify-self: start; }
.app-box .btn[disabled] { opacity: 0.7; cursor: progress; }
.app-status:empty { display: none; }
.app-status { font-weight: 700; }
.app-note { color: var(--muted); font-size: 0.9rem; }

/* Install banner */
.install-banner { background: var(--card); color: var(--ink); border-bottom: 3px solid var(--poppy); }
.install-banner__inner { max-width: 1100px; margin: 0 auto; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.install-banner img { border-radius: 12px; }
.install-banner h2 { font-size: 1.3rem; margin: 0 0 4px; }
.install-banner p { margin: 0 0 8px; }
.install-steps { margin: 0 0 8px; padding-left: 1.4em; display: grid; gap: 4px; }
.install-banner__later { min-height: 48px; min-width: 48px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.install-banner__later:hover { background: var(--paper-deep); }
@media (max-width: 600px) {
  .install-banner__inner { grid-template-columns: auto 1fr; }
  .install-banner__later { grid-column: 1 / -1; justify-self: start; }
  .install-banner img { width: 44px; height: 44px; }
}
.welcome .install-banner, .welcome .install-banner h2 { color: var(--ink); }
.welcome .install-banner a { color: var(--link); }
.welcome .install-banner .btn { border-color: var(--ink); color: var(--ink); }
.welcome .install-banner .btn:hover { background: var(--paper-deep); color: var(--ink); }
.welcome .install-banner .btn--primary { border-color: var(--poppy); background: var(--poppy); color: #FFFFFF; }
.welcome .install-banner .btn--primary:hover { background: #82201A; color: #FFFFFF; }

/* Reflow (WCAG 1.4.10, 1.4.12): long words and wider text spacing wrap instead of pushing the page sideways. */
h1, h2, h3, .kicker, .lede, .site-title { overflow-wrap: break-word; }

/* Reflow at the largest text sizes on narrow screens: let long words,
   email addresses and links wrap, and let grid and flex children shrink. */
p, li, dd, dt, a, blockquote, figcaption, summary, legend, label { overflow-wrap: break-word; }
a[href^="mailto:"] { overflow-wrap: anywhere; }
main, main section, main article, .journey__map > *, .journey__side, .journey__side > *, .stories > li, .story > * { min-width: 0; }
@media (max-width: 480px) { .journey__side { padding: 20px 16px; } }
