/* Engine Extremes: the site. Light and dark from the same tokens. */
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fbfbfa;
  --fg: #16181b;
  --muted: #5b616b;
  --faint: #8a9099;
  --spec: #6a7079;
  --rule: #e3e5e8;
  --rule-strong: #c8ccd2;
  --hover: #f0f2f5;
  --mark: #e6edf8;
  --link: #1d56b3;
  --focus: #1d56b3;
  --btn: #1d56b3;
  --btn-hi: #2462c7;
  --btn-down: #123b80;
  --btn-edge: #0f306a;
  --btn-fg: #ffffff;
  --seg: #e9ecef;
  --seg-on: #ffffff;
  --seg-fg: #4d535c;
  --seg-on-fg: #16181b;
  --ib: #ffffff;
  --ib-fg: #4d535c;
  --ib-edge: #d3d7dc;
  --pop: #ffffff;
  --stage: #f1f2f4;
  --backdrop: rgba(17, 20, 24, 0.55);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131517; --fg: #e9ebee; --muted: #a2a8b1; --faint: #7a8089; --spec: #9aa1aa;
    --rule: #2a2e33; --rule-strong: #3d424a; --hover: #1b1e22; --mark: #1c2636; --link: #8fb4ff; --focus: #8fb4ff;
    --btn: #3368d4; --btn-hi: #3d74e0; --btn-down: #1e4799; --btn-edge: #17397c; --btn-fg: #ffffff;
    --seg: #1f2226; --seg-on: #363b42; --seg-fg: #a2a8b1; --seg-on-fg: #eef0f2;
    --ib: #24282d; --ib-fg: #c0c6ce; --ib-edge: #3b4047; --pop: #1b1e22; --stage: #121417; --backdrop: rgba(0, 0, 0, 0.62);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131517; --fg: #e9ebee; --muted: #a2a8b1; --faint: #7a8089; --spec: #9aa1aa;
  --rule: #2a2e33; --rule-strong: #3d424a; --hover: #1b1e22; --mark: #1c2636; --link: #8fb4ff; --focus: #8fb4ff;
  --btn: #3368d4; --btn-hi: #3d74e0; --btn-down: #1e4799; --btn-edge: #17397c; --btn-fg: #ffffff;
  --seg: #1f2226; --seg-on: #363b42; --seg-fg: #a2a8b1; --seg-on-fg: #eef0f2;
  --ib: #24282d; --ib-fg: #c0c6ce; --ib-edge: #3b4047; --pop: #1b1e22; --stage: #121417; --backdrop: rgba(0, 0, 0, 0.62);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html:has(dialog[open]) { overflow: hidden; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-block: 32px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1 { margin: 0; font-size: 2rem; line-height: 1.15; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Category: a segmented switch */
.cats {
  display: inline-flex; gap: 2px; margin-top: 20px; padding: 3px;
  background: var(--seg); border-radius: 10px;
}
.cat {
  appearance: none; border: 0; border-radius: 8px; padding: 7px 14px;
  background: transparent; color: var(--seg-fg); font-weight: 600; font-size: 14px; line-height: 20px; cursor: pointer;
}
.cat:hover { color: var(--seg-on-fg); }
.cat[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.04); }

/* Engine type: blue buttons; the chosen one stays pressed in */
.types {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.type {
  appearance: none; position: relative; padding: 8px 14px; border: 1px solid var(--btn-edge); border-radius: 8px;
  background: var(--btn); color: var(--btn-fg); font-weight: 600; font-size: 14px; line-height: 20px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 0 var(--btn-edge), 0 3px 5px rgba(10, 30, 70, 0.18);
  transition: background-color 0.12s, box-shadow 0.08s, transform 0.08s;
}
.type:hover { background: var(--btn-hi); }
.type:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 var(--btn-edge); }
.type[aria-pressed="true"] {
  background: var(--btn-down); transform: translateY(2px);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 0 var(--btn-edge);
}

/* The tables: one per type and category; site.js shows the chosen one */
.js .sheet { display: none; }
.js .sheet.on { display: block; }
.sheet { margin-top: 10px; }
.sh { display: none; }
.nojs .sh { display: block; margin: 36px 0 6px; font-size: 1.15rem; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
thead th {
  padding: 8px 12px; border-bottom: 1px solid var(--rule-strong);
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
thead th:first-child { width: 12.5rem; padding-left: 4px; }
tbody th, tbody td { padding: 11px 12px; border-top: 1px solid var(--rule); text-align: left; vertical-align: top; }
tbody tr:first-child > * { border-top: 0; }
tbody tr:last-child > * { border-bottom: 1px solid var(--rule-strong); }
th[scope="row"] { padding-left: 4px; font-size: 1.02rem; font-weight: 700; overflow-wrap: anywhere; }
tr.hit > * { animation: hit 2.4s ease-out; }
@keyframes hit { 0%, 35% { background: var(--mark); } 100% { background: transparent; } }

/* An entry's field; its buttons show in the bottom-right corner on hover */
td.c { position: relative; }
td.c:hover { background: var(--hover); }
.e + .e { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rule-strong); }
.many .e { position: relative; }
.n { font-weight: 600; overflow-wrap: anywhere; }
.s {
  margin-top: 2px; color: var(--spec); font-family: var(--mono); font-weight: 400; font-size: 13px; line-height: 1.5;
  font-feature-settings: "calt" 0, "liga" 0; font-variant-ligatures: none; overflow-wrap: anywhere;
}
.dash { color: var(--faint); }
.eb {
  position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px; padding-left: 14px;
  background: linear-gradient(to right, transparent, var(--hover) 14px);
  opacity: 0; pointer-events: none; transition: opacity 0.12s;
}
.many .eb { right: -6px; bottom: -5px; }
td.c:not(.many):hover .eb, .many .e:hover .eb, .e:focus-within .eb { opacity: 1; pointer-events: auto; }
.e:focus-within .eb { background: linear-gradient(to right, transparent, var(--bg) 14px); }
td.c:hover .e:focus-within .eb { background: linear-gradient(to right, transparent, var(--hover) 14px); }
.ib {
  appearance: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--ib-edge); border-radius: 7px; background: var(--ib); color: var(--ib-fg); cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.ib:hover { color: var(--btn); border-color: var(--btn); }
.ib svg, .x svg, .nav svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.nojs .eb { display: none; }
/* Touch screens can't point: the buttons stay out, in a column beside the name. */
@media (hover: none) {
  td.c:hover { background: none; }
  .e { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
  .e .n, .e .s { grid-column: 1; }
  .eb, .many .eb {
    position: static; grid-column: 2; grid-row: 1 / span 2; align-self: center;
    margin: 0; padding: 0; background: none; opacity: 1; pointer-events: auto;
  }
  .e:focus-within .eb, td.c:hover .e:focus-within .eb { background: none; }
  .ib { width: 34px; height: 34px; }
}

/* Popups: image carousel, notes, sources */
.pop {
  width: min(760px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 32px); padding: 0;
  border: 1px solid var(--rule-strong); border-radius: 14px; background: var(--pop); color: var(--fg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}
.pop[open] { display: flex; flex-direction: column; }
.pop::backdrop { background: var(--backdrop); }
.pop-h { display: flex; align-items: flex-start; gap: 12px; padding: 14px 12px 8px 20px; }
.pop-h h2 { flex: 1; margin: 5px 0 0; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; }
.x {
  appearance: none; flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.x:hover { background: var(--hover); color: var(--fg); }
.x svg { width: 18px; height: 18px; stroke-width: 1.6; }
.pop-b { padding: 4px 20px 20px; overflow: auto; }
.notes p { margin: 0 0 0.85em; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes p:last-child { margin-bottom: 0; }
a { color: var(--link); }
.srcs { list-style: none; margin: 0; padding: 0; }
.srcs li { padding: 9px 0; border-top: 1px solid var(--rule); }
.srcs li:first-child { border-top: 0; padding-top: 2px; }
.srcs a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.srcs a:hover { text-decoration: underline; }
.srcs .h, .car-src .h { display: block; color: var(--spec); font-family: var(--mono); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.car-stage {
  position: relative; display: grid; place-items: center; height: min(64dvh, 540px);
  border-radius: 10px; background: var(--stage); overflow: hidden; touch-action: pan-y; user-select: none;
}
.car-stage img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; }
.nav {
  appearance: none; position: absolute; top: 50%; display: grid; place-items: center; width: 42px; height: 42px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(12, 14, 17, 0.55); color: #fff; cursor: pointer; transform: translateY(-50%);
}
.nav:hover { background: rgba(12, 14, 17, 0.75); }
.nav svg { width: 20px; height: 20px; stroke-width: 2; }
.nav.prev { left: 10px; }
.nav.next { right: 10px; }
.nav[disabled] { opacity: 0; pointer-events: none; }
.car-src { margin-top: 10px; font-size: 13px; }
.car-src ul { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; margin: 0; padding: 0; }
.car-src a { font-weight: 600; text-decoration: none; }
.car-src a:hover { text-decoration: underline; }
.car-src .h { display: inline; margin-left: 6px; }

/* Offline */
.offline { display: grid; place-content: center; min-height: 100dvh; padding: 24px; text-align: center; }
.off-site { margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.offline h1 { font-size: clamp(1.6rem, 4.5vw, 2.5rem); }

/* Phones: each layout becomes a block */
@media (max-width: 720px) {
  .wrap { padding-top: 22px; }
  h1 { font-size: 1.7rem; }
  .cats { display: flex; width: 100%; }
  .cat { flex: 1; padding: 8px 6px; }
  .types { gap: 7px; }
  .type { padding: 8px 12px; }
  table, thead, tbody, tr, th, td { display: block; width: auto; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr { padding: 12px 0; border-top: 1px solid var(--rule); }
  tbody tr:first-child { border-top: 0; }
  tbody tr:last-child > * { border-bottom: 0; }
  tbody tr:last-child { border-bottom: 1px solid var(--rule-strong); }
  tbody th, tbody td { padding: 2px 0; border: 0; }
  th[scope="row"] { padding: 0 0 4px; font-size: 1.12rem; }
  td.c { padding: 6px 8px; margin: 0 -8px; border-radius: 8px; }
  td.c[data-label]::before { content: attr(data-label); display: block; margin-bottom: 1px; font-size: 12px; color: var(--faint); }
  .car-stage { height: min(56dvh, 440px); }
}

/* The dashboard's copy: what can be edited shows when pointed at */
.pv [data-t], .pv .cat, .pv .type { cursor: text; }
.pv [data-t]:hover, .pv .cat:hover, .pv .type:hover { outline: 1px dashed var(--focus); outline-offset: 3px; }
.pv .cat, .pv .type { cursor: pointer; }
.pv [contenteditable] { outline: 2px solid var(--focus) !important; outline-offset: 3px; cursor: text; }
.pv .e { cursor: pointer; border-radius: 6px; }
.pv td.c:hover .e:hover { outline: 1px dashed var(--focus); outline-offset: 4px; }
.pv .eb { pointer-events: auto; }
