/* City App Framework white paper: a scientific case study set as a web page. Plain CSS, no build step.
   Every color comes from the tokens in :root (checked by /city-app:ui:tokens). The palette borrows
   road-sign meaning: green signs guide (advice, like AGENTS.md), red signs stop (laws, like the hooks). */

@font-face {
  font-family: 'Literata';
  src: url('fonts/literata.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Literata';
  src: url('fonts/literata-italic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Overpass';
  src: url('fonts/overpass.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: 'Overpass Mono';
  src: url('fonts/overpass-mono.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #ffffff;
  --ink: #1e252b;
  --muted: #56616b;
  --concrete: #eef1f3;
  --line: #ccd4da;
  --link: #00674a;
  --guide: #00674a;
  --guide-ink: #ffffff;
  --stop: #b3261e;
  --caution: #f2b705;
  --hit: #00674a;
  --miss: #8a96a0;
  --focus: var(--ink);

  --serif: 'Literata', Charter, Georgia, serif;
  --sans: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Overpass Mono', ui-monospace, Menlo, Consolas, monospace;
  --measure: 44rem;
  --wide: 68rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d2226;
    --ink: #e7ecef;
    --muted: #a5afb8;
    --concrete: #262c31;
    --line: #3a434b;
    --link: #5fcb9a;
    --hit: #5fcb9a;
    --miss: #6b7680;
    --focus: var(--caution);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 800;
  line-height: 1.15;
}

h2 {
  font-size: clamp(1.625rem, 1.3rem + 1.4vw, 2.125rem);
  letter-spacing: -0.01em;
  margin-block: 3.5rem 1rem;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-block: 2.25rem 0.5rem;
}

p,
ul,
ol {
  margin: 0 0 1.1rem;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

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

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--concrete);
  border-radius: 0.3rem;
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

/* Inline code and sans run-ins would otherwise stretch the serif lines around them. */
p code,
li code,
td code,
th code,
.abstract p strong,
.rq strong,
.cite {
  line-height: 1;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  padding: 0.5rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 0.5rem;
  z-index: 1;
}

.skip:focus {
  top: 1rem;
}

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

/* The title block is a highway guide sign: green, rounded, a white border set in from the edge,
   and "exits" to the main parts of the paper. */
.sign {
  --focus: var(--caution);
  margin-block-start: clamp(1rem, 4vw, 2.5rem);
  padding: clamp(1.75rem, 5vw, 3.25rem);
  border-radius: 1.25rem;
  background: var(--guide);
  color: var(--guide-ink);
  font-family: var(--sans);
  box-shadow: inset 0 0 0 0.45rem var(--guide), inset 0 0 0 0.7rem var(--guide-ink);
}

.sign-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.sign h1 {
  font-size: clamp(1.875rem, 1.2rem + 3vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  max-width: 21ch;
}

.plate {
  margin: 0;
  padding: 0.2rem 0.75rem 0.1rem;
  border: 0.2rem solid var(--guide-ink);
  border-radius: 0.6rem;
  font-weight: 700;
  font-size: 1.125rem;
  white-space: nowrap;
}

.subtitle {
  margin: 1rem 0 0;
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.4375rem);
  font-weight: 600;
  line-height: 1.35;
}

.exits {
  list-style: none;
  margin: clamp(1.5rem, 4vw, 2.25rem) 0 0;
  padding: clamp(0.75rem, 2vw, 1.25rem) 0 0;
  border-top: 0.2rem solid var(--guide-ink);
}

.exits a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.35rem;
  color: var(--guide-ink);
  font-size: clamp(1.1875rem, 0.95rem + 1.1vw, 1.75rem);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.exits a:hover span {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

.arrow {
  flex: none;
  width: 1.3em;
  height: 1.3em;
  fill: currentColor;
}

.byline {
  max-width: var(--measure);
  margin-block: 1.5rem 0;
  font-family: var(--sans);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.byline strong {
  color: var(--ink);
}

.paper {
  max-width: var(--measure);
}

.abstract h2 {
  margin-block-start: 2.5rem;
}

.abstract p strong,
.rq strong {
  font-family: var(--sans);
}

.keywords {
  color: var(--muted);
  font-size: 1rem;
}

.toc {
  margin-block-start: 2.5rem;
  padding-block: 1.25rem;
  border-block: 1px solid var(--line);
  font-family: var(--sans);
}

.toc h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2 14rem;
  column-gap: 2rem;
}

.toc li {
  padding-block: 0.15rem;
}

.rq {
  list-style: none;
  padding: 0;
}

.rq li + li {
  margin-block-start: 0.4rem;
}

.points {
  padding-inline-start: 1.25rem;
}

.points li + li {
  margin-block-start: 0.5rem;
}

/* Tables in the booktabs style: rules above and below, none between columns. */
.data {
  width: 100%;
  margin-block: 1.75rem 2rem;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.data caption {
  caption-side: top;
  text-align: left;
  padding-block-end: 0.6rem;
  font-size: 1rem;
  line-height: 1.5;
}

.data caption b,
.figure-label {
  font-weight: 800;
}

.data th,
.data td {
  padding: 0.5rem 0.9rem 0.5rem 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.data thead th {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-weight: 700;
}

.data tbody th {
  font-weight: 600;
}

.data tbody tr:last-child > * {
  border-bottom: 2px solid var(--ink);
}

.data .num {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 30rem) {
  .data {
    font-size: 0.875rem;
  }

  .data th,
  .data td {
    padding-inline-end: 0.5rem;
  }
}

@media (max-width: 22.5rem) {
  .data {
    font-size: 0.8125rem;
  }

  .data th,
  .data td {
    padding-inline-end: 0.375rem;
  }
}

.data-note {
  margin-block: -1.25rem 2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.9375rem;
}

/* Figure 1: a rule's with/without result, drawn as runs. The squares repeat what the text says. */
.ab {
  margin: 2rem 0;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 2px solid var(--line);
  border-radius: 0.75rem;
  font-family: var(--sans);
}

.ab-rule {
  font-weight: 700;
  font-size: 1.125rem;
}

.ab table {
  border-collapse: collapse;
  margin-block-end: 1rem;
}

.ab th,
.ab td {
  padding: 0.4rem 1rem 0.4rem 0;
  text-align: left;
  font-weight: 400;
  vertical-align: middle;
}

.ab th,
.count {
  white-space: nowrap;
}

.runs {
  display: inline-flex;
  gap: 0.35rem;
  margin-inline-end: 0.75rem;
  vertical-align: middle;
}

.run {
  width: clamp(1rem, 0.8rem + 1vw, 1.25rem);
  height: clamp(1rem, 0.8rem + 1vw, 1.25rem);
  border: 2px solid var(--miss);
  border-radius: 0.2rem;
}

.run-hit {
  border-color: var(--hit);
  background: var(--hit);
}

.ab figcaption,
.figure figcaption {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
}

/* Figure 1: the development loop, drawn as a transit line with numbered stops. */
.route {
  list-style: none;
  counter-reset: stop;
  margin: 1.5rem 0 1rem 0.9rem;
  padding: 0 0 0 2rem;
  border-inline-start: 0.35rem solid var(--guide);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}

.route li {
  counter-increment: stop;
  position: relative;
  padding-block-end: 1.25rem;
}

.route li:last-child {
  padding-block-end: 0.25rem;
}

.route li::before {
  content: counter(stop);
  position: absolute;
  left: -3.3rem;
  top: -0.2rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding-block-start: 0.15rem;
  border: 0.3rem solid var(--guide);
  border-radius: 50%;
  background: var(--paper);
  font-weight: 800;
  font-size: 0.9375rem;
  line-height: 1;
}

.route b {
  display: block;
  font-size: 1.0625rem;
}

/* Where a result became part of the framework. */
.decision {
  padding: 0.75rem 1rem;
  border-inline-start: 0.3rem solid var(--guide);
  background: var(--concrete);
  border-radius: 0 0.4rem 0.4rem 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}

/* Figure 2: laws and customs, marked with the sign shapes they stand for. */
.figure {
  margin: 2rem 0;
}

.pair {
  display: grid;
  gap: 1.5rem 2.5rem;
  padding-block: 1.5rem;
  border-block: 1px solid var(--line);
  margin-block-end: 1rem;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}

@media (min-width: 40rem) {
  .pair {
    grid-template-columns: 1fr 1fr;
  }
}

.kind h4 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
}

.kind p {
  margin-block-end: 0.75rem;
}

.kind ul {
  margin: 0;
}

.marker {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
}

.stop-face {
  fill: var(--stop);
}

.guide-face {
  fill: var(--guide);
}

.sign-rim {
  fill: none;
  stroke: var(--guide-ink);
  stroke-width: 2;
}

.code {
  display: grid;
  justify-items: start;
  gap: 0.5rem;
  margin-block: 0.75rem 1.5rem;
}

.code pre {
  justify-self: stretch;
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  background: var(--concrete);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.7;
}

.code pre code {
  background: none;
  padding: 0;
  font-size: 1em;
  overflow-wrap: normal;
}

.copy {
  min-height: 2.25rem;
  padding: 0.3rem 0.8rem 0.15rem;
  border: 2px solid var(--ink);
  border-radius: 0.4rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.cite {
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.9em;
  white-space: nowrap;
}

.refs {
  padding-inline-start: 2.25rem;
  font-size: 1rem;
  line-height: 1.55;
}

.refs li {
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  overflow-wrap: anywhere;
}

.refs li:target {
  background: var(--concrete);
  border-radius: 0.3rem;
}

.cite-as {
  padding: 1rem 1.25rem;
  background: var(--concrete);
  border-radius: 0.5rem;
  font-size: 1rem;
}

.footer {
  margin-block-start: 4rem;
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 1rem;
}

.footer p {
  max-width: var(--measure);
}

@media print {
  :root {
    --paper: #ffffff;
    --ink: #000000;
    --muted: #333333;
    --link: #000000;
  }

  body {
    font-size: 10.5pt;
  }

  .skip,
  .exits,
  .copy {
    display: none;
  }

  .sign {
    margin: 0;
    padding: 0 0 0.5rem;
    background: none;
    color: var(--ink);
    box-shadow: none;
    border-radius: 0;
  }

  .plate {
    border-color: var(--ink);
  }

  h2,
  h3 {
    break-after: avoid;
  }

  .data,
  .ab,
  .figure {
    break-inside: avoid;
  }
}
