/* Shared by all pages of the Diffsert site: color tokens (light and dark), base type, header, inline code,
   tables, code blocks, the change explorer and footer. Page-specific styles live in each page. */
:root {
  --paper: #F2F4F8;
  --surface: #FFFFFF;
  --ink: #131A2A;
  --ink-2: #4B566B;
  --ink-3: #6E7890;
  --rule: #D6DCE6;
  --hl: #FFD43B;
  --hl-ink: #241C00;
  --hl-soft: #FFF1B8;
  --insert: #13865A;
  --replace: #C93A52;
  --cell: #DCE2EB;
  --code-bg: #121A2B;
  --code-fg: #DCE3EF;
  --code-dim: #7D889E;
  --code-key: #A9C3F2;
  --code-str: #B9E4C6;
  --code-rule: #26324A;

  --display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3125rem;
  --step-2: 1.75rem;
  --step-3: clamp(2rem, 1.4rem + 2.4vw, 2.75rem);
  --step-4: clamp(2.6rem, 1.6rem + 4.6vw, 4.9rem);

  --measure: 64ch;
  --wide: 76rem;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1320;
    --surface: #141C2D;
    --ink: #E8EDF5;
    --ink-2: #A3AEC3;
    --ink-3: #7F8AA1;
    --rule: #263149;
    --hl: #FFD43B;
    --hl-ink: #241C00;
    --hl-soft: #3A3215;
    --insert: #3BC48B;
    --replace: #F06A80;
    --cell: #212B41;
    --code-bg: #090E18;
    --code-fg: #DCE3EF;
    --code-dim: #75809A;
    --code-key: #A9C3F2;
    --code-str: #B9E4C6;
    --code-rule: #1F2A40;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0D1320;
  --surface: #141C2D;
  --ink: #E8EDF5;
  --ink-2: #A3AEC3;
  --ink-3: #7F8AA1;
  --rule: #263149;
  --hl: #FFD43B;
  --hl-ink: #241C00;
  --hl-soft: #3A3215;
  --insert: #3BC48B;
  --replace: #F06A80;
  --cell: #212B41;
  --code-bg: #090E18;
  --code-fg: #DCE3EF;
  --code-dim: #75809A;
  --code-key: #A9C3F2;
  --code-str: #B9E4C6;
  --code-rule: #1F2A40;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.6;
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  padding-block: 0;
}
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--hl); text-decoration-thickness: 3px; }
:focus-visible { outline: 3px solid var(--hl); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; line-height: 1.05; }
p { margin: 0; }
code, pre, kbd { font-family: var(--mono); }
.wrap { max-width: var(--wide); margin-inline: auto; }

/* Highlighter: the page's one bold device */
.hl {
  background: linear-gradient(transparent 12%, var(--hl) 12%, var(--hl) 88%, transparent 88%);
  color: var(--hl-ink);
  padding-inline: 0.12em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---------- header ---------- */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
}
.top .wrap { display: flex; align-items: center; gap: 1.5rem; padding-block: 0.8rem; }
.mark {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
}
.mark .hl { padding-inline: 0.08em; }
.nav { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; font-size: var(--step--1); }
.nav a { text-decoration: none; color: var(--ink-2); }
.nav a:hover { color: var(--ink); }
.nav .gh { color: var(--ink); font-weight: 600; display: inline-flex; gap: 0.4rem; align-items: center; }
.theme-btn {
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  border-radius: 999px;
  font: 500 0.75rem/1 var(--mono);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}
.theme-btn:hover { color: var(--ink); border-color: var(--ink-3); }
@media (max-width: 760px) { .nav .sec { display: none; } }

.eyebrow {
  font: 600 0.78rem/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- inline code ---------- */
code.inline, p code, li code, td code {
  font-size: 0.86em;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  white-space: nowrap;
}
/* On phones, long inline code wraps (at spaces, or anywhere if one token is too wide) instead of overflowing. */
@media (max-width: 600px) {
  code.inline, p code, li code {
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 2rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 40rem; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font: 600 0.75rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); background: var(--paper); }

/* ---------- code blocks ---------- */
.code {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  min-width: 0;
  overflow: hidden;
}
.code .bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.6rem 0.55rem 1rem;
  border-bottom: 1px solid var(--code-rule);
  font: 500 0.75rem/1.3 var(--mono);
  color: var(--code-dim);
}
.code .bar .copy {
  margin-left: auto;
  font: 600 0.72rem/1 var(--mono);
  color: var(--code-fg);
  background: transparent;
  border: 1px solid var(--code-rule);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}
.code .bar .copy:hover { border-color: var(--code-dim); }
.code pre { margin: 0; padding: 1rem; overflow-x: auto; font-size: 0.84rem; line-height: 1.65; }
.code .k { color: var(--code-key); }
.code .s { color: var(--code-str); }
.code .c { color: var(--code-dim); font-style: italic; }
.code .t { color: #F2C98B; }
.code-stack { display: grid; gap: 1rem; min-width: 0; }

/* ---------- change explorer (built by site.js) ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.explorer { margin: 2rem 0 0; display: grid; gap: 1rem; min-width: 0; }
.explorer figcaption { color: var(--ink-2); max-width: var(--measure); }
.explorer .ex-config { font: 500 0.78rem/1.5 var(--mono); color: var(--ink-3); margin: 0; max-width: none; }
.ex-config b { color: var(--ink); font-weight: 600; }
.ex-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ex-tab {
  font: 600 0.85rem/1 var(--body);
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.ex-tab:hover { color: var(--ink); border-color: var(--ink-3); }
.ex-tab[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ex-panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); min-width: 0; overflow: hidden; }
.ex-scroll { overflow-x: auto; }
.explorer .ex-table { min-width: 31rem; font-size: 0.82rem; }
.ex-table th { padding: 0.55rem 0.9rem; }
.ex-table td { padding: 0.45rem 0.9rem; font-family: var(--mono); vertical-align: baseline; white-space: nowrap; }
.ex-name { font-weight: 600; }
.ex-role {
  font: 600 0.6rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.2rem 0.35rem;
  margin-left: 0.5rem;
  position: relative;
  top: -0.1em;
}
.ex-missing { color: var(--ink-3); }
.ex-v.change, .ex-missing.change { background: var(--hl); color: var(--hl-ink); border-radius: 2px; padding-inline: 0.25em; }
.ex-v.skip { text-decoration: underline dotted var(--ink-3); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.ex-v.removed { color: var(--replace); text-decoration: line-through; }
.ex-v.ev::after {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.45rem;
  border-radius: 50%;
  background: var(--ink);
  vertical-align: 0.05em;
}
.ex-note { font: 500 0.7rem/1 var(--mono); color: var(--ink-3); margin-left: 0.5rem; }
.ex-after.kept { color: var(--ink-3); }
.ex-verdict { border-top: 1px solid var(--rule); padding: 0.9rem 1rem 1rem; display: grid; gap: 0.6rem; }
.explorer .ex-result { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center; margin: 0; }
.ex-outcome { font: 700 0.72rem/1 var(--mono); letter-spacing: 0.06em; padding: 0.35rem 0.55rem; border-radius: 3px; }
.ex-outcome.updated { background: var(--hl); color: var(--hl-ink); }
.ex-outcome.inserted { background: var(--insert); color: var(--surface); }
.ex-outcome.unchanged { border: 1.5px dashed var(--ink-3); color: var(--ink-3); padding: 0.25rem 0.45rem; }
.ex-event { font: 500 0.8rem/1.5 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.explorer .ex-why { margin: 0; color: var(--ink-2); font-size: 0.95rem; max-width: var(--measure); }
.explorer .ex-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; font: 500 0.75rem/1.4 var(--mono); color: var(--ink-3); }
.explorer .ex-legend li { margin: 0; display: inline-flex; align-items: center; gap: 0.45rem; }
.ex-key { display: inline-block; width: 1.1rem; height: 0.75rem; border-radius: 2px; }
.ex-key.change { background: var(--hl); }
.ex-key.skip { border-bottom: 2px dotted var(--ink-3); border-radius: 0; height: 0.5rem; }
.ex-key.ev { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--ink); }
.ex-key.removed { height: 2px; background: var(--replace); }
@media (max-width: 600px) {
  .explorer .ex-table { min-width: 0; font-size: 0.72rem; }
  .ex-table th { padding: 0.45rem 0.4rem; font-size: 0.62rem; white-space: normal; }
  .ex-table td { padding: 0.4rem; }
  .ex-table th:first-child, .ex-table td:first-child { padding-left: 0.7rem; }
  .ex-role, .ex-note { display: block; width: fit-content; margin: 0.2rem 0 0; top: 0; }
  .ex-v.ev::after { margin-left: 0.3rem; }
}

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); padding-block: 2.5rem 3rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: baseline; justify-content: space-between; font-size: var(--step--1); color: var(--ink-3); }
footer .links { display: flex; flex-wrap: wrap; gap: 1.25rem; }
