/* Layout: the app grid, the sidebar / phone tab bar, the player bar. */

/* ---------- layout ---------- */
#app { height: 100%; display: grid; grid-template-columns: var(--nav-w-user, var(--nav-w)) 1fr; grid-template-rows: 1fr auto; grid-template-areas: "nav view" "bar bar"; }
#nav { grid-area: nav; background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px 12px; min-height: 0; }
#view { grid-area: view; overflow-y: auto; min-height: 0; outline: none; position: relative; }
#bar { grid-area: bar; }
/* The queue beside the page (view-queue.js QueueSide): a third column, only while it's open. */
#queueSide { grid-area: side; overflow-y: auto; min-height: 0; background: var(--bg-2); border-left: 1px solid var(--line); }
#app.q-side { grid-template-columns: var(--nav-w-user, var(--nav-w)) minmax(0, 1fr) clamp(300px, 26vw, 420px); grid-template-areas: "nav view side" "bar bar bar"; }
#queueSide .page { padding: 16px 10px 32px; }
#queueSide .page-head { gap: 8px; margin-bottom: 4px; }
#queueSide .page-head h1 { font-size: var(--fs-xl); padding-left: 6px; }
#queueSide .page-head .tools { flex-basis: 100%; gap: 6px; padding-left: 6px; }
#queueSide .tools .btn { padding: 5px 10px; font-size: var(--fs-s); }
#queueSide .qsection { margin: 16px 6px 6px; }
#queueSide .trow, #queueSide .tracks.no-album .trow { grid-template-columns: 26px minmax(0, 1fr) 40px 30px; gap: 8px; padding: 5px 6px; }
#queueSide .trow .al { display: none; }
/* Home carries the logo: no separate "Liner" line. On phones the tab keeps the plain house icon. */
.navlinks .navlogo { width: 22px; height: 22px; border-radius: var(--radius-s); flex: none; }
.navlinks a .hometab { display: none; }
.navlinks { display: flex; flex-direction: column; gap: 2px; }
.navlinks a, .navsettings { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-s); color: var(--text-2); font-weight: 500; }
.navlinks a:hover, .navsettings:hover { color: var(--text); background: var(--raise); }
.navlinks a.on, .navsettings.on { color: var(--text); background: var(--raise); }
.navlinks a.on svg, .navsettings.on svg { color: var(--accent); }
.navsettings { margin-top: auto; }
/* The sidebar's width (dragged at its edge), the rail of icons when it's narrow, and hidden. */
#nav { position: relative; min-width: 0; overflow: hidden; }
#app { position: relative; }
.navgrip { position: absolute; top: 0; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); left: calc(var(--nav-w-user, var(--nav-w)) - 4px); width: 8px; cursor: col-resize; z-index: 20; touch-action: none; }
.navgrip::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
#app.nav-hidden .navgrip { display: none; }
.navgrip:hover::after, .navgrip:focus-visible::after, #app.nav-dragging .navgrip::after { background: var(--accent); }
#app.nav-dragging { cursor: col-resize; user-select: none; }
.navlinks a span, .navsettings span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#app.nav-rail #nav { padding-left: 8px; padding-right: 8px; }
#app.nav-rail .navlinks a, #app.nav-rail .navsettings { justify-content: center; padding: 10px 0; }
#app.nav-rail .navlinks a span, #app.nav-rail .navsettings span { display: none; }
#app.nav-hidden { grid-template-columns: 0 1fr; }
#app.nav-hidden.q-side { grid-template-columns: 0 minmax(0, 1fr) clamp(300px, 26vw, 420px); }
#app.nav-hidden #nav { visibility: hidden; border: 0; padding: 0; }
.navhide { align-self: flex-start; margin: 6px 0 0 4px; color: var(--dim); }
#app.nav-rail .navhide { align-self: center; margin-left: 0; }
.navhide svg, .navshow svg { width: 18px; height: 15px; }
.navshow { position: fixed; left: 12px; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 12px); z-index: 30;
  background: rgba(20,22,28,.85); backdrop-filter: blur(8px); border: 1px solid var(--line); }
.navshow[hidden] { display: none; }
.badge { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 2px 5px; }
.badge:empty { display: none; }
.badge.tx { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
/* the stream format on the seek line: a quiet word, not a key */
.seek { position: relative; }
.seek #fmt { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 6px; border: 0; padding: 0; color: var(--dim); font-size: var(--fs-2xs); white-space: nowrap; }
.seek #fmt.tx { color: var(--accent); }
/* ---------- player bar ---------- */
#bar { height: calc(var(--bar-h) + env(safe-area-inset-bottom)); background: #0e0f14; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(160px, 1fr) minmax(max-content, 2fr) minmax(max-content, 1fr); align-items: center; gap: 16px;
  padding: 0 max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left)); }
#bar[hidden] { display: none; }
.np { display: flex; align-items: center; gap: 12px; min-width: 0; text-align: left; border-radius: var(--radius-s); padding: 4px; }
.np:hover { background: var(--raise); }
.np img { width: 56px; height: 56px; border-radius: var(--radius-s); object-fit: cover; background: var(--raise); flex: none; }
.np-text { display: flex; flex-direction: column; min-width: 0; }
.np-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { color: var(--text-2); font-size: var(--fs-m); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.buttons { display: flex; align-items: center; gap: 10px; }
.seek { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 640px; font-size: var(--fs-s); color: var(--dim); font-variant-numeric: tabular-nums; }
.seek input { flex: 1; }
.seek > span:not(.badge) { min-width: 38px; text-align: center; }
.extras { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.extras #vol { width: 100px; }
.extras .icon.on { color: var(--accent); }
/* ---------- pages ---------- */
.page { padding: 28px 32px 48px; max-width: 1600px; }
/* Home fills a wide window (its shelves scroll sideways and its tiles reflow), rather than stopping at 1600 px with
   a blank strip on the right */
.page.home { max-width: none; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -.02em; flex: 1 0 auto; max-width: 100%; overflow-wrap: anywhere; }
.page-head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head .head-icons { display: flex; gap: 2px; align-items: center; }
.page-head .phone-only, .libtabs, .home-foot { display: none; }
.navlinks a.phone-tab { display: none; }
.no-vol #vol, .no-vol #btnMute { display: none; }
#btnLove[aria-pressed=true] { color: var(--accent); }
#sleepBadge { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.on-dev { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; margin-right: 4px; }
.on-dev svg { width: 13px; height: 13px; }
#bar.remote #btnDevices, #btnDevices.on { color: var(--accent); }
#btnDevices { position: relative; }
#btnDevices.busy::after { content: ""; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg-2); }
.svol { display: flex; align-items: center; gap: 10px; padding: 4px 6px 0; color: var(--text-2); }
.svol[hidden] { display: none; }
.svol svg { width: 18px; height: 18px; flex: none; }
.svol input { flex: 1; }
.badge.dj { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); cursor: pointer; }
/* signed out: just the sign-in box */
body.signed-out #nav, body.signed-out #bar { display: none; }

/* the keys and extras need about 1300 px on one row; under that the transport gets a row of its own */
@media (max-width: 1300px) {
  #bar { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; height: auto; gap: 6px 12px;
    padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  #bar .transport { grid-column: 1 / -1; grid-row: 2; }
  .extras #vol { width: 80px; }
}

@media (max-width: 760px) {
  .q-dock, #queueSide { display: none; }
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; grid-template-areas: "view" "bar" "nav"; }
  #nav { flex-direction: row; padding: 4px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); border-right: 0; border-top: 1px solid var(--line); }
  /* mini-player: one row (art, title, play, next) with a thin progress line on top */
  #bar { padding-bottom: 8px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; position: relative; padding-top: 10px; }
  #bar::before { content: ""; position: absolute; left: 0; top: -1px; height: 2px; width: var(--prog, 0%); background: var(--accent); }
  #bar .transport { grid-column: 2; grid-row: 1; }
  #bar .seek, #bar #btnShuffle, #bar #btnRepeat, #bar #btnPrev, #bar .extras { display: none; }
  #bar .buttons { gap: 4px; }
  #bar .extras #vol, #bar #btnMute { display: none; }
  #bar .icon.play { width: 44px; height: 44px; }
  .navsettings, .navlinks .navlogo { display: none; }
  .navgrip, .navhide, .navshow { display: none !important; }
  #app.nav-hidden #nav, #app.nav-rail #nav { visibility: visible; }
  #app.nav-hidden, #app.nav-rail { grid-template-columns: 1fr; }
  .navlinks a .hometab { display: block; }
  .page-head .phone-only { display: inline-grid; place-items: center; width: 44px; height: 44px; color: var(--text-2); }
  .navlinks { flex-direction: row; justify-content: space-around; width: 100%; }
  /* phones: Home, Search, Library, Queue (Library switches between albums, artists and playlists) */
  .navlinks a[data-nav=artists], .navlinks a[data-nav=albums], .navlinks a[data-nav=playlists] { display: none; }
  .navlinks a.phone-tab { display: flex; }
  .libtabs { display: flex; gap: 6px; margin: 0 0 14px; }
  .libtabs a { flex: 1; text-align: center; padding: 9px 0; border-radius: 999px; background: var(--raise); color: var(--text-2); font-weight: 600; font-size: var(--fs-base); }
  .libtabs a[aria-selected=true] { background: var(--text); color: var(--bg); }
  .libtabs + .page-head h1 { display: none; }
  /* the selected tab already says it */
  .libtabs + .page-head { justify-content: flex-end; margin-bottom: 10px; }
  .navlinks a { flex-direction: column; gap: 2px; font-size: var(--fs-xs); padding: 6px 4px; min-width: 48px; min-height: 48px; justify-content: center; }
  .page { padding: 20px 16px 32px; }
  #bar .np img { width: 44px; height: 44px; }
  #fmt { display: none; }
}

/* The whole app's moving album-art background (livebg.js AppBg): the canvas fills the window behind everything,
   a dark veil keeps the pages readable, and the sidebar and player become frosted glass over it. On the Mac the
   page runs under the title bar (the app's web view fills the window), so everything starts below it. */
#appbg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; pointer-events: none;
  filter: brightness(.42) saturate(1.15); }
#appbgviz { position: fixed; inset: 0; z-index: 0; pointer-events: none; filter: brightness(.42) saturate(1.15); }
#appbgviz .viz.viz-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; cursor: default; animation: fadein .8s ease; }
html.has-appbg body { background: #08090c; }
html.has-appbg body::after { content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 35% 25%, rgba(8,9,12,.3), rgba(8,9,12,.6) 75%); }
/* over the moving album colours the quiet text is lifted: with the veil above, at its thinnest over a pure white
   album (the canvas at 42% brightness), --text-2 here is 5.1:1 and --dim 4.7:1 (WCAG AA); --text 7.1:1 */
html.has-appbg #view { --text-2: #c8cbd3; --dim: #bfc2cb; }
html.has-appbg #app { position: relative; z-index: 1; }
html.has-appbg #nav { background: rgba(14,15,20,.5); -webkit-backdrop-filter: blur(24px) saturate(1.3); backdrop-filter: blur(24px) saturate(1.3); border-right-color: rgba(255,255,255,.06); }
html.has-appbg #bar { background: rgba(12,13,18,.62); -webkit-backdrop-filter: blur(28px) saturate(1.3); backdrop-filter: blur(28px) saturate(1.3); border-top-color: rgba(255,255,255,.06); }
@media (min-width: 761px) {
  #nav { padding-top: calc(18px + env(safe-area-inset-top)); }
  #view { padding-top: env(safe-area-inset-top); }
}

/* The volume fader in the Mac app: unity marked at 80% of the travel; past it (+6 dB) the fill turns warm. */
.extras #vol.boost { width: 120px; background-image: linear-gradient(90deg, transparent calc(80% - 1px), rgba(245,165,36,.9) calc(80% - 1px), rgba(245,165,36,.9) calc(80% + 1px), transparent calc(80% + 1px)); }
.extras #vol.over::-webkit-slider-runnable-track { background: linear-gradient(to right, #ff8a1f var(--p), var(--track) var(--p)); }

/* The radio playing (bar.js paintRadio): the station and a stop key in place of the song and its transport */
.radiobar { grid-column: 1 / 3; grid-row: 1; display: flex; align-items: center; gap: 16px; min-width: 0; }
.radiobar[hidden], #bar.radio > .np, #bar.radio > .transport, #bar.radio #btnLove, #bar.radio #btnLyrics, #bar.radio .seek #fmt { display: none; }
.radiobar .np { flex: 0 1 auto; min-width: 0; }
.radiobar .np-sub { color: var(--accent); }
.radiobar .icon.play svg { width: 18px; height: 18px; }
@media (max-width: 1300px) { .radiobar { grid-column: 1; } }
@media (max-width: 760px) {
  .radiobar { grid-column: 1 / -1; justify-content: space-between; }
  #bar.radio::before { display: none; }
}

/* Home: ‹ › to page a sideways row (a mouse wheel only scrolls them with Shift), and See all on rows that have more */
h2.row-title .shelf-nav { margin-left: auto; display: inline-flex; gap: 4px; align-self: center; }
h2.row-title .see-all { align-self: center; font-size: var(--fs-s); }
h2.row-title .see-all + .shelf-nav { margin-left: 0; }
h2.row-title:has(.see-all) .see-all { margin-left: auto; }
@media (hover: none) { h2.row-title .shelf-nav { display: none; } }
/* Radio: a preset saved for another place can be cleared */
.rd-preset.away { position: relative; }
.rd-preset .rd-clear { margin-left: auto; flex: none; opacity: .7; }
.rd-preset .rd-clear:hover { opacity: 1; }

/* Playlists: a folder (a name prefix, "Folder › Name") is a section that folds */
.pl-folder > summary { list-style: none; cursor: pointer; }
.pl-folder > summary::-webkit-details-marker { display: none; }
.pl-folder > summary h2.row-title { align-items: center; }
.pl-folder > summary h2.row-title svg { width: 18px; height: 18px; color: var(--dim); transition: transform .15s; }
.pl-folder[open] > summary h2.row-title svg { transform: rotate(90deg); }
.pl-folder > summary:hover h2.row-title { color: var(--accent); }

/* ---------- car mode (car.js: the Tesla's browser, opened at /car) ----------
   The same app for a touchscreen at arm's length: type about a quarter bigger, every key a finger's width, the
   seek and volume sliders thick with their knobs always showing (no hover in a car), and the player bar on two rows
   so the bigger keys fit. Only the sizes change; nothing is hidden. */
html.car {
  --fs-2xs: 12px; --fs-xs: 14px; --fs-s: 15px; --fs-m: 16px; --fs-base: 18px; --fs-l: 19px; --fs-xl: 23px;
  --fs-2xl: 30px; --fs-3xl: 38px;
  --nav-w: 260px;
}
html.car svg { width: 24px; height: 24px; }
html.car .icon { width: 56px; height: 56px; }
html.car .icon.sm { width: 50px; height: 50px; }
html.car .icon.sm svg { width: 22px; height: 22px; }
html.car .icon.play, html.car #bar .icon.play { width: 76px; height: 76px; }
html.car .icon.play svg { width: 32px; height: 32px; }
html.car .btn { padding: 13px 22px; }
html.car .btn.sm { padding: 10px 16px; }
html.car .navlinks a, html.car .navsettings { padding: 14px 12px; gap: 14px; }
html.car .trow { padding: 12px 10px; }
html.car #bar { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; height: auto; gap: 8px 20px;
  padding: 12px max(20px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
html.car #bar .transport { grid-column: 1 / -1; grid-row: 2; gap: 8px; }
html.car #bar .buttons { gap: 22px; }
html.car #bar .seek { max-width: none; }
html.car .np img { width: 84px; height: 84px; }
html.car .navgrip { display: none; }   /* (no dragging the sidebar's edge in a car) */
html.car .extras #vol { width: 160px; }
html.car input[type=range] { height: 36px; }
html.car input[type=range]::-webkit-slider-runnable-track { height: 8px; }
html.car input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -8px; opacity: 1; }
html.car input[type=range]::-moz-range-track, html.car input[type=range]::-moz-range-progress { height: 8px; }
html.car input[type=range]::-moz-range-thumb { width: 24px; height: 24px; }
