/* Shared Pearson Records chrome: nav, toolbar, filter panel, cards, chips.
   Replaces the near-identical <style> blocks that were duplicated across
   index/wishlist/queue/stats/album. Loaded before each page's own <style>,
   so page-specific overrides still win. */

:root {
  --bg: #111;
  --card: #1a1a1a;
  --muted: #ccc;
  --chip: #333;
  --star: #f5c518;
}

body {
  background: var(--bg);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

/* ---------- Sticky header ---------- */
/* Nav and toolbar stick as one unit. Bootstrap's .sticky-top on two siblings
   would overlap them, so the wrapper is the sticky element and the nav inside
   it is static. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: #000;
}

.site-nav {
  --nav-control-h: 38px;
  background: #000;
  border-bottom: 1px solid #333;
  padding: 0.4rem 0;
}

/* The nav's width is pinned here on purpose, so all five pages render an
   identical nav — this deliberately does NOT follow each page's own
   content width (which differs: 1320px on index/stats, 1140px on album,
   unset — i.e. full viewport — on wishlist/queue). Do not add a
   `.container-fluid` rule to this file; that would defeat each page's own
   content width instead of just pinning the nav.
   The max-width/margin below is qualified as `.site-nav .site-nav-inner`
   rather than a bare `.site-nav-inner` on purpose: this element also
   carries `.container-fluid`, and album.html's and index.html's own
   page <style> blocks (which set that class's max-width to their own
   content width) load AFTER this file, so a same-specificity bare class
   selector here would lose to them on source order and the nav would
   inherit the page's width again. Nesting under `.site-nav` adds a
   second class to the selector, which reliably outranks the page's
   single-class `.container-fluid` regardless of load order. */
.site-nav .site-nav-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
}

/* Wraps search + links so a single set of controls can serve both the
   inline desktop layout and the collapsible mobile menu — no cloned/
   duplicate controls. Desktop layout matches the pre-hamburger markup
   exactly: this div just takes over the margin-left:auto that used to
   live on .site-nav-search. */
.site-nav-collapse {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  min-width: 0;
}

.nav-toggle {
  display: none;
}

.logo-img {
  height: 70px;
  width: auto;
  max-width: 300px;
  max-height: 10vh;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
  transition: transform 0.25s ease;
}
.logo-img:hover {
  transform: scale(1.05);
}

.site-nav-search {
  background: #1a1a1a;
  color: #fff;
  border-color: #444;
  flex: 0 1 320px;
  min-width: 0;
  height: var(--nav-control-h);
  padding-top: 0;
  padding-bottom: 0;
}

/* `flex: 0 1 320px` alone renders far narrower than 320px (it was measuring
   ~180px), because .site-nav-search's flex-grow is 0: Chrome computes the
   auto/fit-content width of its ancestor .site-nav-collapse (also
   flex-basis: auto) using each child's own outer max-content size rather
   than its flex-basis whenever flex-grow is 0 — so the collapse wrapper
   sizes itself around the search input's tiny UA-default max-content width
   (~180px) instead of the intended 320px, even when there's plenty of real
   room. min-width forces the correct floor and fixes that miscalculation.
   Scoped to >=992px, comfortably above the point (~876px viewport) where
   holding a hard 320px floor would start to collide with the 300px logo —
   below 992px this reverts to the unconstrained (smaller) rendering so the
   row keeps shrinking gracefully instead of overlapping as it narrows
   toward the 767.98px mobile breakpoint. */
@media (min-width: 992px) {
  .site-nav-search {
    min-width: 320px;
  }
}

.site-nav-search:focus {
  background: #1a1a1a;
  color: #fff;
  border-color: var(--star);
  box-shadow: none;
}
.form-control::placeholder {
  color: #aaa !important;
  opacity: 1 !important;
}

.site-nav-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}
.site-nav-links .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  height: var(--nav-control-h);
}
.site-nav-links .btn i {
  margin: 0;
  vertical-align: middle;
}
.site-nav-links .btn.active {
  background: var(--star);
  border-color: var(--star);
  color: #000;
}

/* Text label next to an icon. Hidden on the desktop inline layout (the
   buttons stay icon-only there, same as before). Only the random-album/
   random-artist buttons carry this span at all — see the mobile grid
   rules below for why. */
.nav-btn-label {
  display: none;
}

/* ---------- Mobile hamburger menu ---------- */
@media (max-width: 767.98px) {
  .logo-img {
    height: 56px;
    max-width: 200px;
  }

  /* Must stay qualified as `.site-nav .site-nav-inner` to match the
     specificity of the desktop rule above. A media query adds no
     specificity, so a bare `.site-nav-inner` here (0,1,0) loses to that
     rule's `flex-wrap: nowrap` (0,2,0) and the collapse panel — which
     relies on `flex: 1 0 100%` to claim its own line — gets pinned beside
     the logo and overflows the viewport instead of stacking beneath it. */
  .site-nav .site-nav-inner {
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--nav-control-h);
    margin-left: auto;
  }

  /* Closed by default (menu starts collapsed on every page load); .open
     is toggled by nav.js's plain click handler, not Bootstrap collapse. */
  .site-nav-collapse {
    display: none;
    flex: 1 0 100%;
    margin-left: 0;
    margin-top: 0.6rem;
  }
  .site-nav-collapse.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .site-nav-search {
    width: 100%;
    flex: 0 0 auto;
  }

  /* 12-column grid (LCM of 2 and 4) so both rows come out to exact
     fractions including gaps: random-album/random-artist each span 6
     (50/50), and the four page links (wishlist/queue/stats/turntables)
     each span 3 (25/25/25/25), stacking into two rows under the
     full-width search row above. */
  .site-nav-links {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0.5rem;
  }
  .site-nav-links .btn {
    width: 100%;
    height: auto;
    white-space: normal;
    padding: 0.6rem 0.5rem;
  }
  .site-nav-links #randomBtn,
  .site-nav-links #randomArtistBtn {
    grid-column: span 6;
  }
  .site-nav-links a.btn {
    grid-column: span 3;
  }

  /* Random-album/random-artist get a visible text label next to the icon
     (a half-width button with two bare shuffle glyphs is ambiguous). The
     three page links stay icon-only — a third of the row is tight, and
     their glyphs are already distinct — so they carry no .nav-btn-label. */
  .nav-btn-label {
    display: inline;
    margin-left: 0.35rem;
  }
}

/* ---------- Cards ---------- */
.poster-wrap {
  position: relative;
  overflow: hidden;
  border-top-left-radius: 0.75rem;
  border-top-right-radius: 0.75rem;
  background: #222;
  aspect-ratio: 1 / 1;
}
@supports not (aspect-ratio: 1 / 1) {
  .poster-wrap::before {
    content: "";
    display: block;
    padding-top: 100%;
  }
  .poster-wrap > * {
    position: absolute;
    inset: 0;
  }
}
.poster-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster-link {
  position: absolute;
  inset: 0;
  display: block;
}
.poster-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #222 25%, #333 37%, #222 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s infinite;
}
.skeleton-line {
  display: block;
  height: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #333 25%, #444 37%, #333 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s infinite;
}
.skeleton-title {
  width: 70%;
  margin-bottom: 0.35rem;
}
.skeleton-text {
  width: 50%;
}
.skeleton-pill {
  display: inline-block;
  height: 0.9rem;
  width: 3rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #333 25%, #444 37%, #333 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s infinite;
  margin-right: 0.3rem;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.no-image {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  text-align: center;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: none;
  border-radius: 0.75rem;
  overflow: hidden;
  transition: transform 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
}
.card-title {
  font-size: 1rem;
  margin: 0;
  color: #fff;
  font-weight: 700;
}
.byline {
  font-size: 0.9rem;
  color: var(--muted);
}
.label-line {
  font-size: 0.78rem;
  color: #888;
}
/* Rest state matches the plain text it replaces exactly (same size/color/
   weight) -- only the hover state signals it's clickable. */
.label-line a.label-link {
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.label-line a.label-link:hover {
  color: #fff;
  text-decoration: underline;
}
.rating-pip-mini {
  display: inline-block;
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.4rem;
}
.rating-pip-mini.r-green { background: #4caf50; }
.rating-pip-mini.r-blue { background: #3d8bfd; }
.rating-pip-mini.r-yellow { background: #f5c518; color: #000; }
.rating-pip-mini.r-red { background: #e55; }
.byline a.director-link {
  color: #cfe3ff;
  text-decoration: underline dotted;
}
.byline a.director-link:hover {
  color: #fff;
  text-decoration: underline;
}

.genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.badge-genre {
  background: var(--chip);
  color: #eee;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}
.badge-genre:hover {
  background: #555;
}
.badge-genre.genre-holiday { background: #78ba70; color: #fff; }
.badge-genre.genre-horror { background: #f0a748; color: #000; }

.rating-line {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: #ddd;
  font-size: 0.9rem;
}
.rating-line .star {
  color: var(--star);
  font-weight: 700;
}
.user-rating {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: #ddd;
}
.user-rating-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-icon-svg {
  width: 14px;
  height: 14px;
  fill: #fff;
  stroke: #fff;
  stroke-width: 1;
}

.card.highlight {
  box-shadow: 0 0 0 2px var(--star);
}
.card.needs-replace {
  box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.6);
  filter: saturate(0.7) brightness(0.88);
  opacity: 0.88;
  transition: opacity 0.2s ease, filter 0.2s ease, transform 0.2s ease;
}
.card.needs-replace:hover {
  opacity: 1;
  filter: none;
}
.card.needs-replace .poster-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(220, 53, 69, 0.22);
  pointer-events: none;
}
.card.needs-replace .card-body {
  background: rgba(220, 53, 69, 0.12);
}
.card.in-vet {
  box-shadow: 0 0 0 1px rgba(55, 138, 221, 0.6);
}
.card.in-vet .poster-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(55, 138, 221, 0.22);
  pointer-events: none;
}
.card.in-vet .card-body {
  background: rgba(55, 138, 221, 0.12);
}

/* ---------- Filter chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #2f2f2f;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  margin-right: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}
.chip button {
  all: unset;
  cursor: pointer;
  color: #aaa;
}
.chip button:hover {
  color: #fff;
}
.chip button:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(245, 197, 24, 0.4);
}

footer {
  color: #888;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 2rem;
  padding-bottom: 1rem;
}

/* ---------- Filter / sort toolbar (collection page only) ---------- */
.toolbar {
  background: #0b0b0b;
  border-bottom: 1px solid #333;
  padding: 0.5rem 0;
}

/* Pinned to the same fixed width as .site-nav-inner above, for the same
   reason and with the same `.toolbar .toolbar-inner` specificity trick —
   see the comment on .site-nav-inner. index.html's own `.container-fluid`
   already happens to compute to 1320px, but that's page-content width,
   not toolbar width; pinning it here directly means the two can't drift
   apart if index.html's content width is ever changed. */
.toolbar .toolbar-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
}

.toolbar-status {
  color: var(--muted);
  white-space: nowrap;
}

.toolbar-clear {
  margin-left: auto;
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: var(--star);
  color: #000;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.toolbar-menu {
  background: #1a1a1a;
  color: #ddd;
  border: 1px solid #333;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.5rem;
}
.toolbar-menu .dropdown-item {
  color: #ddd;
  border-radius: 0.35rem;
  padding: 0.35rem 0.5rem;
}
.toolbar-menu .dropdown-item:hover,
.toolbar-menu .dropdown-item:focus {
  background: #2f2f2f;
  color: #fff;
}
.toolbar-menu .dropdown-item.active {
  background: var(--star);
  color: #000;
}

/* The sheet header is mobile-only chrome; the popover doesn't need a title. */
.sheet-header {
  display: none;
}

.active-filters:empty {
  display: none;
}
.active-filters {
  padding-top: 0.5rem;
}

/* ---------- Mobile: dropdowns become bottom sheets ---------- */
@media (max-width: 575.98px) {
  .toolbar-menu {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    transform: none !important;
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 0.75rem 0.75rem 0 0;
    border-bottom: none;
    padding: 0 1rem 1rem;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
  }
  .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: #1a1a1a;
    padding: 0.85rem 0;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid #333;
    font-weight: 700;
  }
  .toolbar-status {
    order: 3;
    flex: 1 0 100%;
  }
}

/* ---------- Filter panel groups ---------- */
.filter-panel {
  min-width: 320px;
}

.filter-group + .filter-group {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #333;
}

.filter-legend {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.filter-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.15rem 0.5rem;
}

.filter-check-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.3rem;
  border-radius: 0.35rem;
  font-size: 0.88rem;
  cursor: pointer;
  min-width: 0;
}
.filter-check-label:hover {
  background: #2f2f2f;
}
.filter-check-label > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-check {
  flex: 0 0 auto;
  margin: 0;
  background-color: #2f2f2f;
  border-color: #555;
  cursor: pointer;
}
.filter-check:checked {
  background-color: var(--star);
  border-color: var(--star);
}
.filter-check:focus {
  box-shadow: none;
  border-color: var(--star);
}
.filter-check:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(245, 197, 24, 0.4);
}

@media (max-width: 575.98px) {
  .filter-panel {
    min-width: 0;
  }
  .filter-check-label {
    padding: 0.5rem 0.3rem; /* larger tap target */
  }
}

/* ---------- Year filter tree ---------- */
.decade-row + .decade-row {
  margin-top: 0.1rem;
}

.decade-head {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.decade-label {
  flex: 1 1 auto;
  font-weight: 600;
}

.decade-caret {
  all: unset;
  cursor: pointer;
  color: var(--muted);
  padding: 0.3rem 0.45rem;
  border-radius: 0.35rem;
  line-height: 1;
}
.decade-caret:hover {
  color: #fff;
  background: #2f2f2f;
}
.decade-caret:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(245, 197, 24, 0.4);
}

.year-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.1rem 0.35rem;
  padding: 0.15rem 0 0.35rem 1.5rem;
}
.year-check-grid .filter-check-label {
  font-size: 0.82rem;
}

/* Bootstrap's own indeterminate rule is
   `.form-check-input[type=checkbox]:indeterminate` — a class + attribute +
   pseudo-class, specificity (0,3,0). Our `.filter-check:indeterminate`
   alone is only (0,2,0) and loses regardless of cascade order, so this
   matches Bootstrap's specificity to win on source order instead. */
.filter-check:indeterminate[type="checkbox"] {
  background-color: var(--star);
  border-color: var(--star);
}

@media (max-width: 575.98px) {
  .year-check-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
