/* Network simulator: tool-specific styles. Theme comes from ../synthwave.css */

/* ---------- App shell: fills the window, the page itself never scrolls ---------- */
html, body.app { height: 100%; }
body.app {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px; padding: 8px 12px;
}

.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; flex: none; }
.topbar h1 { margin: 0; font-size: clamp(1.2rem, 2.6vw, 2rem); letter-spacing: .12em; }
.topbar-right { justify-self: end; display: flex; align-items: center; gap: 12px; }
.topbar-right .theme-toggle { margin-left: 0; }
.home-link { color: var(--cyan); text-decoration: none; text-transform: uppercase; letter-spacing: .1em; font-size: .85rem; }
.home-link:hover, .home-link:focus-visible { color: var(--hi); text-shadow: 0 0 8px var(--cyan); }

.stage {
  flex: 1; min-height: 0;
  display: grid; gap: 10px;
  grid-template-columns: minmax(0, 1fr) clamp(270px, 23vw, 360px);
}
.stage > .panel { min-height: 0; overflow-y: auto; padding: 10px 12px; }
.panel h2 { font-size: .95rem; margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .08em; }
.panel h2:first-child { margin-top: 0; }

/* ---------- Toolbar ---------- */
.toolbar {
  flex: none; padding: 8px 12px;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 18px;
  font-size: .85rem;
}
.tool-group { display: flex; align-items: flex-end; gap: 8px; }
.group-label { align-self: center; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.toolbar .btn, .toolbar .segmented button { padding: 6px 12px; }
.field-label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.field-label select, .field-label input { padding: 5px 8px; }
/* fixed widths, so changing mode or the Send label never reflows the toolbar */
#from, #to { width: 10em; }
#data { width: 9em; }
#sendBtn { width: 10.5em; }
/* keep the toolbar on one row on projector-sized screens */
@media (max-width: 1700px) {
  .toolbar { font-size: .75rem; gap: 6px 12px; }
  .toolbar .group-label { display: none; }
  .toolbar .btn, .toolbar .segmented button { padding: 5px 8px; letter-spacing: .04em; }
  .tool-group { gap: 6px; }
  #data { width: 7em; }
  #sendBtn { width: 10em; }
}

/* ---------- Network diagram ---------- */
.workspace { display: flex; flex-direction: column; gap: 8px; }
.canvas {
  position: relative; flex: 1; min-height: 0; border: 1px solid rgba(123, 47, 247, .6); border-radius: 8px;
  background: var(--canvas-bg);
}
.canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.canvas svg text { font-family: var(--font); pointer-events: none; }

.area { fill: none; stroke: var(--cyan); stroke-width: 2; stroke-dasharray: 10 8; opacity: .55; }
.area--wan { stroke: var(--purple); fill: color-mix(in srgb, var(--purple) 8%, transparent); opacity: 1; }
.area-label { fill: var(--cyan); font-size: 20px; font-weight: 700; letter-spacing: .08em;
              paint-order: stroke; stroke: var(--canvas-bg); stroke-width: 6px; stroke-linejoin: round; }
.area-label--wan { fill: var(--purple); }

.link { stroke: var(--line-strong); stroke-width: 4; }
.link--wan { stroke: var(--purple); stroke-width: 7; }

.port { fill: var(--surface-solid); stroke: var(--yellow); stroke-width: 2; }
.port-num { fill: var(--yellow); font-size: 15px; font-weight: 700; text-anchor: middle; }

.ic-body { fill: var(--surface-solid); stroke: var(--cyan); stroke-width: 3; }
.ic-screen { fill: color-mix(in srgb, var(--cyan) 22%, var(--surface-solid)); stroke: none; }
.ic-paper { fill: var(--hi); stroke: var(--cyan); stroke-width: 2; }
.ic-line { stroke: var(--cyan); stroke-width: 4; }
.ic-led { fill: var(--green); }
.ic-arrow { fill: none; stroke: var(--pink); stroke-width: 3.5; stroke-linecap: round; }
.node--switch .ic-body { stroke: var(--yellow); }
.node--router .ic-body { stroke: var(--pink); stroke-width: 4; }
.switch-name { fill: var(--hi); font-size: 19px; font-weight: 700; text-anchor: middle; }
.node.is-focus .ic-body { filter: drop-shadow(0 0 10px var(--yellow)); stroke: var(--yellow); }

/* text halo so labels stay readable where they cross a cable */
.label { fill: var(--hi); font-size: 18px; font-weight: 700; text-anchor: middle;
         paint-order: stroke; stroke: var(--canvas-bg); stroke-width: 5px; stroke-linejoin: round; }
.label--addr { fill: var(--cyan); font-size: 13px; font-weight: 400; }
.label--ip { fill: var(--pink); }

.tok-frame { fill: var(--surface-solid); stroke: var(--cyan); stroke-width: 3; filter: drop-shadow(0 0 6px var(--cyan)); }
.tok-packet { fill: color-mix(in srgb, var(--pink) 30%, var(--surface-solid)); stroke: var(--pink); stroke-width: 2.5; }
.tok-data { fill: var(--yellow); stroke: var(--hi); stroke-width: 2; filter: drop-shadow(0 0 8px var(--yellow)); }
.tok-text { fill: var(--hi); font-size: 13px; font-weight: 700; text-anchor: middle; letter-spacing: .06em; }
.tok-text--small { font-size: 10px; }
.tok-text--dark { fill: #1a0b3a; }
.token.is-faded { opacity: .3; }

.mark circle { stroke-width: 3; fill: var(--surface-solid); }
.mark--ok circle { stroke: var(--green); }
.mark--bad circle { stroke: var(--pink); }
.mark-text { font-size: 18px; font-weight: 700; text-anchor: middle; }
.mark--ok .mark-text { fill: var(--green); }
.mark--bad .mark-text { fill: var(--pink); }

/* ---------- Narration ---------- */
/* Fixed height (room for five lines) so the diagram above never changes size between steps */
.narration {
  flex: none; height: calc(8.3em + 20px); overflow-y: auto;
  padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-solid);
  font-size: clamp(.9rem, 1.1vw, 1.1rem);
}
.step-count { font-size: .72em; color: var(--yellow); text-transform: uppercase; letter-spacing: .1em; min-height: 1.2em; }
#narration { margin: 4px 0 0; line-height: 1.45; }
#narration b { color: var(--hi); }
#narration code, .tbl td, .fld-value { font-family: var(--font); color: var(--cyan); }

/* ---------- Frame / packet inspector ---------- */
.pdu { border: 2px solid var(--cyan); border-radius: 8px; padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 3px; }
.pdu--packet { border-color: var(--pink); margin: 2px 0; background: color-mix(in srgb, var(--pink) 8%, transparent); }
.pdu--data { border-color: var(--yellow); }
.pdu--data > .pdu-title { color: var(--yellow); }
.pdu.is-new { box-shadow: 0 0 14px var(--cyan); }
.pdu--packet.is-new { box-shadow: 0 0 14px var(--pink); }
.pdu-title { font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--cyan); }
.pdu--packet > .pdu-title { color: var(--pink); }
.pdu-part { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 4px; }
.fld { display: flex; flex-direction: column; padding: 3px 6px; border-radius: 5px; border: 1px solid transparent; }
.fld-label { font-size: .75rem; color: var(--muted); }
.fld-value { font-size: .95rem; overflow-wrap: anywhere; }
.fld-value small, .tbl small { display: block; font-size: .75rem; color: var(--text); opacity: .8; }
.fld.is-read { border-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 16%, transparent); }
.fld.is-read .fld-label { color: var(--yellow); }
.fld.is-changed .fld-value::after { content: " (new)"; color: var(--green); font-size: .75rem; }
/* removed frame: grey out its own header and trailer, but not the packet inside it */
.pdu.is-removed > .fld:not(.is-read), .pdu.is-removed > .pdu-part, .pdu.is-removed > .pdu-title { opacity: .4; }
.pdu.is-removed > .fld:not(.is-read) .fld-value { text-decoration: line-through; }
.pdu.is-removed { border-style: dashed; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; padding: 4px 6px; }
.tbl td { padding: 4px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tr.is-hit td { background: color-mix(in srgb, var(--yellow) 18%, transparent); color: var(--hi); }
.tbl tr.is-new td { background: color-mix(in srgb, var(--green) 16%, transparent); }

/* ---------- Help dialog ---------- */
dialog {
  max-width: min(46rem, 92vw); color: var(--text); background: var(--surface-solid);
  border: 2px solid var(--cyan); border-radius: 12px; padding: 18px 22px; font-family: var(--font);
  box-shadow: 0 0 24px rgba(5, 217, 232, .4);
}
dialog::backdrop { background: rgba(5, 1, 15, .75); }
dialog h3 { color: var(--cyan); margin: 14px 0 6px; }
.help-list { margin: 0; padding-left: 1.3rem; line-height: 1.5; }
.help-list li + li { margin-top: 6px; }
#closeHelpBtn { margin-top: 14px; }

/* ---------- Smaller screens: stack the panels and let the page scroll ---------- */
@media (max-width: 1000px) {
  body.app { height: auto; overflow: auto; }
  .stage { grid-template-columns: 1fr; }
  .canvas { flex: none; height: 62vw; min-height: 300px; }
  .topbar { grid-template-columns: 1fr; justify-items: center; }
  .topbar-right { justify-self: center; }
}
