/* FSCommandLab — interactive directory command demo cards */

.fs-command-lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 18px;
  margin: 1.5em 0;
}

.fs-command-lab {
  border: none;
  padding: 0;
  background-color: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
  margin: 1.5em 0;
  /* Isolate each card's layout so a click on one card doesn't trigger
     repaint checks against the whole page. We use `layout` only (not
     `layout paint`) — including `paint` clips the row-burst drop-shadow
     at the card's edges, which cuts off the glow visually. */
  contain: layout;
}

.fs-command-lab__row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}
.fs-command-lab__caption {
  flex: 1 1 260px;
  min-width: 0;
  order: 1;
}
.fs-command-lab__caption > .fs-command-lab__desc:first-child { margin-top: 0; }

.fs-command-lab__action {
  flex: 1 1 280px;
  min-width: 0;
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fs-command-lab__action > .fs-command-lab__btn { align-self: flex-end; }

/* ----- Tree wrapper + crossfade slots ----- */
.fs-command-lab__tree {
  position: relative;
  min-height: 40px;
  overflow: visible;
}
.fs-command-lab__tree-slot {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transition: opacity 360ms ease;
  pointer-events: none;
}
.fs-command-lab__tree-slot--active {
  opacity: 1;
  pointer-events: auto;
  position: relative;  /* contributes to wrapper height when wrapper height isn't locked */
}
.fs-command-lab__tree-slot svg { display: block; max-width: 100%; height: auto; }

/* Yellow glow burst on new / changed rows is driven by JS — it writes an
   inline `filter: drop-shadow(...)` on each new row's text + icon shapes
   over ~1 second. Colours mirror git-graph's label-burst; the radius is
   tight and the opacity full so the pop reads as *concentrated* rather
   than hazy, and so it stays inside the SVG bitmap (which matters in
   dark mode where outer filters can clip). */

/* Dark mode: theme the folder-tree natively via CSS variables and drop the
   outer invert/hue-rotate filter that uml-diagram.css would otherwise apply.
   Mirrors the pattern git-graph uses — needed here because the outer invert
   would eat the JS-driven yellow burst drop-shadow. */
html.dark-mode .fs-command-lab .uml-folder-tree-diagram-container {
  --uml-stroke: #7aa0ce;
  --uml-text: #e6edf3;
  --uml-header-fill: #2a3a52;
}
html.dark-mode .fs-command-lab .uml-folder-tree-diagram-container svg {
  filter: none !important;
}

/* When the yellow glow fires on a cd/annotation row, the italic annotation
   text ("← (you are here)", "← submodule @ ...") sits inside a bright halo
   and can get washed out in dark mode. A dark outline painted *behind* the
   fill keeps the letterforms readable regardless of halo intensity.
   Selecting on `font-style="italic"` matches UMLFolderTreeDiagram's
   annotation texts without affecting the row-name text. */
html.dark-mode .fs-command-lab text[font-style="italic"] {
  paint-order: stroke fill;
  stroke: #0d1117;
  stroke-width: 3px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* ----- Terminal output area ----- */
.fs-command-lab__output {
  margin: 0;
  padding: 0 12px;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  background-color: #f8f9fa;
  color: #1f2d3d;
  border: 1px solid #d8dde2;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 240ms ease, max-height 240ms ease, padding 240ms ease;
}
.fs-command-lab__output--visible {
  opacity: 1;
  max-height: 260px;
  padding: 8px 12px;
}
html.dark-mode .fs-command-lab__output {
  background-color: #0d1117;
  color: #e6edf3;
  border: 1px solid #2f3a4a;
}

/* ----- Exit-status badge rendered inside the terminal output area ----- */
.fs-command-lab__exit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 10px;
  margin-top: 2px;
  border-radius: 999px;
  border: 1px solid;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
  white-space: nowrap;
}
.fs-command-lab__exit--ok {
  background-color: #e6f4ea;
  color: #1a7d5a;
  border-color: #b6e0c4;
}
.fs-command-lab__exit--err {
  background-color: #fde8e8;
  color: #b03a2e;
  border-color: #f1948a;
}
html.dark-mode .fs-command-lab__exit--ok {
  background-color: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.3);
}
html.dark-mode .fs-command-lab__exit--err {
  background-color: rgba(241, 148, 138, 0.12);
  color: #f1948a;
  border-color: rgba(241, 148, 138, 0.3);
}
.fs-command-lab__exit-label { opacity: 0.75; font-weight: 500; }
.fs-command-lab__exit-icon { font-size: 11px; line-height: 1; }

/* ----- Print layout: show Before | After side by side ----- */
.fs-command-lab__print-pair { display: none; }

@media print {
  .fs-command-lab { break-inside: avoid; page-break-inside: avoid; }
  .fs-command-lab__btn {
    cursor: default !important;
    box-shadow: none !important;
    align-self: flex-start !important;
    margin: 4px 0 10px !important;
  }
  .fs-command-lab__btn .fs-command-lab__icon { display: none !important; }
  .fs-command-lab__row { display: block !important; }
  .fs-command-lab__caption,
  .fs-command-lab__action { display: block !important; }

  /* Hide interactive tree; show static print pair */
  .fs-command-lab__tree { display: none !important; }

  .fs-command-lab__print-pair {
    display: flex !important;
    flex-direction: row;
    gap: 14px;
    align-items: flex-start;
    margin-top: 8px;
  }
  .fs-command-lab__print-cell {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .fs-command-lab__print-cell::before {
    content: attr(data-state-label);
    display: block;
    font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
    font-size: 10pt;
    font-weight: 700;
    color: #1f2d3d;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .fs-command-lab__print-cell svg { max-width: 100% !important; height: auto !important; }
  .fs-command-lab__output {
    max-height: none !important;
    opacity: 1 !important;
    margin-top: 6px !important;
    padding: 6px 10px !important;
    background-color: #f4f6f8 !important;
    color: #1f2d3d !important;
    border: 1px solid #d8dde2 !important;
    font-size: 8.5pt !important;
  }
}

/* ----- Primary (play) button ----- */
.fs-command-lab__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  background-color: #2774AE;
  color: #ffffff;
  border: 1px solid #2774AE;
  border-radius: 999px;
  padding: 7px 16px 7px 12px;
  cursor: pointer;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.fs-command-lab__btn .fs-command-lab__cmd {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.fs-command-lab__btn .fs-command-lab__icon { flex: 0 0 auto; }

@media (max-width: 520px) {
  .fs-command-lab { padding: 12px 12px 10px; }
  .fs-command-lab__btn {
    font-size: 12.5px;
    padding: 6px 12px 6px 10px;
    border-radius: 14px;
  }
}
.fs-command-lab__btn:hover {
  background-color: #1e5f8d;
  border-color: #1e5f8d;
  box-shadow: 0 2px 6px rgba(39,116,174,0.25);
}
.fs-command-lab__btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.fs-command-lab__btn:focus-visible {
  outline: 2px solid #1e5f8d;
  outline-offset: 2px;
}

.fs-command-lab__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 10px;
  line-height: 1;
}

/* ----- Undo variant ----- */
.fs-command-lab__btn--undo {
  background-color: transparent;
  color: #b03a2e;
  border-color: #b03a2e;
  box-shadow: none;
}
.fs-command-lab__btn--undo:hover {
  background-color: rgba(176,58,46,0.08);
  border-color: #b03a2e;
  box-shadow: 0 2px 6px rgba(176,58,46,0.14);
}
.fs-command-lab__btn--undo .fs-command-lab__icon,
.fs-command-lab__btn--restart .fs-command-lab__icon {
  font-size: 17px;
  width: 18px;
  height: 18px;
}

.fs-command-lab__btn .fs-command-lab__cmd,
.fs-command-lab__btn code.fs-command-lab__cmd {
  background: transparent !important;
  background-color: transparent !important;
  color: inherit;
  padding: 0;
  margin: 0;
  border: none;
  font: inherit;
  box-shadow: none;
}

.fs-command-lab__desc {
  margin: 0;
  color: #000;
  font-size: 1.05em;
  line-height: 1.5;
}
.fs-command-lab__desc > p { margin: 0 0 1em; }
.fs-command-lab__desc > p:last-child { margin-bottom: 0; }

/* ----- Multi-step button group (Back + Forward/Restart) ----- */
.fs-command-lab__btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-end;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
}
.fs-command-lab--multi .fs-command-lab__action > .fs-command-lab__btn-group {
  align-self: flex-end;
}

.fs-command-lab__btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: transparent;
  color: #5a6573;
  border: 1px solid #c4cbd3;
  border-radius: 999px;
  padding: 6px 14px 6px 11px;
  cursor: pointer;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
.fs-command-lab__btn-back:hover:not(:disabled) {
  background-color: #f1f3f5;
  border-color: #9aa6b2;
  color: #1f2d3d;
}
.fs-command-lab__btn-back:focus-visible {
  outline: 2px solid #9aa6b2;
  outline-offset: 2px;
}
.fs-command-lab__btn-back:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.fs-command-lab__btn-back .fs-command-lab__icon { font-size: 11px; }
.fs-command-lab__btn-back-label { font: inherit; }

html.dark-mode .fs-command-lab__btn-back {
  color: #9aa6b2;
  border-color: #3a4556;
}
html.dark-mode .fs-command-lab__btn-back:hover:not(:disabled) {
  background-color: rgba(154,166,178,0.1);
  border-color: #5a6573;
  color: #e6edf3;
}

@media print {
  .fs-command-lab__btn-back { display: none !important; }
}

/* ----- Restart button (multi-step final state) ----- */
.fs-command-lab__btn--restart {
  background-color: transparent;
  color: #1a7d5a;
  border-color: #1a7d5a;
  box-shadow: none;
}
.fs-command-lab__btn--restart:hover {
  background-color: rgba(26,125,90,0.08);
  border-color: #1a7d5a;
  box-shadow: 0 2px 6px rgba(26,125,90,0.14);
}
html.dark-mode .fs-command-lab__btn--restart {
  color: #4ade80;
  border-color: #4ade80;
}
html.dark-mode .fs-command-lab__btn--restart:hover {
  background-color: rgba(74,222,128,0.12);
}

/* ----- Step progress indicator (multi-step) ----- */
.fs-command-lab__step-progress {
  margin-top: 10px;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
  font-size: 11.5px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}
html.dark-mode .fs-command-lab__step-progress { color: #9aa6b2; }

/* ----- Print steps grid (hidden on screen, shown in print) ----- */
.fs-command-lab__print-steps { display: none; }

.fs-command-lab__tree-static svg { max-width: 100%; height: auto; display: block; }

@media print {
  .fs-command-lab--multi > .fs-command-lab__row { display: none !important; }

  .fs-command-lab__print-steps {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 18px;
    margin-top: 8px;
  }

  .fs-command-lab__print-step {
    display: flex;
    flex-direction: column;
    gap: 5px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .fs-command-lab__print-step-label {
    font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace !important;
    font-size: 9pt !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    color: #1f2d3d !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .fs-command-lab__print-step-label--initial {
    color: #5a6573 !important;
  }
  .fs-command-lab__print-step-label code {
    background: transparent !important;
    padding: 0 !important;
    font-size: 9pt !important;
    line-height: 1.25 !important;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700 !important;
    color: #1f2d3d !important;
    font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace !important;
  }

  .fs-command-lab__print-step-desc,
  .fs-command-lab__print-step-desc p {
    font-size: 8pt !important;
    line-height: 1.35 !important;
    color: #374151 !important;
  }
  .fs-command-lab__print-step-desc code {
    font-size: 8pt !important;
    padding: 0 2px !important;
    font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace !important;
  }
  .fs-command-lab__print-step-desc p { margin: 0 0 3px; }
  .fs-command-lab__print-step-desc p:last-child { margin-bottom: 0; }

  .fs-command-lab__tree-static svg { max-width: 100% !important; height: auto !important; }
  .fs-command-lab__step-progress { display: none !important; }
}

/* ----- Dark mode ----- */
html.dark-mode .fs-command-lab {
  border-color: #2f3a4a;
  color: #e6edf3;
}
html.dark-mode .fs-command-lab__desc { color: #fff; }
html.dark-mode .fs-command-lab__btn {
  background-color: transparent;
  color: #4a9fd9;
  border-color: #4a9fd9;
}
html.dark-mode .fs-command-lab__btn:hover {
  background-color: rgba(74,159,217,0.12);
  border-color: #66b1e3;
  color: #66b1e3;
}
html.dark-mode .fs-command-lab__btn--undo {
  background-color: transparent;
  color: #f1948a;
  border-color: #f1948a;
}
html.dark-mode .fs-command-lab__btn--undo:hover {
  background-color: rgba(241,148,138,0.12);
  border-color: #f1948a;
}

/* ----- Modal (popup) presentation ----- */

.fs-command-lab-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.55);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fcl-modal-fade 140ms ease-out;
}

.fs-command-lab-modal {
  background-color: #ffffff;
  color: #1f2d3d;
  border-radius: 10px;
  padding: 28px 28px 20px;
  position: relative;
  max-width: min(720px, 96vw);
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
html.dark-mode .fs-command-lab-modal { background-color: #1c2533; color: #e6edf3; }

.fs-command-lab-modal .fs-command-lab {
  border: none;
  padding: 0;
  background-color: transparent;
}

.fs-command-lab-modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #5a6573;
  padding: 4px 8px;
  border-radius: 4px;
}
.fs-command-lab-modal__close:hover { background-color: #f1f3f5; color: #1f2d3d; }
html.dark-mode .fs-command-lab-modal__close { color: #9aa6b2; }
html.dark-mode .fs-command-lab-modal__close:hover { background-color: #2a323e; color: #e6edf3; }

@keyframes fcl-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Respect the OS-level "reduce motion" preference: stop crossfades, the
   row-burst flash on new tree rows, the modal fade-in, output-box
   transitions, and button hover animations. Static colours and the
   instant state swap still convey what changed. The JS-driven row-burst
   and output-burst also check this preference themselves (see the
   window.matchMedia calls in fs-command-lab.js). */
@media (prefers-reduced-motion: reduce) {
  .fs-command-lab__tree-slot { transition: none !important; }
  .fs-command-lab__output,
  .fs-command-lab__btn,
  .fs-command-lab__btn-back { transition: none !important; }
  .fs-command-lab-modal-overlay { animation: none !important; }
}
