/* Shared Pearson Cinema chrome: nav, toolbar, filter panel, cards, pills.
   Replaces the near-identical <style> blocks duplicated across
   index/movie/stats. Loaded before each page's own <style>, so page-specific
   overrides still win. */

:root {
  --bg: #111;
  --card: #1a1a1a;
  --muted: #ccc;
  --chip: #333;
  --star: #f5c518;
  --nav-control-h: 38px;
}

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. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: #000;
}

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

/* The nav's width is pinned here on purpose, so all three pages render an
   identical nav — this deliberately does NOT follow each page's own
   content width (which differs: 1320px on index.html, 1140px on
   movie.html/stats.html). 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 movie.html's/stats.html's own page
   <style> blocks (which set that class's max-width to their own content
   width, 1140px) 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. (Verified
   empirically — the bare-selector version measurably lost on movie.html/
   stats.html before this fix.) */
.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;
}

/* Matches records' logo-img sizing (70px desktop / 56px mobile height,
   300px max-width). Cinema's logo is a different image with a different
   aspect ratio (~1.55:1 vs. records' ~4.3:1), so at 70px tall it renders
   ~109px wide — well under the 300px cap, which exists only as the same
   safety ceiling records has, not an active constraint here. Verified at
   1280px against six nav buttons (four view buttons + Random + Stats) with
   no overflow or crowding. */
.logo-img {
  height: 70px;
  width: auto;
  max-width: 300px;
  max-height: 10vh;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));
  transition: transform 0.25s ease;
}
.logo-img:hover {
  transform: scale(1.05);
}

.site-nav-collapse {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-width: 0;
}

.site-nav-views,
.site-nav-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.site-nav-search {
  background: #1a1a1a;
  color: #fff;
  border-color: #444;
  flex: 0 1 320px;
  min-width: 0;
  margin-left: auto;
  height: var(--nav-control-h);
  padding-top: 0;
  padding-bottom: 0;
}
.site-nav-search:focus {
  background: #1a1a1a;
  color: #fff;
  border-color: var(--star);
  box-shadow: none;
}
.form-control::placeholder {
  color: #aaa !important;
  opacity: 1 !important;
}

/* Every nav control matches the search box's height. */
.site-nav-views .btn,
.site-nav-links .btn,
.site-nav-toggler {
  height: var(--nav-control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.site-nav-views .btn i,
.site-nav-links .btn i {
  margin: 0;
  vertical-align: middle;
}

/* The four type buttons read as the site's yellow at rest, distinct from
   Random/Stats which stay btn-outline-light for contrast. */
.site-nav-views .btn {
  border-color: var(--star);
  color: var(--star);
}
/* border-color and color here are load-bearing, not redundant duplication
   of the rest-state rule above. This is a :hover-specific rule, so it only
   competes with other :hover rules — and Bootstrap's own
   .btn-outline-light:hover sets color:#000 and border-color:#f8f9fa. Drop
   either property here and nothing else overrides Bootstrap's hover
   declaration for it, producing black-on-yellow text. Keep all three
   properties even though color/border-color look unchanged from rest
   state — a future "simplification" to background-only would reintroduce
   that bug. */
.site-nav-views .btn:hover {
  background: rgba(245, 197, 24, 0.15);
  border-color: var(--star);
  color: var(--star);
}

/* Active view button and active page share the site accent. */
.site-nav-views .btn.active,
.site-nav-links .btn.active {
  background: var(--star);
  border-color: var(--star);
  color: #000;
}

.site-nav-views .btn:focus-visible,
.site-nav-links .btn:focus-visible,
.site-nav-toggler:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(245, 197, 24, 0.4);
  outline: none;
}

/* Text labels ride along with the icons on mobile only. */
.nav-btn-label {
  display: none;
}

.site-nav-toggler {
  display: none;
}

/* ---------- Mobile nav: hamburger + 12-column grid ---------- */
@media (max-width: 767.98px) {
  .site-nav-toggler {
    display: inline-flex;
    margin-left: auto;
  }

  .site-nav-collapse {
    display: none;
    flex: 1 0 100%;
    order: 3;
  }
  .site-nav-collapse.open {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0.5rem;
    padding-top: 0.5rem;
  }

  /* 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;
  }

  .site-nav-collapse.open .site-nav-search {
    grid-column: span 12;
    flex: none;
    margin-left: 0;
    width: 100%;
  }

  /* Four view buttons, a quarter each. */
  .site-nav-collapse.open .site-nav-views {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    grid-column: span 12;
  }

  /* Random + Stats, half each, with visible text labels. */
  .site-nav-collapse.open .site-nav-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    grid-column: span 12;
  }
  .site-nav-collapse.open .site-nav-links .nav-btn-label {
    display: inline;
  }

  .site-nav-collapse.open .btn {
    width: 100%;
    height: auto;
    padding: 0.6rem 0.5rem;
  }

  .logo-img {
    height: 56px;
  }
}

/* ---------- Cards ---------- */
.poster-wrap {
  position: relative;
  overflow: hidden;
  border-top-left-radius: 0.75rem;
  border-top-right-radius: 0.75rem;
  background: #222;
  aspect-ratio: 2 / 3;
}
.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;
}
@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;
}

/* ---------- Pills ---------- */
.genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.badge-genre,
.badge-tag {
  background: var(--chip);
  color: #eee;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}
.badge-genre:hover,
.badge-tag:hover {
  background: #555;
}

/* ---------- 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);
  outline: none;
  border-radius: 4px;
}

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. The toolbar only
   exists on index.html. */
.toolbar .toolbar-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
}

.toolbar-inner .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.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;
  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 Sort/Filter icons are mobile-only; the text label carries desktop. */
.toolbar-inner .btn i {
  display: none;
}

/* Sheet chrome is mobile-only. */
.sheet-header {
  display: none;
}

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

/* ---------- Mobile: icon-only buttons, bottom-sheet menus ---------- */
@media (max-width: 767.98px) {
  .toolbar-inner .btn i {
    display: inline;
  }
  #sortLabel,
  #filterLabel {
    display: none;
  }
  /* #filterCount deliberately stays visible — with the label hidden it is the
     only signal that filters are active. */
}

@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.d-none {
  display: none;
}
.filter-group + .filter-group:not(.d-none) {
  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);
}
/* Matches Bootstrap's own (0,3,0) specificity and wins on source order, so no
   !important is needed. */
.filter-check:indeterminate[type="checkbox"] {
  background-color: var(--star);
  border-color: var(--star);
}
.filter-check:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(245, 197, 24, 0.4);
  border-color: var(--star);
  outline: none;
}

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

/* ---------- 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);
  outline: none;
}

.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;
}

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