/* Arka on a wide window. The phone layout is the app; from 1024px the same parts are laid out for a
   desk: the tabs go to a sidebar, the mini player becomes a bar along the bottom carrying the transport
   and the scrubber (moved there by app.js, so they're the same buttons), Now playing opens as a panel
   beside the page instead of a sheet over it, and option sheets open as dialogs in the middle. Nothing
   here applies below 1024px: there the phone layout is exactly as style.css draws it. */

.mini-ctl { display: none; }   /* the bar's transport slot: empty, and out of the way, on a phone */

@media (min-width: 1024px) {
  :root {
    --side-w: clamp(184px, 15vw, 232px);
    --np-w: clamp(320px, 27vw, 420px);
    --content-max: 1000px;
    --tabs-h: 0px;          /* the tabs no longer sit at the bottom: every sum that cleared them drops them */
    --mini-h: 88px;
  }
  body { --np-room: 0px; }
  body.np-side { --np-room: var(--np-w); }
  /* the page's column: what's left between the sidebar and the panel, at most --content-max, centred */
  body { --pad-x: max(0px, (100% - var(--side-w) - var(--np-room) - var(--content-max)) / 2); }

  /* a window has no status bar above the page, so a tab's title gets room of its own, level with the
     sidebar's first tab (24 + half the 35px title = 20 + half the 44px tab) */
  body.is-root main { padding-top: calc(var(--sat) + 24px); }
  main {
    padding-left: calc(var(--side-w) + var(--pad-x));
    padding-right: calc(var(--np-room) + var(--pad-x));
  }
  .bar { left: calc(var(--side-w) + var(--pad-x)); right: calc(var(--np-room) + var(--pad-x)); padding-left: 4px; padding-right: 4px; }
  .toast { left: var(--side-w); right: var(--np-room); }
  .ll-ret.fixed { left: var(--side-w); right: var(--np-room); }
  .ll-retb { max-width: calc(100% - 2 * var(--gut)); }

  /* ---------------------------------------------------------- sidebar */
  .tabs {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: var(--z-dock);
    width: var(--side-w); height: auto; padding: calc(20px + var(--sat)) 0 8px;
    display: flex; flex-direction: column;
    border-top: 0; border-right: 1px solid var(--line);
  }
  body.has-mini .tabs { bottom: calc(var(--mini-h) + var(--sab)); }
  .tabs::after { content: none; }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; height: 44px; padding: 0 20px; }
  .tabs a > span:nth-child(2) { margin-right: 0; }
  .tabs a:focus-visible { outline-offset: -2px; }
  .badge { position: static; margin-left: auto; }

  /* ---------------------------------------------------------- player bar */
  /* the middle column gives way before the title does; the bar clears the home indicator and the
     sides of an iPad's screen as the phone's does */
  .mini {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, min(560px, 46%)) minmax(0, 1fr); column-gap: 24px; align-items: center;
    height: calc(var(--mini-h) + var(--sab));
    padding: 0 max(16px, env(safe-area-inset-right)) var(--sab) max(16px, env(safe-area-inset-left));
  }
  /* opens and closes the panel: its hover tint reaches a little past the cover and the title */
  /* at least 320px wide however short the title, so a one-word name isn't a small target */
  .mini-open { grid-column: 1; grid-row: 1; justify-self: start; min-width: min(calc(100% + 8px), 320px); max-width: calc(100% + 8px); margin-left: -8px; padding: 0 16px 0 8px; }
  .mini-art { width: 56px; height: 56px; }
  #mini-toggle, #mini-skip, .mini-bar { display: none; }
  .mini.live::after { content: none; }   /* the scrubber's own red dot says live */
  .mini-ctl {
    grid-column: 2; grid-row: 1; display: grid; align-content: center; row-gap: 4px; column-gap: 12px;
    grid-template-columns: 64px minmax(0, 1fr) 64px; grid-template-areas: "tr tr tr" "pos sc dur";
  }
  .mini-ctl .transport { grid-area: tr; display: flex; justify-content: center; gap: 8px; margin: 0; }
  .mini-ctl .t-btn, .mini-ctl .t-play { width: 48px; height: 40px; flex: none; }
  .mini-ctl .t-btn svg, .mini-ctl .t-play svg { width: 18px; height: 18px; }
  .mini-ctl #t-back svg, .mini-ctl #t-fwd svg { width: 24px; height: 24px; }
  body:has(#np.is-live) #t-back, body:has(#np.is-live) #t-fwd { display: none; }
  /* the line sits in a 20px row so the bar keeps 12px above the transport and below the line; its reach is
     40px all the same, reaching into the gap above and the bar's bottom margin (never over a button) */
  .mini-ctl .scrub { grid-area: sc; height: 20px; margin: 0; }
  .mini-ctl .scrub::before { content: ""; position: absolute; inset: -4px 0 -16px; }
  .mini-ctl .scrub-track { top: 8px; }
  .mini-ctl .scrub-thumb { top: 4px; }
  .mini-ctl .scrub.live::after { top: 6px; }
  .mini-ctl .times { display: contents; }
  .mini-ctl #t-pos { grid-area: pos; justify-self: end; align-self: center; }
  .mini-ctl #t-dur { grid-area: dur; justify-self: start; align-self: center; }

  /* ---------------------------------------------------------- Now playing, beside the page */
  .np { top: 0; right: 0; bottom: 0; left: auto; width: var(--np-w); }
  body.has-mini .np { bottom: calc(var(--mini-h) + var(--sab)); }
  .np-backdrop { display: none; }
  .np-sheet {
    --np-xl: 24px; --np-xr: 24px;
    padding: 0 24px 24px; border-left: 1px solid var(--line); box-shadow: none;
    translate: none; opacity: 0; transition: opacity 120ms ease;
    scroll-padding-top: calc(var(--sat) + 72px);
  }
  .np.open .np-sheet { opacity: 1; }
  .np-top { margin: 0 -24px; padding: var(--sat) 24px 0; touch-action: auto; }   /* clear of the status bar, installed */
  .np-top .grabber { display: none; }
  .np-head { height: 52px; }   /* its rule level with the top bar's */
  #np-close svg { rotate: -90deg; }   /* the chevron points the way the panel goes */
  .np-drag { touch-action: auto; }
  .np-art { width: 100%; }
  .np-art.paused { scale: 1; }   /* beside the page a shrinking cover reads as the layout jumping; play/pause and the bars say it */
  .np-sheet .np-id { margin-top: 20px; }

  /* ---------------------------------------------------------- option sheets as dialogs */
  /* dialogs hang from near the top, not the middle: a step to shorter or longer content moves only the bottom edge */
  .sheet-wrap { justify-content: flex-start; align-items: center; padding: clamp(48px, 16vh, 160px) 24px 24px; }
  .sheet {
    width: min(480px, 100%); max-height: min(760px, calc(100dvh - clamp(48px, 16vh, 160px) - 24px));
    padding: 16px var(--gut); border: 1px solid var(--line); box-shadow: none;
    translate: none; opacity: 0; scale: .98;
    transition: opacity 140ms ease, scale 140ms var(--ease-out);
  }
  .sheet-wrap.open .sheet { opacity: 1; scale: 1; }
  .sheet-wrap.closing .sheet, .sheet-wrap.closing .sheet-backdrop { transition-duration: 120ms; }
  .sheet-backdrop { transition-duration: 140ms; }
  .sheet-grab .grabber { display: none; }
  .sheet-grab { touch-action: auto; }

  /* ---------------------------------------------------------- the extra width */
  .rail { grid-auto-columns: 184px; }
  .rail.sm { grid-auto-columns: 148px; }
  .genre-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .detail > .actions { max-width: 480px; }   /* an episode's Play now stays a button, not a band */
}

/* a fingertip on a wide touch screen: the transport's buttons at full height */
@media (min-width: 1024px) and (pointer: coarse) {
  :root { --mini-h: 92px; }   /* 12 + 44 + 4 + 20 + 12: the same margins round the taller buttons */
  .mini-ctl .t-btn, .mini-ctl .t-play { height: 44px; }
  .mini-ctl .scrub::before { bottom: -20px; }   /* 44px of reach for a finger */
}
/* over the dark scrim the dialog's edge needs the control rule to be seen */
@media (min-width: 1024px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sheet { border-color: var(--line-control); }
}
@media (min-width: 1024px) {
  :root[data-theme="dark"] .sheet { border-color: var(--line-control); }
}

@media (min-width: 1024px) and (prefers-reduced-motion: reduce) {
  .sheet { scale: none; }
}
