/* ─── Movie recommender view ────────────────────────────── */
.movie-results {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.movie-results::-webkit-scrollbar { width: 8px; }
.movie-results::-webkit-scrollbar-track { background: transparent; }
.movie-results::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 4px; }
.movie-results::-webkit-scrollbar-thumb:hover { background: var(--gold); }

.movie-intro {
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.movie-query { font-size: 1.05rem; }

.movie-card {
  align-self: stretch;
  padding: 14px 18px;
  border-radius: 4px;
  background: rgba(42, 30, 0, 0.4);
  border: 1px solid rgba(214, 160, 23, 0.3);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: bubble-in 0.35s ease both;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.movie-card.error {
  background: rgba(139, 74, 43, 0.2);
  border-color: #ff6b6b;
  color: #ffb3b3;
}

/* Markdown inside a result card */
.movie-card h1, .movie-card h2, .movie-card h3, .movie-card h4 {
  font-family: "Cinzel Decorative", serif;
  color: var(--gold);
  line-height: 1.25;
  margin: 14px 0 6px;
  text-shadow: 0 0 20px rgba(212, 160, 23, 0.25);
}
.movie-card h1 { font-size: 1.18rem; }
.movie-card h2 { font-size: 1.06rem; }
.movie-card h3 { font-size: 0.98rem; }
.movie-card h4 { font-size: 0.92rem; }
.movie-card h1:first-child,
.movie-card h2:first-child,
.movie-card h3:first-child { margin-top: 0; }
.movie-card p { margin: 6px 0; }
.movie-card strong { color: var(--gold-lt); font-weight: 600; }
.movie-card em { color: var(--gold); font-style: italic; }
.movie-card a {
  color: var(--gold-lt);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.movie-card a:hover { color: #fff; }
.movie-card ul { margin: 6px 0 6px 2px; padding-left: 18px; }
.movie-card li { margin: 3px 0; }
.movie-card hr {
  border: none;
  border-top: 1px dashed rgba(139, 105, 20, 0.4);
  margin: 14px 0;
}

.movie-status {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--gold-lt);
  letter-spacing: 0.06em;
  padding: 8px 2px 4px;
  min-height: 1.2em;
}

/* ─── Movie search-level segmented control ──────────────── */
.movie-level {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 8px;
}
.movie-level-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  overflow: hidden;
}
.seg-btn {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-left: 1px solid var(--gold-dim);
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg-btn:first-child { border-left: none; }
.seg-btn:hover { color: var(--gold-lt); }
.seg-btn.is-active {
  color: #1a1206;
  background: var(--gold);
  font-weight: 600;
}

/* ─── Movie search history dropdown ─────────────────────── */
.movie-history {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 10px;
  margin-bottom: 6px;
  border-bottom: 1px dashed rgba(139, 105, 20, 0.3);
}
.movie-history-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex: 0 0 auto;
}
.movie-history-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.movie-history-field select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--gold-lt);
  background: rgba(26, 16, 5, 0.6);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 7px 30px 7px 12px;
  cursor: pointer;
  text-overflow: ellipsis;
  transition: border-color 0.2s, color 0.2s;
}
.movie-history-field select:hover { border-color: var(--gold); }
.movie-history-field select:focus { outline: none; border-color: var(--gold); }
.movie-history-field select option { color: #1a1206; background: #f3e6c8; }
.movie-history-chev {
  position: absolute;
  right: 9px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--gold);
  pointer-events: none;
}
.movie-card-pending { min-height: 1.5em; }


/* ═══════════════ Movie search-time visualization popup ═══════════════
   Driven by SearchViz in js/movies.js (SSE: search_start / search_progress /
   search_filter). Replaces the old text progress line. Self-contained: all
   colours are scoped here so the popup reads as a little "projector" panel.
   Amber (--sv-beam) = database search · teal (--sv-web) = internet search. */
.sv-overlay {
  --sv-surface:  #1b1409;
  --sv-surface2: #241a0d;
  --sv-ink:      var(--text);
  --sv-muted:    var(--text-dim);
  --sv-line:     #4a3811;
  --sv-beam:     var(--gold);
  --sv-beam-dim: #6a5013;
  --sv-web:      #4fd1c5;
  --sv-done:     #7be0a3;

  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 6, 2, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: end center;          /* bottom-sheet on mobile */
  padding: 0;
}
@media (min-width: 560px) {
  .sv-overlay { place-items: center; padding: 24px; }
}

.searchviz {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--sv-surface);
  border: 1px solid var(--sv-line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: sv-rise 0.34s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@media (min-width: 560px) {
  .searchviz { border-radius: 18px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); }
}
@keyframes sv-rise { from { transform: translateY(28px); opacity: 0; } }

/* Film-cell sprocket rail along the bottom — signature framing device. */
.searchviz::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 10px;
  background-image: radial-gradient(circle, var(--sv-line) 2px, transparent 2.5px);
  background-size: 18px 10px;
  background-position: 6px center;
  opacity: 0.8;
  pointer-events: none;
}

.sv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sv-line);
}
.sv-dots { display: flex; gap: 6px; }
.sv-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--sv-line); }
.sv-dots i:nth-child(1) { background: var(--sv-beam); }
.sv-title {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sv-muted);
}
.sv-title b { color: var(--sv-ink); }
.sv-close {
  margin-left: auto;
  background: none; border: 0; cursor: pointer;
  color: var(--sv-muted); font-size: 1.3rem; line-height: 1;
  width: 32px; height: 32px; border-radius: 8px;
}
.sv-close:hover { background: var(--sv-surface2); color: var(--sv-ink); }
.sv-close:focus-visible { outline: 2px solid var(--sv-beam); outline-offset: 2px; }

.sv-body { padding: 22px 18px 22px; }

.sv-query {
  text-align: center;
  font-family: var(--sans);
  font-size: 0.98rem;
  color: var(--sv-ink);
  padding: 0 8px;
}
.sv-query .q {
  background: linear-gradient(180deg, transparent 62%, var(--sv-beam-dim) 62%);
  padding: 2px 2px 0;
}
.sv-query::after {           /* beam dropping from the query */
  content: "";
  display: block;
  width: 2px; height: 20px;
  margin: 8px auto 0;
  background: linear-gradient(180deg, var(--sv-beam), transparent);
}

.sv-rail {
  height: 2px;
  background: var(--sv-line);
  margin: 0 auto;
  max-width: 90%;
  border-radius: 2px;
}
.sv-rail.active {
  background: linear-gradient(90deg, var(--sv-beam-dim), var(--sv-beam), var(--sv-beam-dim));
}

.sv-nodes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 0 2px;
}
@media (min-width: 560px) {
  .sv-nodes { flex-direction: row; gap: 10px; align-items: stretch; }
}

.sv-node {
  flex: 1 1 0;
  position: relative;
  background: var(--sv-surface2);
  border: 1px solid var(--sv-line);
  border-radius: 12px;
  padding: 11px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 0.25s, background 0.25s, opacity 0.25s, transform 0.25s;
}
.sv-node::before {           /* drop-stub connecting node to the rail */
  content: "";
  position: absolute;
  left: 20px; top: -14px;
  width: 2px; height: 14px;
  background: var(--sv-line);
}
@media (min-width: 560px) {
  .sv-node::before { left: 50%; transform: translateX(-50%); }
}

.sv-node[data-kind="db"][data-status="active"]  { border-color: var(--sv-beam); background: #241d0f; }
.sv-node[data-kind="db"][data-status="active"]::before  { background: var(--sv-beam); }
.sv-node[data-kind="web"][data-status="active"] { border-color: var(--sv-web);  background: #12211f; }
.sv-node[data-kind="web"][data-status="active"]::before { background: var(--sv-web); }

.sv-node[data-status="active"]::after {          /* scan shimmer */
  content: "";
  position: absolute; inset: 0;
  border-radius: 12px;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.07) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: sv-scan 1.15s linear infinite;
  pointer-events: none;
}
@keyframes sv-scan { from { background-position: 140% 0; } to { background-position: -60% 0; } }

.sv-node-top {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--sans);
  font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--sv-muted);
}
.sv-node[data-kind="db"][data-status="active"]  .sv-tag { color: var(--sv-beam); }
.sv-node[data-kind="web"][data-status="active"] .sv-tag { color: var(--sv-web); }
.sv-node-icon { font-size: 0.95rem; }
.sv-node-title { font-family: var(--serif); font-size: 0.98rem; font-weight: 600; color: var(--sv-ink); }
.sv-node-sub   { font-family: var(--sans); font-size: 0.68rem; color: var(--sv-muted); }

.sv-node-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
  font-family: var(--sans);
  font-size: 0.74rem;
  color: var(--sv-muted);
}
.sv-glyph { width: 1.1em; text-align: center; }
.sv-node[data-status="done"] { border-color: rgba(123, 224, 163, 0.4); }
.sv-node[data-status="done"] .sv-glyph,
.sv-node[data-status="done"] .sv-node-foot { color: var(--sv-done); }

.sv-converge { margin: 4px auto 0; max-width: 90%; }
.sv-converge .sv-rail { margin-bottom: 14px; }
.sv-filter {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--sv-surface2);
  border: 1px dashed var(--sv-line);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--sv-muted);
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.sv-filter[data-state="running"] { animation: sv-breathe 1.4s ease-in-out infinite; color: var(--sv-ink); }
.sv-filter b { color: var(--sv-ink); }
@keyframes sv-breathe { 50% { border-color: var(--sv-muted); } }

.sv-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--sv-line); border-top-color: var(--sv-beam);
  animation: sv-spin 0.8s linear infinite;
}
@keyframes sv-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .searchviz, .sv-node::after, .sv-filter, .sv-spinner { animation: none !important; }
}
