/* Componentes compartidos: botones, avisos (toasts), modal, skeleton y barra de navegación inferior */

/* ---------- Accesibilidad ---------- */
:focus-visible {
    outline: 3px solid var(--violet-400);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap-size);
    padding: 12px 22px;
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.2s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--brand-green-strong); color: var(--white); }
.btn-violet { background: var(--violet-600); color: var(--white); }
.btn-secondary { background: transparent; color: var(--violet-600); border-color: var(--violet-600); }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); }
.btn-danger { background: var(--red-600); color: var(--white); }

/* ---------- Avisos (mensajes de Django) como toasts ---------- */
.messages {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    z-index: 10002;
    margin: 0;
    padding: 0;
    list-style: none;
    pointer-events: none;
}
.messages li {
    pointer-events: auto;
    margin: 0 0 8px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: var(--shadow-pop);
    background: var(--slate-900);
    color: var(--white);
    border-left: 5px solid var(--blue-500);
    animation: toast-in 0.3s ease, toast-out 0.4s ease 6s forwards;
}
.messages li.success { border-left-color: var(--green-500); }
.messages li.warning { border-left-color: var(--amber-500); }
.messages li.error { border-left-color: var(--red-500); }
.messages li.toast-cerrado { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px); visibility: hidden; } }

/* ---------- Modal (reemplaza alert / confirm) ---------- */
.app-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10003;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.app-modal {
    width: 100%;
    max-width: 360px;
    padding: 24px 20px 20px;
    border-radius: 20px;
    background: var(--white);
    color: var(--slate-800);
    box-shadow: var(--shadow-pop);
    animation: toast-in 0.2s ease;
}
.app-modal h3 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 700; color: var(--slate-900); }
.app-modal p { margin: 0 0 20px; color: var(--gray-500); font-size: 0.95rem; line-height: 1.5; }
.app-modal p.app-modal-multilinea { white-space: pre-line; }
.app-modal-actions { display: flex; gap: 10px; }
.app-modal-actions .btn { flex: 1; padding: 12px 10px; }

/* ---------- Hoja de compartir (static/js/share.js) ---------- */
.share-sheet { display: flex; flex-direction: column; gap: 10px; }
.share-sheet h3 { margin: 0; }
.share-sheet-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-sheet .btn { width: 100%; justify-content: center; padding: 12px 10px; text-decoration: none; }
.share-btn { display: flex; width: 100%; justify-content: center; margin: 10px 0 12px; }

/* ---------- Agregar a la pantalla principal (static/js/install-app.js) ---------- */
.install-sheet { text-align: center; }
.install-icon { display: block; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 14px; }
.install-sheet p { margin-bottom: 14px; }
.install-steps { margin: 0 0 18px; padding: 0 0 0 20px; text-align: left; color: var(--gray-700); font-size: 0.92rem; line-height: 1.5; }
.install-steps li { margin-bottom: 6px; }

/* ---------- Skeleton ---------- */
.skeleton {
    border-radius: var(--radius-md);
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.3s linear infinite;
}
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Barra de navegación inferior ---------- */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 800;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: var(--tap-size);
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg { width: 24px; height: 24px; }
.bottom-nav-item.active { color: var(--violet-600); font-weight: 700; position: relative; }
.bottom-nav-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 28px;
    height: 3px;
    margin-left: -14px;
    border-radius: 0 0 3px 3px;
    background: var(--violet-600);
}

/* Con barra inferior: espacio para que no tape el contenido y flotantes por encima de ella */
body:has(.bottom-nav) .container {
    padding-bottom: calc(var(--bottom-nav-h) + 24px + env(safe-area-inset-bottom, 0px));
}
body:has(.bottom-nav) .cookie-banner {
    bottom: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
}
body:has(.bottom-nav) .fab-button {
    bottom: calc(var(--bottom-nav-h) + 20px + env(safe-area-inset-bottom, 0px));
}
body:has(.bottom-nav) .chat-panel {
    bottom: calc(var(--bottom-nav-h) + 90px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - var(--bottom-nav-h) - 130px);
}

/* Discord: tarjeta de la cuenta, fila del detalle de la medalla y aviso tras la compra */
.discord-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.discord-row .discord-name {
    color: var(--gray-700);
    font-size: 0.85rem;
    font-weight: 600;
    word-break: break-word;
}
.discord-note {
    color: var(--gray-700);
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 6px 0 10px 0;
}
.discord-icon {
    width: 1.35em;
    height: 1.35em;
    flex: none;
}
/* Botón de Discord: Blurple oficial con el logo en blanco */
.pill-btn.btn-discord,
.selfie-btn.btn-discord {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--discord-blurple);
    color: var(--white);
}
.pill-btn.btn-discord:hover,
.selfie-btn.btn-discord:hover {
    background: var(--discord-blurple-dark);
}
/* Botón de Discord suelto (debajo de Watch Location Story en el detalle de la medalla) */
.discord-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 12px 0;
    padding: 14px;
    border-radius: var(--radius-pill);
    background: var(--discord-blurple);
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
}
.discord-btn:hover {
    background: var(--discord-blurple-dark);
}
.discord-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--discord-blurple);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
}

/* Tarjetas con webp/webm (home, galería, Saved Locations): mientras carga el medio solo se ve el rectángulo de
   la tarjeta y el contenido aparece con fade-in de 0,5 s (static/js/tarjetas-fade.js quita tarjeta-cargando
   cuando el medio está listo). La animación es solo la red de seguridad si el script no corre. */
.tarjeta-fade > * {
    transition: opacity 0.5s ease;
}
.tarjeta-fade.tarjeta-cargando > * {
    opacity: 0;
    animation: tarjeta-aparecer 0.5s ease 12s forwards;
}
@keyframes tarjeta-aparecer {
    to { opacity: 1; }
}
/* el loader reserva un alto fijo y hace su propio fade: dentro de la tarjeta lo hace la tarjeta entera
   (si el medio llega tarde, cuando la tarjeta ya se mostró, vuelve a aplicar el fade del medio) */
.tarjeta-fade .img-loader-box.cargando,
.tarjeta-fade .video-cargando {
    min-height: 0;
}
.tarjeta-fade.tarjeta-cargando .img-loader-box.cargando > img,
.tarjeta-fade.tarjeta-cargando .video-cargando > video {
    opacity: 1;
}
/* sin el hueco de línea bajo la imagen, el alto final coincide con el espacio reservado */
.tarjeta-fade .img-loader-box > img {
    display: block;
}

/* Aviso "al continuar aceptás los términos y la política de privacidad" (login y registro): texto chico, sin checkbox */
.terms-notice {
    margin: 16px 0 0 0;
    color: var(--gray-500);
    font-size: 0.78rem;
    line-height: 1.5;
    text-align: center;
}
.terms-notice a {
    color: var(--violet-600);
    font-weight: 600;
    text-decoration: underline;
}

/* "Join the Community" sobre el enlace de Discord tras la compra: título corto en vez de nota */
.discord-note.discord-title {
    margin: 14px 0 2px 0;
    color: var(--slate-800);
    font-size: 0.95rem;
    font-weight: 700;
}

/* Carga diferida (lazy-load.js): la tarjeta lejos de la pantalla no dibuja su HTML pero conserva su alto aproximado */
[data-lazy-render].lazy-fuera {
    content-visibility: hidden;
    contain-intrinsic-height: auto 440px; /* solo el alto: con contain-intrinsic-size el ancho también valdría 440px */
}

/* Scroll paginado (scroll-paginado.js): las tarjetas que pasan del límite se esconden; !important porque los filtros
   fijan style.display en línea sobre las mismas tarjetas */
[data-paginable][data-pag-oculta] {
    display: none !important;
}

/* Carga diferida (lazy-load.js): un video o imagen que se vuelve a pedir arranca transparente y aparece con fade */
video.lazy-recargando,
img.lazy-recargando {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* ---------- Estado vacío (ícono, título, frase y botón) ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 36px 20px;
    text-align: center;
}
.empty-state-icon { width: 56px; height: 56px; color: var(--violet-400); margin-bottom: 4px; }
.empty-state-title { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--slate-900); }
.empty-state-text { margin: 0 0 12px; max-width: 280px; font-size: 0.9rem; line-height: 1.5; color: var(--slate-500); }

/* ---------- Campo de contraseña con botón mostrar/ocultar (static/js/password-toggle.js) ---------- */
.password-field { position: relative; display: block; }
.password-field > input { padding-right: 72px; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    padding: 6px 4px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--violet-600);
    cursor: pointer;
}

/* ---------- Medalla desbloqueada: cartel y confeti al llegar de una compra ---------- */
.unlocked-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px 0 12px;
    padding: 12px 16px;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, var(--violet-700), var(--violet-900));
    color: #f5c542;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    animation: unlocked-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes unlocked-in {
    from { opacity: 0; transform: translateY(-10px) scale(0.92); }
    to { opacity: 1; transform: none; }
}
.confetti-box {
    position: fixed;
    inset: 0;
    z-index: 10001;
    overflow: hidden;
    pointer-events: none;
}
.confetti-piece {
    position: absolute;
    top: -16px;
    width: 9px;
    height: 14px;
    border-radius: 2px;
    animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
    to { top: 105%; opacity: 0.2; margin-left: 40px; }
}

/* ---------- reCAPTCHA ---------- */
/* El badge se oculta en todo el sitio (tapaba el botón del chat y, bajo el .container, se veía como una mancha
   difuminada). Donde se usa reCAPTCHA se muestra el aviso legal que exige Google (.recaptcha-legal). */
.grecaptcha-badge { visibility: hidden; }
.recaptcha-legal { margin: 14px 0 0; font-size: 0.75rem; line-height: 1.4; color: var(--gray-500); text-align: center; }
.recaptcha-legal a { color: var(--gray-500); text-decoration: underline; }

/* ---------- Ícono de compartir según el sistema (includes/share_icons.html; la clase plat-ios la pone share.js) ---------- */
.icon-share-ios { display: none; }
.plat-ios .icon-share-ios { display: block; }
.plat-ios .icon-share-android { display: none; }

/* ---------- Solo para lectores de pantalla y buscadores (por ejemplo el <h1> de la home) ---------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
