/* Colours and type match Complyvane and clausetenconsulting.com. Fonts are served from this site. */
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/figtree-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/figtree-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/figtree-latin-700-normal.woff2") format("woff2"); }
/* Brand tokens (from clausetenconsulting.com) */
:root {
  --ink: #14263D;
  --deep: #14263D;
  --green: #087F8C;
  --sage: #9FDCE3;
  --paper: #F5F7FA;
  --stone: #EEF3F9;
  --muted: #566170;
  --line: #D6DCE4;
  --flag: #8A5A12;
  --flag-bg: #F6EBD3;
  --ok: #2F6B4F;
  --warn: #9A3B26;
  --display: "Figtree", "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
  --body: "Figtree", "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
  --bar: 64px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; font-family: var(--body); color: var(--ink); background: var(--stone); font-size: 17px; line-height: 1.6; }
a { color: var(--green); }
:focus-visible { outline: 3px solid #087F8C; outline-offset: 3px; border-radius: 3px; }

.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; z-index: 50; }
.skip:focus { top: 12px; }

/* Stage: 3D canvas or 2D picture, fixed behind the story */
.stage { position: fixed; inset: 0; z-index: 0; background: linear-gradient(180deg, #DDE4EC 0%, #EEF3F9 60%); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.2s ease; }
.is-3d-ready #scene { opacity: 1; }
.stage-fallback { position: absolute; inset: 0; overflow: hidden; opacity: 0; transition: opacity .6s ease;
  transform: translate3d(calc(var(--mx, 0) * -14px), calc(var(--my, 0) * -10px), 0); }
.stage-fallback .ph { position: absolute; inset: -6%; background-size: cover; background-position: center; opacity: 0;
  transition: opacity 1.6s ease; will-change: transform, opacity; }
.stage-fallback .ph.on { opacity: 1; animation: road-drift 26s ease-in-out infinite alternate; }
.stage-blur { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) saturate(1.05) brightness(1.04); opacity: 0; transition: opacity .6s ease, background-image .8s ease; }
.is-2d .stage-blur, .is-3d-pending .stage-blur { opacity: 1; }
.is-3d-ready:not(.is-2d) .stage-blur { opacity: 0; }
@media (min-width: 900px) {
  /* the photo sits beside the story panel, so people are never hidden behind it */
  .stage-fallback { left: 34%; top: 0; bottom: 0; right: 0; border-radius: 0; box-shadow: -30px 0 60px rgba(20,38,61,.18); }
  .stage-fallback .ph { inset: -4%; }
}
@keyframes road-drift {
  from { transform: scale(1.02) translate3d(var(--dx0, 0), 0, 0); }
  to   { transform: scale(1.06) translate3d(var(--dx1, 0), var(--dy1, 0), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .stage-fallback { transform: none; }
  .stage-fallback .ph.on { animation: none; }
}
.is-2d #scene { display: none; }
.is-2d .stage-fallback, .is-3d-pending .stage-fallback { opacity: 1; }
.stage-veil { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(239,238,233,.55) 0%, rgba(239,238,233,0) 46%); }

.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 18px; justify-content: space-between;
  padding: 12px 24px; background: linear-gradient(180deg, rgba(250,248,243,.92), rgba(250,248,243,0)); }
.brand { font-family: var(--display); font-weight: 600; font-size: 21px; color: var(--ink); text-decoration: none; }
.status { margin: 0; font-size: 13px; color: var(--muted); max-width: 46ch; text-align: right; }

main { position: relative; z-index: 2; }
.chapter { min-height: 120vh; padding: 96px 24px calc(var(--bar) + 70px); display: flex; align-items: flex-start; }
.chapter.intro { min-height: 115vh; }
.panel { position: relative; width: min(520px, 100%); background: rgba(250,248,243,.94); border: 1px solid var(--line);
  border-radius: 10px; padding: 28px 30px; box-shadow: 0 30px 60px -40px rgba(20,38,61,.6); backdrop-filter: blur(6px); }
.panel.wide { width: min(640px, 100%); }
h1, h2 { font-family: var(--display); font-weight: 600; line-height: 1.1; color: var(--deep); margin: 0 0 14px; }
h1 { font-size: clamp(38px, 5vw, 58px); letter-spacing: -0.01em; }
h2 { font-size: clamp(28px, 3.4vw, 38px); }
h3 { font-size: 17px; margin: 22px 0 8px; color: var(--deep); }
.lede { font-size: 19px; }
.step { margin: 0 0 6px; font-size: 14px; color: var(--green); font-weight: 600; }
.small { font-size: 14px; color: var(--muted); }
.sample-note { font-size: 14px; color: var(--muted); border-left: 3px solid var(--sage); padding-left: 12px; }

.routes { border: 0; padding: 0; margin: 22px 0 10px; }
.routes legend { font-weight: 600; margin-bottom: 10px; }
.route-options { display: grid; gap: 10px; }
.route { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.route input { margin-top: 5px; accent-color: var(--green); width: 18px; height: 18px; }
.route strong { display: block; }
.route small { display: block; color: var(--muted); font-size: 14px; line-height: 1.45; }
.route:has(input:checked) { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }

.btn { display: inline-block; background: var(--ink); color: #fff; text-decoration: none; border: 0; border-radius: 6px; padding: 12px 20px;
  font: 600 16px var(--body); cursor: pointer; }
.btn:hover { background: var(--green); }
.textlink { display: inline-block; margin: 10px 16px 0 0; font-weight: 500; }

.records { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }
.record { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; font: 500 15px var(--body); color: var(--ink); cursor: pointer; }
.record:hover { border-color: var(--green); }
.tag { font-size: 11px; font-weight: 600; color: var(--flag); background: var(--flag-bg); border-radius: 4px; padding: 2px 6px; letter-spacing: .02em; }

.gapfind { margin-top: 10px; }
.matrix { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; border: 1px solid var(--line); }
.matrix caption { text-align: left; font-size: 13px; color: var(--muted); padding: 0 0 6px; }
.matrix th, .matrix td { padding: 8px 9px; border-bottom: 1px solid var(--stone); text-align: left; vertical-align: top; }
.matrix thead th { background: var(--stone); font-weight: 600; font-size: 13px; }
.matrix tbody th { font-weight: 500; }
.matrix tr.is-gap { background: #FBEDE7; }
.matrix tr.is-gap th { color: var(--warn); }
.matrix tr.is-wrong { background: #F1F4F8; }
.mark { font: 500 13px var(--body); border: 1px solid var(--green); color: var(--green); background: #fff; border-radius: 5px; padding: 5px 8px; cursor: pointer; white-space: nowrap; }
.mark:hover { background: var(--green); color: #fff; }
.feedback { min-height: 1.2em; font-weight: 500; margin: 12px 0 0; }
.fix { border-left: 3px solid var(--green); padding: 2px 0 2px 14px; margin-top: 10px; }
.fix ol { padding-left: 20px; margin: 6px 0; }

.evidence { padding-left: 20px; }
.support { margin-top: 18px; padding-top: 6px; border-top: 1px solid var(--line); }
.decision { font-size: 14px; color: var(--muted); }

/* Controls */
.controls { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; justify-content: center;
  background: rgba(31,42,39,.94); color: #fff; padding: 8px 10px; border-radius: 12px; box-shadow: 0 16px 36px -18px rgba(0,0,0,.6); max-width: calc(100vw - 16px); }
.controls button, .controls select { font: 500 14px var(--body); color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.28); border-radius: 7px; padding: 8px 12px; cursor: pointer; min-height: 40px; }
.controls button:hover { background: rgba(255,255,255,.1); }
.controls button:disabled { opacity: .4; cursor: default; }
.controls select { background: var(--ink); max-width: 210px; }
.route-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sage); }
.dots { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.dots button { min-width: 40px; padding: 8px 10px; }
.dots button[aria-current] { background: #fff; color: var(--ink); }

/* Record dialog */
dialog { border: 0; padding: 0; border-radius: 10px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(20,38,61,.55); }
.doc { padding: 26px 28px; background: #fff; background-image: repeating-linear-gradient(180deg, transparent 0 31px, #E9EEF4 31px 32px); }
.doc-flag { display: inline-block; margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--flag); background: var(--flag-bg); border-radius: 4px; padding: 3px 8px; }
.doc-meta { color: var(--muted); font-size: 14px; margin-top: -6px; }
.fields { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; margin: 16px 0 20px; }
.fields dt { font-weight: 600; font-size: 14px; color: var(--deep); }
.fields dd { margin: 0; font-size: 15px; }
.doc .matrix { margin: 10px 0 16px; }
.noscript { position: relative; z-index: 3; background: #fff; padding: 16px; }

/* Phones and small tablets: picture on top, story underneath */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .stage-veil { background: linear-gradient(180deg, rgba(239,238,233,0) 35%, rgba(239,238,233,.85) 75%); }
  .chapter { min-height: auto; padding: 46vh 12px calc(var(--bar) + 120px); }
  .chapter.intro { min-height: auto; padding-top: 40vh; }
  .panel, .panel.wide { position: relative; top: 0; padding: 22px 18px; }
  .status { display: none; }
  .matrix { font-size: 13px; display: block; overflow-x: auto; }
  .fields { grid-template-columns: 1fr; gap: 2px; }
  .fields dd { margin-bottom: 10px; }
  .controls { bottom: 8px; gap: 5px; padding: 6px; flex-wrap: wrap; width: calc(100vw - 16px); }
  .controls button, .controls select { padding: 6px 9px; min-height: 40px; font-size: 13px; }
  .route-switch span, .route-switch { font-size: 0; }
  .route-switch select { font-size: 13px; }
}
