/* The field: the proof that follows the hero.

   A map with rev0 alone in its corner, and a table of sixteen rows read against one
   other tool at a time. The markup is written by scripts/proof.mjs from
   src/data/proof.ts; proof.js swaps the other tool. Loaded after chapters.css, whose
   chapter head, stage and panel this section is built from, and before motion.css. */

.proof-grid { display: grid; gap: 1rem; align-items: start; }
.proof-grid > * { min-width: 0; }
.proof-side { display: grid; gap: 0.9rem; }
@media (width >= 900px) {
  .proof-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.25rem; }
  /* The table is taller than a screen; the map stays beside it while it is read. */
  .proof-side { position: sticky; top: 4.5rem; }
}

/* --- the map ------------------------------------------------------------------*/

.proof-map svg { display: block; width: 100%; height: auto; }
.paxis { fill: none; stroke: var(--edge-2); }
.pcap { font: 500 7px var(--mono); letter-spacing: 0.12em; fill: var(--fg-3); }
.pname { font: 650 14px var(--sans); letter-spacing: -0.01em; fill: #fff; }
.pall { font: 500 8px var(--mono); letter-spacing: 0.04em; fill: oklch(0.88 0.05 290); }
.pdot { cursor: pointer; }
.pdot rect { fill: transparent; }
.pdot circle { fill: oklch(0.56 0.012 285); stroke: transparent; stroke-width: 1.6; transition: fill 0.15s, stroke 0.15s; }
.pdot text { font: 500 9.5px var(--sans); fill: var(--fg-3); transition: fill 0.15s; }
.pdot:hover circle { fill: var(--fg-2); }
.pdot:hover text { fill: var(--fg); }
/* The tool the table is reading against: a ring, and its name at full strength. */
.pdot[data-on] circle { fill: var(--stage); stroke: #fff; }
.pdot[data-on] text { fill: var(--fg); font-weight: 650; }

/* --- the other tool, picked ---------------------------------------------------*/

.proof-pick { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.proof-pick a {
  display: inline-flex; padding: 0.36rem 0.78rem; border: 1px solid var(--edge-2); border-radius: 999px;
  background: var(--surface-1); color: var(--fg-2); font: 500 0.8rem var(--sans); text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.proof-pick a:hover { color: var(--fg); border-color: var(--edge-3); }
.proof-pick a[aria-current] {
  color: var(--fg); border-color: var(--accent-hi);
  background: color-mix(in oklab, var(--accent) 16%, var(--surface-1));
}

/* --- the table ----------------------------------------------------------------*/

.ch .proof-table { padding: 0.5rem 1.2rem 1rem; }
.prow {
  display: grid; grid-template-columns: minmax(0, 1fr) 2.6rem minmax(4.7rem, 6.4rem);
  align-items: center; gap: 0.6rem;
}
.pcols { padding: 0.7rem 0 0.6rem; font: 500 0.7rem var(--mono); color: var(--fg-3); }
.pcols b { font-weight: 500; }
.pcols b:first-of-type { color: var(--fg); }
.proof-table details { border-top: 1px solid var(--edge); }
summary.prow { padding: 0.66rem 0; list-style: none; cursor: pointer; font-size: 0.93rem; color: var(--fg); }
summary.prow::-webkit-details-marker { display: none; }
summary.prow:hover .prow-l { color: oklch(0.99 0 0); }
.prow-l { display: flex; align-items: baseline; gap: 0.55rem; }
.prow-l::before {
  content: ""; flex: none; width: 0.36rem; height: 0.36rem; translate: 0 -0.12em;
  border-right: 1.5px solid var(--fg-3); border-bottom: 1.5px solid var(--fg-3);
  rotate: -45deg; transition: rotate 0.2s;
}
[open] > summary .prow-l::before { rotate: 45deg; }

/* A mark is a dot the shape of its answer, so it reads without its colour: full,
   half, empty. rev0's own column is the dot alone. */
.pm { display: inline-flex; align-items: center; gap: 0.45rem; font: 500 0.8rem var(--sans); color: var(--fg-3); }
.pm::before {
  content: ""; flex: none; width: 0.62rem; height: 0.62rem; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px currentColor;
}
.pm[data-m="y"] { color: var(--done); }
.pm[data-m="y"]::before { background: currentColor; }
.pm[data-m="p"] { color: var(--fg-2); }
.pm[data-m="p"]::before { background: linear-gradient(90deg, currentColor 50%, transparent 0); }

.pwhy { display: grid; gap: 0.5rem; max-width: 62ch; padding: 0 0 1rem 0.95rem; font-size: 0.86rem; color: var(--fg-2); }
.pwhy b { color: var(--fg); font-weight: 600; }
.pwhy a { font-size: 0.8rem; white-space: nowrap; color: var(--fg-2); }
.pwhy a:hover { color: var(--fg); }
.ptotal { padding: 0.85rem 0 0.2rem; border-top: 1px solid var(--edge-2); font-weight: 650; }
.ptotal [data-total] { font-size: 0.86rem; }

.proof-more { margin-top: 1.5rem; max-width: 62ch; color: var(--fg-2); }
.proof-more b { color: var(--fg); font-weight: 650; }
.proof-rule { margin-top: 0.6rem; max-width: 80ch; font-size: 0.82rem; color: var(--fg-3); }
.proof-rule a { display: block; width: fit-content; margin-top: 0.45rem; color: var(--fg-2); }
.proof-rule a:hover { color: var(--fg); }

/* --- motion -------------------------------------------------------------------*/

@media (prefers-reduced-motion: no-preference) {
  /* rev0's light breathes; nothing else on the map moves. */
  .phalo { transform-box: fill-box; transform-origin: center; animation: proof-halo 5s ease-in-out infinite; }
  @keyframes proof-halo { 50% { transform: scale(1.1); opacity: 0.78; } }
}
