/* =========================================================================
   Pi IoT Academy — student-facing build guide
   Pi-themed dark UI: red (#c51a4a) and green (#75b343) on a deep slate.
   ========================================================================= */

:root {
  --pi-red: #c51a4a;
  --pi-red-soft: #e25478;
  --pi-green: #75b343;
  --pi-green-soft: #9bd06a;

  --bg: #0d1117;
  --bg-elev-1: #161b22;
  --bg-elev-2: #1f262e;
  --bg-code: #06090d;

  --text: #e6edf3;
  --text-dim: #9aa4b1;
  --text-faint: #6b7480;

  --border: #2a313a;
  --border-strong: #3a424d;

  --warn: #f0b429;
  --warn-bg: rgba(240, 180, 41, 0.08);

  --info: #4ea1ff;
  --info-bg: rgba(78, 161, 255, 0.08);

  --teacher: #b070ff;
  --teacher-bg: rgba(176, 112, 255, 0.08);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, 0.35);

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(197, 26, 74, 0.07) 0%, transparent 35%),
    radial-gradient(circle at 88% 92%, rgba(117, 179, 67, 0.07) 0%, transparent 35%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Subtle PCB-trace dot grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(rgba(154, 164, 177, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

main, header, footer { position: relative; z-index: 1; }

a { color: var(--pi-green-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 2.4rem; margin: 0 0 0.4em; }
h2 { font-size: 1.7rem; margin: 0 0 0.5em; }
h3 { font-size: 1.2rem; margin: 0 0 0.4em; }
p { margin: 0 0 0.9em; }

/* ============================ LAYOUT ============================ */

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================ TOP BAR ============================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 1200px;
  margin: 0 auto;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--pi-red);
  display: grid;
  place-items: center;
  color: white;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 0 0 3px rgba(197, 26, 74, 0.18);
}

.brand-name { font-size: 1.05rem; }
.brand-sub { color: var(--text-dim); font-size: 0.8rem; font-weight: 600; }

.topnav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.topnav a {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.92rem;
}
.topnav a:hover { color: var(--text); text-decoration: none; }
.topnav a.active { color: var(--pi-green-soft); }

.progress-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--text-dim);
}

/* ============================ HERO ============================ */

.hero {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border);
}

.hero h1 .accent { color: var(--pi-red-soft); }
.hero .lede {
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 64ch;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-1);
  color: var(--text-dim);
}
.tag .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pi-green);
}
.tag.tag-difficulty .dot { background: var(--warn); }
.tag.tag-time .dot { background: var(--info); }

/* ============================ PHASE GRID (landing) ============================ */

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 32px 0 56px;
}

.phase-card {
  position: relative;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.phase-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.phase-card.active {
  border-color: var(--pi-green);
  box-shadow: 0 0 0 1px var(--pi-green) inset, var(--shadow-2);
}

.phase-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.phase-card.locked:hover { transform: none; }

.phase-num {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.phase-title {
  font-size: 1.18rem;
  font-weight: 800;
  margin: 4px 0 10px;
  color: var(--text);
}

.phase-desc {
  color: var(--text-dim);
  font-size: 0.94rem;
  flex: 1;
}

.phase-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--pi-green-soft);
}

.phase-card.locked .phase-cta { color: var(--text-faint); }

.phase-card a { color: inherit; text-decoration: none; }
.phase-card a:hover { text-decoration: none; }

.phase-status {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
}
.phase-status.live { background: rgba(117, 179, 67, 0.15); color: var(--pi-green-soft); }
.phase-status.soon { background: rgba(154, 164, 177, 0.1); color: var(--text-faint); }

/* ============================ PHASE PAGE LAYOUT ============================ */

.phase-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 36px;
  margin-top: 32px;
}

@media (max-width: 820px) {
  .phase-layout { grid-template-columns: 1fr; gap: 0; }
  .toc { display: none; }
}

.toc {
  position: sticky;
  top: 96px;
  align-self: start;
  font-size: 0.92rem;
  border-left: 2px solid var(--border);
  padding: 4px 0 4px 14px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li { margin: 6px 0; }

.toc a {
  color: var(--text-dim);
  display: block;
  padding: 4px 0;
}

.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.is-active { color: var(--pi-green-soft); font-weight: 700; }

/* ============================ STEP CARDS ============================ */

.step {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 22px;
  scroll-margin-top: 90px;
}

.step-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

.step-num {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--pi-red);
  color: white;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
}

.step-title-block { flex: 1; min-width: 0; }
.step-title-block h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.step-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.step-body > *:last-child { margin-bottom: 0; }

.step-body ol, .step-body ul {
  padding-left: 22px;
}
.step-body li { margin: 0.3em 0; }

/* ============================ CODE BLOCKS ============================ */

code, .inline-code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--pi-green-soft);
}

.code-block {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 14px 0;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}

.code-block pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover { color: var(--text); border-color: var(--pi-green); }
.copy-btn.copied { color: var(--pi-green-soft); border-color: var(--pi-green); }

/* ============================ CALLOUTS ============================ */

.callout {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 14px 0;
  border: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.callout-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
}

.callout-body { flex: 1; }
.callout-body > *:last-child { margin-bottom: 0; }
.callout-title { font-weight: 800; margin-bottom: 2px; }

.callout.warn { border-color: rgba(240, 180, 41, 0.4); background: var(--warn-bg); }
.callout.warn .callout-icon { background: var(--warn); color: #1a1a1a; }
.callout.warn .callout-title { color: var(--warn); }

.callout.info { border-color: rgba(78, 161, 255, 0.4); background: var(--info-bg); }
.callout.info .callout-icon { background: var(--info); }
.callout.info .callout-title { color: var(--info); }

.callout.teacher { border-color: rgba(176, 112, 255, 0.4); background: var(--teacher-bg); }
.callout.teacher .callout-icon { background: var(--teacher); }
.callout.teacher .callout-title { color: var(--teacher); }

/* ============================ BOM (bill of materials) ============================ */

.bom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0 4px;
}

.bom-item {
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.bom-item-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.bom-item-note {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ============================ CHECKPOINT ============================ */

.checkpoint {
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(117, 179, 67, 0.06);
  border: 1px dashed rgba(117, 179, 67, 0.5);
  border-radius: var(--radius-sm);
}

.checkpoint-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--pi-green-soft);
  margin-bottom: 6px;
}

.checkpoint label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
}

.checkpoint input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-elev-2);
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  margin-top: 1px;
}

.checkpoint input[type="checkbox"]:hover { border-color: var(--pi-green); }
.checkpoint input[type="checkbox"]:checked {
  background: var(--pi-green);
  border-color: var(--pi-green);
}
.checkpoint input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkpoint input[type="checkbox"]:checked + .check-text {
  color: var(--text-faint);
  text-decoration: line-through;
}

/* ============================ FINAL CHECKLIST ============================ */

.final-checklist {
  background: var(--bg-elev-1);
  border: 1px solid var(--pi-green);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin: 32px 0;
}

.final-checklist h3 {
  margin-top: 0;
  color: var(--pi-green-soft);
}

.final-checklist .checkpoint {
  background: transparent;
  border: none;
  padding: 6px 0;
  margin: 0;
}

.final-checklist .checkpoint label { font-size: 1rem; }

/* ============================ NEXT STEP ============================ */

.next-up {
  margin: 36px 0 60px;
  padding: 28px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(197, 26, 74, 0.1), rgba(117, 179, 67, 0.08));
  border: 1px solid var(--border-strong);
}

.next-up h3 {
  margin-top: 0;
  color: var(--pi-red-soft);
}

.next-up .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  background: var(--pi-red);
  color: white;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
}

.next-up .btn:hover { background: var(--pi-red-soft); text-decoration: none; }
.next-up .btn[disabled], .next-up .btn.disabled {
  background: var(--bg-elev-2);
  color: var(--text-faint);
  cursor: not-allowed;
}

/* ============================ FOOTER ============================ */

footer {
  margin-top: 60px;
  padding: 24px 0 36px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.88rem;
}

footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ============================ MOBILE TWEAKS ============================ */

@media (max-width: 600px) {
  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.4rem; }
  .hero { padding: 36px 0 24px; }
  .step { padding: 18px 18px; }
  .step-head { gap: 10px; }
  .step-num { width: 32px; height: 32px; font-size: 0.9rem; }
  .topnav { display: none; }
  .topbar-inner { padding: 12px 16px; }
}
