/* =========================================================
   ADLC animation page — builds on style.css tokens
   ========================================================= */

:root {
  --human: #d97706;
  --agent: var(--accent);
  --gate: #0d9488;
  --fail: #dc2626;
}

:root[data-theme="dark"] {
  --human: #fbbf24;
  --gate: #2dd4bf;
  --fail: #f87171;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --human: #fbbf24;
    --gate: #2dd4bf;
    --fail: #f87171;
  }
}

.container.wide {
  max-width: 1120px;
}

.role-human { --role: var(--human); }
.role-agent { --role: var(--agent); }
.role-gate  { --role: var(--gate); }
.role-fail  { --role: var(--fail); }

/* ---------- Hero ---------- */

.adlc-hero {
  padding: 72px 0 32px;
}

.adlc-hero p.lede {
  max-width: 680px;
  margin-bottom: 0;
}

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

.adlc-stage {
  padding: 12px 0 56px;
}

.adlc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 960px) {
  .adlc-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    align-items: start;
  }
}

.ring-card,
.log-card,
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.ring-card {
  padding: 20px 20px 16px;
}

#adlc-ring {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* ---------- Ring scene ---------- */

#adlc-ring .track {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

#adlc-ring .track-flow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 2 14;
  stroke-linecap: round;
  opacity: 0.55;
  animation: flow 1.6s linear infinite;
}

@keyframes flow {
  to { stroke-dashoffset: -32; }
}

#adlc-ring .loop-path {
  fill: none;
  stroke: var(--fail);
  stroke-width: 2.5;
  stroke-dasharray: 6 6;
  opacity: 0.35;
  transition: opacity 0.3s ease;
}

#adlc-ring .loop-path.hot {
  opacity: 1;
  animation: flow-back 0.8s linear infinite;
}

@keyframes flow-back {
  to { stroke-dashoffset: -24; }
}

#adlc-ring .loop-label {
  font-family: var(--font-mono);
  font-size: 14px;
  fill: var(--fail);
  opacity: 0.85;
}

#adlc-ring .spoke {
  stroke: var(--border);
  stroke-width: 2;
  stroke-dasharray: 3 5;
  transition: stroke 0.3s ease;
}

#adlc-ring .spoke.active {
  stroke: var(--accent);
  animation: flow-in 0.9s linear infinite;
}

@keyframes flow-in {
  to { stroke-dashoffset: 16; }
}

#adlc-ring .hub {
  fill: var(--accent-soft);
  stroke: color-mix(in srgb, var(--accent) 35%, transparent);
  stroke-width: 1.5;
}

#adlc-ring .hub-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 10;
  opacity: 0.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 24s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#adlc-ring .hub-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 25px;
  fill: var(--text);
}

#adlc-ring .hub-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: var(--text-muted);
}

/* Nodes */

#adlc-ring .node {
  color: var(--role);
  cursor: pointer;
  outline: none;
}

#adlc-ring .node-bg {
  fill: var(--bg-elevated);
  stroke: var(--role);
  stroke-width: 2.5;
  transition: fill 0.25s ease;
}

#adlc-ring .node use {
  color: var(--role);
  transition: color 0.25s ease;
}

#adlc-ring .node-halo {
  fill: var(--role);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

#adlc-ring .node.active .node-bg {
  fill: var(--role);
}

#adlc-ring .node.active use {
  color: var(--bg-elevated);
}

#adlc-ring .node.active .node-halo {
  animation: pulse 1.4s ease-out infinite;
}

#adlc-ring .node.focus .node-bg,
#adlc-ring .node:focus-visible .node-bg {
  stroke-width: 5;
}

#adlc-ring .node.focus .node-halo,
#adlc-ring .node:focus-visible .node-halo {
  opacity: 0.18;
}

@keyframes pulse {
  0%   { opacity: 0.45; transform: scale(0.85); }
  100% { opacity: 0;    transform: scale(1.35); }
}

#adlc-ring .node-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  fill: var(--text);
}

#adlc-ring .node-sub {
  font-size: 16px;
  fill: var(--text-muted);
}

/* Tokens */

#adlc-ring .token {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent));
}

#adlc-ring .token.fail {
  fill: var(--fail);
  filter: drop-shadow(0 0 6px var(--fail));
}

#adlc-ring .token.signal {
  fill: var(--human);
  filter: drop-shadow(0 0 6px var(--human));
}

#adlc-ring .sat {
  fill: var(--agent);
  opacity: 0.85;
}

/* Paused: freeze the CSS-driven motion along with the simulation. */
.adlc-paused #adlc-ring * {
  animation-play-state: paused !important;
}

/* ---------- Legend ---------- */

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin: 10px 0 0;
  padding: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--role);
}

/* ---------- Side panel ---------- */

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#play-toggle {
  min-width: 108px;
  justify-content: center;
}

#play-toggle .i-play { display: none; }
#play-toggle.paused .i-play { display: inline; }
#play-toggle.paused .i-pause { display: none; }

.speed {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: var(--bg-elevated);
}

.speed button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: 600 13.5px var(--font-sans);
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
}

.speed button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-num.human {
  color: var(--human);
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.log-card {
  padding: 16px 18px 6px;
  border-radius: var(--radius-md);
}

.log-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gate);
  animation: blink 1.6s ease-in-out infinite;
}

.adlc-paused .live-dot {
  animation: none;
  background: var(--text-muted);
}

@keyframes blink {
  50% { opacity: 0.3; }
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 300px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
}

.log li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  padding: 7px 0 7px 10px;
  border-left: 2px solid var(--role);
  margin-bottom: 6px;
  animation: log-in 0.35s ease-out;
}

.log li:nth-child(n + 5) { opacity: 0.65; }
.log li:nth-child(n + 7) { opacity: 0.35; }

.log .t {
  color: var(--text-muted);
  grid-row: span 2;
}

.log .who {
  color: var(--role);
  font-weight: 500;
}

.log .msg {
  color: var(--text);
  overflow-wrap: anywhere;
}

@keyframes log-in {
  from { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Stage cards ---------- */

.stage-cards {
  padding: 24px 0 100px;
}

.stage-cards .section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.stage-cards h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0;
}

.stage-cards .section-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.stage-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 3px solid var(--role);
  border-radius: var(--radius-md);
  padding: 18px 20px 20px;
  outline: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stage-card:hover,
.stage-card:focus-visible,
.stage-card.focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stage-card.focus {
  border-color: var(--role);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.step {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.role-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--role);
  background: color-mix(in srgb, var(--role) 12%, transparent);
  padding: 3px 10px;
  border-radius: 999px;
}

.stage-card h3 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 6px;
}

.stage-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14.5px;
}

.further {
  margin: 28px 0 0;
  color: var(--text-muted);
  font-size: 14.5px;
}

.further a {
  color: var(--accent-strong);
  text-underline-offset: 3px;
}

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
  .adlc-hero { padding: 48px 0 20px; }
  .ring-card { padding: 12px 8px 14px; }
  /* Sub-labels become unreadably small once the ring scales down; the cards
     below carry the same information. */
  #adlc-ring .node-sub,
  #adlc-ring .hub-sub,
  #adlc-ring .loop-label { display: none; }
  #adlc-ring .node-name { font-size: 30px; }
  .log { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #adlc-ring *,
  .live-dot,
  .log li {
    animation: none !important;
  }
}

.deep-dive {
  display: inline-block;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--role);
  text-decoration: none;
}

.deep-dive:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
