/* lxtrainer.css — single-viewport app layout and panel styling.
   Loaded by app.js; the host page only provides the mount div.
   Deliberately the same visual language as pytrainer.css. */

html, body {
  height: 100%;
  margin: 0;
}

.lx-app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  /* Columns/areas are written inline by app.js (nav 230 | lesson 340 |
     terminal 1fr | inspector 300, with 8px divider columns). */
  grid-template-rows: 1fr;
  gap: 8px;
  padding: 8px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  overflow-anchor: none;
  background: #f2f3f5;
  color: #1d2129;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

/* ---- pane dividers (created by app.js) ---- */

.lx-divider {
  cursor: col-resize;
  touch-action: none;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.lx-divider::after {
  content: "";
  width: 2px;
  border-radius: 1px;
  background: #d5d9de;
}

.lx-divider:hover::after,
.lx-divider.lx-dragging::after {
  background: #7aa7e8;
}

/* ---- panels ---- */

.lx-panel {
  background: #fff;
  border: 1px solid #d5d9de;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.lx-panel h2 {
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5b6470;
  background: #f6f7f8;
  border-bottom: 1px solid #e3e6ea;
  flex: none;
}

/* A− / A+ text-size controls in each panel header (added by app.js). */
.lx-font-controls {
  float: right;
  display: inline-flex;
  gap: 4px;
  margin: -2px 0;
  text-transform: none;
  letter-spacing: normal;
}

.lx-font-controls button {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border: 1px solid #c2c8cf;
  border-radius: 4px;
  background: #fafbfc;
  color: #3c4652;
  cursor: pointer;
}

.lx-font-controls button:hover { background: #eef1f4; }

/* ---- course navigation panel ---- */

.lx-nav-body {
  overflow: auto;
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
}

/* The outline is a browser: expanded/collapsed is a viewing preference,
   independent of which lesson is current. "You are here" is a quiet left
   stripe (.lx-here) carried by the deepest row still visible on the path
   to the current step, so collapsing hands it up rather than losing it. */

.lx-nav-twisty {
  display: inline-block;
  width: 14px;
  flex: none;
  color: #98a2ad;
  font-size: 10px;
  line-height: inherit;
  text-align: center;
  user-select: none;
}

/* The lesson twisty is a real button: its own hit target, so it can
   expand without selecting. */
.lx-nav-twisty-btn {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.lx-nav-twisty-btn:hover { color: #3c4652; }

.lx-nav-twisty-btn:focus-visible {
  outline: 2px solid #7aa7e8;
  outline-offset: 1px;
  border-radius: 3px;
}

.lx-nav-chapter {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 700;
  color: #3c4652;
  margin: 10px 0 2px;
  padding: 3px 6px 3px 2px;
  border-left: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}

.lx-nav-chapter:first-child { margin-top: 0; }
.lx-nav-chapter:hover { background: #eef1f4; }

.lx-nav-chapter:focus-visible {
  outline: 2px solid #7aa7e8;
  outline-offset: -2px;
}

.lx-nav-chapter-title { flex: 1; min-width: 0; }

.lx-nav-count {
  flex: none;
  font-weight: 400;
  font-size: 11px;
  color: #98a2ad;
  font-variant-numeric: tabular-nums;
}

.lx-nav-lessons {
  list-style: none;
  margin: 0 0 4px;
  padding: 0 0 0 8px;
}

.lx-nav-lesson-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 3px 6px 3px 2px;
  border-left: 2px solid transparent;
  border-radius: 4px;
}

.lx-nav-lesson-label {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.lx-nav-lesson-row:hover { background: #f4f6f8; }
.lx-nav-lesson-label:hover { text-decoration: underline; }

.lx-nav-badge {
  flex: none;
  font-size: 11px;
  color: #5b6470;
  font-variant-numeric: tabular-nums;
}

/* Outline numbering (courses that set `numberedOutline`). The digits are a
   column the eye runs down, so they stay quiet and tabular instead of
   thickening the title they sit beside. */
.lx-nav-num {
  margin-right: 0.45em;
  color: #98a2ad;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* Quiet position marker — not a filled block. */
.lx-here {
  border-left-color: #4b8ee0;
  background: #f2f6fc;
}

.lx-nav-steps {
  list-style: none;
  margin: 2px 0 4px;
  padding: 0 0 0 22px;
}

.lx-nav-step {
  padding: 2px 6px;
  border-radius: 4px;
  color: #5b6470;
  cursor: pointer;
}

.lx-nav-step:hover { background: #eef1f4; }

/* The current STEP keeps a real highlight: neither the breadcrumb nor a
   lesson-level marker can say which of the steps you are on. */
.lx-nav-step.lx-current {
  color: #1d2129;
  font-weight: 600;
  background: #eaf1fc;
}

/* Reveal from the breadcrumb: a brief pulse so the eye catches the row. */
@keyframes lx-flash {
  0%, 100% { background: transparent; }
  25%      { background: #ffe9a8; }
}

.lx-flash { animation: lx-flash 1.1s ease-in-out 1; }

@media (prefers-reduced-motion: reduce) {
  .lx-flash { animation-duration: 0.01s; }
}

/* ---- lesson text panel ---- */

/* This panel's header is the path to the current step, with each segment a
   control that re-orients the outline. That needs to be readable and
   clickable, so it drops the uppercase micro-label treatment the other
   panel headers use. */
.lx-lesson-title {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: #3c4652;
}

/* The crumbs live in their own container so that re-rendering the
   breadcrumb cannot remove the font controls beside them. */
.lx-crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.lx-crumb {
  font: inherit;
  color: #2c6cc4;
  background: none;
  border: 0;
  margin: 0;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* When the pane is narrow the chapter gives up room first — the lesson is
   the more useful half of the path to keep readable. */
.lx-crumb { flex: 0 1 auto; min-width: 4ch; }
.lx-crumb:first-of-type { flex-shrink: 4; }

/* This header is a flex container, and `float: right` does nothing to a
   flex item, so the A−/A+ controls have to be pushed to the edge. */
.lx-lesson-title > .lx-font-controls { flex: none; margin-left: auto; }

.lx-crumb:hover { background: #e6eefb; text-decoration: underline; }

.lx-crumb:focus-visible {
  outline: 2px solid #7aa7e8;
  outline-offset: 1px;
}

.lx-crumb-sep { flex: none; color: #98a2ad; }

.lx-lesson-text {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  line-height: 1.5;
}

.lx-lesson-text h1, .lx-lesson-text h2, .lx-lesson-text h3 {
  margin: 0.3em 0 0.5em;
  font-size: 16px;
  /* Beat the panel-h2 chrome styling for headings inside markdown. */
  text-transform: none;
  letter-spacing: 0;
  color: #1d2129;
  background: none;
  border: none;
  padding: 0;
}

.lx-lesson-text p { margin: 0.6em 0; }
.lx-lesson-text ul, .lx-lesson-text ol { margin: 0.5em 0; padding-left: 22px; }

.lx-lesson-text code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #eef1f4;
  padding: 1px 4px;
  border-radius: 3px;
}

.lx-lesson-text pre {
  background: #f4f5f7;
  border: 1px solid #e3e6ea;
  border-radius: 5px;
  padding: 8px 10px;
  overflow-x: auto;
}

.lx-lesson-text pre code {
  background: none;
  padding: 0;
}

.lx-lesson-foot {
  border-top: 1px solid #e3e6ea;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}

.lx-step-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lx-lesson-foot button,
.lx-danger button {
  font: inherit;
  padding: 4px 10px;
  border: 1px solid #c2c8cf;
  border-radius: 5px;
  background: #fafbfc;
  cursor: pointer;
}

.lx-lesson-foot button:hover:not(:disabled),
.lx-danger button:hover:not(:disabled) { background: #eef1f4; }
.lx-lesson-foot button:disabled { opacity: 0.45; cursor: default; }

.lx-step-pos {
  font-size: 12px;
  color: #7a828d;
  white-space: nowrap;
}

.lx-check-btn {
  margin-left: auto;
  background: #2e7d32 !important;
  border-color: #2e7d32 !important;
  color: #fff;
  font-weight: 600;
}

.lx-check-btn:hover:not(:disabled) { background: #256b29 !important; }

.lx-check-result {
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.lx-check-result pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.lx-check-result.lx-pass {
  background: #e6f6e8;
  border: 1px solid #79c284;
  color: #1d6b2a;
}

.lx-check-result.lx-fail {
  background: #fdecea;
  border: 1px solid #f2a49e;
  color: #a8352a;
}

.lx-hint summary {
  cursor: pointer;
  color: #2563eb;
  font-size: 13px;
}

.lx-notice {
  font-size: 12px;
  color: #7a5b12;
  background: #fdf6e3;
  border: 1px solid #ecd9a0;
  border-radius: 5px;
  padding: 6px 8px;
}

.lx-restore-row {
  font-size: 12px;
  color: #7a828d;
}

.lx-restore-confirm { color: #a8352a; }
.lx-restore-confirm button { margin-left: 4px; }

/* ---- terminal panel ---- */

/* Several machines share this pane as tabs: one stack, one visible slot.
   Sizing lives on the slot (not the pane) so a hidden terminal occupies
   no space and the visible one fills the pane exactly. */

.lx-term-stack {
  flex: 1;
  min-height: 0;
  display: flex;
}

.lx-term-slot {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lx-term-slot[hidden] { display: none; }

/* The pane header is the machine name (one machine) or the tab strip
   (several) — either way it drops the uppercase micro-label treatment. */
.lx-term-head { text-transform: none; letter-spacing: 0; font-size: 13px; }

.lx-term-tabs { display: inline-flex; gap: 4px; vertical-align: middle; }

.lx-term-tab {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 3px 10px;
  border: 1px solid #d5d9de;
  border-radius: 5px;
  background: #f0f2f4;
  color: #5b6470;
  cursor: pointer;
}

.lx-term-tab:hover { background: #e6eaee; }

.lx-term-tab.lx-active {
  background: #101014;
  border-color: #101014;
  color: #e8eaed;
  font-weight: 600;
}

.lx-term-tab:focus-visible {
  outline: 2px solid #7aa7e8;
  outline-offset: 1px;
}

.lx-term-mount {
  flex: 1;
  min-height: 0;
  background: #101014;
  padding: 4px;
}

/* xterm fills the mount */
.lx-term-mount .xterm { height: 100%; }

.lx-boot-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(16, 16, 20, 0.92);
  color: #cfd3da;
  z-index: 2;
}

.lx-boot-title { font-size: 16px; }
.lx-boot-progress { font-size: 13px; color: #9aa1ab; }
.lx-boot-failed .lx-boot-progress { color: #ff8a80; white-space: pre-wrap; padding: 0 20px; }

/* ---- inspector panel ---- */

/* Machine picker, above the tabs and only present with two machines: the
   tabs answer "what am I looking at", this answers "on which machine". */
.lx-insp-machines {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  flex: none;
}

.lx-insp-machine {
  font: inherit;
  font-size: 12px;
  flex: 1;
  padding: 3px 8px;
  border: 1px solid #d5d9de;
  border-radius: 5px;
  background: #f6f7f8;
  color: #5b6470;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lx-insp-machine:hover { background: #eef1f4; }

.lx-insp-machine.lx-active {
  background: #eaf1fc;
  border-color: #4b8ee0;
  color: #1d2129;
  font-weight: 600;
}

.lx-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid #e3e6ea;
  flex: none;
}

.lx-tab {
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid #d5d9de;
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  background: #f6f7f8;
  color: #5b6470;
  cursor: pointer;
}

.lx-tab.lx-active {
  background: #fff;
  color: #1d2129;
  font-weight: 600;
  position: relative;
  top: 1px;
}

.lx-insp-scope {
  flex: none;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: #7a828d;
  padding: 4px 10px 0;
}

.lx-insp-body {
  flex: 1;
  overflow: auto;
  padding: 6px 8px;
}

.lx-insp-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.lx-insp-table th {
  text-align: left;
  color: #7a828d;
  font-weight: 600;
  border-bottom: 1px solid #e3e6ea;
  padding: 2px 6px;
  position: sticky;
  top: -6px;
  background: #fff;
}

.lx-insp-table td {
  padding: 2px 6px;
  border-bottom: 1px solid #f1f3f5;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  word-break: break-word;
}

/* The Network tab's widest column is the MAC address, which is a fixed
   17 characters and must not be the one that wraps — the narrow
   inspector of a two-terminal page would otherwise break it across
   three lines while "unknown" sat on one. Let it scroll instead. */
.lx-insp-table.lx-net-table { table-layout: auto; }
.lx-insp-table.lx-net-table td, .lx-insp-table.lx-net-table th {
  white-space: nowrap;
  word-break: normal;
}
.lx-insp-net-scroll { overflow-x: auto; }

.lx-insp-table tr.lx-shared-inode td { background: #fff7d6; }
.lx-insp-table tr.lx-own-tty td { background: #eef6ff; }
.lx-insp-table .lx-dir { font-weight: 600; }
.lx-insp-table .lx-link { color: #2563eb; }
.lx-insp-table .lx-broken { color: #a8352a; font-weight: 600; }

/* Section headings inside a tab body — the Network tab shows three
   tables (interfaces, routes, neighbours) that need naming. */
.lx-insp-heading {
  margin: 10px 2px 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7a828d;
}

.lx-insp-heading:first-child { margin-top: 2px; }

.lx-insp-table tr.lx-if-up td { background: #f3faf4; }
.lx-insp-table .lx-insp-muted { color: #98a2ad; }

.lx-insp-empty, .lx-insp-note {
  font-size: 12px;
  color: #7a828d;
  margin: 6px 2px;
}

.lx-insp-note {
  background: #f4f5f7;
  border: 1px solid #e3e6ea;
  border-radius: 5px;
  padding: 6px 8px;
}

.lx-danger {
  flex: none;
  border-top: 1px solid #e3e6ea;
  padding: 6px 10px;
  font-size: 12px;
  color: #7a828d;
}

.lx-danger summary { cursor: pointer; }
.lx-danger button { display: block; margin: 6px 0; font-size: 12px; }
.lx-danger .lx-wipe-disk { border-color: #f2a49e; color: #a8352a; }
.lx-danger-note { color: #a8352a; }

/* ---- full-mount error card ---- */

.lx-course-error {
  max-width: 640px;
  margin: 12vh auto;
  padding: 20px 24px;
  background: #fff;
  border: 1px solid #f2a49e;
  border-radius: 8px;
  font-family: system-ui, sans-serif;
}

.lx-course-error h2 {
  margin: 0 0 10px;
  color: #a8352a;
  font-size: 18px;
}

.lx-course-error pre {
  background: #fdecea;
  border-radius: 5px;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

.lx-small-screen { border-color: #d5d9de; }
.lx-small-screen h2 { color: #1d2129; }
.lx-small-screen p { line-height: 1.5; color: #3c4652; }
.lx-small-screen button {
  font: inherit;
  padding: 4px 10px;
  border: 1px solid #c2c8cf;
  border-radius: 5px;
  background: #fafbfc;
  cursor: pointer;
}

/* ---- the "cannot run here" panel ---------------------------------------
   Shown in the terminal column when the device cannot drive a shell. The
   lesson itself renders normally beside (or above) it. */
.lx-cannot-run {
  padding: 14px 16px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.5;
  color: #1d2129;
}
.lx-cannot-run h3 { margin: 0 0 10px; font-size: 15px; }
.lx-cannot-run p { margin: 0 0 10px; }
.lx-cannot-run kbd {
  font-family: inherit;
  font-size: 12px;
  padding: 1px 5px;
  border: 1px solid #c9ced6;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f6f7f8;
}
.lx-cannot-run-force button {
  font: inherit;
  padding: 5px 10px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  background: #f6f7f8;
  cursor: pointer;
}
.lx-readonly-note { padding: 12px 14px; font-size: 13px; color: #5b6470; }

/* ---- narrow screens ----------------------------------------------------
   Reading mode is the only way a narrow screen reaches the app at all (a
   device that CAN run the machine is wide), so the columns stack into a
   tower: outline, lesson, then the panel explaining the missing terminal.
   One direction of scrolling only (WCAG 1.4.10 Reflow). */
@media (max-width: 999px) {
  .lx-app {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    overflow-x: hidden;
    overflow-y: visible;
  }
  .lx-divider { display: none; }
  /* Panes carry a named grid-area inline; with the template gone those
     names resolve to lines that do not exist and the grid invents implicit
     columns for them, rebuilding the side-by-side layout. */
  .lx-panel {
    grid-area: auto !important;
    min-width: 0;
  }
  .lx-nav    { order: 1; max-height: 40vh; }
  .lx-lesson { order: 2; }
  .lx-term   { order: 3; }
  .lx-insp   { order: 4; }
}
