/* ============================================================
   BASE.CSS — Estructura de toda la interfaz: pantallas, altar,
   grimorio, matraces (forma), banner PWA, modal de
   notificaciones, bloqueo de selección. Usa las variables
   definidas en temas.css, pero no define ningún color de tema.
   ============================================================ */

    * { box-sizing: border-box; }

  /* ============================================================
     FONDO — grid neo-brutalista, estático (sin animación, sin
     estrellas para el tema base). Capa propia detrás de todo
     (#fondo-animado, z-index:-1) para no pelearse con el layout
     del resto de la app. El nombre del id se queda igual para no
     tener que tocar el HTML que ya lo referencia.
     ============================================================ */
  #fondo-animado {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background-color: var(--fondo-base);
    background-image:
      linear-gradient(to right, var(--fondo-grid) 1px, transparent 1px),
      linear-gradient(to bottom, var(--fondo-grid) 1px, transparent 1px);
    background-size: 32px 32px;
  }

  body {
    margin: 0;
    font-family: 'Georgia', serif;
    color: var(--exterior-texto);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .app {
    max-width: 480px;
    width: 100%;
  }
  header {
    text-align: center;
    margin-bottom: 24px;
  }
  header h1 {
    font-size: 26px;
    margin: 0 0 4px;
    letter-spacing: 1.5px;
    font-weight: bold;
    line-height: 1.15;
    background: linear-gradient(180deg, #fff2a8 0%, #d4af37 45%, #aa7c11 70%, #fef1a9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.9)) drop-shadow(0px 0px 8px rgba(212,175,55,0.3));
  }
  header p {
    color: var(--exterior-titulo);
    font-size: 14px;
    font-weight: bold;
    margin: 0;
  }
  .setup {
    background: var(--modal-fondo);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
  }
  /* La pantalla de bienvenida (teaser) no necesita su propio fondo —
     ya tiene tarjetas propias adentro; con fondo compartido todo se
     fundía en un solo bloque oscuro. */
  #setup {
    background: transparent;
    padding: 0;
  }
  .setup p {
    margin: 0 0 12px;
    color: var(--modal-texto);
  }
  .setup button {
    background: #FF3BA4;
    color: #FEFEFE;
    font-family: 'Georgia', serif;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    margin: 4px;
  }
  .setup button:hover { opacity: 0.9; }
  .card {
    background: var(--diaria-fondo);
    border-radius: 16px;
    padding: 24px;
  }
  .card .fecha {
    color: var(--diaria-titulo);
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
  }
  .card .mensaje {
    font-size: 18px;
    line-height: 1.7;
    white-space: pre-line;
    color: var(--diaria-texto);
  }
  .aviso {
    background: rgba(212,175,55,0.15);
    border-left: 3px solid var(--diaria-titulo);
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: bold;
    color: var(--diaria-titulo);
  }
  .luna-imagen-placeholder {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--modal-texto);
    font-size: 12px;
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .luna-svg-chica {
    width: 70px;
    height: 70px;
    display: block;
    margin: 0 auto 14px;
  }
  .luna-svg-grande {
    width: 140px;
    height: 140px;
    display: block;
    margin: 0 auto 14px;
  }
  .vela-dia.apagada .vela-cuerpo {
    fill: var(--vela-apagada);
  }
  .vela-dia.apagada .vela-flama {
    display: none;
  }
  .luna-marco {
    background: var(--luna-fondo);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 12px;
  }
  .luna-nombre {
    color: var(--luna-titulo);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 8px;
  }
  .luna-energia {
    font-size: 14px;
    font-weight: bold;
    line-height: 1.7;
    margin: 0;
    white-space: pre-line;
    color: var(--luna-texto);
  }
  .luna-afirmacion {
    text-align: center;
    font-size: 13px;
    font-style: italic;
    color: var(--modal-acento);
    margin: 0 0 16px;
  }
  .separador-luna {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #FFEB3B, transparent);
    margin: 20px 0;
  }
  footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--exterior-texto);
  }
  footer button {
    background: none;
    border: 1px solid var(--exterior-texto);
    color: var(--exterior-texto);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
  }
  .hidden { display: none; }
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
  }
  .modal-overlay.hidden {
    display: none;
  }
  .modal-caja {
    background: var(--modal-fondo);
    border-radius: 16px;
    padding: 28px 24px;
    max-width: 380px;
    width: 100%;
    text-align: center;
  }
  .modal-caja .modal-icono-wrap {
    width: 48px;
    height: 48px;
    display: block;
    margin: 0 auto 16px;
    filter: drop-shadow(0 0 5px currentColor);
  }
  /* Máscara SVG reutilizable: para íconos propios (assets/iconos_insignias/)
     que necesitan cambiar de color por CSS (header, modal), a diferencia de
     los del Grimorio que van fijos y usan su propia regla. El color real lo
     define el elemento que la use (currentColor hereda de su contenedor). */
  .icono-svg-mask {
    display: block;
    width: 100%;
    height: 100%;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    background-color: transparent; /* solo se pinta cuando el JS asigna la máscara, ver aplicarIconoSvg */
  }
  .modal-caja .modal-nombre {
    color: var(--modal-titulo-secundario);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px;
  }
  .modal-caja .modal-mensaje {
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 20px;
    color: var(--modal-texto);
  }

  /* ============================================================
     MODAL — Configuración de notificaciones push
     ============================================================ */
  .config-notif-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
  }
  .config-notif-texto {
    text-align: left;
    font-size: 14px;
    color: var(--modal-texto);
    line-height: 1.5;
  }
  .config-notif-estado {
    font-size: 12px;
    margin: 8px 0 18px;
    color: var(--modal-acento);
  }
  .config-notif-estado.error {
    color: #FF6B6B;
  }
  .toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
  }
  .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
  }
  .toggle-switch .toggle-riel {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255,255,255,0.25);
    transition: 0.3s;
    border-radius: 26px;
  }
  .toggle-switch .toggle-riel::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #FEFEFE;
    transition: 0.3s;
    border-radius: 50%;
  }
  .toggle-switch input:checked + .toggle-riel {
    background-color: #3EDB00;
  }
  .toggle-switch input:checked + .toggle-riel::before {
    transform: translateX(20px);
  }
  .toggle-switch input:disabled + .toggle-riel {
    opacity: 0.5;
    cursor: not-allowed;
  }
  #config-notif-hora {
    background: rgba(255,255,255,0.08);
    color: var(--modal-texto);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 14px;
    color-scheme: dark;
  }
  #config-notif-hora option {
    background: #1a1220;
    color: #FEFEFE;
  }

  /* ============================================================
     ALTAR — librero (arco de piedra + repisas) + mesa de trabajo.
     El fondo (librero_y_mesa.webp) NO lleva cielo propio: donde
     no hay madera/piedra es transparente y se ve el fondo animado
     activo de la app por debajo.
     ============================================================ */
  #seccion-altar {
    justify-content: center;
    padding: 10px 0;
  }
  #seccion-altar:not(.hidden) {
    display: flex;
  }
  .altar-lienzo {
    position: relative;
    width: 95%;
    max-width: 480px;
    aspect-ratio: 1441 / 2578; /* proporción real del PNG/WEBP de fondo */
  }
  .altar-fondo-estructura {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none; /* el fondo no debe robar clics a los objetos */
  }

  /* Tótems: cuadrados, tamaño relativo a su proporción real en el
     diseño original (241px de tótem sobre 1441px de fondo) */
  .altar-totem-wrap {
    position: absolute;
    width: 16.7%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
  }
  .altar-totem-wrap img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
  }
  /* No obtenido: el objeto real, pero transparente — se reconoce
     qué es, sin verse activo */
  .altar-totem-wrap img.bloqueado,
  .altar-caldero-wrap img.bloqueado {
    opacity: 0.35;
  }
  .altar-totem-wrap img.obtenido,
  .altar-caldero-wrap img.obtenido {
    opacity: 1;
  }

  /* Tótem-libro (Grimorio): cuando está obtenido, además de verse
     a color, pulsa para invitar al toque — es el único tótem que
     funciona como enlace */
  .altar-totem-wrap.es-grimorio {
    cursor: pointer;
  }
  .altar-totem-wrap.es-grimorio img.obtenido {
    animation: pulsoGrimorio 2.2s ease-in-out infinite;
  }
  @keyframes pulsoGrimorio {
    0%, 100% { filter: drop-shadow(0 0 3px rgba(212,175,55,0.5)); }
    50% { filter: drop-shadow(0 0 12px rgba(212,175,55,0.95)); }
  }
  @keyframes pulsoCaldero {
    0%, 100% { filter: drop-shadow(0 0 2px rgba(212,175,55,0.4)); }
    50% { filter: drop-shadow(0 0 8px rgba(212,175,55,0.85)); }
  }

  /* Caldero del header: sin brillo ni clic hasta ganar la 1a insignia
     (día 7) — visible desde el día 1 para que se vea "crecer" el
     anillo de cooldown, pero no invita a tocarlo todavía. */
  #boton-altar.desbloqueado {
    cursor: pointer;
  }
  #boton-altar.desbloqueado #caldero-header-img {
    animation: pulsoCaldero 2.2s ease-in-out infinite;
  }

  /* Destello de una sola vez sobre el caldero del header (día 7) */
  .destello-caldero {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 15;
  }
  .destello-chispa {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #d4af37;
    box-shadow: 0 0 4px 1px rgba(212,175,55,0.9);
    opacity: 0;
    animation: chispaVolar 0.9s ease-out forwards;
  }
  @keyframes chispaVolar {
    0%   { opacity: 1; transform: translate(-50%, -50%) rotate(var(--angulo)) translateY(0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--angulo)) translateY(-26px) scale(0.4); }
  }

  /* Caldero: tamaño real calculado de las coordenadas (centro/arriba/abajo) */
  .altar-caldero-wrap {
    position: absolute;
    width: 32.6%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
  }
  .altar-caldero-wrap img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
  }

  /* Cooldown tallado en la panza del caldero: tamaño real de tus
     coordenadas (centro-cooldown / arriba-cooldown) = 17.03% */
  .altar-cooldown-wrap {
    position: absolute;
    width: 17.03%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }
  .altar-cooldown-wrap svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
  }

  /* Grids de matraces (SVG inline, 6 por fila).
     Ancho real: 683px sobre 1441px de fondo (dato de CorelDraw) */
  .altar-matraces-wrap {
    position: absolute;
    transform: translate(-50%, -50%);
  }
  .altar-matraces-wrap svg {
    width: 100%;
    height: 100%;
    display: block;
  }
  .matraz-vidrio { fill: var(--matraz-vidrio); opacity: 1; }
  .matraz-grupo {
    filter: drop-shadow(2px 3px 3px #3D3D3D);
  }
  .matraz-grupo.bloqueado {
    pointer-events: none;
    cursor: default;
  }
  .matraz-grupo.bloqueado [class^="matraz-liquido"] {
    opacity: 0.35;
    transition: opacity 0.3s ease;
  }
  .matraz-grupo.obtenido {
    cursor: pointer;
  }
  .matraz-grupo.obtenido [class^="matraz-liquido"] {
    opacity: 1;
    transition: opacity 0.3s ease;
  }
  .matraz-grupo.tinte-activo {
    filter: drop-shadow(2px 3px 3px #3D3D3D) drop-shadow(0 0 6px #d4af37);
  }
  .matraz-liquido-1 { fill: var(--tinte-1); }
  .matraz-liquido-2 { fill: var(--tinte-2); }
  .matraz-liquido-3 { fill: var(--tinte-3); }
  .matraz-liquido-4 { fill: var(--tinte-4); }
  .matraz-liquido-5 { fill: var(--tinte-5); }
  .matraz-liquido-6 { fill: var(--tinte-6); }
  .matraz-liquido-7 { fill: var(--tinte-7); }
  .matraz-liquido-8 { fill: var(--tinte-8); }
  .matraz-liquido-9 { fill: var(--tinte-9); }
  .matraz-liquido-10 { fill: var(--tinte-10); }
  .matraz-liquido-11 { fill: var(--tinte-11); }
  .matraz-liquido-12 { fill: var(--tinte-12); }
  .matraz-liquido-reset { fill: var(--tinte-reset); }
  /* Matraz aún no desbloqueado: vidrio y contenido, transparentes */
  .altar-matraces-wrap svg .bloqueado { opacity: 0.35; }

  /* ============================================================
     MODAL DE TÓTEM DESBLOQUEADO — forma banner/píldora (círculo +
     rectángulo redondeado fusionados), según el SVG de referencia
     de la diseñadora: 430x126, círculo r=58 a la izquierda.
     ============================================================ */
  .modal-totem-banner {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 430 / 126;
    background: var(--modal-fondo);
    border-radius: 999px;
    display: flex;
    align-items: center;
    padding-left: calc(29.3% + 14px); /* diámetro real del círculo (126/430) + espacio */
    padding-right: 5%;
    overflow: hidden;
  }
  .modal-totem-circulo {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--modal-fondo);
    border: 3px solid var(--modal-fondo);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .modal-totem-circulo img {
    width: 72%;
    height: 72%;
    object-fit: contain;
  }
  .modal-totem-textos {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }
  .modal-totem-nombre {
    color: var(--modal-titulo-secundario);
    font-weight: bold;
    font-size: clamp(13px, 4vw, 17px);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .modal-totem-mensaje {
    color: var(--modal-texto);
    font-weight: bold;
    font-size: clamp(10px, 2.6vw, 12px);
    line-height: 1.35;
    margin: 0;
    opacity: 0.92;
  }
  .modal-totem-rareza {
    position: absolute;
    top: 3%;
    right: 4%;
    background: #95143B;
    color: #ffffff;
    font-weight: bold;
    font-size: clamp(9px, 2.2vw, 11px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 14px;
    border-radius: 999px;
    white-space: nowrap;
  }

  /* ============================================================
     TEASER — vista previa fija para quien aún no inició sesión.
     Ventana con cortinas (deja ver que hay una luna, no cuál) +
     tarjetas con texto fijo + velas que se encienden en bucle.
     ============================================================ */
  .teaser-ventana {
    width: 40%;
    margin: 0 auto 16px auto;
    background-color: var(--fondo-base);
    background-image:
      linear-gradient(to right, var(--fondo-grid) 1px, transparent 1px),
      linear-gradient(to bottom, var(--fondo-grid) 1px, transparent 1px);
    background-size: 32px 32px;
    border-radius: 16px;
  }
  .teaser-velas {
    margin: 4px 0 8px;
  }
  .teaser-vela-real.apagada .vela-cuerpo { fill: var(--vela-apagada); }
  .teaser-vela-real.apagada .vela-flama { display: none; }

  /* ============================================================
     GRIMORIO — 52 insignias en 4 páginas de 13. Fondo tipo
     pergamino/cuero armado con CSS puro (mientras la diseñadora
     hace uno propio). Navegación: swipe en celular, flechas de
     teclado en PC, y puntos + numeral romano como indicador visual.
     ============================================================ */
  #seccion-grimorio {
    justify-content: center;
    padding: 20px 0;
  }
  #seccion-grimorio:not(.hidden) {
    display: flex;
  }
  .grimorio-lienzo {
    position: relative;
    width: 95%;
    max-width: 480px;
    aspect-ratio: 481 / 860; /* proporción real de pagina_grimorio.webp */
    touch-action: pan-y;
  }
  .grimorio-fondo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: -1; /* siempre hasta atrás; sin esto tapaba el grid de insignias */
    pointer-events: none; /* el fondo no debe robar clics a las insignias */
  }
  .grimorio-cerrar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(20,15,10,0.85);
    border: 1px solid #d4af37;
    color: #d4af37;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .grimorio-numeral {
    position: absolute;
    left: 84.82%;
    top: 67.33%;
    transform: translate(-50%, -50%);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
    font-weight: bold;
    letter-spacing: 1px;
    font-size: 30px;
    color: #1A0F01;
    margin: 0;
  }
  .grimorio-pagina {
    position: absolute;
    left: 6.24%;
    top: 2.79%;
    width: 86.9%;   /* derecha 93.14% - izquierda 6.24% */
    height: 59.54%; /* abajo 62.33% - arriba 2.79% */
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 7px;
  }
  .grimorio-insignia {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    cursor: default;
    min-width: 0;
    min-height: 0;
  }
  .grimorio-insignia.obtenida { cursor: pointer; }
  .grimorio-insignia-icono {
    width: 36%;
    aspect-ratio: 1 / 1;
    flex: none;
  }
  .grimorio-insignia.obtenida .grimorio-insignia-icono {
    /* El drop-shadow va aquí, NO en el elemento con la máscara CSS:
       filter + mask en el mismo elemento hace que el navegador no
       dibuje la sombra en varios motores. */
    filter: drop-shadow(0 0 5px #8402D4);
  }
  .grimorio-insignia-svg {
    display: block;
    width: 100%;
    height: 100%;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    background-color: currentColor;
  }
  .grimorio-insignia.bloqueada .grimorio-insignia-svg {
    background-color: #453B54;
  }
  .grimorio-insignia.obtenida .grimorio-insignia-svg {
    background-color: #E9CAFC;
  }
  .grimorio-insignia-nombre {
    margin: 0;
    font-size: 14px;
    font-weight: bold;
    color: #1A0F01;
    line-height: 1.2;
  }
  .grimorio-puntos {
    position: absolute;
    left: 50%;
    top: 75.7%;
    transform: translate(-50%, -50%);
    width: 175px;
    height: 25px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  .grimorio-punto {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid #E8A148;
    background: transparent;
    cursor: pointer;
  }
  .grimorio-punto.activo {
    background: #E8A148;
  }

  /* ============================================================
     BANNER — Instalar app
     ============================================================ */
  #banner-instalar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #1a1220;
    border-bottom: 1px solid rgba(212,175,55,0.35);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--modal-texto, #FEFEFE);
  }
  body.tiene-banner-instalar {
    padding-top: 52px;
  }
  #banner-instalar.hidden {
    display: none;
  }
  #banner-instalar .banner-instalar-texto {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.3;
  }
  #banner-instalar .banner-instalar-acciones {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }
  #banner-instalar button.btn-instalar {
    background: #d4af37;
    color: #1a1220;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
  }
  #banner-instalar .btn-cerrar-banner {
    background: none;
    border: none;
    color: var(--modal-texto, #FEFEFE);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    padding: 0 4px;
  }
  /* ============================================================
     Bloqueo de selección/arrastre — deja libres los campos de formulario
     (login, contraseña, etc.) para que copiar/pegar siga funcionando ahí.
     ============================================================ */
  body {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
  }
  input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
  }
  img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
  }
