/* Second Stratum
   A ledger layout: hairline rules, numbered columns, slab headings.
   Six colors live on :root. Everything else refers to them by name. */

:root {
  --paper: #EFF5F0;
  --ink: #122614;
  --muted: #3C533E;
  --accent: #1A6620;
  --rule: #B9CABB;
  --tint: #C4E9C7;

  --font-display: Rockwell, Cambria, Georgia, serif;
  --font-text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --gutter: 1rem;
  --wide: 72rem;
  --measure: 42rem;
}

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

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

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

img,
svg,
canvas,
select,
button,
input {
  max-width: 100%;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 0.6em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.2rem, 1.4rem + 3.6vw, 4.25rem);
  margin-bottom: 0.5em;
}

h2 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.5rem);
}

h3 {
  font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.35rem);
}

p {
  margin: 0 0 1em;
  max-width: var(--measure);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--ink);
}

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

.wrap {
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

@media (min-width: 48rem) {
  .wrap {
    padding-inline: clamp(1.5rem, 4vw, 3rem);
  }
}

/* Skip link */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 0.6rem 1rem;
  background-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--gutter);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Header and navigation */

.site-header {
  padding-block: 1.1rem 1rem;
  border-bottom: 4px double var(--ink);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1.5rem;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  display: block;
  width: 2rem;
  height: 2rem;
  flex: none;
}

.mark-wall {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linecap: square;
}

.mark-route {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

.nav-list,
.footer-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a,
.footer-list a {
  color: var(--ink);
  text-decoration: none;
  padding-block: 0.2rem;
}

.nav-list a:hover,
.nav-list a[aria-current="page"],
.footer-list a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* Masthead and bands */

.masthead {
  padding-block: clamp(2.5rem, 6vw, 5rem) clamp(2rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}

.kicker {
  margin-bottom: 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead {
  max-width: 38rem;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.3rem);
  line-height: 1.55;
}

.band {
  padding-block: clamp(2.25rem, 5vw, 4rem);
  border-bottom: 1px solid var(--rule);
}

.band > .wrap > h2 {
  margin-bottom: 0.4em;
}

.section-intro {
  color: var(--muted);
}

.actions {
  margin-top: 1.5rem;
  max-width: none;
}

/* Buttons and links that act as buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  margin: 0 0.6rem 0.6rem 0;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: 0;
  background-color: var(--accent);
  color: var(--paper);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background-color: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.button-quiet {
  background-color: var(--paper);
  border-color: var(--muted);
  color: var(--ink);
}

.button-quiet:hover {
  background-color: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* Ledger table (index) */

.index-table {
  width: 100%;
  margin-top: 1.5rem;
  border-collapse: collapse;
  table-layout: fixed;
  border-top: 2px solid var(--ink);
}

.index-table caption {
  caption-side: top;
  padding-bottom: 0.6rem;
  text-align: left;
  font-size: 0.9rem;
  color: var(--muted);
}

.index-table th,
.index-table td {
  padding: 0.9rem 0.35rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.index-table thead th {
  padding-block: 0.6rem;
  border-bottom: 1px solid var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.index-table .col-folio {
  width: 2.75rem;
}

.index-table .col-kind {
  width: 5rem;
}

.index-table tbody tr:hover {
  background-color: var(--tint);
}

.col-num {
  margin-right: 0.3em;
  font-family: var(--font-display);
  color: var(--accent);
}

.folio {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: lining-nums tabular-nums;
}

.entry-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.entry-note {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.kind {
  font-size: 0.9rem;
}

@media (min-width: 40rem) {
  .index-table th,
  .index-table td {
    padding: 1.1rem 0.75rem;
  }

  .index-table .col-folio {
    width: 4.5rem;
  }

  .index-table .col-kind {
    width: 9rem;
  }
}

/* Ledger rows (numbered prose sections) */

.ledger {
  margin-top: 1.5rem;
  border-top: 2px solid var(--ink);
}

.ledger-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  column-gap: 0.8rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.ledger-num {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--accent);
}

.ledger-row h3 {
  margin-bottom: 0.4em;
}

.ledger-row p:last-child {
  margin-bottom: 0;
}

@media (min-width: 40rem) {
  .ledger-row {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    column-gap: 1.25rem;
    padding-block: 1.6rem;
  }
}

/* Maze lab */

.no-js-note {
  display: none;
}

.no-js .no-js-note {
  display: block;
}

.no-js .js-lab {
  display: none;
}

.lab-controls {
  min-width: 0;
  margin: 1.5rem 0 1rem;
  padding: 1rem 0 0;
  border: 0;
  border-top: 2px solid var(--ink);
}

.lab-controls legend {
  margin-bottom: 0.9rem;
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.8rem;
  margin-bottom: 0.9rem;
}

.control-row label {
  font-weight: 600;
}

.control-row select {
  min-height: 2.75rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--muted);
  border-radius: 0;
  background-color: var(--paper);
  color: var(--ink);
  font: inherit;
}

.control-row input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
}

.control-row .button {
  margin: 0;
}

.lab-status {
  max-width: 40rem;
  margin: 0 0 1.25rem;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 4px solid var(--accent);
}

.lab-figure {
  margin: 0;
}

.lab-canvas {
  display: block;
  width: 100%;
  max-width: 40rem;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--ink);
  background-color: var(--paper);
}

.lab-figure figcaption,
.sample-figure figcaption {
  max-width: 40rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.keyboard-note {
  max-width: 40rem;
  margin-top: 1rem;
  color: var(--muted);
}

/* Fixed sample (readable without scripts) */

.sample-figure {
  margin: 1.5rem 0 0;
}

.sample-svg {
  display: block;
  width: 100%;
  max-width: 26rem;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--ink);
  background-color: var(--paper);
}

.sample-wall {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: square;
}

.sample-route {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sample-mark {
  fill: var(--accent);
}

/* Footer */

.site-footer {
  padding-block: 2.5rem 2rem;
  border-top: 4px double var(--ink);
}

.footer-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 40rem) {
  .footer-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: start;
  }
}

.footer-brand {
  margin-bottom: 0.4rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.footer-note {
  font-size: 0.95rem;
  color: var(--muted);
}

.footer-copy {
  margin: 1.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Motion: transitions only when the reader has not asked for less motion */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  a,
  .button,
  .nav-list a,
  .footer-list a,
  .index-table tbody tr {
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, text-decoration-color 160ms ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
