/* Plain CSS, no framework (SRS §2.4). Dark-only for now (Phase 0 decision,
   not revisited here) — but chart-relevant tokens use the dataviz skill's
   validated DARK palette steps verbatim (references/palette.md), not
   invented colors, since those are the ones load-bearing for CVD-safety. */
:root {
  /* App shell (pre-existing, Phase 0) */
  --bg: #0d0d0d;
  --fg: #ffffff;
  --muted: #898781;

  /* Chart chrome (palette.md "Chart chrome & ink", dark column) */
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);

  /* Categorical series (palette.md, dark column, slots 1-4 — the app only
     ever overlays up to 4 securities today) */
  --series-1: #3987e5; /* blue */
  --series-2: #d95926; /* orange */
  --series-3: #199e70; /* aqua */
  --series-4: #c98500; /* yellow */

  /* Status (palette.md — fixed, never themed, same hex both modes) */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --accent: var(--series-1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 1rem 2rem;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
}

main {
  max-width: 64rem;
  margin: 0 auto;
}

h1 {
  color: var(--accent);
  font-size: 1.25rem;
}

/* ---------------------------------------------------------------- nav */

#app-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

#app-nav .brand {
  color: var(--accent);
  font-weight: 600;
  margin-right: auto;
}

#app-nav button.nav-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 0.3rem;
}

#app-nav button.nav-link[aria-current="page"] {
  color: var(--text-primary);
  background: var(--surface-1);
}

#app-nav button.nav-link:hover {
  color: var(--text-primary);
}

#status {
  font-family: ui-monospace, monospace;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface-1);
}

.panel pre {
  background: #05060a;
  padding: 0.75rem;
  border-radius: 0.25rem;
  overflow-x: auto;
  user-select: all;
}

.panel button,
button.primary {
  background: var(--accent);
  color: #05060a;
  border: none;
  border-radius: 0.25rem;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

.panel button:disabled {
  opacity: 0.5;
  cursor: default;
}

.panel input {
  font: inherit;
  padding: 0.4rem;
  margin-right: 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  background: #05060a;
  color: var(--fg);
}

#auth-message.error {
  color: var(--status-critical);
}

/* -------------------------------------------------------------- views */

[hidden] {
  display: none !important;
}

.view-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--surface-1);
}

.chip input {
  margin: 0;
}

.chip.checked {
  color: var(--text-primary);
  border-color: var(--chip-color, var(--accent));
}

.chip .swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--chip-color, var(--accent));
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--baseline);
}

td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: rgba(255, 255, 255, 0.03);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.status-badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--text-muted);
}

.status-badge.success::before {
  background: var(--status-good);
}

.status-badge.partial::before {
  background: var(--status-warning);
}

.status-badge.failure::before {
  background: var(--status-critical);
}

.status-badge.running::before {
  background: var(--series-1);
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
}

.entity-link {
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.back-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.75rem;
}

.empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}

/* --------------------------------------------------------- learn view */

.chapter {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.chapter:last-of-type {
  border-bottom: none;
}

.chapter summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chapter-num {
  color: var(--text-muted);
  min-width: 1.2rem;
}

.chapter-title {
  flex: 1;
}

.level-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.level-tag.beginner {
  background: rgba(12, 163, 12, 0.15);
  color: #5fd35f;
}

.level-tag.intermediate {
  background: rgba(250, 178, 25, 0.15);
  color: var(--status-warning);
}

.level-tag.advanced {
  background: rgba(208, 59, 59, 0.15);
  color: #ec8080;
}

.chapter-body {
  margin-top: 0.6rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.chapter-body p {
  margin: 0.5rem 0;
}

.in-cresus {
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: rgba(57, 135, 229, 0.08);
  font-size: 0.9rem;
}

.reading-list {
  margin-top: 0.6rem;
}

.reading-list h4 {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.reading-list ul {
  margin: 0;
  padding-left: 1.1rem;
}

.reading-list li {
  margin: 0.3rem 0;
  font-size: 0.9rem;
}

.reading-list .reading-kind {
  color: var(--text-muted);
}

.reading-list .src {
  color: var(--text-muted);
}
