/* ---------- Temas: claro / oscuro / sistema ----------
   "sistema" = color-scheme: light dark (sigue al dispositivo).
   js/theme.js pone data-tema="claro|oscuro|sistema" en <html>. */
:root {
  color-scheme: light dark;
  --color-tema: #2e7d32;
  --texto-tema: #fff;

  --bg: light-dark(#f3f4f8, #0f1115);
  --card: light-dark(#ffffff, #1a1d24);
  --text: light-dark(#14171c, #f3f4f6);
  --muted: light-dark(#59616f, #9ca3af);
  --borde: light-dark(#e1e4eb, #2a2f3a);
  --track: light-dark(#e6e9f0, #2a2f3a);
  --input-bg: light-dark(#f7f8fb, #111318);
  --input-borde: light-dark(#c9cfda, #2e3440);
  --btn-sec: light-dark(#e4e7ee, #2d323e);
  --btn-sec-text: light-dark(#1f2430, #f3f4f6);
  --btn-off: light-dark(#e1e4eb, #374151);
  --btn-off-text: light-dark(#7d8696, #9ca3af);
  --sombra: light-dark(0 1px 3px rgba(20, 24, 40, .08), 0 1px 3px rgba(0, 0, 0, .3));
  --aviso-bg: light-dark(#fff6dd, #2b2412);
  --aviso-borde: light-dark(#e6c15a, #6b5516);
  --salvado: #eab308;
  --peligro: #b91c1c;
}
:root[data-tema="claro"] { color-scheme: light; }
:root[data-tema="oscuro"] { color-scheme: dark; }

/* Navegadores sin light-dark(): se queda en oscuro */
@supports not (color: light-dark(white, black)) {
  :root {
    --bg: #0f1115; --card: #1a1d24; --text: #f3f4f6; --muted: #9ca3af; --borde: #2a2f3a;
    --track: #2a2f3a; --input-bg: #111318; --input-borde: #2e3440; --btn-sec: #2d323e;
    --btn-sec-text: #f3f4f6; --btn-off: #374151; --btn-off-text: #9ca3af;
    --sombra: 0 1px 3px rgba(0, 0, 0, .3); --aviso-bg: #2b2412; --aviso-borde: #6b5516;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body { background: var(--bg); color: var(--text); padding: 16px; display: flex; justify-content: center; min-height: 100vh; }
.contenedor { width: 100%; max-width: 540px; padding-bottom: 32px; }

:focus-visible { outline: 3px solid var(--color-tema); outline-offset: 2px; }

/* ---------- Barra superior: "En vivo" + selector de tema ---------- */
.barra-superior { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.pill-vivo { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.punto-vivo { width: 9px; height: 9px; border-radius: 50%; background: #e11d48; box-shadow: 0 0 0 0 rgba(225, 29, 72, .6); animation: latido 1.8s ease-out infinite; }
@keyframes latido { 70% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); } 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); } }

.selector-tema { display: inline-flex; background: var(--card); border: 1px solid var(--borde); border-radius: 99px; padding: 3px; gap: 2px; }
.selector-tema button { display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 600; padding: 7px 10px; min-height: 34px; border-radius: 99px; cursor: pointer; }
.selector-tema button svg { width: 15px; height: 15px; flex: none; }
.selector-tema button:hover { color: var(--text); }
.selector-tema button[aria-pressed="true"] { background: var(--color-tema); color: var(--texto-tema); }
@media (max-width: 380px) { .selector-tema button span { display: none; } .selector-tema button { padding: 7px 11px; } }

/* ---------- Encabezado con logo ---------- */
header { text-align: center; margin-bottom: 16px; padding: 18px 16px 16px; background: var(--card); border-radius: 18px; border-top: 4px solid var(--color-tema); box-shadow: var(--sombra); }
.logo-reality { display: block; width: min(100%, 360px); max-height: 190px; height: auto; object-fit: contain; margin: 0 auto 10px; }
.logo-reality[hidden] { display: none; }
.badge-reality { display: inline-block; background: var(--color-tema); color: var(--texto-tema); font-size: .8rem; font-weight: 700; padding: 4px 12px; border-radius: 99px; margin-bottom: 8px; }
h1 { font-size: 1.35rem; line-height: 1.3; text-wrap: balance; }
.meta-votos { color: var(--muted); font-size: .88rem; margin-top: 8px; }
.meta-votos strong { color: var(--text); font-variant-numeric: tabular-nums; }

.auth-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; font-size: .9rem; border: 1px solid var(--borde); }

/* ---------- Botones ---------- */
.btn { background: var(--color-tema); color: var(--texto-tema); border: none; padding: 10px 16px; min-height: 44px; border-radius: 10px; font-weight: 600; font-size: .95rem; cursor: pointer; transition: opacity .2s, transform .1s; }
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.98); }
.btn:disabled { background: var(--btn-off); color: var(--btn-off-text); cursor: not-allowed; transform: none; }
.btn-sec { background: var(--btn-sec); color: var(--btn-sec-text); }
.btn-danger { background: var(--peligro); color: #fff; }
.btn-ancho { width: 100%; margin-top: 6px; }

.aviso { background: var(--aviso-bg); border: 1px solid var(--aviso-borde); border-radius: 12px; padding: 10px 14px; font-size: .85rem; line-height: 1.4; margin-bottom: 14px; }
.aviso[hidden] { display: none; }

/* ---------- Nominados ---------- */
.tarjeta-nominado { background: var(--card); border-radius: 16px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--borde); box-shadow: var(--sombra); position: relative; overflow: hidden; }
.tarjeta-nominado.salvado { opacity: .78; border-color: var(--salvado); }
.tarjeta-nominado.tu-voto { border-color: var(--color-tema); box-shadow: 0 0 0 1px var(--color-tema); }
.tag-salvado, .tag-tuvoto { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.tag-salvado { background: var(--salvado); color: #000; }
.tag-tuvoto { background: var(--color-tema); color: var(--texto-tema); }

.fila-superior { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar { width: 68px; height: 68px; border-radius: 14px; object-fit: cover; background: var(--btn-sec); flex: none; }
.info { flex: 1; min-width: 0; }
.nombre { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; overflow-wrap: anywhere; }
.porcentaje { margin-top: 3px; display: flex; align-items: baseline; gap: 8px; }
.pct { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.votos-n { font-size: .82rem; color: var(--muted); }

.barra-fondo { width: 100%; height: 10px; background: var(--track); border-radius: 99px; overflow: hidden; }
.barra-relleno { height: 100%; background: var(--color-tema); width: 0%; border-radius: 99px; transition: width .5s ease; }

.pie { text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.5; margin-top: 16px; }

/* Cargando */
.skeleton .bloque { background: var(--track); border-radius: 10px; animation: pulso 1.4s ease-in-out infinite; }
.skeleton .av { width: 68px; height: 68px; border-radius: 14px; flex: none; }
.skeleton .l1 { height: 16px; width: 55%; margin-bottom: 9px; }
.skeleton .l2 { height: 12px; width: 35%; }
.skeleton .bar { height: 10px; border-radius: 99px; }
@keyframes pulso { 50% { opacity: .45; } }

/* ---------- Avisos emergentes (toast) ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; z-index: 50; }
.toast { background: var(--card); color: var(--text); border: 1px solid var(--borde); border-left: 5px solid var(--color-tema); border-radius: 12px; padding: 12px 16px; font-size: .92rem; max-width: 460px; width: 100%; box-shadow: 0 8px 28px rgba(0, 0, 0, .28); animation: entra .25s ease-out; }
.toast.error { border-left-color: var(--peligro); }
@keyframes entra { from { transform: translateY(12px); opacity: 0; } }

/* ---------- Confirmación de voto ---------- */
dialog { border: none; border-radius: 20px; background: var(--card); color: var(--text); width: calc(100% - 32px); max-width: 360px; padding: 22px; margin: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
dialog[open] { animation: entra .2s ease-out; }
.dlg-foto { display: block; width: 104px; height: 104px; border-radius: 20px; object-fit: cover; margin: 0 auto 14px; background: var(--btn-sec); }
dialog h2 { font-size: 1.2rem; text-align: center; line-height: 1.3; text-wrap: balance; }
.dlg-nota { text-align: center; color: var(--muted); font-size: .88rem; margin: 8px 0 18px; }
.dlg-botones { display: flex; gap: 10px; }
.dlg-botones .btn { flex: 1; }

/* ---------- Admin ---------- */
label { font-size: .88rem; color: var(--muted); }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
input { background: var(--input-bg); border: 1px solid var(--input-borde); color: var(--text); padding: 10px; min-height: 44px; border-radius: 8px; font-size: .95rem; }
.fila-admin { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.enlace-publico { display: inline-block; margin-top: 8px; color: var(--muted); font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
