/* medsimlali.com: every value comes from the closed sets in DESIGN.md */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* spacing */
  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 32px;
  --s5: 64px;
  --s6: 128px;
  /* type */
  --t1: 14px;
  --t2: 17px;
  --t3: 24px;
  --t4: 40px;
  --t5: 64px;
  --lh-text: 1.5;
  --lh-display: 1.05;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* palette */
  --bg: #F3EDE2;
  --surface: #E9E1D2;
  --text: #1C1A17;
  --text-2: #5C554A;
  --rule: #CBBFA9;
  --accent: #22367A;
  /* radius */
  --r0: 0;
  --r1: 2px;
  /* layout, derived from tokens */
  --measure: 62ch;
  --max: calc(var(--s6) * 10);
  --motion: 150ms;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--t2);
  font-weight: 400;
  line-height: var(--lh-text);
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: var(--s1);
  text-decoration-color: var(--text);
  transition: text-decoration-color var(--motion), color var(--motion);
}
a:hover { text-decoration-color: var(--accent); }

:focus-visible {
  outline: var(--r1) solid var(--accent);
  outline-offset: var(--r1);
  border-radius: var(--r1);
}

.mono {
  font-family: var(--mono);
  font-size: var(--t1);
  line-height: var(--lh-text);
  color: var(--text-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--s3);
  top: var(--s3);
  padding: var(--s2) var(--s3);
  background: var(--text);
  color: var(--bg);
  transform: translateY(calc(var(--s6) * -1));
}
.skip:focus { transform: none; }

/* ---------- layout ---------- */

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--s3);
}

.row > * + * { margin-top: var(--s3); }

/* ---------- header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule);
}
.site-header .name {
  font-weight: 700;
  text-decoration: none;
}
.site-header nav { display: none; }
.site-header nav a {
  color: var(--text-2);
  text-decoration: none;
  margin-right: var(--s4);
}
.site-header nav a:hover { color: var(--text); }
.header-right { display: flex; align-items: center; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  padding: var(--s3) var(--s4);
  border-radius: var(--r0);
  white-space: nowrap;
  transition: background-color var(--motion);
}
.btn:hover { background: var(--text); color: var(--bg); }
.site-header .btn { padding: var(--s2) var(--s3); }

/* ---------- intro ---------- */

.intro { padding-top: var(--s5); }
.intro h1 {
  font-size: var(--t4);
  line-height: var(--lh-display);
  font-weight: 700;
}
.lead {
  font-size: var(--t3);
  max-width: var(--measure);
  margin-top: var(--s4);
}
.facts {
  margin-top: var(--s4);
  padding-top: var(--s3);
  border-top: 1px solid var(--text);
  display: grid;
  gap: var(--s2);
}
.facts div { display: flex; gap: var(--s2); flex-wrap: wrap; }
.facts dt { color: var(--text-2); }
.facts dd { color: var(--text); }

/* ---------- sections ---------- */

.section {
  margin-top: var(--s5);
  padding-top: var(--s3);
  border-top: 1px solid var(--text);
}
.section h2 {
  font-size: var(--t4);
  line-height: var(--lh-display);
  font-weight: 700;
}
.section-label { text-transform: uppercase; }

/* ---------- work entries ---------- */

.entry {
  margin-top: var(--s5);
  padding-bottom: var(--s5);
  border-bottom: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 0; padding-bottom: 0; }

.entry-num { color: var(--text-2); }
.entry h3 {
  font-size: var(--t3);
  line-height: var(--lh-text);
  font-weight: 700;
  max-width: var(--measure);
}
.meta { display: grid; gap: var(--s1); }
.meta div { display: grid; grid-template-columns: calc(var(--s5) + var(--s4)) 1fr; gap: var(--s2); }
.meta dt { text-transform: uppercase; }
.meta dd { color: var(--text); }

.entry p,
.entry .built { max-width: var(--measure); }
.entry h3 + p { margin-top: var(--s2); }
.entry p + p,
.entry p + .built,
.built + figure,
.entry p + figure { margin-top: var(--s3); }

.built li {
  padding: var(--s2) 0;
  border-top: 1px solid var(--rule);
}
.built li:last-child { border-bottom: 1px solid var(--rule); }

/* ---------- figures (HTML flow diagrams) ---------- */

figure { margin-top: var(--s4); }
.plate {
  background: var(--surface);
  padding: var(--s4) var(--s3);
}
figcaption { margin-top: var(--s2); max-width: var(--measure); }

.node {
  display: block;
  background: var(--bg);
  border: 1px solid var(--text);
  padding: var(--s2) var(--s3);
}
.node .mono { color: var(--text); }
.node.is-key { border-color: var(--accent); }
.node.is-key,
.node.is-key .mono { color: var(--accent); }

.arrow {
  display: block;
  font-family: var(--mono);
  font-size: var(--t1);
  color: var(--text);
  text-align: left;
  padding: var(--s1) var(--s3);
}
.arrow::before { content: "\2193"; }
.arrow.is-key { color: var(--accent); }

.flow-1 { display: grid; gap: var(--s1); }
.roles { display: grid; gap: var(--s1); }
.fn-list { margin-top: var(--s1); }

.flow-2 { display: grid; gap: var(--s1); }

/* ---------- also built ---------- */

.also li {
  display: grid;
  grid-template-columns: calc(var(--s5) + var(--s4)) 1fr;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-top: 1px solid var(--rule);
  max-width: calc(var(--measure) + var(--s6));
}
.also li:last-child { border-bottom: 1px solid var(--rule); }
.also .mono { text-transform: uppercase; padding-top: var(--s1); }

/* ---------- method ---------- */

.steps { margin-top: var(--s4); }
.block { display: block; }

.steps li {
  display: grid;
  grid-template-columns: var(--s4) 1fr;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-top: 1px solid var(--rule);
  max-width: calc(var(--measure) + var(--s4));
}
.steps li:last-child { border-bottom: 1px solid var(--rule); }
.steps .mono { padding-top: var(--s1); }

/* ---------- closing + footer ---------- */

.closing .btn { margin-top: var(--s4); }
.closing .mono { margin-top: var(--s3); }

.site-footer {
  margin-top: var(--s5);
  padding: var(--s4) 0 var(--s5);
  border-top: 1px solid var(--rule);
}

/* ---------- 404 ---------- */

.notfound { padding: var(--s6) 0; }
.notfound h1 {
  font-size: var(--t4);
  line-height: var(--lh-display);
  font-weight: 700;
}
.notfound p { margin-top: var(--s4); }

/* ---------- desktop: Swiss grid ---------- */

@media (min-width: 960px) {
  .wrap { padding: 0 var(--s5); }

  .row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--s4);
  }
  .row > * + * { margin-top: 0; }
  .col-label { grid-column: 1 / 4; }
  .col-content { grid-column: 5 / 13; }
  .col-narrow { grid-column: 5 / 11; }
  .col-wide { grid-column: 1 / 11; }

  .site-header nav { display: block; }

  .intro { padding-top: var(--s6); }
  .intro h1 { font-size: var(--t5); }
  .intro .lead,
  .intro .facts { grid-column: 5 / 13; }
  .intro .lead { margin-top: var(--s5); }
  .intro .facts { margin-top: var(--s4); }
  .facts { grid-template-columns: repeat(3, auto); justify-content: start; column-gap: var(--s5); }
  .facts div { flex-direction: column; gap: var(--s1); }

  .section { margin-top: var(--s6); }
  .entry { margin-top: var(--s6); }

  .arrow { text-align: center; padding: var(--s1); align-self: center; }
  .arrow::before { content: "\2192"; }

  .flow-1 {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--s2);
  }
  .flow-2 {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: var(--s1);
  }
  .flow-2 .node { display: flex; align-items: center; padding: var(--s2); }
  .plate { padding: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  body { background: var(--bg); }
  :root { --bg: #FFFFFF; --surface: #FFFFFF; }
  .site-header .btn,
  .closing .btn,
  .skip { display: none; }
  .print-url { display: block !important; }
}
.print-url { display: none; }
