/* ==========================================================================
   AMTR-KV — page-only styles (loaded after site.css on amtr.html).
   Kept out of site.css so the A.M.A.D.E.U.S PWA, which precaches site.css,
   is unaffected. Colours follow the three cache modes:
     EXACT (keep every old token)      → orange, the attention colour
     FOLD  (compress old tokens)       → teal
     DROP  (forget old tokens)         → slate
   and the three memory states inside a folded layer:
     recent-past → sky, mid-range → indigo, long-range → purple;
   the gate / router that mixes them → gold.
   ========================================================================== */
:root {
  --am-exact:  #e0662f;
  --am-fold:   #0d9488;
  --am-drop:   #7c8591;
  --am-recent: #0ea5e9;
  --am-mid:    #4f46e5;
  --am-long:   #9333ea;
  --am-gate:   #c9971f;
}
:root[data-theme="dark"] {
  --am-exact:  #f0814f;
  --am-fold:   #2dd4bf;
  --am-drop:   #9aa3ae;
  --am-recent: #38bdf8;
  --am-mid:    #818cf8;
  --am-long:   #c084fc;
  --am-gate:   #e0b23c;
}

/* Hero: the three modes as chips with a light sweeping through them. */
.am-modes { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin: 1.6rem 0 0.5rem; }
.am-mode {
  position: relative; overflow: hidden;
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--surface); padding: 0.85rem 1rem 0.95rem;
  border-top: 3px solid var(--am-c, var(--accent));
  font-family: var(--sans);
}
.am-mode .k { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--am-c); }
.am-mode .v { font-size: 1rem; font-weight: 650; color: var(--ink); margin-top: 0.25rem; }
.am-mode .d { font-size: 0.85rem; line-height: 1.5; color: var(--ink-secondary); margin-top: 0.35rem; }
.am-mode::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 35%, color-mix(in srgb, var(--am-c) 16%, transparent) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: am-sweep 6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.5s + 0.6s);
}
@keyframes am-sweep {
  0%   { transform: translateX(-120%); }
  22%  { transform: translateX(120%); }
  100% { transform: translateX(120%); }
}

/* Card accents by mode / component. */
.mech[data-lab="am-exact"]  { border-left-color: var(--am-exact); }
.mech[data-lab="am-fold"]   { border-left-color: var(--am-fold); }
.mech[data-lab="am-drop"]   { border-left-color: var(--am-drop); }
.mech[data-lab="am-recent"] { border-left-color: var(--am-recent); }
.mech[data-lab="am-mid"]    { border-left-color: var(--am-mid); }
.mech[data-lab="am-long"]   { border-left-color: var(--am-long); }
.mech[data-lab="am-gate"]   { border-left-color: var(--am-gate); }

/* Viz controls shared by every AMTR interactive. */
.am-bar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0 0 0.9rem; }
.am-bar .am-bar-label { font: 600 0.72rem/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); margin-right: 0.1rem; }
.am-bar .am-gap { flex-basis: 100%; height: 0; }
.am-btn {
  font: 600 0.8rem/1 var(--sans); color: var(--ink-secondary);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 0.45rem 0.85rem; cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.am-btn:hover { color: var(--ink); border-color: var(--baseline); }
.am-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.am-btn[aria-pressed="true"] { color: var(--ink); background: var(--accent-wash); border-color: var(--accent); }
.am-btn.play::before { content: "▶"; font-size: 0.7em; margin-right: 0.45em; }
.am-btn.play[aria-pressed="true"]::before { content: "❚❚"; }

/* SVG pieces. */
.viz .am-cell { transition: fill .35s ease, fill-opacity .35s ease, stroke .35s ease; }
.viz .am-cell:focus-visible { outline: none; stroke: var(--ink); stroke-width: 2; }
.viz .am-bar-rect { transition: y .45s cubic-bezier(.2,.8,.3,1), height .45s cubic-bezier(.2,.8,.3,1), fill .35s, x .45s, width .45s; }
.viz .am-move { transition: transform .5s cubic-bezier(.2,.8,.3,1), opacity .35s; }
.viz .am-meter { transition: width .55s cubic-bezier(.2,.8,.3,1), x .55s cubic-bezier(.2,.8,.3,1); }
.viz .am-pop { animation: am-pop .5s cubic-bezier(.2,.9,.3,1.3) backwards; transform-box: fill-box; transform-origin: center; }
@keyframes am-pop {
  from { transform: scale(0.2); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.viz .am-flow { stroke-dasharray: 6 5; animation: am-flow 1s linear infinite; }
@keyframes am-flow { to { stroke-dashoffset: -22; } }
.viz .am-pulse { animation: am-pulse 1.6s ease-in-out infinite; }
@keyframes am-pulse { 50% { opacity: 0.45; } }

/* The verdict chip under the attention figure. */
.am-verdict {
  display: inline-block; font: 700 0.78rem/1 var(--mono); letter-spacing: 0.05em;
  padding: 0.38rem 0.65rem; border-radius: 6px; color: #fff; background: var(--am-v, var(--accent));
  transition: background .3s;
}

/* "What the results changed" box. */
.am-kill {
  margin: 1.75rem 0 0; padding: 1.1rem 1.3rem; border-radius: var(--radius);
  border: 1px dashed var(--c-transformer); background: rgba(235, 104, 52, 0.06);
  font-family: var(--sans);
}
.am-kill strong { color: var(--c-transformer); }
.am-kill ul { margin: 0.5rem 0 0; padding-left: 1.2rem; color: var(--ink-secondary); font-size: 0.95rem; line-height: 1.55; }
.am-kill li + li { margin-top: 0.35rem; }
.am-kill li strong { color: var(--ink); }

/* Chip lists (queue, tasks). */
.am-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 1rem; }
.am-chips span {
  font: 600 0.76rem/1 var(--sans); color: var(--ink-secondary);
  padding: 0.38rem 0.65rem; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--am-fold) 45%, transparent);
  background: color-mix(in srgb, var(--am-fold) 7%, transparent);
}

/* The folded layer's computation, written out. */
.am-policy {
  margin: 1.25rem 0 0; padding: 1rem 1.2rem; border-radius: var(--radius);
  border: 1px solid var(--hairline); border-left: 3px solid var(--am-fold);
  background: var(--surface); font: 0.86rem/1.65 var(--mono); color: var(--ink);
  overflow-x: auto; white-space: pre;
}
.am-policy .c { color: var(--ink-muted); }
.am-policy sub, .am-policy sup { font-size: 0.7em; }

/* Mode / type pills inside tables and prose. */
.am-tag {
  display: inline-block; font: 700 0.72rem/1 var(--mono); letter-spacing: 0.04em;
  padding: 0.28rem 0.5rem; border-radius: 6px; color: var(--ink);
  background: color-mix(in srgb, var(--am-c, var(--accent)) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--am-c, var(--accent)) 45%, transparent);
  white-space: nowrap;
}
.am-tag.exact { --am-c: var(--am-exact); }
.am-tag.fold  { --am-c: var(--am-fold); }
.am-tag.drop  { --am-c: var(--am-drop); }

/* Results: table view under each figure, findings list, hypothesis status. */
.am-tableview { margin-top: 0.8rem; font-family: var(--sans); }
.am-tableview summary { cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--ink-secondary); }
.am-tableview summary:hover { color: var(--ink); }
.am-tableview .table-wrap { margin-top: 0.6rem; }
.am-tableview caption { caption-side: top; text-align: left; padding-bottom: 0.4rem; }
.am-status {
  display: inline-block; margin-top: 0.45rem; padding: 0.3rem 0.65rem; border-radius: 0.7rem;
  font: 600 0.72rem/1.4 var(--sans); color: var(--ink-secondary);
  border: 1px solid var(--hairline); background: var(--surface);
}
.am-status.tested   { border-color: color-mix(in srgb, var(--am-fold) 55%, transparent); background: color-mix(in srgb, var(--am-fold) 9%, transparent); }
.am-status.running  { border-color: color-mix(in srgb, var(--am-gate) 60%, transparent); background: color-mix(in srgb, var(--am-gate) 10%, transparent); }
.am-status.negative { border-color: color-mix(in srgb, var(--am-exact) 55%, transparent); background: color-mix(in srgb, var(--am-exact) 8%, transparent); }
.am-status.parked   { border-style: dashed; color: var(--ink-muted); }
.am-find { counter-reset: amfind; list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; gap: 0.9rem; }
.am-find > li {
  counter-increment: amfind; position: relative; padding: 0.9rem 1.1rem 0.9rem 3.1rem;
  border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface);
  font: 0.95rem/1.6 var(--sans); color: var(--ink-secondary);
}
.am-find > li::before {
  content: counter(amfind); position: absolute; left: 1rem; top: 0.95rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem; background: var(--accent-wash); color: var(--accent-strong);
}
.am-find > li strong { color: var(--ink); }

/* Glossary strip: the handful of terms the page leans on. */
.am-terms { display: grid; gap: 0.6rem 1.4rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); margin: 1.25rem 0 0; font-family: var(--sans); }
.am-terms div { font-size: 0.88rem; line-height: 1.5; color: var(--ink-secondary); }
.am-terms dt { font-weight: 700; color: var(--ink); font-size: 0.86rem; }
.am-terms dd { margin: 0.1rem 0 0; }

.am-refs { font-family: var(--sans); font-size: 0.86rem; color: var(--ink-secondary); padding-left: 1.6em; }
.am-refs li { margin: 0.35rem 0; }

@media (prefers-reduced-motion: reduce) {
  .am-mode::after,
  .viz .am-pop,
  .viz .am-flow,
  .viz .am-pulse { animation: none; }
  .viz .am-flow { stroke-dasharray: none; }
}
