@import url('https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --ink: #15233F;
  --ink-soft: #4A5875;
  --rule: #D6DDE8;
  --blue: #2A58C0;
  --blue-wash: #E7EEFB;
  --amber: #D98E04;
  --amber-wash: #FDF3DF;
  --green: #2E7D4F;
  --green-wash: #E4F3EA;
  --red: #B8322A;
  --red-wash: #FBE9E7;
  --code-bg: #EEF1F6;
  --fs: 18px;
  --measure: 70ch;
  --sans: 'Public Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C1424; --surface: #131E33; --ink: #E4EAF4; --ink-soft: #A3B0C6;
    --rule: #2A3852; --blue: #7FA2F0; --blue-wash: #18284A; --amber: #F2B441;
    --amber-wash: #2E2412; --green: #6CC792; --green-wash: #13291D; --red: #F08A80;
    --red-wash: #33191A; --code-bg: #1A2640; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C1424; --surface: #131E33; --ink: #E4EAF4; --ink-soft: #A3B0C6;
  --rule: #2A3852; --blue: #7FA2F0; --blue-wash: #18284A; --amber: #F2B441;
  --amber-wash: #2E2412; --green: #6CC792; --green-wash: #13291D; --red: #F08A80;
  --red-wash: #33191A; --code-bg: #1A2640; color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.6; font-weight: 400;
}
a { color: var(--blue); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 2px; }
code, kbd { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { font-family: var(--mono); font-size: .8rem; background: var(--code-bg); padding: 1rem; border-radius: 6px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }
img, svg { max-width: 100%; }

/* ---------- gate ---------- */
html:not(.ok) .shell { display: none; }
html.ok .gate { display: none; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate form { width: min(380px, 100%); }
.gate h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 .25rem; }
.gate p { color: var(--ink-soft); margin: 0 0 1.25rem; }
.gate input { width: 100%; font: inherit; padding: .7rem .8rem; border: 2px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--ink); }
.gate button { margin-top: .75rem; width: 100%; }
.gate .err { color: var(--red); min-height: 1.5em; font-size: .9rem; margin-top: .5rem; }

button, .btn {
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 6px; padding: .6rem 1rem;
}
button.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--rule); }
button.ghost[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); background: var(--blue-wash); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--rule); padding: 1.5rem 1rem 1rem 1.25rem; font-size: .88rem;
}
.rail .brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; margin-bottom: .15rem; display: block; color: var(--ink); text-decoration: none; }
.rail .sub { color: var(--ink-soft); font-size: .8rem; margin: 0 0 1.25rem; }
.route { list-style: none; margin: 0; padding: 0; position: relative; }
.route::before { content: ""; position: absolute; left: 6px; top: 10px; bottom: 10px; width: 3px; background: var(--rule); border-radius: 2px; }
.route li { position: relative; padding-left: 24px; margin: 0 0 .15rem; }
.route li::before {
  content: ""; position: absolute; left: 0; top: .55em; width: 15px; height: 15px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--ink-soft); box-sizing: border-box;
}
.route li.here::before { border-color: var(--blue); background: var(--blue); }
.route li.done::before { border-color: var(--green); background: var(--green); }
.route a { display: block; padding: .3rem .4rem; color: var(--ink); text-decoration: none; border-radius: 4px; line-height: 1.35; }
.route a:hover { background: var(--blue-wash); }
.route li.here a { font-weight: 700; }
.route .count { display: block; font-size: .72rem; color: var(--ink-soft); font-weight: 400; }
.tools { margin-top: 1.5rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.tools button { padding: .35rem .6rem; font-size: .78rem; }

.toc { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--rule); }
.toc p { margin: 0 0 .4rem; color: var(--ink-soft); font-size: .78rem; }
.toc a { display: block; color: var(--ink-soft); text-decoration: none; padding: .15rem 0; font-size: .82rem; }
.toc a:hover { color: var(--blue); }

main { padding: 2.5rem 2.5rem 6rem; min-width: 0; }
.col { max-width: var(--measure); }

.menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); background: var(--surface); z-index: 20; transform: translateX(-102%); transition: transform .2s; box-shadow: 0 0 0 100vmax transparent; }
  .rail.open { transform: none; box-shadow: 0 0 0 100vmax rgba(8,14,28,.45); }
  .menu-btn { display: inline-block; position: sticky; top: 8px; z-index: 10; margin: 8px 16px 0; }
  main { padding: 1rem 16px 5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- page head ---------- */
.page-head { margin-bottom: 2.5rem; }
.page-head h1 { font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.05; font-weight: 800; letter-spacing: -.03em; margin: 0 0 .75rem; }
.lede { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 .75rem; }
.readtime { font-size: .82rem; color: var(--ink-soft); margin: 0; }

.quick { background: var(--surface); border: 1px solid var(--rule); border-left: 5px solid var(--blue); border-radius: 6px; padding: 1rem 1.25rem; margin: 0 0 2.5rem; }
.quick h2 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 700; }
.quick ul, .quick ol { margin: 0; padding-left: 1.2rem; }
.quick li { margin: .25rem 0; }

/* ---------- chapters ---------- */
.chapter { margin: 0 0 3.5rem; scroll-margin-top: 1rem; }
.chapter > h2 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin: 0 0 .75rem; padding-top: 1.25rem; border-top: 3px solid var(--ink); }
h3 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; margin: 2rem 0 .5rem; line-height: 1.25; }
h4 { font-size: 1rem; font-weight: 700; margin: 1.5rem 0 .4rem; }
p, li { max-width: var(--measure); }
li { margin: .2rem 0; }

/* ---------- concept ladder ---------- */
.concept { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 1.25rem 1.4rem 1rem; margin: 1.5rem 0; scroll-margin-top: 1rem; }
.concept > h3 { margin-top: 0; }
.ladder { margin: 0; }
.rung { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; padding: .7rem 0; border-top: 1px dashed var(--rule); }
.rung:first-child { border-top: 0; }
.rung dt { font-size: .8rem; font-weight: 700; color: var(--ink-soft); padding-top: .2rem; }
.rung dd { margin: 0; }
.rung dd > :first-child { margin-top: 0; }
.rung dd > :last-child { margin-bottom: 0; }
.rung.problem dt { color: var(--red); }
.rung.picture dt { color: var(--amber); }
.rung.term dt { color: var(--blue); }
.rung.beacon dt { color: var(--green); }
@media (max-width: 600px) { .rung { grid-template-columns: 1fr; gap: .2rem; } }

details { margin: .75rem 0; }
details > summary { cursor: pointer; font-weight: 600; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; display: inline-block; width: 1.2em; font-weight: 800; color: var(--blue); }
details[open] > summary::before { content: "\2212"; }
details.deeper { border-top: 1px solid var(--rule); padding-top: .6rem; }
details.deeper > div { padding: .25rem 0 0 1.2em; }

details.qa { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: .75rem 1rem; }
details.qa[open] { border-color: var(--blue); }
details.qa > div { padding: .5rem 0 .25rem 1.2em; }
details.qa > div > :first-child { margin-top: 0; }

.gotit { display: inline-flex; gap: .5rem; align-items: center; font-size: .85rem; color: var(--ink-soft); margin-top: .6rem; cursor: pointer; user-select: none; }
.gotit input { width: 1.1rem; height: 1.1rem; accent-color: var(--green); }
.gotit:has(input:checked) { color: var(--green); font-weight: 600; }

/* ---------- notes ---------- */
.note { border-radius: 6px; padding: .8rem 1rem; margin: 1rem 0; border: 1px solid; }
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note .tag { font-weight: 700; font-size: .82rem; display: block; margin-bottom: .2rem; }
.note.say { background: var(--green-wash); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.note.say .tag { color: var(--green); }
.note.watch { background: var(--amber-wash); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.note.watch .tag { color: var(--amber); }
.note.verify { background: var(--blue-wash); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.note.verify .tag { color: var(--blue); }
.note.avoid { background: var(--red-wash); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.note.avoid .tag { color: var(--red); }

blockquote.script { margin: 1rem 0; padding: .9rem 1.1rem; background: var(--surface); border-left: 4px solid var(--green); border-radius: 0 6px 6px 0; font-size: 1.02rem; }
blockquote.script p { margin: .4rem 0; }

.star { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0; }
.star h4 { margin-top: 0; }
.star p { margin: .45rem 0; }
.star b.s, .star b.t, .star b.a, .star b.r { display: inline-block; min-width: 5.5rem; font-size: .8rem; }
.star b.s { color: var(--ink-soft); } .star b.t { color: var(--amber); } .star b.a { color: var(--blue); } .star b.r { color: var(--green); }
.star .fits { font-size: .8rem; color: var(--ink-soft); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table.grid { border-collapse: collapse; width: 100%; font-size: .88rem; background: var(--surface); }
table.grid th, table.grid td { text-align: left; vertical-align: top; padding: .55rem .7rem; border: 1px solid var(--rule); }
table.grid th { background: var(--code-bg); font-weight: 700; }

/* ---------- diagrams ---------- */
figure.diagram { margin: 1.25rem 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 1rem; overflow-x: auto; }
figure.diagram figcaption { font-size: .82rem; color: var(--ink-soft); margin-top: .6rem; }
figure.diagram svg { display: block; margin: 0 auto; height: auto; font-family: var(--sans); }
svg .box { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
svg .box.aws { fill: var(--blue-wash); stroke: var(--blue); }
svg .box.risk { fill: var(--amber-wash); stroke: var(--amber); }
svg .box.ok { fill: var(--green-wash); stroke: var(--green); }
svg .zone { fill: none; stroke: var(--ink-soft); stroke-dasharray: 5 4; stroke-width: 1.2; }
svg .edge { stroke: var(--ink-soft); stroke-width: 1.6; fill: none; }
svg .edge.hot { stroke: var(--blue); stroke-width: 2.2; }
svg text { fill: var(--ink); font-size: 13px; }
svg text.small { fill: var(--ink-soft); font-size: 11px; }
svg text.title { font-weight: 700; }
svg .arrowhead { fill: var(--ink-soft); }
pre.ascii { font-size: .74rem; line-height: 1.3; }

/* ---------- process line (home) ---------- */
.line { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin: 1.5rem 0 2.5rem; position: relative; max-width: 920px; }
.line::before { content: ""; position: absolute; left: 10%; right: 10%; top: 17px; height: 6px; background: var(--ink); border-radius: 3px; }
.stop { text-align: center; position: relative; padding: 0 .4rem; }
.stop .dot { width: 40px; height: 40px; border-radius: 50%; background: var(--paper); border: 6px solid var(--ink); margin: 0 auto .6rem; position: relative; z-index: 1; }
.stop.here .dot { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 6px var(--blue-wash); }
.stop b { display: block; font-size: .95rem; line-height: 1.2; }
.stop span { display: block; font-size: .78rem; color: var(--ink-soft); margin-top: .2rem; }
.stop.here b { color: var(--blue); }
@media (max-width: 700px) {
  .line { grid-template-columns: 1fr; gap: .9rem; }
  .line::before { left: 17px; right: auto; top: 10px; bottom: 10px; width: 6px; height: auto; }
  .stop { display: grid; grid-template-columns: 40px 1fr; gap: .8rem; text-align: left; align-items: center; padding: 0; }
  .stop .dot { margin: 0; }
}

/* ---------- flashcards ---------- */
.deck-bar { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.card { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; min-height: 260px; padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; cursor: pointer; }
.card .side { font-size: .78rem; color: var(--ink-soft); margin-bottom: .6rem; }
.card .face { font-size: 1.2rem; font-weight: 600; line-height: 1.4; }
.card.flipped { border-color: var(--blue); }
.card.flipped .face { font-weight: 400; font-size: 1.02rem; }
.deck-nav { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.deck-nav .pos { margin-left: auto; color: var(--ink-soft); font-size: .88rem; }

.progress-strip { font-size: .85rem; color: var(--ink-soft); margin: 0 0 1rem; }

@media print {
  .rail, .menu-btn, .gotit, .tools { display: none !important; }
  .shell { display: block; }
  details { break-inside: avoid; }
  details:not([open]) > :not(summary) { display: block; }
}
