/* Rural 2026 · La Rioja — sistema visual compartido. Movil primero: 14 personas con el
   telefono en una mano y un vaso en la otra, asi que todo grande y de alto contraste. */

:root {
  color-scheme: dark;

  --wine-900: #1a0d12;
  --wine-800: #24121a;
  --wine-700: #331823;
  --wine-600: #45202e;

  --bg: var(--wine-900);
  --surface: #241520;
  --surface-2: #2f1b28;
  --surface-3: #3b2333;
  --line: #4a2c3c;
  --line-soft: #3a2130;

  --text: #f6ecec;
  --muted: #c0a3ad;
  --faint: #8d7280;

  --gold: #e8b04b;
  --gold-dim: #b0822f;
  --grape: #a855f7;
  --win: #22c55e;
  --hot: #e5484d;
  --cool: #3b82f6;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --pad: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.3);

  --font: 'Outfit', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Outfit', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(168, 85, 247, 0.16), transparent 62%),
    radial-gradient(900px 520px at 92% 4%, rgba(232, 176, 75, 0.13), transparent 60%),
    linear-gradient(180deg, var(--wine-800) 0%, var(--wine-900) 55%, #140a0e 100%);
  background-attachment: fixed;
  padding-bottom: 96px;
}

/* ---------- tipografia ---------- */

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .4em; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 4.6vw, 1.6rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--gold); text-decoration: none; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.up { text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; font-weight: 700; color: var(--faint); }

/* ---------- layout ---------- */

.wrap { max-width: 680px; margin: 0 auto; padding: 0 var(--pad); }
.wrap-wide { max-width: 1100px; margin: 0 auto; padding: 0 var(--pad); }
.stack > * + * { margin-top: 14px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.row-wrap { display: flex; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.hidden { display: none !important; }

/* ---------- cabecera ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad);
  background: rgba(26, 13, 18, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .brand { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.topbar .brand span { color: var(--gold); }
.back { color: var(--muted); font-size: 1.5rem; line-height: 1; padding: 4px 8px; margin-left: -8px; border-radius: var(--r-sm); }
.back:active { background: var(--surface-2); }

.hero { padding: 26px var(--pad) 18px; text-align: center; }
.hero .kicker { font-family: var(--font-display); color: var(--gold); font-weight: 600; letter-spacing: .16em; text-transform: uppercase; font-size: .74rem; }
.hero h1 { margin: 8px 0 6px; }

/* ---------- tarjetas ---------- */

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: var(--pad);
  box-shadow: var(--shadow-sm);
}
/* Una tarjeta que es enlace tiene que ser bloque: si se queda en `inline`, el navegador
   parte su borde y su fondo en trozos por cada linea de texto. */
a.card { display: block; color: inherit; }
.card-flat { background: var(--surface); box-shadow: none; }
.card-gold { border-color: var(--gold-dim); box-shadow: 0 0 0 1px rgba(232, 176, 75, .18), var(--shadow-sm); }
.card-tight { padding: 12px; }
.card h2, .card h3 { margin-top: 0; }

/* ---------- botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 13px 20px;
  font: inherit; font-weight: 650; font-size: 1rem;
  color: #2a1206;
  background: linear-gradient(180deg, #f0bf63, var(--gold));
  border: 0; border-radius: var(--r-pill);
  cursor: pointer; text-align: center;
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
  box-shadow: 0 4px 14px rgba(232, 176, 75, .22);
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 60px; font-size: 1.1rem; padding: 16px 26px; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: .88rem; }
.btn-ghost {
  color: var(--text); background: var(--surface-3);
  border: 1px solid var(--line); box-shadow: none;
}
.btn-outline { color: var(--gold); background: transparent; border: 1px solid var(--gold-dim); box-shadow: none; }
.btn-danger { color: #fff; background: linear-gradient(180deg, #ef5a5f, var(--hot)); box-shadow: none; }
.btn-grape { color: #fff; background: linear-gradient(180deg, #b975f9, var(--grape)); box-shadow: none; }

/* ---------- formularios ---------- */

label.field { display: block; }
label.field > .up { display: block; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 14px 15px;
  font: inherit; color: var(--text);
  background: var(--wine-700);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  appearance: none;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-dim); outline-offset: 1px; border-color: var(--gold-dim); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 84px; resize: vertical; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

/* ---------- avatares ---------- */

.av {
  --s: 44px;
  width: var(--s); height: var(--s); flex: 0 0 var(--s);
  border-radius: 50%; object-fit: cover;
  background: var(--surface-3);
  border: 2px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: var(--muted);
  font-size: calc(var(--s) * .38);
  overflow: hidden; text-transform: uppercase;
}
.av-sm { --s: 32px; }
.av-lg { --s: 68px; }
.av-xl { --s: 104px; }
.av-team { border-color: var(--team, var(--line)); box-shadow: 0 0 0 2px rgba(0,0,0,.4) inset; }

/* ---------- chips / badges ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line);
  font-size: .8rem; font-weight: 600; color: var(--muted);
}
.chip-gold { color: #2a1206; background: var(--gold); border-color: var(--gold); }
.chip-win { color: #06210f; background: var(--win); border-color: var(--win); }
.chip-hot { color: #fff; background: var(--hot); border-color: var(--hot); }
.chip-team { color: #fff; background: var(--team, var(--surface-3)); border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--win); flex: 0 0 9px; }
.dot-off { background: var(--faint); }
.pts { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- listas ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.list > li:last-child { border-bottom: 0; }
.rank {
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  width: 26px; flex: 0 0 26px; text-align: center; color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.rank-1 { color: var(--gold); } .rank-2 { color: #cbd5e1; } .rank-3 { color: #d08a52; }

/* ---------- barra de progreso / votos ---------- */

.bar { height: 8px; border-radius: var(--r-pill); background: var(--wine-700); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); border-radius: inherit; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar-win > i { background: linear-gradient(90deg, #15803d, var(--win)); }

/* ---------- barra inferior de navegacion ---------- */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(20, 10, 14, .93);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-soft);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; color: var(--faint); font-size: .68rem; font-weight: 600;
  border-radius: var(--r-sm);
}
.tabbar a .ic { font-size: 1.28rem; line-height: 1; }
.tabbar a.on { color: var(--gold); }

/* ---------- avisos ---------- */

.toast-host { position: fixed; left: 0; right: 0; bottom: 92px; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 var(--pad); }
.toast {
  max-width: 460px; padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-weight: 600; font-size: .92rem;
  animation: toast-in .22s ease both;
}
.toast-err { background: #4a1a1e; border-color: #7a2b30; }
.toast-ok { background: #14351f; border-color: #1f5c34; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }

.empty { padding: 30px 16px; text-align: center; color: var(--faint); }
.empty .ic { font-size: 2.4rem; display: block; margin-bottom: 8px; opacity: .7; }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.divider { height: 1px; background: var(--line-soft); border: 0; margin: 18px 0; }

/* ---------- utilidades de animacion ---------- */

.pop { animation: pop .32s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.86); opacity: 0; } }
.shake { animation: shake .4s ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- modo tele: encajar la pagina entera en la pantalla ----------
   Las vistas `?pantalla` se ven en la tele del salon, donde no hay nadie con el raton
   para hacer scroll: si el contenido no cabe, la gente se queda sin ver a los ultimos
   del ranking. Se escala todo a la vez hasta que entre (lo calcula app.js). */

html[data-fit] { overflow: hidden; height: 100%; }
html[data-fit] > body {
  transform: scale(var(--fit, 1));
  transform-origin: top left;
  width: calc(100% / var(--fit, 1));
  padding-bottom: 0;
}
