/*
 * The content pages: guide, rhythm dictionary, articles and the policy pages.
 *
 * Separate from styles.css on purpose. That file is the app — 6000 lines of
 * panels, dialogs and editors — and a reading page needs none of it; loading
 * it here would also mean every app refactor could restyle a policy page by
 * accident. What is shared is the palette, copied as tokens, so the pages read
 * as the same product as the guide inside the app.
 *
 * Every page here is generated by tools/build-site.mjs. Edit site/, not the
 * HTML.
 */

:root {
  color-scheme: dark;
  --bg: #080605;
  --panel: #120e0b;
  --panel-deep: #0d0a08;
  --line: rgba(215, 168, 59, 0.22);
  --line-soft: rgba(255, 255, 255, 0.08);
  --gold: #d7a83b;
  --gold-bright: #f4d77b;
  --cream: #f4ead7;
  --text: rgba(244, 234, 215, 0.86);
  --muted: rgba(244, 234, 215, 0.58);
  --faint: rgba(244, 234, 215, 0.38);
  --radius: 14px;
  --sans: system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto,
    sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia,
    "Nanum Myeongjo", serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --measure: 46rem;
  --gutter: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 85% 0%, rgba(135, 69, 26, 0.22), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

a {
  color: var(--gold-bright);
  text-decoration-color: rgba(244, 215, 123, 0.4);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
  padding: 10px max(var(--gutter), env(safe-area-inset-left));
  background: rgba(8, 6, 5, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.site-brand img {
  width: 26px;
  height: 26px;
}

/* Four short links, so a grid of equal tracks rather than a flex row: a label
   that grows later clips instead of pushing the app button off a phone. */
.site-nav {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px 18px;
  margin-left: auto;
  font-size: 0.92rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--gold-bright);
}

.site-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: #140d05;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.site-cta:hover {
  background: var(--gold-bright);
}

@media (max-width: 640px) {
  /* Two rows on a phone, so it stops being sticky there: 90px of header
     pinned over a 375px-wide article is a fifth of the screen gone. */
  .site-header {
    position: static;
    gap: 10px 12px;
    backdrop-filter: none;
  }

  .site-brand {
    font-size: 0.95rem;
  }

  .site-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    font-size: 0.88rem;
  }

  .site-cta {
    margin-left: auto;
  }
}

/* ── Page frame ─────────────────────────────────────────────────────────── */

.site-main {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 20px var(--gutter) 64px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--faint);
}

.crumbs li + li::before {
  content: "/";
  margin-right: 6px;
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.page-head {
  margin-bottom: 40px;
}

.kicker,
.sec-num {
  margin: 0 0 10px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--cream);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(2rem, 7vw, 2.9rem);
  font-weight: 600;
}

.lead {
  margin: 0;
  font-size: 1.12rem;
  color: var(--text);
}

.page-meta {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 0.88rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 10px;
  margin: 24px 0 0;
}

.facts div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-deep);
}

.facts dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--faint);
}

.facts dd {
  margin: 2px 0 0;
  color: var(--cream);
  font-weight: 600;
}

/* ── Sections ───────────────────────────────────────────────────────────── */

.doc-section {
  padding: 32px 0;
  border-top: 1px solid var(--line-soft);
}

.doc-section h2 {
  margin: 0 0 16px;
  font-size: 1.45rem;
}

.doc-section h3 {
  margin: 28px 0 8px;
  font-size: 1.1rem;
}

.doc-section p {
  margin: 0 0 14px;
}

.doc-section ul,
.doc-section ol {
  margin: 0 0 14px;
  padding-left: 1.3rem;
}

.doc-section li {
  margin-bottom: 6px;
}

.doc-section li::marker {
  color: var(--gold);
}

kbd,
code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--panel);
  color: var(--cream);
}

b,
strong {
  color: var(--cream);
}

.note {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.95rem;
}

.note p:last-child {
  margin-bottom: 0;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0 !important;
}

.steps > li {
  position: relative;
  padding: 0 0 18px 48px;
  counter-increment: step;
}

.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.steps > li > strong:first-child {
  display: block;
  margin-bottom: 2px;
}

/* A table is the one thing here allowed to be wider than a phone; it scrolls
   inside its own box rather than pushing the page sideways. */
.table-wrap {
  margin: 0 0 18px;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

th {
  color: var(--faint);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  background: var(--panel-deep);
}

tr:last-child td {
  border-bottom: 0;
}

td.wrap {
  white-space: normal;
  min-width: 12rem;
}

/* ── Cards (index pages) ────────────────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s;
}

a.card:hover {
  border-color: var(--gold);
}

.card-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

/* ── Rhythm figures ─────────────────────────────────────────────────────── */

.figure {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-deep);
}

.figure-big .rhythm-preview {
  display: block;
  width: 100%;
  height: auto;
  color: var(--gold-bright);
}

.figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.variants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.variant {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel);
}

.variant .rhythm-preview {
  display: block;
  width: 100%;
  height: auto;
  color: var(--cream);
}

.variant-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--cream);
  font-weight: 600;
  font-size: 0.95rem;
}

.variant-name small {
  color: var(--faint);
  font-family: var(--mono);
  font-weight: 400;
}

.rhythm-preview .rp-string {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 0.6;
}

.rhythm-preview .rp-beat {
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 0.7;
}

.rhythm-preview .rp-beat-edge {
  stroke: rgba(255, 255, 255, 0.32);
  stroke-width: 1.1;
}

.rhythm-preview .rp-stroke {
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.rhythm-preview .rp-note {
  fill: currentColor;
  stroke: none;
}

.rhythm-preview .rp-mute {
  fill: currentColor;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

/* ── Next / related ─────────────────────────────────────────────────────── */

.try-app {
  margin: 40px 0 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 100% 0%, rgba(215, 168, 59, 0.14), transparent 18rem),
    var(--panel);
  text-align: center;
}

.try-app h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.try-app p {
  margin: 0 0 16px;
  color: var(--muted);
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 32px;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  padding: 28px var(--gutter) calc(32px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: var(--panel-deep);
  color: var(--faint);
  font-size: 0.86rem;
}

.footer-grid {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px 24px;
}

.footer-owner {
  display: flex;
  flex-direction: column;
}

.footer-owner strong {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--gold-bright);
}

.footer-note {
  max-width: var(--measure);
  margin: 16px auto 0;
}
