/* ---------- Design tokens ---------- */
:root {
  --burgundy: #6E1F2A;
  --burgundy-dark: #4A1420;
  --mustard: #C9A227;
  --cream: #F6EFE1;
  --cream-dark: #EBE0C8;
  --ember: #CC4A24;
  --ink: #2A2016;
  --rust: #C76B3F;

  --spine-vhs: #8B6B3D;
  --spine-dvd: #5B7C99;
  --spine-bluray: #1F3C73;
  --spine-4k: #1A1A1A;
  --spine-laserdisc: #5C3C6E;
  --spine-other: #4A4A4A;

  --wood-light: #9C6B3E;
  --wood: #7A4A24;
  --wood-dark: #4E2E15;

  --surface: #fff;
  --surface-tint: #fff6e0;
  --error-tint: #fdecec;
  --success-tint: #fbeedd;
  --muted: #8a7a63;
  --muted-dark: #6a5c47;

  /* Text-only aliases for burgundy/ember - the brand colors stay put for solid
     fills (header, buttons, badges), but as plain text directly on the page
     background they need to get brighter in dark mode or they vanish. */
  --accent: #6E1F2A;
  --accent-muted: #4A1420;
  --link: #CC4A24;

  /* Deliberately NOT redefined in the dark theme below. The header, .btn--primary, and
     .chip--format keep their burgundy fill in both themes, so whatever sits on top of that
     fill (logo text, nav links, button labels) needs to stay a fixed light color too -
     unlike --cream, which dark mode repoints to the page background and would otherwise
     turn this text near-black-on-burgundy. --on-fill-dark is the same idea for the mustard
     fills (the CTA link, .btn--accent, favorite chips): --ink flips to near-white for dark
     mode's page text, which would turn light-on-mustard instead of the dark text those
     fills still need. */
  --on-fill: #F6EFE1;
  --on-fill-dark: #2A2016;

  --font-display: 'Alfa Slab One', serif;
  --font-heading: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Space Mono', monospace;

  --radius: 8px;
  --radius-card: 6px;
}

/* ---------- Dark theme ----------
   A standard neutral black/gray/white dark mode - not just the light theme's
   warm cream tones inverted - so mustard/ember read as deliberate accent pops
   against a plain backdrop instead of competing with a tinted one. Burgundy
   gets its own brighter override just below, since the light theme's version
   is too dark/desaturated to read as a pop against near-black. */
:root[data-theme="dark"] {
  --cream: #121212;
  --cream-dark: #242424;
  --ink: #E8E8E8;
  --surface: #1E1E1E;
  --surface-tint: #262626;
  --error-tint: #2A1A1A;
  --muted: #8A8A8A;
  --muted-dark: #B5B5B5;
  /* Same value as --cream-dark in dark mode, but they're separate tokens for a reason -
     in light mode --success-tint is #fbeedd and --cream-dark is #EBE0C8. They only
     converge here by coincidence, so don't merge them. */
  --success-tint: #242424;
  /* A dark, desaturated red like the light theme's burgundy has very little value
     contrast against near-black even once it's technically legible - two dark things
     just read as similar. Boosting both saturation and lightness (same hue throughout)
     makes it a deliberate, vivid accent instead of a muddy one: this brighter burgundy
     replaces the original for every fill that uses it (header, primary button, format
     chip), and --accent/--accent-muted are the same family tuned further up for text. */
  --burgundy: #C32238;
  --burgundy-dark: #981B2B;
  --accent: #DF495D;
  --accent-muted: #D0253C;
  --link: #FF8A5C;
}

* { box-sizing: border-box; }

/* Everything in this file is sized in rem, so bumping the root size scales
   text, spacing, buttons and cards together. Desktop-only (mobile already
   has its own tuning in the responsive section below, and shouldn't shrink
   to compensate). */
@media (min-width: 900px) {
  html { font-size: 18px; }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100%;
  /* A safety net against any one element overflowing its column width - that's
     enough on a phone to widen the whole page and force the mobile browser to
     zoom out to fit it, taking every other element's sizing out of sync with
     the screen along with it. */
  overflow-x: hidden;
}

body {
  position: relative;
  /* Pins the footer to the bottom of the viewport on short pages (main grows
     to fill the gap via flex: 1) instead of it trailing right behind a
     half-empty page, floating partway down the screen. On a page taller than
     the viewport, main still grows past 100vh as normal and the footer sits
     right after it, same as before. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Subtle aged-paper grain, applied once globally */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 128px 128px;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; margin: 0; color: var(--ink); }

.page-title {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 2rem;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.section-divider {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.1rem;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 0.4rem;
  margin: 2rem 0 1.25rem;
  display: inline-block;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--burgundy);
  border-bottom: 4px solid var(--burgundy-dark);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--on-fill);
}
.site-logo:hover { text-decoration: none; }
.site-logo__mark { font-size: 1.4rem; color: var(--mustard); }
.site-logo__text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.5px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.site-nav__link {
  font-family: var(--font-heading);
  color: var(--on-fill);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-size: 0.85rem;
}
.site-nav__link:hover { color: var(--mustard); text-decoration: none; }
.site-nav__link--cta {
  background: var(--mustard);
  color: var(--on-fill-dark);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
}
.site-nav__link--cta:hover { background: #ecb45c; color: var(--on-fill-dark); }

/* Inline nav search - a magnifying-glass toggle that expands into a text field
   in place, instead of linking straight to the Search page. */
.nav-search { display: flex; align-items: center; position: relative; }
.nav-search__toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--on-fill);
}
.nav-search__toggle:hover { color: var(--mustard); }
.nav-search__label { display: none; }
.nav-search__form { width: 0; overflow: hidden; transition: width 180ms ease-out; }
.nav-search.is-open .nav-search__form { width: 190px; margin-left: 0.3rem; }
.nav-search__input {
  width: 100%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--on-fill);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
}
.nav-search__input::placeholder { color: rgba(246,239,225,0.65); }

.nav-search__suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  width: 280px;
  max-width: 80vw;
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(42,32,22,0.2);
  overflow: hidden;
  z-index: 45;
}
.nav-search__suggestion {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  color: var(--ink);
}
.nav-search__suggestion:hover { background: var(--cream); text-decoration: none; }
.nav-search__suggestion + .nav-search__suggestion { border-top: 1px solid var(--cream-dark); }
.nav-search__suggestion-separator {
  padding: 0.3rem 0.7rem;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--cream);
  border-top: 1px solid var(--cream-dark);
  border-bottom: 1px solid var(--cream-dark);
}
.nav-search__suggestion-poster {
  width: 32px;
  aspect-ratio: 2/3;
  border-radius: 3px;
  overflow: hidden;
  background: var(--cream-dark);
  flex-shrink: 0;
}
.nav-search__suggestion-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-search__suggestion-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ember);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
}
.nav-search__suggestion-title { font-family: var(--font-heading); font-size: 0.85rem; font-weight: 500; }

/* Hamburger toggle - hidden on desktop, shown only once the nav collapses (see Responsive). */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
}
.nav-toggle__bar { display: block; width: 22px; height: 2px; background: var(--on-fill); border-radius: 2px; }

/* Current-user menu in the nav - click the name to reveal Log Out. */
.user-menu { position: relative; }
.user-menu__trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  font-family: var(--font-heading);
  color: var(--on-fill);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}
.user-menu__trigger:hover,
.user-menu__trigger[aria-expanded="true"] { color: var(--mustard); }
.user-menu__chevron { font-size: 0.7rem; }
.user-menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(42,32,22,0.2);
  padding: 0.4rem;
  z-index: 30;
}
.user-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-card);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
}
.user-menu__item:hover { background: var(--cream); }

/* ---------- Layout ---------- */
.site-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  width: 100%;
  /* Grows to fill whatever space the header and footer don't take up - see
     the sticky-footer flex column on body. */
  flex: 1 0 auto;
}

/* ---------- Auth pages (Login) ---------- */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1rem;
}
.auth-page .page-title { text-align: center; margin-bottom: 0; }

/* ---------- Landing page (logged out) ---------- */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 6rem 1.5rem;
  gap: 1.75rem;
}
.landing__title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 2.5rem;
  letter-spacing: 0.5px;
}
.landing__mark { color: var(--mustard); }
.landing__actions { display: flex; gap: 1rem; }

/* A footer band that bookends the burgundy header, instead of a couple of
   lines of text sitting loose on the page background with nothing to anchor
   them. */
.site-footer {
  background: var(--burgundy);
  border-top: 4px solid var(--burgundy-dark);
  color: var(--on-fill);
}
.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.3px;
}
.site-footer__brand { display: flex; align-items: center; gap: 0.5rem; }
.site-footer__mark { color: var(--mustard); }
.site-footer__links { display: flex; gap: 1.25rem; }
.site-footer a { color: var(--on-fill); text-decoration: underline; text-underline-offset: 2px; opacity: 0.85; }
.site-footer a:hover { opacity: 1; color: var(--mustard); }

/* TMDB attribution - colors/logo per TMDB's branding guidelines */
.tmdb-attribution {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: #0d253f;
  border: 1px solid #01b4e4;
  border-radius: 999px;
  padding: 0.4rem 0.9rem 0.4rem 0.7rem;
  text-decoration: none;
  transition: box-shadow 150ms ease-out;
}
.tmdb-attribution:hover {
  text-decoration: none;
  box-shadow: 0 0 0 3px rgba(1,180,228,0.25);
}
.tmdb-attribution__logo { height: 14px; width: auto; display: block; }
.tmdb-attribution__text {
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  color: #90cea1;
  max-width: 260px;
  text-align: left;
  line-height: 1.3;
}

/* ---------- Buttons & form chrome ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-size: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.96); }
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:active { transform: none; }
}
.btn--primary { background: var(--burgundy); color: var(--on-fill); }
.btn--primary:hover { background: var(--burgundy-dark); }
.btn--accent { background: var(--mustard); color: var(--on-fill-dark); }
.btn--accent:hover { background: #ecb45c; }
.btn--ghost { background: transparent; color: var(--link); border-color: var(--link); }
.btn--ghost:hover { background: rgba(204,74,36,0.08); }
.btn--danger { background: var(--rust); color: #fff; }
.btn--danger:hover { background: #b25a32; }

input[type="text"], input[type="search"], input[type="date"], input[type="number"], input[type="password"],
select, textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px rgba(204,74,36,0.25);
}
label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--accent-muted);
  display: block;
  margin-bottom: 0.3rem;
}
.field-validation-error { color: var(--rust); font-size: 0.8rem; display: block; margin-top: 0.25rem; }
.input-validation-error { border-color: var(--rust) !important; }
.validation-summary-errors { color: var(--rust); background: var(--error-tint); border: 1px solid var(--rust); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; }

/* Honeypot field (Register) - off-screen rather than display:none/visibility:hidden, which
   some scripts specifically check for and skip. A sighted user never encounters it; a screen
   reader user is covered by aria-hidden on its wrapper. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
/* The validation-summary tag helper adds this class alongside validation-summary-errors
   rather than replacing it, so without this rule the (empty) box shows even when valid. */
.validation-summary-valid { display: none; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; text-transform: none; font-family: var(--font-body); font-size: 0.95rem; }

/* Vertically aligns a checkbox with the labeled fields beside it in the desktop
   form-grid, which has no label of its own above it. Not needed once the grid
   collapses to one column on mobile (see Responsive). */
.checkbox-row--grid-align { align-self: center; margin-top: 1.5rem; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  background: var(--cream-dark);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.filter-bar__field { flex: 1 1 160px; min-width: 140px; }
.filter-bar__field--grow { flex: 2 1 240px; }
.filter-bar__actions { display: flex; gap: 0.5rem; }

.filter-bar__divider { align-self: stretch; width: 1px; background: rgba(42,32,22,0.15); margin: 0 0.25rem; }

/* A checkbox styled to sit at the same height/weight as a select, so a
   lone checkbox field doesn't look out of place next to its neighbors. */
.filter-bar__toggle {
  height: 2.6rem;
  padding: 0 0.75rem;
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- Categories fold-out ---------- */
.category-dropdown { position: relative; }
.category-dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  height: 2.6rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.category-dropdown__trigger:hover { border-color: var(--link); }
.category-dropdown__trigger[aria-expanded="true"] {
  border-color: var(--link);
  box-shadow: 0 0 0 3px rgba(204,74,36,0.25);
}
.category-dropdown__chevron { color: var(--muted); font-size: 0.7rem; flex-shrink: 0; }
.category-dropdown__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(42,32,22,0.2);
  padding: 0.6rem 0.75rem;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.category-dropdown__panel[hidden] { display: none; }

/* ---------- Shelf grid ---------- */
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.75rem 1.5rem;
}

.shelf-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius-card);
  box-shadow: 4px 4px 0 rgba(42,32,22,0.15);
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
  overflow: hidden;
  color: var(--ink);
}
.shelf-card:hover {
  transform: translateY(-4px);
  box-shadow: 8px 8px 0 rgba(42,32,22,0.2);
  text-decoration: none;
}

.shelf-card__poster {
  aspect-ratio: 2/3;
  background: var(--cream-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.shelf-card__poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shelf-card__poster-placeholder { font-family: var(--font-display); color: #a99a7e; font-size: 0.8rem; text-align: center; padding: 1rem; }

.shelf-card__body { padding: 0.65rem 0.75rem 0.85rem; }
.shelf-card__title { font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem; line-height: 1.25; margin-bottom: 0.35rem; }
.shelf-card__meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

.chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--cream-dark);
  color: var(--ink);
  white-space: nowrap;
}
.chip--format { background: var(--burgundy); color: var(--on-fill); }
.chip--fav { background: var(--mustard); color: var(--on-fill-dark); }
.chip--watched { background: var(--ember); color: #fff; }
.chip--rating { background: var(--burgundy-dark); color: var(--mustard); }
.chip--private { background: #4a4a4a; color: #fff; }

/* Compact badge row for the boolean/rating flags (Favorite, Watched, Rating, Private).
   Unlike the text chips above, these are small fixed-size icon badges so that having
   all four of them present takes barely more width than having just one - the card's
   height stays about the same instead of growing a new wrapped line per flag. */
/* min-height (not just on the badges themselves) so this row reserves its space
   even when empty - the card's total height must not depend on how many of these
   flags happen to be set, only on whether the row exists at all, and it always does. */
.shelf-card__badges { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin-top: 0.3rem; min-height: 20px; }
.chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 0.3rem;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  line-height: 1;
  flex-shrink: 0;
}
.chip-badge--fav { background: var(--mustard); color: var(--on-fill-dark); padding: 0; width: 20px; }
.chip-badge--watched { background: var(--ember); color: #fff; padding: 0; width: 20px; }
.chip-badge--rating { background: var(--burgundy-dark); color: var(--mustard); gap: 0.15rem; }
.chip-badge--private { background: #4a4a4a; color: #fff; padding: 0; width: 20px; }

/* ---------- Activity dashboard ---------- */
.whats-next-carousel { position: relative; margin: 0 2.75rem; }
.whats-next-row {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.whats-next-row::-webkit-scrollbar { display: none; }
.whats-next-row .shelf-card { flex: 0 0 150px; width: 150px; }

.whats-next-carousel__arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ember);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  transition: background 120ms ease-out, opacity 120ms ease-out;
}
.whats-next-carousel__arrow:hover { background: var(--burgundy); }
.whats-next-carousel__arrow:disabled { opacity: 0.3; cursor: default; background: var(--ember); }
.whats-next-carousel__arrow--prev { left: -2.75rem; }
.whats-next-carousel__arrow--next { right: -2.75rem; }

.activity-date-group { margin-bottom: 1.5rem; }
.activity-date-group__heading {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.activity-line { padding: 0.6rem 0; border-bottom: 1px solid var(--cream-dark); }
.activity-line:last-child { border-bottom: none; }
.activity-line__user { font-weight: 600; }
.activity-line__text { margin-bottom: 0.5rem; }

.activity-line__posters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.activity-line__posters--rest { margin-top: 0.5rem; }
.activity-line__poster {
  display: block;
  width: 52px;
  aspect-ratio: 2/3;
  border-radius: 4px;
  overflow: hidden;
  background: var(--cream-dark);
  flex-shrink: 0;
  transition: transform 120ms ease-out;
}
.activity-line__poster:hover { transform: translateY(-2px); }
.activity-line__poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.activity-line__poster-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.5rem;
  line-height: 1.1;
  text-align: center;
  color: #a99a7e;
  padding: 2px;
}

.activity-line__view-more {
  display: inline-flex;
  margin-top: 0.5rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.7rem;
  cursor: pointer;
  list-style: none;
}
.activity-line__view-more::-webkit-details-marker { display: none; }
.activity-line__view-more::marker { content: ""; }
.activity-line__expand[open] .activity-line__view-more-label { display: none; }
.activity-line__expand:not([open]) .activity-line__view-less-label { display: none; }

/* ---------- Star rating input (Create/Edit/Details) ---------- */
.star-input { display: inline-flex; align-items: center; gap: 0.6rem; }
.star-input__track {
  position: relative;
  display: inline-flex;
  gap: 3px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  /* Without this, a touch press-and-drag along the track gets read as a page
     scroll gesture instead of reaching the pointermove handler that previews
     the rating as you slide your finger. */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.star-input__track:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 3px; }
/* Each star fills independently (0/50/100%) instead of clipping one long
   five-star string by an overall percentage - with letter-spacing between
   glyphs, that overall clip doesn't land on a clean half-star boundary, so a
   .5 rating cut through a gap (or the wrong side of a glyph) instead of
   exactly half of one star. */
.star-input__star { position: relative; display: inline-block; }
.star-input__star-bg { color: var(--cream-dark); }
.star-input__star-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  overflow: hidden;
  white-space: nowrap;
  color: var(--mustard);
  pointer-events: none;
}
.star-input__clear {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
}
.star-input__clear:hover { color: var(--rust); }
.star-input__value { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted-dark); min-width: 4.5ch; }

/* ---------- Shelf (spine) view ---------- */
/* Rows of cases, spine-out, like a real shelf. How many fit per row is
   computed from the available width (see shelf-layout.js) at a fixed,
   non-adjustable spine width - never a user setting. Each row is a fixed
   group of cases (flex, nowrap): hovering one grows it and every other
   case in that same row proportionally compresses to compensate, so the
   row's total width never changes - nothing jumps to a different row,
   and moving the mouse along the row doesn't skip past cases. */
.shelf-rows {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.shelf-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 3px;
  position: relative;
  padding-bottom: 16px;
}
.shelf-row::after {
  content: "";
  position: absolute;
  left: -10px;
  right: -10px;
  bottom: 0;
  height: 16px;
  background: linear-gradient(to bottom, var(--wood-light) 0%, var(--wood) 55%, var(--wood-dark) 100%);
  border-radius: 2px;
  box-shadow: 0 8px 10px -4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}

.spine-case {
  position: relative;
  flex: 0 1 var(--spine-w, 44px);
  min-width: 16px;
  height: 340px;
  cursor: pointer;
  transition: flex-basis 200ms ease-out;
  /* Without this, pressing and holding a spine on a phone - easy to do by
     accident, since the case fills its whole 44px-by-340px box - triggers
     the browser's native "open link" callout/context menu instead of just
     registering the tap. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.spine-case:hover {
  flex-basis: 170px;
  flex-shrink: 0;
  z-index: 5;
}

.spine-case__spine {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  box-shadow: inset -2px 0 3px rgba(0,0,0,0.3), inset 2px 0 0 rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 100ms ease-out;
}
.spine-case:hover .spine-case__spine { opacity: 0; }

.spine-case__spine-label {
  writing-mode: vertical-rl;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  white-space: nowrap;
  max-height: calc(100% - 1rem);
  overflow: hidden;
}
/* A single badge is centered; when both are present they split apart instead
   of stacking on top of each other (see the :has() overrides below). */
.spine-case__fav-dot { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); color: var(--mustard); font-size: 0.65rem; }
.spine-case__watched-dot { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.9); font-size: 0.65rem; }
.spine-case__spine:has(.spine-case__fav-dot):has(.spine-case__watched-dot) .spine-case__fav-dot {
  left: 6px;
  transform: none;
}
.spine-case__spine:has(.spine-case__fav-dot):has(.spine-case__watched-dot) .spine-case__watched-dot {
  left: auto;
  right: 6px;
  transform: none;
}

/* The global a:hover underline (see top of file) would otherwise apply to the
   spine/flap links, since neither has its own :hover rule to beat it on specificity. */
.spine-case a:hover { text-decoration: none; }

.spine-case[data-format="Vhs"] .spine-case__spine { background: var(--spine-vhs); }
.spine-case[data-format="Dvd"] .spine-case__spine { background: var(--spine-dvd); }
.spine-case[data-format="BluRay"] .spine-case__spine { background: var(--spine-bluray); }
.spine-case[data-format="Uhd4k"] .spine-case__spine { background: var(--spine-4k); }
.spine-case[data-format="LaserDisc"] .spine-case__spine { background: var(--spine-laserdisc); }
.spine-case[data-format="Other"] .spine-case__spine { background: var(--spine-other); }

.spine-case__flap {
  position: absolute;
  bottom: 0;
  left: 0;
  /* Fixed width rather than `right: 0` - the spine-case itself animates its width
     via flex-basis (200ms), and tying the flap's width to that would keep
     re-wrapping its title/chips at every intermediate width during the
     transition, each reflow jumping the (bottom-anchored) box's height. A fixed
     width matching the hover flex-basis gives it its final size immediately, so
     only opacity animates. */
  width: 170px;
  /* No `top: 0` - anchored to the case's bottom instead, so it rests on the shelf
     ledge like the spine does and grows upward into the row gap above when a
     title/chip row needs more room (e.g. a private item's extra "Private" chip),
     instead of overhanging the ledge below it. */
  min-height: 100%;
  background: var(--surface);
  /* Square bottom corners, not all four - it rests flush against the shelf ledge,
     and a rounded bottom-left/right (at a fractional-pixel box height, which is
     common once the content's wrapped height is added to the 100% minimum) can
     anti-alias into a sliver that reads as a gap above the ledge. */
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  box-shadow: 4px 4px 0 rgba(42,32,22,0.15);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out;
  display: flex;
  flex-direction: column;
}
.spine-case:hover .spine-case__flap {
  opacity: 1;
  pointer-events: auto;
  box-shadow: 6px 10px 18px rgba(42,32,22,0.3);
}
/* Sized to the hovered case's 170px width at a real poster's ~2:3 ratio, so the
   poster fills the box edge to edge - no cropping, no letterbox bars needed. */
.spine-case__flap .shelf-card__poster { height: 255px; flex-shrink: 0; aspect-ratio: auto; }
.spine-case__flap .shelf-card__body { padding: 0.5rem 0.6rem; overflow: hidden; }
.spine-case__flap .shelf-card__title {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-state .page-title { color: var(--muted); }

/* ---------- Users: find people ---------- */
.user-list { display: flex; flex-direction: column; gap: 0.75rem; max-width: 640px; }
.user-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
}
.user-list__identity { display: flex; align-items: center; gap: 0.6rem; }
.user-list__name { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; }

/* ---------- User avatars (initial-letter) ---------- */
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--ember);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.7rem;
  flex-shrink: 0;
  vertical-align: middle;
}
.user-avatar--lg { width: 2rem; height: 2rem; font-size: 0.85rem; }
.activity-line__text .user-avatar { margin-right: 0.45rem; }
.user-list__actions { display: flex; gap: 0.5rem; align-items: center; }

.compare-section { margin-bottom: 2.5rem; }
.compare-section__title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--link);
  border-bottom: 1px solid var(--cream-dark);
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}
.compare-section__count { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.viewing-user-banner {
  background: var(--success-tint); border: 1px solid var(--link); color: var(--link);
  border-radius: var(--radius); padding: 0.65rem 1rem; margin-bottom: 1.25rem;
  font-family: var(--font-heading); font-size: 0.85rem; letter-spacing: 0.2px;
}

/* ---------- Search / add flow ---------- */
.search-box { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; max-width: 640px; }
.search-box input { flex: 1; }
.media-type-toggle { display: inline-flex; border: 1px solid var(--link); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.media-type-toggle button {
  font-family: var(--font-heading); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.3px;
  padding: 0.5rem 1rem; border: none; background: var(--surface); color: var(--link); cursor: pointer;
}
.media-type-toggle button.active { background: var(--ember); color: #fff; }

.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 1.25rem;
}
.result-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius-card);
  overflow: hidden;
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(42,32,22,0.12);
  transition: transform 120ms ease-out;
}
.result-card:hover { transform: translateY(-3px); text-decoration: none; }
.result-card__poster { aspect-ratio: 2/3; background: var(--cream-dark); }
.result-card__poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-card__body { padding: 0.5rem 0.65rem 0.75rem; }
.result-card__title { font-family: var(--font-heading); font-size: 0.85rem; font-weight: 600; line-height: 1.2; margin-bottom: 0.3rem; }
.result-card__badge { font-family: var(--font-mono); font-size: 0.65rem; background: var(--mustard); color: var(--on-fill-dark); padding: 0.1rem 0.35rem; border-radius: 4px; }
.search-hint, .search-empty { color: var(--muted); font-family: var(--font-heading); }

.scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.scan-overlay[hidden] { display: none; }
.scan-overlay__panel {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.3);
}
.scan-overlay__panel video {
  width: 100%;
  border-radius: var(--radius-card);
  background: #000;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.scan-overlay__status {
  margin: 0.75rem 0;
  font-family: var(--font-heading);
  color: var(--ink);
}

/* ---------- Forms (create/edit) ---------- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 820px;
  box-shadow: 4px 4px 0 rgba(42,32,22,0.1);
}
.form-header { display: flex; gap: 1.25rem; margin-bottom: 1.5rem; align-items: flex-start; }
.form-header__poster { width: 100px; aspect-ratio: 2/3; border-radius: var(--radius-card); overflow: hidden; background: var(--cream-dark); flex-shrink: 0; }
.form-header__poster img { width: 100%; height: 100%; object-fit: cover; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}
.form-grid--full { grid-column: 1 / -1; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }
.already-on-shelf-note {
  background: var(--surface-tint); border: 1px solid var(--mustard); color: var(--accent-muted);
  border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 1rem; font-family: var(--font-heading); font-size: 0.85rem;
}
.form-notice {
  background: var(--surface-tint); border: 1px solid var(--mustard); color: var(--accent-muted);
  border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 1.25rem; font-size: 0.85rem; line-height: 1.4;
}

.flash-message {
  background: var(--success-tint); border: 1px solid var(--link); color: var(--link);
  border-radius: var(--radius); padding: 0.65rem 1rem; margin-bottom: 1.25rem;
  font-family: var(--font-heading); font-size: 0.85rem; letter-spacing: 0.2px;
}

/* ---------- Detail page ---------- */
.detail-layout { display: grid; grid-template-columns: 290px 1fr; gap: 2rem; align-items: start; }
.detail-poster { border-radius: var(--radius-card); overflow: hidden; box-shadow: 4px 4px 0 rgba(42,32,22,0.15); background: var(--cream-dark); aspect-ratio: 2/3; }
.detail-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-overview { margin: 1rem 0 1.5rem; line-height: 1.6; color: var(--ink); }
.detail-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.detail-section { margin-bottom: 1.5rem; }
.detail-section h3 { font-family: var(--font-heading); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.3px; color: var(--accent-muted); margin-bottom: 0.5rem; }
.detail-fields { display: grid; grid-template-columns: max-content 1fr; align-items: center; gap: 0.6rem 1rem; }
.detail-fields dt { font-family: var(--font-heading); font-size: 0.75rem; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.detail-fields dd { margin: 0; }
.friend-ownership-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.detail-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.detail-rating { margin-top: 1.25rem; }

/* ---------- Delete confirm ---------- */
.confirm-card {
  background: var(--surface-tint); border: 1px solid var(--rust); border-radius: var(--radius);
  padding: 1.75rem; max-width: 560px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  /* Grid items don't shrink below their content's intrinsic size by default, so
     without min-width:0 the poster image forces the column (and the page) wider
     than the viewport instead of scaling down to fit it. */
  .detail-layout { grid-template-columns: 1fr; }
  .detail-layout > * { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-fields { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar__field { flex: 1 1 auto; }
  .checkbox-row--grid-align { margin-top: 0; }
  .form-actions,
  .detail-actions { flex-direction: column; align-items: stretch; }

  /* Collapse the nav behind a hamburger instead of letting links wrap mid-word.
     The display:none/is-open toggle only applies once nav-toggle.js has marked
     <html> as nav-js - without it (JS disabled or failed to load), the nav
     stays visible and stacked so Your Shelf/Add to Shelf/Logout stay reachable.
     Every row (search, links, the user trigger) shares one left-aligned,
     full-width recipe with a hairline divider, so the open menu reads as one
     consistent list instead of a mix of centered text and an unlabeled icon. */
  .site-header__inner { flex-wrap: wrap; }
  html.nav-js .nav-toggle { display: flex; }
  .site-nav {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 0.85rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  html.nav-js .site-nav { display: none; }
  html.nav-js .site-nav.is-open { display: flex; }

  .site-nav__link,
  .nav-search__toggle,
  .user-menu__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 0.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: left;
  }
  .site-nav__link:active,
  .nav-search__toggle:active,
  .user-menu__trigger:active { background: rgba(255,255,255,0.08); }
  .user-menu__trigger { justify-content: space-between; }

  .site-nav__link--cta {
    border-bottom: none;
    border-radius: var(--radius);
    padding: 0.85rem 0.6rem;
    margin: 0.5rem 0;
  }

  .nav-search { width: 100%; }
  /* Overrides the shared width:100% above - as a flex item inside .nav-search
     (not .site-nav directly), that would claim the whole row and leave no
     space for the input to expand into once search opens. */
  .nav-search__toggle { width: auto; flex: 1; }
  .nav-search.is-open .nav-search__toggle { flex: 0 0 auto; border-bottom-color: transparent; }
  .nav-search__label { display: inline; }
  .nav-search.is-open .nav-search__label { display: none; }
  .nav-search.is-open .nav-search__form { flex: 1; width: auto; margin-left: 0.3rem; }
  .nav-search__suggestions { width: 100%; max-width: none; }

  .user-menu { width: 100%; }
  .user-menu__panel { position: static; width: 100%; margin-top: 0.4rem; box-shadow: none; }

  /* The spine view's fixed 340px case height (tuned for desktop hover-reveal) makes
     browsing the shelf one endless scroll on a phone, where hover never fires anyway. */
  .spine-case { height: 170px; }
  .spine-case:hover { flex-basis: 170px; }
  .spine-case__flap .shelf-card__poster { height: 125px; }

  /* Wider stars give a drag more pixels per half-star to land on, which
     matters more on a touchscreen than with a mouse's finer pointer precision. */
  .star-input__track { font-size: 2.1rem; gap: 4px; }

  /* Let two columns fit on a phone instead of one oversized card per row. */
  .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 1.25rem 0.85rem; }
  .search-results { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }

  /* Less margin for the carousel arrows so the poster cards get the room back. */
  .whats-next-carousel { margin: 0 2.1rem; }
  .whats-next-carousel__arrow { width: 1.9rem; font-size: 0.85rem; }
}

/* Touch devices have no hover to trigger the flap-reveal, so it's dead
   weight there - worse, even fully transparent it's still a 170px-wide
   absolutely-positioned box sitting inside a ~44px spine, and that alone was
   enough to widen the whole row's scrollable area well past the screen,
   dragging the rest of the page wide enough that mobile browsers would zoom
   out to fit it (which is also what knocked every other element out of
   alignment with the screen). Removing it keeps the actual shelf look - the
   packed, color-coded spines on their wood ledge - as the mobile layout too,
   instead of swapping it out for plain poster cards: each spine is already
   its own full-height link, so a single tap opens it exactly as before. */
@media (hover: none) {
  .spine-case__flap { display: none; }
}
