/* Archivo (SIL OFL 1.1, ver fonts/OFL.txt): ejes de peso y ancho. */
@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

/* Papel de periódico gris neutro (no crema) + tinta + rojo de boleto como
   único acento. */
:root {
  color-scheme: light dark;
  --bg: #f0f0ee;
  --surface: #fafaf9;
  --text: #161616;
  --muted: #5c5c58;
  --line: #d4d4d0;
  --rule: #161616;
  --accent: #b3261e;
  --hover: #e6e6e3;
  --cinemark: #b3261e;
  --cinepolis: #1f4f96;
  --cinestar: #8a6a12;
  --uvk: #5e3485;
  --cinerama: #17705f;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1b1b1b;
    --text: #ececea;
    --muted: #a3a39e;
    --line: #333331;
    --rule: #ececea;
    --accent: #f26b5b;
    --hover: #252524;
    --cinemark: #f26b4f;
    --cinepolis: #7ea6ec;
    --cinestar: #d9b453;
    --uvk: #b993dd;
    --cinerama: #5cc4ae;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(100% - 32px, 980px);
  margin: 0 auto;
}

a { color: var(--accent); text-underline-offset: 2px; }

button, input, select { font: inherit; color: inherit; }
a, button, input, select, label, summary { touch-action: manipulation; }
h1, h2, h3 { text-wrap: balance; }

.saltar { position: absolute; left: 8px; top: -60px; z-index: 9; padding: 12px 16px; background: var(--rule); color: var(--bg); font-weight: 700; }
.saltar:focus { top: 8px; }

/* ---------- cabecera: como el titular de una cartelera impresa ---------- */

.top { padding: 28px 0 0; }

.top .wrap {
  padding-bottom: 14px;
  border-bottom: 3px double var(--rule);
}

.top h1, .top .brand {
  margin: 0;
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 800;
  font-stretch: 72%;
  line-height: 0.95;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.top .brand a { color: inherit; text-decoration: none; }

.sub { margin: 8px 0 0; max-width: 60ch; color: var(--muted); }

/* ---------- filtros ---------- */

.filters {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px;
  padding: 12px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.dates, .chains {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.dates::-webkit-scrollbar, .chains::-webkit-scrollbar { display: none; }

/* Fechas: pestañas subrayadas. */
.dates { gap: 18px; border-bottom: 1px solid var(--line); }
.dates[hidden] { display: none; }

.dates .chip {
  flex: none;
  min-height: 44px;
  padding: 10px 0 8px;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.dates .chip:hover { color: var(--text); }
.dates .chip[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--accent); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 12px 0 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.field.grow { flex: 1 1 240px; }

select, input[type="search"] {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 16px;
  letter-spacing: normal;
  text-transform: none;
}

select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search { display: flex; }
.search input { flex: 1; min-width: 0; border-radius: 4px 0 0 4px; }

.search button {
  padding: 0 18px;
  border: 1px solid var(--rule);
  border-radius: 0 4px 4px 0;
  background: var(--rule);
  color: var(--bg);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}

.search button:hover { background: var(--accent); border-color: var(--accent); }

/* Ver por: control segmentado. */
.toggle {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

.toggle button {
  min-height: 44px;
  padding: 6px 14px;
  border: 0;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  white-space: nowrap;
}

.toggle button + button { border-left: 1px solid var(--rule); }
.toggle button[aria-pressed="true"] { background: var(--rule); color: var(--bg); }

/* Cadenas: casilla de color + nombre. */
.chains { gap: 16px; }

.chains .chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chains .chip::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid var(--c);
  border-radius: 2px;
  background: var(--c);
}

.chains .chip[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.chains .chip[aria-pressed="false"]::before { background: none; }

/* ---------- resultados ---------- */

.status {
  margin: 18px 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status.error { color: var(--accent); }

.results { display: grid; }

.card { border-bottom: 1px solid var(--line); }

.card summary {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
}

.card summary::-webkit-details-marker { display: none; }
.card summary:hover h2 { color: var(--accent); }
.card summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.poster {
  flex: none;
  width: 72px;
  height: 106px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--hover);
}

/* Sin afiche: franja de película en vez de un ícono. */
.poster.placeholder {
  background:
    repeating-linear-gradient(to bottom, var(--line) 0 6px, transparent 6px 12px) left / 6px 100% no-repeat,
    repeating-linear-gradient(to bottom, var(--line) 0 6px, transparent 6px 12px) right / 6px 100% no-repeat,
    var(--hover);
}

.card-info { min-width: 0; flex: 1; }

.card-info h2 {
  margin: 0 0 2px;
  font-size: 21px;
  font-weight: 700;
  font-stretch: 85%;
  line-height: 1.15;
}

.card-info p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.count { font-size: 14px; margin-top: 2px !important; }

/* Flecha que indica que la tarjeta se abre. */
.card > summary .card-info h2::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-4px) rotate(45deg);
  opacity: 0.45;
}

@media (prefers-reduced-motion: no-preference) {
  .card > summary .card-info h2::after { transition: transform 0.15s; }
}

.card[open] > summary .card-info h2::after { transform: translateY(-1px) rotate(225deg); }

.badges { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; }

.badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--c, var(--muted));
}

.chain-cinemark { --c: var(--cinemark); }
.chain-cinepolis { --c: var(--cinepolis); }
.chain-cinestar { --c: var(--cinestar); }
.chain-uvk { --c: var(--uvk); }
.chain-cinerama { --c: var(--cinerama); }

.card-body { padding: 0 0 14px 88px; }

.venue { padding: 12px 0; border-top: 1px dashed var(--line); }
.venue:first-child { border-top: 0; padding-top: 0; }
.venue-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.venue-name { font-weight: 600; }

.times { display: flex; flex-wrap: wrap; gap: 6px; }

/* Horarios: como boletos. */
.time {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 62px;
  min-height: 44px;
  justify-content: center;
  padding: 5px 10px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.time strong { font-size: 16px; font-weight: 700; }
a.time:hover { background: var(--rule); border-color: var(--rule); color: var(--bg); }
a.time:hover small { color: inherit; }
.time small { color: var(--muted); font-size: 11px; font-weight: 600; }
.time.late { border-style: dashed; }

.cineplanet { display: inline-block; margin-top: 4px; padding: 12px 0; font-size: 14px; }

.empty { padding: 48px 0; text-align: center; color: var(--muted); }

/* ---------- vista "Próximas" ---------- */

.card.next { display: flex; gap: 16px; padding: 16px 0; }
.card.next .poster { width: 60px; height: 88px; }
.card.next .venue-head { margin-bottom: 8px; }
.card.next h2 { margin: 0; font-size: 18px; }

.next-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--accent);
  color: var(--text);
  text-decoration: none;
}

a.next-main:hover .next-movie { color: var(--accent); }
.next-when { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }

.next-when strong {
  font-size: 26px;
  font-weight: 800;
  font-stretch: 80%;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.next-until { color: var(--accent); font-weight: 700; font-size: 14px; }
.next-movie { font-weight: 600; font-size: 17px; }

.next-more {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin-top: 10px;
  font-size: 14px;
}

.next-more-item { color: var(--text); text-decoration: none; }
.next-more-item strong { font-variant-numeric: tabular-nums; }
a.next-more-item:hover { color: var(--accent); }
.next-more-item small { color: var(--muted); }

/* ---------- texto de presentación (legible sin JS) ---------- */

.about {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  max-width: 68ch;
  font-size: 15px;
  color: var(--muted);
}

.about h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.about p { margin: 0 0 8px; }

/* ---------- pie ---------- */

.foot {
  margin-top: 32px;
  padding: 18px 0 40px;
  border-top: 3px double var(--rule);
  color: var(--muted);
  font-size: 13px;
}

.sources { margin-bottom: 8px; }

/* Botón "Contacto": lleva a toca.pe/#contacto (correo de contacto). */
.contacto-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.contacto-btn:hover { background: var(--rule); color: var(--bg); }

/* ---------- páginas por película y por cine (paginas/generar.py) ---------- */

.migas { margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.migas a { display: inline-flex; align-items: center; min-height: 44px; }
.ficha { display: flex; gap: 20px; align-items: flex-start; padding: 8px 0 18px; border-bottom: 1px solid var(--line); }
.ficha-afiche { width: 160px; height: auto; aspect-ratio: 160 / 236; object-fit: cover; border-radius: 3px; flex: none; }
.ficha h1, .pagina-h1 { margin: 0 0 6px; font-size: clamp(28px, 5vw, 40px); font-weight: 800; font-stretch: 80%; line-height: 1.05; }
.ficha p { margin: 0 0 6px; }
.pagina-h2 { font-size: 20px; font-stretch: 85%; margin: 24px 0 8px; }
.funciones .dates { margin-bottom: 4px; }
.pagina-ciudad { margin: 10px 0 4px; max-width: 260px; }
.pagina-funciones { display: grid; }
.pagina-funciones a.venue-name { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); }
.pagina-lista { margin: 0 0 8px; padding-left: 18px; }
.pagina-lista li { margin: 4px 0; }
.indice { list-style: none; padding: 0; columns: 2 260px; }
.indice a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
@media (max-width: 520px) {
  .ficha { gap: 14px; }
  .ficha-afiche { width: 104px; }
}

.legal h1 { font-size: 28px; font-stretch: 80%; }
.legal h2 { font-size: 18px; margin-top: 24px; }

/* En el celular los filtros no quedan fijos (taparían media pantalla) y
   ciudad + "ver por" comparten fila. */
@media (max-width: 700px) {
  .filters { position: static; }
  .row { gap: 10px; }
  .field:first-child { flex: 1 1 140px; }
  .field.grow { order: 3; flex-basis: 100%; }
}

@media (max-width: 520px) {
  .top { padding-top: 18px; }
  .sub { font-size: 14px; }
  .poster { width: 58px; height: 86px; }
  .card summary, .card.next { gap: 12px; }
  .card-info h2 { font-size: 18px; }
  .card-body { padding-left: 0; }
  .toggle button { padding: 6px 10px; }
}
