/* 2026-10-08 (Brenden's brief, docs/briefs/2026-10-08-demo-library.md): the demo library. The
   featured grid on /capabilities/ (#library), /demos/ and each /demos/<slug>/ page. Loaded only by
   those pages. Markup is written by docs/QA/render-demos.py from docs/content/demos.json;
   behaviour is assets/demo-library.js.

   The palette is scoped: the --dl-* properties name roles in this section, not colours, so the
   owner can retune it in one place and data-variant="soft" flips the whole section for
   comparison. Values beyond the :root tokens are Brenden's recorded exception for these pages:
   #bdccbf (already the dark CTA's text), #9cc2ad, #c08a2e (amber, used only for the human-
   decision dot), #f4f3ee, #dfe5d8, and :root colours at an alpha. Recheck contrast after any
   retune; muted text and chip text are the pairs most likely to fail. Since 2026-10-12 the site kit
   (site.css) sets --dark to pine, the buttons and the heading face; the ratios below are against pine. */
.demo-library {
  --dl-band: var(--dark);                       /* section background */
  --dl-ink: var(--ivory);                       /* titles, primary text */
  --dl-muted: #bdccbf;                          /* descriptions, captions; 7.5:1 on --dark */
  --dl-accent: #9cc2ad;                         /* eyebrows, category labels; 6.4:1 on --dark */
  --dl-line: rgba(250, 249, 245, .16);          /* dividers, poster border */
  --dl-control-line: rgba(250, 249, 245, .44);  /* chip and field outlines; 3.6:1 on --dark */
  --dl-chip-bg: rgba(250, 249, 245, .10);       /* tool chips */
  --dl-chip-fg: var(--ivory);
  --dl-panel: rgba(250, 249, 245, .05);         /* custom-workflow card */
  --dl-button-bg: var(--ivory);                 /* primary button on the band */
  --dl-button-fg: var(--dark);
  --dl-shadow: 0 24px 56px rgba(0, 0, 0, .38);
  --dl-decision: #c08a2e;                       /* amber: the human-decision marker, nothing else */
  --dl-poster-ground: #f4f3ee;                  /* behind a poster while it loads */
  --dl-pill: rgba(18, 43, 34, .86);             /* the Watch pill on the poster */
  background: var(--dl-band);
  color: var(--dl-ink);
}
.demo-library[data-variant="soft"] {
  --dl-band: var(--soft); --dl-ink: var(--ink); --dl-muted: var(--muted);
  --dl-accent: var(--forest); --dl-line: var(--line); --dl-control-line: rgba(34, 38, 31, .6);   /* 3.9:1 on --soft */
  --dl-chip-bg: #dfe5d8; --dl-chip-fg: var(--forest); --dl-panel: var(--ivory);
  --dl-button-bg: var(--forest); --dl-button-fg: var(--ivory);
  --dl-shadow: 0 20px 48px rgba(30, 65, 40, .12);
}
.demo-library p { color: var(--dl-muted); }
.demo-library .eyebrow { color: var(--dl-accent); }
.demo-library .text-link { color: var(--dl-ink); border-color: currentColor; }
.demo-library :focus-visible { outline-color: var(--dl-ink); }
.demo-library > .section.editorial-section, .demo-index > .section { padding-top: 96px; padding-bottom: 88px; }

/* Filter row: chips left, count right, a rule beneath. */
.demo-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 20px; margin-bottom: 40px; border-bottom: 1px solid var(--dl-line); }
.demo-filters { display: flex; flex-wrap: wrap; gap: 10px; min-width: 0; }
.demo-filters button, .demo-player-fullscreen {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--dl-control-line);
  border-radius: 999px;
  color: var(--dl-ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.demo-filters button[aria-pressed="true"] { background: var(--dl-ink); border-color: var(--dl-ink); color: var(--dl-band); }
.demo-filters button:focus-visible { outline-offset: 2px; }
.demo-count { flex: none; font-size: 14px; color: var(--dl-muted); }
.demo-count:empty { display: none; }

/* Cards have no box: the poster is the object and the words sit on the band. */
.demo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 28px; }
.demo-card { display: flex; flex-direction: column; min-width: 0; }
.demo-card-poster {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--dl-line);
  border-radius: 16px;
  background: var(--dl-poster-ground);
  box-shadow: var(--dl-shadow);
  transition: transform .25s ease;
}
.demo-card-poster img { width: 100%; height: 100%; object-fit: cover; }
.demo-card-watch {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  background: var(--dl-pill);
  color: var(--ivory);
  font-size: 12.5px;
  font-weight: 500;
  transition: background .25s, color .25s;
}
.demo-card-play { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--forest); color: var(--ivory); }
.demo-card-play svg { width: 14px; height: 14px; }
.demo-card-poster:focus-visible { transform: translateY(-4px); }
.demo-card-poster:focus-visible .demo-card-watch { background: var(--ivory); color: var(--dark); }
@media (hover: hover) {
  .demo-card-poster:hover { transform: translateY(-4px); }
  .demo-card-poster:hover .demo-card-watch { background: var(--ivory); color: var(--dark); }
}
.demo-card-body { padding-top: 20px; }
.demo-card-category { display: block; margin-bottom: 8px; color: var(--dl-accent); font-size: 11.5px; font-weight: 500; letter-spacing: .2em; }
.demo-library .demo-card-title { color: var(--dl-ink); font-size: 22px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.demo-card-desc { margin-top: 10px; font-size: 14.5px; line-height: 1.6; }
.demo-card-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.demo-card-tools li { padding: 4px 11px; border-radius: 999px; background: var(--dl-chip-bg); color: var(--dl-chip-fg); font-size: 12px; font-weight: 500; }
.demo-card-gate { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12.5px; }
.demo-card-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--dl-decision); }

/* The ninth cell: the custom-workflow prompt (compact in the /demos/ rail). Brenden, 2026-10-08: on the
   palest green so it stands out from the band, inside it the light palette (ink, a forest eyebrow and
   button), no body text, and in the grid the size and shadow of a video thumbnail, at the top of its
   row. If a narrow column cannot hold the words at 16:9, the card grows to fit them. */
.demo-library .demo-custom {
  --dl-ink: var(--ink); --dl-muted: var(--prose); --dl-accent: var(--forest); --dl-line: var(--line);
  --dl-button-bg: var(--pine); --dl-button-fg: var(--ivory);
  display: flex;
  flex-direction: column;
  padding: 5.5% 6%;                 /* of the card's width: about 23px in a wide column, 16px in a narrow one */
  border: 1px solid var(--dl-line);
  border-radius: 16px;
  background: var(--soft);
  box-shadow: var(--dl-shadow);
}
.demo-grid > .demo-custom { align-self: start; aspect-ratio: 16 / 9; container-type: inline-size; }
/* On the light band the card would vanish into its own colour, so there it sits on ivory. */
.demo-library[data-variant="soft"] .demo-custom { background: var(--ivory); }
.demo-custom .eyebrow { margin-bottom: 10px; }
.demo-library .demo-custom h3, .demo-library .demo-custom h2 { margin-bottom: 8px; color: var(--dl-ink); font-size: 24px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
.demo-custom p { margin-bottom: 16px; font-size: 14px; line-height: 1.5; }
.demo-library .demo-custom-button { width: 100%; min-height: 52px; margin-top: auto; padding: 12px 20px; border-color: var(--dl-button-bg); background: var(--dl-button-bg); color: var(--dl-button-fg); font-size: 16px; }
.demo-library .demo-custom-button:hover { border-color: var(--pine-deep); background: var(--pine-deep); }
/* A narrow column (a tablet's three, a phone's one): tighter type so the words still fit at 16:9. */
@container (max-width: 380px) {
  .demo-custom .eyebrow { margin-bottom: 6px; }
  .demo-library .demo-custom h3 { margin-bottom: 6px; font-size: 20px; }
  .demo-custom p { margin-bottom: 12px; font-size: 13px; }
}
.demo-custom.is-compact { padding: 22px; }
.demo-library .demo-custom.is-compact h2 { font-size: 22px; text-wrap: balance; }
/* The rail is narrow: a 14px label that may wrap (on one line it ran into the button's edge below 1300px). */
.demo-library .demo-custom.is-compact .demo-custom-button { min-height: 48px; padding: 12px 14px; gap: 10px; font-size: 14px; text-align: left; }


/* The player: one native dialog per page. Always the dark treatment, whatever the section's variant. */
.demo-player {
  --dl-ink: var(--ivory); --dl-muted: #bdccbf; --dl-accent: #9cc2ad;
  --dl-line: rgba(250, 249, 245, .16); --dl-control-line: rgba(250, 249, 245, .44); --dl-chip-bg: rgba(250, 249, 245, .10);
  /* As wide as the window allows, but no wider than lets the video and everything under it (about 380px
     with the margins) fit the window's height, so a short window does not have to scroll. */
  width: min(1100px, calc(100vw - 80px), max(360px, calc((100vh - 380px) * 16 / 9)));
  width: min(1100px, calc(100vw - 80px), max(360px, calc((100dvh - 380px) * 16 / 9)));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 0;
  background: transparent;
  color: var(--dl-ink);
}
/* Near-opaque: the player has no panel of its own, so its words sit directly on this. */
.demo-player::backdrop { background: rgba(18, 43, 34, .97); }
.demo-player :focus-visible { outline-color: var(--ivory); }
.demo-player p { color: var(--dl-muted); }
.demo-player-shell { display: grid; gap: 18px; padding: 4px; }
/* The counter and the close button stay in view whenever the player scrolls. */
.demo-player-top { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 16px; background: var(--dark); box-shadow: 0 0 0 4px var(--dark); }
.demo-player-counter { flex: 1; min-width: 0; font-size: 14px; }
.demo-player-hint { font-size: 12.5px; color: var(--dl-muted); }
.demo-player-close, .demo-player-step {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--dl-control-line);
  border-radius: 50%;
  color: var(--ivory);
  transition: background .2s;
}
.demo-player-close svg, .demo-player-step svg { width: 20px; height: 20px; }
.demo-player-frame { overflow: hidden; border-radius: 12px; background: var(--dark); box-shadow: 0 32px 80px rgba(0, 0, 0, .45); }
.demo-player-frame video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: var(--dark); }
.demo-player-info { display: flex; align-items: flex-start; justify-content: space-between; gap: 32px; }
.demo-player-text { min-width: 0; max-width: 600px; }
.demo-player-meta { color: var(--dl-accent); font-size: 11.5px; font-weight: 500; letter-spacing: .2em; }
.demo-library p.demo-player-meta, .demo-player p.demo-player-meta { color: var(--dl-accent); }
.demo-player .demo-player-title { margin-top: 8px; color: var(--ivory); font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -.015em; }
.demo-player-caption { margin-top: 10px; font-size: 15px; line-height: 1.6; }
.demo-player-walkthrough { margin-top: 18px; font-size: 14px; }
/* What the video shows, step by step: collapsed in the player, a section of its own on a demo's page. */
.demo-transcript { margin-top: 12px; }
.demo-transcript summary { display: flex; align-items: center; min-height: 44px; color: var(--dl-ink); font-size: 14px; font-weight: 500; cursor: pointer; }
.demo-transcript ol, .demo-transcript-list { display: grid; gap: 8px; margin: 4px 0 6px; padding-left: 22px; color: var(--dl-muted); font-size: 14.5px; line-height: 1.6; }
.demo-transcript-section { margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--dl-line); }
.demo-library .demo-transcript-section h2 { margin-bottom: 14px; color: var(--dl-ink); font-size: 24px; line-height: 1.2; }
.demo-transcript-list { max-width: 760px; font-size: 16px; }
.demo-player-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; flex: none; }
.demo-player-fullscreen { display: inline-flex; align-items: center; gap: 9px; padding: 0 16px 0 13px; }
.demo-player-fullscreen svg { width: 19px; height: 19px; }
.demo-player-steps { display: flex; align-items: center; gap: 10px; }
.demo-player-next { max-width: 210px; font-size: 12.5px; line-height: 1.45; }
@media (hover: hover) {
  .demo-filters button[aria-pressed="false"]:hover, .demo-player-close:hover, .demo-player-step:hover, .demo-player-fullscreen:hover { background: var(--dl-chip-bg); }
}
@media (hover: none) {
  .demo-player-hint { display: none; }
}
/* Scroll lock while the player is open; demo-library.js pins the body (iOS ignores overflow alone). */
html.demo-player-open { overflow: hidden; }

/* A demo's own page: the player inline on the band. */
.demo-detail > .section { padding-top: 40px; padding-bottom: 88px; }
.demo-detail > .section > * { max-width: 1100px; }
.demo-library .demo-back { color: var(--dl-muted); margin-bottom: 36px; }
.demo-library .demo-detail-title { margin: 10px 0 28px; color: var(--dl-ink); font-size: clamp(38px, 4.4vw, 60px); line-height: 1.06; }
.demo-detail .demo-player-frame { box-shadow: var(--dl-shadow); }
.demo-detail .demo-player-info { margin-top: 26px; }
.demo-detail .demo-player-caption { margin-top: 0; color: var(--dl-ink); font-size: 18px; }
.demo-detail-desc { margin-top: 14px; font-size: 16px; line-height: 1.7; }
.demo-detail-steps { display: flex; justify-content: space-between; gap: 24px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--dl-line); }
.demo-detail-step { display: inline-flex; align-items: center; gap: 14px; min-height: 44px; color: var(--dl-ink); font-size: 15px; font-weight: 500; }
.demo-detail-step.is-next { margin-left: auto; text-align: right; }
.demo-detail-step small { display: block; color: var(--dl-muted); font-size: 12px; font-weight: 400; }
.demo-detail-step svg { width: 22px; height: 22px; transition: transform .2s; }
@media (hover: hover) {
  .demo-detail-step.is-next:hover svg { transform: translateX(5px); }
  .demo-detail-step.is-prev:hover svg { transform: translateX(-5px); }
}

/* /demos/: a light hero, then the groups beside a rail. */
.demo-hero-intro { max-width: 640px; margin-top: 28px; font-size: 18px; line-height: 1.65; }
.demo-hero-count { margin-top: 16px; font-size: 14px; }
.demo-index-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px; align-items: start; }
/* min-width: 0 so a row that scrolls inside its own box (the phone pills) never widens the page. */
.demo-index-layout > *, .demo-rail > * { min-width: 0; }
.demo-rail { position: sticky; top: 120px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.demo-rail-nav ul { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--dl-line); }
.demo-rail-nav a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--dl-line); color: var(--dl-muted); font-size: 15px; }
.demo-rail-nav a span { font-size: 13px; }
.demo-rail-nav a[aria-current="true"] { color: var(--dl-ink); font-weight: 500; box-shadow: inset 3px 0 0 var(--dl-ink); padding-left: 14px; }
@media (hover: hover) { .demo-rail-nav a:hover { color: var(--dl-ink); } }
.demo-search input { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--dl-control-line); border-radius: 3px; background: transparent; color: var(--dl-ink); font-size: 15px; }
.demo-search input::placeholder { color: var(--dl-muted); opacity: 1; }
.demo-groups > .demo-count { margin-bottom: 24px; }
.demo-group + .demo-group { margin-top: 64px; }
.demo-library .demo-group-title { margin-bottom: 26px; color: var(--dl-ink); font-size: 28px; }
.demo-group-title span { margin-left: 6px; color: var(--dl-muted); font-size: 15px; letter-spacing: 0; }
.demo-index .demo-grid { gap: 36px 24px; }
.demo-empty { font-size: 16px; }
.demo-custom.after-groups { display: none; margin-top: 56px; }

@media (max-width: 1150px) {
  .demo-index-layout { grid-template-columns: 210px minmax(0, 1fr); gap: 40px; }
  .demo-index .demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .demo-index-layout { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .demo-rail { position: static; gap: 16px; }
  /* Above the demos the rail turns into one scrolling row of pills, and the custom-workflow
     panel moves below the groups. */
  .demo-rail-nav ul { display: flex; gap: 8px; margin: -6px; padding: 6px; overflow-x: auto; border: 0; scrollbar-width: none; }
  .demo-rail-nav ul::-webkit-scrollbar { display: none; }
  .demo-rail-nav a { flex: none; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--dl-control-line); border-radius: 999px; color: var(--dl-ink); font-size: 14px; white-space: nowrap; }
  .demo-rail-nav a[aria-current="true"] { padding-left: 16px; box-shadow: none; background: var(--dl-ink); border-color: var(--dl-ink); color: var(--dl-band); }
  .demo-rail-nav a span { color: inherit; opacity: .75; }
  .demo-custom.in-rail { display: none; }
  .demo-custom.after-groups { display: flex; }
  .demo-player-info { flex-direction: column; gap: 22px; }
  .demo-player-actions { align-items: stretch; width: 100%; }
}
/* A short, wide window (a phone on its side, most laptops): the video on the left, sized to the height
   and at most 62% of the width, and the words and controls beside it, so nothing has to scroll below
   the video and the words keep a readable column. */
@media (max-height: 800px) and (min-aspect-ratio: 8/5) {
  .demo-player { width: min(1400px, calc(100vw - 32px)); }
  .demo-player-shell { grid-template-columns: auto minmax(0, 1fr); column-gap: 24px; align-items: start; }
  .demo-player-top { grid-column: 1 / -1; }
  .demo-player-frame { width: min(62vw, calc((100vh - 120px) * 16 / 9)); width: min(62vw, calc((100dvh - 120px) * 16 / 9)); }
  .demo-player-info { flex-direction: column; gap: 18px; }
  .demo-player-actions { align-items: stretch; width: 100%; }
  .demo-player .demo-player-title { font-size: 22px; }
}
@media (max-width: 699px) {
  .demo-library > .section.editorial-section, .demo-index > .section { padding-top: 56px; padding-bottom: 64px; }
  .demo-grid, .demo-index .demo-grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .demo-filter-row { flex-direction: column; align-items: stretch; gap: 14px; }
  /* The chips scroll sideways in their own box; the padding keeps focus rings inside it. */
  .demo-filters { flex-wrap: nowrap; overflow-x: auto; margin: -6px; padding: 6px; scrollbar-width: none; }
  .demo-filters::-webkit-scrollbar { display: none; }
  .demo-player { width: calc(100vw - 32px); }
  .demo-player .demo-player-title { font-size: 24px; }
  .demo-player-steps { display: grid; grid-template-columns: 1fr 1fr; }
  .demo-player-step { width: 100%; border-radius: 999px; }
  .demo-player-next { grid-column: 1 / -1; max-width: none; }
  .demo-detail-steps { flex-direction: column; }
  .demo-detail-step.is-next { margin-left: 0; text-align: left; flex-direction: row-reverse; justify-content: flex-end; }
}

/* Reduced motion and the page's paused state: no hover lift and no transitions. */
@media (prefers-reduced-motion: reduce) {
  .demo-card-poster:hover, .demo-card-poster:focus-visible { transform: none; }
}
html[data-motion="paused"] .demo-card-poster, html[data-motion="paused"] .demo-card-watch,
html[data-motion="paused"] .demo-filters button, html[data-motion="paused"] .demo-detail-step svg { transition: none; }
html[data-motion="paused"] .demo-card-poster:hover, html[data-motion="paused"] .demo-card-poster:focus-visible { transform: none; }

@media print {
  .demo-filters, .demo-player, .demo-search, .demo-player-fullscreen { display: none !important; }
  .demo-library { --dl-band: transparent; --dl-ink: var(--ink); --dl-muted: var(--muted); --dl-accent: var(--forest); --dl-line: var(--line); --dl-shadow: none; }
}
