/* ============================================================
   Verilog Crash Course — shared design system
   ============================================================ */

:root {
  --bg: #0d1117;
  --bg-raised: #151b23;
  --bg-card: #1a2129;
  --border: #2a323c;
  --text: #d6dce3;
  --text-dim: #8b98a5;
  --text-faint: #5c6773;
  --accent: #4fd1c5;       /* teal — primary accent */
  --accent-dim: #2ea89c;
  --accent-glow: rgba(79, 209, 197, 0.15);
  --amber: #e3b341;        /* secondary accent — warnings / clock edges */
  --red: #f47067;          /* pitfalls / errors */
  --blue: #6ab0f3;
  --purple: #c297ff;
  --code-bg: #1e1e1e;
  --radius: 10px;
  --maxw: 860px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.65;
  font-size: 17px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.topbar a.home-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar a.home-link .chip {
  color: var(--accent);
}
.topbar .lesson-tag {
  color: var(--text-faint);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* ---- Typography ---- */
h1, h2, h3, h4 { color: #eef2f6; font-weight: 650; line-height: 1.25; }
h1 { font-size: 2rem; margin: 0.2em 0 0.4em; }
h2 { font-size: 1.4rem; margin: 2.2em 0 0.7em; padding-top: 0.2em; border-top: 1px solid var(--border); padding-top: 1.4em; }
h2:first-of-type { border-top: none; padding-top: 0; }
h3 { font-size: 1.1rem; margin: 1.6em 0 0.5em; color: var(--accent); }
p { margin: 0.9em 0; }
a { color: var(--accent); }
a:hover { color: var(--amber); }
ul, ol { padding-left: 1.4em; }
li { margin: 0.4em 0; }
strong { color: #f1f5f9; }
hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 0.6em;
}

.objective {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5em 0 2em;
  font-size: 0.97rem;
}
.objective .label {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.35em;
}

/* ---- Callouts ---- */
.callout {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5em 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.callout .label {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.4em;
}
.callout.note { border-left: 3px solid var(--blue); }
.callout.note .label { color: var(--blue); }
.callout.pitfall { border-left: 3px solid var(--red); }
.callout.pitfall .label { color: var(--red); }
.callout.pitfall .label::before { content: "⚠ "; }
.callout.tip { border-left: 3px solid var(--amber); }
.callout.tip .label { color: var(--amber); }
.callout.compare { border-left: 3px solid var(--purple); }
.callout.compare .label { color: var(--purple); }

/* ---- Code blocks ---- */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 1.2em 0;
}
pre code.hljs { background: transparent; padding: 0; }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(110, 130, 150, 0.14);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
pre code { background: transparent; padding: 0; border-radius: 0; }
.code-caption {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: -0.9em;
  margin-bottom: 1.2em;
}
.code-caption a { color: var(--text-dim); }

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3em 0;
  font-size: 0.92rem;
  overflow-x: auto;
  display: block;
}
table.fit { display: table; }
th, td {
  border: 1px solid var(--border);
  padding: 0.55em 0.8em;
  text-align: left;
}
th { background: var(--bg-raised); color: #eef2f6; font-weight: 650; }
td code { white-space: nowrap; }

/* ---- Two-column compare ---- */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.3em 0;
}
@media (max-width: 640px) {
  .compare-grid { grid-template-columns: 1fr; }
}
.compare-col {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  background: var(--bg-card);
}
.compare-col h4 { margin-top: 0; }
.compare-col.bad { border-color: rgba(244, 112, 103, 0.4); }
.compare-col.bad h4 { color: var(--red); }
.compare-col.good { border-color: rgba(79, 209, 197, 0.4); }
.compare-col.good h4 { color: var(--accent); }

/* ---- Illustration containers ---- */
.illustration {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin: 1.6em 0;
}
.illustration .caption {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.82rem;
  margin-top: 0.8em;
}
.illustration svg text { font-family: var(--font-mono); }

/* ---- Buttons / controls ---- */
button.ctl {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5em 1em;
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
button.ctl:hover { border-color: var(--accent); color: var(--accent); }
button.ctl.active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.ctl-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1em 0; }

/* ---- Quiz widget ---- */
.quiz {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 1.25rem 1.4rem;
  margin: 1.6em 0;
}
.quiz .qtext { font-weight: 600; color: #eef2f6; margin-bottom: 0.9em; }
.quiz .choice {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6em 0.9em;
  border-radius: 7px;
  margin-bottom: 0.55em;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.93rem;
}
.quiz .choice:hover { border-color: var(--text-dim); }
.quiz .choice.correct { border-color: var(--accent); background: var(--accent-glow); color: #eef2f6; }
.quiz .choice.wrong { border-color: var(--red); background: rgba(244, 112, 103, 0.12); color: #eef2f6; }
.quiz .feedback { margin-top: 0.8em; font-size: 0.92rem; padding-top: 0.8em; border-top: 1px dashed var(--border); display: none; }
.quiz .feedback.show { display: block; }
.quiz .feedback.right-fb { color: var(--accent); }
.quiz .feedback.wrong-fb { color: var(--red); }

/* ---- Reveal / accordion ---- */
details.reveal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 0.8rem 1.1rem;
  margin: 1.2em 0;
}
details.reveal summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
details.reveal summary::-webkit-details-marker { display: none; }
details.reveal summary::before { content: "▸ "; }
details.reveal[open] summary::before { content: "▾ "; }
details.reveal .reveal-body { margin-top: 0.8em; }

/* ---- Exercise box ---- */
.exercise {
  border: 1px dashed var(--accent-dim);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin: 1.6em 0;
  background: rgba(79, 209, 197, 0.05);
}
.exercise .label {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.5em;
}

/* ---- Footer nav ---- */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--border);
}
.lesson-nav a {
  flex: 1;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.lesson-nav a:hover { border-color: var(--accent); }
.lesson-nav a.next { text-align: right; }
.lesson-nav .dir { display: block; font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.25em; }
.lesson-nav a.home-nav { flex: 0 0 auto; text-align: center; white-space: nowrap; }
.lesson-nav .nav-spacer { flex: 1; }
@media (max-width: 560px) {
  .lesson-nav { flex-wrap: wrap; }
  .lesson-nav a.home-nav { flex: 1 0 100%; order: 3; }
  .lesson-nav .nav-spacer { display: none; }
}

/* ---- Home page ---- */
.hero {
  padding: 3.5rem 0 2rem;
  text-align: left;
}
.hero .kicker { color: var(--accent); }
.hero h1 { font-size: 2.4rem; }
.hero p.lede { color: var(--text-dim); font-size: 1.1rem; max-width: 640px; }

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 700;
  margin: 2.6em 0 1em;
}

.card-list { display: flex; flex-direction: column; gap: 0.7rem; }
.item-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s, transform 0.15s;
}
.item-card:hover { border-color: var(--accent); transform: translateX(2px); }
.item-card .num {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 700;
  flex: 0 0 auto;
  min-width: 1.6em;
}
.item-card .body h3 { margin: 0 0 0.3em; color: #eef2f6; font-size: 1.02rem; }
.item-card .body p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }
.item-card .kind {
  flex: 0 0 auto;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.2em 0.5em;
  align-self: center;
}

footer.site-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.82rem;
  margin-top: 3rem;
}

@media (max-width: 480px) {
  h1 { font-size: 1.6rem; }
  .hero h1 { font-size: 1.9rem; }
  body { font-size: 16px; }
}
