@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600&family=Newsreader:opsz,wght@6..72,400;6..72,500&display=swap');

/* ============================================================
   AA — Algorithm Analysis for Absolute Beginners
   Shared stylesheet. Dark by default, warm-cream light theme.
   ============================================================ */

:root {
  --bg:            #0b0d13;
  --bg-soft:       #11141c;
  --surface:       rgba(255, 255, 255, 0.025);
  --surface-2:     rgba(255, 255, 255, 0.05);
  --border:        rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text:          #dfe1ea;
  --heading:       #ffffff;
  --muted:         #868a9c;
  --accent:        #ffd475;   /* stellar gold  */
  --accent-soft:   rgba(255, 212, 117, 0.10);
  --blue:          #6fb2ff;
  --blue-soft:     rgba(111, 178, 255, 0.10);
  --green:         #57d38c;
  --green-soft:    rgba(87, 211, 140, 0.10);
  --red:           #ff8a8a;
  --red-soft:      rgba(255, 138, 138, 0.10);
  --code-bg:       #0f131c;
  --header-bg:     rgba(11, 13, 19, 0.88);

  --font-display: "Playfair Display", Georgia, serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 14px;
  --measure: 68ch;
}

[data-theme="light"] {
  --bg:            #f5f0e8;
  --bg-soft:       #efe9df;
  --surface:       rgba(0, 0, 0, 0.028);
  --surface-2:     rgba(0, 0, 0, 0.055);
  --border:        rgba(0, 0, 0, 0.11);
  --border-strong: rgba(0, 0, 0, 0.2);
  --text:          #3d3929;
  --heading:       #1a1710;
  --muted:         #7d7462;
  --accent:        #b06d10;
  --accent-soft:   rgba(176, 109, 16, 0.10);
  --blue:          #2b6cb0;
  --blue-soft:     rgba(43, 108, 176, 0.09);
  --green:         #16763a;
  --green-soft:    rgba(22, 118, 58, 0.09);
  --red:           #b3261e;
  --red-soft:      rgba(179, 38, 30, 0.08);
  --code-bg:       #ece5d9;
  --header-bg:     rgba(245, 240, 232, 0.9);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 1.02rem;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2.4rem);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-family: var(--font-mono);
  font-size: .82rem; letter-spacing: .5px;
  color: var(--accent); text-decoration: none; white-space: nowrap;
}
.brand span { color: var(--muted); }
.header-nav { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.hlink {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--muted); text-decoration: none;
  padding: .3rem .7rem; border: 1px solid var(--border);
  border-radius: 20px; transition: all .18s ease; background: none; cursor: pointer;
}
.hlink:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }

/* ---------- layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.4rem) 5rem; }
.lesson { max-width: var(--measure); }
section { margin-top: 3.2rem; }
section:first-of-type { margin-top: 2rem; }

/* ---------- hero ---------- */
.hero { padding: 3rem 0 1.2rem; border-bottom: 1px solid var(--border); }
.eyebrow {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--accent); margin-bottom: .9rem;
}
h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.12;
  color: var(--heading); letter-spacing: -.5px;
}
.lede { font-size: 1.12rem; color: var(--muted); margin-top: 1rem; max-width: var(--measure); }
.hero-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.4rem; }
.chip {
  font-family: var(--font-mono); font-size: .68rem;
  padding: .25rem .7rem; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.chip.gold  { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.chip.blue  { color: var(--blue);   border-color: var(--blue);   background: var(--blue-soft); }
.chip.green { color: var(--green);  border-color: var(--green);  background: var(--green-soft); }

h2 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.4rem, 3.4vw, 1.95rem);
  color: var(--heading); margin-bottom: .9rem; letter-spacing: -.2px;
}
h2 .num { font-family: var(--font-mono); font-size: .75rem; color: var(--accent); margin-right: .6rem; vertical-align: middle; }
h3 { font-family: var(--font-body); font-weight: 500; font-size: 1.12rem; color: var(--heading); margin: 1.8rem 0 .6rem; }
p { margin-bottom: 1rem; max-width: var(--measure); }
strong { font-weight: 500; color: var(--heading); }
em { font-style: italic; }
a { color: var(--blue); text-underline-offset: 3px; }

ul, ol { margin: 0 0 1.1rem 1.3rem; max-width: var(--measure); }
li { margin-bottom: .45rem; }
li::marker { color: var(--accent); }

/* ---------- inline code + blocks ---------- */
code {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .08em .38em; border-radius: 5px; color: var(--accent);
}
.code {
  position: relative; margin: 1.2rem 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--code-bg); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .9rem; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: .68rem; color: var(--muted);
  background: var(--surface);
}
.code-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.copy-btn {
  margin-left: auto; font-family: var(--font-mono); font-size: .66rem;
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: .15rem .55rem; border-radius: 14px; cursor: pointer; transition: all .15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.copy-btn.done { color: var(--green); border-color: var(--green); }
.code pre { margin: 0; padding: .95rem 1.1rem; overflow-x: auto; }
.code code {
  background: none; border: none; padding: 0; color: var(--text);
  font-size: .84rem; line-height: 1.65; white-space: pre;
}
.code .c { color: var(--muted); font-style: italic; }   /* comment  */
.code .k { color: var(--blue); }                         /* keyword  */
.code .s { color: var(--green); }                        /* string   */
.code .n { color: var(--accent); }                       /* number   */
.out {
  border-left: 2px solid var(--border-strong); background: var(--surface);
  font-family: var(--font-mono); font-size: .78rem; color: var(--muted);
  padding: .7rem 1rem; margin: -.6rem 0 1.2rem; border-radius: 0 8px 8px 0; white-space: pre-wrap;
}

/* ---------- callouts ---------- */
.note {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem; margin: 1.4rem 0; max-width: var(--measure);
}
.note p:last-child { margin-bottom: 0; }
.note .label {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--accent); display: block; margin-bottom: .4rem;
}
.note.blue  { border-left-color: var(--blue); }
.note.blue .label { color: var(--blue); }
.note.green { border-left-color: var(--green); }
.note.green .label { color: var(--green); }
.note.red   { border-left-color: var(--red); }
.note.red .label { color: var(--red); }

/* ---------- objectives / cards ---------- */
.objectives { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.5rem; background: var(--surface); }
.objectives ul { margin-bottom: 0; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); max-width: 100%; }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 1.1rem 1.2rem; transition: all .18s ease;
}
.card h4 { font-weight: 500; color: var(--heading); font-size: 1rem; margin-bottom: .3rem; }
.card p { font-size: .9rem; color: var(--muted); margin: 0; }

/* week index cards */
a.week-card { text-decoration: none; color: inherit; display: block; position: relative; }
a.week-card:hover .card { border-color: var(--accent); background: var(--surface-2); transform: translateY(-2px); }
.week-card .wk { font-family: var(--font-mono); font-size: .68rem; color: var(--accent); letter-spacing: 1.4px; }
.week-card .card.done { border-color: var(--green); }
.week-card .tick { position: absolute; top: .9rem; right: 1rem; color: var(--green); font-size: .9rem; display: none; }
.week-card .card.done + .tick, .week-card .card.done .tick { display: block; }

/* phase heading */
.phase {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin: 2.4rem 0 .9rem; display: flex; align-items: center; gap: .8rem;
}
.phase::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 1.3rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 460px; }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--border); }
th {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); font-weight: 400;
}
td code { font-size: .82em; }
tbody tr:hover { background: var(--surface); }

/* ---------- exercise / details ---------- */
details.solution {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .9rem; margin: .8rem 0; background: var(--surface); max-width: var(--measure);
}
details.solution summary {
  cursor: pointer; font-family: var(--font-mono); font-size: .72rem;
  color: var(--muted); list-style: none;
}
details.solution summary::-webkit-details-marker { display: none; }
details.solution summary::before { content: "▸ "; color: var(--accent); }
details.solution[open] summary::before { content: "▾ "; }
details.solution[open] { padding-bottom: .2rem; }
details.solution > *:not(summary) { margin-top: .8rem; }

.task {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; margin: 1.3rem 0; max-width: var(--measure); background: var(--surface);
}
.task .label {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--green); display: block; margin-bottom: .5rem;
}
.task.challenge { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.task.challenge .label { color: var(--accent); }
.task.challenge .label::before { content: "\2605 optional challenge \00b7 "; }
.task p:last-child, .task ul:last-child, .task ol:last-child { margin-bottom: 0; }

/* ---------- quiz ---------- */
.quiz { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.5rem; background: var(--surface); max-width: var(--measure); }
.quiz .q { margin-bottom: 1.6rem; }
.quiz .q:last-of-type { margin-bottom: .4rem; }
.quiz .q > p { font-weight: 400; color: var(--heading); margin-bottom: .7rem; }
.quiz .opt {
  display: block; width: 100%; text-align: left; font-family: var(--font-body); font-size: .95rem;
  font-weight: 300; color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 9px;
  padding: .5rem .85rem; margin-bottom: .45rem; cursor: pointer; transition: all .15s;
}
.quiz .opt:hover:not(.locked) { border-color: var(--border-strong); background: var(--surface-2); }
.quiz .opt.right { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.quiz .opt.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.quiz .why {
  display: none; font-size: .86rem; color: var(--muted);
  border-left: 2px solid var(--border-strong); padding-left: .8rem; margin-top: .5rem;
}
.quiz .why.show { display: block; }
.quiz-score { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }

/* ---------- growth widget ---------- */
.widget { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.4rem; background: var(--surface); margin: 1.4rem 0; }
.widget label { font-family: var(--font-mono); font-size: .7rem; color: var(--muted); display: block; margin-bottom: .5rem; }
.widget input[type=range] { width: 100%; accent-color: var(--accent); }
.widget .readout { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); margin-bottom: .8rem; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 110px; gap: .7rem; align-items: center; margin-bottom: .45rem; font-family: var(--font-mono); font-size: .72rem; }
.bar-row .name { color: var(--text); }
.bar-track { display: block; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--accent)); width: 0; transition: width .3s ease; }
.bar-row .val { color: var(--muted); text-align: right; }

/* ---------- footer nav ---------- */
.week-nav { display: flex; gap: 1rem; justify-content: space-between; margin-top: 4rem; padding-top: 1.6rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.week-nav a {
  font-family: var(--font-mono); font-size: .74rem; text-decoration: none; color: var(--muted);
  border: 1px solid var(--border); border-radius: 20px; padding: .45rem 1rem; transition: all .18s;
}
.week-nav a:hover { color: var(--accent); border-color: var(--accent); }
.done-btn {
  font-family: var(--font-mono); font-size: .72rem; cursor: pointer;
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: .45rem 1rem; border-radius: 20px; transition: all .18s;
}
.done-btn:hover { color: var(--text); border-color: var(--border-strong); }
.done-btn.on { color: var(--green); border-color: var(--green); background: var(--green-soft); }

.site-footer {
  border-top: 1px solid var(--border); padding: 1.6rem clamp(1rem, 4vw, 2.4rem);
  display: flex; gap: 1rem; justify-content: space-between; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: .7rem; color: var(--muted);
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* progress bar on home */
.progress-wrap { margin: 1.6rem 0 0; max-width: var(--measure); }
.progress-track { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--accent)); transition: width .4s ease; }
.progress-label { font-family: var(--font-mono); font-size: .7rem; color: var(--muted); margin-top: .45rem; }

@media (max-width: 620px) {
  body { font-size: .98rem; }
  .bar-row { grid-template-columns: 70px 1fr 88px; font-size: .66rem; }
}

@media print {
  .site-header, .week-nav, .copy-btn, .done-btn { display: none; }
  body { background: #fff; color: #000; }
  .code code { white-space: pre-wrap; overflow-wrap: anywhere; }
}

/* ============================================================
   2026 editorial showcase layer
   Aligns AA lessons with the main course collection while
   preserving all lesson, quiz, code, and progress behavior.
   ============================================================ */
:root {
  --bg: #081018;
  --bg-soft: #0c171e;
  --surface: rgba(15, 27, 34, .82);
  --surface-2: rgba(27, 43, 51, .82);
  --border: rgba(220, 235, 231, .12);
  --border-strong: rgba(220, 235, 231, .22);
  --text: #dce5e2;
  --heading: #eef3f1;
  --muted: #8e9c9a;
  --accent: #ff9e80;
  --accent-soft: rgba(255, 158, 128, .11);
  --blue: #70cfff;
  --blue-soft: rgba(112, 207, 255, .10);
  --green: #75d99b;
  --green-soft: rgba(117, 217, 155, .10);
  --red: #ff8f93;
  --red-soft: rgba(255, 143, 147, .10);
  --code-bg: #091319;
  --header-bg: rgba(8, 16, 24, .84);
  --font-display: "Newsreader", Georgia, serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
  --font-body: "Manrope", system-ui, sans-serif;
  --radius: 14px;
  --measure: 72ch;
}

[data-theme="light"] {
  --bg: #f2f1eb;
  --bg-soft: #e8e8df;
  --surface: rgba(252, 252, 247, .82);
  --surface-2: rgba(232, 232, 223, .75);
  --border: rgba(19, 33, 31, .13);
  --border-strong: rgba(19, 33, 31, .24);
  --text: #263633;
  --heading: #13211f;
  --muted: #5d6b68;
  --accent: #b64f32;
  --accent-soft: rgba(182, 79, 50, .09);
  --blue: #176b8e;
  --blue-soft: rgba(23, 107, 142, .08);
  --green: #287146;
  --green-soft: rgba(40, 113, 70, .08);
  --red: #ae3f48;
  --red-soft: rgba(174, 63, 72, .08);
  --code-bg: #e9e9e1;
  --header-bg: rgba(242, 241, 235, .86);
}

body {
  font-weight: 400;
  background:
    radial-gradient(circle at 88% 7%, rgba(82, 195, 255, .08), transparent 28rem),
    radial-gradient(circle at 7% 35%, var(--accent-soft), transparent 25rem),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .38;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 80px 80px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 72%);
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

.site-header {
  min-height: 68px;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: var(--header-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--heading);
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: -.02em;
}

.brand::before {
  content: "A";
  width: 28px;
  height: 28px;
  margin-right: 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--border));
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 400;
}

.hlink {
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.wrap { max-width: 1120px; padding-bottom: 6rem; }
.lesson { max-width: var(--measure); }

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(4.2rem, 9vw, 7.5rem) 0 clamp(3rem, 6vw, 5rem);
}

.hero::after {
  content: "O(n)";
  position: absolute;
  right: 0;
  bottom: -1rem;
  z-index: -1;
  color: var(--accent-soft);
  font: 500 clamp(7rem, 20vw, 15rem)/.8 var(--font-display);
  letter-spacing: -.08em;
  pointer-events: none;
}

.eyebrow { font-size: .66rem; letter-spacing: .16em; }
h1 {
  max-width: 900px;
  font-size: clamp(3.1rem, 8vw, 7rem);
  line-height: .88;
  letter-spacing: -.055em;
}

.lede { max-width: 690px; font-size: clamp(1rem, 1.8vw, 1.18rem); line-height: 1.75; }
.hero-meta { max-width: 760px; }
.chip { padding: .35rem .7rem; font-size: .62rem; letter-spacing: .05em; text-transform: uppercase; }

section { margin-top: 4.2rem; }
h2 { font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1; letter-spacing: -.035em; }
h2 .num { font-size: .66rem; letter-spacing: .1em; }
h3 { font-weight: 600; }
p { line-height: 1.78; }

.objectives, .card, .note, .task, .quiz, .widget, details.solution, .code {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
}
.objectives, .quiz, .widget { padding: clamp(1.1rem, 3vw, 1.6rem); }
.card { border-radius: var(--radius); padding: 1.25rem; }
a.week-card:hover .card, .card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }

.note { padding: 1.15rem 1.3rem; }
.task { padding: 1.25rem 1.4rem; border-style: solid; }
.task:not(.challenge) { border-left: 3px solid var(--green); }
details.solution { padding: .75rem 1rem; }

.code { border-radius: 12px; background: var(--code-bg); }
.code-head { min-height: 38px; font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; }
.copy-btn { border-radius: 999px; }

.quiz .opt { font-weight: 400; border-radius: 9px; }
.quiz .opt:hover:not(.locked) { border-color: var(--accent); }
.widget { border-radius: var(--radius); }

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table { margin: 0; }
th { background: var(--surface-2); letter-spacing: .08em; }
th, td { padding: .72rem .9rem; }

.week-nav a, .done-btn { border-radius: 7px; font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; }
.week-nav a:hover { color: #071012; border-color: var(--accent); background: var(--accent); }
.site-footer { font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; }

@media (max-width: 700px) {
  .site-header { min-height: 60px; }
  .brand span { display: none; }
  .header-nav .hlink:not(:last-child) { display: none; }
  .hero { padding-top: 4rem; }
  h1 { font-size: clamp(3rem, 16vw, 5rem); }
}
