/* The diagram library (/figures/) and the single-figure pages. Tokens from DESIGN.md
   via site.css; figure cards: --paper-light ground, 1px --rule border, 16px padding. */

/* ---------------------------------------------------------------- library */
.figparts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.figparts a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  font: 400 .875rem var(--f-mono); letter-spacing: .02em; color: var(--ink); text-decoration: none;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-light);
}
@media (hover: hover) { .figparts a:hover { border-color: var(--ink); } }

.figlib { padding-bottom: var(--section); }
.figpart { padding-top: clamp(48px, 6vw, 80px); scroll-margin-top: calc(var(--nav-h) + 16px); }
.figpart h2 { font-size: clamp(1.75rem, 3.2vw, 2.5rem); letter-spacing: -0.025em; line-height: 1.05; }
.figpart__num { color: var(--teal); }
.figpart > .label { margin: 8px 0 24px; }

.figgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gutter); }
.figcard {
  display: flex; flex-direction: column; gap: 10px; height: 100%; box-sizing: border-box;
  padding: 16px; background: var(--paper-light); border: 1px solid var(--rule);
  color: inherit; text-decoration: none; transition: border-color .15s, transform .2s var(--ease);
}
@media (hover: hover) { .figcard:hover { border-color: var(--ink); transform: translateY(-2px); } }
.figcard:active { transform: translateY(0); }
.figcard img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; }
.figcard .label { margin-top: 4px; }
.figcard__cap { font-size: 1rem; line-height: 1.45; color: var(--ink); }
@media (max-width: 960px) { .figgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .figgrid { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- one figure */
.page-head--figure h1 { font-size: clamp(1.9rem, 4vw, 3.25rem); line-height: 1.05; max-width: 28ch; letter-spacing: -0.03em; }
.figpage__num { color: var(--teal); }

.figpage { padding-block: clamp(40px, 6vw, 80px) var(--section); }
.figpage__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); }
.figpage__art { grid-column: 1 / span 8; margin: 0; min-width: 0; }
.figpage__art img { width: 100%; height: auto; box-sizing: border-box; background: var(--paper-light); border: 1px solid var(--rule); padding: clamp(16px, 3vw, 40px); }
.figpage__cap { margin-top: 16px; font-size: 1.0625rem; line-height: 1.55; color: var(--ink-soft); max-width: 64ch; }
.figpage__cap strong { color: var(--ink); margin-right: .4em; }

.figpage__aside { grid-column: 9 / span 4; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.figpage__box { padding: 32px; background: var(--paper-light); border: 1px solid var(--rule); }
.figpage__box h2 { font-size: 1.35rem; margin-bottom: 12px; letter-spacing: -0.015em; }
.figpage__box p { font-size: 1rem; }
.figpage__box .btn { width: 100%; box-sizing: border-box; margin-top: 8px; }
.figpage__terms { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.figpage__terms a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; font-size: 1rem; text-decoration: none; border: 1px solid var(--rule); border-radius: var(--radius); color: var(--teal); }
@media (hover: hover) { .figpage__terms a:hover { border-color: var(--teal); text-decoration: underline; } }
.figpage__box label { display: block; margin: 12px 0 6px; }
.figpage__embed {
  display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; resize: vertical;
  font: 400 .8125rem/1.5 var(--f-mono); color: var(--ink); background: var(--paper);
  border: 1px solid var(--ink); border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere;
}
.figpage__embed:focus-visible { outline-offset: 2px; }

.figpage__nav { grid-column: 1 / span 8; display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--rule); font-size: 1rem; }
.figpage__nav a { display: inline-flex; flex-direction: column; gap: 2px; padding: 8px 0; min-width: 0; max-width: 48%; }
.figpage__nav a span { font: 400 .8125rem var(--f-mono); color: var(--ink-soft); }
.figpage__next { text-align: right; margin-left: auto; }

@media (max-width: 860px) {
  .figpage__art, .figpage__aside, .figpage__nav { grid-column: 1 / -1; }
  .figpage__aside { margin-top: 40px; }
  .figpage__box { padding: 24px; }
}
