/* ── The theme demo player (/live/demo/<themeId>, client/live/demo.ts) ──────────────────────────────────────────────────────────
   Loaded after live.css, and only by the demo page: /live itself downloads none of this.
   /live's layers, HUD and controls bar, in demo form: a DEMO chip where LIVE is, the theme's name and mood with a SAMPLE tag, and a bar
   that flips through the themes, replays, pauses and tries a name. No sponsor unit exists on the page. Everything is scoped to
   .live[data-demo] or a demo- class, so the broadcast's rules (live.css) are untouched.
   Three bar layouts: a phone (the base: three rows, the name form folded behind its toggle), a tablet or small laptop (two rows),
   and a wide screen or a phone held sideways (one row). The top bar carries "All themes" and "Use this theme" from 768 px (720 px
   on a phone held sideways); below that the bar does. Both stay in fullscreen: the player's job is to lead to a booking. */

/* The demo holds the finished card (the director waits HOLD_MS, then plays the entrance again), so the segment has no exit. */
.live[data-demo] .live-seg:not(.is-leaving) { animation: none; }
.live[data-demo][data-motion="reduce"] .live-seg:not(.is-settled):not(.is-leaving) { animation: live-in 250ms linear calc(0ms - var(--o, 0ms)) both; }

/* Top bar: the theme pill and "All themes" are glass like live.css's own pills (the group at .live-hud__brand). */
.live-hud__theme, .live-hud__alt {
  background: var(--live-glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid rgb(255 255 255 / .12);
  color: var(--ink);
}
.live-chip--demo { color: var(--ink-2); letter-spacing: .14em; }
.live-hud__theme {
  display: grid; gap: 2px; min-width: 0; flex: 0 1 auto;
  padding: 6px 16px 6px; border-radius: 22px;
}
.live-hud__theme b { font: 800 15px/1.15 var(--font-display); letter-spacing: -.005em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-hud__sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.live-hud__mood { min-width: 0; font: 500 12px/1.2 var(--font-ui); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The SAMPLE tag (the landing's monitors carry one): the greeting on stage is the theme's own sample, whoever is looking. It lives in the
   theme pill so it takes no room of its own at 320 px, and it never sits over the card. Its other words are for a screen reader. */
.live-hud__sample {
  flex: none; padding: 2px 6px 1px; border-radius: 4px; background: rgb(255 255 255 / .12);
  font: 700 10px/1.2 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap;
}
/* The theme demo's view count (shared/demo-views.ts) follows the mood, set off by a dot that is drawn here (its alt text keeps a screen reader from
   reading it out). It never shrinks. Where the line is tight it drops before the mood does (below 560 px), except from 768 px up, where the
   mood gives way to it (below). A phone's pill holds the name and the SAMPLE tag and nothing else. */
.live-hud__views { flex: none; font: 500 12px/1.2 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.live-hud__views::before { content: "\00b7"; content: "\00b7" / ""; margin-inline-end: 8px; }
.live-hud__sample-more { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); }
.live-hud__alt, .live-hud__use { display: none; }
.live-hud__alt {
  flex: none; align-items: center; min-height: 36px; margin-inline-start: auto; padding: 0 16px; border-radius: var(--radius-pill);
  font: 700 13px/1 var(--font-ui); color: var(--ink); text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out);
}
.live-hud__alt:hover { background: color-mix(in srgb, var(--night-950) 40%, rgb(255 255 255 / .14)); }
.live-hud__alt:focus-visible { outline: 2px solid var(--candle); outline-offset: 2px; }
.live[data-demo] .live-hud__book { margin-inline-start: 0; }
.live-hud__use .icon { width: 16px; height: 16px; flex: none; }

/* The bar and the name popover are a little more solid than /live's glass: the controls sit over every theme's art, bright or busy. */
.demo-ctl { background: color-mix(in srgb, var(--night-950) 76%, transparent); }
.live[data-sky-scheme="light"] .demo-ctl { background: color-mix(in srgb, var(--night-900) 86%, transparent); }

/* A phone: the mood would only ever show its first words, so the pill is the name and the SAMPLE tag under it. */
@media (max-width: 479px) {
  .live-hud__mood { display: none; }
  .live-hud__theme { padding-inline: 14px; }
  .live-hud__theme b { font-size: 14px; }
}
@media (max-width: 559px) { .live-hud__views { display: none; } }
@media (max-width: 359px) {
  .live-chip--demo { padding-inline: 9px; letter-spacing: .08em; }
  .live-hud__theme { padding-inline: 11px; }
}

/* A tablet held upright: the top bar carries both links, and the pill is left a few letters of mood beside the views, so it is the views that stay. */
@media (min-width: 768px) and (max-width: 839px) { .live-hud__mood { display: none; } }

/* The controls bar: a phone's three rows (the base). The name form is a popover over the bar once "Try a name" opens it. */
.live[data-demo] { --demo-dock: calc(max(14px, env(safe-area-inset-bottom)) + 172px); }
.live[data-demo] .live-seg { padding-bottom: var(--demo-dock); }
.demo-ctl {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "play tools" "pick toggle" "links links";
  align-items: center; gap: 6px;
  width: calc(100% - 24px); max-width: 560px; padding: 6px;
  border-radius: 26px;
  bottom: max(14px, env(safe-area-inset-bottom));
}
.demo-ctl__play, .demo-ctl__tools, .demo-ctl__links { display: flex; align-items: center; gap: 2px; }
.demo-ctl__play { grid-area: play; justify-content: flex-start; }
/* A phone's home for the view count (the top bar has no room below 560 px): the spare middle of the transport row, between the buttons and the
   tools. The transport row spans the bar and keeps clear of the tools (which sit over its end), so the count has everything between them: about
   44 px at 360, where "999.9K views" wraps inside itself ("999.9K" over "views"); one line from about 390. The buttons never shrink for it. */
.demo-ctl__views { flex: 1 1 0; min-width: 0; margin-inline-start: 2px; font: 500 12px/1.15 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: center; }
@media (max-width: 559px) { .demo-ctl__play { grid-column: 1 / -1; padding-inline-end: 92px; } }
@media (max-width: 359px) { .demo-ctl__play { padding-inline-end: 84px; } }
@media (max-width: 339px) { .demo-ctl__views { display: none; } }
.demo-ctl__tools { grid-area: tools; justify-content: flex-end; }
.demo-ctl__links { grid-area: links; gap: 6px; }
.demo-ctl { --demo-tool: 44px; }      /* a tool button's side: the two-row bar's tools column is sized from it (below) */
.demo-ctl .live-btn { width: var(--demo-tool); min-width: 0; padding: 0; }
.demo-ctl .live-btn__label {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.demo-ctl .live-btn .icon { width: 20px; height: 20px; }
.demo-ctl .live-btn[data-act="name"][aria-expanded="true"] { background: var(--candle); color: var(--night-900); }
/* "Try a name" is the one control of the bar that says its name on a phone: a bare pencil told nobody what it opens. */
.demo-ctl .live-btn.demo-ctl__name-toggle { width: auto; gap: 6px; padding: 0 14px 0 12px; font: 700 13px/1 var(--font-ui); }
.demo-ctl .demo-ctl__name-toggle .live-btn__label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
.demo-ctl .demo-ctl__name-toggle .icon { width: 18px; height: 18px; }
.demo-pick { grid-area: pick; display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; }
.demo-pick__label { display: none; font: 650 11px/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.demo-ctl .select.demo-pick__select, .demo-ctl .input.demo-name__input {
  min-height: 44px; border-radius: var(--radius-pill);
  border-color: rgb(255 255 255 / .16); background-color: rgb(255 255 255 / .07);
  font: 650 15px/1.2 var(--font-ui); color: var(--ink);
}
.demo-ctl .select.demo-pick__select { flex: 1; min-width: 0; padding: 0 38px 0 16px; background-position: right 13px center; text-overflow: ellipsis; }
.demo-ctl .select.demo-pick__select option { color: #111; background: #fff; }
.demo-ctl .select.demo-pick__select:hover, .demo-ctl .input.demo-name__input:hover { background-color: rgb(255 255 255 / .12); }
.demo-ctl__name-toggle { grid-area: toggle; }
.demo-name {
  display: none; grid-area: auto; margin: 0;
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 1;
  flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px;
  background: color-mix(in srgb, var(--night-950) 90%, transparent); -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid rgb(255 255 255 / .12); border-radius: 26px;
}
.demo-ctl[data-name-open] .demo-name { display: flex; }
.demo-name__lead { display: none; font: 650 11px/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.demo-ctl .input.demo-name__input { flex: 1; min-width: 0; width: auto; padding: 0 16px; font-weight: 500; }
.demo-name__show, .demo-name__reset {
  flex: none; min-height: 44px; border: 0; border-radius: var(--radius-pill); font: 700 14px/1 var(--font-ui); cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.demo-name__show { padding: 0 20px; background: rgb(255 255 255 / .18); color: var(--ink); }
.demo-name__show:hover { background: rgb(255 255 255 / .28); }
.demo-name__show[aria-busy="true"] { opacity: .6; cursor: progress; }
.demo-name__reset { padding: 0 12px; background: transparent; color: var(--candle); text-decoration: underline; text-underline-offset: 3px; }
.demo-name__reset[hidden] { display: none; }
.demo-name__show:active, .demo-name__reset:active { transform: scale(.97); }
.demo-name__show:focus-visible, .demo-name__reset:focus-visible, .demo-link:focus-visible, .demo-use:focus-visible { outline: 2px solid var(--candle); outline-offset: 2px; }
.demo-ctl .input.demo-name__input:focus-visible, .demo-ctl .select.demo-pick__select:focus-visible { outline: 2px solid var(--candle); outline-offset: 1px; }
/* The name check's answer (role=status, always in the form so an answer is announced). In the phone's popover it is a line under the
   field (the popover grows upward, the bar stays put); everywhere else it is a bubble over the bar, out of the layout (below). */
.demo-name__status { flex: 1 0 100%; margin: 0; padding: 2px 12px 4px; font: 600 13px/1.35 var(--font-ui); color: var(--ink); }
.demo-name__status:empty { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.demo-link, .demo-use {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-pill); font: 750 14px/1 var(--font-ui); letter-spacing: .01em; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out);
}
.demo-link { background: rgb(255 255 255 / .09); color: var(--ink); }
.demo-link:hover { background: rgb(255 255 255 / .16); }
.demo-use { flex: 1; background: var(--candle); color: var(--night-900); box-shadow: 0 6px 20px -8px color-mix(in srgb, var(--candle) 70%, transparent); }
.demo-use:hover { background: color-mix(in srgb, var(--candle) 82%, #fff); }
.demo-use .icon { width: 16px; height: 16px; flex: none; }
@media (max-width: 359px) {
  .demo-ctl .live-btn { width: 40px; }
  .demo-ctl .live-btn.demo-ctl__name-toggle { padding: 0 11px 0 9px; font-size: 12px; }
  .demo-ctl .select.demo-pick__select { padding: 0 30px 0 12px; background-position: right 10px center; }
  .demo-link, .demo-use { padding: 0 12px; font-size: 13px; }
}

/* A tablet or small laptop: two rows; from 768 px the top bar carries the two links, and the bar's own row goes. */
@media (min-width: 560px) {
  .live[data-demo] { --demo-dock: calc(max(14px, env(safe-area-inset-bottom)) + 124px); }
  /* Four columns: the tools (two buttons and their 2 px gap: the last column) keep to their own width, so the links under them (the third column
     takes what they need beyond it) can't widen them, and the theme picker, which spans the middle two, keeps the room between the buttons and the
     tools. Before, one column held both the tools and the links (274 px for two buttons), the picker was left 56 px and the tools box lay over it. */
  .demo-ctl {
    grid-template-columns: auto minmax(0, 1fr) auto calc(2 * var(--demo-tool) + 2px); grid-template-areas: "play pick pick tools" "name name links links";
    width: calc(100% - 2 * var(--live-pad-x)); max-width: 880px;
  }
  .demo-ctl .select.demo-pick__select { min-width: 7rem; }
  .demo-ctl .input.demo-name__input { min-width: 7rem; }
  .demo-ctl__name-toggle, .demo-ctl__views { display: none; }
  .demo-name { display: flex; flex-wrap: nowrap; position: static; grid-area: name; padding: 0; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; border-radius: 0; }
  .demo-name__lead { display: inline; }
  .demo-pick__label { display: inline; }
  .demo-ctl__links { justify-content: flex-end; }
  .demo-use { flex: none; }
  /* the answer floats over the bar, centred on it: it is a few words for a few seconds, not a row the bar must keep room for */
  .demo-name__status {
    position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 0; z-index: 1;
    width: max-content; max-width: min(420px, calc(100vw - 32px)); padding: 9px 18px; text-align: center;
    background: color-mix(in srgb, var(--night-950) 90%, transparent); -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
    border: 1px solid rgb(255 255 255 / .12); border-radius: 22px;
  }
  .demo-name__status:empty { padding: 0; border: 0; }
}
@media (min-width: 768px), (orientation: landscape) and (max-height: 500px) and (min-width: 720px) {
  .live-hud__alt, .live-hud__use, .live.is-fullscreen .live-hud__use { display: inline-flex; }    /* (live.css hides the broadcast's Book link in fullscreen: not this one) */
  .demo-ctl__links { display: none; }
  .demo-ctl { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "play pick tools" "name name name"; }
  .live[data-demo] { --demo-dock: calc(max(14px, env(safe-area-inset-bottom)) + 124px); }
}

/* While the two links are in the bar (560 to 767 px) the name form keeps its field and drops its lead-in ("Try a name"; the field says it too), and the
   links shrink to their words (no arrow, less padding), so the field keeps 7rem and more beside its buttons even when Reset is there. */
@media (min-width: 560px) and (max-width: 767px) {
  .demo-name__lead, .demo-use .icon { display: none; }
  .demo-link, .demo-use { padding: 0 12px; }
}

/* A wide screen: one row, every control with its label; the top bar shows the theme's mood beside its SAMPLE tag. */
@media (min-width: 1100px) and (min-aspect-ratio: 4/5) and (min-height: 560px) {
  .live[data-demo] { --demo-dock: calc(max(20px, env(safe-area-inset-bottom)) + 76px); }
  .demo-ctl {
    display: flex; flex-wrap: nowrap; gap: 6px; width: max-content; max-width: calc(100% - 2 * var(--live-pad-x)); padding: 6px;
    border-radius: var(--radius-pill); bottom: max(20px, env(safe-area-inset-bottom));
  }
  .demo-pick, .demo-name, .demo-ctl__tools { margin-inline-start: 4px; padding-inline-start: 10px; border-inline-start: 1px solid rgb(255 255 255 / .12); }
  /* the answer to a name sits right over the field */
  .demo-name { position: relative; min-width: 0; }
  .demo-name__status { bottom: calc(100% + 14px); }
  .demo-ctl .select.demo-pick__select { flex: 0 1 auto; width: auto; min-width: 240px; }      /* "Ministry of Birthdays" is the longest name; a popular theme's option ("… · #3 most popular") is longer, and the select is as wide as its widest option */
  .demo-ctl .input.demo-name__input { flex: 0 1 auto; min-width: 7rem; width: 150px; }
  .demo-name__lead { display: none; }
}
@media (min-width: 1360px) and (min-aspect-ratio: 4/5) and (min-height: 560px) {
  .demo-ctl .live-btn { width: auto; min-width: 44px; padding: 0 14px; }
  .demo-ctl .live-btn__label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
}
/* "Try a name" comes back only where the bar fits (1520 px): from 1360 to 1519 the bar is clamped to the screen and the lead-in (a decoration; the form and
   the field carry their own names) would take room from the picker and the field. */
@media (min-width: 1520px) and (min-aspect-ratio: 4/5) and (min-height: 560px) {
  .demo-name__lead { display: inline; }
}

/* A phone held sideways: one slim row over the bottom edge, as /live's own bar floats there. */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 720px) {
  .live[data-demo] { --demo-dock: calc(max(8px, env(safe-area-inset-bottom)) + 52px + 8px); }
  .live[data-demo] .live-seg { padding-bottom: var(--demo-dock); }
  .demo-ctl {
    display: flex; flex-wrap: nowrap; gap: 4px; padding: 4px; left: 50%; right: auto; transform: translateX(-50%);
    width: max-content; max-width: calc(100% - 16px); border-radius: var(--radius-pill); bottom: max(8px, env(safe-area-inset-bottom));
  }
  .live.controls-hidden .demo-ctl { transform: translate(-50%, 14px); }
  .live.controls-hidden .demo-ctl:focus-within { transform: translateX(-50%); }
  .demo-pick, .demo-name, .demo-ctl__tools { margin-inline-start: 2px; padding-inline-start: 8px; border-inline-start: 1px solid rgb(255 255 255 / .12); }
  .demo-pick { min-width: 150px; flex-shrink: 1000; }      /* the bar is clamped to the screen: the theme's name gives way first (down to its floor), then the field (down to 7rem), and the buttons never leave it */
  .demo-name { min-width: 0; }
  .demo-pick__label, .demo-name__lead { display: none; }
  /* the theme's name gives way first on a narrow screen (a 720 px phone), down to a third of "Ministry of Birthdays" */
  .demo-ctl .select.demo-pick__select { flex: 0 1 210px; width: auto; min-width: 150px; min-height: 40px; }
  .demo-ctl .input.demo-name__input { flex: 0 1 auto; min-width: 7rem; width: 170px; min-height: 40px; }
  /* the slim bar of /live's own short landscape layout: one line for the theme, its SAMPLE tag beside it */
  .live-hud__mood { display: none; }
  .live-hud__theme { display: flex; align-items: center; gap: 10px; padding: 6px 14px; }
  .live-hud__sub { flex: none; }      /* the name gives way first (its ellipsis), never the SAMPLE tag or the views */
  .demo-name__show, .demo-name__reset { min-height: 40px; }
  .demo-ctl .live-btn { width: 40px; min-height: 40px; }
}
@media (orientation: landscape) and (max-height: 500px) and (min-width: 720px) and (max-width: 767px) { .live-hud__views { display: none; } }
@media (forced-colors: active) {
  .demo-ctl .select.demo-pick__select, .demo-ctl .input.demo-name__input, .demo-name__show { border: 1px solid CanvasText; }
}
