/* Detail-page-only styles.

   One centred column: the facts (dates, links, stack, tags) are part of the
   header, so the prose gets the middle of the page. The case-study column
   and header are laid out in css/article.css. */

.detail {
  /* Block padding only: a `0` on the sides here cancelled .wrap's gutter,
     which put the gallery flush against both edges of a phone and 24px off
     the header's rail on a desktop. */
  padding-block: 40px var(--section-gap);
}

.detail__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--gap-lg);
  color: var(--ink-soft);
  font-size: 13px;
}
.detail__back:hover { color: var(--accent-ink); }

.detail__head { margin-bottom: 40px; }

.detail__title {
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: var(--gap);
}

.detail__tagline {
  max-width: var(--measure-narrow);
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.5;
}

/* ---------- at a glance ----------
   Three rows at the head of a long article: problem, what got built, what
   came out of it. The prose below is worth the ten minutes; this is for
   deciding whether to spend them. */
.detail__glance {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 22px;
  margin: 0 0 var(--gap-xl, 48px);
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}
h2.detail__k { margin: 0 0 8px; font-weight: 500; line-height: 1.4; }
.detail__glance > div { display: contents; }
.detail__glance dt {
  color: var(--ink-muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.9;
  white-space: nowrap;
}
.detail__glance dd {
  margin: 0;
  color: var(--ink-body);
  font-size: 14.5px;
  line-height: 1.6;
}
@media (max-width: 640px) {
  .detail__glance { grid-template-columns: 1fr; gap: 4px; }
  .detail__glance dt { margin-top: 12px; }
}

/* ---------- all the way down: the matryoshka ----------
   The project as nested dolls (`nest` in project-data.js, drawn by
   js/project-detail.js). Painted in the day's three Wada colours; the face
   is --surface and the lines are --ink, so it follows the theme. The words
   are the list under the row, which is what a screen reader gets.

   It sits in the left margin beside "At a glance", at a third of its old
   size, and only from 1180px, where there is a margin to sit in. In the
   column it pushed the article 400px down and read as a toy. */
.nest { display: none; }
@media (min-width: 1180px) {
  .detail__body { position: relative; }
  .nest {
    display: block;
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    width: 168px;
  }
}
.nest__h {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font: 500 10px/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.nest__row {
  --k: 0.34;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 2px 6px;
  min-height: 84px;
  cursor: pointer;
}
.nest__doll { display: block; flex: none; width: calc(var(--h) * 0.5 * var(--k, 1)); height: calc(var(--h) * 1.25 * var(--k, 1)); }
.nest__doll svg { display: block; width: 100%; height: 100%; overflow: visible; }
.nest__shell { fill: var(--doll-a); stroke: var(--ink); stroke-width: 1.6; }
.nest__apron { fill: var(--doll-b); }
.nest__flower circle { fill: var(--doll-c); }
.nest__heart { fill: var(--surface); }
.nest__band { fill: var(--doll-c); }
.nest__face { fill: var(--surface); stroke: var(--ink); stroke-width: 1.2; }
.nest__hair { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
.nest__eye { fill: var(--ink); }
.nest__cheek { fill: var(--doll-c); opacity: 0.55; }
.nest__mouth { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; }
/* Opened: the head lifted off and tipped back. */
.nest__top { transform-box: fill-box; transform-origin: 15% 100%; }
.nest__doll.is-open .nest__top { transform: translateY(-8px) rotate(-12deg); }
.nest__doll.is-solid .nest__top { transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .nest__top { transition: transform 0.55s cubic-bezier(0.3, 1.4, 0.5, 1); }
  .nest__doll.is-new { animation: nest-out 0.6s cubic-bezier(0.2, 0.8, 0.3, 1) 0.15s backwards; }
  .nest__doll.is-shaking { animation: nest-shake 0.45s ease-in-out; transform-origin: 50% 100%; }
}
@keyframes nest-out {
  from { opacity: 0; transform: translateX(-60%) scale(0.85); }
}
@keyframes nest-shake {
  25% { transform: rotate(-7deg); }
  75% { transform: rotate(7deg); }
}
.nest__list { display: grid; gap: 6px; margin: 10px 0; padding-left: 1.4em; color: var(--ink-body); font-size: 12px; line-height: 1.45; }
.nest__list b { color: var(--ink); font-weight: 600; }
.nest__list em { color: var(--ink-muted); }
.nest__btn {
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font: 500 11px/1.2 var(--font-mono);
  cursor: pointer;
}
.nest__btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.nest__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.detail__nav {
  display: flex;
  justify-content: space-between;
  gap: var(--gap);
  margin-top: 48px;
  padding-top: var(--gap-lg);
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.detail__nav a { color: var(--ink-soft); }
.detail__nav a:hover { color: var(--accent-ink); }
/* Real text ("start of list" / "end of list"), not decoration, so it takes a
   token that clears AA rather than the dimmest thing that looks right. */
.detail__nav span { color: var(--ink-soft); }

/* Missing / unknown project id */
.detail__missing {
  padding: 60px 0;
  text-align: center;
}
.detail__missing h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  margin-bottom: var(--gap);
}
.detail__missing p {
  color: var(--ink-soft);
  margin-bottom: var(--gap-lg);
}

/* ==========================================================================
   Typeset formulas (js/tex.js)
   ========================================================================== */
.formula {
  overflow-x: auto;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--ink);
  /* Serif italic is the maths convention for variables; the mono stack the
     rest of the site uses reads as code, not notation. */
  /* Georgia first: 'Cormorant Garamond' was never loaded by any page, so the
     stack always silently fell through to it anyway. */
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 21px;
  font-style: italic;
  line-height: 2;
  text-align: center;
  white-space: nowrap;
}
.formula sub, .formula sup {
  font-size: 0.68em;
  font-style: italic;
  line-height: 0;
}

/* Fractions: stacked numerator over denominator with a real rule between. */
.tex-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: -0.52em;
  margin: 0 0.22em;
  text-align: center;
}
.tex-num { padding: 0 0.35em 2px; border-bottom: 1px solid currentColor; }
.tex-den { padding: 3px 0.35em 0; }

/* Sums/products with a lower limit set beneath the operator. */
.tex-bigop { font-size: 1.35em; font-style: normal; }
.tex-limits {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: -0.4em;
  margin: 0 0.15em;
}
.tex-under { font-size: 0.62em; line-height: 1.1; }

/* \text{} and operator names are upright — they are words, not variables. */
.tex-text, .tex-op { font-style: normal; }
.tex-op { margin: 0 0.12em; }
.tex-mathcal { font-family: 'Brush Script MT', cursive; font-style: normal; }
.tex-mathbb { font-weight: 600; font-style: normal; }
.tex-mathbf { font-weight: 700; font-style: normal; }
.tex-sp { display: inline-block; width: 0.32em; }
.tex-acc { position: relative; }
.tex-sqrt .tex-rad { border-top: 1px solid currentColor; padding: 0 0.2em; }

@media (max-width: 599.98px) {
  .formula { font-size: 17px; padding: 15px 16px; }
}

/* ==========================================================================
   Code blocks
   ========================================================================== */
.a-code {
  margin: 0 0 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-sunken);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 7px 10px 7px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}
.code-lang {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.code-copy {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  color: var(--ink-body);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.code-copy:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-tint);
}
.code-copy.is-done {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
  color: var(--on-accent-deep, #fff);
}
.a-code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.a-code figcaption { padding: 0 14px 12px; margin-top: 10px; }

/* ==========================================================================
   Hobby gallery page (hobby.html)
   ========================================================================== */
.hobby__blurb {
  max-width: var(--measure-narrow);
  margin: 0 0 26px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.65;
}

/* A mosaic: masonry columns. Each photograph keeps its own proportions
   (aspect-ratio from --ar, written by js/hobby-page.js from
   js/hobby-dims.js, so the box is right before the file arrives) and stacks
   in the shortest column, so portraits and landscapes interlock with no
   holes and no crop. Three columns, two on a tablet or phone. It replaced
   justified rows (2026-10-30), whose rows all shared one height. */
.hob-shots {
  columns: 3;
  column-gap: 10px;
  margin-bottom: 40px;
}
.hob-shot {
  position: relative;
  display: block;
  aspect-ratio: var(--ar, 1);
  margin: 0 0 10px;
  overflow: hidden;
  break-inside: avoid;
  border-radius: 3px;
  background: var(--bg-sunken);
}

/* The whole tile is the control that opens the popover. */
.hob-shot__btn {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.hob-shot__btn:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: -3px;
}
.hob-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur) var(--ease);
}
.hob-shot__btn:hover img { transform: scale(1.03); }

@media (prefers-reduced-motion: reduce) {
  .hob-shot img,
  .hob-shot__btn:hover img { transition: none; transform: none; }
}

.hob-shot figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 10px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  color: #fff;
  font-size: 12px;
  font-style: italic;
  line-height: 1.35;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  white-space: normal;
}
@media (max-width: 899.98px) {
  .hob-shots { columns: 2; }
}
@media (max-width: 599.98px) {
  .hob-shots { column-gap: 8px; }
  .hob-shot { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  .js .hob-shot img { transition: transform 0.4s var(--ease); }
  .js .hob-shot figcaption { opacity: 0; transition: opacity 0.26s var(--ease); }
  .js .hob-shot:hover img { transform: scale(1.05); }
  .js .hob-shot:hover figcaption { opacity: 1; }
}

/* ==========================================================================
   Phone (<=599px)
   Detail pages carry the densest content on the site — tables, code, formulas
   — so they need the most narrow-width attention.
   ========================================================================== */
@media (max-width: 599.98px) {
  .detail__title { font-size: clamp(26px, 8vw, 34px); }
  .detail__tagline { font-size: 15px; }

  /* Tables: a phone cannot show four columns, so let them scroll and hint it. */
  .table-scroll {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .code-head { padding: 6px 8px 6px 12px; }
  .code-copy { padding: 12px 15px; min-height: 44px; }

  .detail__nav { flex-direction: column; gap: 10px; }
  .detail__nav a { min-height: 44px; display: inline-flex; align-items: center; }

  .hobby__blurb { font-size: 15px; }
}

