/* Project pages: one long page per project, with a contents list beside its sections, laid out like
   shadcn's docs. Builds on site.css. */

/* Each project's colour, from its bloom. Used for the contents marker and link underlines, never for text. */
[data-project="tailwind"] { --project: var(--tw0); }
[data-project="tightnesspro"] { --project: var(--gr2); }
[data-project="halo-cards"] { --project: var(--ha0); }
[data-project="watts-up"] { --project: var(--wu1); }

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

/* The page's head sits close under its breadcrumb */
main[data-page="project"] { gap: 32px; }
main[data-page="project"] .doc { margin-top: 24px; }

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted-foreground); }
.crumbs a { color: inherit; text-decoration: none; transition: color .15s; }
.crumbs a:hover { color: var(--foreground); }
.crumbs svg { width: 14px; height: 14px; }
.crumbs [aria-current] { color: var(--foreground); }

/* ---- Placeholders: stand-ins for images until the real ones are added ---- */

.ph {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--ratio, 16 / 9);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  font: 500 12px/16px var(--font-mono);
  text-align: center;
}
/* A real image dropped in place of a placeholder */
.cover { display: block; width: 100%; height: auto; aspect-ratio: var(--ratio, 16 / 9); object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius); }

/* ---- Key facts: a row of small cards, one per fact ---- */

.facts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; margin: 0; }
.facts > div {
  min-width: 0; padding: var(--card-spacing);
  border-radius: calc(var(--radius) * 1.4);
  background: var(--card); box-shadow: var(--card-ring);
}
.facts dt { font-size: 13px; color: var(--muted-foreground); }
.facts dd { margin: 6px 0 0; font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---- Contents beside the sections ---- */

.doc { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px; align-items: start; }

/* Stays in view under the nav while the sections scroll past; the one being read is marked */
.toc { position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow-y: auto; }
.toc-title { margin: 0 0 8px; font-size: 13px; font-weight: 500; }
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc ol ol { padding-left: 12px; }
.toc a {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
  color: var(--muted-foreground);
  font-size: 14px; line-height: 1.4;
  text-decoration: none;
  transition: color .15s;
}
.toc ol ol a { font-size: 13px; }
.toc a::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 99px; background: transparent; transition: background .15s; }
.toc a:hover { color: var(--foreground); }
.toc a[aria-current="true"] { color: var(--foreground); font-weight: 500; }
.toc a[aria-current="true"]::before { background: var(--project, var(--foreground)); }

.sections { display: flex; flex-direction: column; gap: 48px; min-width: 0; }
.sections > section { scroll-margin-top: 80px; }

/* ---- Body copy: a reading column; .wide pieces run the full width of the sections ---- */

.prose {
  display: grid;
  grid-template-columns: min(68ch, 100%) minmax(0, 1fr);
  font-size: 16px;
  line-height: 1.75;
}
.prose > * { grid-column: 1; margin: 0 0 1em; min-width: 0; }
.prose > .wide { grid-column: 1 / -1; }
.prose > :last-child { margin-bottom: 0; }

.prose h2 { margin: 0 0 .6em; padding-bottom: .35em; border-bottom: 1px solid var(--border); font-size: clamp(24px, 2.6vw, 28px); font-weight: 600; line-height: 1.25; letter-spacing: -0.025em; }
.prose > h2 { grid-column: 1 / -1; }
.prose h3 { margin: 1.6em 0 .4em; font-size: 19px; font-weight: 600; line-height: 1.3; letter-spacing: -0.02em; scroll-margin-top: 80px; }
.prose h3 + * { margin-top: 0; }
.prose a { color: var(--foreground); font-weight: 500; text-decoration-color: var(--project, var(--border)); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose li::marker { color: var(--muted-foreground); }

.prose blockquote { padding: .2em 0 .2em 1.1em; border-left: 2px solid var(--border); color: var(--muted-foreground); font-size: 18px; font-style: italic; line-height: 1.6; }
.prose blockquote p { margin: 0; }

.prose figure img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose figcaption { margin-top: .6em; font-size: 13px; line-height: 1.5; color: var(--muted-foreground); text-align: center; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gallery figure { margin: 0; min-width: 0; }
/* Four small pictures in a row, two across on tablets and phones */
.gallery--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.prose code { padding: .15em .4em; border-radius: 6px; background: var(--muted); font: 500 .86em/1 var(--font-mono); }
.prose pre {
  overflow-x: auto;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  font: 13.5px/1.7 var(--font-mono);
}
.prose pre code { padding: 0; background: none; font: inherit; }

/* Tables: shadcn's, in a bordered box that scrolls sideways on phones */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.prose th { height: 40px; padding: 0 12px; border-bottom: 1px solid var(--border); background: color-mix(in oklch, var(--muted) 50%, transparent); text-align: left; font-weight: 500; white-space: nowrap; }
.prose td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover { background: color-mix(in oklch, var(--muted) 50%, transparent); }

/* Callout: shadcn's alert */
.callout { padding: 12px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--card-ring); font-size: 14px; line-height: 1.6; color: var(--muted-foreground); }
.callout strong:first-child { display: block; margin-bottom: 2px; font-weight: 500; color: var(--foreground); }

.to-top { align-self: flex-start; }

/* Narrower than the contents column plus a reading column: contents go above the sections, in a box */
@media (max-width: 900px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .toc { position: static; max-height: none; padding: var(--card-spacing); border-radius: calc(var(--radius) * 1.4); background: var(--card); box-shadow: var(--card-ring); }
  .facts { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .gallery--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .facts { gap: 12px; }
  .facts dd { font-size: 16px; }
  .sections { gap: 40px; }
  .prose blockquote { font-size: 17px; }
  .gallery { grid-template-columns: minmax(0, 1fr); }
  .gallery--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
