/* ============================================================
   Wire a Three-Way — game styles.
   The site is monochrome on purpose; this page is the one
   exception. The wire colours ARE the lesson, so they stay
   true to the NEC conventions rather than the brand palette.
   ============================================================ */

:root {
  --w-black:  #16181A;
  --w-white:  #F4F4F0;
  --w-red:    #BE3A2B;
  --w-green:  #1C7F46;
  --w-casing: #0B0D0E;
  --live:     #F5A623;
  --fault:    #B4261B;
  --ok:       #12784F;
}

.game-shell { padding-block: clamp(2rem, 5vw, 3.5rem); }

/* --- toolbar ------------------------------------------------ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.tool-group { display: grid; gap: .6rem; }
.tool-group > span {
  font-family: var(--body);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.spools { display: flex; gap: .5rem; flex-wrap: wrap; }

.spool {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: .6rem .9rem;
  cursor: pointer;
  font: inherit;
  font-size: .8125rem;
  color: var(--ink-soft);
  transition: border-color .15s ease, color .15s ease;
}
.spool:hover { border-color: var(--ink-muted); }
.spool[aria-pressed="true"] {
  border-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.spool i {
  width: 18px; height: 18px;
  border: 1px solid var(--casing, #0B0D0E);
  flex: none;
  display: block;
}
.spool[data-color="black"] i { background: var(--w-black); }
.spool[data-color="white"] i { background: var(--w-white); }
.spool[data-color="red"]   i { background: var(--w-red); }
.spool[data-color="green"] i { background: var(--w-green); }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.actions .btn { padding: .75rem 1.25rem; font-size: .8125rem; }

/* --- stage -------------------------------------------------- */

.stage {
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 28px 100%,
    var(--paper);
  position: relative;
}
.stage svg { display: block; width: 100%; height: auto; touch-action: none; }

/* On a phone the full board would scale terminals down to a few pixels,
   which is not draggable. Let the board scroll sideways instead. */
@media (max-width: 860px) {
  .stage { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stage svg { min-width: 800px; }
}

.terminal { cursor: grab; }
.terminal:active { cursor: grabbing; }
.terminal .hit { fill: transparent; }
.terminal .ring { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.terminal.is-target .ring { stroke: var(--live); stroke-width: 4; }
.terminal.is-origin .ring { stroke: var(--live); stroke-width: 4; }
.terminal .screw { stroke: var(--ink); stroke-width: 2; }

.device-box { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.device-inner { fill: none; stroke: var(--line-2, #C6CFCF); stroke-width: 1.5; }
.device-label {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  fill: var(--ink);
}
.device-sub {
  font-family: var(--body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  fill: var(--ink-muted);
}
.term-label {
  font-family: var(--body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  fill: var(--ink-soft);
}

.wire-casing { fill: none; stroke: var(--w-casing); stroke-linecap: round; }
.wire-core   { fill: none; stroke-linecap: round; }
.wire-hit    { fill: none; stroke: transparent; stroke-width: 22; cursor: pointer; }
.wire-group:hover .wire-casing { stroke: var(--fault); }
.wire-glow   { fill: none; stroke: var(--live); stroke-linecap: round; opacity: .3; }

.blade { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; fill: none; }
.blade.live { stroke: var(--live); }

.lever { cursor: pointer; }
.lever rect { fill: var(--ink); stroke: var(--ink); stroke-width: 2; }
.lever:hover rect { fill: var(--ink-soft); }
.lever .plate { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }

.bulb-glass { fill: var(--surface-alt, #EDEFEF); stroke: var(--ink); stroke-width: 2.5; }
.bulb-glass.on { fill: var(--live); }
.bulb-halo { fill: var(--live); opacity: 0; }
.bulb-halo.on { opacity: .22; }
.bulb-filament { fill: none; stroke: var(--ink); stroke-width: 2; }

@media (prefers-reduced-motion: no-preference) {
  .wire-glow { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 0%,100% { opacity: .18; } 50% { opacity: .42; } }
}

/* --- readouts ----------------------------------------------- */

.readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-top: 0;
}
.readout { background: var(--paper); padding: 1rem 1.15rem; }
.readout dt {
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: .4rem;
}
.readout dd {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.readout dd.good  { color: var(--ok); }
.readout dd.bad   { color: var(--fault); }
.readout dd.idle  { color: var(--ink-muted); }

/* --- verdict ------------------------------------------------ */

.verdict {
  margin-top: 1.75rem;
  border: 1px solid var(--ink);
  border-left-width: 4px;
  padding: 1.4rem 1.6rem;
  background: var(--paper-alt);
}
.verdict[hidden] { display: none; }
.verdict.pass { border-left-color: var(--ok); }
.verdict.warn { border-left-color: var(--live); }
.verdict.fail { border-left-color: var(--fault); }
.verdict h3 { font-size: 1.25rem; margin: 0 0 .6rem; }
.verdict > p { color: var(--ink-soft); margin-bottom: 1.1rem; }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.checks li { display: grid; grid-template-columns: 1.4rem 1fr; gap: .7rem; align-items: baseline; }
.checks .mark { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.checks .mark.y { color: var(--ok); }
.checks .mark.n { color: var(--fault); }
.checks .mark.w { color: var(--ink-muted); }
.checks b { font-weight: 600; }
.checks span.why { display: block; color: var(--ink-soft); font-size: .9375rem; }

.truth {
  margin-top: 1.4rem;
  border-collapse: collapse;
  font-size: .875rem;
}
.truth th, .truth td {
  border: 1px solid var(--line);
  padding: .4rem .8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.truth th {
  font-size: .625rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  background: var(--paper);
}
.truth td.on  { color: var(--ok); font-weight: 700; }
.truth td.off { color: var(--ink-muted); }

/* --- explainer ---------------------------------------------- */

.explainer { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: clamp(1.5rem, 3vw, 2.5rem); }
.explainer > div { border-top: 2px solid var(--ink); padding-top: 1.25rem; }
.explainer h3 { font-size: 1.0625rem; margin-bottom: .7rem; }
.explainer p { font-size: .9375rem; color: var(--ink-soft); }

.hint {
  font-size: .8125rem;
  color: var(--ink-muted);
  border-left: 2px solid var(--line);
  padding-left: 1rem;
  margin-top: 1.25rem;
}
