/* Punch-Down Trainer */

/* ---------- setup ---------- */
.pd-setup { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 4px 16px; }
.pd-setup .eyebrow { margin-top: 8px; }
.pd-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.pd-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 88px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.pd-option.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pd-option.is-locked { background: transparent; border-style: dashed; cursor: default; }
.pd-option-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 1.15rem; font-weight: 800; }
.pd-option-detail { color: var(--muted); font-size: 0.92rem; }
.pd-option-best { margin-top: auto; padding-top: 4px; font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.pd-start { margin-top: 12px; min-height: 60px; font-size: 1.15rem; }

/* ---------- play ---------- */
.pd-play { height: 100%; min-height: 240px; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.pd-hint { color: var(--muted); font-size: 0.9rem; }
.pd-clock { font: 700 1.25rem var(--mono); font-variant-numeric: tabular-nums; padding-right: 4px; }
.pd-actions { flex: none; display: flex; gap: 10px; }
.pd-actions .btn { flex: 1; }
.pd-actions .pd-test { flex: 2; }

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.jack, .tray {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(8, minmax(0, 68px));
  align-content: center;
  gap: 5px;
}
.jack { padding: 6px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.tray { padding: 6px 0; }

.slot {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 56px;
  gap: 5px;
  align-items: stretch;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface);
}
.slot.over { outline: 3px solid var(--accent); }
.slot-pin { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.pin-num { font: 800 1rem var(--mono); line-height: 1; }
.pin-dot.wire { width: 22px; height: 10px; min-height: 0; flex: none; border-radius: 5px; box-shadow: none; cursor: default; }

/* The channel a conductor lies in, with the two IDC blades it gets punched between. */
.slot-channel {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 3px 4px;
  border-radius: 8px;
  background: var(--bg);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.slot-channel::before, .slot-channel::after {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 4px;
  border-radius: 1px;
  background: linear-gradient(90deg, #8C939C, #E3E6EA 50%, #8C939C);
  z-index: 0;
}
.slot-channel::before { left: 10%; }
.slot-channel::after { left: 22%; }
.slot.punched .slot-channel::before, .slot.punched .slot-channel::after { z-index: 2; }
.slot-hint {
  position: relative;
  z-index: 1;
  margin-left: auto;
  padding: 0 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.slot.filled .slot-hint { display: none; }
.has-selection .slot:not(.filled) .slot-channel { outline: 2px dashed var(--accent); outline-offset: -2px; }

.punch-btn {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}
.punch-btn:disabled { background: transparent; color: var(--muted); opacity: 0.45; cursor: default; box-shadow: inset 0 0 0 2px var(--line); }
.slot.punched .punch-btn:disabled { opacity: 1; color: var(--pass); font-size: 1.2rem; box-shadow: none; }
.punch-btn:active:not(:disabled) { transform: scale(0.94); }

.tray-cell { min-height: 0; display: flex; align-items: center; border-radius: 999px; outline: 2px dashed var(--line); outline-offset: -3px; }

/* A conductor. --ins is its insulation color, set inline from standards.json. */
.wire {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-height: 46px;
  min-height: 22px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  background: var(--ins);
  box-shadow: inset 0 -7px 8px rgba(0, 0, 0, 0.25), inset 0 5px 6px rgba(255, 255, 255, 0.35);
  cursor: grab;
  touch-action: none;
  transition: width 0.12s ease-out;
}
.wire.striped { background: repeating-linear-gradient(-58deg, #F4F4F0 0 10px, var(--ins) 10px 15px); }
.wire-label {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(13, 21, 38, 0.78);
  color: #F5F1E8;
  font: 700 0.72rem var(--mono);
  white-space: nowrap;
  pointer-events: none;
}
.wire.selected { outline: 3px solid var(--accent); outline-offset: 2px; }
.wire.ghost { opacity: 0.3; }
.wire.drag-clone {
  position: fixed;
  z-index: 100;
  margin: 0;
  max-height: none;
  pointer-events: none;
  cursor: grabbing;
  transition: none;
  box-shadow: inset 0 -7px 8px rgba(0, 0, 0, 0.25), inset 0 5px 6px rgba(255, 255, 255, 0.35), 0 10px 22px rgba(0, 0, 0, 0.35);
}
/* Punched: the tool trims the tail flush, and the conductor is locked in. */
.slot.punched .wire { width: 72%; cursor: default; border-radius: 999px 3px 3px 999px; padding: 0 4px; }
.slot.just-punched { animation: pd-punch 0.25s ease-out; }
.slot.reject { animation: pd-reject 0.3s; }
@keyframes pd-punch { 0% { transform: translateY(0); } 30% { transform: translateY(3px) scale(0.985); } 100% { transform: none; } }
@keyframes pd-reject { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Short landscape screens (phones on their side): two columns of four. */
@media (orientation: landscape) and (max-height: 560px) {
  .pd-play { max-width: none; flex-direction: row; }
  .pd-hint { display: none; }
  .pd-actions { flex-direction: column; width: 124px; }
  .pd-actions .btn { padding: 0 8px; }
  .jack, .tray { grid-template-rows: repeat(4, minmax(0, 68px)); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .tray { column-gap: 8px; }
}
@media (max-height: 620px) and (orientation: portrait) {
  .pd-hint { display: none; }
}

/* ---------- result ---------- */
.pd-result { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }
.pd-result-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.pd-result-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 720px) {
  .pd-result-main { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); }
}

/* The tester is a device with its own screen, so its colors do not follow the theme. */
.tester {
  padding: 12px 14px;
  border: 3px solid var(--slate);
  border-radius: 18px;
  background: #0D1526;
  color: #DCE6F2;
  font-family: var(--mono);
}
.tester-head { display: flex; justify-content: space-between; font-size: 0.8rem; letter-spacing: 0.12em; opacity: 0.8; }
.tester-verdict { margin: 4px 0 6px; font-size: 2rem; font-weight: 800; letter-spacing: 0.08em; line-height: 1.1; }
.tester-verdict.pass { color: #4CC38A; }
.tester-verdict.fail { color: #FF7A66; }
.wiremap { display: block; width: 100%; max-width: 340px; margin: 0 auto; }
.wiremap text { fill: #DCE6F2; font: 700 12px var(--mono); text-anchor: middle; dominant-baseline: central; }
.wiremap .wm-head { font-size: 9px; letter-spacing: 0.1em; opacity: 0.7; }
.wiremap .wm-open { fill: #FF7A66; font-size: 10px; text-anchor: start; }
.wm-line { stroke-width: 2.5; stroke-linecap: round; }
.wm-line.ok { stroke: #4CC38A; }
.wm-line.bad { stroke: #FF7A66; }
.wm-dot { fill: #DCE6F2; }
.wm-dot.bad { fill: #FF7A66; }
.tester-faults { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed rgba(220, 230, 242, 0.3); font-size: 0.88rem; }
.tester-faults b { color: #FF7A66; }

.pd-summary { display: flex; flex-direction: column; gap: 6px; }
.pd-stars { font-size: 2.6rem; line-height: 1; }
.pd-numbers { display: flex; gap: 20px; margin: 0; flex-wrap: wrap; }
.pd-numbers dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.pd-numbers dd { margin: 0; font: 800 1.5rem var(--mono); font-variant-numeric: tabular-nums; }
.pd-best, .pd-unlock { color: var(--muted); font-size: 0.95rem; }
.pd-best.is-new, .pd-unlock.is-new { color: var(--accent); font-weight: 800; }
.pd-notes { display: flex; flex-direction: column; gap: 8px; font-size: 0.95rem; }
.pd-note { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; }
