/* ==========================================================================
   AgentPrep — shared styles
   ========================================================================== */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e2e6ef;
  --text: #1a1f2e;
  --text-muted: #5b6478;
  --accent: #5b4cf0;
  --accent-2: #0ea5a4;
  --accent-soft: #ecebff;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --ok: #15803d;
  --ok-soft: #e9f9ef;
  --danger: #b91c1c;
  --code-bg: #0f1424;
  --code-text: #e6e9f2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
  --maxw: 1180px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e17;
    --surface: #121726;
    --surface-2: #1a2033;
    --border: #262d44;
    --text: #e6e9f2;
    --text-muted: #9aa3b8;
    --accent: #8b80ff;
    --accent-2: #2dd4bf;
    --accent-soft: #221f45;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --ok: #4ade80;
    --ok-soft: #10261a;
    --danger: #f87171;
    --code-bg: #0a0d18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  --bg: #0b0e17;
  --surface: #121726;
  --surface-2: #1a2033;
  --border: #262d44;
  --text: #e6e9f2;
  --text-muted: #9aa3b8;
  --accent: #8b80ff;
  --accent-2: #2dd4bf;
  --accent-soft: #221f45;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --ok: #4ade80;
  --ok-soft: #10261a;
  --danger: #f87171;
  --code-bg: #0a0d18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin-top: .2em; }
h2 { font-size: 1.6rem; padding-top: .4em; border-top: 1px solid var(--border); }
h3 { font-size: 1.2rem; }
p, ul, ol { margin: 0 0 1em; }
li { margin: .25em 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: .95rem; display: block; overflow-x: auto; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
kbd { font-family: var(--mono); font-size: .85em; padding: .1em .4em; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: var(--maxw); margin: 0 auto; padding: .7rem 16px;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; color: var(--text); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-text { white-space: nowrap; }
.brand-accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (max-width: 420px) { .brand { font-size: .95rem; gap: .45rem; } }
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: .9rem;
}
.nav-links { display: flex; gap: .2rem; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  color: var(--text-muted); padding: .4rem .7rem; border-radius: 8px; font-size: .93rem; font-weight: 500;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 1rem;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }

@media (max-width: 1200px) {   /* nav collapses earlier than the page layout: brand + 9 links need ~1200px */
  .menu-btn { display: grid; margin-left: auto; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .5rem 16px 1rem; margin: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .65rem .7rem; }
}

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.page { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2.5rem; padding: 2rem 16px 4rem; max-width: var(--maxw); margin: 0 auto; }
.page.no-toc { grid-template-columns: minmax(0, 1fr); }
.toc {
  position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto;
  font-size: .9rem; padding-right: .5rem;
}
.toc summary { cursor: pointer; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary { display: flex; justify-content: space-between; align-items: center; }
.toc summary::after { content: "▾"; font-size: .9rem; transition: transform .15s; }
.toc details:not([open]) summary::after { transform: rotate(-90deg); }
.toc details:not([open]) summary { margin-bottom: 0; }
.toc-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; margin-bottom: .6rem; }
.toc ol, .toc ul { list-style: none; padding: 0; margin: 0; }
.toc a { display: block; padding: .3rem .6rem; border-left: 2px solid var(--border); color: var(--text-muted); }
.toc a:hover { color: var(--text); text-decoration: none; border-left-color: var(--text-muted); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-nested .toc-group { margin-top: .5rem; }
.toc-nested .toc-group > a { font-weight: 700; color: var(--text); border-left-color: transparent; padding-left: 0; }
.toc-nested .toc-group > a.active { color: var(--accent); }
.toc-nested ol ol a { padding-left: .9rem; font-size: .86rem; }
.content { min-width: 0; }
.content > h2:first-of-type { border-top: 0; }

@media (max-width: 900px) {
  .page { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding-top: 1.2rem; }
  .toc { position: static; max-height: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; background: var(--surface); }
}

.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; }
.lead { font-size: 1.15rem; color: var(--text-muted); max-width: 70ch; }

/* ---------- Hero ---------- */
.hero { padding: 4rem 0 2.5rem; text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin-bottom: .4em; }
.hero .grad { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { margin: 0 auto 1.8rem; }
.pill { display: inline-block; padding: .25rem .75rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 600; margin-bottom: 1rem; }
.btn-row { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .7rem 1.2rem; border-radius: 10px;
  font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: .95rem;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem; box-shadow: var(--shadow); color: var(--text); display: block;
}
a.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); transition: .15s; }
.card h3 { margin: .3rem 0 .4rem; font-size: 1.1rem; }
.card p { color: var(--text-muted); margin: 0; font-size: .95rem; }
.card .icon { font-size: 1.6rem; }
.card .meta { font-size: .8rem; color: var(--text-muted); margin-top: .8rem; }
.section { padding: 2.5rem 0; }
.section h2 { border-top: 0; text-align: center; margin-top: 0; }
.section .sub { text-align: center; color: var(--text-muted); margin-bottom: 2rem; }

/* ---------- Callouts ---------- */
.callout { border-radius: 10px; padding: .9rem 1.1rem; margin: 1.2rem 0; border: 1px solid var(--border); background: var(--surface); border-left: 4px solid var(--accent); }
.callout.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.interview { border-left-color: var(--accent-2); }
.callout > strong:first-child { display: block; margin-bottom: .25rem; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }

/* ---------- Code ---------- */
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .12em .35em; border-radius: 5px; }
:not(pre) > code { overflow-wrap: anywhere; }
pre { position: relative; margin: 1rem 0 1.4rem; border-radius: 10px; background: var(--code-bg); border: 1px solid var(--border); overflow: hidden; }
pre code { display: block; padding: 1rem 1.1rem; overflow-x: auto; background: transparent !important; color: var(--code-text); font-size: .85rem; line-height: 1.6; border-radius: 0; }
pre[data-file]::before {
  content: attr(data-file); display: block; padding: .45rem 1rem; font-family: var(--mono); font-size: .78rem;
  color: #9aa3b8; background: rgba(255, 255, 255, .04); border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.copy-btn {
  position: absolute; top: .4rem; right: .5rem; font-size: .75rem; padding: .25rem .55rem; border-radius: 6px;
  background: rgba(255, 255, 255, .08); color: #cfd5e4; border: 1px solid rgba(255, 255, 255, .15); cursor: pointer; opacity: .8;
}
.copy-btn:hover { opacity: 1; background: rgba(255, 255, 255, .16); }

/* ---------- Steps ---------- */
.step { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 1rem; margin: 1.5rem 0; }
.step-num {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--accent); color: #fff; font-size: .95rem;
}
.step-body h3 { margin-top: .3rem; }
.done-toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-muted); cursor: pointer; user-select: none; margin-top: .3rem; }
.done-toggle input { accent-color: var(--ok); width: 16px; height: 16px; }

/* ---------- Diagram ---------- */
.diagram { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 1.2rem 0; overflow-x: auto; }
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
@media (max-width: 600px) { .diagram svg { max-width: none; width: 600px; } }
.diagram svg text { fill: var(--text); font-family: var(--font); }
.diagram .box { fill: var(--surface-2); stroke: var(--border); }
.diagram .box-accent { fill: var(--accent-soft); stroke: var(--accent); }
.diagram .line { stroke: var(--text-muted); fill: none; }
.diagram .muted { fill: var(--text-muted) !important; }
.figcap { text-align: center; font-size: .85rem; color: var(--text-muted); margin-top: .5rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-top: 1rem; flex-wrap: wrap; }
.tab-btn { background: none; border: 0; padding: .6rem 1rem; cursor: pointer; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid transparent; font-size: .95rem; font-family: inherit; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; padding-top: .5rem; }
.tab-panel.active { display: block; }

/* ---------- Progress ---------- */
.progress-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1rem 0 1.5rem; }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; transition: width .3s; }

/* ---------- Roadmap ---------- */
.roadmap { counter-reset: rm; list-style: none; padding: 0; max-width: 820px; margin: 0 auto; }
.roadmap li { position: relative; padding: 0 0 1.4rem 3.2rem; margin: 0; }
.roadmap li::before {
  counter-increment: rm; content: counter(rm); position: absolute; left: 0; top: 0;
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.roadmap li::after { content: ""; position: absolute; left: 1.1rem; top: 2.4rem; bottom: .2rem; width: 2px; background: var(--border); }
.roadmap li:last-child::after { display: none; }
.roadmap h3 { margin: .2rem 0 .2rem; font-size: 1.05rem; }
.roadmap p { color: var(--text-muted); margin: 0; font-size: .95rem; }

/* ---------- Interview ---------- */
.qa-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.qa-toolbar input[type="search"], .qa-toolbar select {
  padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font-size: .95rem; font-family: inherit;
}
.qa-toolbar input[type="search"] { flex: 1 1 260px; min-width: 0; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: .85rem; cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.qa { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6rem; overflow: hidden; }
.qa summary { cursor: pointer; padding: .9rem 1.1rem; display: flex; gap: .7rem; align-items: flex-start; list-style: none; font-weight: 600; }
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before { content: "▸"; color: var(--accent); transition: transform .15s; flex-shrink: 0; }
.qa[open] summary::before { transform: rotate(90deg); }
.qa .q-text { flex: 1; }
.qa .answer { padding: 0 1.1rem 1rem 2.6rem; border-top: 1px solid var(--border); padding-top: .9rem; }
.qa .answer p:last-child { margin-bottom: 0; }
.qa.known { opacity: .65; }
.tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 6px; white-space: nowrap; flex-shrink: 0; }
.tag.easy { background: var(--ok-soft); color: var(--ok); }
.tag.medium { background: var(--warn-soft); color: var(--warn); }
.tag.hard { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tag.cat { background: var(--surface-2); color: var(--text-muted); }
.tag.code { background: var(--accent-soft); color: var(--accent); text-transform: none; font-family: var(--mono); }
.qa .answer pre, .flashcard pre { text-align: left; }
.qa-actions { display: flex; gap: .8rem; margin-top: .8rem; font-size: .85rem; }
.qa-actions label { display: inline-flex; gap: .35rem; align-items: center; cursor: pointer; color: var(--text-muted); }
.qa-count { color: var(--text-muted); font-size: .9rem; }
.flashcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 2rem 1.5rem; min-height: 220px; display: flex; flex-direction: column; justify-content: center; text-align: center;
}
.flashcard .fc-q { font-size: 1.25rem; font-weight: 700; }
.flashcard .fc-a { text-align: left; margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: 1rem; display: none; }
.flashcard.revealed .fc-a { display: block; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 16px; text-align: center; color: var(--text-muted); font-size: .9rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; flex-wrap: wrap; }
.pager a { flex: 1 1 220px; border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1.1rem; background: var(--surface); }
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager small { display: block; color: var(--text-muted); }
.pager .next { text-align: right; }

.compare td:first-child { font-weight: 600; white-space: nowrap; }
.muted { color: var(--text-muted); }
