/*
 * Themeplumb marketing site. Tokens, type, line, marks, severity, focus, dark scheme and forced colours are
 * the dashboard's (apps/web/src/app/globals.css, docs/DESIGN.md); nothing here introduces a new colour.
 *
 * Contrast ratios (WCAG 2.x relative luminance), measured for the dashboard and reused unchanged:
 *
 *                     light on paper / sheet     dark on paper / sheet
 *   ink               14.03 / 16.05              15.16 / 13.68     body text (needs 7:1)
 *   ink-soft           7.06 /  8.07               8.98 /  8.10     secondary text (needs 7:1)
 *   chalk              6.88 /  7.87               7.89 /  7.11     links, focus ring (needs 4.5:1 / 3:1)
 *   on-chalk on chalk  7.87                       7.89             primary button label
 *   brass              4.93 /  5.63               7.99 /  7.21     the line and its marks (non-text, 3:1)
 *   edge               3.95 /  4.52               5.01 /  4.52     control and table borders (non-text, 3:1)
 *   rule               1.36 /  1.55               1.59 /  1.43     row rules only (decorative)
 *   critical           6.74 /  7.71               8.79 /  7.93
 *   serious            4.61 /  5.27               9.55 /  8.62
 *   moderate           5.75 /  6.58              10.28 /  9.27
 *   minor              7.06 /  8.07               8.98 /  8.10
 *
 * Severity colours are used for the shape and the word together; the word alone carries the meaning.
 */

/* Atkinson Hyperlegible Next and Mono, SIL Open Font License (fonts/OFL.txt). Variable, latin subset. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("/fonts/atkinson-hyperlegible-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --paper-light: #edf0f3;
  --sheet-light: #ffffff;
  --ink-light: #14213a;
  --ink-soft-light: #44506a;
  --chalk-light: #2447b8;
  --on-chalk-light: #ffffff;
  --brass-light: #8a5f14;
  --rule-light: #c9d0da;
  --edge-light: #6b778c;
  --critical-light: #a31b14;
  --serious-light: #b24e00;
  --moderate-light: #6b5d00;
  --minor-light: #44506a;

  --paper-dark: #0f1724;
  --sheet-dark: #17212f;
  --ink-dark: #e8ecf2;
  --ink-soft-dark: #aeb8c8;
  --chalk-dark: #8fa8ff;
  --on-chalk-dark: #0f1724;
  --brass-dark: #d9a441;
  --rule-dark: #2f3b4d;
  --edge-dark: #7c889c;
  --critical-dark: #ff9a8f;
  --serious-dark: #ffaa5e;
  --moderate-dark: #d8c54a;
  --minor-dark: #aeb8c8;

  /* Fallback for browsers without light-dark(): light values, switched by the media query below. */
  --paper: var(--paper-light);
  --sheet: var(--sheet-light);
  --ink: var(--ink-light);
  --ink-soft: var(--ink-soft-light);
  --chalk: var(--chalk-light);
  --on-chalk: var(--on-chalk-light);
  --brass: var(--brass-light);
  --rule: var(--rule-light);
  --edge: var(--edge-light);
  --critical: var(--critical-light);
  --serious: var(--serious-light);
  --moderate: var(--moderate-light);
  --minor: var(--minor-light);

  /* Type scale, ratio ~1.25 (DESIGN.md), plus the 3.052rem step between 2.441 and 3.815 for the hero only. */
  --step--1: 0.8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-hero: 3.052rem;

  /* Space, 4px base */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4.5rem;
  --s9: 7rem;

  /* The line, the gap between it and what hangs from it, and the marks on it. */
  --line-width: 2px;
  --hang-gap: clamp(1rem, 0.6rem + 1.6vw, 1.5rem);
  --mark: 14px;
  --measure: 68ch;
  --column: 72rem;
  --radius-control: 2px;

  --font-sans: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  accent-color: var(--chalk);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: var(--paper-dark);
    --sheet: var(--sheet-dark);
    --ink: var(--ink-dark);
    --ink-soft: var(--ink-soft-dark);
    --chalk: var(--chalk-dark);
    --on-chalk: var(--on-chalk-dark);
    --brass: var(--brass-dark);
    --rule: var(--rule-dark);
    --edge: var(--edge-dark);
    --critical: var(--critical-dark);
    --serious: var(--serious-dark);
    --moderate: var(--moderate-dark);
    --minor: var(--minor-dark);
  }
}

@supports (color: light-dark(white, black)) {
  :root {
    --paper: light-dark(var(--paper-light), var(--paper-dark));
    --sheet: light-dark(var(--sheet-light), var(--sheet-dark));
    --ink: light-dark(var(--ink-light), var(--ink-dark));
    --ink-soft: light-dark(var(--ink-soft-light), var(--ink-soft-dark));
    --chalk: light-dark(var(--chalk-light), var(--chalk-dark));
    --on-chalk: light-dark(var(--on-chalk-light), var(--on-chalk-dark));
    --brass: light-dark(var(--brass-light), var(--brass-dark));
    --rule: light-dark(var(--rule-light), var(--rule-dark));
    --edge: light-dark(var(--edge-light), var(--edge-dark));
    --critical: light-dark(var(--critical-light), var(--critical-dark));
    --serious: light-dark(var(--serious-light), var(--serious-dark));
    --moderate: light-dark(var(--moderate-light), var(--moderate-dark));
    --minor: light-dark(var(--minor-light), var(--minor-dark));
  }
}

/* Forced Colors Mode: system colours, and borders where the design uses fills. */
@media (forced-colors: active) {
  :root {
    --paper: Canvas;
    --sheet: Canvas;
    --ink: CanvasText;
    --ink-soft: CanvasText;
    --chalk: LinkText;
    --on-chalk: ButtonText;
    --brass: CanvasText;
    --rule: CanvasText;
    --edge: CanvasText;
    --critical: CanvasText;
    --serious: CanvasText;
    --moderate: CanvasText;
    --minor: CanvasText;
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* Base                                                                                                  */
/* ---------------------------------------------------------------------------------------------------- */

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

html {
  font-family: var(--font-sans);
  font-size: 100%;
  font-size-adjust: from-font;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--edge) var(--paper);
}

body {
  margin: 0;
  min-block-size: 100vh;
  min-block-size: 100dvh;
  background: var(--paper);
  color: var(--ink);
  overflow-wrap: break-word;
  text-align: start;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

h2 {
  font-size: var(--step-2);
}

h3 {
  font-size: var(--step-1);
}

p {
  margin: 0;
  max-inline-size: var(--measure);
  text-wrap: pretty;
}

code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  font-size-adjust: from-font;
}

strong {
  font-weight: 600;
}

a {
  color: var(--chalk);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 3px;
}

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

::selection {
  background: var(--chalk);
  color: var(--on-chalk);
}

/* Zero specificity, so layout rules such as `.band > * + *` still space these lists. */
:where(ul[class], ol[class]) {
  list-style: none;
  margin: 0;
  padding: 0;
}

svg {
  max-inline-size: 100%;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--s4);
  inset-block-start: var(--s2);
  z-index: 10;
  padding: var(--s2) var(--s4);
  background: var(--sheet);
  color: var(--chalk);
  border: 2px solid var(--chalk);
  translate: 0 -200%;
}

.skip-link:focus-visible {
  translate: 0 0;
}

.soft {
  color: var(--ink-soft);
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------------------------------- */
/* Column, top bar and footer                                                                            */
/* ---------------------------------------------------------------------------------------------------- */

.column {
  inline-size: 100%;
  max-inline-size: var(--column);
  margin-inline: auto;
  padding-inline: var(--s4);
}

@media (min-width: 40rem) {
  .column {
    padding-inline: var(--s6);
  }
}

.topbar {
  border-block-end: 1px solid var(--rule);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s1) var(--s6);
  padding-block: var(--s2);
  min-block-size: 3.5rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-block-size: 44px;
  font-weight: 800;
  font-size: var(--step-1);
  color: var(--ink);
  text-decoration: none;
  /* The bob hangs on the same x as the page line below it. */
  margin-inline-start: calc(-1 * (6px - var(--line-width) / 2));
}

.wordmark:hover span {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.wordmark svg {
  color: var(--brass);
  flex: none;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s5);
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-block-end: 3px solid transparent;
}

.nav-list a:hover {
  border-block-end-color: var(--edge);
}

.nav-list a[aria-current="page"] {
  border-block-end-color: var(--chalk);
}

.site-footer {
  border-block-start: 1px solid var(--rule);
  padding-block: var(--s5) var(--s6);
}

.footer-inner {
  /* Footer text keeps the content's left edge: the line's width plus its gap. */
  padding-inline-start: calc(var(--hang-gap) + var(--line-width));
}

.footer-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s5);
}

.footer-list a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

.copyright {
  color: var(--ink-soft);
  margin-block-start: var(--s2);
}

/* ---------------------------------------------------------------------------------------------------- */
/* The line: one brass rule down the content column, ending in the bob above the footer                  */
/* ---------------------------------------------------------------------------------------------------- */

.line {
  position: relative;
  flex: 1 0 auto;
  border-inline-start: var(--line-width) solid var(--brass);
  padding-inline-start: var(--hang-gap);
  padding-block: var(--s7) var(--s8);
  margin-block-end: var(--s6);
}

.line-bob {
  position: absolute;
  inset-inline-start: calc(-1 * var(--line-width) / 2 - 9px);
  inset-block-end: -16px;
  inline-size: 18px;
  block-size: 18px;
  color: var(--brass);
}

/* A section mark: a filled brass dot on the line and a short tick to the heading it carries. */
.marked {
  position: relative;
}

.marked::before,
.marked::after {
  content: "";
  position: absolute;
}

.marked::before {
  inset-inline-start: calc(-1 * var(--hang-gap) - var(--line-width) / 2 - var(--mark) / 2);
  inset-block-start: calc(0.6em - var(--mark) / 2);
  inset-block-start: calc(0.5lh - var(--mark) / 2);
  inline-size: var(--mark);
  block-size: var(--mark);
  border: calc(var(--mark) / 2) solid var(--brass);
  border-radius: 50%;
}

.marked::after {
  inset-inline-start: calc(-1 * var(--hang-gap));
  inset-block-start: calc(0.6em - 1px);
  inset-block-start: calc(0.5lh - 1px);
  inline-size: calc(var(--hang-gap) - var(--s2));
  border-block-start: 2px solid var(--brass);
}

.band {
  padding-block-start: var(--s8);
}

.band > * + * {
  margin-block-start: var(--s5);
}

.prose > * + * {
  margin-block-start: var(--s4);
}

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

.hero {
  display: grid;
  gap: var(--s7) var(--s8);
}

@media (min-width: 64rem) {
  .hero {
    grid-template-columns: minmax(0, 1.15fr) minmax(24rem, 1fr);
    align-items: start;
  }
}

.hero-text > * + * {
  margin-block-start: var(--s5);
}

.hero h1 {
  font-size: clamp(var(--step-3), 1.1rem + 2.4vw, var(--step-hero));
  line-height: 1.12;
  letter-spacing: -0.015em;
  max-inline-size: 22ch;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-soft);
  max-inline-size: 36ch;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s5);
  padding-block-start: var(--s2);
}

.button {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  padding: var(--s2) var(--s5);
  border: 2px solid var(--chalk);
  border-radius: var(--radius-control);
  background: var(--chalk);
  color: var(--on-chalk);
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

.button:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.text-action {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

@media (forced-colors: active) {
  .button {
    border-color: ButtonText;
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* The specimen: a static excerpt of the theme anatomy for the sample store                              */
/* ---------------------------------------------------------------------------------------------------- */

.specimen {
  margin: 0;
  container-type: inline-size;
}

.sheet {
  background: var(--sheet);
  padding: var(--s5) var(--s5) var(--s5) var(--s4);
}

.specimen-head {
  padding-inline-start: calc(var(--hang-gap) + var(--line-width));
  padding-block-end: var(--s4);
}

.specimen-head p + p {
  margin-block-start: var(--s1);
}

.store-name {
  font-weight: 600;
}

/* The anatomy's own line, drawn once on load. */
.anatomy {
  position: relative;
  padding-inline-start: calc(var(--hang-gap) + var(--line-width));
  padding-block: var(--s3) var(--s6);
}

.anatomy::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: var(--line-width);
  background: var(--brass);
  transform-origin: top;
}

.anatomy-sections > * + * {
  margin-block-start: var(--s4);
}

.key {
  position: relative;
  font-weight: 600;
}

.key code {
  font-size: 1em;
}

/* Tick from the line to the section key, and the mark on the line. */
.key::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(-1 * var(--hang-gap));
  inset-block-start: calc(0.775rem - 1px);
  inline-size: calc(var(--hang-gap) - var(--s2));
  border-block-start: 2px solid var(--brass);
}

.mark {
  position: absolute;
  inset-inline-start: calc(-1 * var(--hang-gap) - var(--line-width) / 2 - var(--mark) / 2);
  inset-block-start: calc(0.775rem - var(--mark) / 2);
  inline-size: var(--mark);
  block-size: var(--mark);
  border: calc(var(--mark) / 2) solid var(--brass);
  border-radius: 50%;
  background: var(--sheet);
}

.mark-hollow {
  border-width: 2px;
}

.defect {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--s3);
  padding-block-start: var(--s1);
}

.defect-what {
  flex: 1 1 12rem;
}

.pages {
  flex: 0 0 auto;
  margin-inline-start: auto;
  color: var(--ink-soft);
}

.severity {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  flex: 0 0 6.5rem;
  font-weight: 600;
  white-space: nowrap;
}

.severity svg {
  inline-size: 0.95em;
  block-size: 0.95em;
  flex: none;
}

.critical {
  color: var(--critical);
}

.serious {
  color: var(--serious);
}

.moderate {
  color: var(--moderate);
}

.minor {
  color: var(--minor);
}

.anatomy-bob {
  position: absolute;
  inset-inline-start: calc(var(--line-width) / 2 - 9px);
  inset-block-end: -16px;
  inline-size: 18px;
  block-size: 18px;
  color: var(--brass);
}

.apps {
  position: relative;
  margin-block-start: 22px;
  padding-inline-start: calc(var(--hang-gap) + var(--line-width));
  padding-block: var(--s5) var(--s2);
}

.apps::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  border-inline-start: var(--line-width) dashed var(--brass);
}

.apps .key {
  font-weight: 600;
}

.apps-where {
  color: var(--ink-soft);
}

.specimen-more {
  padding-inline-start: calc(var(--hang-gap) + var(--line-width));
  padding-block-start: var(--s4);
  color: var(--ink-soft);
}

.specimen figcaption {
  margin-block-start: var(--s3);
  font-size: var(--step--1);
  font-size: max(var(--step--1), 0.875rem);
  color: var(--ink-soft);
  max-inline-size: 48ch;
}

@media (prefers-reduced-motion: no-preference) {
  .anatomy::before {
    animation: draw 400ms cubic-bezier(0.25, 0.7, 0.3, 1) both;
  }

  .anatomy-sections .mark {
    animation: appear 160ms ease-out both;
  }

  .anatomy-sections > :nth-child(2) .mark {
    animation-delay: 72ms;
  }

  .anatomy-sections > :nth-child(3) .mark {
    animation-delay: 144ms;
  }

  .anatomy-sections > :nth-child(4) .mark {
    animation-delay: 216ms;
  }

  .anatomy-sections > :nth-child(5) .mark {
    animation-delay: 288ms;
  }

  .anatomy-bob {
    animation: appear 160ms ease-out 380ms both;
  }
}

@keyframes draw {
  from {
    scale: 1 0;
  }
}

@keyframes appear {
  from {
    opacity: 0;
    scale: 0.3;
  }
}

@media (forced-colors: active) {
  .sheet {
    border: 1px solid CanvasText;
  }

  .anatomy::before {
    background: none;
    border-inline-start: var(--line-width) solid CanvasText;
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* How it works: a true sequence, so its marks carry numbers                                            */
/* ---------------------------------------------------------------------------------------------------- */

.steps {
  counter-reset: step;
}

.steps > li {
  position: relative;
  counter-increment: step;
  padding-block: var(--s1);
}

.steps > li + li {
  margin-block-start: var(--s5);
}

.steps > li::before {
  content: counter(step);
  /* The list already announces its position; the drawn numeral is visual only. */
  content: counter(step) / "";
  position: absolute;
  inset-inline-start: calc(-1 * var(--hang-gap) - var(--line-width) / 2 - 0.875rem);
  inset-block-start: 0;
  display: grid;
  place-items: center;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border: 2px solid var(--brass);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--step-0);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.steps > li > p {
  /* Clear the numbered mark (half its width plus a small gap) without leaving the heading's edge when the gap allows. */
  padding-inline-start: max(0px, calc(0.875rem + var(--s2) - var(--hang-gap)));
}

/* ---------------------------------------------------------------------------------------------------- */
/* Plain lists hanging from the line                                                                     */
/* ---------------------------------------------------------------------------------------------------- */

.plain-list > li {
  max-inline-size: var(--measure);
}

.plain-list > li + li {
  margin-block-start: var(--s4);
}

/* ---------------------------------------------------------------------------------------------------- */
/* Pricing: one table on a sheet, stacked when its container is narrow                                   */
/* ---------------------------------------------------------------------------------------------------- */

.table-region {
  container-type: inline-size;
  max-inline-size: 56rem;
  background: var(--sheet);
}

.table {
  inline-size: 100%;
  border-collapse: collapse;
  background: var(--sheet);
}

.table caption {
  text-align: start;
  padding: var(--s4) var(--s4) var(--s2);
  font-weight: 600;
  font-size: var(--step-1);
  caption-side: top;
}

.table th,
.table td {
  text-align: start;
  vertical-align: top;
  padding: var(--s3) var(--s4);
  border-block-end: 1px solid var(--rule);
}

.table thead th {
  font-weight: 600;
  color: var(--ink-soft);
  border-block-end: 2px solid var(--edge);
  text-wrap: balance;
}

.table tbody th {
  font-weight: 600;
}

.table tbody tr:last-child > * {
  border-block-end: 0;
}

.price {
  white-space: nowrap;
}

@container (width < 40rem) {
  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table th,
  .table td {
    display: block;
  }

  .table tr {
    padding-block: var(--s3);
    border-block-end: 1px solid var(--edge);
  }

  .table tbody tr:last-child {
    border-block-end: 0;
  }

  .table th,
  .table td {
    border: 0;
    padding: var(--s1) var(--s4);
  }

  .table td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--ink-soft);
  }

  .price {
    white-space: normal;
  }
}

@media (forced-colors: active) {
  .table-region {
    border: 1px solid CanvasText;
  }
}

/* ---------------------------------------------------------------------------------------------------- */
/* Policy pages and 404                                                                                  */
/* ---------------------------------------------------------------------------------------------------- */

.doc-head h1 {
  font-size: clamp(var(--step-3), 1.6rem + 1.4vw, var(--step-4));
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.doc-head > * + * {
  margin-block-start: var(--s3);
}

.doc {
  max-inline-size: var(--measure);
}

.doc > section {
  padding-block-start: var(--s7);
}

.doc > section > * + * {
  margin-block-start: var(--s4);
}

.doc ul {
  margin: 0;
  padding-inline-start: var(--s5);
}

.doc li + li {
  margin-block-start: var(--s2);
}

/* The policy page you are on: bolder and with the thick underline, not colour alone. */
.footer-list a[aria-current="page"] {
  font-weight: 600;
  text-decoration-thickness: 3px;
}
