/* whatisimax.com — design system
   Dark first, light supported. Typography carries the design.
   No gradients, no shadows, no bounce. One accent, used sparingly.
   Every colour is a custom property. Never hard-code a colour below. */

:root {
  /* Dark theme (default).
     Monochrome by design. There is no brand hue anywhere on this site.
     Hierarchy is carried by VALUE, weight, scale, and space, never by colour,
     so --accent is simply the brightest available value. Keep it that way. */
  --bg:          #0a0a0b;
  --bg-raised:   #141416;
  --bg-sunken:   #060607;
  --ink:         #f2f1ef;
  --ink-muted:   #a3a19d;
  --ink-faint:   #85827c;   /* 4.5:1 on --bg, WCAG 2.2 AA for small text */
  --rule:        #26262a;
  --rule-strong: #3d3d42;
  --accent:      #ffffff;   /* maximum emphasis, not a colour */
  --accent-dim:  #6e6e73;
  --good:        #f2f1ef;
  --warn:        #a3a19d;

  /* Diagram value ramp, bright to dim. Tier 1 is the best picture delivered.
     A reader should be able to rank these in greyscale, or in print. */
  --tier-1: #ffffff;
  --tier-2: #cfcecb;
  --tier-3: #a3a19d;
  --tier-4: #7a7874;
  --tier-5: #56544f;
  --tier-6: #3a3937;

  --measure: 68ch;
  --pad:     clamp(1.25rem, 4vw, 2.5rem);
  --gap:     clamp(2.5rem, 7vw, 5rem);
  --radius:  3px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #fcfcfb;
    --bg-raised:   #ffffff;
    --bg-sunken:   #f2f1ee;
    --ink:         #131211;
    --ink-muted:   #56534e;
    --ink-faint:   #6f6c66;   /* 4.5:1 on --bg, WCAG 2.2 AA for small text */
    --rule:        #e2e0da;
    --rule-strong: #c4c1b9;
    --accent:      #000000;   /* maximum emphasis, not a colour */
    --accent-dim:  #9b9791;
    --good:        #131211;
    --warn:        #56534e;

    --tier-1: #000000;
    --tier-2: #3a3835;
    --tier-3: #63605a;
    --tier-4: #8b8781;
    --tier-5: #b0aca5;
    --tier-6: #d2cec7;
  }
}

/* Reset ------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;      /* the body never scrolls sideways */
}

img, svg, table { max-width: 100%; }
img { height: auto; }

/* Type -------------------------------------------------------------- */

h1, h2, h3, h4 {
  line-height: 1.12;
  letter-spacing: -0.022em;
  font-weight: 620;
  text-wrap: balance;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.25rem, 1.5rem + 3.6vw, 4.25rem); letter-spacing: -0.032em; }
h2 { font-size: clamp(1.6rem, 1.25rem + 1.7vw, 2.5rem); margin-top: 2.2em; }
h3 { font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem); margin-top: 2em; }
h4 { font-size: 1rem; margin-top: 1.6em; text-transform: uppercase;
     letter-spacing: 0.08em; color: var(--ink-muted); font-weight: 600; }

p, ul, ol { margin: 0 0 1.15em; }
p, li { max-width: var(--measure); }
li { margin-bottom: 0.4em; }

a {
  color: var(--ink);
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

strong { font-weight: 640; }
code, kbd { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--bg-sunken); padding: 0.12em 0.36em; border-radius: 2px; }

/* The lede sentence under an h1. The short answer lives here. */
.lede {
  font-size: clamp(1.15rem, 1.02rem + 0.65vw, 1.5rem);
  line-height: 1.5;
  color: var(--ink);
  max-width: 40ch;
  letter-spacing: -0.012em;
}
.lede + .lede, .lede.secondary { color: var(--ink-muted); max-width: 52ch; }

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 1.4em;
  display: block;
}

.muted { color: var(--ink-muted); }
.small { font-size: 0.875rem; }

/* Layout ------------------------------------------------------------ */

.wrap {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: var(--pad);
}
.wrap-narrow { max-width: 760px; }

main { display: block; padding-bottom: var(--gap); }
section { margin-block: var(--gap); }

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: var(--bg);
  padding: 0.6em 1em; z-index: 100;
}
.skip:focus { left: 1rem; top: 1rem; }

/* Header and footer -------------------------------------------------- */

.site-head {
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
}
.site-head .wrap {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 58px; flex-wrap: wrap;
}
.brand {
  font-weight: 660; letter-spacing: -0.03em;
  text-decoration: none; font-size: 1.02rem; white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand .q { color: var(--accent); }

.site-nav { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  font-size: 0.875rem; color: var(--ink-muted);
  text-decoration: none; white-space: nowrap;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"] { box-shadow: inset 0 -1px 0 var(--accent); }

.site-foot {
  border-top: 1px solid var(--rule);
  margin-top: var(--gap);
  padding-block: 2.5rem 3.5rem;
  color: var(--ink-faint);
  font-size: 0.82rem;
}
.site-foot p { max-width: 72ch; }
.site-foot a { color: var(--ink-muted); }

/* Components --------------------------------------------------------- */

.card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  background: var(--bg-raised);
}

.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}
.grid p, .grid li { max-width: none; }

/* The callout that answers the question directly. Used once per page. */
.answer {
  border-left: 2px solid var(--accent);
  padding: 0.1rem 0 0.1rem 1.25rem;
  margin-block: 2rem;
}
.answer p:last-child { margin-bottom: 0; }

.note {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: var(--ink-muted);
  background: var(--bg-sunken);
}
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.note strong { color: var(--ink); }

/* Tables ------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
caption { text-align: left; color: var(--ink-muted); font-size: 0.85rem;
          padding-bottom: 0.6rem; }
th, td {
  text-align: left; padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top; white-space: nowrap;
}
thead th {
  position: sticky; top: 0;
  background: var(--bg-sunken);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-muted); font-weight: 600; z-index: 1;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-raised); }
td.wrap-cell { white-space: normal; min-width: 18rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sortable headers are real buttons so they work with a keyboard. */
th button {
  all: unset; cursor: pointer; display: inline-flex; gap: 0.35em;
  align-items: center; font: inherit; color: inherit;
}
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th button::after { content: "↕"; opacity: 0.35; font-size: 0.9em; }
th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; color: var(--accent); }
th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; color: var(--accent); }

/* Badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.18em 0.5em;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink-muted);
  white-space: nowrap;
}
/* Monochrome: badges separate by fill and value, never by hue.
   Filled reads strongest, outlined next, dimmed weakest. */
.badge-143   { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.badge-film  { color: var(--ink); border-color: var(--ink); }
.badge-est   { color: var(--ink-faint); border-color: var(--rule); font-style: italic; }

/* Forms -------------------------------------------------------------- */

.controls { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }
input[type="search"], select {
  font: inherit; font-size: 0.9rem;
  background: var(--bg-raised); color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  min-width: 0;
}
input[type="search"] { flex: 1 1 16rem; }
input[type="search"]:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}

/* Diagrams ----------------------------------------------------------- */

figure { margin: 2.5rem 0; }
figure svg { display: block; width: 100%; height: auto; }
figcaption {
  font-size: 0.82rem; color: var(--ink-muted);
  margin-top: 0.9rem; max-width: var(--measure);
}
.diagram-scroll { overflow-x: auto; }

/* SVG elements inherit theme colours through these classes. */
.d-stroke   { stroke: var(--rule-strong); fill: none; }
.d-rule     { stroke: var(--rule); fill: none; }
.d-fill     { fill: var(--bg-raised); }
.d-ink      { fill: var(--ink); }
.d-muted    { fill: var(--ink-muted); }
.d-accent   { fill: var(--accent); }
.d-accent-s { stroke: var(--accent); fill: none; }
.d-label    { fill: var(--ink-muted); font-size: 11px; font-family: var(--font); }
.d-label-lg { fill: var(--ink); font-size: 13px; font-weight: 600; font-family: var(--font); }

/* Utilities ---------------------------------------------------------- */

.vh {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--gap) 0; }
.stack > * + * { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-head, .site-nav, .controls { display: none; }
  body { background: #fff; color: #000; }
}
