/* The simple theme, and the base every other theme builds on.
   Restyle a workshop with theme.primary / theme.accent in workshop.yaml, or
   with a theme/custom.css that overrides the variables below. */

:root {
  --primary: #3f3cbb;
  --accent: #d9480f;

  --bg: #fbfaf8;
  --surface: #ffffff;
  --sunken: #f3f1ec;
  --text: #24242b;
  --muted: #62626e;
  --line: #e3e0d9;
  --link: var(--primary);
  --on-primary: #ffffff;
  --done: #2b8a3e;

  --code-bg: #1d1e26;
  --code-text: #e6e6ec;
  --code-muted: #8b8d9e;
  --code-keyword: #c792ea;
  --code-string: #addb67;
  --code-number: #f78c6c;
  --code-function: #82aaff;
  --code-type: #ffcb6b;
  --code-added: #addb67;
  --code-removed: #ff7b85;
  --code-line: rgb(255 255 255 / 14%);

  --inline-code-bg: color-mix(in srgb, var(--primary) 9%, transparent);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --topbar: 56px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15151b;
    --surface: #1d1d25;
    --sunken: #101015;
    --text: #e8e8ee;
    --muted: #a0a0ae;
    --line: #2f2f3a;
    --link: color-mix(in srgb, var(--primary) 45%, #ffffff);
    --done: #69db7c;
    --code-bg: #101015;
    --inline-code-bg: color-mix(in srgb, var(--primary) 30%, transparent);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15151b;
  --surface: #1d1d25;
  --sunken: #101015;
  --text: #e8e8ee;
  --muted: #a0a0ae;
  --line: #2f2f3a;
  --link: color-mix(in srgb, var(--primary) 45%, #ffffff);
  --done: #69db7c;
  --code-bg: #101015;
  --inline-code-bg: color-mix(in srgb, var(--primary) 30%, transparent);
  color-scheme: dark;
}

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

html { scroll-padding-top: calc(var(--topbar) + 16px); -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 30;
  padding: 8px 14px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary);
}
.skip-link:focus { top: 8px; color: var(--on-primary); }

/* Top bar ------------------------------------------------------------------ */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: var(--topbar); padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: var(--text); font-weight: 700; text-decoration: none;
}

.topbar-tools { display: flex; align-items: center; gap: 14px; flex: none; font-size: 14px; }
.progress { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tool-link { color: var(--muted); text-decoration: none; }

.track-picker select, .menu summary, .icon-button {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
}
.track-picker select { max-width: 170px; }

.icon-button { display: inline-flex; align-items: center; padding: 0 7px; }

.menu { position: relative; }
.menu summary { display: flex; align-items: center; list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: "▾"; margin-left: 6px; color: var(--muted); font-size: 11px; }
.menu ul {
  position: absolute; right: 0; top: 38px; min-width: 150px; margin: 0; padding: 6px;
  list-style: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 14%);
}
.menu a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.menu a:hover { background: var(--sunken); }
.menu a[aria-current] { font-weight: 700; }

/* Buttons ------------------------------------------------------------------ */

.button {
  display: inline-block; padding: 11px 22px;
  border: 1px solid var(--primary); border-radius: 9px;
  background: var(--primary); color: var(--on-primary);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { filter: brightness(1.12); color: var(--on-primary); }
.button-small { padding: 6px 14px; font-size: 15px; }
.button-quiet { background: transparent; border-color: var(--line); color: var(--text); }
.button-quiet:hover { border-color: var(--primary); color: var(--text); filter: none; }
.button-quiet.is-done { border-color: var(--done); color: var(--done); }

/* Landing page ------------------------------------------------------------- */

.landing { max-width: 1040px; margin: 0 auto; padding: 0 24px 64px; }

.hero { padding: 72px 0 48px; }
.hero h1 {
  max-width: 20ch; margin: 0 0 16px;
  font-size: clamp(2.3rem, 6vw, 3.6rem); line-height: 1.08; letter-spacing: -0.025em;
}
.hero-lead { max-width: 62ch; margin: 0 0 28px; color: var(--muted); font-size: 1.22rem; line-height: 1.55; }

.facts { display: flex; flex-wrap: wrap; gap: 12px 44px; margin: 40px 0 0; padding-top: 22px; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-weight: 700; }

.contents { margin-top: 40px; }
.contents > h2, .author > h2 { margin: 48px 0 16px; font-size: 1.7rem; letter-spacing: -0.015em; }
.part-title { margin: 36px 0 14px; color: var(--muted); font-size: 1.02rem; font-weight: 600; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }

.module-card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.module-card:hover { border-color: var(--primary); color: var(--text); transform: translateY(-2px); }
.module-card-number { color: var(--muted); font: 13px var(--mono); }
.module-card-title { font-weight: 700; line-height: 1.3; }
.module-card-text { color: var(--muted); font-size: 15px; line-height: 1.5; }
.module-card-duration { margin-top: auto; padding-top: 6px; color: var(--muted); font-size: 13px; }
.module-card.is-done::after {
  content: "✓"; position: absolute; top: 14px; right: 16px; color: var(--done); font-weight: 700;
}

.author-card { display: flex; gap: 20px; align-items: flex-start; }
.author-card img { flex: none; border-radius: 50%; object-fit: cover; }
.author-card p { margin: 0 0 8px; }
.author-name { font-weight: 700; }
.author-role { color: var(--muted); font-size: 15px; }

/* Module pages ------------------------------------------------------------- */

.layout {
  display: grid; grid-template-columns: 264px minmax(0, 1fr) 216px; gap: 48px;
  max-width: 1420px; margin: 0 auto; padding: 0 24px;
}

.sidebar, .toc {
  position: sticky; top: var(--topbar); align-self: start;
  max-height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 28px 0; font-size: 14.5px; line-height: 1.4;
}

.module-nav-home { display: block; margin-bottom: 14px; color: var(--muted); text-decoration: none; }
.module-nav-part { margin: 20px 0 6px; color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.module-nav ol { margin: 0; padding: 0; list-style: none; }
.module-nav li a {
  position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 4px;
  padding: 6px 22px 6px 8px; border-radius: 7px; color: var(--text); text-decoration: none;
}
.module-nav li a:hover { background: var(--sunken); }
.module-nav li a[aria-current] { background: var(--inline-code-bg); color: var(--link); font-weight: 600; }
.module-nav-number { color: var(--muted); font: 12.5px/1.6 var(--mono); }
.module-nav li a.is-done::after { content: "✓"; position: absolute; right: 7px; color: var(--done); font-weight: 700; }

.mobile-nav { display: none; }

/* The module list of themes with no sidebar. */
.contents-box { margin: 32px 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.contents-box summary { display: flex; align-items: center; gap: 8px; padding: 14px 20px; cursor: pointer; list-style: none; user-select: none; }
.contents-box summary::-webkit-details-marker { display: none; }
.contents-box summary:hover { background: var(--sunken); }
.contents-box-title { flex: 1; font-size: .94rem; font-weight: 600; }
.contents-box-toggle { color: var(--muted); font-size: .75rem; transition: transform .2s; }
.contents-box[open] .contents-box-toggle { transform: rotate(180deg); }
.contents-box .module-nav { padding: 12px 16px 14px; border-top: 1px solid var(--line); font-size: .9rem; line-height: 1.5; }
.contents-box .module-nav-home { margin: 0 8px 6px; }
.contents-box .module-nav-part { margin: 14px 8px 4px; }
.contents-box .module-nav li a { padding: 4px 26px 4px 8px; border-radius: 4px; }
.contents-box .module-nav li a:hover { background: var(--sunken); }

.doc { min-width: 0; max-width: 780px; width: 100%; margin: 0 auto; padding: 40px 0 72px; }
.doc-header h1 { margin: 0 0 12px; font-size: clamp(2rem, 4.5vw, 2.7rem); line-height: 1.13; letter-spacing: -0.02em; }

.eyebrow { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.draft-badge { color: var(--accent); font-weight: 700; }

.lede { margin: 0 0 28px; color: var(--muted); font-size: 1.16rem; line-height: 1.55; }

.notice { padding: 10px 14px; background: var(--sunken); border-radius: 8px; color: var(--muted); font-size: 15px; }

.exercise {
  margin: 0 0 32px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.exercise-title { margin: 0 0 10px; font-weight: 700; }
.exercise-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 15px; }
.exercise-files { margin-top: 10px; color: var(--muted); font-size: 14.5px; }
.exercise-files summary { cursor: pointer; }
.exercise-files ul { margin: 8px 0 0; padding: 0; list-style: none; }

.complete { margin-top: 48px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 24px; }
.pager a {
  display: block; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; line-height: 1.35;
}
.pager a:hover { border-color: var(--primary); color: var(--text); }
.pager small { display: block; color: var(--muted); }
.pager-next { grid-column: 2; text-align: right; }

.toc-title { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.toc ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.toc a { display: block; margin-left: -1px; padding: 4px 0 4px 12px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); }
.toc a.is-active { border-left-color: var(--primary); color: var(--text); }
.toc-level-3 a { padding-left: 24px; font-size: 13.5px; }

/* Module content ----------------------------------------------------------- */

.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.25; letter-spacing: -0.012em; }
.prose h1 { font-size: 2rem; }
.prose h2 { margin: 2.1em 0 .6em; font-size: 1.6rem; }
.prose h3 { margin: 1.8em 0 .5em; font-size: 1.22rem; }
.prose h4 { margin: 1.6em 0 .4em; font-size: 1.03rem; }
.prose > :first-child { margin-top: 0; }

.heading-anchor { margin-left: 8px; color: var(--muted); font-weight: 400; text-decoration: none; opacity: 0; }
h2:hover > .heading-anchor, h3:hover > .heading-anchor { opacity: 1; }

.prose img { display: block; max-width: 100%; height: auto; margin: 1.6em auto; border-radius: 8px; }
.prose hr { margin: 2.4em 0; border: 0; border-top: 1px solid var(--line); }
.prose li + li { margin-top: .3em; }
.prose li::marker { color: var(--muted); }

.prose blockquote {
  margin: 1.4em 0; padding: 2px 18px;
  border-left: 3px solid var(--line); color: var(--muted);
}

.prose table { display: block; max-width: 100%; margin: 1.5em 0; overflow-x: auto; border-collapse: collapse; font-size: 15.5px; }
.prose th, .prose td { padding: 7px 13px; border: 1px solid var(--line); text-align: left; }
.prose th { background: var(--sunken); }

.prose :not(pre) > code {
  padding: .13em .36em; border-radius: 5px;
  background: var(--inline-code-bg); font: .88em var(--mono);
  overflow-wrap: anywhere;
}

.prose input[type="checkbox"] { width: 16px; height: 16px; margin: 0 8px 0 0; vertical-align: -2px; accent-color: var(--primary); }
.prose li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.2em; }

.footnotes { margin-top: 3em; color: var(--muted); font-size: 15px; }

/* Code --------------------------------------------------------------------- */

.code-block { position: relative; margin: 1.3em 0; border-radius: var(--radius); overflow: hidden; background: var(--code-bg); }
.code-title {
  padding: 7px 16px; border-bottom: 1px solid var(--code-line);
  color: var(--code-muted); font: 13px var(--mono);
}

.chroma { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--code-text); font: 14px/1.6 var(--mono); tab-size: 4; }
.chroma code { font: inherit; }
.chroma .line { display: block; min-height: 1.6em; }
.chroma .cl { display: inline; }

.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .nt, .chroma .nb { color: var(--code-keyword); }
.chroma .kt, .chroma .nc, .chroma .ne { color: var(--code-type); }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd, .chroma .s1, .chroma .s2, .chroma .se, .chroma .sh, .chroma .si, .chroma .sx, .chroma .sr, .chroma .ss { color: var(--code-string); }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .il, .chroma .mo { color: var(--code-number); }
.chroma .nf, .chroma .fm, .chroma .nd, .chroma .na { color: var(--code-function); }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs, .chroma .cp, .chroma .cpf { color: var(--code-muted); font-style: italic; }
.chroma .gi { color: var(--code-added); }
.chroma .gd { color: var(--code-removed); }
.chroma .gh, .chroma .gu { color: var(--code-muted); }

.copy-button {
  position: absolute; top: 6px; right: 6px; padding: 2px 9px;
  border: 1px solid var(--code-line); border-radius: 6px;
  background: var(--code-bg); color: var(--code-muted);
  font: 12px var(--font); cursor: pointer; opacity: 0; transition: opacity .15s;
}
.code-block:hover .copy-button, .copy-button:focus-visible { opacity: 1; }
.copy-button:hover { color: var(--code-text); }

/* Callouts ----------------------------------------------------------------- */

.alert {
  --tone: var(--primary);
  display: block; margin: 1.4em 0; padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--tone) 28%, var(--line));
  border-left: 4px solid var(--tone); border-radius: 8px;
  background: color-mix(in srgb, var(--tone) 6%, transparent);
}
/* Mixing with the text color keeps every tone readable on light and dark. */
.alert-title, .alert summary { margin: 0; color: color-mix(in srgb, var(--tone) 60%, var(--text)); font-weight: 700; }
.alert summary { cursor: pointer; }
.alert-body > :first-child { margin-top: .4em; }
.alert-body > :last-child { margin-bottom: 0; }
.alert-tip { --tone: #2b8a3e; }
.alert-important { --tone: #8e44ad; }
.alert-warning { --tone: #c77700; }
.alert-caution { --tone: #d6336c; }
.alert-hint { --tone: #1c7ed6; }
.alert-solution { --tone: #2b8a3e; }

/* Tracks ------------------------------------------------------------------- */

.track-block { margin: 1.3em 0; padding-left: 14px; border-left: 2px solid var(--line); }
.track-block > :last-child { margin-bottom: 0; }
.track-label { color: var(--muted); font: 12.5px var(--mono); }

/* Once a track is chosen the rest are hidden, so these blocks read as prose. */
html[data-track] .track-block { padding-left: 0; border-left: 0; }
html[data-track] .track-label { display: none; }

/* Footer ------------------------------------------------------------------- */

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14.5px; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px; max-width: 1420px; margin: 0 auto; padding: 22px 24px; }
.footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; margin: 0; padding: 0; list-style: none; }
.footer-links a { color: var(--muted); }
.built-with { margin-left: auto !important; }

/* Responsive --------------------------------------------------------------- */

@media (max-width: 1240px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); gap: 40px; }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .layout { display: block; padding: 0 16px; }
  .sidebar { display: none; }
  .doc { padding-top: 16px; }
  .topbar { padding: 0 16px; }
  .landing { padding: 0 16px 48px; }
  .hero { padding-top: 44px; }
  .progress, .tool-link { display: none; }
  .built-with { margin-left: 0 !important; }

  .mobile-nav { display: block; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; }
  .mobile-nav summary { padding: 9px 14px; font-weight: 600; cursor: pointer; }
  .mobile-nav .module-nav { padding: 0 10px 12px; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  /* The tools need the whole width, so the title gets a line of its own. */
  .topbar { flex-wrap: wrap; gap: 4px 12px; height: auto; padding: 8px 16px; }
  .brand { flex: 1 0 100%; }
  html { scroll-padding-top: 108px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .author-card { flex-direction: column; }
}

@media print {
  .topbar, .sidebar, .toc, .mobile-nav, .contents-box, .pager, .complete, .footer, .copy-button { display: none !important; }
  .layout { display: block; }
  .doc { max-width: none; padding: 0; }
  .alert details, details.alert { display: block; }
}
