/* ---- "Bring your own AI." (#byo, js/byo.js): one pinned, scroll-driven stage. The heading on top, the parts as a
   stepper (RubberSegment, look .ds-seg) with a progress line that scrubs, a device in the centre that swaps in place
   (phone pages, then the tablet, then the laptop), Vivi's line beside it (.ds-answer) and today's facts (.ds-card +
   .ds-facts) with the current row lit. This file only places the design-system primitives (css/ds.css) and moves
   them: transform and opacity only; entrances from 0.97, ease-out in, ease-in out; reduced motion / Pause motion:
   instant. Colours are theme tokens (light and dark). */
.byo { --steps: 8; max-width: calc(var(--container-wide) + 2 * var(--gutter)); margin-inline: auto; padding: clamp(4rem, 8vw, 6rem) var(--gutter) 0; }
.byo-run { position: relative; height: calc(var(--steps) * 55dvh + 100dvh - var(--bar-h)); }
.byo-pin {
  position: sticky; top: var(--bar-h); height: calc(100dvh - var(--bar-h)); min-height: 30rem;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: clamp(0.6rem, 1.6dvh, 1.25rem); padding-block: clamp(0.75rem, 2.5dvh, 1.75rem);
}
.byo-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: 2rem; row-gap: 0.3rem;
  h2 { font-size: clamp(1.75rem, 1rem + 2.2 * var(--fl), 3rem); font-family: var(--font-display); font-weight: var(--display-wght); letter-spacing: var(--head-track); line-height: var(--head-lh); }
  .byo-line { max-width: 34rem; font-size: var(--step-0); } }
/* the stepper: centred, the progress line under it follows the scroll (scaleX, compositor only) */
.byo-steps { position: relative; display: grid; justify-items: center; gap: 0.45rem; min-width: 0; }
.byo-steps-host { max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.byo-steps-host > .ui-rubber-segment { width: max-content; }
.byo-progress { display: block; width: min(30rem, 100%); height: 2px; border-radius: 2px; background: var(--ds-divider, var(--line)); overflow: hidden; }
.byo-progress i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
/* the stage: Vivi's line | the device | today's facts */
.byo-stage { min-height: 0; display: grid; grid-template-columns: minmax(16rem, 24rem) minmax(0, 1fr) minmax(16rem, 24rem); column-gap: clamp(1rem, 3vw, 3rem); align-items: center; }
.byo-side { display: grid; gap: 1rem; align-content: center; min-width: 0; }
.byo .byo-bots { display: grid; justify-items: start; gap: 0.4rem; margin: 0; padding: 0; border: 0; background: none; border-radius: 0;
  transition: opacity 0.28s var(--ease-out), translate 0.28s var(--ease-out), visibility 0s; }
.byo:not([data-part="bot"]) .byo-bots { opacity: 0; translate: 0 6px; visibility: hidden; transition: opacity 0.16s ease-in, translate 0.16s ease-in, visibility 0s 0.16s; }
.byo-say { display: grid; gap: 0.5rem; }
/* Vivi answers: its own orb, talking (the orb's listening turn and rim) while the line comes in; the bot it thinks
   with sits on it as a small badge (bot steps only) */
/* the brain picker: avatar chips (each bot's face and name), unlike the step tabs above; the chosen one is filled */
.byo-pick { display: flex; flex-wrap: wrap; gap: var(--ds-2, 0.5rem); }
.byo-pick-chip {
  display: inline-flex; align-items: center; gap: 0.45rem; min-height: max(2.25rem, var(--target, 2.25rem)); padding: 0.25rem 0.85rem 0.25rem 0.35rem;
  border: 1px solid var(--ds-border, var(--line-2)); border-radius: 999px; background: var(--ds-surface-float, var(--card)); color: var(--ink);
  font: 500 0.92rem/1 var(--font); cursor: pointer; transition: background-color 0.15s ease-out, color 0.15s ease-out, scale 0.15s ease-out;
}
.byo-pick-chip:hover { background: var(--paper-2); }
.byo-pick-chip:active { scale: 0.97; }
.byo-pick-chip[aria-checked="true"] { background: var(--ink); color: var(--paper); border-color: transparent; }
.byo-pick-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.byo-pick-face { --orb-size: 1.6rem; }
.byo-facts:not([data-lit])::before { opacity: 0; }
.byo-face { position: relative; display: inline-grid; margin-top: 0.1rem; }
.byo-face .byo-ans-orb { --orb-size: 32px; }
.byo-face .byo-badge { --orb-size: 16px; position: absolute; right: -5px; bottom: -4px; box-shadow: 0 0 0 2px var(--paper); border-radius: 50%; }
:root[data-persona="vivi"] .byo-face .byo-badge, :root:not([data-persona]) .byo-face .byo-badge { display: none; }
.byo[data-swap="in"] .byo-ans-orb::before { animation: byo-talk 0.5s ease-in-out 3 alternate; }
@keyframes byo-talk { from { opacity: 0.2; } to { opacity: 0.9; } }
.byo-when { display: flex; flex-wrap: wrap; gap: var(--ds-1); }
.byo-when:empty { display: none; }
.byo-ans .ds-bubble--you { max-inline-size: 100%; }
/* Vivi's line changes: out with ease-in (160 ms), in with ease-out from 0.97 + a few px (280 ms), the chips a beat later */
.byo-ask, .byo-say > * { transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out), filter 0.28s var(--ease-out); }
.byo-say > :nth-child(2) { transition-delay: 0.06s; } .byo-say > :nth-child(3) { transition-delay: 0.12s; }
.byo[data-swap="out"] :is(.byo-ask, .byo-say > *) { opacity: 0; transform: translateY(4px) scale(0.97); filter: blur(3px); transition-duration: 0.16s; transition-timing-function: ease-in; transition-delay: 0s; }
/* the facts: the lit row is a soft band that glides to the current row */
.byo-today { width: 100%; }
.byo-facts { position: relative; isolation: isolate; }
.byo-facts::before { content: ""; position: absolute; z-index: -1; inset-inline: -0.5rem; top: 0; height: var(--hl-h, 0); transform: translateY(var(--hl-y, 0));
  border-radius: var(--ds-r-sm, 10px); background: color-mix(in oklch, var(--accent-soft) 70%, transparent); transition: transform 0.35s var(--ease-out), height 0.35s var(--ease-out); }
.byo-facts > div { transition: color 0.2s; }
.byo-facts > div:not([data-on]) dd { color: var(--ink-2); }

/* the device cell: every device stacked in one place, sized to fit the cell (container query units) */
.byo-devs { position: relative; height: 100%; min-height: 0; container-type: size; perspective: 1400px; }
.byo-dev { position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  transition: opacity 0.28s var(--ease-out), transform 0.42s var(--ease-out); }
.byo-dev[data-pos="before"] { opacity: 0; transform: translateX(-8%) rotateY(10deg) scale(0.97); transition-timing-function: ease-in; transition-duration: 0.16s, 0.3s; pointer-events: none; }
.byo-dev[data-pos="after"] { opacity: 0; transform: translateX(8%) rotateY(-10deg) scale(0.97); transition-timing-function: ease-in; transition-duration: 0.16s, 0.3s; pointer-events: none; }
.byo-art { display: grid; place-items: center; width: 100%; height: 100%; }
.byo-dev--phone .byo-fig { width: min(300px, 100cqw, calc(100cqh / 2.09)); }
.byo-dev--tablet .byo-fig { width: min(100cqw, calc(100cqh * 1.58), 44rem); }
.byo-dev--laptop .byo-fig { width: min(100cqw, calc(100cqh * 1.47), 46rem); }
/* the laptop keeps its real proportions at any size: a 16:10 screen (screens.css squares it up in small containers) */
.byo .byo-fig--laptop .vs-desktop { aspect-ratio: 16 / 10; --l: calc(100cqi / 800); --u: var(--l); }
/* the phone's pages: forward slides in from the right, back from the left (One UI / Android shared-axis X) */
.byo-layers { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.byo-layer { position: absolute; inset: 0; transition: transform 0.36s var(--ease-out), opacity 0.24s var(--ease-out); }
.byo-layer[data-pos="before"] { transform: translateX(-30%); opacity: 0; }
.byo-layer[data-pos="after"] { transform: translateX(30%); opacity: 0; }
/* a bot's face arrives: the avatar crossfades in from 0.97 with a little blur */
@keyframes byo-face { from { opacity: 0.2; scale: 0.9; filter: blur(3px); } }
.byo .vivi-orb { animation: none; }
html[data-persona] .byo:is([data-swap="in"]) .vivi-orb { animation: byo-face 0.32s var(--ease-out); }

/* medium and short: the facts card under Vivi's line, two columns */
@media (width < 1100px) {
  .byo-stage { grid-template-columns: minmax(13rem, 1fr) minmax(0, 1.25fr); grid-template-rows: auto auto; row-gap: 1rem; }
  .byo-devs { grid-column: 2; grid-row: 1 / span 2; }
  .byo-side--a { grid-column: 1; grid-row: 1; align-self: end; }
  .byo-side--b { grid-column: 1; grid-row: 2; align-self: start; }
}
/* phones: the device on top, the stepper as a scrolling row, Vivi's line and the lit fact below */
@media (width < 640px) {
  .byo-pin { grid-template-rows: auto auto minmax(0, 1fr); }
  .byo-head .byo-line { display: none; }
  .byo-steps-host { justify-self: stretch; mask: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .byo-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; row-gap: 0.6rem; }
  .byo-devs { grid-column: 1; grid-row: 1; }
  .byo-side--a { grid-column: 1; grid-row: 2; align-self: start; gap: 0.5rem; }
  .byo-side--b { grid-column: 1; grid-row: 3; }
  .byo .byo-bots { position: absolute; }    /* overlays nothing when hidden */
  .byo[data-part="bot"] .byo-bots { position: static; }
  .byo-ans .ds-bubble--you { display: none; }
  .byo-honest { display: none; }
  .byo-today { padding: 0.55rem 0.8rem; gap: 0.25rem; }
  .byo-today .ds-label { display: none; }
  .byo-facts > div:not([data-on]) { display: none; }
  .byo-facts::before { display: none; }
  .byo-today:has(.byo-facts:not([data-lit])) { display: none; }
}

/* reduced motion / Pause motion: every swap is instant */
@media (prefers-reduced-motion: reduce) {
  .byo :is(.byo-dev, .byo-layer, .byo-bots, .byo-ask, .byo-say > *, .byo-facts::before) { transition: none !important; }
  .byo .vivi-orb { animation: none !important; }
}
html[data-motion="off"] .byo :is(.byo-dev, .byo-layer, .byo-bots, .byo-ask, .byo-say > *, .byo-facts::before) { transition: none !important; }
html[data-motion="off"] .byo .vivi-orb { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .byo .byo-ans-orb::before { animation: none !important; } }
html[data-motion="off"] .byo .byo-ans-orb::before { animation: none !important; }

/* ================= inside the devices: Vivi's settings in One UI (1 dp = var(--u)) ================= */
.byo-fig { margin: 0; }
.byo-app { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--vs-bg); }
.byo-bar { padding-block: calc(10 * var(--u)) calc(12 * var(--u)); gap: calc(16 * var(--u)); }
.byo-bar .vs-bar-title { font-size: calc(20 * var(--u)); }
.byo-bar .vs-bar-title small { margin-top: calc(2 * var(--u)); }
.byo-scroll { display: flex; flex-direction: column; padding: calc(2 * var(--u)) 0 calc(24 * var(--u)); min-height: 0; }
/* group header: One UI's small grey label above a focus block */
.byo-group { margin: calc(16 * var(--u)) calc(26 * var(--u)) calc(8 * var(--u)) !important; font-size: calc(13 * var(--u)); font-weight: 600; color: var(--vs-ink-2); line-height: 1.2; }
.byo-scroll > .byo-group:first-child { margin-top: calc(6 * var(--u)) !important; }
/* the focus block: a white card (lighter grey in dark), radius 26 dp, rows with inset dividers */
.byo-card { margin: 0 calc(12 * var(--u)); border-radius: calc(26 * var(--u)); background: var(--vs-card); overflow: hidden; }
.byo-row {
  position: relative; display: flex; align-items: center; gap: calc(16 * var(--u));
  min-height: calc(60 * var(--u)); padding: calc(11 * var(--u)) calc(22 * var(--u));
}
.byo-row + .byo-row::before { content: ""; position: absolute; top: 0; left: calc(22 * var(--u)); right: calc(22 * var(--u)); height: 1px; background: var(--vs-line); }
/* under a radio the divider starts at the text, as in One UI's lists */
.byo-row:has(> .byo-radio) + .byo-row::before { left: calc(58 * var(--u)); }
.byo-tx { display: grid; gap: calc(2 * var(--u)); flex: 1; min-width: 0; }
.byo-tx b { font-size: calc(16 * var(--u)); font-weight: 500; line-height: 1.25; color: var(--vs-ink); }
.byo-tx small { font-size: calc(13 * var(--u)); line-height: 1.3; color: var(--vs-ink-2); overflow-wrap: anywhere; }
.byo-tx small.byo-v { color: var(--vs-accent-text); }
/* One UI radio: a ring, filled with the activated blue and a centre dot when chosen */
.byo-radio {
  flex: none; width: calc(20 * var(--u)); height: calc(20 * var(--u)); border-radius: 50%;
  box-shadow: inset 0 0 0 calc(2 * var(--u)) light-dark(oklch(0.6 0.005 270), oklch(0.6 0.005 270));
}
.byo-radio[data-on] { background: radial-gradient(circle, var(--vs-card) 0 calc(4.6 * var(--u)), var(--vs-accent-deep) calc(5 * var(--u))); box-shadow: none; }
/* One UI switch: a pill track, a white knob; on = the activated blue */
.byo-sw {
  position: relative; flex: none; width: calc(40 * var(--u)); height: calc(22 * var(--u)); border-radius: 999px; background: var(--vs-tonal);
  box-shadow: inset 0 0 0 calc(1.5 * var(--u)) light-dark(oklch(0.62 0.005 270), oklch(0.55 0.005 270));
}
.byo-sw::after { content: ""; position: absolute; top: calc(3 * var(--u)); left: calc(3 * var(--u)); width: calc(16 * var(--u)); height: calc(16 * var(--u)); border-radius: 50%;
  background: light-dark(oklch(0.62 0.005 270), oklch(0.78 0.005 270)); }
.byo-sw[data-on] { background: var(--vs-accent-deep); box-shadow: none; }
.byo-sw[data-on]::after { left: auto; right: calc(3 * var(--u)); background: oklch(1 0 0); }
.byo-link { display: inline-block; margin-top: calc(10 * var(--u)); font-size: calc(14 * var(--u)); font-weight: 600; color: var(--vs-accent-text); }

/* (a) your bot: the brain summary (Vivi's orb: Vivi stays the voice), the brains, then the persona details */
.byo-brain { display: flex; align-items: center; gap: calc(14 * var(--u)); margin-top: calc(4 * var(--u)); padding: calc(16 * var(--u)) calc(20 * var(--u)); }
.byo-brain-orb { --orb-size: calc(44 * var(--u)); }
.byo-brain .byo-tx b { font-size: calc(16.5 * var(--u)); font-weight: 600; }
.byo-brain .byo-tx small { font-size: calc(13 * var(--u)); line-height: 1.35; }
.byo-apps { display: flex; align-items: center; gap: calc(6 * var(--u)); margin: calc(8 * var(--u)) calc(26 * var(--u)) 0 !important; font-size: calc(12.5 * var(--u)); line-height: 1.3; color: var(--vs-accent-text); }
.byo-apps .vs-i { width: calc(14 * var(--u)); height: calc(14 * var(--u)); stroke-width: 2.2; flex: none; }
.byo-clip { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* (older persona hero, kept for reference by other screens) */
.byo-hero { display: grid; justify-items: center; gap: calc(6 * var(--u)); padding: calc(10 * var(--u)) calc(24 * var(--u)) calc(20 * var(--u)); text-align: center; }
.byo-hero-orb { --orb-size: calc(76 * var(--u)); margin-bottom: calc(6 * var(--u)); }
.byo-hero-name { font-size: calc(26 * var(--u)); font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.byo-hero-sub { font-size: calc(13.5 * var(--u)); line-height: 1.35; color: var(--vs-ink-2); }
.byo-prompt { padding: calc(16 * var(--u)) calc(22 * var(--u)) calc(14 * var(--u)); }
.byo-prompt p { font-size: calc(14.5 * var(--u)); line-height: 1.45; color: var(--vs-ink); }

/* (d) the tablet: the #devices tablet frame, its screen a 900 x 562 dp landscape (an 8.7-inch Galaxy Tab) */
.byo .byo-fig--tablet {
  &::after { display: none; }
  .vs-phone { padding: 2.1cqi; border-radius: 4.4cqi;
    box-shadow: inset 0 0 0 .16cqi oklch(.82 .02 255 / .55), inset 0 0 0 .6cqi oklch(.36 .035 258), inset 0 0 0 .78cqi oklch(.1 .005 260); }
  .vs-phone::before { top: 0.75cqi; width: 0.9cqi; box-shadow: none; }
  .vs-phone::after { display: none; }
  .vs-screen { --u: calc(100cqi / 900); aspect-ratio: 16 / 10; border-radius: 2.4cqi; }
}
.byo-tab { flex-direction: row; gap: calc(12 * var(--u)); padding: calc(4 * var(--u)) calc(16 * var(--u)) calc(16 * var(--u)); }
.byo-tab-nav { flex: none; width: calc(250 * var(--u)); display: flex; flex-direction: column; gap: calc(2 * var(--u)); }
.byo-tab-who { display: flex; align-items: center; gap: calc(10 * var(--u)); padding: calc(10 * var(--u)) calc(14 * var(--u)) calc(14 * var(--u)); font-size: calc(22 * var(--u)); font-weight: 700; }
.byo-tab-orb { --orb-size: calc(30 * var(--u)); }
.byo-nav { display: flex; align-items: center; gap: calc(12 * var(--u)); min-height: calc(46 * var(--u)); padding: 0 calc(14 * var(--u)); border-radius: calc(16 * var(--u)); font-size: calc(15 * var(--u)); }
.byo-nav b { font-weight: 500; }
.byo-nav.is-on { background: var(--vs-card); }
.byo-nav.is-on b { font-weight: 600; }
.byo-nav-i { display: grid; place-items: center; width: calc(28 * var(--u)); height: calc(28 * var(--u)); border-radius: 50%; background: var(--vs-tonal); color: var(--vs-ink-2); }
.byo-nav-i .vs-i { width: calc(16 * var(--u)); height: calc(16 * var(--u)); }
.byo-nav.is-on .byo-nav-i { background: var(--vs-accent-deep); color: oklch(1 0 0); }
.byo-tab-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.byo-tab-h { padding: calc(10 * var(--u)) calc(14 * var(--u)) 0; font-size: calc(22 * var(--u)); font-weight: 700; }
.byo-tab-main .byo-group { margin: calc(12 * var(--u)) calc(14 * var(--u)) calc(8 * var(--u)) !important; }
.byo-tab-main .byo-card { margin: 0; }
.byo-tab .byo-row { min-height: calc(52 * var(--u)); padding-block: calc(8 * var(--u)); }

/* (e) the laptop: a real screenshot of Vivi's Connectors window (a Kirigami app) on the founder's KDE Plasma desktop
   (js/byo.js, assets/laptop/connectors). Breeze Dark on a dark page, Breeze Light on a light page. */
.byo .byo-conn-desk { background: oklch(0.2 0.01 250); }
.byo-conn { display: none; position: absolute; inset: 0; }
.byo-conn img { display: block; width: 100%; height: 100%; object-fit: cover; }
html:not([data-scheme="dark"]) .byo-conn[data-shot-theme="light"], html[data-scheme="dark"] .byo-conn[data-shot-theme="dark"] { display: block; }

@media (prefers-reduced-motion: reduce) { .byo :is([data-p], [data-b]) { transition: none; } }
html[data-motion="off"] .byo :is([data-p], [data-b]) { transition: none; }

/* stopgap until the Connectors captures exist: the Plasma wallpaper fills the screen and a missing capture never shows a broken icon */
.byo .byo-conn-desk { background: oklch(0.2 0.01 250) url("../assets/laptop/plasma-wallpaper.webp") center / cover no-repeat; }
.byo-conn:has(img:is([data-broken])) { display: none !important; }
