/* ============================================================
   Afterimage — anonymous companion page
   White background throughout. ONE column width for
   everything: prose, figures, videos, tables. Every block on
   the page shares the same left and right edges. Grids inside
   that column (m1 / m2 / m3) split it without changing them.
   ============================================================ */

:root{
  --bg:        #ffffff;
  --ink:       #16171b;
  --ink-soft:  #35373e;
  --muted:     #6b6e78;
  --rule:      #e2e0da;
  --rule-soft: #eeece6;

  /* the afterimage pair: a warm stimulus and its cool complement */
  --petal:       #c2452d;
  --center:      #2f6fa8;
  --petal-wash:  rgba(194,69,45,.06);
  --center-wash: rgba(47,111,168,.05);

  --serif: "Iowan Old Style", Charter, "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  --w: 52rem;   /* the one column width: prose, media, tables, nav */
}

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

html{
  scroll-behavior:smooth; scroll-padding-top:5rem;
  -webkit-text-size-adjust:100%; background:var(--bg);
}
@media (prefers-reduced-motion: reduce){ html{ scroll-behavior:auto; } }

body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:var(--serif); font-size:1.15rem; line-height:1.75;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}

.skip{
  position:absolute; left:-9999px; top:0; z-index:200;
  background:var(--ink); color:#fff; padding:.6rem 1rem; border-radius:0 0 .4rem 0;
  font-family:var(--sans); font-size:.85rem;
}
.skip:focus{ left:0; }

/* ---------------- layout ---------------- */
.wrap { max-width:var(--w); margin-inline:auto; padding-inline:16px; }
.media{ max-width:var(--w); margin:2.4rem auto 2.8rem; padding-inline:16px; }

section{ padding:3.6rem 0; border-top:1px solid var(--rule-soft); }
section.hero{ border-top:0; padding-top:3.2rem; }
@media (max-width:640px){ section{ padding:2.6rem 0; } }

/* ---------------- progress + nav ---------------- */
#progress{ position:fixed; inset:0 0 auto 0; height:2px; z-index:60; pointer-events:none; }
#progress i{ display:block; height:100%; width:0; background:linear-gradient(90deg,var(--center),var(--petal)); }

#nav{
  position:sticky; top:0; z-index:50; background:rgba(255,255,255,.9);
  backdrop-filter:saturate(1.6) blur(10px); -webkit-backdrop-filter:saturate(1.6) blur(10px);
  border-bottom:1px solid var(--rule);
}
.nav-inner{
  max-width:var(--w); margin-inline:auto; padding:.55rem 16px;
  display:flex; align-items:center; gap:.7rem;
  font-family:var(--sans); font-size:.76rem;
}
.brand{
  display:inline-flex; align-items:center; gap:.45rem; font-weight:650;
  color:var(--ink); text-decoration:none; white-space:nowrap;
}
.brand .mark{
  width:.85rem; height:.85rem; border-radius:50%;
  background:var(--petal); box-shadow:0 0 0 3px var(--center-wash), inset 0 0 0 3px var(--center);
}
#nav nav{
  display:flex; gap:.15rem; overflow-x:auto; flex:1 1 auto; scrollbar-width:none;
  mask-image:linear-gradient(90deg,transparent,#000 12px,#000 calc(100% - 12px),transparent);
}
#nav nav::-webkit-scrollbar{ display:none; }
#nav nav a{ color:var(--muted); text-decoration:none; padding:.3rem .42rem; border-radius:.4rem; white-space:nowrap; }
#nav nav a:hover{ color:var(--ink); background:var(--rule-soft); }
#nav nav a.on{ color:var(--petal); background:var(--petal-wash); }

.ghost{
  font-family:var(--sans); font-size:.8rem; color:var(--muted);
  background:transparent; border:1px solid var(--rule); border-radius:999px;
  padding:.3rem .7rem; cursor:pointer; display:inline-flex; align-items:center; gap:.4rem; white-space:nowrap;
}
.ghost:hover{ color:var(--ink); border-color:var(--muted); }
.ghost .dot{ width:.5rem; height:.5rem; border-radius:50%; background:var(--petal); }
.ghost[aria-pressed="false"] .dot{ background:var(--muted); }
@media (max-width:820px){ .ghost .label{ display:none; } }
@media (max-width:560px){ #nav nav{ display:none; } }

/* ---------------- typography ---------------- */
h1{ font-size:clamp(1.9rem,4.4vw,2.9rem); line-height:1.13; letter-spacing:-.018em; font-weight:600; margin:.4rem 0 1.3rem; }
@media (max-width:700px){ .br-wide{ display:none; } }
h2{ font-size:clamp(1.4rem,2.8vw,1.85rem); line-height:1.22; letter-spacing:-.012em; font-weight:600; margin:.2rem 0 1rem; }
h3{ font-size:1.1rem; font-weight:650; margin:2rem 0 .7rem; }
p{ margin:0 0 1.1rem; }
.wrap p, .wrap li{ color:var(--ink-soft); }
b,strong{ color:var(--ink); font-weight:650; }
a{ color:var(--center); text-underline-offset:.18em; text-decoration-thickness:.06em; }
a:hover{ color:var(--petal); }

.secnum{
  font-family:var(--sans); font-size:.71rem; font-weight:650; letter-spacing:.13em;
  text-transform:uppercase; color:var(--petal); margin:0 0 .5rem;
}
.kicker{
  font-family:var(--sans); font-size:.75rem; font-weight:600; letter-spacing:.08em;
  text-transform:uppercase; color:var(--muted); margin:0;
}

/* ---------------- hero ---------------- */
.hero .lede{ font-size:1.28rem; line-height:1.62; color:var(--ink-soft); }
.hero .lede strong{ color:var(--petal); }
.cta{ display:flex; flex-wrap:wrap; gap:.6rem; margin-top:1.6rem; }
.hint{ font-family:var(--sans); font-size:.82rem; color:var(--muted); margin-top:1rem; }

.btn{
  font-family:var(--sans); font-size:.86rem; font-weight:550;
  display:inline-flex; align-items:center; justify-content:center;
  padding:.6rem 1.05rem; border-radius:.5rem; cursor:pointer;
  border:1px solid var(--rule); background:#fff; color:var(--ink);
  text-decoration:none; transition:border-color .15s, transform .08s;
}
.btn:hover{ border-color:var(--muted); color:var(--ink); }
.btn:active{ transform:translateY(1px); }
.btn.primary{ background:var(--petal); border-color:var(--petal); color:#fff; }
.btn.primary:hover{ filter:brightness(1.07); color:#fff; }
.btn.small{ padding:.38rem .8rem; font-size:.8rem; border-radius:.4rem; }

/* ---------------- media: the same column, split into 1, 2 or 3 ---------------- */
.media.m1{ display:block; }
.media.m2{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.5rem; align-items:stretch; }
.media.m3{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1.4rem; align-items:stretch; }
/* two formulas side by side, as one row of the column */
.media.m2.pair-display{ align-items:stretch; }
.media.m2.pair-display .display{ margin:0; display:flex; flex-direction:column; justify-content:center; }
.media.m2.pair-display .caption{ margin-top:.8rem; }

/* a near-square figure sits beside its caption instead of filling the width */
.media.m2.side{ align-items:center; gap:2rem; }
.sidetext{ font-family:var(--sans); font-size:.9rem; line-height:1.65; color:var(--muted); }
.sidetext p{ margin:0; }
.sidetext b{ color:var(--ink-soft); }
@media (max-width:820px){
  .media.m2, .media.m3{ grid-template-columns:minmax(0,1fr); gap:2rem; }
}

figure{ margin:0; display:flex; flex-direction:column; }
figure img, figure video{
  display:block; width:100%; height:auto; border-radius:.4rem;
  background:#fff; border:1px solid var(--rule);
}
figure video{ cursor:pointer; }
/* keep the three supporting plots the same height despite different aspect ratios */
.media.m3 figure img{ aspect-ratio:4/3; object-fit:contain; }
figcaption{
  font-family:var(--sans); font-size:.83rem; line-height:1.58;
  color:var(--muted); margin-top:auto; padding-top:.65rem;
}
figcaption b{ color:var(--ink-soft); }

.figlead{
  grid-column:1/-1; font-family:var(--sans); font-size:.83rem; line-height:1.6;
  color:var(--muted); text-align:center; margin:1rem auto 0;
}
.figlead b{ color:var(--ink-soft); }

.vctl{ grid-column:1/-1; display:flex; gap:.5rem; justify-content:center; margin-top:.9rem; }
.media.m1 .vctl{ margin-top:.9rem; }

/* ---------------- callouts ---------------- */
.inwords{
  border-left:3px solid var(--rule); padding-left:1.05rem;
  color:var(--muted) !important; margin:1.6rem 0;
}
.inwords b{ color:var(--petal); }

.keybox{
  border:1px solid var(--petal); background:var(--petal-wash);
  padding:1rem 1.2rem; border-radius:.5rem; margin:1.8rem 0;
}
.keybox p{ margin:0; color:var(--ink); }

.display{
  margin:1.7rem 0; padding:1.1rem 1rem; text-align:center;
  background:#fff; border:1px solid var(--rule-soft); border-radius:.5rem; overflow-x:auto;
}
.display p{ margin:0; }
.display .caption{ font-family:var(--sans); font-size:.81rem; color:var(--muted); margin-top:.7rem; }

ul.limits, ol.steps{ padding-left:1.2rem; margin:0 0 1.2rem; }
ul.limits li, ol.steps li{ margin-bottom:.8rem; color:var(--ink-soft); }
ol.steps li::marker{ color:var(--petal); font-weight:650; font-family:var(--sans); font-size:.85em; }
ul.limits li::marker{ color:var(--petal); }

/* ---------------- tables ---------------- */
table{ border-collapse:collapse; width:100%; font-family:var(--sans); font-size:.87rem; }
caption{
  caption-side:bottom; font-family:var(--sans); font-size:.83rem; color:var(--muted);
  text-align:left; padding-top:.85rem; line-height:1.6;
}
caption b{ color:var(--ink-soft); }
th,td{ text-align:left; padding:.65rem .8rem; border-bottom:1px solid var(--rule-soft); vertical-align:top; }
thead th{
  font-size:.72rem; letter-spacing:.07em; text-transform:uppercase;
  color:var(--muted); font-weight:650; border-bottom:1px solid var(--rule);
}
tbody td{ color:var(--ink-soft); }
tbody tr:last-child td{ border-bottom:1px solid var(--rule); }

/* a small table fills the text column, so it shares the edges of the boxes above and below it */
table.num{ margin:1.6rem 0; }
/* the uppercase header style would turn a Greek epsilon into a capital E */
thead th .m{ text-transform:none; letter-spacing:0; font-size:1.2em; }
table.num td:last-child, table.num th:last-child{ text-align:right; }
table.pred td:first-child, table.pred td:nth-child(2){ white-space:nowrap; }
table.pred td:nth-child(2){ color:var(--muted); }
.sub{ font-weight:400; text-transform:none; letter-spacing:0; font-size:.92em; opacity:.8; }
.tag{
  display:inline-block; margin-top:.3rem; font-size:.67rem; letter-spacing:.09em;
  text-transform:uppercase; color:var(--petal); background:var(--petal-wash);
  padding:.12rem .45rem; border-radius:.25rem; font-weight:650;
}
/* a wide table scrolls inside the column instead of widening the page */
.tscroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
.tscroll table{ min-width:30rem; }
@media (max-width:700px){
  table.pred td:first-child, table.pred td:nth-child(2){ white-space:normal; }
  table.pred{ font-size:.8rem; }
  table.pred th, table.pred td{ padding:.55rem .5rem; }
}

/* ---------------- footer ---------------- */
footer{ border-top:1px solid var(--rule); padding:2.4rem 0 3rem; }
.foot-main{ font-family:var(--sans); font-size:.85rem; color:var(--muted); }
.foot-links{ font-family:var(--sans); font-size:.85rem; display:flex; gap:1.4rem; margin:0; }

/* ---------------- math ---------------- */
.katex{ font-size:1.02em; }
.display .katex-display{ margin:0; }
