/* Requests from the Cinema (media/cinema-request.js): the right-click menu, the
   seasons popout and the "Worth adding" finder. The Cinema's own screening-room
   palette (media/cinema.css: ink, warm paper, brass), declared here too because
   the menu, the popout and the page sit on <body>, outside .cinema-host. */
.cr-menu, .cr-scrim, .cr-page, .cr-toast {
  --cr-bg: #0d1016;
  --cr-panel: #191d25;
  --cr-ink: #f4f0e9;
  --cr-muted: #b8bbc4;
  --cr-accent: #edc78d;
  --cr-line: #ffffff20;
  --cr-pill: rgba(245, 158, 11, .42);
  --cr-ease: cubic-bezier(.2, .8, .2, 1);
  color: var(--cr-ink);
  color-scheme: dark;
}
.cr-menu [hidden], .cr-scrim [hidden], .cr-page [hidden] { display: none !important; }

/* ── the right-click menu ─────────────────────────────────────────────── */
.cr-menu {
  position: fixed; z-index: 10060; min-width: 260px; max-width: min(340px, calc(100vw - 16px)); padding: 6px;
  border-radius: 14px; border: 1px solid var(--cr-pill); background: rgba(25, 29, 37, .98);
  box-shadow: 0 24px 48px -18px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 233, 196, .06);
  opacity: 0; transform: translateY(4px) scale(.98); transform-origin: top left; transition: opacity .12s, transform .18s var(--cr-ease);
}
.cr-menu.is-open { opacity: 1; transform: none; }
.cr-menu-h { margin: 4px 10px 6px; font-size: 13px; font-weight: 700; color: var(--cr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-menu-h span { font-weight: 500; }
.cr-menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 40px;
  padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: var(--cr-ink); text-align: left; cursor: pointer; font: inherit;
}
.cr-menu-item b { font-weight: 650; font-size: 14.5px; }
.cr-menu-item small { font-size: 12.5px; color: var(--cr-muted); }
.cr-menu-item.is-lead b { color: var(--cr-accent); }
.cr-menu-item:hover:not(:disabled), .cr-menu-item:focus-visible { background: rgba(245, 158, 11, .12); outline: none; }
.cr-menu-item:disabled { cursor: default; opacity: .55; }
.cr-menu-item.has-ico { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 11px; row-gap: 1px; align-items: center; }
.cr-menu-item.has-ico > .cr-menu-ico { grid-row: 1 / span 2; width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 2px 3px #0008); }
.cr-menu-item.has-ico:not(:has(small)) > .cr-menu-ico { grid-row: auto; }
.cr-menu-item.has-ico > b, .cr-menu-item.has-ico > small { grid-column: 2; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; }
.cr-menu-item.is-sep { position: relative; margin-top: 9px; }
.cr-menu-item.is-sep::before { content: ''; position: absolute; left: 12px; right: 12px; top: -5px; height: 1px; background: var(--cr-line); pointer-events: none; }

/* ── the seasons popout ───────────────────────────────────────────────── */
.cr-scrim {
  position: fixed; inset: 0; z-index: 10050; display: flex; align-items: center; justify-content: center; padding: 4vh 16px;
  background: rgba(4, 6, 10, .62); backdrop-filter: blur(6px); opacity: 0; transition: opacity .18s;
}
.cr-scrim.is-open { opacity: 1; }
.cr-dlg {
  width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; outline: none;
  border-radius: 20px; border: 1px solid var(--cr-line); background: var(--cr-panel);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .95); transform: translateY(12px); transition: transform .28s var(--cr-ease);
}
.cr-scrim.is-open .cr-dlg { transform: none; }
.cr-dlg-h { display: flex; align-items: center; gap: 14px; padding: 18px 18px 14px; border-bottom: 1px solid var(--cr-line); }
.cr-dlg-poster { flex: none; width: 54px; height: 81px; border-radius: 8px; object-fit: cover; }
.cr-dlg-t { flex: 1 1 auto; min-width: 0; }
.cr-dlg-t p { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--cr-accent); }
.cr-dlg-t h2 { margin: 0; font-size: 21px; line-height: 1.2; text-wrap: balance; }
.cr-dlg-t h2 span { font-size: .7em; font-weight: 500; color: var(--cr-muted); }
.cr-icon {
  flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border-radius: 12px; border: 1px solid var(--cr-line); background: rgba(255, 255, 255, .03); color: var(--cr-ink); cursor: pointer;
}
.cr-icon:hover { border-color: var(--cr-accent); }
.cr-icon:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }
.cr-dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 18px; }
.cr-dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 16px; border-top: 1px solid var(--cr-line); flex-wrap: wrap; }
.cr-quiet { margin: 8px 0; color: var(--cr-muted); font-size: 14px; }
.cr-note { font-size: 13px; }
.cr-err { margin: 8px 0; padding: 10px 12px; border-radius: 10px; color: #ffd8cc; background: rgba(180, 56, 30, .25); border: 1px solid rgba(255, 138, 107, .45); }
.cr-season-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cr-season { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--cr-line); cursor: pointer; transition: border-color .15s, background .15s; }
.cr-season:hover { border-color: var(--cr-pill); }
.cr-season:has(input:checked) { border-color: var(--cr-accent); background: rgba(245, 158, 11, .1); }
.cr-season.is-future { opacity: .5; cursor: default; }
.cr-season input, .cr-all input { width: 20px; height: 20px; accent-color: #f59e0b; flex: none; }
.cr-season-t { display: flex; flex-direction: column; min-width: 0; }
.cr-season-t b { font-weight: 650; }
.cr-season-t small { color: var(--cr-muted); font-size: 13px; }
.cr-all { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14.5px; }
.cr-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.cr-log li { padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, .03); overflow-wrap: anywhere; }
.cr-log li.is-ok { color: #a7f3d0; background: rgba(16, 185, 129, .1); }
.cr-log li.is-error { color: #ffd8cc; background: rgba(180, 56, 30, .2); }

/* The Cinema's button, here outside its dialog: an amber pill; the season
   "Request" leads. */
.cr-page .cinema-button, .cr-dlg .cinema-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--cr-pill); background: rgba(245, 158, 11, .12);
  color: var(--cr-ink); font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.cr-page .cinema-button:hover:not(:disabled), .cr-dlg .cinema-button:hover:not(:disabled) { background: rgba(245, 158, 11, .24); border-color: var(--cr-accent); }
.cr-page .cinema-button:focus-visible, .cr-dlg .cinema-button:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }
.cr-dlg .cr-go:not(:disabled) { color: #1c1206; border-color: rgba(255, 220, 160, .7); background: linear-gradient(180deg, #ffd27a, #f59e0b); }
.cr-page .cinema-button:disabled, .cr-dlg .cinema-button:disabled { opacity: .55; cursor: default; }

/* ── the finder page ──────────────────────────────────────────────────── */
.cr-page {
  position: fixed; inset: 0; z-index: 10040; display: flex; flex-direction: column; outline: none;
  background: radial-gradient(80% 50% at 100% 0%, rgba(237, 199, 141, .08), transparent 60%), var(--cr-bg);
  opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .3s var(--cr-ease);
}
.cr-page.is-open { opacity: 1; transform: none; }
.cr-page-bar {
  flex: none; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px max(20px, calc((100vw - 1400px) / 2)); padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--cr-line); background: rgba(18, 23, 32, .92); backdrop-filter: blur(16px);
}
.cr-page-bar h1 { margin: 0; font-size: clamp(22px, 2.4vw, 28px); letter-spacing: -.02em; }
.cr-page-sub { margin: 0; color: var(--cr-muted); font-size: 14px; }
.cr-page-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px max(20px, calc((100vw - 1400px) / 2)) 48px; }
.cr-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; margin-bottom: 12px; }
.cr-f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cr-f span { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--cr-muted); }
.cr-f select, .cr-f input {
  min-height: 44px; min-width: 150px; padding: 0 14px; border-radius: 999px; font: inherit; font-size: 15px; color: var(--cr-ink);
  border: 1px solid var(--cr-pill); background: rgba(10, 11, 16, .72);
}
.cr-f select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--cr-muted) 50%), linear-gradient(135deg, var(--cr-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.cr-f select option { background: #191d25; color: var(--cr-ink); }
.cr-f--genre input { min-width: 190px; }
.cr-f select:focus-visible, .cr-f input:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }
.cr-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14.5px; }
.cr-switch input { width: 20px; height: 20px; accent-color: #f59e0b; }
.cr-count { min-height: 20px; margin: 4px 0 14px; color: var(--cr-muted); font-size: 14px; }
/* Posters in columns that always fill the row: no gaps at the end. */
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 16px; }
.cr-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; animation: cr-in .4s var(--cr-ease) both; animation-delay: calc(var(--i, 0) * 25ms); }
@keyframes cr-in { from { opacity: 0; transform: translateY(10px); } }
.cr-card-art {
  position: relative; display: block; width: 100%; aspect-ratio: 2 / 3; padding: 0; border: 0; border-radius: 12px; overflow: hidden; cursor: pointer;
  background: var(--cr-panel); box-shadow: 0 10px 22px -14px rgba(0, 0, 0, .9);
}
.cr-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s var(--cr-ease); }
.cr-card-art:hover img { transform: scale(1.04); }
.cr-card-art:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 3px; }
.cr-rating {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 999px; font-size: 13px; font-weight: 800;
  color: #1c1206; background: linear-gradient(180deg, #ffd27a, #f59e0b);
}
.cr-card-t { display: flex; flex-direction: column; min-width: 0; }
.cr-card-t b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-card-t small { color: var(--cr-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-card-go { min-height: 40px; width: 100%; }
.cr-card-go:disabled { opacity: .6; cursor: default; }
.cr-skel { pointer-events: none; animation: none; }
.cr-skel .cr-card-art { background: linear-gradient(110deg, rgba(255, 255, 255, .03) 30%, rgba(255, 255, 255, .07) 50%, rgba(255, 255, 255, .03) 70%) 0 0 / 300% 100%; animation: cr-shimmer 1.5s linear infinite; }
.cr-line { display: block; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .06); }
.cr-line--short { width: 60%; }
@keyframes cr-shimmer { to { background-position: -300% 0; } }
.cr-empty { grid-column: 1 / -1; padding: 48px 20px; text-align: center; border-radius: 18px; border: 1px dashed var(--cr-line); }
.cr-empty h3 { margin: 0 0 8px; font-size: 20px; }
.cr-empty p { margin: 0 auto; max-width: 52ch; color: var(--cr-muted); }

/* The page's own toast when the host has none (the phone). */
.cr-toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 10070; max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 14px; background: rgba(25, 29, 37, .97); border: 1px solid var(--cr-pill); font-size: 14.5px;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--cr-ease);
}
.cr-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.cr-toast.is-error { border-color: rgba(255, 138, 107, .7); }

@media (max-width: 720px) {
  .cr-scrim { padding: 0; align-items: flex-end; }
  .cr-dlg { width: 100vw; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .cr-dlg-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .cr-page-scroll { padding: 14px 16px 40px; }
  .cr-page-sub { flex-basis: 100%; }
  .cr-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .cr-f select, .cr-f input { min-width: 0; width: 100%; }
  .cr-f--genre, .cr-switch { grid-column: 1 / -1; }
  .cr-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .cr-menu, .cr-scrim, .cr-dlg, .cr-page, .cr-toast, .cr-card-art img { transition: none !important; }
  .cr-card, .cr-skel .cr-card-art { animation: none !important; }
}

/* A finder title a friend's Hearth already has (media/cinema-shared.js findShared). */
.cr-on-shared { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; color: #241b0e; background: rgba(237, 199, 141, .94); }
.cr-card-go.cr-card-watch { color: #241b0e; background: var(--cinema-accent, #edc78d); border-color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
