/*
  The Waypoint design system (docs/design.md, ADR-0010). One hand-written
  stylesheet, no framework and no build step. It is served as a separate
  file rather than inlined into every page so browsers cache it once: the
  runner is walked dozens of times a day and every screen after the first
  should paint instantly.

  Layout is prototype variant "G": navy app bar, one white card on a grey
  page, progress line across the top edge of the card.
*/

/* Inter, self-hosted (docs/design.md): no Google Fonts or any other
   third-party request in production. One variable file per subset covers
   the 400-700 range the design uses. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  --navy: #10233e;
  --ink: #1b2430;
  --muted: #55607a;
  --faint: #96a0b3;
  --blue: #3667d4;
  --blue-tint: #f3f6fd;
  --page: #f2f4f7;
  --card: #ffffff;
  --line: #e3e7ee;
  --triage-bg: #fdf3e2;
  --triage-ink: #9a6a1f;
  --triage-line: #f0dfc0;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Focus is always the accent blue and always visible: the runner is worked
   by keyboard as often as by mouse. */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 0.3rem;
}

/* ---- app bar ---- */

.bar {
  background: var(--navy);
  color: #fff;
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.bar .wordmark {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #fff;
  text-decoration: none;
}
.bar .wordmark svg {
  color: #6c95e8;
  flex: none;
}
.bar .who {
  font-size: 0.85rem;
  color: #9fb0c9;
}
.bar .who strong {
  color: #fff;
  font-weight: 600;
}
.bar .who a {
  color: #9db9f2;
  text-decoration: none;
  margin-left: 0.5rem;
}
.bar .who a:hover {
  text-decoration: underline;
}

/* ---- page and card ---- */

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(20, 30, 55, 0.04),
    0 8px 24px rgba(20, 30, 55, 0.06);
}
.cardbar {
  height: 0.25rem;
  background: #edf0f5;
}
.cardbar i {
  display: block;
  height: 100%;
  background: var(--blue);
}
.meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 2rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.meta .qn {
  color: var(--faint);
  flex: none;
}
.inner {
  padding: 0.9rem 2rem 2rem;
}
.inner > :first-child {
  margin-top: 0;
}
.inner > :last-child {
  margin-bottom: 0;
}

/* On a phone the card is most of the screen, so the generous desktop
   gutters would cost too much of the question. */
@media (max-width: 30rem) {
  main {
    padding: 1.5rem 0.9rem 3rem;
  }
  .bar {
    padding: 0.7rem 1rem;
  }
  .meta {
    padding: 0.9rem 1.2rem 0;
  }
  .inner {
    padding: 0.8rem 1.2rem 1.5rem;
  }
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
  margin: 0 0 1.2rem;
}
h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 0.75rem;
}
p {
  margin: 0 0 1.1rem;
}
.lede {
  color: var(--muted);
}
a {
  color: var(--blue);
}

/* ---- answer affordances ---- */

.answers {
  display: grid;
  gap: 0.55rem;
  margin: 1.4rem 0 0;
  padding: 0;
  list-style: none;
}
.answers a,
.answers button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.95rem 1.15rem;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--card);
  border: 1px solid #cfd6df;
  border-radius: 0.55rem;
  cursor: pointer;
  transition:
    border-color 120ms,
    background 120ms,
    box-shadow 120ms;
}
.answers a:hover,
.answers button:hover {
  border-color: var(--blue);
  background: #f8faff;
  box-shadow: 0 2px 8px rgba(54, 103, 212, 0.1);
}

/* The one committing action on a screen: Start, Continue past the entry
   forms, Copy the record entry. */
button.primary {
  display: block;
  width: 100%;
  padding: 0.95rem 1.15rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 0.55rem;
  cursor: pointer;
  transition: background 120ms;
}
button.primary:hover {
  background: #1b3557;
}

/* Any option that exits to Triage says so before it is clicked
   (docs/design.md): the tag carries text, never colour alone. */
.tag {
  flex: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--triage-bg);
  color: var(--triage-ink);
  border: 1px solid var(--triage-line);
}

/* ---- checklist ---- */

.items {
  list-style: none;
  margin: 0 0 1.9rem;
  padding: 0;
  border-top: 1px solid #edf0f5;
}
.items li {
  border-bottom: 1px solid #edf0f5;
}
.items label {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 0.85rem 0.35rem;
  line-height: 1.5;
  cursor: pointer;
  transition: background 120ms;
}
.items label:hover {
  background: #f5f7fa;
}
.items label:has(input:checked) {
  background: var(--blue-tint);
}
.items input {
  appearance: none;
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.2rem 0 0;
  border: 1.5px solid #b7c0cd;
  border-radius: 0.3rem;
  background: var(--card);
  position: relative;
  transition:
    background 120ms,
    border-color 120ms;
}
.items input:checked {
  background: var(--blue);
  border-color: var(--blue);
}
/* The tick itself, so checked state is never signalled by colour alone. */
.items input:checked::after {
  content: "";
  position: absolute;
  left: 0.4rem;
  top: 0.14rem;
  width: 0.28rem;
  height: 0.58rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---- notices, record text, back ---- */

/* Something needs correcting before the screen can be answered. It stays
   off the amber deliberately: amber means "this exits to Triage" and
   nothing else, or the one colour the design makes load-bearing stops
   meaning anything. */
.notice {
  background: var(--blue-tint);
  border: 1px solid #d4dff7;
  border-left: 3px solid var(--blue);
  border-radius: 0.55rem;
  padding: 0.75rem 1rem;
  color: var(--ink);
  font-weight: 500;
}

textarea,
input[type="password"],
input[type="text"],
.field input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #cfd6df;
  border-radius: 0.55rem;
}
textarea {
  line-height: 1.5;
  resize: vertical;
}

.back {
  margin: 1.5rem 0 0;
}
.back a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.back a::before {
  content: "\2190\00a0";
}
.back a:hover {
  color: var(--navy);
}

/* ---- the pathway list on the landing page ---- */

.pathways {
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.pathways a {
  display: block;
  padding: 1rem 1.15rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #cfd6df;
  border-radius: 0.55rem;
  transition:
    border-color 120ms,
    box-shadow 120ms;
}
.pathways a:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(54, 103, 212, 0.1);
}
.pathways strong {
  display: block;
  font-weight: 600;
}
.pathways span {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- motion (docs/design.md) ----

   Light and directional, one axis, ~180ms: the card leaves towards the
   answer and the next screen arrives from the other side. Browsers without
   View Transitions simply navigate instantly, which is the fallback the
   design asks for. */

@view-transition {
  navigation: auto;
}

main {
  view-transition-name: wp-main;
}
.cardbar i {
  view-transition-name: wp-progress;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

/* The progress line morphs its width rather than jumping or cross-fading:
   hold both snapshots opaque and let the group animate the geometry, on
   the same timing as the card. */
::view-transition-group(wp-progress) {
  animation-duration: 180ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
::view-transition-old(wp-progress),
::view-transition-new(wp-progress) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(wp-main) {
  animation: 180ms cubic-bezier(0.4, 0, 0.2, 1) both wp-leave;
}
::view-transition-new(wp-main) {
  animation: 180ms cubic-bezier(0.4, 0, 0.2, 1) both wp-arrive;
}

@keyframes wp-leave {
  to {
    opacity: 0;
    transform: translateX(-8px);
  }
}
@keyframes wp-arrive {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
}

/* Back reverses the axis. */
html[data-nav="back"]::view-transition-old(wp-main) {
  animation-name: wp-leave-back;
}
html[data-nav="back"]::view-transition-new(wp-main) {
  animation-name: wp-arrive-back;
}
@keyframes wp-leave-back {
  to {
    opacity: 0;
    transform: translateX(8px);
  }
}
@keyframes wp-arrive-back {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  * {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
