/* library.css (U-LIBRARY): library views, playlist page, track list, options / add-to-playlist / edit sheets.
   Look (docs/ui-reference.png, research/ui.md 3, 5.9-5.13, 7.2): blurred art band on top with a heavy white
   headline, the light lower half, quiet cards and flush-ish cover tiles with the double focus ring. Tokens only. */

.lib-view { padding-top: 0; }

/* ---- art band hero ---------------------------------------------------------------------------------------- */
.lib-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: clamp(220px, 36vh, 400px);
  margin: 0 calc(-1 * var(--gutter));
  padding: var(--s-7) var(--gutter) var(--s-6);
  overflow: hidden;
  color: var(--on-band);
  background: linear-gradient(135deg, var(--art, #3B4A8F) 0%, #1A1D2E 100%);
}
.lib-hero-art { position: absolute; inset: 0; z-index: -2; }
.lib-hero-art img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(28px) saturate(1.15);
  transform: scale(1.25);
}
.lib-hero::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, var(--scrim-top) 0%, rgba(8, 8, 12, .28) 45%, rgba(8, 8, 12, .55) 100%);
}
[data-perf="low"] .lib-hero-art img { filter: none; opacity: 0; }
.lib-hero-body { display: flex; align-items: flex-end; gap: var(--s-6); width: 100%; min-width: 0; }
.lib-hero-cover { flex: none; width: clamp(140px, 16vw, 232px); aspect-ratio: 1; box-shadow: var(--sh-3); background: rgba(255, 255, 255, .12); }
.lib-hero-cover .img { width: 100%; height: 100%; object-fit: cover; }
.lib-hero-text { min-width: 0; flex: 1; }
.lib-eyebrow { margin: 0 0 var(--s-2); color: var(--on-band); opacity: .86; }
.lib-title {
  margin: 0;
  color: var(--on-band);
  font-size: var(--fs-display);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .18);
}
.lib-meta { margin: var(--s-2) 0 0; font-size: var(--fs-label); font-weight: 500; color: var(--on-band); opacity: .9; }
.lib-desc { margin: 0 0 var(--s-3); max-width: 64ch; color: var(--on-band); opacity: .92; overflow-wrap: anywhere; white-space: pre-line; }
.lib-actions { margin-top: var(--s-5); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.lib-actions > .lib-desc { flex: 0 0 100%; }
.lib-action-row { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.lib-actions .btn .glyph { width: 18px; height: 18px; }
.btn--glass { background: rgba(255, 255, 255, .16); color: #FFFFFF; border-color: rgba(255, 255, 255, .28); }
.btn--glass:hover { color: #FFFFFF; background: rgba(255, 255, 255, .26); }
.lib-hero :focus-visible { outline-color: #FFFFFF; }

/* ---- lower half -------------------------------------------------------------------------------------------- */
.lib-body {
  position: relative;
  z-index: var(--z-content);
  margin: 0 calc(-1 * var(--gutter));
  padding: var(--s-5) var(--gutter) 0;
  background: var(--bg); /* the light lower half starts right under the hero, over any taller shell band */
}
.lib-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); }
.lib-subtabs ul { display: inline-flex; gap: 2px; margin: 0; padding: 4px; list-style: none; border-radius: var(--r-pill); background: var(--surface-2); }
.lib-subtabs a {
  display: inline-flex; align-items: center;
  min-height: 36px; padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  color: var(--ink-2); font-weight: 600; text-decoration: none;
  transition: background-color var(--dur-ui) var(--ease-out), color var(--dur-ui) var(--ease-out);
}
.lib-subtabs a:hover { color: var(--ink); }
.lib-subtabs a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.lib-sort { display: inline-flex; align-items: center; gap: var(--s-2); }
.lib-sort .select { width: auto; min-height: 36px; padding: 0 var(--s-3); }
.lib-back { font-weight: 600; text-decoration: none; }
.lib-back::before { content: "\2039\00a0"; }

.lib-section { margin-top: var(--s-7); }
.lib-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.lib-section-title { margin: 0; font-size: var(--fs-h2); font-weight: 700; }
.lib-see-all { font-weight: 600; text-decoration: none; }

/* overview cards (quiet) */
.lib-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--s-4); }
.lib-card {
  position: relative;
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 96px; padding: var(--s-3);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--sh-1);
  color: var(--ink); text-decoration: none;
  transition: transform var(--dur-focus) var(--ease-out), box-shadow var(--dur-focus) var(--ease-out);
}
.lib-card:hover { color: var(--ink); box-shadow: var(--sh-2); }
.lib-card-art { flex: none; display: grid; place-items: center; width: 72px; height: 72px; background: var(--accent); color: #FFFFFF; overflow: hidden; }
.lib-card-art .img { width: 100%; height: 100%; object-fit: cover; }
.lib-card-art--soft { background: var(--accent-soft); color: var(--accent-ink); }
.lib-card-text { display: grid; gap: 2px; min-width: 0; }
.lib-card-title { font-size: var(--fs-label); font-weight: 700; }
.lib-card-sub { color: var(--ink-3); font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-card-icon { margin-left: auto; color: var(--accent); }

/* ---- playlist tiles ---------------------------------------------------------------------------------------- */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
  gap: var(--s-5) var(--s-4);
  margin: 0; padding: var(--s-2) 0; list-style: none;
}
.lib-tile {
  position: relative;
  display: grid; gap: var(--s-1);
  width: 100%; padding: 0;
  border: 0; background: transparent;
  color: var(--ink); text-align: left; text-decoration: none;
  transition: transform var(--dur-focus) var(--ease-out);
}
.lib-tile:hover { color: var(--ink); }
.lib-tile-art {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 1;
  border-radius: var(--r-tile);
  background: var(--surface-2);
  color: var(--ink-3);
  overflow: hidden;
  transition: transform var(--dur-focus) var(--ease-out), box-shadow var(--dur-focus) var(--ease-out);
}
.lib-tile-art .img, .lib-tile-art .img--empty { width: 100%; height: 100%; object-fit: cover; }
.lib-tile-title { margin-top: var(--s-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-tile-sub { color: var(--ink-3); font-size: var(--fs-small); }
.lib-tile--new .lib-tile-art { background: transparent; border: 2px dashed var(--line); color: var(--ink-2); }
.lib-tile--new:hover .lib-tile-art { border-color: var(--accent); color: var(--accent); }
.lib-tile:hover .lib-tile-art { box-shadow: var(--sh-2); }
.lib-tile:focus-visible { outline: none; }
.lib-tile:focus-visible .lib-tile-art { outline: 3px solid #FFFFFF; outline-offset: -3px; box-shadow: var(--sh-2); z-index: var(--z-focus); }
.lib-tile:focus-visible .lib-tile-art::after { content: ""; position: absolute; inset: 0; border: 2px solid var(--ink); pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .lib-tile:hover .lib-tile-art, .lib-tile:focus-visible .lib-tile-art { transform: scale(1.04); }
}
.lib-grid--skeleton span { display: block; aspect-ratio: 1; background: var(--surface-2); }

/* ---- track list -------------------------------------------------------------------------------------------- */
.lib-list { margin: 0; padding: 0; list-style: none; }
.lib-row {
  position: relative;
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 56px; padding: var(--s-1) var(--s-2);
  border-radius: var(--r-ctl);
  transition: background-color var(--dur-ui) var(--ease-out);
}
.lib-row:hover, .lib-row:focus-within { background: var(--surface); }
.lib-row.is-dragging { opacity: .55; }
.lib-row.is-over { box-shadow: inset 0 2px 0 var(--accent); }
.lib-row-main {
  display: flex; align-items: center; gap: var(--s-3);
  flex: 1 1 auto; min-width: 0;
  padding: 0; border: 0; background: transparent; color: inherit; text-align: left;
}
.lib-row-cover { position: relative; flex: none; width: 48px; height: 48px; background: var(--surface-2); overflow: hidden; border-radius: 2px; }
.lib-row-cover .img, .lib-row-cover .img--empty { width: 48px; height: 48px; object-fit: cover; }
.lib-row-play {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(8, 8, 12, .45); color: #FFFFFF;
  opacity: 0; transition: opacity var(--dur-focus) var(--ease-out);
}
.lib-row-main:hover .lib-row-play, .lib-row-main:focus-visible .lib-row-play { opacity: 1; }
.lib-row-text { display: grid; min-width: 0; }
.lib-row-title, .lib-row-artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-row-title { font-weight: 600; color: var(--ink); }
.lib-row-artist { font-size: var(--fs-small); color: var(--ink-2); }
.chip--explicit { padding: 0 5px; margin-left: 4px; background: transparent; border: 1px solid var(--ink-3); color: var(--ink-3); vertical-align: 1px; }
.lib-row-release { flex: 0 1 26%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); }
.lib-row-release a { color: var(--ink-2); text-decoration: none; }
.lib-row-release a:hover { color: var(--ink); text-decoration: underline; }
.lib-row-time { flex: none; width: 3.25rem; text-align: right; color: var(--ink-3); font-size: var(--fs-small); }
.lib-row .icon-btn { flex: none; color: var(--ink-2); }
.lib-row .icon-btn:hover { color: var(--ink); }
.lib-like.is-on, .lib-like.is-on:hover { color: var(--accent); }
.lib-row-tools { display: inline-flex; flex: none; }
.lib-row-tools .icon-btn { width: 36px; height: 36px; }
.lib-row-tools .icon-btn:disabled { opacity: .3; }
.lib-handle {
  flex: none;
  display: grid; place-items: center;
  width: 32px; height: 44px;
  padding: 0; border: 0; background: transparent;
  color: var(--ink-3);
  cursor: grab; touch-action: none;
}
.lib-handle:active { cursor: grabbing; }

.lib-day { margin-bottom: var(--s-6); }
.lib-day-title { margin: 0 0 var(--s-2); padding-left: var(--s-2); font-size: var(--fs-h3); font-weight: 700; }
.lib-more { display: flex; justify-content: center; padding: var(--s-5) 0; }

/* empty / error / skeleton */
.lib-empty {
  display: grid; justify-items: start; gap: var(--s-3);
  padding: var(--s-6);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--sh-1);
  margin-top: var(--s-4);
}
.lib-empty p { margin: 0; color: var(--ink-2); font-size: var(--fs-label); }
.lib-skeleton { display: grid; gap: var(--s-2); }
.lib-skel-row { display: flex; align-items: center; gap: var(--s-3); height: 56px; padding: 0 var(--s-2); }
.lib-skel-row span:first-child { width: 48px; height: 48px; background: var(--surface-2); }
.lib-skel-row span:last-child { width: min(320px, 50%); height: 14px; border-radius: var(--r-pill); background: var(--surface-2); }
@media (prefers-reduced-motion: no-preference) {
  .lib-skel-row span, .lib-grid--skeleton span { animation: lib-shimmer 1.2s ease-in-out infinite alternate; }
}
@keyframes lib-shimmer { from { opacity: 1; } to { opacity: .55; } }

/* ---- sheets ------------------------------------------------------------------------------------------------- */
.lib-sheet h2 { margin-bottom: var(--s-1); }
.lib-sheet-head { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-4); }
.lib-sheet-head .img, .lib-sheet-head .img--empty { width: 64px; height: 64px; flex: none; object-fit: cover; background: var(--surface-2); }
.lib-sheet-head h2 { margin: 0; overflow-wrap: anywhere; }
.lib-sheet-sub { margin: 0 0 var(--s-3); color: var(--ink-2); }
.lib-options { margin: 0 0 var(--s-4); padding: 0; list-style: none; border-top: 1px solid var(--line); }
.lib-options li { border-bottom: 1px solid var(--line); }
.lib-option {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  width: 100%; min-height: 48px; padding: 0 var(--s-2);
  border: 0; background: transparent;
  color: var(--ink); font-weight: 500; text-align: left; text-decoration: none;
}
.lib-option:hover { background: var(--surface-2); color: var(--ink); }
.lib-option--danger { color: var(--danger); }
.lib-option--danger:hover { color: var(--danger); }
.lib-option--quiet { color: var(--ink-3); }
.lib-pick-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-pick-count { flex: none; color: var(--ink-3); font-size: var(--fs-small); }
.lib-inline-form { display: flex; gap: var(--s-2); margin: var(--s-3) 0; }
.lib-inline-form .input { flex: 1; min-width: 0; }
.lib-sheet-cancel { width: 100%; }
.lib-sheet-buttons { display: flex; justify-content: flex-end; gap: var(--s-3); margin-top: var(--s-4); }

/* ---- breakpoints -------------------------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .lib-row-release { display: none; }
}
@media (max-width: 599px) {
  .lib-hero { min-height: 200px; padding: var(--s-6) var(--gutter) var(--s-5); }
  .lib-hero-body { flex-direction: column; align-items: flex-start; gap: var(--s-4); }
  .lib-hero-cover { width: 132px; }
  .lib-title { font-size: var(--fs-h1); }
  .lib-actions { margin-top: var(--s-4); gap: var(--s-2); }
  .lib-action-row .btn { padding: 0 var(--s-4); }
  .lib-subtabs { max-width: 100%; overflow-x: auto; }
  .lib-subtabs a { padding: 0 var(--s-3); }
  .lib-row { min-height: 64px; padding-inline: 0; gap: var(--s-1); }
  .lib-list--edit .lib-row-time { display: none; }
  .lib-list--edit .lib-move { display: none; }
  .lib-grid { gap: var(--s-4) var(--s-2); }
  .lib-tile-art { border-radius: 4px; }
}
@media (pointer: coarse) {
  .lib-list--edit .lib-move { display: none; }
}
