/* figures.css — the shared figure parts for the home, About and the Writing room.
   Loaded through each page's pageStyles. Built from the patterns in
   posts/revisiting-down-and-out.css (the post keeps its own file).
   Pen + pixel marks (docs/pen-and-pixel.md): meaning rides on marks, never colour;
   marks sit in a strip at the edge and always beside a word; text never sits on
   texture. Moss = where to look. Dark mode comes from the tokens. No script. */

/* ── The panel ── */
.fig{
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
/* Type for .fig__title and .fig-seq__kicker: the tracked label, in
   components.css (docs/brand.md → Type → Labels). Here: place and colour. */
.fig__title{
  margin: 0 0 .8rem;
  color: var(--muted);
}
.fig figcaption{ margin-top: .8rem; font-size: var(--text-sm); color: var(--muted); line-height: 1.5; }

/* ── Legend: a word beside each mark ── */
.fig__legend{ display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin: .9rem 0 0; padding: 0; list-style: none; font-size: var(--text-sm); color: var(--ink-soft); }
.fig__legend li{ display: flex; align-items: center; gap: .45rem; margin: 0; }
.fig__mk{ display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--mark); }
.fig__mk--ruled{ background: var(--mark-ruled); }
.fig__mk--hatch{ background: var(--mark-hatch); }
.fig__mk--solid{ background: var(--mark-solid); }
.fig__mk--dither{ background: var(--mark-dither); }
.fig__mk--dashed{ box-shadow: none; border: 1.5px dashed var(--mark); }
.fig__mk--moss{ box-shadow: inset 0 0 0 2px var(--moss); }

/* ── Chips: mono word on --bg, the mark in a 6px strip at the left edge ── */
.fig__chips{ display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip{
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 0;
  padding: .15rem .45rem .15rem calc(6px + .4rem);
  font-family: var(--mono);
  font-size: var(--text-xs);
  line-height: 1.3;
  color: var(--ink);
  background: var(--bg);
  background-image: linear-gradient(90deg, transparent 0 6px, var(--bg) 6px);
  border: 1px solid var(--mark);
  border-radius: var(--radius-sm);
}
.chip--ruled{ background-image: linear-gradient(90deg, transparent 0 6px, var(--bg) 6px), var(--mark-ruled); }
.chip--hatch, .chip--budding{ background-image: linear-gradient(90deg, transparent 0 6px, var(--bg) 6px), var(--mark-hatch); }

/* ── The writing bed: one chip per piece, the stage mark at its edge ──
   seedling = dashed edge, no strip · budding = hatch strip · evergreen = solid
   strip · no stage = plain (its hidden word says "stage not set"). Moss is only
   for the newest piece; amber only on the in-progress pill (components.css). */
.fig--bed .fig__legend{ margin: 0 0 .9rem; }
.fig--bed .bed__group{
  display: grid;
  grid-template-columns: 8ch minmax(0,1fr) auto;
  grid-template-areas: "label chips count";
  gap: var(--space-sm) .75rem;
  align-items: baseline;
  padding: .55rem 0;
  border-top: 1px solid var(--rule);
}
.bed__label, .bed__count{ margin: 0; font-family: var(--mono); font-size: var(--text-xs); line-height: 26px; }
.bed__label{ grid-area: label; color: var(--ink); }
.bed__count{ grid-area: count; color: var(--muted); text-align: right; white-space: nowrap; }
.bed__chips{ grid-area: chips; align-self: start; }
.bed__chips li{ display: inline-flex; align-items: center; gap: 6px; margin: 0; }
a.chip{ color: var(--ink); text-decoration: none; } /* color: a:visited (base.css) outranks .chip alone */
a.chip:hover{ text-decoration: underline; text-underline-offset: .16em; }
.chip--seedling{ border: 1.5px dashed var(--mark); }
.chip--evergreen{ background-image: linear-gradient(90deg, transparent 0 6px, var(--bg) 6px), var(--mark-solid); }
.chip--newest{ border: 2px solid var(--moss); }
.chip--newest.chip--seedling{ border-style: dashed; }
.chip__newest{ font-family: var(--mono); font-size: var(--text-xs); color: var(--moss); }
.chip .index-pill{ flex: none; margin-inline-start: 1ch; }

/* ── How writing works here (the Writing room): one piece at its three
   stages, dashed → hatch → solid, each chip over the words for its stage.
   The chips are pictures, not links; the words carry the meaning. ── */
.stages{ display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem var(--space-md); margin: 0; padding: 0; list-style: none; }
.stages__step{ display: grid; justify-items: start; align-items: center; row-gap: .35rem; margin: 0; }
.stages__step + .stages__step{ grid-template-columns: auto auto; column-gap: var(--space-md); }
.stages__step + .stages__step > *{ grid-column: 2; }
.stages__step + .stages__step::before{ content: "\2192"; content: "\2192" / ""; grid-column: 1; grid-row: 1; align-self: center; font-family: var(--mono); line-height: 1; color: var(--muted); }
.stages__word{ font-family: var(--mono); font-size: var(--text-xs); color: var(--ink-soft); }

/* ── The Writing room's index: an eyebrow over each block's rows; a group of
   more than 12 rows splits by year under a mono label (not a heading). ── */
.writing-block{ margin-top: var(--flow); }
.writing-block > h2{ margin: 0 0 var(--space-sm); }
.writing-block > .index-table{ margin-top: var(--space-md); }
.writing-year{ margin: var(--space-md) 0 0; padding-bottom: var(--space-xs); border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--muted); }
.writing-year:first-child{ margin-top: 0; }

/* ── The join: the system | the path | the people ── */
.fig__join{
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(140px,220px) minmax(0,1fr);
  gap: .75rem;
  align-items: center;
}
.fig__box{ background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: .8rem; }
.fig__box-title{ margin: 0 0 .55rem; font-family: var(--display); font-weight: 600; font-size: 1.05rem; line-height: 1.2; color: var(--ink); }
.fig__svg{ display: block; width: 100%; height: auto; overflow: visible; }
.fig__svg--v{ display: none; }
.fig__svg text{ font-family: var(--mono); fill: var(--muted); }
.fig__svg--h text{ font-size: 11px; }
.fig__svg--v text{ font-size: 8px; }
.fig__svg .fig__label--moss{ fill: var(--moss); font-weight: 600; }
.fig__line{ fill: none; stroke-linecap: round; }
.fig__line--moss{ stroke: var(--moss); stroke-width: 2; }
.fig__line--dotted{ stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 0 4.5; }
.fig__line--dashed{ stroke: var(--mark); stroke-width: 1.5; stroke-dasharray: 5 4; stroke-linecap: butt; }
.fig__head{ fill: var(--moss); }

@media (max-width: 600px){
  .fig__join{ grid-template-columns: minmax(0,1fr); }
  .fig__svg--h{ display: none; }
  .fig__svg--v{ display: block; width: 165px; max-width: 100%; margin: 0 auto; }
}

@media (max-width: 520px){
  /* The label sits above its chips; the count stays right. */
  .fig--bed .bed__group{ grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "label count" "chips chips"; gap: .35rem .75rem; }
}

@media print{
  .fig{ break-inside: avoid; }
  /* Keep the marks on paper. print.css clears every background with !important
     (it is tuned for the résumé), so the marks re-assert themselves here,
     narrowly: swatches and chip strips only, never a panel or box fill. The
     light-mode values are pinned so a print from dark mode stays legible; the
     four mark gradients are re-declared (as in tokens.css) so each element
     re-resolves them against the pinned --mark instead of :root's dark ink. */
  .fig, .fig *{
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    --mark: #3a453d; --moss: #5b3fa3; --muted: #595249; --amber: #b07a0f;
    --mark-solid: linear-gradient(var(--mark), var(--mark));
    --mark-ruled: repeating-linear-gradient(0deg, var(--mark) 0 1.5px, transparent 1.5px 4px);
    --mark-hatch: repeating-linear-gradient(45deg, var(--mark) 0 1.5px, transparent 1.5px 4.5px);
    --mark-dither: conic-gradient(var(--mark) 25%, transparent 0 50%, var(--mark) 0 75%, transparent 0) 0 0 / 4px 4px;
  }
  .fig__mk{ box-shadow: inset 0 0 0 1px var(--mark) !important; }
  .fig__mk--dashed{ box-shadow: none !important; }
  .fig__mk--moss{ box-shadow: inset 0 0 0 2px var(--moss) !important; }
  .fig__mk--ruled{ background: var(--mark-ruled) !important; }
  .fig__mk--hatch{ background: var(--mark-hatch) !important; }
  .fig__mk--solid{ background: var(--mark-solid) !important; }
  .fig__mk--dither{ background: var(--mark-dither) !important; }
  .chip--ruled{ background: linear-gradient(90deg, transparent 0 6px, #fff 6px), var(--mark-ruled) !important; }
  .chip--hatch, .chip--budding{ background: linear-gradient(90deg, transparent 0 6px, #fff 6px), var(--mark-hatch) !important; }
  .chip--evergreen{ background: linear-gradient(90deg, transparent 0 6px, #fff 6px), var(--mark-solid) !important; }
}

/* ── About's sequence: the join told in three states, three panels in a row.
   clear: both keeps it below the floated portrait. Inside it the join's inner
   grid is always one column and the vertical drawing shows (as on a phone).
   Each step is kicker / panel / sentence on shared rows, so the three panels
   match in height. The content is top-aligned and the legend sits at the foot,
   so the three frames read as one picture gaining a part each step. ── */
.fig-seq{
  clear: both;
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  grid-template-rows: auto 1fr auto;
  gap: 0 var(--space-md);
  margin: var(--space-lg) 0;
}
.fig-seq__step{ display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; min-width: 0; }
.fig-seq__kicker{ margin: 0 0 var(--space-sm); color: var(--muted); }
.fig-seq .fig{ display: flex; flex-direction: column; margin: 0; }
.fig-seq__text{ margin: .6rem 0 0; font-size: var(--text-sm); line-height: 1.5; color: var(--ink); }
.fig-seq .fig__join{ flex: 1; grid-template-columns: minmax(0,1fr); align-content: start; }
.fig-seq .fig__svg--h{ display: none; }
.fig-seq .fig__svg--v{ display: block; width: 165px; max-width: 100%; margin: 0 auto; }
@media (max-width: 760px){
  .fig-seq{ grid-template-columns: minmax(0,1fr); grid-template-rows: none; gap: var(--space-lg) 0; }
  .fig-seq__step{ grid-row: auto; grid-template-rows: auto; }
  .fig-seq .fig__join{ flex: none; }
}
