/* =========================================================
   Centinelas del Reino — Calendario de retos
   Depende de decoraciones.css (tokens y garabatos).
   ========================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--c-fondo);
  color: var(--c-texto);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.oculto { display: none !important; }

/* ---------------------------------------------------------
   Barra superior
   --------------------------------------------------------- */

.barra {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(8, 8, 15, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1c1c26;
}

.barra__marca {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  color: var(--c-texto);
  text-decoration: none;
  margin-right: auto;
}

.estrellas {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(250, 201, 3, .12);
  border: 1px solid rgba(250, 201, 3, .35);
  color: var(--c-amarillo);
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
}

.estrellas svg { width: 16px; height: 16px; flex: none; }

.boton-texto {
  background: none;
  border: 0;
  color: var(--c-texto-suave);
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: 8px;
}

.boton-texto:hover { color: var(--c-texto); background: #16161f; }

/* ---------------------------------------------------------
   Cabecera de la página
   --------------------------------------------------------- */

.intro {
  position: relative;
  text-align: center;
  padding: clamp(44px, 8vh, 84px) clamp(20px, 5vw, 48px) clamp(28px, 5vh, 48px);
}

.intro__etiqueta {
  font-family: var(--font-heading);
  color: var(--c-lima);
  font-size: clamp(.95rem, 2vw, 1.15rem);
  margin: 0 0 10px;
}

.intro__titulo {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1.04;
  margin: 0;
  text-wrap: balance;
}

.intro__titulo .subrayado {
  width: min(58%, 300px);
  margin-inline: auto;
  color: var(--c-morado-claro);
}

.intro__texto {
  margin: clamp(16px, 3vh, 26px) auto 0;
  max-width: 52ch;
  color: var(--c-texto-suave);
  text-wrap: pretty;
}

/* ---------------------------------------------------------
   Rejilla de retos
   --------------------------------------------------------- */

.retos-seccion { padding: 0 clamp(16px, 4vw, 48px) clamp(50px, 8vh, 90px); }

.retos {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 1120px;
  display: grid;
  gap: clamp(14px, 2vw, 22px);
  grid-template-columns: repeat(5, 1fr);
}

.reto {
  perspective: 1200px;      /* necesario para que el giro se vea en 3D */
  aspect-ratio: 3 / 4;
}

.reto__giro {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.22, 1, .36, 1);
}

.reto--volteada .reto__giro { transform: rotateY(180deg); }

.reto__cara {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  border-radius: clamp(14px, 2vw, 20px);
  border: 2px solid #0A0A05;
  /* Oculta la cara que queda de espaldas */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* --- Cara frontal --- */

.reto__frente {
  background: linear-gradient(160deg, #1a1430 0%, #120f22 60%, #0e0c18 100%);
  color: var(--c-texto);
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
}

.reto--activa .reto__frente {
  border-color: var(--c-lima);
  box-shadow: 0 0 0 0 rgba(200, 248, 0, .4);
}

.reto--activa .reto__frente:hover,
.reto--activa .reto__frente:focus-visible {
  transform: translateY(-6px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, .5);
}

.reto__frente:focus-visible {
  outline: 3px solid #FFFFFF;
  outline-offset: 3px;
}

/* Va con la palabra "Día" delante a propósito: en la tipografía de
   marcador el 1 es un trazo simple y solo no se lee como número. */
.reto__dia {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  line-height: 1;
  color: var(--c-lima);
}

.reto__icono {
  width: clamp(38px, 5vw, 56px);
  height: clamp(38px, 5vw, 56px);
}

.reto__titulo {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(.82rem, 1.5vw, 1rem);
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

.reto__pista {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--c-texto-suave);
}

/* --- Estado bloqueado --- */

.reto--bloqueada { cursor: not-allowed; }

.reto--bloqueada .reto__frente {
  opacity: .38;                 /* el "toque de opacidad" del bloqueo */
  filter: saturate(.35);
  cursor: not-allowed;
  border-color: #2a2a38;
}

.reto--bloqueada .reto__dia { color: var(--c-texto-suave); }

/* --- Marca de completado --- */

.reto__hecho {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-lima);
  color: #0A0A05;
}

.reto__hecho svg { width: 15px; height: 15px; }

/* --- Cara trasera: la imagen del día ---
   Deja de ser decorado: cuando el reto está respondido, esta es la
   cara que queda a la vista, así que es un botón para poder volver
   a abrir la respuesta. */

.reto__dorso {
  transform: rotateY(180deg);
  padding: 0;
  background: #0e0c18;
  border-color: var(--c-lima);
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: block;          /* anula el flex de .reto__cara */
}

.reto__dorso img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reto__dorso:focus-visible {
  outline: 3px solid #FFFFFF;
  outline-offset: 3px;
}

/* Franja inferior: deja claro que hay algo que ver, y que se puede tocar */
.reto__dorso-pie {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 6px;
  background: linear-gradient(to top, rgba(8, 8, 15, .94) 55%, transparent);
  color: var(--c-lima);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(.64rem, 1.3vw, .76rem);
  letter-spacing: .02em;
}

.reto__dorso-pie svg { width: 13px; height: 13px; flex: none; }

.reto--activa .reto__dorso:hover img { opacity: .82; }
.reto__dorso img { transition: opacity .25s ease; }

/* ---------------------------------------------------------
   Diálogo del reto
   --------------------------------------------------------- */

.dialogo {
  width: min(560px, calc(100vw - 32px));
  max-height: min(88svh, 860px);
  padding: 0;
  border: 2px solid #0A0A05;
  border-radius: clamp(16px, 3vw, 24px);
  background: var(--c-superficie);
  color: var(--c-texto);
  overflow: auto;
  overscroll-behavior: contain;
}

.dialogo::backdrop {
  background: rgba(4, 4, 8, .78);
  backdrop-filter: blur(4px);
}

/* Entra girando: la misma idea de "voltear la tarjeta" */
@keyframes dialogo-entra {
  from { opacity: 0; transform: perspective(1200px) rotateY(-24deg) scale(.94); }
  to   { opacity: 1; transform: perspective(1200px) rotateY(0) scale(1); }
}

.dialogo[open] { animation: dialogo-entra .5s cubic-bezier(.22, 1, .36, 1); }

.dialogo__cerrar {
  position: sticky;
  top: 10px;
  float: right;
  margin: 10px 10px 0 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(8, 8, 15, .7);
  color: #fff;
  font-size: 1.2rem; line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.dialogo__cerrar:hover { background: rgba(8, 8, 15, .95); }

.dialogo__imagen {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #0e0c18;
}

.dialogo__cuerpo { padding: clamp(18px, 4vw, 30px); }

.dialogo__dia {
  font-family: var(--font-heading);
  color: var(--c-lima);
  font-size: .95rem;
  margin: 0 0 4px;
}

.dialogo__titulo {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1.1;
  margin: 0 0 14px;
}

.dialogo__cita {
  margin: 0 0 20px;
  padding-left: 14px;
  border-left: 3px solid var(--c-morado-claro);
  font-style: italic;
  color: var(--c-texto-suave);
  font-size: .95rem;
}

.dialogo__cita cite {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-family: var(--font-heading);
  color: var(--c-morado-claro);
  font-size: .85rem;
}

/* --- Formulario --- */

.campo { margin-top: 20px; }

.campo__etiqueta {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: .95rem;
  text-wrap: pretty;
}

.campo__ayuda {
  display: block;
  margin-top: 6px;
  font-size: .8rem;
  color: var(--c-texto-suave);
}

textarea, input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #2a2a38;
  background: #0d0d15;
  color: var(--c-texto);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
}

textarea { min-height: 130px; resize: vertical; }

textarea:focus, input:focus {
  outline: none;
  border-color: var(--c-lima);
}

.contador {
  display: block;
  margin-top: 6px;
  text-align: right;
  font-size: .78rem;
  color: var(--c-texto-suave);
  font-variant-numeric: tabular-nums;
}

/* Aviso de publicación: tiene que verse ANTES de guardar */
.aviso {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(168, 85, 247, .1);
  border: 1px solid rgba(168, 85, 247, .35);
  font-size: .85rem;
  color: #D9C8FB;
  line-height: 1.55;
}

.aviso svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }

.acciones {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 28px;
  border-radius: 999px;
  border: 2px solid #0A0A05;
  background: var(--c-lima);
  color: #0A0A05;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .98rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.boton:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0,0,0,.45); }
.boton:disabled { opacity: .5; cursor: not-allowed; }
.boton:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.boton--fantasma {
  background: transparent;
  color: var(--c-texto);
  border-color: #2a2a38;
}

.mensaje { font-size: .88rem; margin: 0; }
.mensaje--ok    { color: var(--c-lima); }
.mensaje--error { color: #FF8A73; }

/* ---------------------------------------------------------
   Muro: Tus amigos los centinelas
   --------------------------------------------------------- */

.muro {
  position: relative;
  padding: clamp(50px, 9vh, 100px) clamp(16px, 4vw, 48px) clamp(70px, 10vh, 120px);
  background: var(--c-superficie);
  border-top: 1px solid #1c1c26;
}

.muro__contenedor { max-width: 900px; margin: 0 auto; }

.muro__cabecera { text-align: center; margin-bottom: clamp(30px, 5vh, 52px); }

.muro__titulo {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(1.7rem, 5vw, 2.8rem);
  line-height: 1.06;
  margin: 0;
  text-wrap: balance;
}

.muro__titulo .subrayado {
  width: min(52%, 260px);
  margin-inline: auto;
  color: var(--c-lima);
}

.muro__intro {
  margin: 16px auto 0;
  max-width: 50ch;
  color: var(--c-texto-suave);
  font-size: .95rem;
}

/* --- Bloque de un día --- */

.dia {
  margin-top: clamp(26px, 4vh, 44px);
  border-top: 1px solid #22222e;
  padding-top: clamp(20px, 3vh, 30px);
}

.dia:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }

.dia__cabecera {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.dia__numero {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: var(--c-lima);
}

.dia__titulo {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
  color: var(--c-texto);
}

.dia__total {
  margin-left: auto;
  font-size: .8rem;
  color: var(--c-texto-suave);
  font-variant-numeric: tabular-nums;
}

.dia__lista {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

/* --- Una respuesta --- */

.respuesta {
  position: relative;
  padding: 16px 18px 16px 42px;
  border-radius: 14px;
  background: #14141d;
  border: 1px solid #22222e;
}

.respuesta::before {
  content: "“";
  position: absolute;
  left: 14px;
  top: 6px;
  font-family: var(--font-heading);
  font-size: 1.8rem;
  line-height: 1;
  color: var(--c-morado-claro);
}

.respuesta__texto {
  margin: 0;
  /* pre-wrap conserva los saltos de línea del participante
     sin necesidad de interpretar ningún formato */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #D6D8E0;
  font-size: .95rem;
  line-height: 1.7;
}

.respuesta__pie {
  display: block;
  margin-top: 10px;
  font-size: .75rem;
  color: var(--c-texto-suave);
}

.dia__vacio {
  margin: 0;
  padding: 22px;
  border-radius: 14px;
  border: 1px dashed #2a2a38;
  text-align: center;
  color: var(--c-texto-suave);
  font-size: .9rem;
}

/* ---------------------------------------------------------
   Carga y errores
   --------------------------------------------------------- */

.cargando {
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--c-texto-suave);
}

.girador {
  width: 34px; height: 34px;
  border: 3px solid #2a2a38;
  border-top-color: var(--c-lima);
  border-radius: 50%;
  animation: girar-carga .8s linear infinite;
}

@keyframes girar-carga { to { transform: rotate(360deg); } }

.panel-error {
  max-width: 620px;
  margin: 60px auto;
  padding: 26px 30px;
  border-radius: 16px;
  border: 1px solid #4a2a2a;
  background: #1a1013;
}

.panel-error h2 { font-family: var(--font-heading); font-weight: 400; margin: 0 0 10px; }
.panel-error p  { color: var(--c-texto-suave); margin: 0 0 8px; }
.panel-error code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: #241419;
  font-size: .85rem;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 900px) {
  .retos { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
  .retos { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .barra { gap: 10px; }
  .barra__marca { font-size: .95rem; }
  .estrellas { padding: 6px 12px; font-size: .82rem; }
  .acciones .boton { width: 100%; }
}

/* ---------------------------------------------------------
   Movimiento reducido
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .reto__giro,
  .reto__frente,
  .boton { transition: none; }
  .dialogo[open] { animation: none; }
  .girador { animation-duration: 2s; }
}
