/* ==========================================================================
   datascience.md — TUI theme
   --------------------------------------------------------------------------
   Palette derived from the Data36 design system, inverted for a terminal:
     brand green        #41905C  -> dimmed accent, borders, secondary text
     brand green hover  #20D181  -> primary terminal green
     brand navy         #1D2448  -> the base the dark neutrals are mixed from
     semantic amber/red #E8A13B / #D9534F  carried over unchanged
   Design-system ethos kept: hairline borders, small radii, no gradients,
   no glass, no heavy effects. Monospace throughout, because it's a terminal.
   ========================================================================== */

:root {
  --bg:          #0B0F1A;
  --bg-panel:    #111726;
  --bg-elev:     #161D2F;
  --bg-hover:    #1A2236;

  --border:      #222B42;
  --border-br:   #2E3A57;

  --fg:          #DDE3EE;
  --fg-dim:      #8A93A8;
  --fg-faint:    #5D6980;

  --green:       #20D181;
  --green-dk:    #41905C;
  --green-glow:  rgba(32, 209, 129, 0.14);
  --amber:       #E8A13B;
  --red:         #D9534F;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono",
          Menlo, Consolas, "Liberation Mono", monospace;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --statusbar-h: 34px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-bottom: calc(var(--statusbar-h) + 8px);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--green); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: currentColor; }

::selection { background: var(--green); color: #04120B; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--border-br);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg-dim);
  white-space: nowrap;
}

.prompt { color: var(--green); font-weight: 700; user-select: none; }
.hl { color: var(--green); }

/* ── layout ────────────────────────────────────────────────────────────── */
.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 48px 20px 60px;
}

/* ── hero ──────────────────────────────────────────────────────────────── */
.hero { margin-bottom: 38px; }

.hero__ascii {
  margin: 0 0 22px;
  font-size: clamp(6px, 1.62vw, 14px);
  line-height: 1.25;
  color: var(--green);
  overflow: hidden;
  white-space: pre;
}

.hero__h1 {
  display: none;
  margin: 0 0 18px;
  font-size: 26px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.5px;
}

.hero__lines p { margin: 0 0 4px; }
.hero__lines .out {
  color: var(--fg-dim);
  padding-left: 16px;
  max-width: 78ch;
}
.hero__lines .line { color: var(--fg); }
.hero__lines .line + .line,
.hero__lines .out + .line { margin-top: 16px; }

.cursor {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  margin-left: 6px;
  background: var(--green);
  vertical-align: text-bottom;
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ── toolbar ───────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }

.tab {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 6px 12px;
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.tab:hover { color: var(--fg); border-color: var(--border-br); }
.tab[aria-selected="true"] {
  color: var(--green);
  border-color: var(--green-dk);
  background: var(--green-glow);
}
.tab__n { color: var(--fg-faint); margin-left: 6px; }
.tab[aria-selected="true"] .tab__n { color: var(--green-dk); }
.tab__key { color: var(--fg-faint); margin-right: 2px; }
.tab[aria-selected="true"] .tab__key { color: var(--green-dk); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
  max-width: 400px;
  padding: 5px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.search:focus-within { border-color: var(--green-dk); }
.search__prompt { color: var(--green); font-size: 12.5px; flex: none; user-select: none; }
.search__input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
}
.search__input::placeholder { color: var(--fg-faint); }
.search__input::-webkit-search-cancel-button { filter: invert(0.6); }
.search__kbd { flex: none; }
.search:focus-within .search__kbd { opacity: 0; }

/* ── listing ───────────────────────────────────────────────────────────── */
.listing {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-panel);
  overflow: hidden;
}

.listing__head,
.row {
  display: grid;
  grid-template-columns: 78px 58px 62px 104px 1fr auto;
  gap: 14px;
  align-items: baseline;
  padding: 9px 16px;
}

.listing__head {
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.rows { margin: 0; padding: 0; list-style: none; outline: none; }

.row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.rows li:last-child .row { border-bottom: 0; }
.row:hover { background: var(--bg-hover); }
.row.is-active {
  background: var(--green-glow);
  box-shadow: inset 3px 0 0 var(--green);
}

.col-mode  { color: var(--fg-faint); font-size: 12px; }
.col-size  { color: var(--amber); font-size: 12px; }
.col-lines { color: var(--fg-faint); font-size: 12px; }
.col-date  { color: var(--fg-faint); font-size: 12px; }

.col-name { min-width: 0; }
.name {
  color: var(--fg);
  font-weight: 500;
  word-break: break-word;
}
.row.is-active .name,
.row:hover .name { color: var(--green); }

.desc {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--fg-dim);
}

.tags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border: 1px solid var(--border-br);
  border-radius: var(--r-sm);
  color: var(--fg-faint);
}

.col-act { display: flex; gap: 6px; align-items: center; flex: none; }

.btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 11px;
  border: 1px solid var(--border-br);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s, background .12s;
}
.btn:hover {
  color: var(--green);
  border-color: var(--green-dk);
  background: var(--green-glow);
}
.btn--primary { color: var(--green); border-color: var(--green-dk); }
.btn--primary:hover { background: var(--green); color: #04120B; border-color: var(--green); }

.empty { padding: 22px 16px; margin: 0; color: var(--fg-dim); }
.linkish {
  background: none; border: 0; padding: 0;
  font-family: var(--mono); font-size: inherit;
  color: var(--green); cursor: pointer;
  border-bottom: 1px solid currentColor;
}

/* ── footer ────────────────────────────────────────────────────────────── */
.foot {
  margin-top: 44px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}
.foot p { margin: 0 0 4px; }
.foot .out { color: var(--fg-dim); padding-left: 16px; max-width: 78ch; }
.foot__cmd { margin-top: 22px; }

.foot__by {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--fg-faint);
}
.foot__motto { color: var(--green-dk); }

/* ── privacy policy (collapsible) ──────────────────────────────────────── */
.policy {
  margin: 6px 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-panel);
  max-width: 84ch;
}

.policy__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.policy__summary::-webkit-details-marker { display: none; }
.policy__summary:hover .policy__label { color: var(--green); }

.policy__chev {
  flex: none;
  color: var(--green);
  transition: transform .15s;
}
.policy[open] .policy__chev { transform: rotate(90deg); }

.policy__label { color: var(--fg); font-weight: 500; }
.policy__tldr { font-size: 11.5px; color: var(--green-dk); }

.policy__body {
  padding: 4px 18px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-dim);
}
.policy__updated {
  margin: 14px 0 18px;
  font-size: 11.5px;
  color: var(--fg-faint);
}
.policy__body h2 {
  margin: 22px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.3px;
}
.policy__body h2::before { content: "## "; color: var(--fg-faint); font-weight: 400; }
.policy__body p { margin: 0 0 10px; line-height: 1.7; }
.policy__body strong { color: var(--fg); font-weight: 700; }
.policy__body ul { margin: 0 0 12px; padding-left: 0; list-style: none; }
.policy__body li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 4px;
  line-height: 1.65;
}
.policy__body li::before {
  content: "-";
  position: absolute;
  left: 4px;
  color: var(--green-dk);
}

/* ── pager overlay ─────────────────────────────────────────────────────── */
.pager {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 9, 16, 0.86);
}
.pager[hidden] { display: none; }

.pager__box {
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  max-height: min(84vh, 900px);
  background: var(--bg-panel);
  border: 1px solid var(--border-br);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.pager__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.pager__badge {
  flex: none;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid var(--green-dk);
}
.pager__name {
  flex: 1;
  min-width: 0;
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager__meta { flex: none; font-size: 12px; color: var(--fg-faint); }
.pager__close {
  flex: none;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 9px;
  background: none;
  border: 1px solid var(--border-br);
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  cursor: pointer;
}
.pager__close:hover { color: var(--red); border-color: var(--red); }

.pager__body {
  flex: 1;
  margin: 0;
  padding: 18px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--fg);
  white-space: pre;
  tab-size: 4;
}
.pager__body::-webkit-scrollbar { width: 10px; height: 10px; }
.pager__body::-webkit-scrollbar-track { background: var(--bg-panel); }
.pager__body::-webkit-scrollbar-thumb {
  background: var(--border-br); border-radius: 5px;
}
.pager__body::-webkit-scrollbar-thumb:hover { background: var(--green-dk); }

.pager__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}
.pager__hint { margin-left: auto; font-size: 11.5px; color: var(--fg-faint); }

/* ── status bar ────────────────────────────────────────────────────────── */
.statusbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--statusbar-h);
  padding: 0 14px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--fg-faint);
}
.statusbar__mode {
  flex: none;
  padding: 2px 9px;
  border-radius: var(--r-sm);
  background: var(--green);
  color: #04120B;
  font-weight: 700;
  letter-spacing: 0.6px;
}
.statusbar__count { flex: none; color: var(--fg-dim); }
.statusbar__keys {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
}

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .listing__head, .row { grid-template-columns: 62px 1fr auto; }
  .col-mode, .col-lines, .col-date { display: none; }
}

@media (max-width: 640px) {
  .hero__ascii { display: none; }
  .hero__h1 { display: block; }
  .statusbar__keys { display: none; }
  .wrap { padding: 24px 14px 50px; }
  .listing__head, .row { grid-template-columns: 1fr auto; gap: 10px; }
  .col-size { display: none; }
  .pager { padding: 0; }
  .pager__box { max-height: 100vh; height: 100vh; border-radius: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .cursor { animation: none; }
}

/* Honour an explicit light-theme preference minimally — this page is
   deliberately a dark terminal, so we only soften the pure black. */
@media print {
  body { background: #fff; color: #000; }
  .statusbar, .toolbar, .pager { display: none; }
}
