/* 3 Days of Spec-Driven Development — the only stylesheet.
   No external fonts, no imports, no network requests.
   Colour tokens live on :root; dark values are declared twice, once for the
   system preference (unless the reader forced light) and once for the
   explicit data-theme="dark" the toggle sets. */

:root {
  --bg: #ffffff;
  --fg: #15181c;
  --muted: #555c66;
  --accent: #0b5ea8;
  --border: #7f8690;
  --code-bg: #f1f4f7;

  --surface: #f5f7fa;
  --accent-contrast: #ffffff;
  /* Hairline rules and separators. Alpha is set so the composited line clears
     3:1 against --bg and against --surface, the two backgrounds it is ever
     drawn on, because a rule that also draws a table cell or a lane block is a
     boundary a reader has to see, not decoration. */
  --rule: rgba(21, 24, 28, 0.52);
  --warn-bg: #fdf3e3;
  --ok-bg: #eaf3ec;

  /* The text column, about 72 characters at the body size. Kept in rem rather
     than ch: ch resolves against each element's own font-size, so a .wrap
     inside a smaller-text landmark (the footer) drew a narrower, off-axis
     column than the header, main and pager above it. */
  --measure: 48rem;
  --gutter: 16px;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181b;
    --fg: #e6e9ee;
    --muted: #a7aeb8;
    --accent: #82b4ef;
    --border: #6c7480;
    --code-bg: #1b1f25;

    --surface: #1d2126;
    --accent-contrast: #10131a;
    --rule: rgba(230, 233, 238, 0.40);
    --warn-bg: #2a2418;
    --ok-bg: #18251c;
  }
}

:root[data-theme="dark"] {
  --bg: #15181b;
  --fg: #e6e9ee;
  --muted: #a7aeb8;
  --accent: #82b4ef;
  --border: #6c7480;
  --code-bg: #1b1f25;

  --surface: #1d2126;
  --accent-contrast: #10131a;
  --rule: rgba(230, 233, 238, 0.40);
  --warn-bg: #2a2418;
  --ok-bg: #18251c;
}

/* ---------- base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
  overflow-wrap: break-word;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 1.8em 0 0.5em; font-weight: 650; }
h1 { font-size: 1.85rem; margin-top: 0.6em; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p, ul, ol, dl { margin: 0 0 1em; }
li { margin: 0.3em 0; }
ul, ol { padding-left: 1.3em; }
strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

img, svg, iframe { max-width: 100%; }
img { height: auto; }

/* ---------- header, footer, pager ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding-top: 10px;
  padding-bottom: 10px;
}
.site-title { font-weight: 650; text-decoration: none; color: var(--fg); }
.site-title:hover { color: var(--accent); }
.header-tools { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 3em;
  padding: 1.2em 0 2.4em;
  color: var(--muted);
  font-size: 0.9rem;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  border-top: 1px solid var(--rule);
  margin-top: 2.5em;
  padding-top: 1em;
}
.pager a { display: inline-block; max-width: 100%; }
.pager .next { margin-left: auto; text-align: right; }
.pager .pager-label { display: block; color: var(--muted); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- small controls ---------- */

button {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 11px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button[aria-pressed="true"], button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
[hidden] { display: none !important; }

/* Labels bottom out at 0.875rem: html sets no font-size, so rem is the 16 px
   browser default and 0.875rem is the 14 px floor. The pill may wrap inside its
   own border on a narrow screen rather than push past the column. */
.timing {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 1em;
  padding: 1px 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.lede { font-size: 1.08rem; color: var(--fg); }
.meta-line { color: var(--muted); font-size: 0.92rem; margin: 0.2em 0 1.4em; }
.quote {
  border-left: 3px solid var(--accent);
  margin: 0 0 1.6em;
  padding: 0.1em 0 0.1em 14px;
  color: var(--muted);
}
.quote p { margin: 0 0 0.3em; }
.quote cite { font-style: normal; font-size: 0.9rem; }

/* ---------- code ---------- */

code, kbd, samp { font-family: var(--mono); font-size: 0.92em; font-size: max(0.92em, 0.875rem); }
p code, li code, td code, dd code {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}
kbd {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05em 0.35em;
  white-space: nowrap;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin: 0 0 1.2em;
  padding: 12px 14px;
  overflow-x: auto;
  position: relative;
  line-height: 1.5;
}
/* A code block inside a list item or table cell also matches the inline-code
   rule above; it is one block, not a chip per line. */
pre code { font-size: 0.875rem; white-space: pre; background: none; border: 0; padding: 0; }
pre[data-lang] { padding-top: 26px; }
pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 1px 8px;
  font-family: var(--mono);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface);
  border-left: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  border-radius: 0 var(--radius) 0 var(--radius);
}

/* The script wraps each bash block in .code-copy and adds the button. The
   wrapper takes over the block's bottom margin; the language label steps left
   by the button's fixed width so the two sit side by side. */
.code-copy { position: relative; margin: 0 0 1.2em; }
.code-copy pre { margin: 0; }
.code-copy pre[data-lang]::before { right: 4.5rem; border-radius: 0 0 0 var(--radius); }
.copy-button {
  position: absolute;
  top: 0;
  right: 0;
  width: 4.5rem;
  padding: 0 0 1px;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-align: center;
  background: var(--surface);
  border-color: var(--rule);
  border-radius: 0 var(--radius) 0 0;
}

/* ---------- callouts ---------- */

.callout {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  margin: 0 0 1.3em;
}
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title {
  display: block;
  font-weight: 650;
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35em;
}
.callout.note { border-left-color: var(--accent); }
.callout.warning { border-left-color: var(--border); background: var(--warn-bg); }
.callout.done-when { border-left-color: var(--accent); background: var(--ok-bg); }

/* ---------- figures ---------- */

.figure { margin: 1.6em 0; padding: 0; }
/* Figures are drawn in a ~360-unit viewBox so their labels stay at least 14px
   on a 390px screen. The cap keeps them from outgrowing the text on a desktop. */
.figure svg { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; background: var(--bg); }
.figure figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.6em;
  border-top: 1px solid var(--rule);
  padding-top: 0.5em;
}

/* ---------- video card ---------- */

.video {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  margin: 0 0 1.5em;
}
.video > :last-child { margin-bottom: 0; }
.video .video-kicker {
  display: block;
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35em;
}
.video .video-title { font-weight: 650; }
.video .video-meta { color: var(--muted); font-size: 0.9rem; margin: 0.3em 0 0; }
.video-thumb {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0.7em 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
  position: relative;
  cursor: pointer;
  /* A locally drawn panel, not a remote thumbnail: the aspect ratio gives it
     the shape the iframe will take when the reader presses Play. */
  aspect-ratio: 16 / 9;
}
.video-thumb .video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-weight: 650;
  font-size: 0.95rem;
}
.video-frame { margin: 0.7em 0 0; }
.video-frame iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- quick check and reveals ---------- */

.quick-check { margin: 2em 0 0; }
.quick-check ol { padding-left: 1.2em; }

details.reveal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 12px;
  margin: 0 0 0.9em;
}
details.reveal[open] { padding-bottom: 12px; }
/* The disclosure triangle hangs outside the summary box; the margin makes room
   for it inside the reveal's padding instead of on top of its border. */
details.reveal > summary {
  cursor: pointer;
  font-weight: 650;
  list-style-position: outside;
  margin-left: 1em;
}
details.reveal > summary:hover { color: var(--accent); }
details.reveal > :not(summary) { margin-top: 0.7em; }
details.reveal > :last-child { margin-bottom: 0; }

/* ---------- tabs (Day 3 tracks) ---------- */

.tabs { margin: 1.6em 0; }
.tabs [role="tablist"] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
  margin-bottom: 1.2em;
}
.tabs [role="tab"] { white-space: nowrap; }
.tab-panel { margin: 0; }
.tab-panel > h3:first-child { margin-top: 0; }
.tabs-all .tab-panel { border-top: 1px solid var(--rule); padding-top: 0.6em; margin-top: 1.4em; }
.tabs-all .tab-panel:first-of-type { border-top: 0; margin-top: 0; }
/* Top-aligned: the tablist's own padding, rule and margin make it taller than
   the Show all button, so centring hung the button below the tab row. */
.tabs-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-bottom: 1em; }

/* ---------- lanes ---------- */

.lane { display: inline-flex; gap: 6px; align-items: center; }
.lane .lane-legend { color: var(--muted); font-size: 0.875rem; }
.lane-block {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 10px 12px 2px;
  margin: 0 0 1.2em;
}
.lane-block > .lane-name {
  display: block;
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5em;
}
:root[data-lane="swift"] .lane-kotlin { display: none; }
:root[data-lane="kotlin"] .lane-swift { display: none; }

/* ---------- progress ---------- */

.progress { list-style: none; padding: 0; margin: 0 0 1.2em; }
.progress li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-bottom: 1px solid var(--rule);
  padding: 8px 0;
  margin: 0;
}
.progress li:last-child { border-bottom: 0; }
.progress input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  flex: none;
}
.progress label { cursor: pointer; }
.progress-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 1em; }
.progress-transfer { width: 100%; min-height: 5.5em; font-family: var(--mono); font-size: 0.875rem;
  background: var(--code-bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.progress-summary { list-style: none; padding: 0; margin: 0 0 1em; }
.progress-summary li { border-bottom: 1px solid var(--rule); padding: 6px 0; }
.progress-note { color: var(--muted); font-size: 0.9rem; }

/* ---------- day cards, sources, tables ---------- */

.daycard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 1em;
  background: var(--surface);
}
.daycard h3 { margin: 0 0 0.3em; }
.daycard h3 a { text-decoration: none; }
.daycard h3 a:hover { text-decoration: underline; }
.daycard p { margin: 0 0 0.6em; }
.daycard .daycard-meta { color: var(--muted); font-size: 0.9rem; margin: 0; }

.sources { font-size: 0.92rem; }
.sources li { margin-bottom: 0.6em; }
/* An id or a short path stays whole on one line; a path longer than the line
   wraps inside its own box instead of pushing the page sideways. Code inside a
   link stays inline so the link underline still runs under it. */
.sources li > code { display: inline-block; max-width: 100%; line-height: 1.4; }

.table-scroll { overflow-x: auto; margin: 0 0 1.2em; }
table { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
/* Left, not centred: a grid wider than the column would centre its caption
   out of view until the reader scrolls sideways. */
caption { text-align: left; }
th, td { border: 1px solid var(--rule); padding: 7px 9px; text-align: left; vertical-align: top; }
th { background: var(--surface); }
/* A short command or tag in a grid cell stays whole: the grid scrolls sideways
   in its .table-scroll wrapper instead of splitting `swift test` over two lines.
   Long per-lane commands sit in lane divs and still wrap at their spaces. */
td > code { white-space: nowrap; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--fg);
  padding: 8px 12px;
  border: 1px solid var(--accent);
  z-index: 10;
}
.skip-link:focus { left: 8px; top: 8px; }

@media (max-width: 460px) {
  body { font-size: 16px; }
  h1 { font-size: 1.55rem; }
  .header-tools { margin-left: 0; width: 100%; }
}

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