/* Shared Pearson Arcade chrome: nav, toolbar, filter panel, chips.
   Ported from pearsonlibrary/nav.css (same nav delivery mechanism, same
   toolbar layout, same filter-panel structure, same mobile bottom-sheet CSS,
   same specificity conventions), which itself was ported from
   pearsonrecords/nav.css. Adapted for a single-page site with one random
   button and no wishlist/queue/stats. Loaded before the 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 the nav renders at the same
   width as pearsonrecords/pearsoncinema/pearsonlibrary — this deliberately
   does NOT follow the page's own content width. Do not add a
   `.container-fluid` rule to this file; that would defeat the page's own
   content width instead of just pinning the nav.
   1320px matches the other three sites (pearsonrecords/nav.css,
   pearsoncinema/nav.css, pearsonlibrary/nav.css after its own width fix).
   Arcade's own page <style> sets `.container-fluid { max-width: 1140px; }`
   for its content column — the nav must NOT inherit that value.
   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 index.html's own page <style> block
   (which sets that class's max-width to 1140px) loads AFTER this file, so a
   same-specificity bare class selector here would lose to it 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. */
.site-nav-collapse {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  min-width: 0;
}

.nav-toggle {
  display: none;
}

/* Matches this site's original logo sizing (90px desktop / 70px mobile
   height), same values as pearsonlibrary's raster PNG logo. */
.logo-img {
  height: 90px;
  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;
}

/* See pearsonrecords/nav.css for the full explanation of why min-width is
   needed here (flex-basis alone under-computes against a flex-grow:0
   sibling). Scoped to >=992px, above the point where a hard 320px floor
   would start to collide with the logo. */
@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
   random button stays icon-only there, matching the other sites). */
.nav-btn-label {
  display: none;
}

/* ---------- Mobile hamburger menu ---------- */
@media (max-width: 767.98px) {
  .logo-img {
    height: 70px;
    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.
     This exact bug was found and fixed on pearsonrecords, pearsoncinema,
     and pearsonlibrary; do not reintroduce it here. */
  .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;
  }

  /* Only one button lives here (Random Game) — unlike records' 6-column
     grid or library's 2-column grid, a single full-width button is enough. */
  .site-nav-links {
    display: flex;
    flex-direction: column;
  }
  .site-nav-links .btn {
    width: 100%;
    height: auto;
    white-space: normal;
    padding: 0.6rem 0.5rem;
  }

  .nav-btn-label {
    display: inline;
    margin-left: 0.35rem;
  }
}

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

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