/* Bonsai – The Living Collection: site styles. No framework, no outside requests. */

@font-face {
  font-family: "Noto Serif";
  src: url("fonts/NotoSerif-Latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans";
  src: url("fonts/NotoSans-Latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* Colour tokens: warm white paper, ink-dark text, one deep moss-green accent. */
:root {
  --paper: #f8f5ee;
  --panel: #efeadf;
  --ink: #1c1e19;
  --muted: #4b4e45;
  --accent: #34532a;
  --accent-soft: #dfe7d4;
  --rule: #d6cfbf;
  --focus: #34532a;
  --serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --gutter: 16px;
  --max: 72rem;
  --measure: 40rem;
  --header-h: 106px;
  --shade: #23271f;
  --on-shade: #ffffff;
  --on-shade-soft: #e9e6dc;
  /* Drawings in diagrams/ take these, so they follow the theme when placed in a page. */
  --diagram-ink: var(--ink);
  --diagram-moss: var(--accent);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121410;
    --panel: #1b1e18;
    --ink: #ebe7dd;
    --muted: #bdb9ad;
    --accent: #a8c98a;
    --accent-soft: #263022;
    --rule: #34372f;
    --focus: #a8c98a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.1rem, 1.4rem + 3.2vw, 3.75rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.35rem, 1.15rem + 0.9vw, 1.85rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main:focus { outline: none; }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
@media (min-width: 56rem) { :root { --gutter: 32px; } }

.skip {
  position: absolute; left: var(--gutter); top: -100px;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; z-index: 10;
}
.skip:focus { top: 0.5rem; }

/* Header and navigation, no script. Wide screens: the top bar of sections and a second row
   (Masters, Glossary, About). Phones: the same links in a <details> menu. */
.site-header { position: relative; border-bottom: 1px solid var(--rule); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; padding-block: 0.6rem; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.status {
  font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 0 0.6rem;
}
.site-nav { display: none; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink); text-decoration: none; font-size: 0.98rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--rule); }
.site-nav a[aria-current] { color: var(--accent); border-bottom-color: var(--accent); }
.site-nav a[aria-current="page"] { font-weight: 600; }
.site-nav .nav-secondary { padding-bottom: 0.25rem; }
.site-nav .nav-secondary a { font-size: 0.9rem; color: var(--muted); }
.site-nav .nav-secondary a[aria-current] { color: var(--accent); }

.menu { margin-left: auto; }
.menu-button {
  list-style: none; display: inline-flex; align-items: center; gap: 0.55rem; min-height: 44px;
  padding: 0 1rem; border: 1px solid var(--rule); border-radius: 999px; cursor: pointer;
  font-weight: 600; color: var(--ink); background: var(--paper);
}
.menu-button::-webkit-details-marker { display: none; }
.menu-button::after {
  content: ""; width: 0.45em; height: 0.45em; margin-top: -0.25em;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.menu[open] .menu-button::after { margin-top: 0.25em; transform: rotate(-135deg); }
.menu-panel {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: 0 10px 18px rgba(0, 0, 0, 0.14);
  padding-block: 0.25rem 1rem;
}
.menu-panel ul { list-style: none; margin: 0; padding: 0; }
.menu-panel a {
  display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none; font-size: 1.05rem;
}
.menu-panel .nav-secondary { margin-top: 0.75rem; }
.menu-panel .nav-secondary a { color: var(--muted); font-size: 1rem; }
.menu-panel a[aria-current] { color: var(--accent); font-weight: 600; }
@media (min-width: 48rem) {
  :root { --header-h: 140px; } /* measured: 140 px wide, 99 px on phones (106 px default kept) */
  .header-row { padding-block: 1rem 0; }
  .site-nav { display: block; }
  .menu { display: none; }
}

/* The small menu shared by the pages under "Our game, in development" and under "About". */
.subnav { background: var(--panel); border-bottom: 1px solid var(--rule); }
.subnav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
.subnav a {
  display: inline-flex; align-items: center; min-height: 44px; font-size: 0.92rem;
  color: var(--ink); text-decoration: none; border-bottom: 2px solid transparent;
}
.subnav li:first-child a { font-weight: 600; }
.subnav a:hover { border-bottom-color: var(--rule); }
.subnav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Page heads and text */
.kicker { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 0.75rem; }
.page-head { padding-top: clamp(1.5rem, 4vw, 3rem); padding-bottom: 1rem; }
.page-head h1 { max-width: 22ch; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: var(--measure); }
.note { color: var(--muted); max-width: var(--measure); }
.prose { padding-block: 1.5rem; }
.prose > section { max-width: var(--measure); margin-bottom: 2rem; }
.section { padding-block: clamp(2rem, 5vw, 3.5rem); }
.section-label { font-size: 0.85rem; font-family: var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* Home hero and page banners: the photograph full width (never wider than its source), with the
   words merged on in white over a shade rising from the bottom. On narrow screens the words sit in
   the shade just below the photograph, so they never cover the tree. */
.hero, .banner { position: relative; max-width: var(--src-w, 100%); margin-inline: auto; background: var(--shade); color: var(--on-shade); }
.hero-media, .banner-media { position: relative; }
/* The shade is only as dark as white text needs for 4.5:1 where the words sit
   (measured with tools/hero-contrast.mjs; results in review/hero-contrast.txt). */
.hero-media::after, .banner-media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(13, 15, 11, var(--shade-1, 0.68)) 0%, rgba(13, 15, 11, var(--shade-2, 0.62)) 20%, rgba(13, 15, 11, var(--shade-3, 0.42)) 38%, rgba(13, 15, 11, 0) 58%);
}
/* The hero never grows taller than the window below the header, so the words show without scrolling. */
.hero-img { width: 100%; height: auto; max-height: calc(100svh - var(--header-h, 100px)); object-fit: cover; object-position: var(--focus, 50% 50%); }
.hero-text { padding: 0.5rem var(--gutter) 1.75rem; }
.hero .kicker, .banner .kicker { color: var(--on-shade-soft); }
.hero h1 { font-size: clamp(2.5rem, 1.6rem + 4.5vw, 4rem); max-width: 14ch; margin-bottom: 0.25rem; color: var(--on-shade); }
.mission { margin: 1rem 0 0; max-width: 34rem; }
.mission-label { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-shade-soft); }
.mission blockquote { margin: 0.3rem 0 0; font-family: var(--serif); font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem); line-height: 1.4; }
.mission blockquote p { margin: 0; }
.hero h1, .hero p, .banner h1 { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
@media (min-width: 60rem) {
  /* The tree stands in the middle on its stand: the headline sits bottom left and the mission
     bottom right, over the pond either side of the stand, never over the tree. */
  .hero-text {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem;
    padding: 0 min(3vw, 112px) min(2.4vw, 84px);
  }
  .hero-head { max-width: 28%; }
  .hero .kicker { font-size: min(0.85vw, 1.4rem); margin-bottom: 0.4em; }
  .hero h1 { font-size: min(3.6vw, 140px); max-width: none; margin: 0; }
  .mission { margin: 0; max-width: 27%; }
  .mission-label { font-size: min(0.8vw, 1.3rem); }
  .mission blockquote { font-size: min(1.4vw, 54px); }
}
.banner-img { width: 100%; height: auto; aspect-ratio: 4 / 3; max-height: 80vh; object-fit: cover; object-position: var(--focus, 50% 50%); }
@media (min-width: 48rem) { .banner-img { aspect-ratio: 2 / 1; } }
.banner-text { padding: 0.25rem 0 1.25rem; }
.banner h1 { margin: 0; font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.75rem); color: var(--on-shade); }
@media (min-width: 48rem) {
  .banner-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 0 clamp(1.25rem, 2.6vw, 2.5rem); }
  .banner-text .wrap { max-width: var(--max); }
  .banner h1 { max-width: 30%; font-size: clamp(2.1rem, 1rem + 2.6vw, 3.5rem); }
}
.banner-credit { font-size: 0.8rem; color: var(--muted); padding-top: 0.5rem; margin-block: 0; }
.banner-credit .fig-tree { color: var(--muted); }
.headline { font-size: clamp(1.7rem, 1.3rem + 1.8vw, 2.6rem); max-width: 24ch; }

/* Figures */
.fig { margin: 0; }
.fig figcaption { font-size: 0.85rem; color: var(--muted); padding-top: 0.5rem; }
.fig-tree { color: var(--ink); }
.fig-hero { margin-block: 0 1rem; }
.fig-hero img { width: 100%; }
.fig-feature { max-width: var(--src-w, 100%); margin: 2rem auto 1rem; }
.fig-feature img { width: 100%; height: auto; }
.fig-wide { max-width: var(--max); margin: 1rem auto 2rem; padding-inline: var(--gutter); }
.pair { display: grid; gap: 1.5rem; padding-block: 1rem; }
.pair img { width: 100%; aspect-ratio: 5 / 4; object-fit: cover; object-position: var(--focus, 50% 50%); }
.gallery { display: grid; gap: 1.5rem; padding-block: 0.5rem 2rem; }
@media (min-width: 56rem) {
  .pair { grid-template-columns: 1fr 1fr; align-items: start; }
  .gallery { grid-template-columns: repeat(3, 1fr); align-items: end; }
}

/* Blocks */
.blocks { display: grid; gap: 1.25rem; }
@media (min-width: 56rem) { .blocks { grid-template-columns: repeat(3, 1fr); gap: 2rem; } }
.block { border-top: 3px solid var(--accent); padding-top: 1rem; }
.block p { margin-bottom: 0; }
.devices { margin-top: 2rem; font-size: 1.1rem; max-width: var(--measure); }

/* Early access: shows a status and sends nothing. */
.signup { background: var(--panel); border-left: 4px solid var(--accent); padding: 1.25rem 1.25rem 0.5rem; max-width: var(--measure); }
.signup h2 { font-size: 1.4rem; }
.signup-status { font-size: 1.15rem; font-weight: 600; }
.signup-note { color: var(--muted); }

.next-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.next-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: 1.1rem; font-weight: 600; }
.next-links a::after { content: "\2192"; margin-left: 0.4rem; }
@media (min-width: 56rem) { .next-links { grid-template-columns: repeat(3, max-content); gap: 2rem; } }

/* Builds and rules lists */
.steps, .rules { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: 1rem; max-width: 48rem; }
.steps li, .rules li { background: var(--panel); padding: 1.1rem 1.25rem 0.25rem; border-left: 4px solid var(--accent); }
.steps h2, .rules h2 { font-size: 1.3rem; }
.facts { padding-left: 1.2rem; }
.quote { margin: 0; font-family: var(--serif); font-size: 1.35rem; line-height: 1.45; border-left: 4px solid var(--accent); padding-left: 1rem; }
.contact { margin-top: 2rem; }

/* Credits */
.credits { list-style: none; margin: 1rem 0 2.5rem; padding: 0; display: grid; gap: 1.5rem; }
.credit { display: grid; gap: 1rem; border-top: 1px solid var(--rule); padding-top: 1.25rem; }
@media (min-width: 40rem) { .credit { grid-template-columns: 14rem 1fr; } }
.credit-tree { font-weight: 600; }
.credit dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.95rem; }
.credit dt { color: var(--muted); }
.credit dd { margin: 0; overflow-wrap: anywhere; }

/* Home: tiles, newest articles and the game band */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
@media (min-width: 40rem) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile a {
  display: flex; flex-direction: column; gap: 0.35rem; height: 100%; min-height: 44px;
  padding: 1.1rem 1.25rem 1.25rem; background: var(--panel); border-top: 3px solid var(--accent);
  color: var(--ink); text-decoration: none;
}
.tile a:hover { background: var(--accent-soft); }
.tile-title { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; line-height: 1.25; color: var(--accent); }
.tile-body { color: var(--muted); }
.tile-title::after, .more-link a::after, .band-link::after, .page-links a::after { content: "\2192"; content: "\2192" / ""; margin-left: 0.4rem; }
.more-link { margin: 1.25rem 0 0; }
.more-link a, .band-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; font-size: 1.05rem; }
.empty { color: var(--muted); font-size: 1.1rem; max-width: var(--measure); }
.band { background: var(--accent-soft); border-block: 1px solid var(--rule); margin-block: 1rem 1.5rem; }
.band-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 1.5rem; padding-block: 1.5rem; }
.band-text { margin: 0; font-family: var(--serif); font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem); line-height: 1.35; }
.band-link { font-size: 1.1rem; }

/* Article cards (home, section pages, the article index) */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem 1.75rem; }
@media (min-width: 40rem) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card { position: relative; }
.card-media img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; object-position: var(--focus, 50% 50%); }
.card-text { padding-top: 0.75rem; }
.card-section { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 0.25rem; }
.card-title { font-size: 1.25rem; margin: 0 0 0.4rem; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; }
.card:hover .card-title a { text-decoration: underline; }
.card-desc { color: var(--muted); font-size: 0.98rem; margin-bottom: 0.4rem; }
.card-date { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* Lists of pages (Our game, About) and of sections (the article index) */
.page-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem 2rem; }
@media (min-width: 56rem) { .page-links { grid-template-columns: repeat(2, 1fr); } }
.page-links li { border-top: 1px solid var(--rule); padding-top: 0.5rem; }
.page-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: 1.15rem; font-weight: 600; }
.page-links p { margin: 0; color: var(--muted); }
.section-links ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 1.75rem; }
.section-links a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.section-links .count { color: var(--muted); font-size: 0.9rem; }
.section-links .count::before { content: "("; }
.section-links .count::after { content: ")"; }
.check-steps { padding-left: 1.4rem; }
.check-steps li + li { margin-top: 0.5rem; }

/* Articles */
.article-head { padding-top: 0.75rem; }
.breadcrumb ol { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0 0.5rem; font-size: 0.9rem; }
.breadcrumb li + li::before { content: "\203A"; content: "\203A" / ""; color: var(--muted); margin-right: 0.5rem; }
.breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.breadcrumb a[aria-current] { color: var(--ink); text-decoration: none; }
.article-head h1 { max-width: 26ch; font-size: clamp(2rem, 1.4rem + 2.6vw, 3.25rem); }
.article-meta { color: var(--muted); font-size: 0.9rem; }
.fig-lead { margin-block: 0.5rem 1.5rem; }
.fig-lead img { width: auto; max-width: 100%; max-height: 78vh; margin-inline: auto; }
.fig-lead figcaption { max-width: var(--measure); }
.article-body { max-width: var(--measure); overflow-wrap: break-word; }
.article-body h2 { margin-top: 2.25rem; }
.article-body h3 { margin-top: 1.75rem; font-size: 1.2rem; }
.article-body ul, .article-body ol { padding-left: 1.4rem; margin: 0 0 1.25rem; }
.article-body li + li { margin-top: 0.4rem; }
.article-body li > ul, .article-body li > ol { margin: 0.4rem 0 0; }
.article-body blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 4px solid var(--accent); font-family: var(--serif); font-size: 1.1rem; }
.article-body hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
.article-body code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; background: var(--panel); padding: 0.05em 0.3em; }
.glance { background: var(--panel); border-left: 4px solid var(--accent); padding: 1rem 1.25rem 0.25rem; margin: 1.5rem 0 2rem; }
.article-body .glance-title { font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.5rem; }
.glance ul, .glance ol { padding-left: 1.1rem; }
.table-wrap { overflow-x: auto; margin: 1.25rem 0 1.75rem; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.table-wrap th, .table-wrap td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--rule); }
.table-wrap thead th { border-bottom: 2px solid var(--accent); font-weight: 600; }
.article-body .fig { margin: 1.75rem 0; }
.fig-article img { width: 100%; }
.fig-caption { color: var(--ink); }
.diagram-svg { display: block; width: 100%; height: auto; color: var(--diagram-ink); }
.diagram-img { display: block; width: 100%; height: auto; }
/* Helper classes a drawing may use instead of its own colours (tools/README.md, "Diagrams"). */
.diagram-svg .d-line { fill: none; stroke: currentColor; }
.diagram-svg .d-fill { fill: currentColor; }
.diagram-svg .d-moss { fill: var(--diagram-moss); }
.diagram-svg .d-moss-line { fill: none; stroke: var(--diagram-moss); }
.diagram-svg .d-soft { fill: var(--accent-soft); }
.diagram-svg .d-paper { fill: var(--paper); }
.diagram-svg .d-muted { fill: var(--muted); }
.article-foot { max-width: var(--measure); margin-top: 2rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.related ul { padding-left: 1.2rem; }
.checked a { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--rule); margin-top: 2rem; padding-block: 2rem 3rem; color: var(--muted); font-size: 0.95rem; }
.footer-text p { max-width: var(--measure); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .block, .steps li, .rules li, .signup, .tile a, .glance, .menu-button { border-color: CanvasText; }
}
