/* A research-post layout: serif reading column, sans for labels and data, a contents list in the left margin.
   The painting (watercolor washes, oil-stick scrawl) opens the page and runs down the outer margins. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #26262a;
  --soft: #4a4a50;
  --muted: #84848c;
  --line: #e7e7ea;
  --blue: #a9d8f2;
  --blue-deep: #2f8fc9;
  --card: #f5f7f9;
  --text: 44rem;
  --figure: 50rem;
  --pad: clamp(1.25rem, 5vw, 2rem);
  --serif: "Iowan Old Style", "Iowan Old Style BT", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--blue);
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

a:hover {
  text-decoration-color: var(--blue-deep);
}

code {
  font-family: var(--mono);
  font-size: 0.8em;
  overflow-wrap: anywhere;
}

/* ── backdrop: a faint drawing fixed behind the page, moving slowly the whole time ──
   A rolled, half-wiped repeat of one tooth; a sprayed line with drips that keeps redrawing itself; a tooth printed
   as a coarse screen of dots; a hand-drawn tooth chart; an arch of teeth as on the film, with the dentist's box
   and a guess that wanders towards it. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.backdrop .wash {
  position: absolute;
  inset: -8%;
  background: url("/projects.html/periapicalbench/wash.webp") center / cover no-repeat;
  opacity: 0.2;
  animation: wash 28s ease-in-out infinite alternate;
}

.figures {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* hand-drawn boil: every line exists twice, shown in turn */
.bb,
.ba {
  animation: boil 0.56s steps(1) infinite;
}

.bb {
  animation-delay: -0.28s;
}

.stencil {
  opacity: 0.16;
}

.roll {
  animation: roll 14s linear infinite;
}

.spray {
  stroke-dasharray: 1 1;
  animation: spray 90s linear infinite;
}

.sprays {
  stroke: #9fb4c6;
  animation: fade 52s linear infinite;
}

.jawline,
.float {
  opacity: 0.32;
}

/* the whole arch breathes: it opens and closes a little, like a jaw */
.jawline {
  transform-origin: 50% 100%;
  animation: bite 4.6s ease-in-out infinite alternate;
}

/* each tooth in the arch rocks a little in its socket, out of step with its neighbours */
.rock {
  transform-box: fill-box;
  transform-origin: 50% 20%;
  animation: rock 2.9s ease-in-out infinite alternate;
}

.halftone {
  fill: #2a3948;
  opacity: 0.28;
}

.halftone .dark {
  fill: var(--blue-deep);
}

.scan {
  animation: scan 2.6s ease-in-out infinite;
}

.wipe {
  stroke: #ffffff;
  opacity: 0.75;
  filter: blur(7px);
  animation: wipe var(--t, 30s) ease-in-out infinite alternate;
}

.drip {
  stroke: #9fb4c6;
  opacity: 0.45;
  transform-box: fill-box;
  transform-origin: top;
  animation: drip var(--t, 20s) ease-in infinite;
}

.toothchart {
  opacity: 0.26;
}

.struck path {
  stroke-width: 1.8;
  stroke-dasharray: 1 1;
  animation: strike 10s ease-in-out infinite;
  animation-delay: inherit;
}

.gold {
  stroke: var(--blue-deep);
  stroke-width: 2;
  opacity: 0.5;
}

.guess {
  stroke: #2a3948;
  stroke-width: 1.3;
  stroke-opacity: 0.5;
  stroke-dasharray: 5 4;
  transform-box: fill-box;
  animation: guess 8s ease-in-out infinite;
}

.float {
  transform-box: fill-box;
  animation: float var(--t, 30s) ease-in-out infinite alternate;
}

@keyframes boil {
  0% { visibility: visible; }
  50%, 100% { visibility: hidden; }
}

@keyframes roll {
  to { transform: translate(44px, 52px); }
}

@keyframes spray {
  0% { stroke-dashoffset: 1; }
  80%, 100% { stroke-dashoffset: 0; }
}

@keyframes fade {
  0%, 92% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes wash {
  to { transform: translate(4%, -3.5%) scale(1.1) rotate(1.5deg); }
}

@keyframes scan {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.12; }
}

@keyframes wipe {
  from { transform: translate(-90px, 24px); }
  to { transform: translate(130px, -50px); }
}

@keyframes drip {
  0% { transform: scaleY(0); opacity: 0; }
  8% { opacity: 0.45; }
  70%, 90% { transform: scaleY(1); opacity: 0.45; }
  100% { transform: scaleY(1); opacity: 0; }
}

@keyframes strike {
  0%, 12% { stroke-dashoffset: 1; }
  22%, 82% { stroke-dashoffset: 0; }
  94%, 100% { stroke-dashoffset: 1; }
}

/* the guess starts well off the lesion, hunts, and settles with partial overlap */
@keyframes guess {
  0% { transform: translate(56px, -42px); opacity: 0; }
  10% { opacity: 1; }
  30% { transform: translate(-36px, 26px); }
  52% { transform: translate(24px, 18px); }
  70%, 88% { transform: translate(5px, 3px); opacity: 1; }
  100% { transform: translate(5px, 3px); opacity: 0; }
}

@keyframes float {
  from { transform: translate(-26px, 54px) rotate(-18deg); }
  to { transform: translate(30px, -66px) rotate(18deg); }
}

@keyframes rock {
  from { transform: translateY(6px) rotate(-10deg); }
  to { transform: translateY(-14px) rotate(10deg); }
}

@keyframes bite {
  from { transform: translateY(10px) scaleY(0.97); }
  to { transform: translateY(-16px) scaleY(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop *,
  .backdrop .wash {
    animation: none;
  }

  .bb {
    display: none;
  }

  .spray,
  .struck path {
    stroke-dasharray: none;
  }
}

/* the post itself sits on a white sheet whose edges feather into the backdrop */
.sheet {
  max-width: calc(var(--figure) + 2 * var(--pad) + 3rem);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 0 46px 34px rgba(255, 255, 255, 0.93);
}

/* ── top bar ── */
.topbar-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem var(--pad);
  font-family: var(--sans);
  font-size: 14px;
}

.topbar a {
  color: var(--soft);
  text-decoration: none;
}

.topbar a:hover {
  color: var(--blue-deep);
}

.links {
  display: flex;
  gap: clamp(1rem, 2.5vw, 1.75rem);
}

/* ── title, then the painting ── */
.masthead {
  padding: clamp(2.5rem, 7vh, 4.5rem) var(--pad) 0;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4.6vw, 2.75rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.byline {
  display: grid;
  gap: 0.15rem;
  margin-top: 1.1rem;
  color: var(--soft);
  font-family: var(--sans);
  font-size: 15px;
}

.byline span:last-child {
  color: var(--muted);
}

/* ── article: text column, a slightly wider one for figures ── */
.post {
  position: relative;
  counter-reset: figure;
  padding: clamp(1.5rem, 4vw, 2.5rem) 0 clamp(4rem, 8vw, 6rem);
}

.flow {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--pad), 1fr)
    [figure-start] minmax(0, calc((var(--figure) - var(--text)) / 2))
    [text-start] min(var(--text), 100% - 2 * var(--pad))
    [text-end] minmax(0, calc((var(--figure) - var(--text)) / 2))
    [figure-end] minmax(var(--pad), 1fr) [full-end];
}

.flow > * {
  grid-column: text;
  min-width: 0;
}

.flow > .figure,
.flow > .table-wrap {
  grid-column: figure;
}

/* ── contents, in the left margin ── */
.toc {
  position: fixed;
  top: 7.5rem;
  left: max(1.25rem, calc(50% - var(--figure) / 2 - 17rem));
  display: grid;
  gap: 0.55rem;
  width: 10.5rem;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.35;
}

.toc a {
  color: var(--muted);
  text-decoration: none;
}

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

h2 {
  margin: 3.6rem 0 1rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
}

h3 {
  margin: 2.4rem 0 0.7rem;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.35;
}

p {
  margin: 0 0 1.1rem;
}

ol,
ul {
  margin: 0 0 1.1rem;
  padding-left: 1.3rem;
}

li {
  margin-bottom: 0.5rem;
  padding-left: 0.2rem;
}

li::marker {
  color: var(--muted);
}

/* ── traces: a transcript card ── */
.trace {
  margin: 1.6rem 0 1.8rem;
}

.trace > p {
  margin: 0 0 0.75rem;
}

.card {
  margin: 0 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  font-family: var(--sans);
  font-size: 12.5px;
}

.card-head .tag {
  padding: 0.05rem 0.45rem;
  border-radius: 4px;
  background: var(--blue);
  color: #16384b;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-head .who {
  color: var(--ink);
  font-weight: 600;
}

.card-head .where {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.card-head .score {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.row {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.7rem 0.9rem;
}

.row + .row {
  border-top: 1px dashed var(--line);
}

.role {
  color: var(--blue-deep);
  font-size: 11.5px;
  line-height: 1.85;
}

.said {
  color: var(--soft);
  overflow-wrap: anywhere;
}

.said .cmd {
  display: block;
  font-size: 1em;
  white-space: pre-wrap;
}

/* ── the files the model is handed ── */
.inputs {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 0.85rem;
}

.inputs .given {
  margin: 0;
}

.inputs .wide {
  grid-column: 1 / -1;
}

.given pre {
  margin: 0;
  padding: 0.8rem 0.9rem;
  color: var(--soft);
  font: inherit;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .inputs {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── figures ── */
.figure {
  margin: 2rem 0 2.6rem;
}

.figure img {
  display: block;
  width: 100%;
  height: auto;
}

.figure .zoom {
  margin-top: 0.5rem;
}

.figure .chart {
  background: #ffffff;
}

figcaption {
  margin-top: 0.8rem;
  color: var(--soft);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
}

figcaption::before {
  counter-increment: figure;
  content: "Figure " counter(figure) ": ";
  color: var(--ink);
  font-weight: 600;
}

.key {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin: 0 0.2em 0 0.1em;
  vertical-align: -0.06em;
  border: 2px solid var(--blue);
}

.key.dashed {
  border: 1.5px dashed var(--muted);
}

.figure svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--sans);
}

.figure svg text {
  fill: var(--ink);
  font-size: 13px;
}

.figure svg .muted {
  fill: var(--muted);
  font-size: 12px;
}

.figure svg .note {
  fill: var(--muted);
  font-size: 11.5px;
}

.figure svg .tick {
  fill: var(--soft);
  font-size: 14px;
}

.figure svg .title {
  fill: var(--soft);
  font-size: 14px;
}

.figure svg .name {
  font-size: 15px;
  font-weight: 600;
}

.figure svg .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.figure svg .axis {
  stroke: var(--ink);
  stroke-width: 1;
}

.figure svg .label {
  font-size: 14px;
}

.figure svg .value {
  fill: var(--soft);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

/* ── the film with every model's boxes ── */
.figure svg.film {
  background: #000000;
}

.film rect {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.film .ref {
  stroke: var(--blue);
  stroke-width: 2.6;
}

.film .try {
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
}

.zooms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.4;
}

button.chip {
  cursor: pointer;
}

button.chip[aria-pressed="false"] {
  color: var(--muted);
  text-decoration: line-through;
}

.chip i {
  width: 0.85em;
  height: 0.85em;
  border: 2px dashed;
  background: #1d1d1f;
}

.chip i.ref {
  border: 2px solid var(--blue);
}

button.chip[aria-pressed="false"] i {
  opacity: 0.3;
}

/* ── chart controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  font-family: var(--sans);
  font-size: 12.5px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.seg button {
  padding: 0.28rem 0.7rem;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  color: var(--soft);
  font: inherit;
  cursor: pointer;
}

.seg button:first-child {
  border-left: 0;
}

.seg button[aria-pressed="true"] {
  background: var(--blue);
  color: #16384b;
  font-weight: 600;
}

.passfig .pk {
  display: none;
}

.passfig[data-k="1"] .k1,
.passfig[data-k="2"] .k2,
.passfig[data-k="3"] .k3 {
  display: inline;
}

/* ── tables ── */
.table-wrap {
  margin: 1.8rem 0 2.4rem;
  overflow-x: auto;
  background: #ffffff;
  font-family: var(--sans);
}

.table-wrap.narrow {
  grid-column: text;
  max-width: 24rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}

caption {
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
}

th {
  padding: 0.7rem 0.75rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th.num,
td.num {
  text-align: right;
}

/* ── footer ── */
.foot {
  max-width: calc(var(--text) + 2 * var(--pad));
  margin: 0 auto;
  padding: 1.5rem var(--pad) 3.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14px;
}

.foot a {
  color: var(--muted);
  text-decoration: none;
}

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

/* the margins hold the contents and the art only when there is room for them */
@media (max-width: 1320px) {
  .toc {
    display: none;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 17px;
  }

  h2 {
    margin-top: 3rem;
  }

  .card {
    font-size: 12.5px;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .card-head {
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
  }
}
