/* Java Flowchart Study Kit — shared styles (no external dependencies) */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efeee8;
  --ink: #1b1d21;
  --muted: #5a6068;
  --line: #d8d6cf;
  --accent: #b4461f;
  --accent-soft: #f8e4da;
  --ok: #1d7a3a;
  --ok-soft: #dff3e5;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --t-fill: #dde9f8;
  --p-fill: #fff0c7;
  --d-fill: #f9dce6;
  --io-fill: #d9f0de;
  --c-fill: #ebe2f7;
  --code-bg: #1f2228;
  --code-ink: #e8e6e3;
  --code-cmt: #8d96a3;
  --radius: 12px;
  --maxw: 1000px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --surface: #1d2025;
    --surface-2: #262a31;
    --ink: #e9e7e2;
    --muted: #a0a6ae;
    --line: #353a42;
    --accent: #f08a5d;
    --accent-soft: #3a2a22;
    --ok: #5cc27d;
    --ok-soft: #1c3325;
    --bad: #f0776d;
    --bad-soft: #3b2220;
    --t-fill: #203247;
    --p-fill: #3d3418;
    --d-fill: #43222e;
    --io-fill: #1d3a26;
    --c-fill: #31274a;
    --code-bg: #0f1114;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
}
a { color: var(--accent); }
img, svg { max-width: 100%; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- header / nav ---------- */
header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.site .wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { width: 26px; height: 26px; }
nav.main { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
nav.main a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}
nav.main a:hover { background: var(--surface-2); color: var(--ink); }
nav.main a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

main { padding: 36px 0 72px; }

footer.site {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  padding: 24px 0 40px;
}

/* ---------- type ---------- */
h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.015em; }
h2 { font-size: 25px; line-height: 1.25; margin: 56px 0 12px; letter-spacing: -0.01em; scroll-margin-top: 80px; }
h3 { font-size: 18px; margin: 30px 0 8px; scroll-margin-top: 80px; }
p { margin: 0 0 14px; }
.lead { font-size: 18px; color: var(--muted); max-width: 62ch; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- layout pieces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card > :last-child { margin-bottom: 0; }
.card h3 { margin-top: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.pair { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.trio { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
@media (max-width: 800px) {
  .pair, .trio { grid-template-columns: minmax(0, 1fr); }
}
.stack > * + * { margin-top: 12px; }

.note {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  margin: 16px 0;
}
.note > :last-child { margin-bottom: 0; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; margin-bottom: 12px; }
.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: 600 15px var(--font);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- code ---------- */
pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  font: 14px/1.55 var(--mono);
  margin: 0;
  tab-size: 4;
}
pre .c { color: var(--code-cmt); font-style: italic; }
code { font-family: var(--mono); font-size: 0.92em; }
/* show Java operators exactly as typed (no >= → ≥ ligatures) */
pre, code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
:not(pre) > code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-2); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.shape-cell { width: 130px; }
td.shape-cell svg { width: 110px; height: 56px; display: block; }

/* ---------- flowchart SVG ---------- */
.fc { width: 100%; height: auto; display: block; margin: 0 auto; }
.fc text { font: 13px var(--font); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.fc .shape { stroke: var(--ink); stroke-width: 1.5; transition: fill .2s, stroke .2s; }
.fc .t { fill: var(--t-fill); }
.fc .p { fill: var(--p-fill); }
.fc .d { fill: var(--d-fill); }
.fc .io { fill: var(--io-fill); }
.fc .cn { fill: var(--c-fill); }
.fc .flow { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.fc .arrow { marker-end: url(#arrow); }
.fc .lbl { font-size: 12px; font-weight: 700; fill: var(--muted); }
.fc g.active .shape { stroke: var(--accent); stroke-width: 3.5; }
.fc g.active text { font-weight: 700; }
.arrowhead { fill: var(--ink); }
figure.chart { margin: 0; }
figure.chart .card { padding: 16px; }
figcaption { font-size: 14px; color: var(--muted); text-align: center; margin-top: 8px; }

/* ---------- legend chips ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--ink); display: inline-block; }

/* ---------- lessons TOC ---------- */
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.toc a {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
}
.toc a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- tracer ---------- */
.tracer { margin-top: 16px; }
.tracer-state { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; margin-top: 12px; }
.tracer-state b { font-family: var(--mono); }
.tracer-msg { margin: 10px 0 0; min-height: 3.2em; color: var(--muted); }

/* ---------- quiz ---------- */
.topic-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 24px; }
.topic {
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.topic:hover { border-color: var(--accent); }
.topic strong { font-size: 17px; }
.topic .meta { font-size: 13px; color: var(--muted); }
.topic .best { font-size: 13px; font-weight: 600; color: var(--ok); }

.quiz-box { max-width: 720px; margin: 0 auto; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 20px; }
.progress > div { height: 100%; background: var(--accent); transition: width .25s; }
.q-head { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.q-text { font-size: 19px; font-weight: 600; margin: 0 0 14px; line-height: 1.45; }
.q-code { margin-bottom: 16px; }
.choices { display: grid; gap: 10px; }
.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice .key {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.choice code { white-space: pre-wrap; }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 10px; }
.feedback.ok { background: var(--ok-soft); border: 1px solid var(--ok); }
.feedback.no { background: var(--bad-soft); border: 1px solid var(--bad); }
.feedback strong { display: block; margin-bottom: 4px; }
.score-big { font-size: 56px; font-weight: 800; line-height: 1; margin: 8px 0; }
.review { margin-top: 24px; }
.review .card { margin-bottom: 12px; }
.review .ans { color: var(--ok); font-weight: 600; }
.review .yours { color: var(--bad); font-weight: 600; }
.kbd-hint { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---------- downloads ---------- */
.dl { display: flex; gap: 14px; align-items: flex-start; }
.dl .ico {
  flex: none;
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font: 700 12px var(--mono);
}
.dl h3 { margin: 0 0 4px; font-size: 17px; }
.dl p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.dl .links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 15px; font-weight: 600; }

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
