/* Plataforma de votaciones — estilos base.
   Los colores y tipografías vienen de cada concurso (variables en base.html). */
:root {
  --primary: #b3122e;
  --secondary: #1f6f4a;
  --bg: #fbf7f2;
  --text: #1d1d1f;
  --font-heading: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --surface: #ffffff;
  --muted: color-mix(in srgb, var(--text) 62%, var(--bg));
  --line: color-mix(in srgb, var(--text) 12%, var(--bg));
  --primary-soft: color-mix(in srgb, var(--primary) 10%, var(--surface));
  --secondary-soft: color-mix(in srgb, var(--secondary) 12%, var(--surface));
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .06);
  --wrap: 1180px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-heading); line-height: 1.15; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3.2rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* Barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; line-height: 1.2; min-width: 0; }
.brand img { height: 44px; width: auto; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: .95rem; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang a, .lang span { padding: 6px 10px; font-size: .8rem; font-weight: 600; text-decoration: none; color: var(--muted); text-transform: uppercase; }
.lang span { background: var(--text); color: var(--surface); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .nav .nav-link { display: none; }
  .nav.open .nav-link { display: block; }
  .nav.open { position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); flex-direction: column; align-items: stretch; padding: 8px 20px 16px; border-bottom: 1px solid var(--line); }
  .menu-btn { display: inline-flex; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; cursor: pointer; color: var(--text); }
  .nav { margin-left: 0; }
}

/* Cabecera */
.hero { position: relative; color: #fff; background: var(--primary); overflow: hidden; }
.hero.has-image { background: #222 var(--hero-image) center/cover no-repeat; }
.hero.has-image::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / .15), rgb(0 0 0 / .6)); }
.hero .wrap { position: relative; padding-top: clamp(48px, 9vw, 110px); padding-bottom: clamp(36px, 6vw, 72px); }
.hero h1 { color: #fff; max-width: 24ch; text-wrap: balance; }
.hero .tagline { font-size: clamp(1.05rem, 2vw, 1.3rem); max-width: 50ch; opacity: .95; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; background: rgb(255 255 255 / .16); backdrop-filter: blur(6px); border: 1px solid rgb(255 255 255 / .3); padding: 6px 14px; border-radius: 999px; font-size: .9rem; font-weight: 600; margin-top: 8px; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #5ee08a; box-shadow: 0 0 0 4px rgb(94 224 138 / .25); }
.status-pill.closed .dot, .status-pill.upcoming .dot { background: #ffd166; box-shadow: none; }

.intro { padding: 36px 0 8px; max-width: 72ch; font-size: 1.05rem; }

/* Pestañas de categorías */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 24px 0 8px; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 9px 18px; font: 600 .95rem var(--font-body); cursor: pointer; text-decoration: none; }
.tab[aria-selected="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.tab .count { opacity: .6; font-weight: 500; margin-left: 4px; }

.category { padding: 24px 0 48px; scroll-margin-top: 80px; }
.category-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.category-head p { color: var(--muted); margin: 0; }
.badge-voted { display: inline-flex; align-items: center; gap: 6px; background: var(--secondary-soft); color: var(--secondary); padding: 5px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; }

/* Tarjetas */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s ease, box-shadow .15s ease; position: relative; }
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(0 0 0 / .06), 0 16px 32px rgb(0 0 0 / .1); }
.card .photo { aspect-ratio: 4 / 3; background: var(--line); overflow: hidden; }
.card .photo img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card .addr { color: var(--muted); font-size: .92rem; margin: 0; }
.card .summary { font-size: .95rem; margin: 0; }
.card .actions { margin-top: auto; padding-top: 10px; display: flex; gap: 8px; position: relative; z-index: 1; }
.card .num { position: absolute; top: 12px; left: 12px; background: rgb(255 255 255 / .92); color: var(--text); font-weight: 700; font-size: .85rem; padding: 3px 10px; border-radius: 999px; }
.card .my-vote { position: absolute; top: 12px; right: 12px; background: var(--secondary); color: #fff; font-weight: 600; font-size: .8rem; padding: 4px 10px; border-radius: 999px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 11px 22px; font: 600 1rem var(--font-body); cursor: pointer; text-decoration: none; background: var(--primary); color: #fff; transition: filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 8px 16px; font-size: .92rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Ficha */
.crumbs { padding: 20px 0 0; font-size: .92rem; }
.crumbs a { color: var(--muted); }
.detail { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; padding: 20px 0 64px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; gap: 24px; } }
.main-photo { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--line); }
.main-photo img { width: 100%; max-height: 72vh; object-fit: cover; cursor: zoom-in; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: var(--line); }
.thumbs button[aria-current="true"] { border-color: var(--primary); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.side { position: sticky; top: 88px; }
.side .cat { color: var(--secondary); font-weight: 600; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.meta { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 6px; color: var(--muted); }
.meta a { color: inherit; }
.vote-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 20px 0; }
.vote-box p { margin: 0 0 12px; color: var(--muted); font-size: .95rem; }
.prose { max-width: 70ch; }
.prose img { border-radius: 10px; }

/* Formularios */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 4vw, 36px); max-width: 620px; margin: 32px auto 64px; }
.voting-for { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; background: var(--primary-soft); margin-bottom: 22px; }
.voting-for img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; }
.voting-for small { display: block; color: var(--muted); }
.voting-for strong { font-family: var(--font-heading); font-size: 1.15rem; }
.field { margin-bottom: 18px; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--primary); }
.field .help { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.field .errorlist, .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: #b00020; font-size: .9rem; font-weight: 500; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
}
.has-error input, .has-error select, .has-error textarea { border-color: #b00020; }
.field ul.radio, .field div[id] > div { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.field label > input[type=radio] { margin-right: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400 !important; }
.check input { margin-top: 5px; width: 18px; height: 18px; flex: none; accent-color: var(--primary); }
.code-input { font-size: 2rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; padding: 14px !important; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.alert.error { background: #fdecee; color: #8a0018; }
.alert.warning { background: #fff6dd; color: #6b4b00; }
.alert.info { background: var(--secondary-soft); color: var(--secondary); }
.muted { color: var(--muted); }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.turnstile { margin: 8px 0 18px; min-height: 65px; }

/* Gracias */
.big-check { width: 72px; height: 72px; border-radius: 50%; background: var(--secondary); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; font-size: 2.2rem; }

/* Resultados */
.ranking { list-style: none; padding: 0; margin: 0 0 40px; display: grid; gap: 10px; }
.ranking li { display: grid; grid-template-columns: 44px 64px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.ranking .pos { font: 700 1.4rem var(--font-heading); text-align: center; color: var(--muted); }
.ranking li:nth-child(-n+3) .pos { color: var(--primary); }
.ranking img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; }
.ranking .votes { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgb(0 0 0 / .9); display: none; place-items: center; z-index: 100; padding: 20px; }
.lightbox.open { display: grid; }
.lightbox img { max-height: 92vh; max-width: 96vw; object-fit: contain; border-radius: 6px; }
.lightbox button { position: absolute; top: 14px; right: 16px; background: rgb(255 255 255 / .15); color: #fff; border: 0; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }

/* Pie */
.footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: .92rem; }
.footer .wrap { display: flex; gap: 24px; justify-content: space-between; flex-wrap: wrap; }
.footer a { color: inherit; }
.footer nav { display: flex; gap: 16px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
