/* ============================================================================
   globals.css — the palette source of truth
   One central dark theme. Every page inherits from here; pages add no CSS.
   Loaded after docsify's vue.css, so these rules win.
   ========================================================================== */

:root {
  /* surfaces */
  --bg:        #0d1117;   /* page */
  --bg-soft:   #131923;   /* sidebar / cover */
  --bg-elev:   #1b2230;   /* code, tables, callouts */
  --border:    #243042;

  /* ink */
  --text:      #c4ccd6;
  --text-soft: #8b97a7;
  --heading:   #f0f6fc;

  /* accents */
  --accent:      #5ec8d8;   /* links, theme color */
  --accent-soft: #2b4a52;
  --domain:      #c39bff;   /* sidebar DOMAIN labels */
  --hl:          #ffce7a;   /* <em> colored highlight */

  /* docsify theme hook */
  --theme-color: var(--accent);

  /* responsive sidebar widths */
  --sidebar-w-desktop: 340px;
  --sidebar-w-tablet:  300px;
}

/* ── base ─────────────────────────────────────────────────────────────── */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.markdown-section {
  max-width: 760px;
  color: var(--text);
}

/* ── headings (lowercase, casual — set in the markdown, styled here) ────── */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
  color: var(--heading);
  font-weight: 700;
  line-height: 1.25;
}
.markdown-section h1 { font-size: 2rem; margin: 0 0 1.25rem; }
.markdown-section h2 {
  font-size: 1.45rem;
  margin: 2.4rem 0 1rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.markdown-section h3 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; color: var(--accent); }
.markdown-section h4 { font-size: 1rem;   margin: 1.3rem 0 .5rem; color: var(--text-soft); }

.markdown-section p,
.markdown-section li { line-height: 1.7; }

/* ── em = COLORED HIGHLIGHT (not italics) ───────────────────────────────── */
.markdown-section em {
  color: var(--hl);
  font-style: normal;
  font-weight: 600;
}

/* ── links ──────────────────────────────────────────────────────────────── */
.markdown-section a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}
.markdown-section a:hover { border-bottom-color: var(--accent); }

/* ── code ───────────────────────────────────────────────────────────────── */
.markdown-section code {
  background: var(--bg-elev);
  color: #e6c07b;
  border-radius: 4px;
  padding: .15em .4em;
  font-size: .9em;
}
.markdown-section pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.markdown-section pre > code { background: transparent; color: var(--text); }

/* ── blockquote / callout ───────────────────────────────────────────────── */
.markdown-section blockquote {
  background: var(--bg-elev);
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
  border-radius: 0 6px 6px 0;
  margin: 1.4rem 0;
}

/* ── tables (great for "when to use X vs Y") ────────────────────────────── */
.markdown-section table { display: table; width: 100%; border-collapse: collapse; }
.markdown-section th {
  background: var(--bg-elev);
  color: var(--heading);
  border: 1px solid var(--border);
}
.markdown-section td { border: 1px solid var(--border); }
.markdown-section tr { background: transparent; }
.markdown-section tr:nth-child(2n) { background: rgba(255, 255, 255, .02); }

/* ── sidebar ────────────────────────────────────────────────────────────── */
/* Two-scale onion: top-level <li> = a DOMAIN (a macro-onion layer); nested
   **bold** = an onion PHASE within that domain; links beneath = pages. A
   single-phase domain may list its pages directly with no phase header — the
   phase rules below are simply inert when no phase <strong> is present. */
.sidebar-nav ul { margin: 0; }
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  width: var(--sidebar-w-tablet);
  padding: .5rem;   /* trim vue.css's 40px top gap */
}
.sidebar > h1 { margin: .6rem 0; }
.sidebar > h1 a { color: var(--heading); font-weight: 800; }

.sidebar-nav { padding-bottom: 2rem; line-height: 1; }
.sidebar-nav .app-sub-sidebar { margin-left: 1rem; line-height: 1.2rem; }

/* top-level <li> = a DOMAIN (macro-onion layer). Make it visually distinct. */
.sidebar-nav > ul > li {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  line-height: 1.2rem;
}
.sidebar-nav > ul > li:first-child {
  border-top: none;
  margin-top: .4rem;
  padding-top: 0;
}

.sidebar-nav > ul > li > strong {
  display: block;
  color: var(--domain);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
  font-weight: 800;
}
/* the smaller domain caption — light + thin, tucked right under the title */
.sidebar-nav > ul > li > strong + small,
.sidebar-nav small {
  display: block;
  color: var(--text-soft);
  font-size: .72rem;
  font-weight: 100;
  opacity: .5;
  line-height: 1;
  margin-left: .5rem;
}

/* onion PHASE sub-headers within a domain — a quiet uppercase "eyebrow" label.
   Deliberately NOT link-colored, so it never reads as a clickable page. */
.sidebar-nav > ul > li > ul > li > strong {
  display: block;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: .62rem;
  font-weight: 700;
  opacity: .72;
  margin-top: 1.5rem;
}
.sidebar-nav > ul > li > ul > li:first-child > strong { margin-top: .8rem; }

/* page links — brighter than the labels, and indented under a faint guide line
   (when nested below a phase) so the grouping reads clearly. */
.sidebar-nav ul ul { padding-left: 0; }
.sidebar-nav > ul > li > ul > li > ul {
  padding-left: .8rem;
  margin-left: .15rem;
  border-left: 1px solid var(--border);
}
.sidebar-nav ul ul li a {
  color: var(--text);
  font-size: .92rem;
  padding: 0;
}
.sidebar-nav a:hover { color: var(--accent); }
.sidebar-nav li.active > a,
.sidebar-nav ul ul li.active > a {
  color: var(--accent);
  font-weight: 600;
  border-right: 2px solid var(--accent);
}

/* ── top navbar + its dropdown ──────────────────────────────────────────── */
.app-nav a { color: var(--text-soft); }
.app-nav a.active,
.app-nav a:hover { color: var(--accent); }
.app-nav a.active { border-bottom-color: var(--accent); }

/* dropdown panel (vue.css hardcodes a white background) */
.app-nav li ul {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.app-nav li ul li a { color: var(--text); }
.app-nav li ul li a:hover { color: var(--accent); }

/* ── sidebar toggle (hamburger) ─────────────────────────────────────────── */
/* vue.css pins this bottom-left, 284px wide, white. Move it top-left, size it
   to the icon, and let it float transparently over whatever's behind it. */
.sidebar-toggle,
body.close .sidebar-toggle {
  top: 0;
  bottom: auto;
  left: 0;
  width: auto;
  padding: 14px 16px;
  background: transparent;
  border-right: none;
}
.sidebar-toggle span { background-color: var(--accent); }

/* ── dedicated search page (#notes-search, mounted by the notesSearch plugin) ─ */
#notes-search { margin: 1.4rem 0 2rem; }
#notes-search .ns-input {
  width: 100%;
  box-sizing: border-box;
  padding: .75rem .95rem;
  font-size: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
}
#notes-search .ns-input:focus { outline: none; border-color: var(--accent); }
#notes-search .ns-status { color: var(--text-soft); font-size: .76rem; margin: .55rem .1rem 1rem; }

#notes-search .ns-results { display: flex; flex-direction: column; gap: .55rem; }
#notes-search .ns-result {
  display: block;
  padding: .8rem .95rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}
#notes-search .ns-result:hover { border-color: var(--accent); }

#notes-search .ns-crumb { font-size: .72rem; letter-spacing: .02em; margin-bottom: .3rem; }
#notes-search .ns-domain { color: var(--domain); text-transform: uppercase; font-weight: 800; }
#notes-search .ns-phase { color: var(--accent); }
#notes-search .ns-chapter { color: var(--text); }
#notes-search .ns-sep { color: var(--text-soft); margin: 0 .35rem; }

#notes-search .ns-trail { font-size: .82rem; color: var(--heading); font-weight: 600; margin-bottom: .3rem; }
#notes-search .ns-arrow { color: var(--text-soft); margin: 0 .35rem; font-weight: 400; }

#notes-search .ns-snippet { font-size: .85rem; color: var(--text-soft); line-height: 1.6; }
#notes-search .ns-snippet mark {
  background: var(--accent-soft);
  color: var(--heading);
  border-radius: 3px;
  padding: 0 .15em;
}
#notes-search .ns-empty { color: var(--text-soft); }

/* ── pagination ─────────────────────────────────────────────────────────── */
.docsify-pagination-container {
  border-top: 1px solid var(--border);
  color: var(--text-soft);
}
.pagination-item-title { color: var(--accent); }

/* ── cover page ─────────────────────────────────────────────────────────── */
section.cover { background: var(--bg-soft) !important; }
section.cover .cover-main > p > a {
  border-color: var(--accent);
  color: var(--accent);
}
/* both CTAs are outline by default; the FIRST one (start reading) is primary.
   (vue.css order is [start reading] then [search], so target :first-child.) */
section.cover .cover-main > p > a:first-child {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
section.cover h1 { color: var(--heading); }
section.cover blockquote p { color: var(--text-soft); }

/* ── responsive sidebar ─────────────────────────────────────────────────── */

/* desktop — wider */
@media (min-width: 1200px) {
  .sidebar { width: var(--sidebar-w-desktop); }
  .content { left: var(--sidebar-w-desktop); }
}

/* phones — full-screen drawer. We reuse docsify's own toggle class (`body.close`
   = drawer open on mobile) so the hamburger keeps working; the index.html plugin
   removes `close` on navigation so the drawer auto-closes after you pick a page. */
@media (max-width: 768px) {
  .sidebar { width: 100vw; left: -100vw; }
  body.close .sidebar { transform: translateX(100vw); }
  .content { left: 0; }
  body.close .content { transform: translateX(100vw); }
}

/* ── home page: card grid (used by home.md) ─────────────────────────────────
   A visual index of the chapters. Colors map onto the palette above:
   tier eyebrow = --domain, title = --hl, body = --text-soft. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 2rem 0 1rem;
}
.markdown-section .card {
  display: block;
  padding: 1.3rem 1.45rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.markdown-section .card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .45);
}
.markdown-section .card .tier {
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--domain);
  font-weight: 700;
}
.markdown-section .card h3 { margin: .35rem 0 .5rem; color: var(--hl); font-size: 1.18rem; }
.markdown-section .card p  { margin: 0; color: var(--text-soft); font-size: .92rem; line-height: 1.55; }

/* ── home page: the onion diagram (used by home.md) ─────────────────────────
   Three nested layers — mental model → moving parts → specifics. */
.onion { display: grid; place-items: center; margin: 2.2rem 0; }
.onion .layer {
  display: grid;
  place-items: start center;
  padding-top: 1.1rem;
  border-radius: 50% 50% 14px 14px;
  text-align: center;
  font-weight: 700;
  width: 100%;
}
.onion .l1 {
  max-width: 30rem; padding: 1.3rem 1.3rem 1.6rem;
  background: rgba(195, 155, 255, .10); border: 1px solid rgba(195, 155, 255, .35);
  color: var(--domain);
}
.onion .l2 {
  max-width: 22rem; padding: 1.2rem 1.2rem 1.5rem; margin-top: 1rem;
  background: rgba(94, 200, 216, .10); border: 1px solid rgba(94, 200, 216, .35);
  color: var(--accent);
}
.onion .l3 {
  max-width: 14rem; padding: 1.1rem; margin-top: 1rem;
  background: rgba(255, 206, 122, .12); border: 1px solid rgba(255, 206, 122, .4);
  color: var(--hl);
  border-radius: 50%; aspect-ratio: 1 / 0.7; place-content: center;
}
.onion .layer small {
  display: block; font-weight: 500; font-size: .78rem;
  color: var(--text-soft); margin-top: .25rem;
}
