/* tinyfragments.com. Kanagawa Lotus (light, darkened for WCAG AA) and
   Kanagawa Wave (dark). scripts/test_contrast.py holds the tokens to 4.5:1. */

:root {
  --bg: #F2ECBC;
  --surface: #E8E1B6;
  --fg: #43436C;
  --muted: #5A5960;
  --accent: #3B5687;
  --accent2: #4F6436;
  --border: #D5CEA3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1F28;
    --surface: #2A2A37;
    --fg: #DCD7BA;
    --muted: #9A978A;
    --accent: #7E9CD8;
    --accent2: #98BB6C;
    --border: #363646;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 40rem is about 68 characters of body text. In rem, not ch, so the footer's
   smaller type doesn't make its column narrower than the page's. */
header.site, main, footer.site {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- header / footer --------------------------------------------------- */

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.brand {
  color: var(--fg);
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
}
.brand span { color: var(--accent); }

header.site nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover { color: var(--accent); }

footer.site {
  margin-top: 4rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9375rem;
}
footer.site p { margin: 0.25rem 0; }
.fine { font-size: 0.875rem; }

.cta {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: 8px;
  color: var(--fg);
}

/* ---- type -------------------------------------------------------------- */

h1, h2, h3 { line-height: 1.25; margin: 2rem 0 0.75rem; }
h1 { font-size: 2rem; margin-top: 0.5rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

p, li { overflow-wrap: anywhere; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code, pre {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}
code { background: var(--surface); padding: 0.1em 0.3em; border-radius: 4px; }
pre {
  background: var(--surface);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.45;
}
pre code { background: none; padding: 0; }

/* Wide tables scroll inside their own box instead of widening the page. */
table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1rem 0;
}
th, td { padding: 0.4rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

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

figure { margin: 1.5rem 0; }
figure img, figure video { display: block; border-radius: 8px; border: 1px solid var(--border); }
/* Phone screenshots: a whole column of phone is too much on a desktop. */
/* min(): 22rem alone overrides max-width: 100% and overflows a 360 px phone. */
.hero.narrow img, .hero.narrow video { max-width: min(22rem, 100%); margin: 0 auto; }

figcaption { color: var(--muted); font-size: 0.9375rem; margin-top: 0.5rem; }

/* ---- home ---------------------------------------------------------------- */

.intro { margin-bottom: 2.5rem; }
.intro p { font-size: 1.125rem; }

/* The card grid is allowed wider than the reading column. */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: min(64rem, calc(100vw - 32px));
  margin-left: 50%;
  transform: translateX(-50%);
}
@media (min-width: 40rem) {
  .cards { grid-template-columns: 1fr 1fr; }
}

.card {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card img { display: block; width: 100%; border-radius: 6px; margin-bottom: 0.75rem; }
.card h2 { margin: 0 0 0.25rem; font-size: 1.125rem; color: var(--accent); }
.card p { margin: 0; color: var(--muted); }

/* ---- project pages ----------------------------------------------------- */

.outcome { font-size: 1.25rem; color: var(--muted); margin-top: 0; }

.numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}
.numbers li {
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border-radius: 999px;
  color: var(--accent2);
  font-weight: 600;
}

details.built {
  margin: 2.5rem 0 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
details.built > summary {
  cursor: pointer;
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}
details.built > summary::-webkit-details-marker { display: none; }
details.built > summary::before { content: "▸ "; }
details.built[open] > summary::before { content: "▾ "; }
details.built > summary:hover { border-color: var(--accent); }

.prevnext {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
}
.prevnext a[rel="next"] { margin-left: auto; }
