/* Motie parent app: layout and app-specific parts. Every colour, radius, shadow, type size and
   timing comes from brand.css tokens. Components (.btn, .input, .chip, .card, .consent, .dd) are brand.css. */

/* ---------- page frame ---------- */
:root {
  --hdr: 64px;                      /* header row, below the top safe area */
  --gut: var(--s4);                 /* brand page margin: compact 16 · medium 24 · expanded 32 */
  --pw: clamp(340px, 40vw, 540px);  /* the facts / form column beside Motie */
  --sheet-h: 0px;                   /* measured height of the bottom sheet (set by the app) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
@media (min-width: 600px) { :root { --gut: var(--s6); } }
@media (min-width: 840px) { :root { --gut: var(--s8); --hdr: 72px; } }
@media (max-height: 480px) { :root { --hdr: 56px; } }

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
[hidden] { display: none !important; }
p, dd, .ctext { text-wrap: pretty; }
button { font-family: var(--sans); color: inherit; }
.app { position: fixed; inset: 0; height: 100vh; height: 100dvh; background: var(--cream); overflow: hidden; }

/* ---------- header ---------- */
.top {
  position: absolute; z-index: 20; left: 0; right: 0; top: 0;
  height: calc(var(--hdr) + var(--safe-t));
  padding: var(--safe-t) calc(var(--gut) + var(--safe-r)) 0 calc(var(--gut) + var(--safe-l));
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.logo { height: 24px; width: auto; flex: none; }
@media (min-width: 600px) { .logo { height: 28px; } }
.top-r { display: flex; align-items: center; gap: var(--s2); }
.signin { height: 44px; padding: 0 var(--s4); gap: 6px; font-weight: 600; border-radius: var(--r-pill); }
.signin .q { font-weight: 500; color: var(--ink-3); }
.signin .a { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 599px) { .signin .q { display: none; } }

/* round icon button: brand .btn .btn-secondary material and states, square and round */
.btn.iconbtn { width: 48px; height: 48px; padding: 0; border-radius: var(--r-pill); flex: none; color: var(--navy); }

/* ---------- scene: Motie's stage + the sheet ---------- */
.scene { position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--hdr) + var(--safe-t)); }

.stage {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 calc(var(--gut) + var(--safe-r)) 0 calc(var(--gut) + var(--safe-l));
  container: stage / size;
  transition: right var(--d-stage) var(--e-standard), bottom var(--d-stage) var(--e-standard), opacity var(--d-fade) var(--e-standard);
}
.app[data-player] .stage { opacity: 0; }

/* what Motie says, set like a line of dialogue above Motie */
/* the caption has a fixed slot (two lines) above Motie, and Motie's size and place come from the stage alone:
   a line that wraps only uses the cream above his head and never moves or shrinks him. --cap-h is that slot. */
.cap { flex: 1 1 0; min-height: 0; width: 100%; display: flex; justify-content: center; align-items: flex-end; padding-top: var(--s2); }
.motie { --cap-h: 64px; }
.cap p {
  max-width: 22em; text-align: center; text-wrap: balance; color: var(--navy);
  font: 500 var(--t-22)/28px var(--serif); letter-spacing: -.01em;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--d-fade) var(--e-out), transform var(--d-fade) var(--e-out);
}
.cap p[data-on] { opacity: 1; transform: none; }
.app[data-start] .cap { display: none; }
/* the narrowest phones: a smaller line, so the longest caption still fits the two-line slot */
@container stage (max-width: 359px) { .cap p { font-size: var(--t-18); line-height: 26px; } }
@container stage (max-height: 300px) { .motie { --cap-h: 60px; } .cap p { font-size: var(--t-18); line-height: 26px; } }
@container stage (min-width: 460px) and (min-height: 520px) { .motie { --cap-h: 80px; } .cap p { font-size: var(--t-28); line-height: 36px; } }
@container stage (min-width: 640px) and (min-height: 640px) { .motie { --cap-h: 100px; } .cap { padding-top: var(--s4); } .cap p { font-size: var(--t-34); line-height: 42px; } }
@container stage (min-width: 980px) and (min-height: 760px) { .motie { --cap-h: 120px; } .cap p { font-size: var(--t-44); line-height: 52px; } }

/* Motie: the clips are 16:9 on white; the figure crops to Motie and blends the white into cream.
   He sits low and big, and the bottom of the stage (the screen's bottom edge, or the top of the sheet)
   cuts him across the hands and belly, so his legs never show. --cut is how much of the figure shows,
   --fw how much wider than the stage he may grow (his arms run off the sides on narrow screens). */
:root { --cut: .71; --fw: 1.8; }
.motie {
  position: relative; flex: none; width: 100%; min-height: 0; container-type: size; pointer-events: none;
  height: min(100cqw * var(--fw) / .963 * var(--cut), 100cqh - var(--cap-h));
  overflow: clip; overflow-clip-margin: var(--s6);
}
.app[data-start] .motie { margin-top: auto; }
/* a tall, narrow stage (phones upright): he grows past the sides so he fills the height, as in the first prototype */
@container stage (max-aspect-ratio: 5/8) { .motie { --fw: 2.15; } }
/* the clips' white is not quite white around the fur (compression); a touch of contrast lifts it to pure white,
   so multiply leaves clean cream around the pompom instead of a pale ragged edge */
:root { --clip-clean: contrast(1.06) brightness(1.03); }
.motie-fig {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  height: min(100cqh / var(--cut), 100cqw * var(--fw) / .963); aspect-ratio: .963; mix-blend-mode: multiply;
}
/* a short stage (short screens, long panels): Motie becomes a small avatar beside his line */
@container stage (max-height: 150px) {
  .cap { margin: auto 0; min-height: 0; padding: 0 0 0 calc(min(100cqh - var(--s4), 96px) + var(--s3)); justify-content: flex-start; align-items: center; }
  .cap p { text-align: left; font-size: var(--t-18); line-height: 24px; max-width: none; }
  .motie { position: absolute; left: calc(var(--gut) + var(--safe-l)); top: 0; bottom: var(--s4); margin: auto 0; width: min(100cqh - var(--s4), 96px); height: min(100cqh - var(--s4), 96px); margin: 0; overflow-clip-margin: 0px; }
  /* head and shoulders: the same crop, softened into the cream at the edges of the small square */
  .motie-fig { height: calc(100cqh / var(--cut)); }
  .motie::after { content: ""; position: absolute; inset: 0; z-index: 8; background: radial-gradient(ellipse 58% 62% at 50% 40%, color-mix(in srgb, var(--cream) 0%, transparent) 72%, var(--cream) 100%); }
}
.motie-fig video {
  position: absolute; top: -2.08%; left: -46.15%; width: 192.3%; height: 104.17%;
  object-fit: cover; filter: var(--clip-clean); opacity: 0; transition: opacity var(--d-base) ease;
}
.motie-fig video[data-on] { opacity: 1; }
.motie-fig .lv { z-index: 3; }
.motie-fig .lv[data-front] { z-index: 4; }
.motie-fig .sv { z-index: 5; transition: none; }
.motie-fig .tv { z-index: 7; transition-duration: var(--d-fast); }

/* the one action, floating over Motie's lower body: start, or pick up where you left off */
.cta {
  position: absolute; z-index: 9; left: calc(var(--gut) + var(--safe-l)); right: calc(var(--gut) + var(--safe-r));
  bottom: calc(var(--s4) + var(--safe-b)); display: flex; justify-content: center; pointer-events: none;
}
.cta > * { pointer-events: auto; }
.btn-hero { height: var(--s16); padding: 0 var(--s10); font-size: var(--t-18); width: 100%; max-width: 360px; }
.btn-hero svg { flex: none; }
.app[data-start] .btn-hero { animation: rise var(--d-stage) var(--e-out) 300ms both; }
.resume {
  display: flex; align-items: center; gap: var(--s4); width: 100%; max-width: 560px;
  padding: var(--s3) var(--s3) var(--s3) var(--s5); border-radius: var(--r-18); background: var(--white);
  box-shadow: var(--sh-tile); animation: rise var(--d-stage) var(--e-out) both;
}
.resume p { flex: 1; font: 400 var(--t-15)/20px var(--sans); color: var(--ink-2); }
.resume .btn { flex: none; }
.resume .short { display: none; }
@media (max-width: 599px) { .resume .long { display: none; } .resume .short { display: inline; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- the sheet ----------
   portrait: rises from the bottom. When the panel is taller than the room left under Motie, the whole
   scene scrolls: Motie stops shrinking at --floor (a small avatar beside his line on short screens) and
   scrolls away, and the panel's action stays pinned to the bottom edge.
   landscape: a column beside Motie that scrolls on its own, with the action pinned the same way. */
:root { --floor: max(30%, 168px); --side: var(--gut); }
@media (max-height: 699px) { :root { --floor: 104px; } }
/* a scroller is its own layer: give Motie's multiply blend the cream to sit on */
.app[data-open] .scene { background: var(--cream); overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 160px; }
.sheet {
  position: absolute; z-index: 6; left: 0; right: 0; top: max(100% - var(--sheet-h), var(--floor) - var(--tuck, 0px));
  display: flex; flex-direction: column;
  background: var(--white); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--sh-sheet);
  transform: translateY(calc(100% + var(--s6))); visibility: hidden;
  transition: transform var(--d-stage) var(--e-standard), visibility 0s linear var(--d-stage);
}
.app[data-open] .sheet { transform: none; visibility: visible; transition: transform var(--d-stage) var(--e-out) 160ms, visibility 0s; }
.app[data-open] .stage { bottom: min(var(--sheet-h), 100% - var(--floor) + var(--tuck, 0px)); }
.sheet-in {
  flex: none; display: flex; flex-direction: column; width: 100%; max-width: 608px; margin: 0 auto;
  padding: var(--s6) calc(var(--gut) + var(--safe-r)) 0 calc(var(--gut) + var(--safe-l));
}

@media (orientation: landscape) and (min-width: 600px) {
  /* Motie and the column are one group, centred, never wider than --gmax */
  :root { --gmax: 1360px; --side: max(var(--gut), (100vw - var(--gmax)) / 2); }
  .stage { left: calc(var(--side) - var(--gut)); right: calc(var(--side) - var(--gut)); }
  .cta { bottom: calc(var(--s6) + var(--safe-b)); }
  .app[data-open] .stage { bottom: 0; right: calc(var(--side) + var(--pw) + var(--safe-r)); padding-right: var(--s6); }
  .app[data-open] .scene { overflow: visible; }
  .sheet {
    left: auto; top: 0; bottom: 0; right: calc(var(--side) + var(--safe-r)); width: var(--pw);
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
    padding: var(--gut) 0 0;
    background: none; border-radius: 0; box-shadow: none;
    transform: translateX(calc(100% + var(--side) + var(--s12)));
  }
  .sheet::-webkit-scrollbar { display: none; }
  .sheet::after { content: ""; flex: none; height: calc(var(--gut) + var(--safe-b)); }
  .sheet-in { margin: auto 0; max-width: none; padding: var(--s8) var(--s8) 0; background: var(--white); border-radius: var(--r-sheet); box-shadow: var(--sh-tile); }
  .app[data-open] .sheet { transform: none; }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  .sheet { padding-top: var(--s3); }
  .sheet::after { height: calc(var(--s3) + var(--safe-b)); }
  .sheet-in { padding: var(--s5) var(--s6) 0; }
}
/* very large screens: the group and the card's contents grow with the screen */
@media (orientation: landscape) and (min-width: 1800px) and (min-height: 1000px) { :root { --pw: 600px; --gmax: 1600px; } .sheet-in { zoom: 1.12; } }
@media (orientation: landscape) and (min-width: 2400px) and (min-height: 1300px) { :root { --pw: 780px; --gmax: 2080px; } .sheet-in { zoom: 1.4; } }
/* the header grows with them */
@media (min-width: 1800px) and (min-height: 1000px) { .top .logo { height: 34px; } }
@media (min-width: 2400px) and (min-height: 1300px) { :root { --hdr: 96px; } .top .logo { height: 40px; } .top .btn { zoom: 1.25; } }

/* one panel: the body, then the action pinned to the bottom edge while there is more to scroll */
.pv { flex: none; display: flex; flex-direction: column; animation: pv-in var(--d-fade) var(--e-out) both; }
@keyframes pv-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pbody { display: flex; flex-direction: column; gap: var(--pgap, var(--s5)); margin: 0 calc(-1 * var(--s1)); padding: var(--s1) var(--s1) var(--s2); }
.pfoot {
  position: sticky; bottom: 0; z-index: 2; flex: none; display: grid; gap: var(--s2); justify-items: stretch;
  margin: 0 calc(-1 * var(--s2)); padding: var(--s4) var(--s2) calc(var(--s5) + var(--safe-b)); background: var(--white);
}
/* the fade above the pinned action: only while the panel scrolls and isn't at its end */
.pfoot::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 36px; pointer-events: none;
  background: linear-gradient(to top, var(--white), color-mix(in srgb, var(--white) 0%, transparent)); opacity: 0;
}
@supports (animation-timeline: scroll()) {
  .pfoot::before { animation: more-below linear both; animation-timeline: scroll(nearest block); }
}
@keyframes more-below { 0%, 92% { opacity: 1; } 100% { opacity: 0; } }
.pfoot .btn { width: 100%; }
.pfoot .btn-quiet { justify-self: center; width: auto; }
.pfoot.end { padding-top: 0; }
.pfoot.end:empty { padding-top: 0; }
/* a footer with nothing to finish the step (only "Not now", or empty) flows with the panel instead of
   covering it; then the scroller itself fades out at the bottom */
.pfoot:not(:has(.btn-primary)) { position: static; }
.app[data-open] .scene:not(:has(.pfoot .btn-primary)), .sheet:not(:has(.pfoot .btn-primary)) {
  mask-image: linear-gradient(to bottom, var(--navy) calc(100% - var(--fade-b)), transparent);
}
@supports (animation-timeline: scroll()) {
  .app[data-open] .scene:not(:has(.pfoot .btn-primary)), .sheet:not(:has(.pfoot .btn-primary)) { animation: fade-b linear both; animation-timeline: scroll(self block); }
}
/* short screens: the connect step drops the profile recap and uses a smaller QR so the QR is in view */
@media (max-height: 699px) {
  .sheet-in:has(#join-code) .prof { display: none; }
  .qr-box svg { width: 88px; height: 88px; }
  .qr { padding: var(--s3); gap: var(--s4); }
}
/* short landscape: a wider column, and the footer's actions side by side */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  :root { --pw: clamp(340px, 48vw, 540px); }
  .pfoot { grid-template-columns: 1fr auto; align-items: center; column-gap: var(--s4); }
  .pfoot .consent { grid-column: 1 / -1; }
  .sheet-in .prof { display: none; }
}
@media (orientation: landscape) and (min-width: 600px) { .pfoot { padding-bottom: var(--s8); } }
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) { .pfoot { padding-bottom: var(--s5); } }
/* landscape phone: the saved-profile recap gives its room to the step's own control, which must show above the pinned button */
@media (orientation: landscape) and (max-height: 500px) { .sheet-in .prof { display: none; } .sheet-in { padding-top: var(--s5); } }

.p-h { font-size: var(--t-28); line-height: 36px; letter-spacing: -.01em; }
.p-lead { font: 400 var(--t-17)/26px var(--sans); color: var(--ink-2); margin-top: calc(-1 * var(--s3)); }
.hint { margin-top: calc(-1 * var(--s1)); }
@media (min-width: 840px) and (min-height: 700px) {
  .p-h { font-size: var(--t-34); line-height: 42px; }
  .p-lead { font-size: var(--t-18); line-height: 28px; }
}
@media (max-height: 560px) { .p-h { font-size: var(--t-22); line-height: 28px; } .p-lead { font-size: var(--t-16); line-height: 24px; } .pbody { --pgap: var(--s4); } }

/* profile card: fills in as Motie learns about the kid */
.prof { display: flex; gap: var(--s3); align-items: center; padding: var(--s3); margin-bottom: var(--s5); border-radius: var(--r-16); background: var(--surface); flex: none; animation: pv-in var(--d-fade) var(--e-out) both; }
.prof-av { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--tint); color: var(--navy); font: 600 var(--t-22)/28px var(--serif); box-shadow: inset 0 0 0 1.5px var(--white); }
.prof-b { min-width: 0; display: grid; gap: 2px; }
.prof-h { display: flex; align-items: center; gap: var(--s3); }
.prof-t { font: 600 var(--t-13)/16px var(--sans); letter-spacing: .06em; color: var(--ink-3); }
.prof .dd { font-size: var(--t-13); }
.prof-rows { display: flex; flex-wrap: wrap; column-gap: var(--s3); row-gap: 2px; font: 500 var(--t-15)/22px var(--sans); color: var(--navy); }
.prof-row { display: inline-flex; align-items: center; gap: var(--s1); animation: rowin var(--d-fade) var(--e-out) both; }
.prof-row svg { color: var(--success); flex: none; }
/* short portrait screens: the profile card gets tighter so the step itself has the room */
@media (orientation: portrait) and (max-height: 700px) {
  .prof { padding: var(--s2) var(--s3); margin-bottom: var(--s4); }
  .prof-av { width: 36px; height: 36px; font-size: var(--t-18); }
  .prof-rows { font-size: var(--t-14); line-height: 20px; }
}
@keyframes rowin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* explanation tiles: brand cards, whole card is one tap */
.tiles { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
.tiles .card .cm { flex-wrap: wrap; column-gap: var(--s2); row-gap: 0; }
@media (max-width: 359px) { .tiles .card .thumb { width: 88px; height: 50px; } .tiles .card { gap: var(--s3); } }
button.card { width: 100%; color: var(--navy); }
button.card:focus-visible { box-shadow: var(--focus-edge); }
.card .thumb { position: relative; }
.card .play { position: absolute; inset: 0; display: grid; place-items: center; }
.card .play span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--white); color: var(--navy); box-shadow: var(--sh-2); }
.card .cb { flex: 1; min-width: 0; }
.card .chev { flex: none; color: var(--ink-3); margin-right: var(--s1); }

/* sign-up */
.stack { display: grid; gap: var(--s3); }
.stack .btn { width: 100%; }
.form { display: grid; gap: var(--s4); }
.two { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 420px) { .two { grid-template-columns: 1fr 1fr; } }
.field .input { width: 100%; color: var(--navy); }
.input:hover { box-shadow: inset 0 0 0 1px var(--navy); }
.input:focus-visible, .input:focus { box-shadow: var(--focus-edge); outline: none; }
.input::placeholder { color: var(--ink-3); opacity: 1; }
select.input { padding-right: var(--s10); cursor: pointer; }
.sel { position: relative; display: block; }
.sel::after { content: ""; position: absolute; right: var(--s3); top: 50%; width: 20px; height: 20px; margin-top: -10px; pointer-events: none; background: var(--navy);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; }
input.input[readonly] { cursor: pointer; }

/* 6-digit code boxes */
.code { display: grid; grid-template-columns: repeat(6, minmax(0, 56px)); gap: var(--s2); }
.cbox { height: 64px; border-radius: var(--r-14); background: var(--white); box-shadow: inset 0 0 0 1px var(--muted); display: grid; place-items: center; font: 600 var(--t-28)/36px var(--sans); color: var(--navy); transition: box-shadow var(--d-fast) var(--e-standard); }
.cbox.is-cur { box-shadow: var(--focus-edge); }
.cbox.is-full { box-shadow: inset 0 0 0 1px var(--navy); animation: pop var(--d-base) var(--e-out); }
@keyframes pop { from { transform: scale(.94); } to { transform: none; } }

/* consent: facts first, one permission per row */
.facts { margin: 0; border-radius: var(--r-16); background: var(--surface); padding: var(--s1) var(--s4); }
.facts > div { padding: var(--s3) 0; display: grid; gap: 2px; }
.facts > div + div { border-top: 1px solid var(--line-soft); }
.facts dt { font: 600 var(--t-15)/20px var(--sans); }
.facts dd { margin: 0; font: 400 var(--t-15)/22px var(--sans); color: var(--ink-2); }
.linkq { justify-self: start; min-height: 44px; height: auto; padding: 0 var(--s1); margin: calc(-1 * var(--s3)) 0 0 calc(-1 * var(--s1)); }
.consents { display: grid; gap: var(--s3); }
.consent { user-select: none; }
.consent .box { margin-top: -1px; }
.consent:hover { box-shadow: inset 0 0 0 1px var(--navy); }
.consent:has(.sr:focus-visible) { box-shadow: var(--focus-edge); }
/* a tap on the greyed-out Agree button points at the box it needs */
.btn-primary.is-disabled { filter: none; transform: none; text-shadow: none; }
.consent.nudge { animation: nudge 1.2s var(--e-out); }
@keyframes nudge { 0%, 60% { box-shadow: inset 0 0 0 2px var(--navy); } 100% { box-shadow: inset 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .consent.nudge { animation: none; box-shadow: inset 0 0 0 2px var(--navy); } }
.optional { display: grid; gap: var(--s3); }
.optional .eyebrow { margin-top: var(--s2); }

/* kid age */
.ages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
/* 11 ages: rows of 4 (4·4·3) or 6 (6·5), never a lone "13+" on its own row */
.pbody:has(> .ages) { container: pbody / inline-size; }
@container pbody (min-width: 292px) { .ages { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@container pbody (min-width: 444px) { .ages { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.agebtn {
  height: 64px; border: 0; border-radius: var(--r-16); cursor: pointer; background: var(--white); color: var(--navy);
  font: 600 var(--t-22)/28px var(--sans); box-shadow: inset 0 0 0 1px var(--line), var(--sh-1);
  transition: box-shadow var(--d-fast) var(--e-standard), background var(--d-fast) var(--e-standard), transform var(--d-fast) var(--e-standard);
}
.agebtn:hover { box-shadow: inset 0 0 0 1px var(--navy), var(--sh-2); }
.agebtn:active { background: var(--surface); transform: scale(.97); }
.agebtn:focus-visible { box-shadow: var(--focus-edge); }

/* likes: brand chips, a little larger for a confident tap */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips .chip { height: 48px; padding: 0 var(--s5); }
.chips .chip:focus-visible { box-shadow: var(--focus-edge); }
.chips .chip.is-on:hover { box-shadow: inset 0 0 0 1.5px var(--navy); }

/* how will Maya use Motie */
.opts { display: grid; gap: var(--s3); }
.opt {
  width: 100%; display: flex; align-items: center; gap: var(--s4); text-align: left; cursor: pointer; border: 0;
  padding: var(--s4); border-radius: var(--r-18); background: var(--white); color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--line-soft), var(--sh-1); min-height: 88px;
  transition: box-shadow var(--d-fast) var(--e-standard), background var(--d-fast) var(--e-standard), transform var(--d-fast) var(--e-standard);
}
.opt:hover { box-shadow: inset 0 0 0 1px var(--line), var(--sh-2); }
.opt:active { background: var(--surface); transform: scale(.99); }
.opt:focus-visible { box-shadow: var(--focus-edge); }
.opt-ic { width: 48px; height: 48px; border-radius: var(--r-14); flex: none; display: grid; place-items: center; background: var(--tint); color: var(--navy); }
.opt-tx { flex: 1; display: grid; gap: 2px; }
.opt-t { font: 600 var(--t-18)/26px var(--sans); }
.opt-d { font: 400 var(--t-15)/22px var(--sans); color: var(--ink-3); }
.opt .chev { flex: none; color: var(--ink-3); }

/* notes, QR, success */
.note { display: flex; align-items: center; gap: var(--s4); padding: var(--s4); border-radius: var(--r-16); background: var(--surface); font: 500 var(--t-16)/24px var(--sans); color: var(--ink-2); }
.note img { width: 56px; height: 56px; flex: none; }
.qr { display: flex; gap: var(--s5); align-items: center; padding: var(--s4); border-radius: var(--r-16); background: var(--surface); }
.qr-box { flex: none; padding: var(--s3); border-radius: var(--r-12); background: var(--white); box-shadow: inset 0 0 0 1px var(--line-soft); }
.qr-box svg { display: block; width: 116px; height: 116px; }
.qr-t { display: grid; gap: var(--s1); min-width: 0; }
.qr-t a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-ink); font: 600 var(--t-16)/24px var(--sans); flex-wrap: wrap; text-underline-offset: 3px; border-radius: 4px; }
.qr-t a .nw { white-space: nowrap; }
@media (max-width: 380px) { .qr { flex-direction: column; align-items: flex-start; } }
.done-ic { position: relative; flex: none; aspect-ratio: 1; width: 72px; height: 72px; margin-top: var(--s2); border-radius: 50%; display: grid; place-items: center; background: var(--success-tint); color: var(--success); animation: done-in var(--d-stage) var(--e-out) both; }
.done-ic svg { position: relative; z-index: 1; }
/* connected: a one-time moment. The badge scales in, a soft ring spreads out once, and brand dots burst out and stay.
   With reduced motion brand.css drops the animations and the resting state (badge + dots, no ring) shows. */
.done-ic::before { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 40%, transparent); opacity: 0; animation: done-ring 900ms var(--e-out) 200ms both; }
.done-ic::after {
  content: ""; position: absolute; left: -12px; top: -12px; width: 144px; height: 100px; pointer-events: none; transform-origin: 48px 48px;
  background:
    radial-gradient(circle at 98px 16px, var(--brand-amber) 4px, transparent 4.5px),
    radial-gradient(circle at 116px 44px, var(--brand-hot) 3.5px, transparent 4px),
    radial-gradient(circle at 100px 78px, var(--success) 4px, transparent 4.5px),
    radial-gradient(circle at 70px 6px, var(--navy) 2.5px, transparent 3px),
    radial-gradient(circle at 132px 22px, var(--brand-mid) 2.5px, transparent 3px),
    radial-gradient(circle at 130px 70px, var(--brand-amber) 2.5px, transparent 3px),
    radial-gradient(circle at 34px 6px, var(--brand-hot) 2.5px, transparent 3px);
  animation: done-dots 700ms var(--e-out) 240ms both;
}
@keyframes done-in { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes done-ring { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes done-dots { 0% { transform: scale(.45); opacity: 0; } 40% { opacity: 1; } 100% { transform: none; opacity: 1; } }

/* ---------- explanation player ---------- */
.player {
  position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; top: calc(var(--hdr) + var(--safe-t));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; justify-items: center; align-content: stretch; gap: var(--s4);
  padding: var(--s2) calc(var(--gut) + var(--safe-r)) calc(var(--s6) + var(--safe-b)) calc(var(--gut) + var(--safe-l));
  background: var(--cream); opacity: 0; visibility: hidden;
  transition: opacity var(--d-fade) var(--e-standard), visibility 0s linear var(--d-fade);
}
.app[data-player] .player { opacity: 1; visibility: visible; transition: opacity var(--d-fade) var(--e-standard) 120ms, visibility 0s; }
.pl-head { text-align: center; display: grid; gap: var(--s1); }
.pl-head h2 { font-size: var(--t-28); line-height: 36px; }
.pl-meta { font: 400 var(--t-14)/20px var(--sans); color: var(--ink-3); }
.pl-media { position: relative; width: 100%; height: 100%; min-height: 120px; container-type: size; }
.pl-frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100cqw, 100cqh * 16 / 9); aspect-ratio: 16 / 9;
  border-radius: var(--r-18); overflow: hidden; background: var(--navy); box-shadow: var(--sh-tile);
}
.app[data-player] .pl-frame { animation: frame-in var(--d-stage) var(--e-out) both; }
@keyframes frame-in { from { transform: translate(-50%, -48%) scale(.97); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.pl-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.pl-frame video[data-on] { opacity: 1; }
.pl-cap { width: 100%; max-width: 36em; min-height: 56px; text-align: center; text-wrap: balance; font: 500 var(--t-20)/28px var(--serif); color: var(--navy); }
.pl-ctrl { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--s3); width: 100%; }
.pl-ctrl .pp { min-width: 148px; }
.pl-ctrl .pp .ip, .app[data-paused] .pl-ctrl .pp .ipause { display: none; }
.app[data-paused] .pl-ctrl .pp .ip { display: block; }
@media (max-width: 599px) {
  .pl-ctrl { display: grid; grid-template-columns: 1fr 1fr; }
  .pl-ctrl .btn-quiet { grid-column: 1 / -1; justify-self: center; order: 3; }
  .pl-ctrl .btn { width: 100%; min-width: 0; }
  .pl-ctrl .btn-quiet { width: auto; }
}
@media (min-width: 840px) and (min-height: 700px) {
  .pl-head h2 { font-size: var(--t-34); line-height: 42px; }
  .pl-cap { font-size: var(--t-28); line-height: 36px; min-height: 72px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .player { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto; column-gap: var(--s6); align-items: center; }
  .pl-media { grid-row: 1 / -1; grid-column: 1; }
  .pl-head, .pl-cap, .pl-ctrl { grid-column: 2; }
  .pl-head { align-self: end; }
  .pl-cap { font-size: var(--t-18); line-height: 26px; }
  .pl-ctrl { align-self: start; }
}
/* short landscape phones (568×320 to 844×390): the video beside the title and caption, and every control
   on one row under both, so Back to Motie never falls off the bottom */
@media (orientation: landscape) and (max-height: 500px) {
  .player {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr) auto;
    grid-template-areas: "media ." "media head" "media cap" "media ." "ctrl ctrl"; column-gap: var(--s5); row-gap: var(--s2);
    padding-top: var(--s1); padding-bottom: calc(var(--s3) + var(--safe-b));
  }
  .pl-media { grid-area: media; min-height: 0; }
  .pl-head { grid-area: head; align-self: end; }
  .pl-head h2 { font-size: var(--t-22); line-height: 28px; }
  .pl-cap { grid-area: cap; align-self: start; font-size: var(--t-16); line-height: 22px; min-height: 44px; }
  .pl-ctrl { grid-area: ctrl; display: flex; flex-wrap: nowrap; justify-content: center; gap: var(--s3); align-self: end; }
  .pl-ctrl .btn { height: 44px; width: auto; padding: 0 var(--s5); }
  .pl-ctrl .pp { min-width: 120px; }
  .pl-ctrl .btn-quiet { order: 0; }
}

/* portrait: the video takes its own 16:9 height and the title, video, caption and controls sit as one
   centred group instead of the video floating in a tall empty row */
@media (orientation: portrait) {
  .player { grid-template-rows: auto auto auto auto; align-content: center; row-gap: var(--s5); }
  .pl-media { height: auto; aspect-ratio: 16 / 9; min-height: 0; }
  .pl-head { margin-bottom: var(--s2); }
}
/* ---------- toast ---------- */
.toast {
  position: absolute; z-index: 30; left: 50%; top: calc(var(--hdr) + var(--safe-t) + var(--s2));
  max-width: calc(100% - 2 * var(--gut)); width: max-content;
  padding: var(--s3) var(--s5); border-radius: var(--r-pill); background: var(--navy); color: var(--cream);
  font: 500 var(--t-15)/20px var(--sans); text-align: center; box-shadow: var(--sh-3);
  opacity: 0; transform: translate(-50%, -8px); pointer-events: none;
  transition: opacity var(--d-base) var(--e-out), transform var(--d-base) var(--e-out);
}
.toast[data-on] { opacity: 1; transform: translate(-50%, 0); }

/* ---------- FAQ / privacy document ---------- */
.doc-wrap {
  position: fixed; inset: 0; z-index: 35; display: grid; place-items: center;
  padding: calc(var(--safe-t) + var(--s6)) calc(var(--gut) + var(--safe-r)) calc(var(--safe-b) + var(--s6)) calc(var(--gut) + var(--safe-l));
  visibility: hidden; transition: visibility 0s linear var(--d-fade);
}
.doc-wrap[data-on] { visibility: visible; transition: visibility 0s; }
.doc-scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--navy) 32%, transparent); opacity: 0; transition: opacity var(--d-fade) var(--e-standard); }
.doc-wrap[data-on] .doc-scrim { opacity: 1; }
.doc {
  position: relative; width: min(680px, 100%); max-height: min(100dvh - var(--safe-t) - var(--safe-b) - 2 * var(--s6), 880px); min-height: 0; overflow: hidden; display: flex; flex-direction: column;
  background: var(--white); border-radius: var(--r-sheet); box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(16px); transition: opacity var(--d-fade) var(--e-out), transform var(--d-fade) var(--e-out);
}
.doc-wrap[data-on] .doc { opacity: 1; transform: none; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s5) var(--s5) var(--s3) var(--s8); flex: none; }
.doc-head h2 { font-size: var(--t-34); line-height: 42px; }
.doc-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s2) var(--s8) var(--s8); }
.qa { padding: var(--s5) 0; display: grid; gap: var(--s2); }
.qa + .qa { border-top: 1px solid var(--line-soft); }
.qa h3 { font-size: var(--t-22); line-height: 28px; }
.qa p, .doc-lead { font: 400 var(--t-16)/24px var(--sans); color: var(--ink-2); }
.doc-lead { font-size: var(--t-17); line-height: 26px; margin-bottom: var(--s5); }
.doc-body .facts { margin-bottom: var(--s6); }
@media (max-width: 599px) {
  .doc-wrap { place-items: end stretch; padding: calc(var(--safe-t) + var(--s4)) 0 0; }
  .doc { width: 100%; max-height: calc(100dvh - var(--safe-t) - var(--s4)); border-radius: var(--r-sheet) var(--r-sheet) 0 0; transform: translateY(40px); }
  .doc-head { padding: var(--s4) var(--s4) var(--s2) var(--s5); }
  .doc-head h2 { font-size: var(--t-28); line-height: 36px; }
  .doc-body { padding: var(--s2) var(--s5) calc(var(--s8) + var(--safe-b)); }
}

/* ---------- full-screen menu ---------- */
.menu {
  position: fixed; inset: 0; z-index: 40; background: var(--cream);
  display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden;
  opacity: 0; visibility: hidden;
  transition: opacity var(--d-fade) var(--e-standard), visibility 0s linear var(--d-fade);
}
.menu[data-on] { opacity: 1; visibility: visible; transition: opacity var(--d-fade) var(--e-out), visibility 0s; }
.menu-top {
  height: calc(var(--hdr) + var(--safe-t)); display: flex; align-items: center; justify-content: space-between;
  padding: var(--safe-t) calc(var(--gut) + var(--safe-r)) 0 calc(var(--gut) + var(--safe-l));
}
.menu-body {
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: safe center; justify-items: center; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s6) calc(var(--gut) + var(--safe-r)) calc(var(--hdr) + var(--s6) + var(--safe-b)) calc(var(--gut) + var(--safe-l));
}
.menu-list { display: grid; gap: var(--s2); width: 100%; max-width: 560px; }
@media (min-width: 840px) { .menu-list { max-width: 640px; } }
.mitem {
  display: flex; align-items: center; gap: var(--s4); width: 100%; min-height: 72px; padding: var(--s3) var(--s4) var(--s3) var(--s3);
  border: 0; border-radius: var(--r-18); background: transparent; color: var(--navy); cursor: pointer; text-align: left;
  font: 500 var(--t-28)/36px var(--serif); letter-spacing: -.01em;
  transition: background var(--d-fast) var(--e-standard), transform var(--d-fast) var(--e-standard), box-shadow var(--d-fast) var(--e-standard);
  opacity: 0; transform: translateY(16px);
}
.mitem .mi-t { flex: 1; }
.mitem .chev { color: var(--ink-3); transition: transform var(--d-fast) var(--e-standard); }
.mitem:hover { background: var(--surface); }
.mitem:hover .chev { transform: translateX(4px); }
.mitem:active { background: var(--line-soft); }
.mitem:focus-visible { box-shadow: var(--focus-edge); }
.mi-ic {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--navy);
  background: var(--white); box-shadow: var(--hl-inner), var(--sh-1);
}
.menu-sep { height: 1px; background: var(--line-soft); margin: var(--s1) var(--s3); }
.menu[data-on] .mitem { opacity: 1; transform: none; transition: opacity var(--d-fade) var(--e-out), transform var(--d-stage) var(--e-out), background var(--d-fast) var(--e-standard), box-shadow var(--d-fast) var(--e-standard); }
.menu[data-on] .mitem:nth-child(1) { transition-delay: 60ms, 60ms, 0s, 0s; }
.menu[data-on] .mitem:nth-child(2) { transition-delay: 110ms, 110ms, 0s, 0s; }
.menu[data-on] .mitem:nth-child(4) { transition-delay: 160ms, 160ms, 0s, 0s; }
.menu-motie { display: none; }
.menu-motie { position: relative; align-self: center; justify-self: center; width: min(100%, 360px); opacity: 0; transform: translateY(24px); transition: opacity var(--d-stage) var(--e-out) 120ms, transform var(--d-stage) var(--e-out) 120ms; }
.menu[data-on] .menu-motie { opacity: 1; transform: none; }
.menu-motie img { position: relative; width: 100%; height: auto; }
.menu-motie::before { content: ""; position: absolute; left: 12%; right: 12%; bottom: -2%; height: 8%; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--navy) 18%, transparent), color-mix(in srgb, var(--navy) 0%, transparent)); }
/* portrait tablet: Motie sits under the list, so the screen isn't an empty cream field */
@media (min-width: 600px) and (max-width: 839px) and (min-height: 900px) { .menu-motie { display: block; width: 280px; margin-top: var(--s12); } }
@media (min-width: 840px) {
  .mitem { min-height: 96px; font-size: var(--t-44); line-height: 52px; gap: var(--s5); }
  .mi-ic { width: 64px; height: 64px; }
  .menu-motie { display: block; }
  .menu-body { justify-items: stretch; grid-template-columns: minmax(0, 640px) minmax(0, 1fr); column-gap: var(--s12); align-content: center; padding-left: calc(var(--s24) + var(--safe-l)); }
}
@media (min-width: 840px) and (max-height: 640px) { .menu-motie { width: min(100%, 240px); } .mitem { min-height: 72px; font-size: var(--t-34); line-height: 42px; } }

/* reduced motion: brand.css stops movement; keep the crossfades readable */
@media (prefers-reduced-motion: reduce) {
  .menu, .doc-scrim, .toast, .player { transition-duration: var(--d-fade) !important; }
  .menu .mitem, .doc { transform: none !important; }
}

/* scroll fade: anything that scrolls on its own fades out at the bottom while there is more below */
@property --fade-b { syntax: "<length>"; inherits: false; initial-value: 0px; }
.doc-body, .menu-body { mask-image: linear-gradient(to bottom, var(--navy) calc(100% - var(--fade-b)), transparent); }
@supports (animation-timeline: scroll()) {
  .doc-body, .menu-body { animation: fade-b linear both; animation-timeline: scroll(self block); }
}
@keyframes fade-b { 0%, 94% { --fade-b: 40px; } 100% { --fade-b: 0px; } }

/* short screens: a smaller code square (after the base .qr rules so it wins) */
@media (max-height: 699px) { .qr-box svg { width: 88px; height: 88px; } .qr { padding: var(--s3); gap: var(--s4); } }
@media (orientation: landscape) and (max-height: 500px) { .qr-box { padding: var(--s2); } .qr-box svg { width: 64px; height: 64px; } .qr .hint { margin-top: 0; } }
/* narrow and short (320×568): code square and link stay side by side so the link shows on first view */
@media (max-width: 380px) and (max-height: 699px) { .qr { flex-direction: row; align-items: center; gap: var(--s3); } .qr-box { padding: var(--s2); } .qr-box svg { width: 72px; height: 72px; } }

/* consent: the required tick sits after the facts and the optional ones, in the flow; only the buttons are pinned */
.consents .consent.must { margin-top: var(--s2); }
/* short screens: the pinned row is one line of buttons, so the panel keeps the room */
@media (max-height: 699px) {
  .pfoot:has(.btn-primary):has(.btn-quiet) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--s3); padding-top: var(--s3); }
  .pfoot:has(.btn-primary):has(.btn-quiet) .btn-primary { padding: 0 var(--s4); }
}

/* menu, very short landscape (844×390): no room for Motie beside the list; three 60px rows that fit under the header */
@media (max-height: 450px) {
  .menu-motie { display: none !important; }
  .menu-body { grid-template-columns: minmax(0, 1fr) !important; justify-items: center !important; padding: var(--s2) calc(var(--gut) + var(--safe-r)) calc(var(--s4) + var(--safe-b)) calc(var(--gut) + var(--safe-l)) !important; }
  .menu-list { gap: var(--s1); max-width: 560px; }
  .mitem { min-height: 60px !important; padding: var(--s1) var(--s4) var(--s1) var(--s2); font-size: var(--t-28) !important; line-height: 36px !important; gap: var(--s4) !important; }
  .mi-ic { width: 48px !important; height: 48px !important; }
  .menu-sep { margin: 0 var(--s3); }
}
/* phone portrait: Motie under the list, as on the portrait tablet */
@media (max-width: 599px) and (min-height: 760px) { .menu-motie { display: block; width: 200px; margin-top: var(--s8); } }
/* phone portrait connect: the profile recap gives its room to the code field too */
@media (max-width: 599px) { .sheet-in:has(#join-code) .prof { display: none; } }
/* menu, narrow phones (320px): one line per item; type steps down to 23px and the icon to 44px */
/* landscape phones (844×390): chips a little tighter so the next row of chips shows above Done */
@media (orientation: landscape) and (max-height: 430px) {
  .chips { gap: 6px; margin-top: -6px; }
  .chips .chip { height: 44px; }
}
@media (max-width: 359px) {
  .chips .chip { padding: 0 var(--s3); }
  .mitem { gap: var(--s3); padding-right: var(--s2); font-size: var(--t-23); line-height: 30px; }
  .mi-ic { width: 44px; height: 44px; }
}
