/* ==========================================================================
   30 Days of DSA in JavaScript — shared stylesheet
   Calm, warm, light theme — JetBrains Mono for headings/code, mobile-first,
   zero dependencies. Reader-friendly: no dark backgrounds, no pure black.
   Colors/fonts/radius live in tokens.css — edit values there, not here.
   ========================================================================== */

@import url('tokens.css');

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
}

body { padding-bottom: 4rem; }

h1, h2, h3, h4, .mono {
  font-family: var(--font-head);
  letter-spacing: -0.01em;
  color: var(--heading);
  font-weight: 700;
}

h1 { font-size: 1.9rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.4rem; margin-top: 2.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.4rem; }
h3 { font-size: 1.1rem; margin-top: 1.5rem; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); text-decoration: none; }

code, pre {
  font-family: var(--font-head);
  font-size: 0.92em;
}

pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
}

/* syntax highlighting — tokens applied by js/engine.js's highlightCode() */
.dsa-hl .tok-keyword { color: var(--c-active); }
.dsa-hl .tok-string { color: var(--c-sorted); }
.dsa-hl .tok-comment { color: var(--text-dim); font-style: italic; }
.dsa-hl .tok-number, .dsa-hl .tok-literal { color: var(--warn); }

p code, li code {
  background: var(--bg-raised);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* focus visibility everywhere (accessibility) */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- layout shell ------------------------------------------ */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header .brand {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--heading);
  text-decoration: none;
  font-size: 1.05rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 0.75rem;
  color: var(--accent-2);
  background: rgba(152, 195, 121, 0.14);
  border: 1px solid rgba(152, 195, 121, 0.4);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  margin-bottom: 0.9rem;
}

/* ---------- buttons -------------------------------------------------- */
.btn {
  font-family: var(--font-head);
  text-decoration: none;
  display: inline-block;
  background: var(--btn-bg);
  color: var(--heading);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #282C34; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-done { background: var(--c-sorted); color: var(--c-sorted-text); border-color: var(--c-sorted); font-weight: 600; }

/* ---------- home page -------------------------------------------- */
.hero { text-align: center; padding: 2rem 1rem 1rem; }
.hero p { color: var(--text-dim); max-width: 640px; margin: 0.5rem auto; }
.hero-tagline { color: var(--accent); font-style: italic; font-weight: 600; }

.progress-bar-wrap {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 22px;
  overflow: hidden;
  max-width: 480px;
  margin: 1rem auto;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-pointer), var(--c-sorted));
  transition: width 0.3s ease;
}
.progress-label { text-align: center; color: var(--text-dim); font-family: var(--font-head); font-size: 0.9rem; }

.continue-row { text-align: center; margin: 1.25rem 0; }

/* ---------- roadmap: week-grouped detail list -------------------- */
.week-section { margin: 1.75rem 0; }

.week-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.week-header h3 {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.week-header .week-num { color: var(--accent); }
.week-header .week-subtitle { color: var(--text-dim); font-weight: 400; font-family: var(--font-body); font-size: 0.88rem; }
.week-progress {
  font-family: var(--font-head);
  color: var(--text-dim);
  font-size: 0.8rem;
  white-space: nowrap;
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.day-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.day-row:hover {
  border-color: var(--accent);
  transform: translateX(3px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.day-row.done { border-color: var(--c-sorted); }

.day-badge {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.day-row.done .day-badge {
  background: var(--c-sorted);
  color: var(--c-sorted-text);
  border-color: var(--c-sorted);
}

.day-info { flex: 1 1 auto; min-width: 0; }
.day-info .day-title {
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-info .day-blurb {
  color: var(--text-dim);
  font-size: 0.83rem;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-head);
  font-size: 0.76rem;
  color: var(--text-dim);
}
.day-row.done .day-status { color: var(--c-sorted); }
.day-status .chevron { color: var(--text-dim); font-size: 1rem; }

@media (max-width: 560px) {
  .day-info .day-blurb { display: none; }
  .day-status .status-text { display: none; }
  .day-row { gap: 0.75rem; padding: 0.6rem 0.85rem; }
}

.how-to-list { display: grid; gap: 0.6rem; }
.how-to-list li { padding-left: 0.2rem; }

/* ---------- lesson chrome ---------------------------------------- */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.lesson-nav a { text-decoration: none; }

.goal-list, .interview-list { padding-left: 1.2rem; }
.goal-list li, .interview-list li { margin-bottom: 0.4rem; }

.complexity-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
}
.complexity-table th, .complexity-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.92rem;
}
.complexity-table th { background: var(--bg-raised-2); font-family: var(--font-head); }

/* ---------- color legend ------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0.75rem 0 1.25rem;
}
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid rgba(255, 255, 255, 0.15); }
.legend .lg-compare { background: var(--c-compare); }
.legend .lg-swap { background: var(--c-swap); }
.legend .lg-sorted { background: var(--c-sorted); }
.legend .lg-pointer { background: var(--c-pointer); }
.legend .lg-neutral { background: var(--c-neutral); }
.legend .lg-active { background: var(--c-active); }

/* ---------- visualizer shell --------------------------------------- */
.viz-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}

.viz-stage {
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.viz-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.85rem;
}

.viz-counter {
  font-family: var(--font-head);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-left: auto;
}

.narration {
  font-family: var(--font-head);
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  margin-top: 0.75rem;
  min-height: 1.4em;
  font-size: 0.92rem;
}

/* generic cell state classes shared by every renderer */
.dsa-cell { transition: background 0.2s, color 0.2s, transform 0.15s; }
.dsa-compare { background: var(--c-compare) !important; color: var(--c-compare-text) !important; }
.dsa-swap { background: var(--c-swap) !important; color: var(--c-swap-text) !important; }
.dsa-sorted { background: var(--c-sorted) !important; color: var(--c-sorted-text) !important; }
.dsa-pointer { background: var(--c-pointer) !important; color: var(--c-pointer-text) !important; }
.dsa-active { background: var(--c-active) !important; color: var(--c-active-text) !important; }

/* bars renderer */
.dsa-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 180px;
  padding: 0 0.5rem;
}
.dsa-bar {
  flex: 1 1 0;
  max-width: 46px;
  min-width: 18px;
  background: var(--c-neutral);
  color: var(--c-neutral-text);
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
}
.dsa-bar-label {
  position: absolute;
  top: -1.4em;
  font-family: var(--font-head);
  font-size: 0.75rem;
  color: var(--text);
}

/* graph renderer */
.dsa-graph-wrap {
  width: 100%;
  overflow-x: auto;
}
.dsa-graph-svg {
  width: 100%;
  height: auto;
  max-height: 340px;
}
.dsa-node-circle { stroke: var(--border); stroke-width: 2; fill: var(--c-neutral); }
/* SVG shapes ignore CSS `background` (used by the div-based renderers above) — a circle
   needs its color set via `fill`, so the shared state classes are re-applied here explicitly. */
.dsa-node-circle.dsa-compare { fill: var(--c-compare) !important; }
.dsa-node-circle.dsa-swap { fill: var(--c-swap) !important; }
.dsa-node-circle.dsa-sorted { fill: var(--c-sorted) !important; }
.dsa-node-circle.dsa-pointer { fill: var(--c-pointer) !important; }
.dsa-node-circle.dsa-active { fill: var(--c-active) !important; }
.dsa-node-circle.dsa-compare ~ .dsa-node-text { fill: var(--c-compare-text) !important; }
.dsa-node-circle.dsa-swap ~ .dsa-node-text { fill: var(--c-swap-text) !important; }
.dsa-node-circle.dsa-sorted ~ .dsa-node-text { fill: var(--c-sorted-text) !important; }
.dsa-node-circle.dsa-pointer ~ .dsa-node-text { fill: var(--c-pointer-text) !important; }
.dsa-node-circle.dsa-active ~ .dsa-node-text { fill: var(--c-active-text) !important; }
.dsa-node-text {
  font-family: var(--font-head);
  font-size: 12px;
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.dsa-edge { stroke: var(--border); stroke-width: 2; }
.dsa-edge-active, .dsa-edge-pointer { stroke: var(--c-pointer); stroke-width: 3; }
.dsa-edge-sorted { stroke: var(--c-sorted); stroke-width: 3; }
.dsa-arrowhead { fill: var(--border); }

/* grid / DP table renderer */
.dsa-grid-wrap { overflow-x: auto; }
.dsa-grid-table { border-collapse: collapse; margin: 0 auto; }
.dsa-grid-table th, .dsa-grid-table td {
  border: 1px solid var(--border);
  min-width: 38px;
  height: 34px;
  text-align: center;
  font-family: var(--font-head);
  font-size: 0.82rem;
}
.dsa-grid-table th { background: var(--bg-raised-2); color: var(--text-dim); font-weight: 500; }
.dsa-grid-cell { background: var(--bg); color: var(--text); }

/* call stack renderer */
.dsa-callstack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.dsa-frame {
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-family: var(--font-head);
  font-size: 0.82rem;
  background: var(--c-neutral);
  color: var(--c-neutral-text);
}
.dsa-frame-empty {
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-head);
  font-size: 0.85rem;
  padding: 0.5rem;
}

/* ---------- svg diagrams ------------------------------------------- */
.diagram {
  width: 100%;
  max-width: 620px;
  display: block;
  margin: 1rem auto;
  height: auto;
}
.diagram text { font-family: var(--font-head); fill: var(--text); }
.diagram .dim { fill: var(--text-dim); }

/* ---------- reveal (hints/solutions) --------------------------------- */
.dsa-reveal-toggle { margin: 0.5rem 0; }
.dsa-reveal-panel {
  background: var(--bg-raised);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin: 0.5rem 0 1.25rem;
}

.problem {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1rem 0;
  background: var(--bg-raised);
}
.problem h4 { margin-top: 0; }
.problem .leetcode-link { font-size: 0.85rem; color: var(--text-dim); }

/* ---------- quiz --------------------------------------------------- */
.dsa-quiz {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  background: var(--bg-raised);
}
.dsa-quiz p.q-text { font-weight: 600; margin-top: 0; }
.dsa-quiz-options { display: grid; gap: 0.5rem; }
.dsa-quiz-option {
  text-align: left;
  font-family: var(--font-body);
}
.dsa-quiz-option.dsa-correct { background: var(--c-sorted) !important; color: var(--c-sorted-text) !important; border-color: var(--c-sorted); }
.dsa-quiz-option.dsa-wrong { background: var(--c-swap) !important; color: var(--c-swap-text) !important; border-color: var(--c-swap); }
.dsa-quiz-feedback { margin-top: 0.6rem; font-size: 0.9rem; }

/* ---------- dry-run table ------------------------------------------- */
.dryrun-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.88rem; }
.dryrun-table th, .dryrun-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: center;
}
.dryrun-table th { background: var(--bg-raised-2); font-family: var(--font-head); }

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

@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  .container, .container-wide { padding: 1rem 0.85rem; }
  .viz-controls { justify-content: center; }
  .viz-counter { margin-left: 0; width: 100%; text-align: center; }
}
