/* ==========================================================================
   Votación de Disfraces 2026 - tema Halloween compartido (app.css)
   Mobile-first. Sin estilos inline (CSP: style-src 'self').
   Rutas relativas a /assets/css/ -> ../img, ../fonts
   ========================================================================== */

/* ---- Fuentes (OFL) - latin ---------------------------------------------- */
@font-face {
  font-family: 'Creepster';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/creepster-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Nunito es una fuente variable: un solo archivo cubre 400 y 800 */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Variables ---------------------------------------------------------- */
:root {
  --hw-bg: #0d0a14;
  --hw-surface: #1a1325;
  --hw-orange: #ff7a1a;
  --hw-purple: #8b5cf6;
  --hw-green: #7cff6b;
  --hw-text: #f5efe6;
  --hw-muted: #b8a9c9;
  --font-display: 'Creepster', 'Chalkboard SE', 'Comic Sans MS', cursive;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* auxiliares (no forman parte del contrato, pero estables) */
  --hw-surface-2: #241a33;
  --hw-border: rgba(139, 92, 246, 0.45);
  --hw-radius: 18px;
  --hw-radius-sm: 12px;
  --hw-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --hw-glow-orange: 0 0 18px rgba(255, 122, 26, 0.55);
  --hw-glow-purple: 0 0 18px rgba(139, 92, 246, 0.6);
  --hw-glow-green: 0 0 18px rgba(124, 255, 107, 0.55);
  --hw-gutter: 16px;
}

/* ---- Base --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--hw-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--hw-text);
  background-color: var(--hw-bg);
  background-image:
    linear-gradient(180deg, rgba(13, 10, 20, 0.35) 0%, rgba(13, 10, 20, 0.85) 100%),
    url('../img/bg-night.webp');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  margin: 0 0 0.5em;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.1;
  color: var(--hw-orange);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 122, 26, 0.35);
}
h1,
h2,
h3 { text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 9vw, 3.2rem); }
h2 { font-size: clamp(1.6rem, 6.5vw, 2.2rem); }
h3 { font-size: 1.4rem; color: var(--hw-green); text-shadow: none; }

p { margin: 0 0 1em; text-wrap: pretty; }
.hw-center p,
.hw-header p { text-wrap: balance; }

a {
  color: var(--hw-green);
  text-underline-offset: 3px;
}
a:hover { color: #b6ffac; }

:focus-visible {
  outline: 3px solid var(--hw-green);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: var(--hw-purple);
  color: #fff;
}

.hw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hw-muted { color: var(--hw-muted); }
.hw-center { text-align: center; }
.hw-hidden { display: none !important; }

/* ---- Página ------------------------------------------------------------- */
.hw-page {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px var(--hw-gutter) 56px;
  overflow-x: clip;
}

/* telaraña decorativa en la esquina */
.hw-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 110px;
  height: 110px;
  background: url('../img/web-corner.webp') top left / contain no-repeat;
  opacity: 0.85;
  pointer-events: none;
}

.hw-logo {
  display: block;
  width: min(86%, 420px);
  height: auto;
  margin: 8px auto 18px;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.55));
}

.hw-header {
  text-align: center;
  margin-bottom: 20px;
}
.hw-header p { color: var(--hw-muted); margin-bottom: 0; }

/* ---- Tarjeta ------------------------------------------------------------ */
.hw-card {
  background: linear-gradient(160deg, var(--hw-surface) 0%, var(--hw-surface-2) 100%);
  border: 1px solid var(--hw-border);
  border-radius: var(--hw-radius);
  padding: 20px;
  margin: 0 0 20px;
  box-shadow: var(--hw-shadow);
}
.hw-card > :last-child { margin-bottom: 0; }

/* ---- Botones ------------------------------------------------------------ */
.hw-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  min-width: 48px;
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: var(--hw-text);
  background: var(--hw-surface-2);
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.hw-btn:hover { color: var(--hw-text); }

.hw-btn--primary {
  color: #1a0d00;
  background: linear-gradient(180deg, #ff9a45 0%, var(--hw-orange) 100%);
  border-color: #ffb36b;
  box-shadow: 0 6px 0 #a64a00, var(--hw-glow-orange);
}
.hw-btn--primary:hover { color: #1a0d00; filter: brightness(1.08); }
.hw-btn--primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #a64a00, var(--hw-glow-orange); }

.hw-btn--ghost {
  color: var(--hw-text);
  background: transparent;
  border-color: var(--hw-purple);
}
.hw-btn--ghost:hover { background: rgba(139, 92, 246, 0.2); }
.hw-btn--ghost:active { background: rgba(139, 92, 246, 0.35); }

.hw-btn--block { display: flex; width: 100%; }

.hw-btn[disabled],
.hw-btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.4);
}

/* ---- Íconos (img/icons.svg + img/cat/*.webp; ver img/ICONS.md) ----------- */
/* Trazo de Lucide: se hereda dentro del <use>; el color sigue al texto. */
.hw-i {
  display: inline-block;
  flex: none;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.hw-i--sm { width: 0.95em; height: 0.95em; vertical-align: -0.15em; }
.hw-i--lg { width: 1.5em; height: 1.5em; vertical-align: -0.35em; }
.hw-i--xl { width: 2.25em; height: 2.25em; vertical-align: middle; stroke-width: 1.75; }
.hw-i--2xl { width: 3.5em; height: 3.5em; vertical-align: middle; stroke-width: 1.5; }
.hw-i--orange { color: var(--hw-orange); }
.hw-i--purple { color: #a78bfa; } /* morado aclarado: contraste AA sobre --hw-bg */
.hw-i--green { color: var(--hw-green); }
.hw-i--muted { color: var(--hw-muted); }

/* En botones: un poco más grande y con trazo más grueso para ir con el texto 800. */
.hw-btn .hw-i { width: 1.25em; height: 1.25em; vertical-align: 0; stroke-width: 2.4; }
.hw-btn--icon { gap: 0; padding: 0; width: 48px; border-radius: 50%; }
.hw-btn--icon .hw-i { width: 1.4em; height: 1.4em; }

/* Encabezados en Creepster: el ícono no hereda la sombra de texto, la lleva como filtro. */
h1 .hw-i,
h2 .hw-i,
h3 .hw-i { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5)); }

/* Arte de categoría: ilustración a color; halo morado para que el gato o el sombrero negro no se pierdan. */
.hw-cat-icon {
  display: inline-block;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.55)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
  -webkit-user-drag: none;
  user-select: none;
}
.hw-cat-icon--sm { width: 1.75rem; height: 1.75rem; }
.hw-cat-icon--lg { width: 4rem; height: 4rem; }
.hw-cat-icon--xl { width: 7rem; height: 7rem; }

/* ---- Formularios -------------------------------------------------------- */
.hw-field { display: block; margin-bottom: 16px; }
.hw-label { display: block; margin-bottom: 6px; font-weight: 800; color: var(--hw-text); }
.hw-input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  color: var(--hw-text);
  background: #120d1c;
  border: 2px solid var(--hw-border);
  border-radius: var(--hw-radius-sm);
}
.hw-input::placeholder { color: var(--hw-muted); opacity: 1; }
.hw-input:focus-visible { border-color: var(--hw-green); outline: 3px solid var(--hw-green); outline-offset: 2px; box-shadow: var(--hw-glow-green); }

.hw-error {
  margin: 0 0 12px;
  padding: 10px 14px;
  color: #ffd6d6;
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid #f87171;
  border-radius: var(--hw-radius-sm);
}

/* ---- Pasos -------------------------------------------------------------- */
.hw-steps {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  counter-reset: hw-step;
}
.hw-steps > li {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 800;
  text-align: center;
  color: var(--hw-muted);
  counter-increment: hw-step;
}
.hw-steps > li::before {
  content: counter(hw-step);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--hw-text);
  background: var(--hw-surface-2);
  border: 2px solid var(--hw-border);
  border-radius: 50%;
}
.hw-steps > li.is-active,
.hw-steps > li[aria-current='step'] { color: var(--hw-text); }
.hw-steps > li.is-active::before,
.hw-steps > li[aria-current='step']::before {
  color: #1a0d00;
  background: var(--hw-orange);
  border-color: #ffb36b;
  box-shadow: var(--hw-glow-orange);
}
.hw-steps > li.is-done::before {
  content: '\2713';
  color: #0d2a08;
  background: var(--hw-green);
  border-color: #b6ffac;
}

/* ---- Rejilla de fotos --------------------------------------------------- */
.hw-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.hw-photo {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  color: var(--hw-text);
  background: var(--hw-surface);
  border: 3px solid var(--hw-border);
  border-radius: var(--hw-radius);
  cursor: pointer;
  font: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hw-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hw-photo:hover { border-color: var(--hw-purple); }

.hw-photo__caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 24px 10px 8px;
  font-weight: 800;
  font-size: 0.95rem;
  background: linear-gradient(180deg, rgba(13, 10, 20, 0) 0%, rgba(13, 10, 20, 0.92) 100%);
}

.hw-photo--selected {
  border-color: var(--hw-green);
  box-shadow: 0 0 0 3px rgba(124, 255, 107, 0.35), var(--hw-glow-green);
}
.hw-photo--selected::after {
  content: '\2713';
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #0d2a08;
  background: var(--hw-green);
  border-radius: 50%;
}

/* número del disfraz */
.hw-badge-num {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1;
  color: #1a0d00;
  background: var(--hw-orange);
  border: 2px solid #ffd0a3;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

/* ---- Toast -------------------------------------------------------------- */
.hw-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: min(92vw, 420px);
  padding: 14px 20px;
  font-weight: 800;
  text-align: center;
  color: var(--hw-text);
  background: var(--hw-surface-2);
  border: 2px solid var(--hw-purple);
  border-radius: var(--hw-radius);
  box-shadow: var(--hw-shadow), var(--hw-glow-purple);
  transform: translate(-50%, 24px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.hw-toast.is-visible,
.hw-toast[data-show='true'] {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}
.hw-toast--ok { border-color: var(--hw-green); box-shadow: var(--hw-shadow), var(--hw-glow-green); }
.hw-toast--error { border-color: #f87171; }

/* ---- Estados ------------------------------------------------------------ */
.is-loading {
  position: relative;
  pointer-events: none;
  cursor: progress;
  opacity: 0.8;
}
.hw-btn.is-loading { color: transparent; }
.hw-btn.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(26, 13, 0, 0.35);
  border-top-color: #1a0d00;
  border-radius: 50%;
}
.hw-btn--ghost.is-loading::after {
  border-color: rgba(245, 239, 230, 0.35);
  border-top-color: var(--hw-text);
}

.is-voted { cursor: default; }
.hw-photo.is-voted { border-color: var(--hw-green); }
.hw-btn.is-voted {
  color: #0d2a08;
  background: var(--hw-green);
  border-color: #b6ffac;
  box-shadow: var(--hw-glow-green);
  pointer-events: none;
}

/* ---- Decoración --------------------------------------------------------- */
.hw-pumpkin {
  display: block;
  width: 96px;
  height: auto;
  margin: 0 auto 8px;
  filter: drop-shadow(0 0 14px rgba(255, 122, 26, 0.55));
}
.hw-ghost { display: block; width: 88px; height: auto; margin: 0 auto 8px; }
.hw-trophy { display: block; width: 120px; height: auto; margin: 0 auto 8px; }

.hw-bats {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.hw-bat {
  position: absolute;
  top: 12%;
  left: -64px;
  width: 48px;
  height: 36px;
  background: url('../img/bat.webp') center / contain no-repeat;
  opacity: 0.8;
}
.hw-bat:nth-child(2) { top: 28%; width: 36px; height: 27px; opacity: 0.6; }
.hw-bat:nth-child(3) { top: 6%;  width: 28px; height: 21px; opacity: 0.5; }
.hw-page { z-index: 1; }

.hw-winner-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 16px;
  background: url('../img/frame-winner.webp') center / 100% 100% no-repeat;
}
.hw-winner-frame img {
  width: 57%;
  height: 57%;
  object-fit: cover;
  border-radius: 8px;
}

/* ---- Tablet / escritorio ------------------------------------------------ */
@media (min-width: 560px) {
  .hw-page { padding-top: 32px; }
  .hw-photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .hw-btn--block { display: inline-flex; width: auto; min-width: 260px; }
}
@media (min-width: 900px) {
  .hw-page--wide { max-width: 960px; }
  .hw-page--wide .hw-photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---- Movimiento: solo si el usuario no pide reducirlo ------------------- */
@media (prefers-reduced-motion: no-preference) {
  .hw-btn,
  .hw-photo,
  .hw-input { transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease, background-color 0.2s ease; }
  .hw-photo:hover { transform: translateY(-3px) rotate(-0.6deg); }
  .hw-photo--selected { animation: hw-pop 0.35s ease-out; }

  .hw-toast { transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s; }

  .hw-btn.is-loading::after { animation: hw-spin 0.8s linear infinite; }
  .hw-i--spin { animation: hw-spin 0.9s linear infinite; }

  .hw-pumpkin { animation: hw-glow 3.2s ease-in-out infinite; }
  .hw-ghost { animation: hw-bob 4s ease-in-out infinite; }
  .hw-trophy { animation: hw-bob 3s ease-in-out infinite; }
  .hw-btn--primary:not(.is-voted):not(:active):not([disabled]):not(.is-loading) { animation: hw-btn-glow 2.8s ease-in-out infinite; }

  .hw-bat { animation: hw-fly 18s linear infinite; }
  .hw-bat:nth-child(2) { animation-duration: 26s; animation-delay: -9s; }
  .hw-bat:nth-child(3) { animation-duration: 32s; animation-delay: -20s; }
}

@keyframes hw-spin { to { transform: rotate(360deg); } }
@keyframes hw-pop {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes hw-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 122, 26, 0.4)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 22px rgba(255, 122, 26, 0.9)); transform: scale(1.04); }
}
@keyframes hw-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes hw-btn-glow {
  0%, 100% { box-shadow: 0 6px 0 #a64a00, 0 0 10px rgba(255, 122, 26, 0.35); }
  50% { box-shadow: 0 6px 0 #a64a00, 0 0 24px rgba(255, 122, 26, 0.75); }
}
@keyframes hw-fly {
  0% { transform: translate(0, 0) rotate(-4deg); }
  25% { transform: translate(30vw, 40px) rotate(4deg); }
  50% { transform: translate(60vw, -10px) rotate(-4deg); }
  75% { transform: translate(90vw, 50px) rotate(4deg); }
  100% { transform: translate(calc(100vw + 128px), 10px) rotate(-4deg); }
}
