/* ============================================================================
   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);

  /* mono utility face — structure, labels, the cover tree */
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
    Menlo, monospace;

  /* 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 ────────────────────────────────────────────────────────────── */
.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 .6rem; }
.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 (onion tier). 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 tier sub-label beneath a domain — light + thin, tucked right
   under the title it describes */
.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: 0.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: 0.8rem; }

/* page links nested under a phase — the primary, navigable items: brighter than
   the labels, and indented under a faint guide line so the grouping is obvious. */
.sidebar-nav ul ul { 
  /* margin-left: 1.5rem;  */
  padding-left: 0; 
}
/*phase bar*/
.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); }

/* the "tracks" 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; }
/* both CTAs are outline by default; the first one (start reading) is primary */
section.cover .cover-main > p > a {
  border-color: var(--accent);
  color: var(--accent);
}
section.cover .cover-main > p > a:first-child {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* title set like a code comment — these are notes, after all */
section.cover h1 {
  color: var(--heading);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 2.3rem;
  letter-spacing: -0.02em;
}
section.cover blockquote p { color: var(--text-soft); }

/* cover prose — keep paragraphs close together, comfy reading width */
section.cover .cover-main > p {
  max-width: 38rem;
  margin: 0.9rem auto;
  line-height: 1.6;
}

/* the signature: the structure drawn the way you'd sketch it on a whiteboard —
   foundation as the trunk, the three tracks branching off it */
section.cover .cover-tree {
  display: inline-block;
  text-align: left;
  margin: 1.8rem auto;
  padding: 1rem 1.4rem;
  font-family: var(--mono);
  font-size: clamp(0.78rem, 3.2vw, 0.95rem);
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
section.cover .cover-tree .root { color: var(--accent); }
section.cover .cover-tree .b    { color: var(--accent-soft); }
section.cover .cover-tree .lbl  { 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); }
}
