/* Resilivo landing page. Hand-written, no build step (docs/adr/0011).
   The page is set as a controlled document (docs/adr/0012). */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/assets/fonts/source-serif-4-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/public-sans-latin.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
}

/* Red-pencil corrections on the old plan only. Basic Latin subset. */
@font-face {
  font-family: "Caveat";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/caveat-600-ascii.woff2") format("woff2");
}

:root {
  /* Colour. Pairs used for text are contrast-checked in tests/landing.test.ts.
     Coral marks only what a person has done: a stamp, a status, the one
     action. */
  --paper: #f7f3ea;
  --sheet: #fffdf8;
  --mist: #eee8db;
  --line: #d5ccba;
  --text: #16181c;
  --text-2: #4d4f57;
  --accent: #c9401f;
  --accent-hover: #ae3415;
  --on-accent: #ffffff;
  --accent-text: #b5381a;
  --ink-950: #0c1322;
  --ink-800: #18233a;
  --line-dark: #33405a;
  --on-dark: #f4f0e7;
  --on-dark-2: #b4bac7;
  --accent-on-dark: #ff8a6b;
  --warn-text: #6f4300;
  --warn-bg: #f5e6bf;
  --ok-text: #1f5132;
  --ok-bg: #dce8d3;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans:
    "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --header-h: 60px;
  --gutter: max(20px, env(safe-area-inset-left), env(safe-area-inset-right));
  --section-y: clamp(48px, 8vw, 96px);
  --target: 44px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (min-width: 900px) {
  :root {
    --header-h: 68px;
    --gutter: max(32px, env(safe-area-inset-left), env(safe-area-inset-right));
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  margin: 0;
  counter-reset: page;
  background: var(--paper);
  color: var(--text);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

svg {
  display: block;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.dark :focus-visible {
  outline-color: var(--accent-on-dark);
}

.wrap {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--sheet);
  color: var(--text);
  border: 1px solid var(--text);
  font-weight: 700;
}

.skip:focus {
  top: 12px;
}

/* ---------- Type ---------- */

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 1.2rem + 4.2vw, 3.9rem);
  line-height: 1.06;
}

h2 {
  font-size: clamp(1.6rem, 1.15rem + 2vw, 2.5rem);
  line-height: 1.14;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.35;
}

.lede {
  max-width: 62ch;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  color: var(--text-2);
  text-wrap: pretty;
}

.dark .lede {
  color: var(--on-dark-2);
}

/* The small capitals of form labels, section names and table heads. */
.label,
dt,
.sec-name,
.clause-num,
.layer-name,
cite {
  font: 500 0.75rem/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.caption,
figcaption {
  font-size: 0.8125rem;
  color: var(--text-2);
}

.dark :is(.label, dt, cite, figcaption) {
  color: var(--on-dark-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 2px;
  font: 600 1rem/1.2 var(--sans);
  text-align: center;
  text-decoration: none;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-quiet {
  border-color: var(--text);
}

.btn-quiet:hover {
  background: var(--text);
  color: var(--paper);
}

.btn-small {
  min-height: var(--target);
  padding: 8px 12px;
  white-space: nowrap;
  font-size: 0.9375rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--text);
  padding-top: env(safe-area-inset-top);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: var(--target);
  margin-right: auto;
  font: 600 1.375rem/1 var(--serif);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.seal {
  width: 30px;
  height: 30px;
  flex: none;
}

.seal circle {
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 1.5;
}

.seal .seal-inner {
  stroke-width: 0.75;
}

.seal text {
  font: 600 15px var(--serif);
  fill: var(--accent-text);
}

.site-nav {
  display: none;
}

.site-nav a,
.menu-panel a {
  text-decoration: none;
}

.site-nav a:hover,
.menu-panel a:hover {
  text-decoration: underline;
  text-underline-offset: 5px;
}

.cta-long {
  display: none;
}

/* Too narrow for the wordmark, the action and the menu: the menu keeps Apply. */
@media (max-width: 339px) {
  .site-header .btn {
    display: none;
  }
}

@media (min-width: 400px) {
  .cta-short {
    display: none;
  }

  .cta-long {
    display: inline;
  }
}

@media (min-width: 900px) {
  .site-nav {
    display: flex;
    gap: 4px;
    margin-right: 12px;
    font-size: 0.9375rem;
  }

  .site-nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--target);
    padding-inline: 10px;
  }

  .menu {
    display: none;
  }
}

.menu-button {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--target);
  height: var(--target);
  border: 1px solid var(--text);
  border-radius: 2px;
  cursor: pointer;
  list-style: none;
}

.menu-button::-webkit-details-marker {
  display: none;
}

.menu .icon-close,
.menu[open] .icon-open {
  display: none;
}

.menu[open] .icon-close {
  display: block;
}

.menu-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  display: grid;
  padding: 8px var(--gutter) 16px;
  /* Short landscape screens: the panel scrolls instead of running off. */
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  background: var(--paper);
  border-bottom: 1px solid var(--text);
  counter-reset: menu;
}

/* A closed panel must not widen the page in engines that still lay it out. */
.menu:not([open]) .menu-panel {
  display: none;
}

.menu-panel a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  font-size: 1.0625rem;
}

.menu-panel a::before {
  counter-increment: menu;
  content: counter(menu);
  font: 500 0.8125rem/1 var(--mono);
  color: var(--text-2);
}

/* ---------- Hero ---------- */

.hero {
  padding-block: 20px clamp(40px, 7vw, 80px);
}

.hero .wrap {
  display: grid;
  gap: 24px 56px;
}

/* The block a controlled document opens with: what it is, which version,
   where it comes from, what state it is in. */
.docblock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: solid var(--text);
  border-width: 1px 0 0 1px;
}

.docblock div {
  padding: 7px 10px 8px;
  border: solid var(--text);
  border-width: 0 1px 1px 0;
}

.docblock dd {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.hero-note {
  font-size: 0.875rem;
  color: var(--text-2);
}

.hero-figure {
  display: grid;
  gap: 14px;
  min-width: 0;
}

@media (min-width: 720px) {
  .docblock {
    grid-template-columns: 1.2fr 1fr 1fr 1.1fr;
  }
}

@media (min-width: 960px) {
  .hero {
    padding-top: 28px;
  }

  .hero .wrap {
    grid-template-columns: minmax(0, 1fr) minmax(0, 448px);
    row-gap: 44px;
  }

  .docblock {
    grid-column: 1 / -1;
  }
}

@media (max-height: 520px) and (min-width: 560px) {
  .hero {
    padding-block: 12px 28px;
  }

  .hero .wrap {
    gap: 12px 40px;
    align-items: start;
  }

  .docblock {
    grid-template-columns: repeat(4, auto);
  }

  h1 {
    font-size: clamp(1.7rem, 4.6vw, 2.4rem);
  }

  .hero-copy {
    gap: 12px;
  }

  /* Keep the main action on the first screen: it moves above the paragraph. */
  .hero-actions {
    order: 1;
    margin-top: 0;
  }

  .hero .lede,
  .hero-note {
    order: 2;
  }
}

/* ---------- Sheets: the pieces of a plan the page shows ---------- */

.sheet {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--text);
  box-shadow: 6px 6px 0 var(--line);
  /* A stamp starts larger than it lands; it must not widen the page. */
  overflow: clip;
  font-size: 0.875rem;
  line-height: 1.45;
}

.sheet > * {
  padding: 12px 16px;
}

.sheet > * + * {
  border-top: 1px solid var(--line);
}

.sheet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: end;
  border-bottom: 1px solid var(--text);
}

.sheet-head + * {
  border-top: 0;
}

.sheet-head .label {
  grid-column: 1 / -1;
}

.sheet-title {
  font: 600 1.25rem/1.2 var(--serif);
}

.sheet-meta {
  font: 500 0.75rem/1.6 var(--mono);
}

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 2px;
  font: 500 0.75rem/1.6 var(--mono);
  white-space: nowrap;
}

.chip-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.chip-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.fields {
  display: grid;
  gap: 5px;
}

.fields div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.sheet-part {
  display: grid;
  gap: 6px;
}

.sheet-part strong {
  font-weight: 600;
}

.branch {
  color: var(--text-2);
}

.roles {
  display: grid;
}

.roles li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 10px;
  padding-block: 5px;
}

.roles li + li {
  border-top: 1px dotted var(--line);
}

.roles small {
  font: 500 0.75rem/1.6 var(--mono);
  color: var(--text-2);
}

.roles p {
  grid-column: 1 / -1;
  color: var(--text-2);
}

.contacts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.sheet-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 16px;
  border-top-color: var(--text);
}

.sheet-foot .fields {
  flex: 1 1 180px;
}

.stamp {
  display: inline-grid;
  gap: 4px;
  margin: 4px 6px 4px 4px;
  padding: 7px 12px 6px;
  border: 2px solid var(--accent-text);
  border-radius: 3px;
  box-shadow:
    0 0 0 2px var(--sheet),
    0 0 0 3px var(--accent-text);
  color: var(--accent-text);
  font: 500 0.6875rem/1.3 var(--mono);
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(-4deg);
}

.stamp b {
  font: 800 1.0625rem/1 var(--sans);
  letter-spacing: 0.16em;
  margin-right: -0.16em;
}

/* ---------- The document body: contents rail and numbered sections ---------- */

.contents {
  display: none;
}

@media (min-width: 1280px) {
  .doc {
    display: grid;
    grid-template-columns: 172px minmax(0, 1fr);
    column-gap: 52px;
    align-items: start;
  }

  .contents {
    position: sticky;
    top: calc(var(--header-h) + 28px);
    display: grid;
    gap: 10px;
    margin-top: calc(var(--section-y) + 4px);
  }

  .contents ol {
    border-top: 1px solid var(--text);
  }

  .contents a {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: center;
    min-height: var(--target);
    padding-block: 8px;
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
    line-height: 1.35;
    color: var(--text-2);
    text-decoration: none;
  }

  .contents a span {
    font: 500 0.75rem/1.6 var(--mono);
  }

  .contents a:hover,
  .contents a[aria-current] {
    color: var(--text);
  }

  .contents a[aria-current] {
    font-weight: 700;
    border-bottom-color: var(--text);
  }
}

.sec {
  padding-block: var(--section-y);
  counter-increment: page;
}

.doc .sec {
  border-top: 2px solid var(--text);
}

.sec-head {
  display: grid;
  gap: 14px 48px;
  margin-bottom: clamp(28px, 4vw, 44px);
}

.sec-name {
  display: flex;
  gap: 14px;
  color: var(--text);
}

.sec-num {
  color: var(--accent-text);
}

/* The running page number a controlled document carries on every sheet. */
.sec-name::after {
  content: "Page " counter(page) " of 8";
  margin-left: auto;
  color: var(--text-2);
  white-space: nowrap;
}

.dark .sec-name {
  color: var(--on-dark);
}

.dark .sec-num {
  color: var(--accent-on-dark);
}

.dark .sec-name::after {
  color: var(--on-dark-2);
}

.note {
  display: grid;
  gap: 4px;
  align-content: start;
  max-width: 62ch;
  padding-left: 14px;
  border-left: 1px solid var(--text);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-2);
}

@media (min-width: 1000px) {
  .sec-head {
    grid-template-columns: minmax(0, 1fr) 252px;
  }

  .sec-head > * {
    grid-column: 1;
  }

  .sec-head > .sec-name {
    grid-column: 1 / -1;
  }

  /* Notes move out to the margin, level with the heading they qualify. */
  .sec-head > .note {
    grid-column: 2;
    grid-row: 2 / span 3;
  }
}

/* ---------- 1 The problem ---------- */

.clauses li {
  display: grid;
  gap: 4px 24px;
  padding-block: 18px;
  border-top: 1px solid var(--line);
}

.clauses li:last-child {
  border-bottom: 1px solid var(--line);
}

.clauses p {
  max-width: 62ch;
  color: var(--text-2);
}

@media (min-width: 760px) {
  .clauses li {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: baseline;
  }

  .clauses p {
    grid-column: 2;
  }
}

/* What the plan looks like today: a page of a word-processor file, corrected
   in red pencil. It is set in the reader's own Times on purpose. */
.oldpage {
  padding: 16px 18px 20px;
  background: var(--mist);
  border: 1px solid var(--line);
  color: var(--text-2);
  font:
    400 0.9375rem/1.5 "Times New Roman",
    Times,
    serif;
}

.oldpage-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
}

.oldpage-title {
  margin: 14px 0 6px;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 700;
}

.callout li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 12px;
  align-items: baseline;
  padding-block: 7px;
  border-bottom: 1px solid var(--line);
}

.callout-role {
  grid-column: 1 / -1;
  font-style: italic;
}

.oldpage-foot {
  margin-top: 14px;
}

.blank {
  display: inline-block;
  width: 6.5em;
  border-bottom: 1px solid var(--text-2);
}

.oldpage del {
  position: relative;
  text-decoration: none;
  white-space: nowrap;
}

.oldpage del::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 52%;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-text);
  transform: rotate(-2deg) scaleX(var(--done));
  transform-origin: left;
}

.oldpage ins {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent-text);
  font: 600 1.4375rem/0.9 var(--hand);
  text-decoration: none;
  white-space: nowrap;
  opacity: var(--done);
  transform: rotate(-3deg);
}

.ring {
  position: relative;
  white-space: nowrap;
}

.ring svg {
  position: absolute;
  left: -9px;
  top: -5px;
  width: calc(100% + 18px);
  height: calc(100% + 10px);
  overflow: visible;
}

.ring path {
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--done));
}

/* ---------- 2 How it works ---------- */

.story-grid {
  display: grid;
  gap: 20px;
}

/* On a phone the plan stays under the header while the steps pass below it,
   so it needs its own full-width backing. */
.story-visual {
  margin-inline: calc(var(--gutter) * -1);
  padding: 12px calc(var(--gutter) + 6px) 18px var(--gutter);
  background: var(--paper);
}

.story-sheet > * {
  padding-block: 7px;
}

.story-sheet .sheet-head .label {
  grid-column: 1;
}

.story-sheet .states {
  grid-area: 1 / 2;
}

.story-sheet .sheet-title {
  grid-column: 1 / -1;
  font-size: 1.125rem;
}

.layer {
  display: grid;
  gap: 4px;
}

.layer-name,
.layer-body {
  transition: opacity 0.45s var(--ease);
}

.layer-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  min-height: 30px;
}

.layer-body > span {
  font-weight: 600;
}

.sign {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.sign span {
  display: grid;
  gap: 3px;
  font-weight: 600;
  line-height: 1.25;
}

.sign i {
  padding-top: 3px;
  border-top: 1px solid var(--text);
  font: 500 0.6875rem/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.layer-body:has(.stamp) {
  flex-wrap: nowrap;
}

.layer .stamp {
  flex: none;
  margin-left: auto;
  padding: 5px 9px 4px;
  transition:
    opacity 0.2s,
    transform 0.28s cubic-bezier(0.3, 0, 0.2, 1.4);
}

.layer .stamp b {
  font-size: 0.8125rem;
}

.states {
  display: grid;
}

.state {
  grid-area: 1 / 1;
  justify-self: end;
  transition: opacity 0.3s;
}

.state-draft {
  opacity: 0;
}

/* Scripted: the plan shows only what the current step has added. Without the
   script nothing sets data-step and the finished plan shows. */
[data-step] .layer {
  --on: 0;
}

[data-step="1"] [data-layer="1"],
[data-step="2"] :is([data-layer="1"], [data-layer="2"]),
[data-step="3"] :is([data-layer="1"], [data-layer="2"], [data-layer="3"]),
[data-step="4"] [data-layer] {
  --on: 1;
}

.layer-body {
  opacity: var(--on, 1);
}

.layer-name {
  opacity: calc(0.5 + 0.5 * var(--on, 1));
}

.layer .stamp {
  opacity: var(--on, 1);
  transform: rotate(-4deg) scale(calc(1.5 - 0.5 * var(--on, 1)));
}

:is([data-step="1"], [data-step="2"]) .state-draft {
  opacity: 1;
}

:is([data-step="1"], [data-step="2"]) .state-published {
  opacity: 0;
}

.steps {
  display: grid;
}

.step {
  display: grid;
  grid-template-columns: var(--target) minmax(0, 1fr);
  gap: 6px 14px;
  align-content: start;
  padding-block: 20px;
  border-top: 1px solid var(--line);
  transition: opacity 0.3s;
}

.step-button {
  grid-row: 1 / span 2;
  width: var(--target);
  height: var(--target);
  border: 1px solid var(--text);
  border-radius: 2px;
  background: none;
  color: var(--text);
  font: 500 0.9375rem/1 var(--mono);
  cursor: pointer;
}

.step-button:disabled {
  cursor: default;
}

.step.is-active .step-button {
  background: var(--text);
  color: var(--paper);
}

.step h3 {
  align-self: center;
  min-height: 0;
  padding-top: 10px;
}

.step p {
  grid-column: 2;
  max-width: 56ch;
  color: var(--text-2);
}

@media (min-height: 640px) {
  .js .story-visual {
    position: sticky;
    top: var(--header-h);
    z-index: 2;
    border-bottom: 1px solid var(--line);
  }

  .js .step {
    min-height: 44vh;
    min-height: 44svh;
  }
}

@media (min-width: 960px) {
  .story-grid {
    grid-template-columns: minmax(0, 448px) minmax(0, 1fr);
    gap: 72px;
    align-items: start;
  }

  .story-visual {
    margin: 0;
    padding: 0 6px 6px 0;
    background: none;
  }

  .story-sheet > * {
    padding-block: 13px;
  }
}

@media (min-width: 960px) and (min-height: 640px) {
  .js .story-visual {
    top: calc(var(--header-h) + 40px);
    border-bottom: 0;
  }

  .js .step {
    min-height: clamp(220px, 34vh, 300px);
    align-content: center;
  }

  .js .step:first-child {
    border-top: 0;
  }
}

/* ---------- Scroll progress ----------
   The script sets --p on a [data-progress] figure: 0 as it comes onto the
   screen, 1 once it has been read. Each .m part inside appears when --p passes
   its own --at. Without the script --p is unset and read as 1, so every part
   shows finished. */

.m {
  --done: clamp(0, (var(--p, 1) - var(--at, 0)) * 9, 1);
}

/* ---------- 3 The first hour ----------
   The one dark sheet in the document. It runs off the paper to the right,
   and to the left too until the contents rail appears. */

.doc .sec.night,
.doc .night + .sec {
  border-top: 0;
}

.night {
  box-shadow: 0 0 0 100vmax var(--ink-950);
  clip-path: inset(0 -100vmax);
}

@media (min-width: 1280px) {
  .night {
    padding-left: 44px;
    clip-path: inset(0 -100vmax 0 0);
  }
}

.night-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 44px;
}

@media (min-width: 1000px) {
  .night-grid {
    grid-template-columns: minmax(0, 1fr) 332px;
    gap: 56px 40px;
    align-items: start;
  }

  .hour {
    grid-column: 1 / -1;
  }
}

/* The decision tree. Stacked by default, in a row where it has the width. */
.tree {
  display: grid;
  gap: 14px;
  min-width: 0;
  container-type: inline-size;
}

.tree-flow {
  display: grid;
  gap: 26px;
}

.node {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 14px 16px 16px;
  border: 1px solid var(--line-dark);
  background: var(--ink-800);
  transition:
    opacity 0.3s,
    border-color 0.3s;
}

.node-text {
  font: 600 1.125rem/1.3 var(--serif);
}

.node-sub {
  color: var(--on-dark-2);
  font-size: 0.875rem;
}

.answers {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.answers button {
  min-width: 68px;
  min-height: var(--target);
  padding: 6px 14px;
  border: 1px solid var(--on-dark-2);
  border-radius: 2px;
  background: none;
  color: var(--on-dark);
  font: 600 0.9375rem/1 var(--sans);
  cursor: pointer;
}

.answers button[aria-pressed="true"] {
  border-color: var(--accent-on-dark);
  background: var(--accent-on-dark);
  color: var(--ink-950);
}

.answers button:disabled {
  cursor: default;
}

.leaf {
  display: grid;
  gap: 2px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-dark);
  color: var(--on-dark-2);
  font-size: 0.875rem;
  transition:
    color 0.3s,
    border-color 0.3s;
}

/* The line from one node to the next, and the coral that runs along it when
   the answers lead that way. */
.node + .node::before,
.node + .node::after {
  content: "";
  position: absolute;
  left: 27px;
  top: -27px;
  width: 2px;
  height: 27px;
  background: var(--line-dark);
}

.node + .node::after {
  background: var(--accent-on-dark);
  transform: scale(1, var(--lit, 0));
  transform-origin: 0 0;
}

@container (min-width: 660px) {
  .tree-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 34px;
  }

  .node + .node::before,
  .node + .node::after {
    left: -35px;
    top: 44px;
    width: 35px;
    height: 2px;
  }

  .node + .node::after {
    transform: scale(var(--lit, 0), 1);
  }
}

[data-q1="yes"] [data-node="q2"],
[data-q1="yes"][data-q2="no"] [data-node="end"] {
  --lit: var(--done);
}

[data-q1="no"] :is([data-node="q2"], [data-node="end"]),
[data-q2="yes"] [data-node="end"] {
  opacity: 0.4;
}

[data-q1="no"] [data-leaf="q1"],
[data-q1="yes"][data-q2="yes"] [data-leaf="q2"] {
  border-top: 1px solid var(--accent-on-dark);
  color: var(--on-dark);
}

[data-q1="no"] [data-leaf="q1"] .label,
[data-q1="yes"][data-q2="yes"] [data-leaf="q2"] .label {
  color: var(--accent-on-dark);
}

[data-q1="yes"][data-q2="no"] .node-end {
  border-color: var(--accent-on-dark);
  box-shadow: inset 4px 0 0 var(--accent-on-dark);
}

/* One role's card, as printed: paper on the dark desk, with crop marks. */
.card-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  justify-items: center;
  align-content: start;
  min-width: 0;
}

.cropmarks {
  --c: var(--on-dark-2);
  --o: 14px;
  --l: 9px;
  width: min(100%, 328px);
  padding: var(--o);
  transform: rotate(-2.2deg);
  background:
    linear-gradient(var(--c), var(--c)) left var(--o) top 0 / 1px var(--l)
      no-repeat,
    linear-gradient(var(--c), var(--c)) left 0 top var(--o) / var(--l) 1px
      no-repeat,
    linear-gradient(var(--c), var(--c)) right var(--o) top 0 / 1px var(--l)
      no-repeat,
    linear-gradient(var(--c), var(--c)) right 0 top var(--o) / var(--l) 1px
      no-repeat,
    linear-gradient(var(--c), var(--c)) left var(--o) bottom 0 / 1px var(--l)
      no-repeat,
    linear-gradient(var(--c), var(--c)) left 0 bottom var(--o) / var(--l) 1px
      no-repeat,
    linear-gradient(var(--c), var(--c)) right var(--o) bottom 0 / 1px var(--l)
      no-repeat,
    linear-gradient(var(--c), var(--c)) right 0 bottom var(--o) / var(--l) 1px
      no-repeat;
}

.rolecard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 16px 18px 12px;
  background: var(--sheet);
  box-shadow: 0 18px 36px rgb(0 0 0 / 0.5);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
}

.rolecard .label,
.rolecard .when,
.card-sub {
  color: var(--text-2);
}

.card-sub {
  font: 500 0.75rem/1.5 var(--mono);
}

.rolecard .sheet-title {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--text);
  font-size: 1.5rem;
}

.card-steps li {
  position: relative;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 0 8px;
  padding: 7px 0 7px 22px;
  border-bottom: 1px dotted var(--line);
}

.card-steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text);
}

.when {
  font: 500 0.75rem/1.6 var(--mono);
  white-space: nowrap;
}

.card-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 12px;
  font: 500 0.6875rem/1.6 var(--mono);
  color: var(--text-2);
}

/* The first hour. A chronological list on a phone; three lanes against a
   clock where there is room. The coral follows the reader down or across. */
.hour {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.hour-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-block: 10px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--ink-950);
}

.clock {
  color: var(--accent-on-dark);
  font: 500 clamp(1.75rem, 1.2rem + 2.4vw, 3rem) / 1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.hour-axis,
.lane {
  display: none;
}

.timeline {
  position: relative;
  display: grid;
  padding-left: 26px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  background: linear-gradient(
    to bottom,
    var(--accent-on-dark) calc(var(--p, 1) * 100%),
    var(--line-dark) 0
  );
}

.timeline li {
  /* Eight steps, spaced so the last one is finished when --p reaches 1. */
  --at: calc((var(--i) + 0.3) / 8.5);
  position: relative;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 0 10px;
  padding-block: 9px;
  opacity: calc(0.45 + 0.55 * var(--done));
}

.timeline li > span:last-child {
  grid-column: 2;
}

.timeline b {
  font: 500 0.75rem/1.6 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-dark-2);
}

.timeline .when {
  grid-row: 1 / span 2;
  color: var(--on-dark);
}

.timeline li::before,
.timeline li::after {
  content: "";
  position: absolute;
  left: -26px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--on-dark-2);
  background: var(--ink-950);
}

.timeline li::after {
  border-color: var(--accent-on-dark);
  background: var(--accent-on-dark);
  opacity: var(--done);
}

@media (max-width: 899px) and (min-height: 640px) {
  .js .hour-head {
    position: sticky;
    top: var(--header-h);
    z-index: 1;
  }
}

@media (min-width: 900px) {
  @supports (grid-template-rows: subgrid) {
    .hour-grid {
      display: grid;
      grid-template-columns: 116px minmax(0, 1fr);
      grid-template-rows: auto repeat(3, auto);
    }

    .hour-axis {
      grid-area: 1 / 2;
      display: flex;
      justify-content: space-between;
      /* Each label is centred on its ten-minute line. */
      margin-inline: -3ch;
      padding-bottom: 8px;
      font: 500 0.6875rem/1.4 var(--mono);
      color: var(--on-dark-2);
    }

    .hour-axis span {
      width: 6ch;
      text-align: center;
    }

    .lane {
      display: block;
      grid-column: 1 / -1;
      padding: 14px 0 0;
      border-top: 1px solid var(--line-dark);
      font: 500 0.75rem/1.4 var(--mono);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--on-dark-2);
    }

    .lane-1 {
      grid-row: 2;
    }

    .lane-2 {
      grid-row: 3;
    }

    .lane-3 {
      grid-row: 4;
    }

    .timeline {
      grid-area: 2 / 2 / span 3;
      grid-template-rows: subgrid;
      grid-template-columns: repeat(60, minmax(0, 1fr));
      padding-left: 0;
      background: repeating-linear-gradient(
        to right,
        var(--ink-800) 0 1px,
        transparent 1px calc(100% / 6)
      );
    }

    /* The coral line is the clock hand: it crosses the hour as you read. */
    .timeline::before {
      left: calc(var(--p, 1) * 100%);
      top: 0;
      bottom: 0;
      background: var(--accent-on-dark);
    }

    .timeline li {
      --at: calc(var(--min) / 60);
      grid-column: calc(var(--min) + 1) / span var(--span);
      display: block;
      padding: 12px 10px 16px;
      border-left: 2px solid var(--on-dark-2);
      font-size: 0.875rem;
      line-height: 1.4;
    }

    .timeline [data-lane="1"] {
      grid-row: 1;
    }

    .timeline [data-lane="2"] {
      grid-row: 2;
    }

    .timeline [data-lane="3"] {
      grid-row: 3;
    }

    .timeline .when {
      display: block;
    }

    /* The lane names the role; the item keeps it for screen readers. */
    .timeline b {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }

    .timeline li::before {
      display: none;
    }

    .timeline li::after {
      left: -2px;
      top: 0;
      width: 2px;
      height: 100%;
      border: 0;
      border-radius: 0;
    }
  }
}

/* ---------- 4 Readiness ---------- */

.split {
  display: grid;
  gap: 36px 64px;
}

.stack {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.outputs {
  border-top: 1px solid var(--text);
}

.outputs li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding-block: 12px;
  border-bottom: 1px solid var(--line);
}

.outputs span {
  grid-column: 1;
  color: var(--text-2);
}

.outputs small {
  grid-area: 1 / 2;
  font: 500 0.75rem/1.9 var(--mono);
  color: var(--text-2);
}

.register li {
  display: grid;
  gap: 5px;
  padding-block: 12px;
}

.register li + li {
  border-top: 1px solid var(--line);
}

.register .chip {
  justify-self: start;
}

.register small {
  font: 500 0.75rem/1.5 var(--mono);
  color: var(--text-2);
}

.sheet > .register {
  padding-block: 2px;
}

@media (min-width: 960px) {
  .split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    align-items: start;
  }

  .split > figure {
    padding-right: 6px;
  }

  .split-even {
    grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  }
}

.register li.m {
  opacity: var(--done);
  transform: translateY(calc((1 - var(--done)) * 8px));
}

/* ---------- 5 Rules ---------- */

.rules {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.rules thead th {
  padding: 0 24px 10px 0;
  border-bottom: 1px solid var(--text);
  font: 500 0.75rem/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.rules tbody th,
.rules td {
  padding: 18px 24px 18px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-weight: 400;
}

.rules tbody th {
  width: 24%;
}

.rules tbody a {
  font: 600 1.375rem/1.2 var(--serif);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.rules cite {
  display: block;
  margin-top: 6px;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
}

.rules td {
  color: var(--text-2);
}

/* The record answers the rule: a coral rule is drawn down its left side. */
.rules td.m {
  position: relative;
  padding-left: 18px;
  padding-right: 0;
  color: var(--text);
}

.rules td.m::after {
  content: "";
  position: absolute;
  left: 0;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: var(--accent);
  transform: scaleY(var(--done));
  transform-origin: top;
}

@media (max-width: 819px) {
  .rules thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .rules,
  .rules tbody,
  .rules tr,
  .rules tbody th,
  .rules td {
    display: block;
    width: auto;
  }

  .rules tr {
    padding-block: 18px;
    border-top: 1px solid var(--text);
  }

  .rules tbody th,
  .rules td {
    padding-block: 0;
    padding-right: 0;
    border: 0;
  }

  .rules td {
    margin-top: 14px;
  }

  .rules td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font: 500 0.75rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-2);
  }

  .rules td.m::after {
    top: 2px;
    bottom: 2px;
  }
}

/* ---------- 6 Pilot ---------- */

.pilot-lists {
  display: grid;
  gap: 32px 56px;
}

.checklist {
  display: grid;
  gap: 4px;
  align-content: start;
}

.checklist h3 {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--text);
}

.checklist li {
  position: relative;
  padding: 11px 0 11px 28px;
  border-bottom: 1px solid var(--line);
}

.checklist li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 16px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text);
}

.checklist.ticked li::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 16px;
  width: 9px;
  height: 5px;
  border: solid var(--accent-text);
  border-width: 0 0 2px 2px;
  opacity: var(--done);
  transform: rotate(-48deg) scale(calc(1.6 - 0.6 * var(--done)));
}

.pilot-terms {
  margin-top: 24px;
  color: var(--text-2);
}

@media (min-width: 720px) {
  .pilot-lists {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- 7 Questions ---------- */

.faq {
  max-width: 820px;
  border-top: 1px solid var(--text);
  counter-reset: faq;
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 20px;
  align-items: baseline;
  min-height: 56px;
  padding-block: 15px;
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.4;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::before {
  counter-increment: faq;
  content: "7." counter(faq);
  font: 500 0.75rem/1 var(--mono);
  color: var(--text-2);
}

.faq summary::after {
  content: "+";
  font: 500 1.125rem/1 var(--mono);
  text-align: right;
}

.faq details[open] summary::after {
  content: "\2212";
}

.faq details p {
  max-width: 64ch;
  padding: 0 20px 18px 40px;
  color: var(--text-2);
}

.faq-more {
  margin-top: 20px;
  color: var(--text-2);
}

.faq-more a {
  color: var(--text);
  font-weight: 600;
  text-underline-offset: 4px;
}

/* The change record every controlled document ends with. */
.revisions {
  max-width: 820px;
  margin-top: clamp(40px, 6vw, 72px);
}

.revisions table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  border-bottom: 1px solid var(--line);
  font: 500 0.75rem/1.5 var(--mono);
  color: var(--text-2);
  text-align: left;
}

.revisions th,
.revisions td {
  padding: 6px 16px 6px 0;
  border-top: 1px solid var(--line);
  font-weight: 500;
  vertical-align: top;
}

.revisions td:last-child {
  width: 60%;
}

/* ---------- 8 Apply ---------- */

.dark {
  background: var(--ink-950);
  color: var(--on-dark);
}

.apply .wrap {
  display: grid;
  gap: 16px;
}

.apply-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  margin-top: 12px;
}

.apply-address {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  font: 500 0.9375rem/1.4 var(--mono);
  color: var(--on-dark-2);
  text-underline-offset: 4px;
}

/* Two signature lines: ours is filled in, the visitor's is waiting. */
.signoff {
  display: grid;
  gap: 24px 40px;
  max-width: 620px;
  margin-top: 28px;
}

@media (min-width: 560px) {
  .signoff {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.signoff div {
  display: grid;
  gap: 4px;
}

.signoff dt {
  order: 1;
}

.signoff dd {
  order: 2;
  font: 500 0.75rem/1.4 var(--mono);
  color: var(--on-dark-2);
}

.signoff dd:first-of-type {
  order: 0;
  min-height: 36px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--on-dark-2);
  font: 600 1.1875rem/1.6 var(--serif);
  color: var(--on-dark);
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--ink-950);
  color: var(--on-dark-2);
  border-top: 1px solid var(--ink-800);
  font-size: 0.875rem;
  padding-bottom: env(safe-area-inset-bottom);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
  padding-block: 18px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
}

/* ---------- Motion ----------
   Everything below only adds to a finished page. Without animation support,
   or with reduced motion, each element shows its final state. */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .plan-sheet .a {
    animation: appear 0.5s var(--ease) both;
    animation-delay: calc(var(--d) * 1s + 0.15s);
  }

  .plan-sheet .stamp {
    animation: press 0.3s cubic-bezier(0.3, 0, 0.2, 1.4) both;
    animation-delay: calc(var(--d) * 1s + 0.15s);
  }

  @supports (animation-timeline: view()) {
    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }

    .card-figure.reveal {
      animation-name: land;
      animation-range: entry 0% entry 80%;
    }
  }

  /* Scroll progress arrives in steps; these take the edges off. */
  .oldpage ins,
  .register li.m,
  .timeline li,
  .timeline li::after,
  .checklist.ticked li::after {
    transition:
      opacity 0.2s linear,
      transform 0.2s var(--ease);
  }
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes press {
  from {
    opacity: 0;
    transform: rotate(-4deg) scale(1.6);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* No rotation here: a turning card is wider than a narrow phone. */
@keyframes land {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
}
