/* ==========================================================================
   games/network-lab/style.css — Atelier réseau
   --------------------------------------------------------------------------
   Grand écran : outils + missions | plan + console | configuration.
   Tablette : plan et console en pleine largeur, configuration et missions côte
   à côte dessous. Téléphone : une colonne, le plan défile horizontalement
   (le glisser d'un équipement ne gêne pas le défilement : touch-action).
   Couleurs : uniquement les variables de tokens.css.
   ========================================================================== */
.nl-noscript { padding: var(--space-5); color: var(--text-2); }

.nl-app {
  display: grid; gap: var(--space-3); padding: var(--space-3) max(16px, env(safe-area-inset-left, 0px)) var(--space-4);
  grid-template-columns: 240px minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr) minmax(170px, 30%);
  grid-template-areas: "tools stage insp" "miss stage insp" "miss cons insp";
  height: calc(var(--vh100) - 64px); min-height: 600px;
}
.nl-tools { grid-area: tools; }
.nl-stage { grid-area: stage; }
.nl-console { grid-area: cons; }
.nl-insp { grid-area: insp; }
.nl-miss { grid-area: miss; }
.nl-tools, .nl-stage, .nl-console, .nl-insp, .nl-miss { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

/* Palette ---------------------------------------------------------------- */
.nl-tools { padding: var(--space-3); display: grid; gap: var(--space-3); }
.nl-palette { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.nl-tool { display: grid; justify-items: center; gap: 4px; min-height: 64px; padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text-2); font-size: var(--fs-xs); cursor: pointer; }
.nl-tool:hover { border-color: var(--line-strong); color: var(--text); background: var(--panel-hover); }
.nl-tool.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nl-cable { grid-column: 1 / -1; grid-auto-flow: column; justify-content: center; align-items: center; min-height: 44px; font-size: var(--fs-sm); }
.nl-ico { width: 40px; height: 32px; overflow: visible; }
.nl-cable .nl-ico { width: 34px; height: 26px; }
.nl-acts { display: flex; justify-content: flex-end; }
.nl-mini { min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: transparent; color: var(--text-2); font-size: var(--fs-sm); cursor: pointer; }
.nl-mini:hover { color: var(--text); background: var(--panel-hover); }

/* Formes des équipements (palette et plan) */
.nl-ico .b, .nl-shape .b { fill: var(--panel); stroke: var(--text-2); stroke-width: 2; }
.nl-ico .s, .nl-shape .s { fill: var(--accent-soft); stroke: none; }
.nl-ico .l, .nl-shape .l { fill: none; stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nl-ico .port, .nl-shape .port { fill: var(--muted); }
.nl-ico .led, .nl-shape .led { fill: var(--ok); }

/* Plan ------------------------------------------------------------------- */
.nl-stage { display: flex; flex-direction: column; overflow: hidden; background: var(--bg-deep); }
.nl-scroll { flex: 1; min-height: 0; overflow: auto; display: grid; }
.nl-svg { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.nl-griddot { fill: var(--line-strong); }
.nl-bg { cursor: default; }
.nl-empty { font-family: var(--sans); font-size: 18px; fill: var(--muted); }
.nl-tip { margin: 0; padding: 6px 12px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); background: var(--panel); }

.nl-dev { cursor: grab; touch-action: none; outline: none; }
.nl-dev:active { cursor: grabbing; }
.nl-dev .halo { fill: transparent; stroke: transparent; stroke-width: 2; }
.nl-dev:hover .halo { fill: var(--panel-hover); }
.nl-dev.sel .halo { fill: var(--accent-soft); stroke: var(--accent); }
.nl-dev.from .halo { fill: var(--warn-soft); stroke: var(--warn); stroke-dasharray: 5 4; }
.nl-dev:focus-visible .halo { stroke: var(--accent); stroke-dasharray: 3 3; }
.nl-dev.sel .nl-shape .b, .nl-dev.sel .nl-shape .l { stroke: var(--accent); }
.nl-router .nl-shape .b { fill: var(--bg); }
.nl-dev .nm { font-family: var(--sans); font-size: 14px; font-weight: 600; fill: var(--text); }
.nl-dev .ad { font-family: var(--mono); font-size: 11.5px; fill: var(--muted); }

.nl-link { cursor: pointer; outline: none; }
.nl-link .hit { stroke: transparent; stroke-width: 18; }
.nl-link .wire { stroke: var(--line-strong); stroke-width: 3; stroke-linecap: round; }
.nl-link:hover .wire { stroke: var(--text-2); }
.nl-link.sel .wire, .nl-link:focus-visible .wire { stroke: var(--accent); }
.nl-link text { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); paint-order: stroke; stroke: var(--bg-deep); stroke-width: 4px; }

.nl-fx { pointer-events: none; }
.nl-pkt.req { fill: var(--accent); }
.nl-pkt.rep { fill: var(--ok); }
.nl-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .7; animation: nlring .6s var(--ease) forwards; transform-box: fill-box; transform-origin: center; }
@keyframes nlring { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.4); opacity: 0; } }
.nl-fail circle { fill: var(--crit); }
.nl-fail path { stroke: #fff; stroke-width: 2.5; stroke-linecap: round; }

/* Console ---------------------------------------------------------------- */
.nl-console { display: flex; flex-direction: column; overflow: hidden; background: var(--bg-deep); }
.nl-cbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }
.nl-cbar b { font-weight: 500; color: var(--text-2); }
.nl-cdot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.nl-chost { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-log { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; font-family: var(--mono); font-size: 13px; line-height: 1.5; color: #C9D4DE; }
.nl-log > div { white-space: pre-wrap; word-break: break-word; }
.nl-log .echo { color: var(--text); }
.nl-log .ok { color: #6BD47B; }
.nl-log .err { color: #FF8A86; }
.nl-log .win { color: var(--warn); font-weight: 600; }
.nl-log .muted { color: var(--muted); }
.nl-cform { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 13px; }
.nl-prompt { color: #6BD47B; font-weight: 600; white-space: nowrap; }
.nl-cform input { flex: 1; min-width: 0; min-height: 30px; background: transparent; border: 0; color: var(--text); font: inherit; caret-color: var(--accent); }
.nl-cform input:focus-visible { outline: none; }
.nl-cform:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }

/* Inspecteur ------------------------------------------------------------- */
.nl-insp { padding: var(--space-4); overflow-y: auto; display: grid; align-content: start; gap: var(--space-3); }
.nl-ihead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.nl-ihead h2 { font-size: 1.1rem; overflow-wrap: anywhere; }
.nl-ihead span { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.nl-h3 { margin-top: var(--space-2); font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.nl-p { font-size: var(--fs-sm); color: var(--text-2); }
.nl-p.mono, .mono { font-family: var(--mono); }
.nl-help { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.nl-field { display: grid; gap: 4px; font-size: var(--fs-xs); color: var(--muted); }
.nl-field input { min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: 14px var(--mono); }
.nl-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nl-field input[aria-invalid="true"] { border-color: var(--crit); }
.nl-field input:disabled { opacity: .5; }
.nl-err { color: #FF8A86; min-height: 0; }
.nl-err:empty { display: none; }
.nl-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; justify-self: start; }
.nl-segbtn { min-height: 34px; padding: 0 14px; border: 0; background: transparent; color: var(--text-2); font-size: var(--fs-sm); cursor: pointer; }
.nl-segbtn + .nl-segbtn { border-left: 1px solid var(--line-strong); }
.nl-segbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.nl-if { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.nl-ifhead { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); }
.nl-ifhead .up { color: var(--ok); }
.nl-ifhead .down { color: var(--muted); }
.nl-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.nl-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.nl-routes { display: grid; gap: 8px; }
.nl-route { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 34px; gap: 6px; align-items: end; }
.nl-x { width: 34px; height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.nl-x:hover { color: var(--crit); border-color: var(--crit); }
.nl-routes + .nl-mini { justify-self: start; }
.nl-ports { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.nl-ports li { display: flex; gap: 8px; padding: 4px 8px; border-radius: var(--radius-sm); background: var(--bg); font-size: var(--fs-xs); color: var(--muted); overflow: hidden; }
.nl-ports li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-ports li.up { color: var(--text-2); }
.nl-ports li.up b { color: var(--ok); }
.nl-linkto { display: flex; gap: 6px; }
.nl-linkto select { flex: 1; min-width: 0; min-height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: inherit; font-size: var(--fs-sm); padding: 0 8px; }
.nl-iacts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: var(--space-2); }
.nl-btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; }
.nl-btn:hover { background: var(--accent-hover); }
.nl-btn.danger { background: transparent; border-color: var(--crit-line); color: #FF8A86; font-weight: 500; }
.nl-btn.danger:hover { background: var(--crit-soft); border-color: var(--crit); }

/* Missions --------------------------------------------------------------- */
.nl-miss { padding: var(--space-3); overflow-y: auto; display: grid; align-content: start; gap: var(--space-2); }
.nl-mhead { display: flex; justify-content: space-between; align-items: baseline; }
.nl-mhead h2 { font-size: 1rem; }
.nl-mhead span { font-size: var(--fs-sm); color: var(--muted); }
.nl-mbar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.nl-mbar i { display: block; height: 100%; background: var(--ok); transition: width .4s var(--ease); }
.nl-mlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nl-mlist li { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.nl-mlist li.next { border-color: var(--accent); }
.nl-mlist summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: var(--fs-sm); list-style: none; }
.nl-mlist summary::-webkit-details-marker { display: none; }
.nl-mlist .ck { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; }
.nl-mlist .done .ck { background: var(--ok); border-color: var(--ok); }
.nl-mlist .done .ck::after { content: ""; width: 7px; height: 4px; border: solid #06210E; border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.nl-mlist .done b { color: var(--text-2); }
.nl-mlist p { padding: 0 10px 8px 34px; font-size: var(--fs-xs); line-height: 1.5; color: var(--text-2); }
.nl-mlist p.hint { color: var(--muted); }
.nl-won { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--ok-line); border-radius: var(--radius-sm); background: var(--ok-soft); font-size: var(--fs-sm); }
.nl-won b { color: var(--ok); }
.nl-won span { color: var(--text-2); font-size: var(--fs-xs); }
.nl-won .nl-btn { justify-self: start; }

/* Message flottant */
.nl-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 50; max-width: min(520px, calc(100vw - 32px)); padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); color: var(--text); font-size: var(--fs-sm); box-shadow: 0 12px 30px rgba(0, 0, 0, .45); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); }
.nl-toast.show { opacity: 1; transform: translate(-50%, 0); }
.nl-toast.bad { border-color: var(--crit-line); color: #FF8A86; }

/* Tablette : plan et console en largeur, configuration et missions dessous */
@media (max-width: 1099px) {
  .nl-app {
    height: auto; min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto 240px auto;
    grid-template-areas: "tools tools" "stage stage" "cons cons" "insp miss";
  }
  .nl-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .nl-palette { display: flex; flex-wrap: wrap; }
  .nl-tool { min-height: 44px; grid-auto-flow: column; align-items: center; padding: 4px 12px; font-size: var(--fs-sm); }
  .nl-ico { width: 30px; height: 24px; }
  .nl-cable { grid-column: auto; }
  .nl-scroll { aspect-ratio: 1000 / 600; flex: 0 0 auto; }
  .nl-insp, .nl-miss { max-height: 640px; }
}
/* Téléphone : une colonne ; le plan garde une taille lisible et défile. */
@media (max-width: 700px) {
  .nl-app { padding-inline: 8px; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "tools" "stage" "cons" "insp" "miss"; }
  .nl-tools { flex-direction: column; align-items: stretch; padding: 8px; }
  .nl-palette { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .nl-tool { grid-auto-flow: row; justify-items: center; padding: 6px 2px; font-size: 11px; min-height: 56px; }
  .nl-acts { justify-content: flex-end; }
  .nl-scroll { aspect-ratio: auto; height: min(420px, 70vw + 60px); }
  .nl-svg { width: 680px; height: 408px; max-width: none; }
  .nl-console { height: 220px; }
  .nl-insp, .nl-miss { max-height: none; }
}
/* Téléphone en paysage : le plan occupe la hauteur disponible */
@media (max-height: 500px) and (orientation: landscape) {
  .nl-app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "tools tools" "stage cons" "insp miss"; }
  .nl-tools { padding: 6px 8px; }
  .nl-tool { min-height: 38px; }
  .nl-scroll { aspect-ratio: auto; height: calc(var(--vh100) - 120px); min-height: 200px; }
  .nl-svg { width: 640px; height: 384px; max-width: none; }
  .nl-console { height: auto; min-height: 220px; }
}
@media (prefers-reduced-motion: reduce) {
  .nl-ring { animation: none; opacity: 0; }
}
