/* ---- Clean Retro Blockbuster theme ---- */
:root {
  --bb-blue: #00268f;
  --bb-blue-dark: #001a66;
  --bb-blue-mid: #16244d;
  --bb-gold: #f6d000;
  --bb-red: #e8322e;
  --bb-cream: #e9e4d8;
  --bb-text: #dfe7ff;
  --bb-muted: #8fa7d9;
  --wood-hi: #a8734a;
  --wood: #7a5230;
  --wood-dark: #4a2f18;
  --sign-font: "Arial Black", "Arial Bold", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bb-blue);
  color: var(--bb-text);
  font-family: Arial, Helvetica, sans-serif;
}

/* ---- Header ---- */
.store-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bb-blue-dark);
  border-bottom: 3px solid var(--bb-gold);
}

.logo {
  display: inline-block;
  background: var(--bb-gold);
  color: var(--bb-blue);
  font-family: var(--sign-font);
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: 1px;
  padding: 5px 14px;
  transform: skew(-8deg);
  text-decoration: none;
}

.logo-h { margin: 0; font-size: inherit; line-height: 1; }

.header-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

#search-input {
  border: none;
  border-radius: 3px;
  padding: 8px 12px;
  font-size: 0.9rem;
  width: 200px;
}

.btn-gold, .btn-outline {
  font-family: var(--sign-font);
  font-size: 0.75rem;
  padding: 8px 12px;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.5px;
}
.btn-gold { background: var(--bb-gold); color: var(--bb-blue); border: none; font-weight: 900; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--bb-gold); border: 2px solid var(--bb-gold); font-weight: 700; }
.btn-outline:hover { background: rgba(246, 208, 0, 0.12); }

main { padding: 18px; max-width: 1200px; margin: 0 auto; }

/* ---- Shelf signs ---- */
.sign {
  display: inline-block;
  font-family: var(--sign-font);
  font-weight: 900;
  font-size: 0.95rem;
  padding: 4px 12px;
  margin: 0;
  letter-spacing: 1px;
}
.sign-gold { background: var(--bb-gold); color: var(--bb-blue); }
.sign-red { background: var(--bb-red); color: #fff; }

.shelf { margin-bottom: 26px; }
.shelf-title-row { display: flex; align-items: baseline; gap: 12px; }
.see-all {
  color: var(--bb-muted);
  font-size: 0.8rem;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.see-all:hover { color: var(--bb-gold); }
.shelf-refresh {
  background: none;
  border: none;
  color: var(--bb-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.shelf-refresh:hover { color: var(--bb-gold); }

.shelf-collapse {
  background: none;
  border: none;
  color: var(--bb-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.shelf-collapse:hover { color: var(--bb-gold); }
.shelf.collapsed .shelf-row, .shelf.collapsed .shelf-wood { display: none; }

.shelf-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 12px 2px 10px;
  scrollbar-width: thin;
}

.shelf-wood {
  height: 8px;
  background: linear-gradient(var(--wood), var(--wood-dark));
  border-top: 2px solid var(--wood-hi);
  border-radius: 1px;
}

/* ---- Movie boxes ---- */
.movie-box {
  position: relative;
  flex: 0 0 auto;
  width: 130px;
}
.movie-open {
  display: block;
  width: 100%;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}
.poster-wrap { position: relative; display: block; }
.rating-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 8, 30, 0.78);
  color: #fff;
  font-size: 0.62rem;
  line-height: 1;
  padding: 3px 4px;
  text-align: center;
  letter-spacing: 0.3px;
  pointer-events: none;
}
.movie-box img, .movie-box .no-poster {
  display: block;
  width: 130px;
  height: 195px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid rgba(246, 208, 0, 0.55);
  background: var(--bb-blue-mid);
}
.movie-box .no-poster {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  color: var(--bb-muted);
  font-family: var(--sign-font);
  font-size: 0.75rem;
}
.movie-box:hover img, .movie-box:hover .no-poster { outline: 2px solid var(--bb-gold); }
.movie-open:focus-visible img, .movie-open:focus-visible .no-poster { outline: 2px solid var(--bb-gold); }
.btn-gold:focus-visible, .btn-outline:focus-visible, .see-all:focus-visible,
.shelf-refresh:focus-visible, .shelf-collapse:focus-visible,
.btn-stack:focus-visible, .btn-trailer:focus-visible, .btn-again:focus-visible,
.btn-watched:focus-visible, .watched-chip:focus-visible, .hide-chip:focus-visible, .stack-chip:focus-visible,
.trailer-chip:focus-visible, #trailer-resize:focus-visible,
.stack-item-title:focus-visible, .stack-remove:focus-visible, .case-close:focus-visible {
  outline: 2px solid var(--bb-gold);
  outline-offset: 2px;
}

.new-sticker {
  position: absolute;
  top: 6px;
  left: -4px;
  background: var(--bb-red);
  color: #fff;
  font-family: var(--sign-font);
  font-size: 0.6rem;
  font-weight: 900;
  padding: 2px 6px;
  transform: rotate(-6deg);
}

.stack-chip, .watched-chip, .hide-chip, .trailer-chip {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 26, 102, 0.85);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}
.stack-chip { top: 6px; border: 1px solid #fff; color: #fff; font-size: 1rem; }
.stack-chip:hover { background: #fff; color: var(--bb-blue); }
.stack-chip.stacked { background: var(--bb-gold); border-color: var(--bb-gold); color: var(--bb-blue); }
.watched-chip { top: 38px; border: 1px solid var(--bb-gold); color: var(--bb-gold); }
.watched-chip:hover { background: var(--bb-gold); color: var(--bb-blue); }
.hide-chip { top: 70px; border: 1px solid var(--bb-red); color: #ff9c99; }
.hide-chip:hover { background: var(--bb-red); color: #fff; }
.trailer-chip { top: 102px; border: 1px solid var(--bb-muted); color: var(--bb-text); }
.trailer-chip:hover { background: var(--bb-gold); color: var(--bb-blue); border-color: var(--bb-gold); }

.clerk-note {
  display: block;
  margin: 4px 0 0;
  color: var(--bb-muted);
  font-size: 0.7rem;
  font-style: italic;
  width: 130px;
}

/* ---- Placeholders / errors ---- */
.shelf-error { color: var(--bb-muted); font-size: 0.85rem; display: flex; gap: 10px; align-items: center; }
.placeholder-box {
  flex: 0 0 auto;
  width: 130px;
  height: 195px;
  border-radius: 2px;
  background: var(--bb-blue-mid);
  opacity: 0.6;
}

/* ---- Grid view ---- */
.grid-header { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  padding: 14px 0;
}
.poster-grid .movie-box { width: 100%; }
.poster-grid .movie-box img, .poster-grid .movie-box .no-poster { width: 100%; height: auto; aspect-ratio: 2 / 3; }
.grid-footer { text-align: center; padding: 10px 0 30px; }

/* ---- Corner trailer player: borderless, video fills the box, controls float ---- */
#trailer-player {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 35;
  width: min(360px, calc(100vw - 28px));
  background: #000;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}
#trailer-player[hidden] { display: none; }
.trailer-bar {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  pointer-events: none; /* only the buttons catch clicks; video stays interactive */
}
#trailer-title { display: none; }
#trailer-resize, #trailer-close {
  pointer-events: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 8, 30, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 400;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
#trailer-resize { cursor: nwse-resize; touch-action: none; }
#trailer-resize:hover, #trailer-close:hover { background: var(--bb-gold); color: var(--bb-blue); border-color: var(--bb-gold); }
#trailer-frame { aspect-ratio: 16 / 9; }
#trailer-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
/* after a manual resize the frame fills whatever height the user chose */
#trailer-player.freesize #trailer-frame { aspect-ratio: auto; height: 100%; }
#trailer-player.resizing iframe { pointer-events: none; }

/* ---- Modal: back of the case ---- */
/* The [hidden] rule is load-bearing: our display:flex would otherwise override
   the UA stylesheet's display:none for the hidden attribute, leaving an
   invisible click-blocking overlay over the whole page. */
#modal-root[hidden] { display: none; }
#modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 10, 40, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.case-back {
  background: var(--bb-cream);
  color: #222;
  border-radius: 3px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.case-top { display: flex; gap: 14px; }
.case-poster { width: 110px; height: 165px; object-fit: cover; border-radius: 2px; background: var(--bb-blue-mid); flex-shrink: 0; }
.case-title { font-family: var(--sign-font); font-size: 1.05rem; margin: 0; color: #111; }
.case-meta { font-size: 0.75rem; color: #555; margin: 4px 0 8px; }
.case-overview { font-size: 0.85rem; line-height: 1.5; color: #333; margin: 0; }
.case-cast { font-size: 0.75rem; color: #666; margin: 8px 0 0; }
.clerk-says {
  background: var(--bb-gold);
  color: var(--bb-blue);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 2px;
  margin-bottom: 10px;
}
.availability { border-top: 1px dashed #aaa; margin-top: 12px; padding-top: 10px; }
.availability-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--bb-blue);
  letter-spacing: 1px;
  margin: 0 0 6px;
}
.provider-row { display: flex; flex-wrap: wrap; gap: 6px; }
.provider {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #111;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 2px;
}
.provider img { width: 16px; height: 16px; border-radius: 3px; }
.provider.rent-buy { background: #f4f4f4; color: #555; border: 1px solid #ddd; }
.not-in-stock { font-size: 0.8rem; color: #777; font-style: italic; }
.case-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btn-stack {
  flex: 1;
  background: var(--bb-blue);
  color: var(--bb-gold);
  font-family: var(--sign-font);
  font-weight: 900;
  font-size: 0.8rem;
  border: none;
  padding: 10px;
  border-radius: 2px;
  cursor: pointer;
}
.btn-trailer, .btn-again, .btn-watched {
  background: #fff;
  border: 2px solid var(--bb-blue);
  color: var(--bb-blue);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.case-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #666;
}

/* ---- Stack panel ---- */
#stack-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(340px, 90vw);
  background: var(--bb-blue-dark);
  border-left: 3px solid var(--bb-gold);
  padding: 16px;
  overflow-y: auto;
}
.stack-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stack-empty { color: var(--bb-muted); font-size: 0.85rem; }
#stack-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
#watched-sign { margin: 18px 0 4px; }
#watched-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
#watched-list img, #watched-list .no-poster { opacity: 0.55; }
.stack-item { display: flex; gap: 10px; align-items: center; }
.stack-item img, .stack-item .no-poster {
  width: 45px;
  height: 68px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--bb-blue-mid);
}
.stack-item-title {
  flex: 1;
  background: none;
  border: none;
  color: var(--bb-text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.stack-item-title:hover { color: var(--bb-gold); }
.stack-remove { background: none; border: none; color: var(--bb-red); cursor: pointer; font-size: 1rem; }

@media (max-width: 640px) {
  .store-header { justify-content: center; }
  #search-input { width: 100%; order: 3; }
}
