/*
  ═══════════════════════════════════════════════════════════
  FILE: command-bible.css
  PURPOSE: Extra styles for the Command Bible (command-bible.html)
           and the Command Builder (command-builder.html).

  It is loaded AFTER style.css, so it reuses the site's colour
  variables (--accent-color, --card-bg …) and only adds what
  these two pages need.

  HOW THIS FILE IS ORGANISED:
    1. Wider page + shared bits (buttons, tags, toolbar)
    2. Command part colours (the coloured "chips")
    3. Bible page: sidebar list + detail panel
    4. Builder page: controls, switches, output panel
    5. Explain table
    6. Phones
  ═══════════════════════════════════════════════════════════
*/

/* ─────────────────────────────────────────────────────────
   1. WIDER PAGE + SHARED BITS
   ───────────────────────────────────────────────────────── */
body.wide main {
  max-width: 1200px;
}

/* Colours for each kind of command part */
:root {
  --part-sudo: #e5484d;
  --part-cmd: #ff6600;
  --part-sub: #e6b422;
  --part-opt: #4aa3ff;
  --part-val: #3fb96b;
  --part-arg: #e0e0e0;
  --part-op: #c084fc;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.btn:hover,
.btn:focus-visible {
  background: var(--accent-color);
  color: #121212;
  text-decoration: none;
}

.btn.solid {
  background: var(--accent-color);
  color: #121212;
}

.btn.solid:hover {
  background: #ff7f2a;
}

.btn.small {
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.lt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}

.tag.root   { background: rgba(229, 72, 77, 0.15); color: var(--danger-color); }
.tag.maybe  { background: rgba(230, 180, 34, 0.15); color: var(--warn-color); }
.tag.info   { background: rgba(74, 163, 255, 0.15); color: var(--info-color); }

/* Search box, selects and text inputs on both pages */
.lt-input,
.lt-select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font: inherit;
  background: var(--card-bg);
  color: var(--text-color);
  border: 2px solid #444;
  border-radius: 6px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}

.lt-input:focus,
.lt-select:focus {
  border-color: var(--accent-color);
}

textarea.lt-input {
  font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
  min-height: 4.5rem;
  resize: vertical;
}

.lt-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.lt-toolbar label,
.lt-field > label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted-text);
  margin-bottom: 0.25rem;
}

/* Copy buttons sit on top-right of code blocks */
.code-wrap {
  position: relative;
}

.code-wrap pre {
  padding-right: 4.5rem;
}

.code-wrap .copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
}

.lt-panel {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.lt-panel h3:first-child {
  margin-top: 0;
}

.lt-muted {
  color: var(--muted-text);
}

/* ─────────────────────────────────────────────────────────
   2. COMMAND PART COLOURS
   <span class="part opt">-l</span> … used in the anatomy
   diagram, the builder output and the explain table.
   ───────────────────────────────────────────────────────── */
.part {
  font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
  border-bottom: 2px solid transparent;
  padding: 0 0.05em;
}

.part.sudo { color: var(--part-sudo); border-color: var(--part-sudo); }
.part.cmd  { color: var(--part-cmd);  border-color: var(--part-cmd); font-weight: 700; }
.part.sub  { color: var(--part-sub);  border-color: var(--part-sub); }
.part.opt  { color: var(--part-opt);  border-color: var(--part-opt); }
.part.val  { color: var(--part-val);  border-color: var(--part-val); }
.part.arg  { color: var(--part-arg);  border-color: #777; }
.part.op   { color: var(--part-op);   border-color: var(--part-op); }
.part.unknown { color: #999; border-bottom: 2px dashed #777; }
.part.missing { opacity: 0.6; font-style: italic; border-bottom-style: dotted; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.85rem;
  color: var(--muted-text);
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.legend li {
  margin: 0;
}

.anatomy {
  font-size: 1.15rem;
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────
   3. BIBLE PAGE
   Left: list of commands grouped by category.
   Right: details of the chosen command (or the overview).
   ───────────────────────────────────────────────────────── */
.bible-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.bible-list {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 0.5rem 0;
}

.bible-list h4 {
  margin: 0.75rem 1rem 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-text);
}

.bible-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bible-list li {
  margin: 0;
}

.bible-list a {
  display: block;
  padding: 0.3rem 1rem;
  color: var(--text-color);
  border-left: 3px solid transparent;
}

.bible-list a:hover {
  background: rgba(255, 102, 0, 0.08);
  text-decoration: none;
}

.bible-list a.active {
  border-left-color: var(--accent-color);
  background: rgba(255, 102, 0, 0.12);
  color: var(--accent-color);
}

.bible-list .cmd-name {
  font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
  font-weight: 600;
}

.bible-list .cmd-title {
  display: block;
  font-size: 0.8rem;
  color: var(--muted-text);
}

.bible-list .overview-link {
  font-weight: 600;
}

.bible-detail h2 {
  margin-top: 0;
}

.bible-detail h2 .cmd-display {
  font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
  color: var(--accent-color);
}

.bible-detail .subtitle {
  color: var(--muted-text);
  font-size: 1.1rem;
  margin: -0.5rem 0 0.5rem;
}

.bible-detail section {
  margin-bottom: 1.75rem;
}

.bible-detail h3 {
  margin-bottom: 0.5rem;
}

.data-table code {
  white-space: nowrap;
}

.only-note {
  display: block;
  font-size: 0.8rem;
  color: var(--muted-text);
}

.example-text {
  color: var(--muted-text);
  margin: -0.25rem 0 0.9rem;
  font-size: 0.95rem;
}

.example-actions {
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.distro-row.is-mine td {
  background: rgba(255, 102, 0, 0.08);
}

.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.related-list li {
  margin: 0;
}

.steps-list li {
  margin-bottom: 0.6rem;
}

/* Mobile-only toggle that shows/hides the command list */
.list-toggle {
  display: none;
}

/* ─────────────────────────────────────────────────────────
   4. BUILDER PAGE
   ───────────────────────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.builder-output {
  position: sticky;
  top: 90px;
}

.lt-field {
  margin-bottom: 1rem;
}

.lt-step {
  display: inline-block;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  border-radius: 50%;
  background: var(--accent-color);
  color: #121212;
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.cmd-summary {
  color: var(--muted-text);
  font-size: 0.95rem;
  margin: 0.5rem 0 0;
}

/* Subcommand choices (apt install, systemctl restart …) */
.choice-list {
  display: grid;
  gap: 0.4rem;
}

.choice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
}

.choice:hover {
  border-color: #555;
}

.choice.on {
  border-color: var(--accent-color);
  background: rgba(255, 102, 0, 0.07);
}

.choice input {
  margin-top: 0.3rem;
  accent-color: var(--accent-color);
}

.choice .choice-name {
  font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
  color: var(--part-sub);
  font-weight: 600;
  margin-right: 0.4rem;
}

.choice .choice-desc {
  display: block;
  font-size: 0.88rem;
  color: var(--muted-text);
}

/* One option row: switch + label + flag + explanation */
.opt-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-color);
}

.opt-row:last-child {
  border-bottom: none;
}

.opt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
}

.opt-head .opt-label {
  font-weight: 600;
}

.opt-head code {
  color: var(--part-opt);
}

.opt-plain {
  grid-column: 2;
  font-size: 0.9rem;
  color: var(--muted-text);
}

.opt-value {
  grid-column: 2;
  margin-top: 0.35rem;
}

.opt-row.on .opt-label {
  color: var(--accent-color);
}

.opt-warn {
  color: var(--warn-color);
  font-size: 0.85rem;
}

/* Toggle switch built from a checkbox */
.switch {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.4rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: #444;
  border-radius: 999px;
  transition: background 0.15s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  left: 0.2rem;
  top: 0.2rem;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.switch input:checked + .slider {
  background: var(--accent-color);
}

.switch input:checked + .slider::before {
  transform: translateX(1.1rem);
}

.switch input:focus-visible + .slider {
  outline: 2px solid var(--info-color);
  outline-offset: 2px;
}

.setting-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.setting-row .opt-plain {
  display: block;
}

.required-mark {
  color: var(--accent-color);
}

/* The built command */
.built-cmd {
  font-size: 1.05rem;
  line-height: 1.9;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.built-cmd .prompt {
  color: #777;
  user-select: none;
}

.sentence {
  font-size: 1.05rem;
  margin: 1rem 0;
}

.sentence code {
  color: var(--part-val);
}

.warn-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.warn-list li {
  border-left: 3px solid var(--warn-color);
  padding: 0.35rem 0.75rem;
  background: rgba(230, 180, 34, 0.08);
  border-radius: 4px;
  font-size: 0.92rem;
}

.copy-status {
  margin-left: 0.5rem;
  color: var(--tip-color);
  font-size: 0.9rem;
}

/* ─────────────────────────────────────────────────────────
   5. EXPLAIN TABLE (part by part breakdown)
   ───────────────────────────────────────────────────────── */
.explain-table td:first-child {
  white-space: nowrap;
  width: 1%;
}

.explain-table td {
  font-size: 0.92rem;
}

.explain-join td {
  background: rgba(192, 132, 252, 0.08);
}

.kind-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  font-family: system-ui, sans-serif;
}

/* Bar pinned to the bottom of the builder on phones (see section 6) */
.mobile-bar {
  display: none;
}

/* ─────────────────────────────────────────────────────────
   6. PHONES AND NARROW WINDOWS
   ───────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-top: 2px solid var(--accent-color);
  }

  .mobile-bar code {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow-x: auto;
    padding: 0.35rem 0.5rem;
  }

  body:has(.mobile-bar) footer {
    padding-bottom: 4.5rem;
  }

  .bible-layout,
  .builder-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .bible-list,
  .builder-output {
    position: static;
    max-height: none;
  }

  .bible-list {
    display: none;
  }

  .bible-list.open {
    display: block;
    max-height: 60vh;
  }

  .list-toggle {
    display: inline-block;
    margin-bottom: 1rem;
  }

  .lt-toolbar {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────────────────
   19. AUTHORIZED-USE NOTE (builder page, security tools)
   The bible page reuses the shared .callout danger styling.
   ───────────────────────────────────────────────────────── */
.legal-note {
  margin-top: 0;
  margin-bottom: 1rem;
}
