/* AB#284 demo page. Colors are the btddev.org brief's paper (light) and slate (dark) tokens.
   Every transition and animation below reads a token from motion-tokens.css. Keyframe animations
   exist only when the OS allows motion and the level is not "none", so nothing is left running. */

:root {
  color-scheme: light dark;
  --surface: light-dark(#f7f6f3, #0a0c10);
  --surface-raised: light-dark(#ffffff, #13161c);
  --ink: light-dark(#11141a, #eceef2);
  --ink-soft: light-dark(#4a505c, #a9afbb);
  --line: light-dark(#d9d6cf, #2a2f39);
  --accent: light-dark(#0b6e5e, #2ee6c5);
  --on-accent: light-dark(#ffffff, #0a0c10);
  --radius: 10px;
  --space: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--ink); }
main { max-width: 960px; margin: 0 auto; padding: calc(var(--space) * 4) calc(var(--space) * 2) calc(var(--space) * 8); }
h1 { font-size: clamp(2rem, 6vw, 3.25rem); line-height: 1.1; margin: 0 0 calc(var(--space) * 2); letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; margin: 0 0 var(--space); }
p { margin: 0 0 calc(var(--space) * 2); }
.lede { font-size: 1.125rem; color: var(--ink-soft); max-width: 60ch; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.875rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Level picker ---------- */
.picker { border: 1px solid var(--line); border-radius: var(--radius); padding: calc(var(--space) * 2); margin: 0 0 calc(var(--space) * 3); background: var(--surface-raised); }
.picker legend { font-weight: 600; padding: 0 var(--space); }
.picker-options { display: flex; flex-wrap: wrap; gap: var(--space); }
.picker label { display: inline-flex; align-items: center; gap: var(--space); padding: var(--space) calc(var(--space) * 2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.picker label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.picker input { accent-color: var(--accent); margin: 0; }
.rm-note { display: none; margin: calc(var(--space) * 2) 0 0; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .rm-note { display: block; } }

/* ---------- Sections ---------- */
.grid { display: grid; gap: calc(var(--space) * 2); grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: calc(var(--space) * 2); background: var(--surface-raised); min-width: 0; }
.card > p:last-child { margin-bottom: 0; }
.what { font-size: 0.875rem; color: var(--ink-soft); }

/* ---------- Hero loop (the one loop on the page; Pause stops it) ---------- */
.hero { display: grid; gap: calc(var(--space) * 3); margin-bottom: calc(var(--space) * 4); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space); }
.feed li { display: flex; gap: var(--space); align-items: center; padding: var(--space) calc(var(--space) * 1.5); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-raised); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; position: relative; }
.dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
.loop-row { display: flex; align-items: center; gap: var(--space); }

/* ---------- Buttons ---------- */
.btn { font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius); border: 1px solid var(--accent); padding: var(--space) calc(var(--space) * 2); min-height: 44px;
  background: var(--accent); color: var(--on-accent);
  transition: transform var(--motion-fast) var(--ease-move), box-shadow var(--motion-fast) var(--ease-enter), background-color var(--motion-fast) var(--ease-enter); }
.btn-quiet { background: transparent; color: var(--accent); }
.btn:hover, .btn:focus-visible { transform: translateY(var(--motion-lift)); box-shadow: 0 4px 12px light-dark(#0b6e5e33, #2ee6c533); }
.btn:active { transform: translateY(0) scale(var(--motion-press)); }

/* ---------- Disclosure (continuity: the panel arrives from its button) ---------- */
.disclosure-btn { display: flex; width: 100%; justify-content: space-between; align-items: center; font: inherit; font-weight: 600; background: none; color: inherit; border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space) calc(var(--space) * 1.5); min-height: 44px; cursor: pointer; }
.chevron { transition: rotate var(--motion-standard) var(--ease-move); }
[aria-expanded="true"] .chevron { rotate: 180deg; }
.panel { padding: calc(var(--space) * 1.5) calc(var(--space) * 1.5) 0; }

/* ---------- Status (cause and effect: the text is there at once; motion only follows it) ---------- */
.status { min-height: 3rem; margin-top: calc(var(--space) * 1.5); }
.status-msg { display: inline-block; padding: var(--space) calc(var(--space) * 1.5); border-radius: var(--radius); border: 1px solid var(--accent); }
.status-msg:empty { display: none; }

/* ---------- Token readout ---------- */
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }

/* ---------- Keyframes: only when the OS allows motion and the level is not "none" ---------- */
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-motion="none"]) .feed li {
    animation: enter var(--motion-slow) var(--ease-move) backwards;
    animation-delay: calc(var(--i, 0) * var(--motion-stagger));
  }
  :root:not([data-motion="none"]) .feed li:last-child .dot::after {
    animation: ring var(--motion-loop) var(--ease-enter) infinite;
    animation-play-state: var(--motion-loop-state);
  }
  :root:not([data-motion="none"])[data-loop="paused"] .feed li:last-child .dot::after { animation: none; }
  :root:not([data-motion="none"]) .panel { animation: enter var(--motion-standard) var(--ease-enter) backwards; }
  :root:not([data-motion="none"]) .status-msg { animation: enter var(--motion-standard) var(--ease-enter) backwards; }
}
/* Entry moves things; it never hides them. Content is readable from the first frame (no opacity: 0 start). */
@keyframes enter { from { translate: 0 var(--motion-distance); } }
@keyframes ring { 0% { opacity: 0.6; scale: 0.6; } 70%, 100% { opacity: 0; scale: 1.6; } }
