/*
 * The public site's one stylesheet (ADR-41): hand-written, no framework, the system's own fonts (nothing from a third
 * party). Mobile first; wider screens only widen the margins. The three appearances of ADR-38 are colour variables:
 * the server marks the root with data-appearance from the cookie; without it the device preference decides. The
 * colours are the tool's (web/src/theme.ts, global.css): indigo accent, cool neutrals, the brown appearance's coffee
 * tones. Text colours are at least 4.5:1 on their background.
 */

:root {
  color-scheme: light;
  --page: #f4f5f8;
  --surface: #ffffff;
  --text: #1a2233;
  --text-soft: #4f5868;
  --border: #dce0e8;
  --accent: #3446a8;
  --accent-strong: #232f7a;
  --accent-soft: #eef0fa;
  --on-accent: #ffffff;
  --link: #3446a8;
  --brand: #c2410c;
  --code: #eef0fa;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.06), 0 14px 36px rgba(20, 30, 60, 0.13);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-appearance]) {
    color-scheme: dark;
    --page: #171c27;
    --surface: #1f2533;
    --text: #dce1ea;
    --text-soft: #a3acbb;
    --border: #3a4253;
    --accent: #4c5db5;
    --accent-strong: #6f7fc4;
    --accent-soft: #232a44;
    --on-accent: #ffffff;
    --link: #9aa6d6;
    --brand: #ff8a3d;
    --code: #2c3342;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 36px rgba(0, 0, 0, 0.45);
  }
}

:root[data-appearance='dark'] {
  color-scheme: dark;
  --page: #171c27;
  --surface: #1f2533;
  --text: #dce1ea;
  --text-soft: #a3acbb;
  --border: #3a4253;
  --accent: #4c5db5;
  --accent-strong: #6f7fc4;
  --accent-soft: #232a44;
  --on-accent: #ffffff;
  --link: #9aa6d6;
  --brand: #ff8a3d;
  --code: #2c3342;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 36px rgba(0, 0, 0, 0.45);
}

:root[data-appearance='brown'] {
  color-scheme: dark;
  --page: #221b15;
  --surface: #2c231c;
  --text: #efe4d6;
  --text-soft: #bfa98f;
  --border: #4b3d31;
  --accent: #4c5db5;
  --accent-strong: #6f7fc4;
  --accent-soft: #33271d;
  --on-accent: #ffffff;
  --link: #a9b4e0;
  --brand: #ff8a3d;
  --code: #3a2f26;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 36px rgba(0, 0, 0, 0.45);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-strong);
}

:root:not([data-appearance='light']) a:hover {
  color: var(--text);
}

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

img {
  max-width: 100%;
  height: auto;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip:focus {
  left: 1rem;
  z-index: 1;
  background: var(--surface);
  padding: 0.5rem 1rem;
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  display: flex;
}

.brand img {
  display: block;
  height: 48px;
  width: auto;
}

.nav,
.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.nav a {
  font-weight: 600;
  text-decoration: none;
}

.button,
a.button {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
}

a.button:hover {
  background: var(--accent-strong);
  color: var(--on-accent);
}

a.button.secondary {
  background: transparent;
  color: var(--link);
  border: 1px solid var(--border);
}

a.button.secondary:hover {
  color: var(--text);
  border-color: var(--text-soft);
}

/* Content */

main {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 1.75em 0 0.5em;
}

h1 {
  font-size: 2rem;
  margin-top: 0.5em;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.2rem;
}

h4 {
  font-size: 1.05rem;
}

p,
ul,
ol,
blockquote,
pre {
  margin: 0 0 1em;
}

.lead {
  font-size: 1.2rem;
  color: var(--text-soft);
}

.muted {
  color: var(--text-soft);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1.5rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.features,
.steps,
.posts {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.features h3,
.steps h3 {
  margin-top: 0;
}

.features p,
.steps p {
  margin: 0;
}

.steps {
  counter-reset: step;
}

.steps li {
  counter-increment: step;
}

.steps h3::before {
  content: counter(step) '. ';
  color: var(--link);
}

.posts h2,
.posts h3 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}

.posts p {
  margin: 0.25rem 0 0;
}

.post-meta {
  color: var(--text-soft);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

/* A post's body: the editor's HTML (headings h2–h4, lists, quotes, code, links, images). */

.prose img {
  display: block;
  margin: 1.5rem auto;
  border-radius: 8px;
}

.prose blockquote {
  border-left: 4px solid var(--border);
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--text-soft);
}

.prose code {
  background: var(--code);
  border-radius: 4px;
  padding: 0.1em 0.3em;
  font-size: 0.92em;
}

.prose pre {
  background: var(--code);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.notice {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.95rem;
}

.footer-row {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
}

.site-footer .links {
  gap: 0.5rem 1.25rem;
}

/* Appearance picker (ADR-38): one icon button at the end of the header's menu, a small menu under it. The menu is
   placed against the header row, not the item, so it stays on screen when the menu wraps. */

.header-row {
  position: relative;
}

.appearance {
  display: flex;
}

.appearance-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.appearance-toggle:hover {
  border-color: var(--text-soft);
}

.appearance-menu {
  position: absolute;
  top: 100%;
  right: 1rem;
  z-index: 2;
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  min-width: 9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.appearance-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  text-align: left;
  cursor: pointer;
}

.appearance-menu button:hover {
  background: var(--accent-soft);
}

.appearance-menu button[aria-current='true'] {
  font-weight: 700;
}

.check {
  display: inline-block;
  width: 1em;
}

[aria-current='true'] > .check::before {
  content: '\2713';
}

@media (min-width: 40em) {
  .wrap {
    padding: 0 1.5rem;
  }

  h1 {
    font-size: 2.4rem;
  }

  .features {
    grid-template-columns: 1fr 1fr;
  }

  .appearance-menu {
    right: 1.5rem;
  }
}

/* The home page (PageMeta.Wide): full-width bands, each with its content in a wider .wrap; the bands alternate the page
   and the surface colour. Headings get a larger scale here. */

.wide .wrap {
  max-width: 72rem;
}

main.bands {
  padding: 0;
}

.band {
  padding: 3rem 0;
}

.band.alt {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.band h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.55rem, 1.1rem + 1.6vw, 2.15rem);
  line-height: 1.2;
  text-wrap: balance;
}

.band h3 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}

.band-head {
  max-width: 42rem;
  margin: 0 auto 2rem;
  text-align: center;
}

.band-head p {
  color: var(--text-soft);
  margin: 0;
}

.band-head .eyebrow {
  margin-bottom: 0.5rem;
}

.eyebrow {
  color: var(--link);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.button.large,
a.button.large {
  padding: 0.8rem 1.75rem;
  font-size: 1.1rem;
  border-radius: 10px;
}

.cta {
  margin: 1.75rem 0 0.75rem;
}

.fine {
  color: var(--text-soft);
  font-size: 0.95rem;
  margin: 0;
}

/* The hero: the question, one call to action, then the wide screenshot. */

.hero {
  padding-top: 2.5rem;
  text-align: center;
}

.hero h1 {
  margin: 0 auto 1rem;
  max-width: 18ch;
  font-size: clamp(2.1rem, 1.2rem + 4vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.hero h1 .name {
  color: var(--brand);
  white-space: nowrap;
}

.hero .lead {
  max-width: 40rem;
  margin: 0 auto;
}

.hero-figure {
  max-width: 62.5rem;
  margin: 2.5rem auto 0;
}

.caption {
  margin-top: 0.75rem;
  color: var(--text-soft);
  font-size: 0.9rem;
}

/* Screenshots: a light frame (border, radius, soft shadow); one picture per appearance, switched by CSS only. Without a
   cookie the root has no data-appearance and the <picture> (.v-auto) picks light or dark itself; with one, the <img>
   of that appearance shows. Hidden pictures are lazy and never displayed, so they are not fetched (_Screenshot). */

.shot {
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.shot img,
.shot picture {
  display: block;
  width: 100%;
  height: auto;
}

.shot .v {
  display: none;
}

:root:not([data-appearance]) .shot .v-auto,
:root[data-appearance='light'] .shot .v-light,
:root[data-appearance='dark'] .shot .v-dark,
:root[data-appearance='brown'] .shot .v-brown {
  display: block;
}

/* Three questions: a tile is a cropped screenshot (taken inside the tool's card, so its background is the surface
   colour and the frame's empty part blends in), the question and one sentence. */

.tiles,
.how,
.facts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tiles {
  display: grid;
  gap: 2rem;
  max-width: 34rem;
  margin: 0 auto;
}

.tile-shot {
  margin-bottom: 1rem;
}

.tiles p,
.step-text p,
.split-text p,
.facts p {
  color: var(--text-soft);
}

.tiles p {
  margin: 0;
}

/* How it works: numbered steps, text and screenshot side by side on wide screens, alternating sides. */

.how {
  counter-reset: step;
  display: grid;
  gap: 3rem;
}

.step {
  counter-increment: step;
  display: grid;
  gap: 1.25rem;
  align-items: center;
}

.step-text::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.step-text p:last-child,
.split-text p:last-child {
  margin-bottom: 0;
}

/* The trace: screenshot and text side by side on wide screens. */

.split {
  display: grid;
  gap: 1.75rem;
  align-items: center;
}

/* Four facts. */

.facts {
  display: grid;
  gap: 1rem;
}

.facts li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
}

.facts h3 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.facts p {
  margin: 0;
  font-size: 0.97rem;
}

/* The latest posts on the surface band. */

.band .posts {
  margin: 0;
}

.alt .card {
  background: var(--page);
}

.more {
  margin: 1.25rem 0 0;
  text-align: center;
}

.closing {
  text-align: center;
  padding: 3.5rem 0 4rem;
}

.closing p {
  color: var(--text-soft);
  margin: 0;
}

/* Without the posts' band the facts and the closing share the page colour: no second gap between them. */
.band:not(.alt) + .closing {
  padding-top: 0;
}

.closing .cta {
  margin-top: 1.5rem;
}

@media (min-width: 40em) {
  .band {
    padding: 4rem 0;
  }

  .hero {
    padding-top: 3.5rem;
  }

  .facts {
    grid-template-columns: 1fr 1fr;
  }

  .band .posts {
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  }
}

@media (min-width: 56em) {
  .tiles {
    grid-template-columns: repeat(3, 1fr);
    max-width: none;
  }

  /* Side by side the tiles share one frame shape, the tallest picture's; a wider one sits at the top. */
  .tile-shot {
    aspect-ratio: 520 / 411;
  }

  .tile-shot img,
  .tile-shot picture {
    height: 100%;
    object-fit: contain;
    object-position: top center;
  }

  .how {
    gap: 4.5rem;
  }

  .step,
  .split {
    grid-template-columns: 5fr 7fr;
    gap: 3.5rem;
  }

  .step:nth-child(even) {
    grid-template-columns: 7fr 5fr;
  }

  .step:nth-child(even) .step-text {
    order: 2;
  }

  .split {
    grid-template-columns: 7fr 5fr;
  }

  .facts {
    grid-template-columns: repeat(4, 1fr);
  }
}
