/* Ficha (hoja de detalle), buscador en celular, ficha tecnica, barra de progreso. */

/* ---------- ficha ---------- */
.sheet-overlay { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 70; align-items: flex-end; justify-content: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet-overlay.open { display: flex; }
/* la ficha recibe el foco al abrirse (para el lector de pantalla); no lleva contorno, sus botones si */
.sheet:focus-visible { outline: none; }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 90vh; background: var(--bg-app); border-radius: 24px 24px 0 0; padding: 10px 20px 26px; overflow-y: auto; box-shadow: 0 0 0 1px var(--ring), 0 30px 70px var(--glow-strong); }
.sheet-handle { width: 36px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 6px auto 14px; }
.sheet-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: none; color: var(--text-dim); font-size: 15px; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3; transition: transform .12s, color .15s;
}
.sheet-close:hover { color: var(--text); }
.sheet-close:active { transform: scale(.9); }

.sheet-body { display: block; }
.sheet-info, .sheet-actions { min-width: 0; }
.sheet-left { display: block; }
.sheet-headline { min-width: 0; }
.sheet-actions { margin-top: 4px; }
.sheet-poster { width: 130px; margin-bottom: 14px; }
.sheet-title { font-family: var(--font-title); font-size: 22px; font-weight: 700; letter-spacing: -.015em; line-height: 1.15; margin-bottom: 12px; text-wrap: balance; overflow-wrap: break-word; hyphens: auto; }
.sheet-title.is-mid { font-size: 20px; }
.sheet-title.is-long { font-size: 18px; line-height: 1.2; }
.sheet-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.sheet-meta .pill { font-family: var(--font-body); font-weight: 700; font-size: 12px; letter-spacing: 0; padding: 5px 11px; border-radius: 999px; color: var(--on-color); }
.names-list { margin-bottom: 10px; background: var(--surface); border-radius: 10px; padding: 2px 13px; }
.name-row { display: flex; gap: 12px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); }
.name-row:last-child { border-bottom: none; }
.name-lang { color: var(--text-faint); min-width: 34px; flex-shrink: 0; font-weight: 700; font-size: 11px; letter-spacing: .5px; padding-top: 1px; }
.name-value { color: var(--text-dim); }
.sheet-synopsis { font-size: 13.5px; line-height: 1.65; color: var(--text-dim); margin-bottom: 18px; }
.finished-note { font-size: 12px; color: var(--text-faint); margin-bottom: 16px; }
.finished-note strong { color: var(--text-dim); }
.sheet-section-label { font-family: var(--font-title); font-weight: 700; font-size: 15px; letter-spacing: -.01em; color: var(--text); margin: 14px 0 8px; }
.sheet-actions .sheet-section-label { margin-top: 0; }
.opt-block .hint { color: var(--text-faint); font-size: 12px; line-height: 1.5; }

/* PC: la ficha ocupa buena parte de la pantalla y se parte en dos columnas
   (poster + datos a la izquierda, controles a la derecha) para no dejar huecos */
@media (min-width: 900px) {
  .sheet-overlay { align-items: center; }
  .sheet { width: 82%; max-width: 1000px; max-height: 86vh; border-radius: 18px; padding: 26px 30px 30px; }
  .sheet-handle { display: none; }
  .sheet-body { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 14px 36px; align-items: start; }
  /* poster FLOTADO en vez de cuadricula rigida: el texto corre a su lado y,
     cuando la sinopsis es larga, RETOMA el ancho completo por debajo del
     poster en vez de dejar una columna vacia (el clear final ordena lo que sigue) */
  .sheet-left { display: block; margin-bottom: 20px; }
  .sheet-left .sheet-poster { float: left; width: 210px; margin: 0 26px 14px 0; }
  .sheet-left::after { content: ''; display: block; clear: both; }
  .sheet-poster { width: 100%; margin-bottom: 0; }
  .sheet-title { font-size: 30px; }
  .sheet-title.is-mid { font-size: 25px; }
  .sheet-title.is-long { font-size: 21px; }
  .sheet-synopsis { font-size: 14.5px; margin-bottom: 0; }
}

.search-input {
  width: 100%; padding: 13px 15px; border-radius: 12px; border: 1.5px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 15px; font-family: inherit;
  margin-bottom: 14px; transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-faint); }
.search-result { display: flex; gap: 13px; align-items: center; padding: 9px 4px; background: none; border: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit; color: inherit; transition: transform .12s; }
.search-result:active { transform: scale(.98); }
.search-result .poster { width: 50px; font-size: 16px; flex-shrink: 0; }
.search-result-title { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.search-result .pill { font-family: var(--font-body); font-weight: 700; font-size: 11px; letter-spacing: 0; padding: 3px 9px; border-radius: 999px; color: var(--on-color); }

/* ---------- pantalla de busqueda (celular) ----------
   (z-index 60: debajo de la ficha, que es 70, para que la ficha se abra encima)
   en celular buscar es una pantalla completa y no un panel flotante: asi el
   teclado de iOS no pelea por reposicionar nada y no se descoloca al escribir */
.search-screen {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: var(--bg-app); flex-direction: column;
}
.search-screen.open { display: flex; }
.search-screen-bar {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border-soft); background: var(--bg-nav);
}
.search-screen-bar .search-input { margin-bottom: 0; flex: 1 1 auto; min-width: 0; }
.search-cancel {
  background: none; border: none; color: var(--accent); font-family: inherit;
  font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; padding: 6px 2px;
}
.search-screen-results {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- ficha tecnica ---------- */
.tech-list { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 9px; }
.tech-row { display: flex; gap: 10px; font-size: 13px; line-height: 1.45; }
.tech-label { color: var(--text-faint); min-width: 82px; flex-shrink: 0; font-weight: 600; }
.tech-value { color: var(--text-dim); }
.tech-value.loading { opacity: .45; }
.tmdb-score { display: inline-flex; align-items: center; gap: 6px; }
.tmdb-score i { color: var(--star); font-size: 12px; }
.tmdb-score .count { color: var(--text-faint); font-size: 11px; }
.year-tag { color: inherit; font-weight: inherit; }

/* ---------- salir (al final de opciones) ---------- */
.logout-block { margin-top: 30px; max-width: 560px; }
.btn-logout {
  width: 100%; padding: 13px; border-radius: 12px; background: none;
  border: 1.5px solid var(--danger-line); color: var(--danger);
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .12s;
}
.btn-logout:active { transform: scale(.96); }

/* ---------- barra de progreso de la actualizacion ---------- */
.progress-wrap { margin-top: 12px; }
.progress-bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.progress-text-line { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.progress-text-line.ok { color: var(--success); }
.progress-text-line.fail { color: var(--danger); }
