/* tsugi — a changelog mended in gold.
   Urushi ground, bone text, and gold only where something was repaired.
   Flat colour throughout: every fill is a single tone, every line a single weight. */

/* ---------- tokens ---------- */
:root {
  --bg: #14110f;
  --surface: #1f1a16;
  --fg: #e9e2d4;
  --muted: #a0978a;
  --accent: #d4a63c;
  --accent-fg: #1a1408;

  --fg-soft: color-mix(in srgb, var(--fg) 84%, var(--bg));
  --border: color-mix(in srgb, var(--fg) 12%, transparent);
  --hair: color-mix(in srgb, var(--fg) 24%, transparent);
  --gold-dim: color-mix(in srgb, var(--accent) 45%, var(--bg));

  --font-display: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-text: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-xs: 0.75rem;
  --text-sm: clamp(0.84rem, 0.81rem + 0.15vw, 0.9rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.15rem, 1.07rem + 0.4vw, 1.35rem);
  --text-xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --text-2xl: clamp(2.1rem, 1.6rem + 2.4vw, 3.4rem);
  --text-hero: clamp(4rem, 2.2rem + 7vw, 7.25rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
  --space-7: 6rem;

  --wrap: 70rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  /* The spine sits directly under the bowl's foot: the foot centre is
     50.4% across the bowl drawing, so the meta column is derived from the
     bowl's width. Narrow screens set --meta to 0 and the spine hugs the edge. */
  --bowl: min(41rem, 54vw);
  --spine: 2.5rem;
  --meta: calc(var(--bowl) * 0.504 - var(--spine) / 2);
  --mark: 1.2rem; /* how far below a row's top its join sits */

  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  margin: 0;
}

p { margin: 0; }

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

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

::selection { background: var(--accent); color: var(--accent-fg); }

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: var(--text-sm);
  text-decoration: none;
  transform: translateY(-300%);
  z-index: 10;
}
.skip-link:focus { transform: none; }

.label,
.gloss-def,
.site-nav a,
.foot-nav a,
.crumb a,
.change dt,
.filter label,
#log-h {
  font-family: var(--font-text);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.version {
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

time {
  font-size: var(--text-sm);
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------- header and footer ---------- */
.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-4) var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6em;
  min-height: 2.5rem;
  color: var(--fg);
  text-decoration: none;
}
.brand-ja { font-family: var(--font-display); font-size: var(--text-lg); }
.brand-name {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--muted);
  transition: color 160ms ease-out;
}
.brand:hover .brand-name { color: var(--fg); }

.site-nav, .foot-nav { display: flex; gap: var(--space-4); }

.site-nav a, .foot-nav a, .crumb a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  text-decoration: none;
  transition: color 160ms ease-out;
}
.site-nav a::after, .foot-nav a::after, .crumb a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.55rem;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease-out;
}
.site-nav a:hover, .foot-nav a:hover, .crumb a:hover { color: var(--fg); }
.site-nav a:hover::after, .foot-nav a:hover::after, .crumb a:hover::after { transform: scaleX(1); }

.site-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  margin-top: var(--space-7);
  padding-block: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}
.colophon { font-size: var(--text-sm); color: var(--muted); max-width: 44ch; }

/* ---------- the bowl ---------- */
.bowl {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  --b-clay: color-mix(in srgb, var(--muted) 40%, var(--bg));
  --b-glaze: color-mix(in srgb, var(--surface) 84%, var(--fg));
  --b-band: color-mix(in srgb, var(--surface) 92%, var(--fg));
  --b-lip: color-mix(in srgb, var(--surface) 70%, var(--fg));
  --b-inside: color-mix(in srgb, var(--surface) 55%, var(--bg));
}
/* the same bowl, set back, for pages that show a single seam */
.bowl--ghost {
  --b-clay: color-mix(in srgb, var(--muted) 24%, var(--bg));
  --b-glaze: color-mix(in srgb, var(--surface) 92%, var(--fg));
  --b-band: var(--surface);
  --b-lip: color-mix(in srgb, var(--surface) 82%, var(--fg));
  --b-inside: color-mix(in srgb, var(--surface) 45%, var(--bg));
}
.b-clay { fill: var(--b-clay); }
.b-glaze { fill: var(--b-glaze); }
.b-band { fill: var(--b-band); }
.b-lip { fill: var(--b-lip); }
.b-inside, .b-void { fill: var(--b-inside); }

.seam-line, .seam-fork {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.seam-line { stroke-width: 2.8; }
.seam-fork { stroke-width: 1.7; }
.seam-hit { fill: none; stroke: transparent; stroke-width: 18; pointer-events: stroke; }
.seam-lead { stroke: color-mix(in srgb, var(--muted) 42%, transparent); stroke-width: 0.75; }
.seam-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--muted);
  fill: currentColor;
  transition: color 160ms ease-out;
}

/* every seam is a link to its release */
.seam { transition: opacity 180ms ease-out; }
.seam:hover .seam-tag, .seam:focus-visible .seam-tag { color: var(--fg); }
.seam--new .seam-tag,
.seam--new:hover .seam-tag { color: var(--accent); }
.bowl:has(.seam:hover) .seam:not(:hover),
.bowl:has(.seam:focus-visible) .seam:not(:focus-visible) { opacity: 0.32; }
.seam:focus-visible { outline-offset: 5px; }

/* only the newest seam draws itself; it is whole within 0.8s */
.seam--new .seam-line {
  stroke-dasharray: 1 2;
  animation: seam-draw 520ms 120ms ease-out backwards;
}
.seam--new .seam-fork {
  stroke-dasharray: 1 2;
  animation: seam-draw 200ms 600ms ease-out backwards;
}
.seam--new .seam-lead, .seam--new .seam-tag {
  animation: seam-fade 240ms 80ms ease-out backwards;
}
@keyframes seam-draw { from { stroke-dashoffset: 1.02; } to { stroke-dashoffset: 0; } }
@keyframes seam-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: var(--bowl) minmax(0, 1fr);
  grid-template-areas: "bowl title" "bowl note";
  gap: var(--space-4) var(--space-6);
  padding-top: var(--space-4);
  border-bottom: 1px solid var(--hair); /* the shelf the bowl stands on */
}
.hero-bowl { grid-area: bowl; align-self: end; margin: 0; }
.hero-title { grid-area: title; align-self: start; }
.hero-note { grid-area: note; align-self: end; padding-bottom: var(--space-5); max-width: 25rem; }

.hero h1 {
  font-size: var(--text-hero);
  line-height: 1;
  letter-spacing: -0.01em;
  margin-left: -0.04em;
}
/* set under the title the way a dictionary sets a headword's reading */
.gloss { display: flex; align-items: baseline; gap: 0.9em; margin-top: var(--space-2); }
.gloss [lang="ja"] { font-family: var(--font-display); font-size: var(--text-lg); color: var(--fg); }

.hero-note > p:first-child { font-size: var(--text-lg); line-height: 1.55; color: var(--fg); }
.hero-note > p + p { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--muted); }

/* ---------- the spine ---------- */
.row {
  position: relative;
  display: grid;
  grid-template-columns: var(--meta) var(--spine) minmax(0, 1fr);
}
.row-meta { grid-column: 1; text-align: right; padding-right: var(--space-3); }
.row-body { grid-column: 3; padding-left: var(--space-3); }

/* One stretch of the crack. It runs from this row's join to the next row's,
   which is why it starts --mark down and overhangs the row by the same. */
.crack, .cracks {
  position: absolute;
  left: var(--meta);
  top: var(--mark);
  width: var(--spine);
  height: 100%;
  pointer-events: none;
}
.crack { overflow: visible; }
.crack path, .crack-tail path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.crack .crack-spur, .crack-tail .crack-spur { stroke-width: 0.8; }

/* a long page gets three stretches end to end instead of one stretched thin */
.cracks { display: flex; flex-direction: column; }
.cracks .crack { position: static; flex: 1 1 0; min-height: 0; height: auto; width: 100%; }

.join {
  position: absolute;
  left: calc(var(--meta) + var(--spine) / 2 - 11px);
  top: calc(var(--mark) - 5px);
  width: 22px;
  height: 10px;
  color: var(--accent);
}

.crack-end { height: 6rem; }
.crack-tail {
  position: absolute;
  left: var(--meta);
  top: var(--mark);
  width: var(--spine);
  height: auto;
  overflow: visible;
}

/* ---------- the log ---------- */
.log-head { align-items: center; padding-block: var(--space-4) var(--space-5); }
.log-head .crack { top: 0; height: calc(100% + var(--mark)); }
#log-h { color: var(--fg); }

.filter {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  max-width: 36rem;
  margin-left: var(--space-3);
  padding-left: 0;
  border-bottom: 1px solid var(--hair);
  transition: border-color 160ms ease-out;
}
.filter:focus-within { border-bottom-color: var(--accent); }
.filter input {
  flex: 1 1 8rem;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.filter input::placeholder { color: color-mix(in srgb, var(--muted) 70%, var(--bg)); opacity: 1; }
.filter input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.filter-status {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
}

.releases { list-style: none; margin: 0; padding: 0; }
.release { padding-bottom: var(--space-7); align-items: baseline; }

.release .version { font-size: var(--text-lg); line-height: 1.2; }
.release.is-latest .version { color: var(--accent); }
.release time { display: block; margin-top: 0.15rem; }

.release h3 { font-size: var(--text-xl); }
.release h3 a {
  color: var(--fg);
  text-decoration: none;
  transition: color 160ms ease-out;
}
.release h3 a:hover { color: var(--accent); }

.summary { margin-top: var(--space-2); max-width: 34rem; color: var(--fg-soft); }

.changes {
  display: grid;
  gap: var(--space-3);
  max-width: 38rem;
  margin: var(--space-4) 0 0;
  font-size: var(--text-sm);
  line-height: 1.65;
}
.change { display: grid; grid-template-columns: 6.75rem minmax(0, 1fr); column-gap: var(--space-3); }
.change dt { display: flex; align-items: center; gap: 0.6rem; height: 1.65em; font-size: 0.7rem; }
.change dd { margin: 0; }
.change ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; color: var(--fg-soft); }
.change li p { margin: 0; }
.glyph { flex: none; width: 12px; height: 12px; color: var(--accent); }

.more { margin-top: var(--space-4); font-size: var(--text-sm); }
.more a, .text-link, .prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-dim);
  transition: border-color 160ms ease-out;
}
.more a:hover, .text-link:hover, .prose a:hover { border-bottom-color: var(--accent); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--fg);
}
:not(pre) > code { overflow-wrap: anywhere; }

/* ---------- interior pages ---------- */
.lede { font-size: var(--text-lg); line-height: 1.55; color: var(--fg-soft); max-width: 34rem; }
.lede p { margin: 0; }

.prose { margin-top: var(--space-5); }
.prose > * { max-width: 38rem; }
.prose > * + * { margin-top: 1.15em; }
.prose h2 { font-size: var(--text-xl); margin-top: var(--space-5); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 500; color: var(--fg); }
.prose p, .prose li { color: var(--fg-soft); }

/* a short block keeps the prose measure; a wide report may run out to 46rem */
.prose > pre { width: fit-content; min-width: min(100%, 38rem); max-width: min(100%, 46rem); }
pre {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}
pre code { font-size: inherit; }
/* highlight.js ships its own ground and inks; put them back on the palette */
pre code.hljs { padding: 0; background: transparent; color: var(--fg-soft); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--muted); font-style: normal; }
.hljs-string, .hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-regexp {
  color: color-mix(in srgb, var(--accent) 50%, var(--fg));
}
.hljs-keyword, .hljs-built_in, .hljs-title, .hljs-name, .hljs-type, .hljs-attr,
.hljs-attribute, .hljs-section, .hljs-selector-tag, .hljs-selector-id,
.hljs-selector-class, .hljs-variable, .hljs-template-variable, .hljs-link,
.hljs-doctag, .hljs-subst, .hljs-params { color: var(--fg); }

/* a release page is one log entry opened out: same columns, same crack */
.lead-row { height: var(--space-6); align-items: start; }
.lead-row .crack { top: 0; height: calc(100% + var(--mark)); }
.crumb { margin-left: 0; }

.sheet-meta { position: sticky; top: var(--space-4); align-self: start; }
.sheet-meta .version { font-size: var(--text-xl); line-height: 1.2; color: var(--fg); }
.sheet-meta time { display: block; margin-top: 0.15rem; }
.seam-figure { margin: var(--space-5) 0 0 auto; max-width: 17rem; }
/* drawn small, a seam needs a heavier line to stay a seam */
.seam-figure .seam-line, .lost .seam-line { stroke-width: 5; }
.seam-figure .seam-fork { stroke-width: 3.2; }
.cat-row .seam-line { stroke-width: 6.5; }
.cat-row .seam-fork { stroke-width: 4; }
.seam-figure figcaption {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--muted);
}

.release-sheet { --mark: 1.45rem; }
.sheet-body h1 { font-size: var(--text-2xl); line-height: 1.12; }
.sheet-body .lede { margin-top: var(--space-3); }

.sheet-changes { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border); max-width: 46rem; }
.sheet-changes h2 { font-size: var(--text-xl); }

.sheet-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  max-width: 46rem;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.sheet-nav a {
  display: grid;
  gap: 0.2rem;
  min-height: 2.5rem;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--fg);
  text-decoration: none;
  transition: color 160ms ease-out;
}
.sheet-nav a:hover { color: var(--accent); }
.sheet-next { margin-left: auto; text-align: right; }

/* about, and the head of the catalogue */
.plain-page, .catalogue-head { padding-top: var(--space-6); }
.plain-page h1, .catalogue-head h1 { font-size: var(--text-2xl); line-height: 1.12; }
.plain-page .lede, .catalogue-head .lede { margin-top: var(--space-3); }
.page-mark {
  writing-mode: vertical-rl;
  justify-self: end;
  align-self: start;
  text-align: start;
  padding: 0.3rem var(--space-4) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: 1;
  letter-spacing: 0.12em;
  color: color-mix(in srgb, var(--muted) 55%, var(--bg));
}

/* the catalogue: every release beside the one seam it left */
.catalogue { list-style: none; margin: var(--space-6) 0 0; padding: 0; border-top: 1px solid var(--border); }
.cat-row {
  display: grid;
  grid-template-columns: calc(var(--meta) - var(--space-4)) 5.5rem minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-4);
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  text-decoration: none;
}
.cat-row .bowl { width: min(100%, 13rem); margin-left: auto; opacity: 0.86; transition: opacity 180ms ease-out; }
.cat-row:hover .bowl { opacity: 1; }
.cat-row .version { font-size: var(--text-lg); }
.cat-text { display: grid; gap: 0.3rem; }
.cat-name { font-family: var(--font-display); font-size: var(--text-xl); line-height: 1.2; transition: color 160ms ease-out; }
.cat-row:hover .cat-name { color: var(--accent); }
.cat-sum { font-size: var(--text-sm); line-height: 1.6; color: var(--muted); max-width: 32rem; }

/* 404 */
.lost { padding-top: var(--space-6); text-align: center; }
.lost .bowl { width: min(100%, 26rem); margin-inline: auto; }
.lost-code { margin-top: var(--space-5); font-family: var(--font-mono); font-size: var(--text-sm); color: var(--muted); }
.lost h1 { margin-top: var(--space-3); font-size: var(--text-2xl); }
.lost-note { max-width: 30rem; margin: var(--space-3) auto var(--space-4); color: var(--fg-soft); }

/* ---------- narrow screens ---------- */
@media (max-width: 56rem) {
  :root { --meta: 0px; --spine: 1.75rem; }

  .hero { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "bowl" "note"; border-bottom: 0; }
  .hero-bowl { border-bottom: 1px solid var(--hair); }
  .hero-note { padding-bottom: var(--space-2); }
  .log { border-top: 1px solid var(--border); }
  .seam-lead, .seam-tag { display: none; } /* too small to read; the seams stay links */

  .row { grid-template-columns: var(--spine) minmax(0, 1fr); }
  .row-meta { grid-column: 2; text-align: left; padding: 0 0 0 var(--space-2); }
  .row-body { grid-column: 2; padding-left: var(--space-2); }
  .filter { margin-left: var(--space-2); padding-left: 0; }

  .log-head { padding-block: var(--space-4); row-gap: var(--space-1); }
  .release { padding-bottom: var(--space-6); }
  .release .row-meta { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
  .release time { margin-top: 0; }
  .change { grid-template-columns: minmax(0, 1fr); row-gap: 0.3rem; }

  /* version and date on the left, the seam drawn small beside them */
  .sheet-meta {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8.5rem;
    column-gap: var(--space-3);
    align-content: start;
    margin-bottom: var(--space-4);
  }
  .sheet-meta .version, .sheet-meta time { grid-column: 1; }
  .seam-figure { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
  .seam-figure figcaption { display: none; }
  .lead-row { height: var(--space-5); }

  /* pages without a spine give its column back */
  .page-mark { display: none; }
  .plain-page, .catalogue-head { display: block; padding-top: var(--space-5); }
  .plain-page .row-body, .catalogue-head .row-body { padding-left: 0; }
  .cat-row { grid-template-columns: 5.5rem minmax(0, 1fr); align-items: baseline; row-gap: var(--space-2); }
  .cat-row .bowl { grid-column: 1 / -1; margin-left: 0; }
  .cat-row time { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
