/* ============================================================================
   SOCD Trainer — tool layer.

   base.css is loaded immediately before this file and owns everything
   structural: reset, body, links, focus rings, headings, forms, .panel,
   .btn, .chip, .chips, tables, header, footer, .wrap, .lede, .badge.

   This file sets the tool's accent and styles only what is specific to a
   SOCD trainer: the controller-pad SVG, the resolution instruction bar, the
   mode/layout selectors and the drill panel.

   Accent — lime/chartreuse (~90° hue), the widest gap from every sibling
   accent (43° amber → 142° green). Measured with a WCAG relative-luminance
   script against the shared palette in base.css:

     dark   #a3e635 on --bg #0e1116   12.54:1   on --surface #161a21  11.57:1
                     on --bg-sunk #0a0c10  12.98:1
     light  #3f6212 on --bg #fbfaf8    6.78:1   on --surface #ffffff   7.08:1
                     on --bg-sunk #f2f0ec   6.22:1

   Both clear the 4.5:1 text threshold against all three surfaces in both
   themes — this tool must pass the site's own contrast checker.
   ========================================================================= */

:root {
  --accent:     #a3e635;
  --accent-dim: rgba(163, 230, 53, 0.14);
}

@media (prefers-color-scheme: light) {
  :root {
    --accent:     #3f6212;
    --accent-dim: rgba(63, 98, 18, 0.10);
  }
}

/* --------------------------------------------------------------- utility -- */

[hidden] { display: none !important; }

main ul, main ol { padding-left: 1.25em; margin: 0 0 1.1em; }
main li { margin-bottom: 0.4em; }

.content p, .content ul, .content ol { max-width: 68ch; }
.content h2:first-child { margin-top: 0; }

.tool { margin-bottom: 2rem; }

/* The trainer panel is focusable so it can capture keys without the arrow keys
   hijacking page scroll everywhere. Show a clear accent ring when it has focus. */
#trainerPanel { outline: none; transition: border-color 0.12s ease, box-shadow 0.12s ease; }
#trainerPanel:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* --------------------------------------------------------- selector rows -- */

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.control-group { min-width: 0; }
.control-group > .field-label {
  display: block;
  margin-bottom: 0.5rem;
}

/* selected chip uses the accent, like the tab pattern elsewhere on the site */
.chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ------------------------------------------------------------- the pad --- */

.pad-stage {
  display: flex;
  justify-content: center;
  padding: 1.25rem;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}
.pad-svg { width: 100%; height: auto; max-width: 30rem; }
.pad-svg.wide { max-width: 34rem; }

/* a pad button: default resting state. Each button is a <g class="pad-cell">
   holding a shape (.pad-btn) and its label (.pad-btn-label); state classes go
   on the group. */
.pad-btn {
  fill: var(--surface-2);
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: fill 0.06s linear, stroke 0.06s linear;
}
.pad-btn-label {
  fill: var(--text-dim);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
/* a directional button reads slightly brighter so the axis stands out */
.pad-cell.is-dir .pad-btn { stroke: var(--text-faint); }

/* physically held AND passing through: accent fill */
.pad-cell.pressed .pad-btn { fill: var(--accent); stroke: var(--accent); }
.pad-cell.pressed .pad-btn-label { fill: var(--bg); }

/* held but SOCD-cleaned AWAY (input is being cancelled/overridden) */
.pad-cell.overridden .pad-btn { stroke: var(--accent); stroke-dasharray: 3 3; }
.pad-cell.overridden .pad-btn-label { fill: var(--accent); }

/* -------------------------------------------------------- instruction ---- */

.socd-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.socd-cell {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.socd-cell .socd-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.35rem;
}
.socd-value {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}
.socd-arrow {
  align-self: center;
  font-size: 1.5rem;
  color: var(--text-faint);
}
/* resolved-state colouring */
.socd-cell.is-clean .socd-value { color: var(--accent); }
.socd-cell.is-neutral .socd-value { color: var(--text-dim); }
.socd-cell.is-raw .socd-value { color: #fb7185; }   /* natural/no-cleaning = warning */

.socd-numpad {
  margin-left: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-faint);
}

@media (max-width: 34rem) {
  .socd-bar { grid-template-columns: 1fr; }
  .socd-arrow { transform: rotate(90deg); justify-self: center; }
}

/* --------------------------------------------------------- challenges ---- */

.challenges {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
#gameGroup { margin-top: 1rem; }
.game-note { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--text-faint); max-width: 68ch; line-height: 1.5; }
.chal-list { margin: 0.75rem 0 1rem; }
.chal-chip .chal-tick { color: var(--accent); font-weight: 700; }

.chal-active {
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.chal-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.4rem;
}
.chal-name { font-weight: 600; }
.chal-np { font-size: 0.85rem; color: var(--accent); }
.chal-reps { margin-left: auto; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.chal-desc { color: var(--text-dim); margin: 0 0 0.7rem; }
.chal-track {
  height: 8px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.chal-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.18s ease;
}

/* --------------------------------------------------------- victory ------- */

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
.victory-badge {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 1.15rem;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  animation: victory-pop 1.5s ease forwards;
}
.confetti-piece {
  position: absolute;
  top: -5%;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall 1.4s ease-in forwards;
}
@keyframes victory-pop {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  30%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}
@keyframes confetti-fall {
  0%   { top: -5%; opacity: 1; }
  100% { top: 105%; opacity: 0.9; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-piece { display: none; }
  .victory-badge { animation: none; }
}

/* ------------------------------------------------------------- misc ------ */

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-faint);
}
.hint-row kbd {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text-dim);
}

/* -------------------------------------------------------- controller ----- */

.controller {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.ctl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.ctl-status { color: var(--text-dim); }
.ctl-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ctl-actions .btn { font-size: 0.8rem; padding: 0.3rem 0.7rem; }
.ctl-cal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}
.ctl-cal-prompt {
  font-weight: 700;
  color: var(--accent);
  animation: ctl-pulse 1s ease-in-out infinite;
}
@keyframes ctl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .ctl-cal-prompt { animation: none; } }

.callout {
  margin: 1.4em 0;
  padding: 0.9rem 1.1rem;
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-dim);
  font-size: 0.9375rem;
  color: var(--text-dim);
}
.callout > :last-child { margin-bottom: 0; }
.callout strong { color: var(--text); }

.attributed { color: var(--text-faint); font-style: italic; }
