/* assets/styles.css — AGENT B — global stylesheet.
   Owns :root design tokens, domain colours, [data-theme=dark] overrides,
   the layout grid (sidebar + content), topbar, cards, weight bars, and the
   .c-* component namespace. Does NOT style .q-* (quiz) or .s-* (search) beyond
   the topbar .s-input field, which lives here for layout consistency. */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f7f8fa;
  --fg: #1a1d24;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e3e6eb;
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);

  /* Domain colours */
  --d-indigo: #4f46e5;
  --d-green: #16a34a;
  --d-amber: #d97706;
  --d-blue: #2563eb;
  --d-red: #dc2626;
  --d-slate: #64748b;
  --d-purple: #9333ea;

  --sidebar-w: 288px;
  --topbar-h: 56px;
  --radius: 10px;
  --maxw: 860px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --fg: #e6e8ee;
  --muted: #9aa3b2;
  --card: #171a22;
  --border: #262b36;
  --accent: #818cf8;
  --accent-fg: #0f1117;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);

  --d-indigo: #818cf8;
  --d-green: #4ade80;
  --d-amber: #fbbf24;
  --d-blue: #60a5fa;
  --d-red: #f87171;
  --d-slate: #94a3b8;
  --d-purple: #c084fc;
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 650;
}
h1 {
  font-size: 1.9rem;
  margin: 0 0 0.5rem;
}
h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.6rem;
}
h3 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.4rem;
}
img {
  max-width: 100%;
}

.c-skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius) 0;
}
.c-skip:focus {
  left: 0;
}

/* ---------- Layout grid ---------- */
.c-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.c-main-col {
  min-width: 0; /* allow content (tables/pre) to shrink instead of overflow */
  display: flex;
  flex-direction: column;
}
.c-content {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem 1.5rem 5rem;
}

/* ---------- Sidebar ---------- */
.c-sidebar {
  grid-row: 1;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 0.75rem 0.5rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.c-brand {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem 1rem;
  color: var(--fg);
}
.c-brand:hover {
  text-decoration: none;
}
.c-brand-mark {
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.c-brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.c-nav-domain {
  margin-bottom: 0.15rem;
}
.c-nav-domain-head {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.35rem;
  border-radius: 8px;
}
.c-nav-domain-head:hover {
  background: color-mix(in srgb, var(--fg) 5%, transparent);
}
.c-nav-toggle {
  flex: none;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}
.c-nav-toggle::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 0.8rem;
}
.c-nav-domain.is-open .c-nav-toggle::before {
  transform: rotate(90deg);
}
.c-nav-domain-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  color: var(--fg);
  font-weight: 550;
  font-size: 0.92rem;
  padding: 0.15rem 0;
}
.c-nav-domain-link:hover {
  text-decoration: none;
  color: var(--accent);
}
.c-nav-domain-link.is-active {
  color: var(--accent);
}
.c-nav-domain-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.c-nav-weight {
  flex: none;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
}
.c-nav-weight--x {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.6rem;
}
.c-nav-concepts {
  list-style: none;
  margin: 0.1rem 0 0.4rem;
  padding: 0 0 0 1.55rem;
  border-left: 1px solid var(--border);
  margin-left: 0.7rem;
  display: none;
}
.c-nav-domain.is-open .c-nav-concepts {
  display: block;
}
.c-nav-concept {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.16rem 0.4rem;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-nav-concept:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 5%, transparent);
  text-decoration: none;
}
.c-nav-concept.is-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-weight: 600;
}
.c-nav-concept[data-missing] {
  opacity: 0.5;
  font-style: italic;
}

/* ---------- Topbar ---------- */
.c-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.c-menu-btn {
  display: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.c-search {
  flex: 1;
  max-width: 460px;
  position: relative;
}
.s-input {
  width: 100%;
  height: 36px;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg);
  font-size: 0.9rem;
  outline: none;
}
.s-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.c-topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}
.c-topnav-link {
  color: var(--fg);
  font-weight: 550;
  font-size: 0.9rem;
}
.c-topnav-link.is-active {
  color: var(--accent);
}
.c-progress {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.c-theme-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--fg);
}
.c-theme-toggle:hover {
  border-color: var(--accent);
}
.c-theme-icon::before {
  content: "☀";
  font-size: 1rem;
}
[data-theme="dark"] .c-theme-icon::before {
  content: "☾";
}

/* ---------- Cards ---------- */
.c-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.c-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  color: var(--fg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
a.c-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
}
.c-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.c-card-title {
  font-weight: 650;
  font-size: 1.02rem;
}
.c-card-desc {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.2rem 0 0.6rem;
}

/* ---------- Weight bars ---------- */
.c-weight {
  margin-top: 0.6rem;
}
.c-weight-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.c-weight-bar {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  overflow: hidden;
}
.c-weight-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.c-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.c-badge--muted {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  color: var(--muted);
}

/* ---------- Concept / prose links ---------- */
.c-link {
  color: var(--accent);
  font-weight: 500;
}
.c-stub {
  color: var(--muted);
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}
.c-verify {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--d-amber) 20%, transparent);
  color: var(--d-amber);
  border: 1px solid color-mix(in srgb, var(--d-amber) 40%, transparent);
  white-space: nowrap;
  vertical-align: middle;
}

/* ---------- Page header block ---------- */
.c-page-head {
  margin-bottom: 1.4rem;
}
.c-breadcrumb {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.c-breadcrumb a {
  color: var(--muted);
}
.c-domain-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg);
}
.c-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0.5rem 0;
}

/* ---------- Concept sections & lists ---------- */
.c-section {
  margin-top: 1.4rem;
}
.c-list-plain {
  list-style: none;
  padding: 0;
  margin: 0;
}
.c-hooklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}
.c-hooklist li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
}
.c-hook-title {
  font-weight: 600;
}
.c-hook-text {
  color: var(--muted);
  font-size: 0.88rem;
}
.c-linklist {
  padding-left: 1.2rem;
  margin: 0.3rem 0;
}

/* Backlinks / prev-next */
.c-backlinks {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.c-prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.c-prevnext a {
  max-width: 45%;
}
.c-prevnext .c-pn-dir {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.c-prevnext .c-nx {
  text-align: right;
  margin-left: auto;
}

/* ---------- Buttons ---------- */
.c-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  transition: filter 0.15s ease;
}
.c-btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}
.c-btn--ghost {
  background: transparent;
  color: var(--accent);
}
.c-btn--ghost:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.c-btn[aria-pressed="true"] {
  background: var(--d-green);
  border-color: var(--d-green);
  color: #fff;
}
.c-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.4rem 0;
}

/* ---------- Exam-facts strip ---------- */
.c-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  padding: 0.8rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.2rem 0;
  font-size: 0.9rem;
}
.c-facts b {
  color: var(--fg);
}
.c-facts .c-fact {
  color: var(--muted);
}

/* Point-in-time / verify note box */
.c-note {
  background: color-mix(in srgb, var(--d-amber) 8%, var(--card));
  border: 1px solid color-mix(in srgb, var(--d-amber) 30%, var(--border));
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 1.4rem 0;
  font-size: 0.88rem;
}
.c-note h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}
.c-note ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}
.c-note code {
  font-size: 0.82em;
}

/* Overall-progress placeholder on home */
.c-home-progress {
  margin: 1rem 0 0;
}

/* ---------- Tables ---------- */
.c-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}
.c-content th,
.c-content td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.7rem;
  text-align: left;
}
.c-content th {
  background: color-mix(in srgb, var(--fg) 5%, transparent);
  font-weight: 650;
}

/* ---------- Code ---------- */
.c-content code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}
.c-content pre {
  background: color-mix(in srgb, var(--fg) 5%, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.c-content pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.5;
}
.c-content blockquote {
  margin: 1rem 0;
  padding: 0.4rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---------- Scrim (mobile drawer) ---------- */
.c-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 25;
}

/* ---------- Responsive: sidebar → drawer ---------- */
@media (max-width: 800px) {
  .c-shell {
    grid-template-columns: 1fr;
  }
  .c-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    width: min(84vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.c-nav-open .c-sidebar {
    transform: translateX(0);
  }
  .c-menu-btn {
    display: block;
  }
}
@media (min-width: 801px) {
  .c-scrim {
    display: none !important;
  }
}
