/* ------------------------------------------------------------------
   hackpack

   One accent colour per section. The sidebar shows every section's
   colour as a dot; the page you're on uses its colour for links,
   headings, callouts and tables. Quiet on a single page, colourful
   across the whole thing.
   ------------------------------------------------------------------ */

:root {
  --bg: #fcfcfe;
  --surface: #ffffff;
  --text: #191c22;
  --muted: #5d6470;
  --line: #e6e8ee;
  --line-strong: #d5d9e2;
  --code-bg: #f6f7fa;
  --hover: #f3f4f8;
  --tint: #eef0ff;
  --edge: #dbdefb;
  --accent: #4338ca;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --header-h: 56px;
  --radius: 4px;
}

/* Section colours */
.sec-home      { --accent: #4338ca; --tint: #eef0ff; --edge: #d9ddfb; }
.sec-intro     { --accent: #b45309; --tint: #fff6e9; --edge: #f4dfbc; }
.sec-setup     { --accent: #1d4ed8; --tint: #edf3ff; --edge: #d3e1fd; }
.sec-basics    { --accent: #0f766e; --tint: #e9f7f4; --edge: #c5e8e0; }
.sec-git       { --accent: #c2410c; --tint: #fdf1e9; --edge: #f4d6c1; }
.sec-ai        { --accent: #6d28d9; --tint: #f4efff; --edge: #ded0fa; }
.sec-guide     { --accent: #be123c; --tint: #fdeff2; --edge: #f6cbd6; }
.sec-demo      { --accent: #a21caf; --tint: #fbeffc; --edge: #f0cdf4; }
.sec-resources { --accent: #15803d; --tint: #ecf7ef; --edge: #cbe7d4; }
.sec-templates { --accent: #0369a1; --tint: #eaf5fb; --edge: #c6e3f1; }
.sec-scripts   { --accent: #475569; --tint: #f1f3f7; --edge: #dbe0e9; }
.sec-extras    { --accent: #475569; --tint: #f1f3f7; --edge: #dbe0e9; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

::selection { background: var(--tint); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--accent); }

/* Top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.top a { text-decoration: none; }

.top .brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.top .brand .by {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.top .brand:hover,
.top .brand:hover .by { color: var(--accent); }

/* The GitHub mark, small, next to the word. The same glyph is the
   watermark at the foot of the sidebar. */
.top .repo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.top .repo svg { width: 15px; height: 15px; fill: currentColor; }

.top > a:last-child { font-size: 0.86rem; color: var(--muted); }
.top > a:last-child:hover { color: var(--accent); }

/* Two columns: sidebar + content */
.layout {
  display: flex;
  align-items: flex-start;
  max-width: 1140px;
  margin: 0 auto;
}

.sidebar {
  flex: 0 0 258px;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1.4rem 1rem 2.5rem 1.5rem;
  font-size: 0.9rem;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}

.content {
  flex: 1;
  min-width: 0;
  max-width: 800px;
  padding: 0 2rem 0 1.75rem;
}

/* Sidebar list */
.nav-list, .nav-list ul { list-style: none; margin: 0; padding: 0; }

.nav-list > li { margin-bottom: 0.1rem; }

.nav-list a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.33rem 0.55rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.35;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-list a:hover { color: var(--text); background: var(--hover); }

.nav-list a.section {
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.005em;
  color: var(--text);
}

.nav-list ul {
  margin: 0.1rem 0 0.55rem 1.05rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--line);
}

.nav-list ul a { padding: 0.26rem 0.5rem; font-size: 0.86rem; }

.nav-list a.current {
  background: var(--tint);
  color: var(--accent);
  font-weight: 600;
}

.nav-list li.active > a.section {
  background: var(--tint);
  color: var(--accent);
}

.nav-list li.active > ul { border-left-color: var(--edge); }

/* Section dots */
.nav-list .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px transparent;
}

.dot-home      { background: #4338ca; }
.dot-intro     { background: #b45309; }
.dot-setup     { background: #1d4ed8; }
.dot-basics    { background: #0f766e; }
.dot-git       { background: #c2410c; }
.dot-ai        { background: #6d28d9; }
.dot-guide     { background: #be123c; }
.dot-demo      { background: #a21caf; }
.dot-resources { background: #15803d; }
.dot-templates { background: #0369a1; }
.dot-scripts   { background: #475569; }
.dot-extras    { background: #475569; }

.nav-list li.active .dot { box-shadow: 0 0 0 3px var(--tint); }

/* On small screens the sidebar becomes a collapsible menu */
.mobile-nav { display: none; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .content { padding: 0 1.25rem; max-width: none; }
  .mobile-nav {
    display: block;
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.95rem;
  }
  .mobile-nav summary { cursor: pointer; font-weight: 600; }
  .mobile-nav[open] summary { color: var(--accent); margin-bottom: 0.6rem; }
  .mobile-nav .nav-list { margin-top: 0.4rem; }
}

/* Breadcrumbs */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.7rem;
  font-size: 0.82rem;
  color: var(--muted);
}

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

.crumbs a:nth-of-type(2) { color: var(--accent); font-weight: 500; }

main { padding: 0.8rem 0 1rem; }

/* Content */
main h1 {
  font-size: clamp(1.85rem, 1.45rem + 1vw, 2.3rem);
  line-height: 1.18;
  letter-spacing: -0.022em;
  font-weight: 700;
  margin: 0.2rem 0 1.2rem;
}

/* The handle sits with the title on the home page, same as the top bar. */
main h1 .by {
  font-family: var(--mono);
  font-size: 0.4em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: 0.35em;
  margin-left: 0.3rem;
  white-space: nowrap;
}

main h1::before {
  content: "";
  display: block;
  width: 32px;
  height: 3px;
  border-radius: 0;
  margin-bottom: 0.9rem;
  background: var(--accent);
}

main h2 {
  font-size: 1.3rem;
  line-height: 1.35;
  letter-spacing: -0.012em;
  font-weight: 600;
  margin: 2.4rem 0 0.6rem;
}

main h3 {
  font-size: 1.06rem;
  line-height: 1.4;
  font-weight: 600;
  margin: 1.7rem 0 0.4rem;
}

main a {
  text-decoration: underline;
  text-decoration-color: var(--edge);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

main p { margin: 0.9rem 0; }

main ul, main ol { padding-left: 1.35rem; margin: 0.8rem 0; }
main ul li::marker { color: var(--accent); }
main ol li::marker { color: var(--accent); font-weight: 600; }
li { margin: 0.25rem 0; }
li > ul, li > ol { margin: 0.25rem 0; }

code, pre { font-family: var(--mono); font-size: 0.88em; }

code {
  background: var(--tint);
  color: var(--accent);
  padding: 0.12em 0.34em;
  border-radius: 5px;
  white-space: nowrap;
}

pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  line-height: 1.5;
  margin: 1.1rem 0;
}

pre code {
  background: none;
  color: var(--text);
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

/* Syntax colour, in the section's own hue: the accent for the structure
   of the code, a softer mix for strings and numbers, grey for comments.
   Only blocks with a language tag get tokens; the rest stay plain text. */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp {
  color: var(--muted);
  font-style: italic;
}

.highlight .k, .highlight .kc, .highlight .kd, .highlight .kn,
.highlight .kp, .highlight .kr, .highlight .kt,
.highlight .nt, .highlight .na, .highlight .nb, .highlight .nv,
.highlight .nc, .highlight .nn,
.highlight .gu, .highlight .gh, .highlight .gd {
  color: var(--accent);
}

.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb,
.highlight .se, .highlight .sx, .highlight .sr, .highlight .si {
  color: color-mix(in srgb, var(--accent) 45%, var(--text));
}

.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh,
.highlight .mo, .highlight .il {
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}

.highlight .o, .highlight .p { color: var(--muted); }

/* Rouge flags anything it can't parse as an error. We're not a linter. */
.highlight .err { color: inherit; background: none; }

pre .copy {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: var(--surface);
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease,
    background 0.12s ease;
}

pre:hover .copy, pre .copy:focus-visible { opacity: 1; }
pre .copy:hover {
  color: var(--accent);
  border-color: var(--edge);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

/* Big prompts and quotes */
blockquote {
  margin: 1.3rem 0;
  padding: 0.75rem 1.1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0;
  background: var(--tint);
  color: var(--text);
}

blockquote p { margin: 0.35rem 0; }
blockquote code { background: var(--surface); }
blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3rem 0;
  font-size: 0.93rem;
  display: block;
  overflow-x: auto;
}

th, td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

thead th {
  background: var(--tint);
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }

hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.2rem 0;
}

/* Images */
main img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6rem 0 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

main img[src*="xkcd"] {
  background: #fff;
  padding: 0.5rem;
  max-width: 480px;
  border-color: #eee;
}

/* Diagrams: a matching pair of images, one per colour scheme. Their
   background is the page background, so they sit in the column without
   a frame around them. */
main figure.diagram { margin: 1.8rem 0 1.9rem; }

main figure.diagram img {
  margin: 0;
  border: 0;
  border-radius: 0;
}

main figure.diagram figcaption {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Captions: the italic line under a picture, whether it sits in the same
   paragraph as the image or the one after it. */
main img + em,
main p:has(> img:only-child) + p > em:only-child {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1.6rem;
}

ul.task-list { list-style: none; padding-left: 1.2rem; }
ul.task-list li::marker { content: ""; }

/* Home page cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 0.7rem;
  margin: 1.4rem 0 2rem;
}

.cards p { margin: 0; }

.cards a {
  display: block;
  height: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}

/* Plain until you point at it; then the card takes its section's colour. */
.cards a:hover {
  background: color-mix(in srgb, var(--card, var(--accent)) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--card, var(--accent)) 35%, var(--line));
}

.cards strong { display: inline; color: var(--accent); font-size: 0.98rem; }
.cards span { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

/* A small dot carries each section's colour, so the grid stays quiet. */
.cards strong::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: 1px;
  background: var(--card, var(--accent));
}

.cards a.c-intro     { --card: #b45309; }
.cards a.c-setup     { --card: #1d4ed8; }
.cards a.c-basics    { --card: #0f766e; }
.cards a.c-git       { --card: #c2410c; }
.cards a.c-ai        { --card: #6d28d9; }
.cards a.c-guide     { --card: #be123c; }
.cards a.c-demo      { --card: #a21caf; }
.cards a.c-resources { --card: #15803d; }
.cards a.c-templates { --card: #0369a1; }
.cards a.c-scripts   { --card: #475569; }
.cards a.c-extras    { --card: #475569; }

/* Previous / next */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.4rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.pager a {
  flex: 0 1 48%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: background 0.14s ease, border-color 0.14s ease;
}

.pager a:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.pager small {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.15rem;
}

.pager a:hover small { color: var(--accent); }

.pager .next { text-align: right; margin-left: auto; }
.pager .prev small::before { content: "← "; }
.pager .next small::after { content: " →"; }

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1.2rem;
  margin-top: 2rem;
  padding: 1rem 0 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
  color: var(--muted);
}

footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  text-decoration: none;
}

footer svg { width: 14px; height: 14px; fill: currentColor; flex: 0 0 auto; }
footer .foot-links { display: inline-flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
footer a:hover { color: var(--accent); }

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #13171e;
    --text: #e2e6ee;
    --muted: #939cab;
    --line: #232932;
    --line-strong: #2e3540;
    --code-bg: #151a22;
    --hover: #171c25;
    --tint: #1a2030;
    --edge: #2b3446;
    --accent: #a5b4fc;
  }

  /* The section classes sit on <body>, so they beat :root. Set the dark
     tint on them too, or the light tints inherit through and stay light. */
  .sec-home, .sec-intro, .sec-setup, .sec-basics, .sec-git,
  .sec-ai, .sec-guide, .sec-demo, .sec-resources, .sec-templates,
  .sec-scripts, .sec-extras {
    --tint: #1a2030;
    --edge: #2b3446;
  }

  .sec-home      { --accent: #a5b4fc; }
  .sec-intro     { --accent: #f0b46b; }
  .sec-setup     { --accent: #93b4ff; }
  .sec-basics    { --accent: #5eead4; }
  .sec-git       { --accent: #fdba74; }
  .sec-ai        { --accent: #c4b5fd; }
  .sec-guide     { --accent: #fda4af; }
  .sec-demo      { --accent: #f0abfc; }
  .sec-resources { --accent: #86efac; }
  .sec-templates { --accent: #7dd3fc; }
  .sec-scripts   { --accent: #cbd5e1; }
  .sec-extras    { --accent: #cbd5e1; }

  .dot-home      { background: #a5b4fc; }
  .dot-intro     { background: #f0b46b; }
  .dot-setup     { background: #93b4ff; }
  .dot-basics    { background: #5eead4; }
  .dot-git       { background: #fdba74; }
  .dot-ai        { background: #c4b5fd; }
  .dot-guide     { background: #fda4af; }
  .dot-demo      { background: #f0abfc; }
  .dot-resources { background: #86efac; }
  .dot-templates { background: #7dd3fc; }
  .dot-scripts   { background: #cbd5e1; }
  .dot-extras    { background: #cbd5e1; }

  main img[src*="xkcd"] { background: #fff; border-color: #2a2a2a; }
  blockquote code { background: var(--surface); }
  pre .copy { background: var(--surface); }
}
