/* Route-level patterns: findings, the teardown, metric pairs, glossary
 * entries, and the essay. */

/* The whole site is one page; each section is an anchor target. The offset
 * keeps a jumped-to heading clear of the sticky navigation. */
.route-section {
  scroll-margin-block-start: 4rem;
}

.route-section + .route-section {
  border-block-start: 1px solid var(--rule);
}

/* A dark section supplies its own edge, so the rule would double it. */
.route-section:has(> .band--dark:first-child) {
  border-block-start: 0;
}

.route-title {
  font-size: var(--text-2xl);
  max-width: 20ch;
  margin-block-end: 1.25rem;
  text-wrap: balance;
}

.module {
  margin-block-start: 1.75rem;
}

/* Findings (on /) ---------------------------------------------------------- */

/* Three claims, each with its own number and a link to the module that
 * produces it. Not cards with icons, and not numbered: they are not sequential,
 * so numbering them would be decoration pretending to be structure. */
.findings {
  display: grid;
  gap: 2rem 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
  margin-block-start: 0.5rem;
}

.finding {
  padding-block-start: 1rem;
  border-block-start: 2px solid var(--accent);
}

.finding__title {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-snug);
  margin-block-end: 0.6rem;
  text-wrap: balance;
}

.finding__body {
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--text);
}

.finding__link {
  margin-block-start: 0.85rem;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Teardown (on /anatomy) --------------------------------------------------- */

.teardown__step {
  padding-block: 2.25rem;
  border-block-start: 1px solid var(--rule);
}

.teardown__step:first-child {
  border-block-start: 0;
}

.teardown__operation {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-block-end: 1.1rem;
  text-wrap: balance;
}

.teardown__pair {
  display: grid;
  gap: 1.5rem 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
}

.teardown__side {
  padding-inline-start: 1rem;
  border-inline-start: 2px solid var(--rule);
}

.teardown__side--dtc {
  border-inline-start-color: var(--series-dtc);
}

.teardown__side--token {
  border-inline-start-color: var(--series-token);
}

.teardown__vocab {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-block-end: 0.2rem;
}

.teardown__title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-block-end: 0.4rem;
}

.teardown__body {
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--text);
  max-width: 46ch;
}

.teardown__aside {
  margin-block-start: 1.25rem;
  padding-inline-start: 1rem;
  border-inline-start: 2px solid var(--accent);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text-muted);
  max-width: var(--measure);
}

/* Scroll-linked marking. Only opacity moves, and only once a step reaches
 * reading position; nothing animates on its own.
 *
 * 0.75 rather than something more dramatic because this dims real body text:
 * measured against the paper surface, 0.58 put it at 4.27:1 and under AA,
 * while 0.75 holds 7.57:1. De-emphasis must never cost legibility. */
.teardown[data-linked="true"] .teardown__step {
  transition: opacity var(--dur-slow) var(--ease);
  opacity: 0.75;
}

.teardown[data-linked="true"] .teardown__step.is-current {
  opacity: 1;
}

/* Dimming a step is decoration, not information, so reduced motion switches
 * it off entirely rather than merely making the fade instant. */
.teardown[data-reduced-motion="true"] .teardown__step {
  opacity: 1;
}

/* Metric pairs (on /metrics) ---------------------------------------------- */

.pairs {
  margin-block-start: 1.5rem;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr 15rem;
  gap: 1.25rem 2rem;
  padding-block: 1.1rem;
  border-block-start: 1px solid var(--rule);
  align-items: start;
}

.pair__head {
  padding-block: 0.4rem;
  border-block-start: 0;
  border-block-end: 1px solid var(--rule-strong);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.pair__head .pair__side,
.pair__head .pair__meta {
  margin: 0;
}

.pair__term {
  font-size: var(--text-base);
  font-weight: 600;
  margin-block-end: 0.1rem;
}

.pair__vocab {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-block-end: 0.35rem;
}

/* Redundant wherever the column header is showing. */
@media (min-width: 38.001rem) {
  .pairs .pair:not(.pair__head) .pair__vocab {
    display: none;
  }
}

.pair__definition {
  font-size: var(--text-sm);
  line-height: 1.55;
  max-width: 42ch;
}

.pair__formula {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums lining-nums;
}

.pair__note {
  margin-block-start: 0.5rem;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--text-muted);
}

@media (max-width: 60rem) {
  .pair {
    grid-template-columns: 1fr 1fr;
  }

  .pair__meta {
    grid-column: 1 / -1;
  }

  .pair__head {
    display: none;
  }
}

@media (max-width: 38rem) {
  .pair {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  /* On one column the vocabulary tag is the only thing distinguishing the two
   * halves, so it earns a rule of its own. */
  .pair__side + .pair__side {
    padding-block-start: 0.9rem;
    border-block-start: 1px dashed var(--rule);
  }
}

/* Glossary (on /glossary) ------------------------------------------------- */

.entries {
  margin-block-start: 1.5rem;
  columns: 2;
  column-gap: 3rem;
}

.entry {
  break-inside: avoid;
  padding-block: 1rem;
  border-block-start: 1px solid var(--rule);
  /* Anchored jumps must not land under the sticky nav. */
  scroll-margin-block-start: 5rem;
}

.entry__head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.entry__term {
  font-size: var(--text-base);
  font-weight: 600;
}

.entry__vocab {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.05rem 0.4rem;
  border-radius: 2px;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
}

.entry__definition {
  margin-block-start: 0.35rem;
  font-size: var(--text-sm);
  line-height: 1.55;
}

.entry__link {
  margin-block-start: 0.4rem;
  font-size: var(--text-xs);
}

.entry__link::before {
  content: "See also ";
  color: var(--text-muted);
}

@media (max-width: 46rem) {
  .entries {
    columns: 1;
  }
}

/* Essay (on /essay) ------------------------------------------------------- */

.essay {
  margin-block-start: 1.5rem;
}

.essay h2 {
  scroll-margin-block-start: 5.5rem;
}

.essay__meta {
  margin-block-start: 2.5rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--rule);
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: var(--measure);
}

.fn-ref {
  font-size: 0.72em;
  font-weight: 600;
  line-height: 0;
}

.fn-ref a {
  text-decoration: none;
  padding-inline: 0.1em;
}

.fn-ref a:hover {
  text-decoration: underline;
}

.footnotes {
  margin-block-start: 3rem;
  padding-block-start: 1.25rem;
  border-block-start: 1px solid var(--rule);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footnotes h2 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-block-end: 0.75rem;
}

.footnotes ol {
  padding-inline-start: 1.2rem;
}

.footnotes li {
  margin-block-end: 0.75rem;
  line-height: 1.55;
  scroll-margin-block-start: 5.5rem;
}

.fn-back {
  text-decoration: none;
  margin-inline-start: 0.2em;
}
