/* ==========================================================
   Primer components — additions on top of css/style.css
   (the shared cybertrainer.uk stylesheet). Only primer-specific
   components live here; colours come from style.css variables.
   ========================================================== */
:root {
  /* aliases used by the interactive labs */
  --bg: var(--navy-950);
  --bg-2: var(--navy-900);
  --bg-3: var(--navy-800);
  --text: var(--text-hi);
  --muted: var(--text-dim);
  --accent: var(--violet-bright);   /* UI highlight */
  --accent-2: var(--warn);          /* keys */
  --danger: var(--bad);             /* ciphertext / attacks */
  --ok: var(--good);
  --pt: var(--good);                /* plaintext */
}
html { scroll-behavior: smooth; }
.wrap section.card { scroll-margin-top: 80px; }
.card h2 { font-size: 1.5rem; }
.card h3 { font-size: 1.12rem; margin-top: 1.6em; }
.card ul, .card ol { padding-left: 1.3em; }
.card li { margin: .25em 0; }
.card b, .card strong { color: var(--text-hi); }
.prose { max-width: 70ch; }
code, kbd { font-family: var(--mono); font-size: .88em; color: var(--violet-bright); }
.wrap img, .wrap svg { max-width: 100%; }

/* "On this page" + pager */
.toc { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 24px; }
.toc .hint { margin: 0 4px 0 0; font-family: var(--mono); font-size: .75rem; }
.toc a.chip { text-decoration: none; }
.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 8px; }
.pager a { flex: 1; max-width: 48%; }
.pager a.next { text-align: right; align-items: flex-end; }
.pager .go { margin-top: 4px; }

/* Small info cards (inside a .card) */
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 16px 0; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 16px 0; }
.mini { padding: 16px; border-radius: 12px; background: var(--navy-800); border: 1px solid var(--line); }
.mini h3 { margin: 0 0 6px; font-size: 1rem; }
.mini p { font-size: .9rem; margin: 0 !important; }

/* Callouts reuse the .takeaway look */
.callout {
  position: relative; overflow: hidden; margin: 18px 0; padding: 16px 18px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--text-lo);
}
.callout::before { content: ""; position: absolute; inset: 0; background: var(--grad); opacity: .1; pointer-events: none; }
.callout > * { position: relative; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0 !important; }
.callout strong:first-child { display: block; margin-bottom: 4px; color: var(--violet-bright); font-family: var(--display); }
.callout.warn { border-color: rgba(255, 194, 102, .45); background: var(--warn-bg); }
.callout.warn::before, .callout.bad::before { display: none; }
.callout.warn strong:first-child { color: var(--warn); }
.callout.bad { border-color: rgba(255, 103, 103, .45); background: var(--bad-bg); }
.callout.bad strong:first-child { color: var(--bad); }

.tag { display: inline-block; font-family: var(--mono); font-size: .7rem; letter-spacing: .04em; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-lo); background: var(--navy-800); }
.tag.ok { color: var(--good); border-color: rgba(91, 224, 142, .45); background: var(--good-bg); }
.tag.bad { color: var(--bad); border-color: rgba(255, 103, 103, .45); background: var(--bad-bg); }
.tag.warn { color: var(--warn); border-color: rgba(255, 194, 102, .45); background: var(--warn-bg); }

.table-wrap { overflow-x: auto; }
.card table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: .9rem; }
.card th, .card td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
.card th { color: var(--text-hi); font-weight: 600; background: var(--navy-800); font-family: var(--display); }

/* ---------- Labs ---------- */
.lab { background: var(--navy-950); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 20px; margin: 20px 0; }
.lab-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font: 600 1.02rem var(--display); color: var(--text-hi); }
.lab-title::before { content: "LAB"; font: 600 .66rem var(--mono); letter-spacing: .12em; color: var(--navy-950); background: var(--grad); padding: 3px 8px; border-radius: 999px; }
.lab h3 { font-size: .98rem; margin: 1.2em 0 .4em; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.row > label { color: var(--text-lo); font-size: .88rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.grid2 > *, .compare > *, .enigma-machine > * { min-width: 0; }

.wrap input[type=text], .wrap input[type=number], .wrap textarea, .wrap select {
  font: .92rem var(--mono); color: var(--text-hi); background: var(--navy-900);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%;
}
.wrap input[type=number] { width: 6.5em; }
.wrap textarea { min-height: 5em; resize: vertical; }
.wrap input:focus, .wrap textarea:focus, .wrap select:focus { outline: none; border-color: var(--violet-bright); box-shadow: 0 0 0 3px rgba(178, 102, 255, .2); }
.wrap input[type=range] { accent-color: var(--violet); width: 220px; max-width: 100%; }
.wrap input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--navy-900); }

/* lab buttons follow .btn, slightly more compact */
.wrap button {
  display: inline-flex; align-items: center; gap: 6px; font: 600 .86rem 'Inter', sans-serif;
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text-hi);
  transition: border-color .18s ease, color .18s ease, transform .18s ease;
}
.wrap button:hover { border-color: var(--violet-bright); color: var(--violet-bright); }
.wrap button.primary { background: var(--grad); color: var(--navy-950); border-color: transparent; box-shadow: 0 6px 22px rgba(124, 92, 252, .3); }
.wrap button.primary:hover { color: var(--navy-950); transform: translateY(-1px); }
.wrap button.danger { border-color: rgba(255, 103, 103, .5); color: var(--bad); }
.wrap button:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.out {
  font: .88rem/1.55 var(--mono); color: var(--text-hi); background: var(--navy-900); border: 1px dashed var(--line);
  border-radius: 9px; padding: 10px 12px; word-break: break-all; white-space: pre-wrap; min-height: 2.4em;
}
.out.pt, .p { color: var(--pt); }
.out.ct, .c { color: var(--bad); }
.out.key, .k { color: var(--warn); }
.muted { color: var(--text-dim); }
.small { font-size: .86rem; }
.lab .hint, .hint.small { font-size: .84rem; }

/* pipeline */
.pipeline { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.pipeline .box { flex: 1 1 140px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--navy-800); text-align: center; color: var(--text-hi); }
.pipeline .box b { display: block; font: .7rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--violet-bright); margin-bottom: 2px; }
.pipeline .arrow { align-self: center; color: var(--text-dim); font-size: 1.3rem; }

/* letters / grids */
.strip { display: flex; flex-wrap: wrap; gap: 2px; font-family: var(--mono); }
.strip span { width: 1.75em; text-align: center; padding: 2px 0; background: var(--navy-900); border: 1px solid var(--line); border-radius: 4px; color: var(--text-hi); }
.strip span.hi { background: var(--violet); color: #fff; border-color: var(--violet); }
.strip span.hi2 { background: var(--warn); color: var(--navy-950); border-color: var(--warn); }
.cgrid { border-collapse: separate !important; border-spacing: 3px; width: auto !important; margin: 8px 0 !important; font-family: var(--mono); }
.cgrid td { border: 1px solid var(--line) !important; width: 2em; height: 2em; text-align: center !important; padding: 0 !important; background: var(--navy-900); border-radius: 4px; color: var(--text-hi); }
.cgrid td.on { background: rgba(124, 92, 252, .22); border-color: var(--violet) !important; }
.cgrid td.empty { opacity: .3; }

/* bits */
.bits { font-family: var(--mono); display: grid; grid-template-columns: 7em repeat(8, 2.1em); gap: 3px; align-items: center; margin: 4px 0; }
.bits .lbl { color: var(--text-lo); font-size: .82rem; }
.bit { text-align: center; border: 1px solid var(--line); border-radius: 5px; padding: 3px 0; }
.bit.one { background: color-mix(in srgb, currentColor 22%, var(--navy-950)); }
.wrap .bits button.bit { padding: 3px 0; justify-content: center; font: 600 .9rem var(--mono); color: inherit; }

/* sequence diagram stepper */
.stepper .seq { width: 100%; height: auto; display: block; background: var(--navy-900); border-radius: 10px; border: 1px solid var(--line); }
.stepper .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 8px; }
.stepper .counter { margin-left: auto; font-size: .78rem; padding: 4px 10px; }
.stepper .explain { background: var(--navy-900); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-height: 5.5em; }
.stepper .explain h4 { margin: 0 0 4px; font: 600 1rem var(--display); color: var(--text-hi); }
.stepper .explain p { margin: 4px 0; font-size: .92rem; }
.seq text { font-family: 'Inter', system-ui, sans-serif; fill: var(--text-hi); }
.seq .lane-label { font-weight: 600; font-size: 15px; font-family: 'Space Grotesk', system-ui, sans-serif; }
.seq .lane { stroke: var(--line); stroke-dasharray: 4 5; }
.seq .msg { stroke: var(--text-dim); stroke-width: 1.6; fill: none; }
.seq .msg.enc { stroke: var(--warn); stroke-width: 2.2; }
.seq .msg.cur { stroke: var(--violet-bright); stroke-width: 2.8; }
.seq .mlabel { font-size: 13px; font-family: 'JetBrains Mono', monospace; }
.seq .msub { font-size: 11px; fill: var(--text-dim); }
.seq .phase { font-size: 11px; fill: var(--violet-bright); font-family: 'JetBrains Mono', monospace; }
.seq .note-box { fill: var(--navy-800); stroke: var(--line); }
.seq .note { font-size: 12px; fill: var(--text-lo); }
.seq .faded { opacity: .45; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .82rem; color: var(--text-dim); margin-top: 8px; }
.legend i { display: inline-block; width: 22px; height: 3px; vertical-align: middle; margin-right: 6px; background: var(--text-dim); }
.legend i.enc { background: var(--warn); }
.legend i.cur { background: var(--violet-bright); }

/* timeline */
.timeline { list-style: none; padding: 0 !important; margin: 18px 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 20px; margin: 0 !important; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .45em; width: 12px; height: 12px; border-radius: 50%; background: var(--grad); }
.timeline .when { font-family: var(--mono); color: var(--violet-bright); font-size: .8rem; }

/* quiz */
.quiz { margin: 14px 0 0; }
.quiz .q { background: var(--navy-950); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.quiz .q p { margin: 0 0 10px; font-weight: 600; color: var(--text-hi); }
.quiz .opts { display: grid; gap: 6px; }
.wrap .quiz .opts button { justify-content: flex-start; text-align: left; font-weight: 500; color: var(--text-lo); }
.wrap .quiz .opts button.right { border-color: var(--good); color: var(--good); background: var(--good-bg); }
.wrap .quiz .opts button.wrong { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }
.quiz .why { color: var(--text-dim); font-size: .88rem; margin-top: 8px; display: none; }
.quiz .q.done .why { display: block; }

/* Enigma */
.enigma-machine { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.rotors { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.rotor { background: var(--navy-900); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; min-width: 112px; display: grid; gap: 4px; justify-items: center; }
.rotor .win { font: 700 2rem var(--mono); background: var(--navy-800); color: var(--text-hi); border-radius: 8px; width: 100%; padding: 2px 0; }
.rotor .lbl { font: .66rem var(--mono); color: var(--violet-bright); text-transform: uppercase; letter-spacing: .1em; }
.wrap .rotor .ud button { padding: 2px 12px; }
.wrap .rotor select { width: auto; padding: 4px 8px; font-size: .8rem; }
.lampboard, .keyboard { display: grid; gap: 6px; justify-content: center; }
.lampboard .krow, .keyboard .krow { display: flex; gap: 6px; justify-content: center; }
.lamp { width: 2.3em; height: 2.3em; border-radius: 50%; display: grid; place-items: center; font: 600 .92rem var(--mono); background: var(--navy-900); border: 1px solid var(--line); color: var(--text-dim); transition: background .1s; }
.lamp.lit { background: var(--warn); color: #241600; border-color: var(--warn); box-shadow: 0 0 18px var(--warn); }
.wrap .keyboard button { width: 2.5em; height: 2.5em; padding: 0; justify-content: center; font-family: var(--mono); }
.signal-path { font: .84rem var(--mono); overflow-x: auto; white-space: nowrap; background: var(--navy-900); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; color: var(--text-hi); }
.signal-path b { color: var(--warn); }

/* pigpen */
.pigpen { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 40px; }
.pigpen svg { width: 34px; height: 34px; }
.pigpen svg line, .pigpen svg polyline { stroke: var(--violet-bright); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pigpen svg circle { fill: var(--violet-bright); }
.pigpen .gap { width: 16px; }

/* frequency */
.freq { display: grid; grid-template-columns: repeat(26, 1fr); gap: 2px; align-items: end; height: 140px; margin: 10px 0 0; }
.freq div { background: var(--violet); border-radius: 2px 2px 0 0; min-height: 1px; }
.freq div.eng { background: var(--text-dim); opacity: .5; }
.freq-labels { display: grid; grid-template-columns: repeat(26, 1fr); gap: 2px; font: .68rem var(--mono); color: var(--text-dim); text-align: center; }

/* ECB canvases */
.canvases { display: flex; gap: 16px; flex-wrap: wrap; }
.canvases figure { margin: 0; text-align: center; }
.canvases canvas { width: 180px; height: 180px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; }
.canvases figcaption { font-size: .82rem; color: var(--text-dim); margin-top: 4px; }

/* certificates */
.chain { display: grid; gap: 8px; }
.cert { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--navy-800); position: relative; }
.cert.root { border-color: rgba(178, 102, 255, .6); }
.cert .ttl { font: 600 1rem var(--display); color: var(--text-hi); padding-right: 2.5em; }
.cert dl { display: grid; grid-template-columns: 8.5em 1fr; gap: 2px 10px; margin: 8px 0 0; font-size: .8rem; }
.cert dt { color: var(--text-dim); }
.cert dd { margin: 0; font-family: var(--mono); color: var(--text-lo); word-break: break-all; }
.cert .status { position: absolute; top: 10px; right: 12px; }
.chain .link { text-align: center; color: var(--text-dim); font: .78rem var(--mono); }
.chain .link.ok { color: var(--good); }
.chain .link.bad { color: var(--bad); }

/* DH paint */
.paint-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; font-size: .9rem; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); display: inline-block; }
.party { background: var(--navy-900); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.party h4 { margin: 0 0 6px; color: var(--text-hi); font-family: var(--display); }

.card details { background: var(--navy-800); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.card details summary { cursor: pointer; font-weight: 600; color: var(--text-hi); }
.hero-graphic { font: .86rem/1.5 var(--mono); color: var(--text-lo); background: var(--navy-950); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; overflow-x: auto; white-space: pre; margin: 0; }
.home-start { margin-top: 26px; }

@media (max-width: 640px) {
  .stepper .counter { margin-left: 0; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}
.tool-card .eyebrow { flex: 0 0 auto; font-size: .68rem; }
.lab p.small.muted, .lab p.muted.small { margin: 12px 0 4px; } .lab label.small.muted { display:block; margin: 4px 0 4px; }

/* ---------- Flow diagram (plaintext → encrypt → ciphertext → decrypt → plaintext) ---------- */
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1.25fr auto 1fr auto 1fr; gap: 10px 8px; align-items: stretch; margin: 18px 0 6px; }
.flow .box { border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px; background: var(--navy-800); text-align: center; color: var(--text-hi); display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.flow .box b { font: .68rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); }
.flow .box .v { font: 600 1.02rem var(--mono); word-break: break-word; }
.flow .box small { font-size: .74rem; color: var(--text-dim); }
.flow .box.ct { border-color: rgba(255, 103, 103, .45); background: var(--bad-bg); }
.flow .box.op { background: var(--navy-900); }
.flow .arrow { align-self: center; color: var(--text-dim); font-size: 1.2rem; text-align: center; }
.flow .keybar { grid-column: 3 / 8; text-align: center; font-size: .84rem; color: var(--text-lo); border: 1px dashed rgba(255, 194, 102, .45); border-radius: 10px; padding: 8px 12px; background: var(--warn-bg); }
.flow .keybar .k { font-weight: 600; }
@media (max-width: 760px) {
  .flow { grid-template-columns: 1fr; }
  .flow .arrow { transform: rotate(90deg); }
  .flow .keybar { grid-column: auto; }
}
.flow.f3 { grid-template-columns: 1fr auto 1fr auto 1fr; }
@media (max-width: 760px) { .flow.f3 { grid-template-columns: 1fr; } .flow .arrow.noturn { transform: none; } }
.dbtable td.mono, .dbtable td .mono { word-break: break-all; }
.dbtable tr.same td { background: rgba(255, 103, 103, .08); }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.wrap .radio-row button.on { background: var(--grad); color: var(--navy-950); border-color: transparent; }
.crack-row.cracked td { background: rgba(255, 103, 103, .1); }
.crack-row.safe td { background: rgba(91, 224, 142, .06); }
.totp-code { font: 700 2.6rem var(--mono); letter-spacing: .12em; color: var(--text-hi); }
.countdown { height: 8px; border-radius: 99px; background: var(--navy-800); overflow: hidden; margin: 8px 0; }
.countdown div { height: 100%; background: var(--grad); transition: width 1s linear; }
.jwt { font: .86rem/1.6 var(--mono); word-break: break-all; background: var(--navy-900); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.jwt .h { color: var(--bad); } .jwt .pl { color: var(--violet-bright); } .jwt .s { color: var(--blue); }
.out { word-break: normal; overflow-wrap: anywhere; }
