/* Colours follow Peacemeal's own tokens (bmad-meal-planner src/ui/styles/tokens.css) so the case study feels like the app. */
:root {
  color-scheme: light;
  --bg: #fff8ef;
  --surface: #ffffff;
  --border: #f0e2cf;
  --text: #2b1d14;
  --muted: #6e5a4c;
  --accent: #c2410c;
  --accent-soft: #fdeadd;
  --edge: #8a7464;
  --tint: #fbf1e4;
  --radius: 14px;
  --measure: 680px;
  --wide: 880px;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #1c1612;
    --surface: #27201a;
    --border: #3a2f26;
    --text: #f6ece2;
    --muted: #bba898;
    --accent: #ff9461;
    --accent-soft: #3a2418;
    --edge: #bba898;
    --tint: #231c17;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

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

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 16px;
  background: var(--surface);
  padding: 8px 12px;
  z-index: 10;
}

/* Layout: one centred column (--wide) with a single left edge. Prose stops at a reading measure; stats, screenshots,
   tables and diagrams use the full column width. Everything starts at the same left edge. */
main {
  --col-left: max(0px, calc((100% - var(--wide)) / 2));
  padding: 0 16px 64px;
}

main > * {
  max-width: var(--measure);
  margin-left: var(--col-left);
  margin-right: 0;
}

main > .wide {
  max-width: var(--wide);
}

/* Header */
.hero {
  padding: 56px 0 8px;
}

.eyebrow {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  margin: 0 0 12px;
}

.tagline {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.25rem;
  color: var(--muted);
}

h2 {
  font-size: 1.5rem;
  margin-top: 56px;
  margin-bottom: 12px;
  padding-top: 8px;
}

h3 {
  font-size: 1.125rem;
  margin-top: 36px;
  margin-bottom: 0;
}

h3 + .stats {
  margin-top: 12px;
}

.lead {
  font-size: 1.1875rem;
}

.cta {
  display: inline-block;
  margin: 4px 0 8px;
  padding: 10px 18px;
  border-radius: 9999px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-head);
  font-weight: 700;
  text-decoration: none;
}

.cta:hover {
  filter: brightness(1.08);
}

/* At a glance stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 0;
  margin-top: 28px;
  margin-bottom: 8px;
  list-style: none;
}

.stats li,
.stats li + li {
  margin-top: 0;
}

.stats li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.stats strong {
  display: block;
  font-family: var(--font-head);
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--accent);
}

.stats span {
  color: var(--muted);
  font-size: 0.875rem;
  display: block;
  line-height: 1.35;
  margin-top: 4px;
}


ul,
ol {
  padding-left: 1.25em;
}

/* Contents: numbered section links; two columns where there is room. */
.toc {
  margin-top: 28px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toc-title {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc ol {
  margin: 0;
  font-size: 0.9375rem;
}

.toc li + li {
  margin-top: 4px;
}

.toc a {
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

@media (min-width: 640px) {
  .toc ol {
    columns: 2;
    column-gap: 32px;
  }

  .toc li {
    break-inside: avoid;
  }
}

h2[id] {
  scroll-margin-top: 16px;
}

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

li + li {
  margin-top: 6px;
}

.callout {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.callout p {
  margin: 0;
}

/* Screenshots: phone shots in a row that wraps, captions under each. */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin-top: 32px;
  margin-bottom: 8px;
}

.shots figure {
  margin: 0;
}

.shots img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
}

figcaption {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
  margin-top: 8px;
}

/* Tables scroll inside their own box on narrow screens, never the page. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9375rem;
  line-height: 1.45;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: 0;
}

th {
  font-family: var(--font-head);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--tint);
}

/* Metrics: one row per funnel stage; each metric in a row is named in bold on its own line. */
.metrics th.stage {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  background: none;
  white-space: nowrap;
}

.metrics tr:last-child th {
  border-bottom: 0;
}

.metrics td p {
  margin: 0;
}

.metrics td p + p {
  margin-top: 8px;
}

.metrics .when {
  color: var(--muted);
  min-width: 190px;
}

.metrics .north-star th,
.metrics .north-star td {
  background: var(--accent-soft);
}

/* Phones: each stage becomes a small stacked card: stage label, metrics, then the time frame. */
@media (max-width: 560px) {
  .metrics thead {
    position: absolute;
    left: -9999px;
  }

  .metrics,
  .metrics tbody,
  .metrics tr,
  .metrics th,
  .metrics td {
    display: block;
  }

  .metrics tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .metrics tr:last-child {
    border-bottom: 0;
  }

  .metrics tr.north-star {
    background: var(--accent-soft);
  }

  .metrics th,
  .metrics td,
  .metrics .north-star th,
  .metrics .north-star td {
    padding: 0;
    border: 0;
    background: none;
    min-width: 0;
  }

  .metrics th.stage {
    font-family: var(--font-head);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 4px;
  }

  .metrics .when {
    margin-top: 8px;
    font-size: 0.875rem;
  }

  .metrics .when::before {
    content: 'Time frame';
    display: block;
    font-weight: 600;
  }

  .metrics .when p + p {
    margin-top: 2px;
  }
}

.decisions td {
  min-width: 150px;
}

.decisions td:first-child {
  min-width: 0;
  font-weight: 600;
}

.decisions td:last-child {
  color: var(--muted);
}

/* Phones: each decision becomes a stacked card with small labels, so no column is hidden off-screen. */
@media (max-width: 560px) {
  .decisions thead {
    position: absolute;
    left: -9999px;
  }

  .decisions,
  .decisions tbody,
  .decisions tr,
  .decisions td {
    display: block;
  }

  .decisions tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .decisions tr:last-child {
    border-bottom: 0;
  }

  .decisions td,
  .decisions td:first-child {
    padding: 0;
    border: 0;
    min-width: 0;
  }

  .decisions td:first-child {
    font-family: var(--font-head);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
  }

  .decisions td + td {
    margin-top: 6px;
  }

  .decisions td:nth-child(2)::before,
  .decisions td:nth-child(3)::before,
  .decisions td:nth-child(4)::before {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
  }

  .decisions td:nth-child(2)::before {
    content: 'What I chose';
  }

  .decisions td:nth-child(3)::before {
    content: 'Why';
  }

  .decisions td:nth-child(4)::before {
    content: 'Turned down';
  }
}

/* Diagrams: drawn at 760 wide; on phones they scroll sideways in their own box. */
.diagram {
  margin-top: 24px;
  margin-bottom: 8px;
}

.diagram .scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px;
}

.diagram svg {
  display: block;
  width: 100%;
  min-width: 640px;
  height: auto;
  font-family: var(--font-body);
}

.d-title {
  font-size: 15px;
  font-weight: 600;
  fill: var(--text);
}

.d-name {
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
}

.d-sub {
  font-size: 11.5px;
  fill: var(--muted);
}

.d-sub.on {
  fill: var(--text);
}

.d-box {
  fill: none;
  stroke: var(--edge);
  stroke-width: 1.25;
}

.d-box.main {
  fill: var(--accent);
  fill-opacity: 0.12;
  stroke: var(--accent);
  stroke-width: 2;
}

.d-zone {
  fill: var(--tint);
  stroke: var(--edge);
  stroke-width: 1;
}

.d-lines {
  fill: none;
  stroke: var(--edge);
  stroke-width: 1.25;
}

.d-head {
  fill: var(--edge);
}

.scroll-hint {
  display: none;
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 6px;
}

@media (max-width: 680px) {
  .scroll-hint {
    display: block;
  }
}



footer {
  border-top: 1px solid var(--border);
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: 0.875rem;
}

footer p {
  max-width: var(--wide);
  margin: 0 auto;
}

/* Phones: the four stat tiles sit two by two. */
@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
