/* Concurso de Calaveritas Literarias 2026 — página pública */

:root {
  --noche: #22093A;
  --noche-2: #2F0F4E;
  --noche-3: #3F1766;
  --rosa: #E2307A;
  --cempa: #F79A1E;
  --cempa-claro: #FFB547;
  --cempa-sombra: #A9580A;
  --lila: #9A4FD0;
  --vela: #FFD45C;
  --hueso: #FBF3E4;
  --hueso-2: #D8C9E6;
  --error: #FFB4C8;
  --linea: rgba(251, 243, 228, .16);
  --linea-fuerte: rgba(251, 243, 228, .38);
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --sans: 'Alegreya Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--noche);
  color: var(--hueso);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]), html.lector-abierto body { overflow: hidden; }

a { color: var(--hueso); text-underline-offset: .18em; }
:focus-visible { outline: 3px solid var(--cempa); outline-offset: 3px; }
img { max-width: 100%; }

.defs { position: absolute; }
.visualmente-oculto {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Portada ---------- */

.portada { position: relative; text-align: center; padding-bottom: 3.5rem; }

.picado {
  position: relative;
  display: flex;
  justify-content: center;
  gap: clamp(4px, .8vw, 10px);
  overflow: hidden;
  padding-top: 8px;
  height: clamp(86px, 13.5vw, 140px);
}
.picado::before {
  content: '';
  position: absolute;
  inset: 7px 0 auto;
  height: 2px;
  background: var(--linea-fuerte);
}
.bandera {
  flex: 0 0 auto;
  width: clamp(54px, 8.6vw, 98px);
  height: auto;
  transform-origin: 50% 0;
  filter: drop-shadow(0 8px 6px rgba(8, 0, 16, .45));
  animation: mecer 4.6s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -.83s);
}
.bandera:nth-child(3n) { animation-duration: 5.4s; }
.bandera:nth-child(4n+1) { animation-duration: 3.9s; }
@keyframes mecer {
  from { transform: rotate(-2.4deg) skewX(-1deg); }
  to   { transform: rotate(2.4deg) skewX(1deg); }
}

.portada-texto { max-width: 46rem; margin: 0 auto; padding: 1.75rem 1.25rem 0; }

.emisor { margin: 0 0 .9rem; color: var(--hueso-2); font-weight: 500; font-size: 1.05rem; }

h1 { margin: 0; font-family: var(--serif); line-height: .84; }
.h1-grande {
  display: block;
  font-weight: 900;
  font-size: clamp(3.3rem, 15.5vw, 9.6rem);
  letter-spacing: -.025em;
  color: var(--cempa);
  text-shadow: .045em .05em 0 var(--rosa);
}
.h1-sub {
  display: block;
  margin-top: .4em;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.6rem, 6vw, 3.1rem);
  letter-spacing: .01em;
}

.entrada {
  max-width: 33rem;
  margin: 1.6rem auto 0;
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.55;
}

.estado {
  display: inline-block;
  margin: 2rem auto 0;
  padding: .9rem 1.4rem 1rem;
  background: var(--noche-2);
  border: 1px solid var(--linea);
  border-radius: 12px;
}
.estado-frase { margin: 0; color: var(--hueso-2); }
.cuenta {
  margin: .2rem 0 0;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--vela);
  font-variant-numeric: tabular-nums;
}
.cuenta.sin-dias [data-u="d"], .cuenta.sin-dias [data-l="d"] { display: none; }

/* ---------- Contenido ---------- */

main { max-width: 74rem; margin: 0 auto; padding: 0 1.25rem 4.5rem; }

.mi-voto {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.25rem;
  margin: 0 0 2.5rem;
  padding: 1rem 1.25rem;
  background: var(--rosa);
  color: var(--hueso);
  border-radius: 12px;
}
.mi-voto p { margin: 0; font-size: 1.1rem; }
.mi-voto strong { font-family: var(--serif); }
.mi-voto .btn-sec { width: auto; margin: 0; border-color: rgba(251, 243, 228, .7); }

.obras-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--linea);
}
.obras-barra h2 { flex: 1 1 auto; margin: 0; font-family: var(--serif); font-weight: 900; font-size: 2rem; line-height: 1.1; }
.obras-total { margin: 0; color: var(--hueso-2); font-size: .95rem; }
.buscar { order: 3; flex: 1 1 100%; }
.buscar input {
  width: 100%;
  padding: .7rem 1.1rem;
  font: inherit;
  color: var(--hueso);
  background: var(--noche-2);
  border: 1px solid var(--linea-fuerte);
  border-radius: 999px;
}
.buscar input::placeholder { color: var(--hueso-2); opacity: .8; }
@media (min-width: 720px) {
  .buscar { order: 0; flex: 0 1 19rem; }
}

.rejilla {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2.25rem 1.25rem;
}
@media (min-width: 640px) {
  .rejilla { grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 3rem 2.25rem; }
}

.obra { --giro: -.8deg; }
.obra:nth-child(2n) { --giro: .7deg; }
.obra:nth-child(3n) { --giro: -.25deg; }
.obra:nth-child(5n) { --giro: 1.1deg; }

.obra-abrir {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.obra-abrir:focus-visible { outline: none; }

.hoja {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--hueso);
  border-radius: 3px;
  box-shadow: 0 16px 22px -14px rgba(5, 0, 12, .95), 0 2px 0 rgba(0, 0, 0, .25);
  transform: rotate(var(--giro));
  transition: transform .18s ease, box-shadow .18s ease;
}
.hoja img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.hoja-texto {
  display: block;
  padding: 1rem;
  font-family: var(--serif);
  font-size: .95rem;
  line-height: 1.45;
  color: var(--noche);
  white-space: pre-line;
}
.obra-abrir:hover .hoja,
.obra-abrir:focus-visible .hoja { transform: rotate(0) translateY(-4px); }
.obra-abrir:focus-visible .hoja { outline: 3px solid var(--cempa); outline-offset: 5px; }

.marca-voto {
  display: none;
  position: absolute;
  top: .7rem;
  left: 0;
  padding: .28rem .7rem .3rem .6rem;
  font-weight: 800;
  font-size: .88rem;
  color: var(--hueso);
  background: var(--rosa);
  border-radius: 0 6px 6px 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
}
.obra.votada .marca-voto { display: block; }
.obra.votada .hoja { outline: 3px solid var(--rosa); outline-offset: 4px; }

.obra-titulo {
  display: block;
  margin-top: 1.05rem;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
}
.obra-autor { display: block; margin-top: .25rem; color: var(--hueso-2); font-size: .97rem; line-height: 1.35; }
.obra-votos { display: block; margin-top: .3rem; color: var(--vela); font-weight: 700; font-size: .92rem; }

.vacio {
  padding: 3rem 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--hueso-2);
}

/* ---------- Resultados ---------- */

.resultados { margin: 0 0 3.5rem; }
.resultados h2 { margin: 0 0 1.25rem; font-family: var(--serif); font-weight: 900; font-size: 2rem; }
.podio { list-style: none; margin: 0; padding: 0; }
.podio-fila {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  align-items: baseline;
  gap: .25rem .75rem;
  padding: .9rem 0;
  border-bottom: 1px solid var(--linea);
}
.podio-pos { font-family: var(--serif); font-weight: 900; font-size: 1.6rem; color: var(--hueso-2); }
.premio .podio-pos { color: var(--cempa); }
.podio-obra { min-width: 0; }
.podio-autor { display: block; color: var(--hueso-2); font-size: .95rem; }
.podio-votos { font-weight: 800; color: var(--vela); font-variant-numeric: tabular-nums; white-space: nowrap; }
.podio-barra { grid-column: 2 / -1; height: 5px; border-radius: 3px; background: var(--linea); position: relative; overflow: hidden; }
.podio-barra::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--cempa); border-radius: 3px; }

.enlace {
  padding: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--hueso);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--linea-fuerte);
  text-underline-offset: .2em;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- Pie ---------- */

.pie {
  max-width: 74rem;
  margin: 0 auto;
  padding: 3rem 1.25rem calc(3rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--linea);
}
.pie-bases { display: grid; gap: 1.75rem; }
@media (min-width: 820px) { .pie-bases { grid-template-columns: repeat(3, 1fr); gap: 2.5rem; } }
.pie h2 { margin: 0 0 .4rem; font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--cempa); }
.pie p { margin: 0; color: var(--hueso-2); max-width: 62ch; }
.pie-privacidad { margin-top: 2.5rem !important; font-size: .92rem; }
.pie-legal { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: 1rem !important; font-size: .92rem; }

/* ---------- Botones ---------- */

.btn-votar {
  display: block;
  width: 100%;
  padding: .95rem 1.25rem;
  font-family: var(--sans);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--noche);
  background: var(--cempa);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--cempa-sombra);
  cursor: pointer;
}
.btn-votar:hover { background: var(--cempa-claro); }
.btn-votar:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cempa-sombra); }
.btn-votar:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-votar:focus-visible { outline-color: var(--hueso); }

.btn-sec {
  display: block;
  width: 100%;
  margin-top: .6rem;
  padding: .7rem 1.1rem;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--hueso);
  background: transparent;
  border: 1px solid var(--linea-fuerte);
  border-radius: 10px;
  cursor: pointer;
}
.btn-sec:hover { background: rgba(251, 243, 228, .08); }

/* ---------- Lector ---------- */

dialog.lector {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  color: var(--hueso);
  background: transparent;
  border: 0;
}
dialog.lector:not([open]) { display: none; }
dialog.lector::backdrop { background: rgba(10, 2, 18, .84); }
html.lector-abierto dialog.lector[open] { position: fixed; inset: 0; z-index: 50; background: rgba(10, 2, 18, .84); }

.lector-caja {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--noche-2);
}
.lector-cerrar {
  position: fixed;
  z-index: 3;
  top: calc(.75rem + env(safe-area-inset-top));
  right: .75rem;
  padding: .5rem 1rem;
  font: 700 1rem var(--sans);
  color: var(--hueso);
  background: rgba(34, 9, 58, .9);
  border: 1px solid var(--linea-fuerte);
  border-radius: 999px;
  cursor: pointer;
}

.lector-info { order: 1; padding: calc(4rem + env(safe-area-inset-top)) 1.25rem 1.25rem; }
.lector-hoja { order: 2; padding: .5rem 1.25rem 1.5rem; text-align: center; }
.voto { order: 3; }

.lector-hoja img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  background: var(--hueso);
  border-radius: 3px;
  box-shadow: 0 18px 30px -18px rgba(0, 0, 0, .9);
}
.lector-ayuda { margin: .7rem 0 0; color: var(--hueso-2); font-size: .88rem; }

.lector-folio { margin: 0 0 .5rem; color: var(--hueso-2); font-size: .92rem; }
#lector-titulo {
  margin: 0;
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(1.85rem, 6vw, 2.7rem);
  line-height: 1.05;
}
.lector-autor { margin: .6rem 0 0; font-size: 1.12rem; }
.lector-area { margin: .1rem 0 0; color: var(--hueso-2); font-size: .97rem; }
.lector-texto {
  margin: 1.5rem 0 0;
  padding-left: 1rem;
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.6;
  white-space: pre-line;
  border-left: 3px solid var(--rosa);
}

.voto {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--noche-2);
  border-top: 1px solid var(--linea);
  box-shadow: 0 -12px 24px -12px rgba(5, 0, 12, .8);
}
.voto-aviso { margin: 0 0 .75rem; color: var(--hueso-2); font-size: .97rem; }
.ts { display: flex; justify-content: center; margin: 0 0 .75rem; }
.ts:empty { display: none; }
.voto-listo { margin: 0 0 .5rem; font-family: var(--serif); font-weight: 700; font-size: 1.3rem; color: var(--vela); }
.voto-info { margin: 0 0 .25rem; font-size: 1.05rem; }
.voto-error { margin: .65rem 0 0; color: var(--error); font-size: .97rem; }
.voto-error:empty { display: none; }
.voto-error .enlace { font-family: var(--sans); font-size: 1rem; color: var(--error); }

@media (min-width: 900px) {
  .lector-caja {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    width: min(1120px, 94vw);
    height: min(92vh, 920px);
    margin: 4vh auto;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .9);
  }
  .lector-cerrar { position: absolute; top: 1rem; right: 1rem; }
  .lector-hoja { grid-column: 1; grid-row: 1 / span 2; overflow-y: auto; padding: 2rem; background: var(--noche); }
  .lector-info { grid-column: 2; grid-row: 1; overflow-y: auto; padding: 3.5rem 2.25rem 1.5rem; }
  .voto { grid-column: 2; grid-row: 2; position: static; padding: 1.25rem 2.25rem 1.75rem; box-shadow: none; }
  .lector.sin-hoja .lector-caja { grid-template-columns: 1fr; width: min(680px, 94vw); }
  .lector.sin-hoja .lector-info, .lector.sin-hoja .voto { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bandera { animation: none; }
  .hoja { transition: none; }
}
