/* btop — the built-in btop++ terminal look.
 *
 * Colors are btop++'s built-in "Default" theme (src/btop_theme.cpp): a black
 * terminal, muted box borders, a dark-red selection, and green-to-red meters.
 * The shell is flattened into a terminal: monospace everywhere, square
 * corners, no glows or gradients on panes, and blocky meter segments. */
:root {
  color-scheme: dark;

  /* btop++ Default palette. Short btop hex values are expanded. */
  --btop-bg: #000000;              /* main_bg (#00 on a black terminal) */
  --btop-fg: #cccccc;              /* main_fg */
  --btop-title: #eeeeee;           /* title */
  --btop-hi: #b54040;              /* hi_fg */
  --btop-selected-bg: #6a2f2f;     /* selected_bg */
  --btop-selected-fg: #eeeeee;     /* selected_fg */
  --btop-inactive: #404040;        /* inactive_fg */
  --btop-graph-text: #606060;      /* graph_text */
  --btop-meter-bg: #404040;        /* meter_bg */
  --btop-misc: #0de756;            /* proc_misc */
  --btop-cpu-box: #556d59;
  --btop-mem-box: #6c6c4b;
  --btop-net-box: #5c588d;
  --btop-proc-box: #805252;
  --btop-div: #303030;             /* div_line */
  --btop-temp-start: #4897d4;
  --btop-temp-mid: #5474e8;
  --btop-temp-end: #ff40b6;
  --btop-cpu-start: #77ca9b;
  --btop-cpu-mid: #cbc06c;
  --btop-cpu-end: #dc4c4c;
  --btop-free-start: #384f21;
  --btop-free-mid: #b5e685;
  --btop-free-end: #dcff85;
  --btop-cached-start: #163350;
  --btop-cached-mid: #74e6fc;
  --btop-cached-end: #26c5ff;
  --btop-available-start: #4e3f0e;
  --btop-available-mid: #ffd77a;
  --btop-available-end: #ffb814;
  --btop-used-start: #592b26;
  --btop-used-mid: #d9626d;
  --btop-used-end: #ff4769;
  --btop-download-start: #291f75;
  --btop-download-mid: #4f43a3;
  --btop-download-end: #b0a9de;
  --btop-upload-start: #620665;
  --btop-upload-mid: #7d4180;
  --btop-upload-end: #dcafde;
  --btop-process-start: #80d0a3;
  --btop-process-mid: #dcd179;
  --btop-process-end: #d45454;

  /* Panes stay black; btop only draws borders and meters. */
  --bg: var(--btop-bg);
  --bg-soft: var(--btop-bg);
  --bg-inset: var(--btop-bg);
  --rail: var(--btop-bg);
  --rail-top: var(--btop-bg);
  --panel: var(--btop-bg);
  --panel-2: #050505;
  --panel2: var(--panel-2);
  --panel-3: #0f0f0f;
  --line: var(--btop-cpu-box);
  --line-soft: var(--btop-div);
  --line-strong: var(--btop-cpu-start);
  --border: var(--line);

  /* btop text ramp: title, body, labels, graph text. */
  --ink: var(--btop-fg);
  --fg: var(--ink);
  --muted: #9a9a9a;
  --muted-2: var(--btop-graph-text);

  /* CPU, memory, and network ramps from the btop meters. */
  --mint: var(--btop-cpu-start);
  --mint-dim: var(--btop-misc);
  --accent: var(--mint);
  --accent-2: var(--btop-cpu-end);
  --green: var(--btop-cpu-start);
  --amber: var(--btop-cpu-mid);
  --amber-2: var(--btop-available-end);
  --red: var(--btop-cpu-end);
  --blue: var(--btop-temp-start);
  --accent-soft: var(--btop-selected-bg);
  --accent-faint: rgba(106, 47, 47, .28);
  --accent-border: var(--btop-cpu-box);
  --accent-ink: var(--btop-bg);
  --badge-ink: var(--btop-bg);
  --accent-glow: transparent;
  --success-border: var(--btop-cpu-start);
  --warn-border: var(--btop-cpu-mid);
  --danger-border: var(--btop-cpu-end);

  /* Controls and states. */
  --input-bg: var(--btop-bg);
  --focus-border: var(--btop-misc);
  --focus-ring: rgba(13, 231, 86, .18);
  --topbar: var(--btop-bg);
  --card-top: var(--btop-bg);
  --card-bottom: var(--btop-bg);
  --inset: transparent;
  --hover: rgba(255, 255, 255, .07);
  --overlay-bg: rgba(0, 0, 0, .78);
  --modal-bg: var(--panel-2);
  --palette-bg: var(--btop-bg);
  --toast-bg: #0a0a0a;
  --onboarding-glow: rgba(119, 202, 155, .05);
  --ambient-a: transparent;
  --ambient-b: transparent;
  --shadow: none;

  /* Terminal geometry: no rounding, one monospace family. */
  --radius: 0;
  --radius-sm: 0;
  --rail-width: 228px;
  --rail-collapsed-width: 64px;
  --font-sans: "JetBrains Mono", "Cascadia Mono", "Berkeley Mono", ui-monospace, SFMono-Regular, Menlo, "DejaVu Sans Mono", monospace;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "Berkeley Mono", ui-monospace, SFMono-Regular, Menlo, "DejaVu Sans Mono", monospace;
  font-family: var(--font-sans);

  caret-color: var(--btop-misc);
}

/* ---------- Terminal chrome ---------- */

/* btop is a flat terminal, not a glass dashboard. */
body {
  background: var(--bg);
  font-family: var(--font-sans);
  font-variant-ligatures: none;
}

h1, h2, h3 {
  color: var(--btop-title);
  letter-spacing: 0;
}

.eyebrow,
.metric-label,
.brand-copy small {
  text-transform: lowercase;
  letter-spacing: .06em;
}

.brand-copy b { letter-spacing: 0; }
.brand-mark { filter: none; }

/* btop's selected row: dark red fill with bright text. */
.nav-item.active,
.settings-tab.active {
  background: var(--btop-selected-bg);
  color: var(--btop-selected-fg);
}

.nav-item.active .nav-glyph { color: var(--btop-selected-fg); }

/* Square controls and panels everywhere the shell hard-codes a radius. */
.card,
.metric,
.chip,
.button,
.icon-button,
.docs-action,
.docs-menu-button,
.rail-toggle,
.mobile-menu-button,
.nav-item,
.page-drag-handle,
.overview-editbar,
.overview-editor,
.overview-resize-handle,
.overview-glyph,
.overview-open,
.overview-pick,
.module-icon,
.perm,
.job,
.peer-card,
.module-settings,
.permission-row,
.config-check,
.empty,
.toast,
.modal-box,
.onboarding-box,
.pick-dir-row,
.status-dot,
.tab-count,
.tab,
input.field,
textarea.field,
select.field {
  /* Module CSS re-declares some radii after theme.css; keep btop square. */
  border-radius: 0 !important;
}

/* btop color-codes its boxes. Cycle the four box borders through card grids. */
.card:nth-of-type(4n + 1),
.metric:nth-of-type(4n + 1),
.overview-card:nth-of-type(4n + 1) {
  --card-line: var(--btop-cpu-box);
  border-color: var(--card-line);
}

.card:nth-of-type(4n + 2),
.metric:nth-of-type(4n + 2),
.overview-card:nth-of-type(4n + 2) {
  --card-line: var(--btop-mem-box);
  border-color: var(--card-line);
}

.card:nth-of-type(4n + 3),
.metric:nth-of-type(4n + 3),
.overview-card:nth-of-type(4n + 3) {
  --card-line: var(--btop-net-box);
  border-color: var(--card-line);
}

.card:nth-of-type(4n + 4),
.metric:nth-of-type(4n + 4),
.overview-card:nth-of-type(4n + 4) {
  --card-line: var(--btop-proc-box);
  border-color: var(--card-line);
}

.card-link:hover,
.overview-card.is-editing,
.overview-card.overview-resizing { border-color: var(--line-strong); }

/* btop embeds box titles in the top border: ────╮ title ╭──── */
.card:has(> .card-title),
.card:has(> .row:first-child > h2),
.card:has(> h2:first-child) {
  position: relative;
  padding-top: 30px;
}

.card > .card-title,
.card > .row:first-child:has(> h2),
.card > h2:first-child,
.overview-card > .overview-card-head {
  position: absolute;
  top: -1px;
  left: 12px;
  right: auto;
  width: fit-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 0 10px;
  border: 0;
  background: var(--bg);
  z-index: 2;
  gap: 6px;
}

/* The caps are drawn with borders instead of font glyphs so the horizontal
 * strokes always meet the card border exactly. */
.card > .card-title::before,
.card > .row:first-child:has(> h2)::before,
.card > h2:first-child::before,
.overview-card > .overview-card-head::before,
.card > .card-title::after,
.card > .row:first-child:has(> h2)::after,
.card > h2:first-child::after,
.overview-card > .overview-card-head::after {
  content: "";
  position: absolute;
  top: 0;
  box-sizing: border-box;
  width: 7px;
  height: 6px;
  margin: 0;
  pointer-events: none;
  border: 0 solid var(--card-line, var(--line));
}

.card > .card-title::before,
.card > .row:first-child:has(> h2)::before,
.card > h2:first-child::before,
.overview-card > .overview-card-head::before {
  left: 0;
  border-top-width: 1px;
  border-right-width: 1px;
  border-top-right-radius: 4px;
}

.card > .card-title::after,
.card > .row:first-child:has(> h2)::after,
.card > h2:first-child::after,
.overview-card > .overview-card-head::after {
  right: 0;
  border-top-width: 1px;
  border-left-width: 1px;
  border-top-left-radius: 4px;
}

.card > .card-title,
.card > .card-title b,
.card > .row:first-child > h2,
.card > h2:first-child,
.overview-card > .overview-card-head .overview-card-name b {
  color: var(--card-line, var(--mint));
}

/* Keep the metric strip's accent colors without inlaying its labels into a
 * border the strip does not draw. */
.metric > .metric-label {
  color: var(--card-line, var(--mint));
}

.card > .row:first-child:has(> h2) > h2 {
  margin: 0;
}

/* Overview cards clip their iframe; keep the legend visible and make room. */
.overview-card:has(> .overview-card-head) {
  position: relative;
  padding-top: 34px;
  /* Keep the bottom border off the grid's fractional edge; without this it
   * can disappear at fractional display scales when the legend is inlaid. */
  padding-bottom: 1px;
  overflow: visible;
}

.overview-card > .overview-card-head { padding: 0 10px; border-bottom: 0; }

/* Settings disclosures are cards too: put their summary on the border. */
details.card:has(> summary) {
  position: relative;
  padding-top: 30px;
}

details.card > summary {
  position: absolute;
  top: -1px;
  left: 12px;
  right: auto;
  width: fit-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 0 10px;
  border: 0;
  background: var(--bg);
  z-index: 2;
  gap: 6px;
  white-space: nowrap;
}

/* Keep the inlaid legend to one line; a wrapped summary is taller than the
 * 30px inset and overlaps the body when the card is open. */
details.card > summary .settings-disclosure-title h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

details.card > summary > :not(.settings-disclosure-title) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 680px) {
  /* The legend has no room for a secondary hint on a phone-width card. */
  details.card > summary > :not(.settings-disclosure-title) { display: none; }
}

details.card > summary::before,
details.card > summary::after {
  content: "";
  position: absolute;
  top: 0;
  box-sizing: border-box;
  width: 7px;
  height: 6px;
  margin: 0;
  pointer-events: none;
  border: 0 solid var(--card-line, var(--line));
}

details.card > summary::before {
  left: 0;
  border-top-width: 1px;
  border-right-width: 1px;
  border-top-right-radius: 4px;
}

details.card > summary::after {
  right: 0;
  border-top-width: 1px;
  border-left-width: 1px;
  border-top-left-radius: 4px;
}

details.card > summary .settings-disclosure-title h2 {
  color: var(--card-line, var(--mint));
}

/* btop meters: blocky segments over the green-yellow-red CPU ramp. */
.bar {
  height: 8px !important;
  background: var(--btop-meter-bg);
  border-radius: 0 !important;
}

.bar i {
  border-radius: 0 !important;
  background:
    repeating-linear-gradient(90deg, transparent 0 6px, var(--btop-bg) 6px 8px),
    linear-gradient(90deg, var(--btop-cpu-start), var(--btop-cpu-mid) 55%, var(--btop-cpu-end)) !important;
}

.bar.amber i {
  background:
    repeating-linear-gradient(90deg, transparent 0 6px, var(--btop-bg) 6px 8px),
    linear-gradient(90deg, var(--btop-available-start), var(--btop-available-mid) 55%, var(--btop-available-end)) !important;
}

/* Square status pixels, not glowing dots. */
.status-dot { box-shadow: none; }
.status-dot.online { box-shadow: none; }

/* Terminal focus rings. */
a:focus-visible,
button:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 1px solid var(--btop-misc);
  outline-offset: 1px;
}

::selection {
  background: var(--btop-selected-bg);
  color: var(--btop-selected-fg);
}

/* Thin square scrollbars. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--btop-cpu-box) var(--btop-bg);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--btop-bg); }
::-webkit-scrollbar-thumb {
  background: var(--btop-div);
  border: 1px solid var(--btop-cpu-box);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: var(--btop-cpu-box); }

/* Website-only polish: the marketing shell loads styles.css after theme.css,
 * so square corners and terminal tracking need to be explicit here. */
* {
  border-radius: 0 !important;
}

h1,
h2,
h3,
.brand-copy b,
.eyebrow,
.lede,
.button {
  letter-spacing: 0 !important;
}

.eyebrow {
  color: var(--btop-cpu-start) !important;
  text-transform: lowercase !important;
}

.card,
.hero-panel,
.build-terminal {
  box-shadow: none !important;
}
