/* Brateng Music v3 — the kids' iPad shell (SPEC v3 §6.2, D33-D36, D40).
 *
 * Carried from the approved mockup (design/build_v3_kid_mockups.py, its CSS
 * string) — tokens, radii, sizes and metrics VERBATIM where the spec does not
 * override. The player component lives in base.css because §5 defines it once
 * for all three shells; everything here is the four screens around it: the
 * shelf, the playlist/album/artist list page, search and bedtime.
 *
 * Browser floor (§8.1): Chrome 96 ∩ Safari 15. No :has(), no container
 * queries, no nesting, no @layer, no overscroll-behavior, no :focus-visible,
 * no dvh. aspect-ratio and CSS grid are in and used.
 *
 * The stage is a fixed 1024x768 canvas scaled by js/shells/stage.js. The iPad
 * keyboard OVERLAYS rather than pushing (§6.2), so the typing state reserves a
 * fixed 398 pt band and the stage never rescales.
 */

/* ==================================================================== SHELF */
.shelf { flex-direction: column; padding: 28px 36px 0; }
.shelf .hdr { display: flex; align-items: center; gap: 14px; height: 64px; flex: 0 0 auto; }
.shelf .who { font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.hdr .sp { flex: 1; }

/* The grid scaling rule (§6.2, §5b item 11): 1-2 lists = one row of big tiles;
   more = two rows with ceil(n/2) columns. Eight is the ceiling and therefore
   the minimum tile size. Tiles are square at every count. */
.tiles {
  flex: 1; display: grid;
  grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr 1fr;
  gap: 22px 24px; margin-top: 22px; padding-bottom: 28px;
  min-height: 0; align-content: center; justify-items: center;
}
.tiles.c1 { grid-template-columns: 1fr; }
.tiles.c2 { grid-template-columns: repeat(2, 1fr); }
.tiles.c3 { grid-template-columns: repeat(3, 1fr); }
.tiles.r1 { grid-template-rows: 1fr; }
.tiles.r1 .tile .t { font-size: 26px; margin-top: 16px; }
.tiles.r1 .tile .t small { font-size: 17px; }
.tiles.c3 .tile .t { font-size: 21px; }
/* On-glass edit (Emma's iPad, 2026-09-11, Phil): the bottom bar needs room.
   The mockup's 112 px put a two-row caption ON the bar's top edge (the grid
   overflowed its box by ~8 px at 210 px tiles); 128 px = bar top (104) + a
   24 px gap, and the playing-state tiles drop to 196 px so two rows fit:
   2 × (196 + 54 caption) + 22 gap = 522 ≤ 526 available. */
.stage.playing .tiles, .stage.bedtime .tiles { padding-bottom: 128px; }

.tile { display: flex; flex-direction: column; color: var(--text); width: 220px; }
.stage.playing .tiles.c4 .tile, .stage.bedtime .tiles.c4 .tile { width: 196px; }
.tiles.c3 .tile, .tiles.c2.r2 .tile { width: 262px; }
.stage.playing .tiles.c3 .tile, .stage.bedtime .tiles.c3 .tile,
.stage.playing .tiles.c2.r2 .tile, .stage.bedtime .tiles.c2.r2 .tile { width: 196px; }
.tiles.r1 .tile { width: 464px; }
.tile .a {
  flex: 0 0 auto; width: 100%; aspect-ratio: 1; border-radius: var(--r);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .5); position: relative;
  background: var(--panel2) center/cover no-repeat;
}
.tiles.r1 .tile .a { border-radius: 28px; }
/* A tile whose art is empty renders the flat card with the title centred and
   NO placeholder glyph — library playlists frequently have no art and that is
   the ordinary case, not an error (§5). */
.tile .a .noart {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 16px; text-align: center; color: var(--dim);
  font-size: 20px; font-weight: 700; line-height: 1.25;
}
.tile .a i {
  position: absolute; right: 12px; bottom: 12px; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(11, 13, 18, .72);
  display: none; place-items: center; color: #fff;
}
.tile .a i .ico { width: 22px; height: 22px; }
.stage.playing .tile.now .a i { display: grid; }
.tile .t {
  width: 100%; text-align: left; margin-top: 10px; font-size: 19px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 0 auto;
}
.tile .t small { display: block; color: var(--dim); font-size: 14px; font-weight: 500; margin-top: 1px; }
/* Her sister's tile: subtitle "<sister>'s · listen only", art slightly dimmed
   (§6.2, from §7.4's listen_only flag). */
.tile.ro .a { opacity: .85; }
.shelf .empty { grid-column: 1 / -1; color: var(--dim); font-size: 24px; font-weight: 600; text-align: center; }

/* Two bottom bars, MUTUALLY EXCLUSIVE (§6.2). The now-playing bar while music
   plays; the bedtime bar while a timer runs. */
/* `.stage .nowbar`, not `.nowbar`: the bar is a <button> (a tap anywhere but
   the three keys returns to the player, §6.2) and base.css's `.stage button`
   reset outranks a bare class — see the note at base.css's shared chrome. */
.stage .nowbar {
  position: absolute; left: 36px; right: 36px; bottom: 24px; height: 80px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  display: none; align-items: center; gap: 16px; padding: 0 14px 0 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55); width: auto;
}
.stage.playing .nowbar:not(.bedbar) { display: flex; }
.stage.bedtime .nowbar:not(.bedbar) { display: none; }
.stage.bedtime .nowbar.bedbar { display: flex; background: #12141a; border-color: #2a2618; }
.nowbar.bedbar .th.moon { display: grid; place-items: center; background: #1e1a12; color: var(--amber); }
.nowbar.bedbar .th.moon .ico { width: 30px; height: 30px; }
.nowbar.bedbar .tt b { color: #f3e9d6; }
.nowbar.bedbar .tt small { color: #a89673; }
.nowbar.bedbar .left { font-size: 24px; font-weight: 800; color: var(--amber); font-variant-numeric: tabular-nums; padding-right: 16px; }
.nowbar .th { width: 60px; height: 60px; border-radius: 14px; flex: 0 0 auto; background: var(--panel2) center/cover no-repeat; }
.nowbar .tt { flex: 1; min-width: 0; line-height: 1.15; }
.nowbar .tt b { display: block; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowbar .tt small { display: block; color: var(--dim); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowbar .k { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; color: var(--text); flex: 0 0 auto; }
.nowbar .k .ico { width: 30px; height: 30px; }
.nowbar .k.pp { background: var(--text); color: #0b0d12; }
.nowbar .k.pp .ico { width: 32px; height: 32px; }

/* ==================================== PLAYLIST / ALBUM / ARTIST LIST PAGE */
/* 24 px bottom inset to match the top (on-glass edit, 2026-09-11): the mockup
   ran the list to the bottom edge, which reads as no border on the tablet. */
.plist { flex-direction: column; padding: 24px 36px 24px; }
.plist .hdr { display: flex; align-items: center; height: 56px; gap: 10px; flex: 0 0 auto; }
.plist .hdr .sp { flex: 1; }
.pld { display: flex; gap: 26px; align-items: flex-end; margin-top: 10px; flex: 0 0 auto; }
.pld .a { width: 170px; height: 170px; border-radius: 18px; flex: 0 0 auto; box-shadow: 0 14px 34px rgba(0, 0, 0, .5); background: var(--panel2) center/cover no-repeat; }
.pld .a.round { border-radius: 50%; }
.pld h2 { font-size: 40px; font-weight: 800; line-height: 1.05; letter-spacing: -.015em; }
.pld .m { color: var(--dim); font-size: 18px; margin-top: 6px; }
.pld .go { margin-top: 16px; display: flex; gap: 12px; }
.pld .go button { height: 56px; padding: 0 24px; border-radius: 999px; font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.pld .go .p { background: var(--text); color: #0b0d12; }
.pld .go .s { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.pld .go .ico { width: 22px; height: 22px; }
/* Every song in TWO COLUMNS so sixteen show at once (§6.2). */
/* The scroll box and the grid are TWO elements, on purpose. On Emma's iPad
   (iPadOS 15, 2026-09-11) the list panned on both axes like a map, and the
   first fix — minmax(0, 1fr) tracks, overflow-x hidden, pan-y on the grid
   itself — changed nothing on the glass, though it cures the same symptom in
   current WebKit and Chrome. The two scrollers that DO work there, .hits and
   .pq, are plain blocks whose rows are the full 952 px wide; this was the one
   scroller that was also a grid, with 465 px rows that nearly every real title
   overruns. Whatever Safari 15 gets wrong in that combination (fr floors, a
   <button> whose flex child will not shrink), row content past the row's edge
   became the scroller's own scrollable overflow. So: the scroller is now the
   same shape as .hits — a block with overflow-y auto — and the grid lives in a
   .rows wrapper that clips (overflow hidden, as the approved mockup's own
   .plist .list is), so nothing the grid or its rows do can widen the scroll
   area. Each row clips too: overflow hidden zeroes a grid item's automatic
   minimum in every engine, minmax(0, 1fr) or not. Vertical only, by layout. */
.plist .list { margin-top: 18px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.plist .list .rows { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 22px; align-content: start; overflow: hidden; }
.plist .list .tr { height: 60px; background: none; min-width: 0; max-width: 100%; overflow: hidden; }
.plist .list .tr:nth-child(4n+3), .plist .list .tr:nth-child(4n+4) { background: rgba(255, 255, 255, .03); }
/* A playlist whose tracks are all unplayable renders its rows dimmed with Play
   and Shuffle disabled, rather than an empty page (§5). */
.plist .list .tr.dim { opacity: .45; pointer-events: none; }
.plist .empty { grid-column: 1 / -1; color: var(--dim); font-size: 22px; font-weight: 600; padding: 24px 14px; }
/* The tapped Play / Shuffle / row shows a pressed state at once — a class,
   not :active, because the tap's work (the play POST) outlives the touch and
   iOS drops :active the moment the finger lifts (D41 follow-up). Cleared on
   the page's next open(). */
.plist .go button.pressed { transform: scale(.96); opacity: .8; }
.plist .list .tr.pressed { background: rgba(255, 255, 255, .12); }

/* =================================================================== SEARCH */
/* Same 24 px bottom inset as the list page (on-glass edit, 2026-09-11). The
   keyboard band below is a margin on .hits, so the two add: with the keyboard
   up the hits end 24 px above the band, which is the intent. */
.search { flex-direction: column; padding: 24px 36px 24px; }
.sbar { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.sbox { flex: 1; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 22px; border-radius: 999px; background: var(--panel); border: 2px solid var(--accent); }
.sbox .ico { width: 28px; height: 28px; color: var(--accent2); flex: 0 0 auto; }
.sbox input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 26px; font-weight: 600;
  -webkit-appearance: none; appearance: none; padding: 0;
}
/* A type=search field draws its own clear button in both engines, beside the
   mockup's `.x` — two clear controls in one pill. Suppress the native pair. */
.sbox input::-webkit-search-cancel-button,
.sbox input::-webkit-search-decoration,
.sbox input::-webkit-search-results-button { -webkit-appearance: none; appearance: none; display: none; }
.sbox input::-webkit-input-placeholder { color: var(--dim); font-weight: 500; }
.sbox input::placeholder { color: var(--dim); font-weight: 500; }
.sbox .x { width: 44px; height: 44px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; color: var(--dim); flex: 0 0 auto; }
.sbox .x .ico { width: 20px; height: 20px; color: var(--dim); }
.hits { margin-top: 14px; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.search .tr { height: 56px; }
.search .sh { margin: 8px 0 4px 14px; }
.search .empty { color: var(--dim); font-size: 22px; font-weight: 600; padding: 24px 14px; }
/* The iOS keyboard OVERLAYS: the layout viewport never changes and no resize
   fires, so the typing state reserves a FIXED BAND and the stage does not
   rescale (§6.2). 398 pt is the approved mockup's figure and is the DEFAULT
   here; where `visualViewport` reports a real keyboard, search.js overwrites
   `--kbband` with the MEASURED overlap converted into stage px (the band is
   inside the scaled stage, the measurement is in device px), which is what
   §6.2 schedules B2's device probe to pin. */
.stage.kbup .hits { margin-bottom: var(--kbband, 398px); }
/* Standing up, the keyboard is shorter: 300 px on the Air 2 in portrait, the
   bench's measurement (bedside reference/air2_web_app_facts.md). Same rule —
   a measured band still overrides it. */
.stage.portrait.kbup .hits { margin-bottom: var(--kbband, 300px); }

/* ================================================================= BEDTIME */
.bed { flex-direction: column; align-items: center; justify-content: center; background: #07080b; color: #e9dcc3; text-align: center; padding: 0 60px; }
.bed .face { display: flex; flex-direction: column; align-items: center; }
.bed .homebtn { position: absolute; right: 36px; top: 26px; background: #12141a; border-color: #23262f; color: #8a7b5c; }
.bed .moon { width: 120px; height: 120px; color: var(--amber); opacity: .9; filter: drop-shadow(0 0 40px rgba(217, 164, 65, .35)); }
.bed .moon .ico { width: 120px; height: 120px; }
.bed h1 { margin-top: 26px; font-size: 46px; font-weight: 800; letter-spacing: -.015em; color: #f3e9d6; }
.bed .sub { margin-top: 10px; font-size: 21px; color: #a89673; font-weight: 500; }
.bed .sub b { color: #e9dcc3; font-weight: 700; }
.bed .start { margin-top: 40px; height: 84px; padding: 0 60px; border-radius: 999px; background: #f3e9d6; color: #1a1408; font-size: 26px; font-weight: 800; display: flex; align-items: center; gap: 14px; }
.bed .start .ico { width: 30px; height: 30px; }
.bed .ring { position: relative; width: 320px; height: 320px; }
.bed .ring svg { position: absolute; inset: 0; width: 320px; height: 320px; transform: rotate(-90deg); }
.bed .ring .bg { fill: none; stroke: #1e1a12; stroke-width: 12; }
.bed .ring .fg { fill: none; stroke: var(--amber); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 848; stroke-dashoffset: 0; }
.bed .ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; font-weight: 800; letter-spacing: -.02em; color: #f3e9d6; font-variant-numeric: tabular-nums; }
.bed .ring .num small { display: block; font-size: 17px; font-weight: 600; color: #a89673; letter-spacing: .12em; text-transform: uppercase; margin-top: 6px; }
.bed .stopb { margin-top: 44px; height: 64px; padding: 0 40px; border-radius: 999px; border: 1px solid #3a3325; color: #e9dcc3; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.bed .stopb .ico { width: 22px; height: 22px; }

/* The kid shell's toast sits ABOVE the now-playing bar, in the shelf's own
   type — never a modal, never a retry button (§8.3). Scaled: the toast is on
   <body> at 1:1 and the bar is inside the stage (see base.css's `.toast`). */
body.shell-kid .toast { bottom: calc(120px * var(--stage-scale, 1)); }

/* ============================================================= BEDSIDE'S CLOCK
 * The embed hook (bedside SPEC §3.2, D63): Music opened inside Bedside carries a
 * Clock pill at the top left of every screen, and each header moves over for
 * it. Absent outside Bedside's frame — `.embedded` is set only by kid/embed.js. */
.stage .pill.clockpill { position: absolute; left: 36px; top: 24px; z-index: 6; height: 58px; }
.stage .pill.clockpill .ico { width: 26px; height: 26px; }
.stage[data-screen="bedtime"] .pill.clockpill { background: #12141a; border-color: #23262f; color: #8a7b5c; }
.stage.embedded .shelf .hdr,
.stage.embedded .search .sbar,
.stage.embedded .player .top { padding-left: 150px; }

/* ================================================================ PORTRAIT
 * bedside SPEC §3.1 (D63): the Air 2 standing up, a 768x1004 canvas — Bedside's
 * frames 8-13 (bedside/design/mockups_v1.html, their y less the 20 pt status bar
 * the mockups draw). Every rule above still holds; only the arrangement moves. */

/* Shelf (frame 8): her name in the top bar, the grid rule turned upright — two
   columns up to four lists, three beyond, square tiles, eight the ceiling. The
   sizes leave the now-playing bar its 128 px, as the landscape rule does. */
.stage.portrait .shelf { padding: 24px 36px 0; }
.stage.portrait .shelf .hdr { height: 58px; }
.stage.portrait .shelf .who { font-size: 36px; letter-spacing: -.02em; }
.stage.portrait .tiles { margin-top: 44px; align-content: start; gap: 26px 36px; padding-bottom: 28px; }
.stage.portrait .tiles.pc1 { grid-template-columns: 1fr; }
.stage.portrait .tiles.pc2 { grid-template-columns: repeat(2, 1fr); }
.stage.portrait .tiles.pc3 { grid-template-columns: repeat(3, 1fr); gap: 22px 24px; }
.stage.portrait .tiles.pr1 { grid-template-rows: auto; }
.stage.portrait .tiles.pr2 { grid-template-rows: repeat(2, auto); }
.stage.portrait .tiles.pr3 { grid-template-rows: repeat(3, auto); }
.stage.portrait .tiles.pc1 .tile { width: 420px; }
.stage.portrait .tiles.pc2 .tile { width: 290px; }
.stage.portrait .tiles.pc3 .tile { width: 200px; }
.stage.portrait.playing .tiles.pc2.pr2 .tile, .stage.portrait.bedtime .tiles.pc2.pr2 .tile { width: 270px; }
.stage.portrait .tiles.pc3.pr3 .tile { width: 190px; }
.stage.portrait.playing .tiles.pc3.pr3 .tile, .stage.portrait.bedtime .tiles.pc3.pr3 .tile { width: 160px; }
.stage.portrait .tile .t { font-size: 24px; margin-top: 14px; }
.stage.portrait .tile .t small { font-size: 17px; }
.stage.portrait .tiles.pc3 .tile .t { font-size: 20px; }
.stage.portrait .nowbar { height: 96px; }

/* List page (frame 10): one column of songs, so the names fit. */
.stage.portrait .pld .a { width: 220px; height: 220px; }
.stage.portrait .pld h2 { font-size: 46px; }
.stage.portrait .plist .list .rows { grid-template-columns: minmax(0, 1fr); }
.stage.portrait .plist .list .tr { height: 66px; }
.stage.portrait .plist .list .tr:nth-child(4n+3),
.stage.portrait .plist .list .tr:nth-child(4n+4) { background: none; }
.stage.portrait .plist .list .tr:nth-child(2n) { background: rgba(255, 255, 255, .03); }

/* Player (frame 9): the toggle centred under the top bar, the art on top, then
   the origin line and the title with Add to My List beside it, progress,
   transport and volume — the same parts, stacked. */
.stage.portrait .player { padding: 24px 36px 26px; }
.stage.portrait .player .top { height: 58px; }
.stage.portrait .player .seg { position: absolute; top: 96px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
.stage.portrait .player .body { flex-direction: column; align-items: stretch; margin-top: 72px; }
.stage.portrait .player .lft { width: 100%; height: 420px; flex: 0 0 auto; align-items: center; }
.stage.portrait .art { width: 400px; height: 400px; }
.stage.portrait .lyr { left: 40px; right: 40px; }
.stage.portrait .player .col { margin-left: 0; margin-top: 24px; height: auto; flex: 1; justify-content: flex-start; position: relative; padding: 0 28px; }
.stage.portrait .ttl { font-size: 40px; padding-right: 240px; -webkit-line-clamp: 1; }
.stage.portrait .addrow { position: absolute; right: 28px; top: 28px; margin-top: 0; }
.stage.portrait .prog { margin-top: 20px; }
.stage.portrait .tx { margin-top: 16px; }
.stage.portrait .vol { margin-top: 16px; }
