/* Memorial virtual — Funeraria Rey David */

/* Fuentes propias (variables, sólo alfabeto latino) */
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 300 600; font-display: swap;
    src: url('../fonts/memorial/inter.woff2') format('woff2');
}
@font-face {
    font-family: 'Playfair Display'; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url('../fonts/memorial/playfair-display.woff2') format('woff2');
}
:root {
    --oro: #c5a059;
    --oro-claro: #e2c48a;
    --noche: #0f1424;
    --vidrio: rgba(16, 20, 34, 0.78);
    --borde: rgba(197, 160, 89, 0.35);
    --texto: #f3efe6;
    --tenue: #b9b3a6;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; height: 100%; overflow: hidden;
    background: var(--noche); color: var(--texto);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
#escena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
[hidden] { display: none !important; }
/* Sin menú de selección de iOS ("Copiar / Consultar") al mantener el dedo
   sobre la escena; los campos de texto siguen siendo seleccionables. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, .ficha-bio, .mensajes p { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
a { color: var(--oro-claro); }
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* --- Viñeta y fundido -------------------------------------------- */
.vineta {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(8,6,20,.45) 100%);
}
.fundido { position: fixed; inset: 0; z-index: 15; pointer-events: none; background: #0b0a18; opacity: 0; transition: opacity .38s ease; }
.fundido.activo { opacity: 1; }
body.en-vitrina .joystick, body.en-vitrina .etiqueta { visibility: hidden; }

/* --- Carga --------------------------------------------------------- */
.carga {
    position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
    background: radial-gradient(ellipse at center, #1b2238 0%, #0a0d17 75%);
    transition: opacity .8s ease;
}
.carga.fuera { opacity: 0; pointer-events: none; }
.carga-caja { text-align: center; color: var(--tenue); font-size: .95rem; letter-spacing: .04em; }
.vela-carga { width: 18px; height: 46px; margin: 0 auto 18px; background: linear-gradient(#f6eedc, #d9cdb4); border-radius: 3px; position: relative; }
.vela-carga span {
    position: absolute; left: 50%; top: -22px; width: 12px; height: 20px; margin-left: -6px;
    background: radial-gradient(ellipse at 50% 70%, #fff6c8 0%, #ffbf4d 45%, rgba(255,140,0,0) 75%);
    border-radius: 50% 50% 45% 45%; animation: llama 1.4s ease-in-out infinite;
}
@keyframes llama { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12, 1.2) rotate(2deg); } }

/* --- Barra superior ------------------------------------------------ */
.hud-top {
    position: fixed; top: 0; left: 0; right: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    background: linear-gradient(rgba(8,10,18,.75), rgba(8,10,18,0));
    pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--texto); min-width: 0; }
.marca img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--oro); }
.marca strong { display: block; font-family: 'Playfair Display', serif; font-size: 1.15rem; font-weight: 700; color: var(--oro-claro); }
.marca small { display: block; font-size: .75rem; color: var(--tenue); white-space: nowrap; }
.hud-acciones { display: flex; align-items: center; gap: 8px; }
.btn-hud {
    background: var(--vidrio); color: var(--texto); border: 1px solid var(--borde);
    border-radius: 22px; height: 40px; min-width: 40px; padding: 0 14px;
    font: 500 .9rem 'Inter', sans-serif; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: border-color .2s, background .2s;
}
.btn-hud:hover, .btn-hud:focus-visible { border-color: var(--oro); background: rgba(30,36,56,.9); outline: none; }
.selector-anio {
    appearance: none; -webkit-appearance: none; padding: 0 30px 0 14px;
    background-image: linear-gradient(45deg, transparent 50%, var(--oro) 50%), linear-gradient(135deg, var(--oro) 50%, transparent 50%);
    background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat;
    background-color: var(--vidrio);
}
.selector-anio option { background: #141a2e; color: var(--texto); }
.buscador { position: relative; }
.buscador input {
    width: 220px; height: 40px; border-radius: 22px; padding: 0 16px;
    background: var(--vidrio); border: 1px solid var(--borde); color: var(--texto);
    font: 400 .9rem 'Inter', sans-serif; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.buscador input::placeholder { color: #8f8a80; }
.buscador input:focus { outline: none; border-color: var(--oro); }
.resultados {
    position: absolute; top: 46px; right: 0; width: 280px; max-height: 50vh; overflow: auto;
    list-style: none; margin: 0; padding: 6px; background: rgba(14,18,30,.96);
    border: 1px solid var(--borde); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.resultados li button, .lista-nombres li button {
    width: 100%; text-align: left; background: none; border: 0; color: var(--texto);
    padding: 9px 10px; border-radius: 8px; cursor: pointer; font: 400 .9rem 'Inter', sans-serif;
}
.resultados li button:hover, .resultados li button:focus-visible,
.lista-nombres li button:hover, .lista-nombres li button:focus-visible { background: rgba(197,160,89,.16); outline: none; }
.resultados small, .lista-nombres small { display: block; color: var(--tenue); font-size: .75rem; }

/* --- Etiqueta y aviso ---------------------------------------------- */
.etiqueta {
    position: fixed; z-index: 9; pointer-events: none; transform: translate(-50%, -130%);
    background: rgba(10,12,20,.88); border: 1px solid var(--borde); color: var(--texto);
    padding: 6px 12px; border-radius: 10px; font-size: .85rem; white-space: nowrap;
}
.aviso-cerca {
    position: fixed; z-index: 9; left: 50%; bottom: max(28px, env(safe-area-inset-bottom));
    transform: translateX(-50%); max-width: calc(100% - 32px);
    background: rgba(10,12,20,.9); color: var(--texto); border: 1px solid var(--oro);
    border-radius: 26px; padding: 12px 22px; font: 500 .95rem 'Inter', sans-serif; cursor: pointer;
    box-shadow: 0 6px 24px rgba(197,160,89,.25); animation: aparecer .3s ease;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aviso-cerca kbd { margin-right: 6px; }
@keyframes aparecer { from { opacity: 0; transform: translate(-50%, 10px); } }

/* --- Joystick ------------------------------------------------------ */
.joystick {
    position: fixed; z-index: 8; left: max(24px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom));
    width: 120px; height: 120px; border-radius: 50%;
    background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.18);
    display: none; touch-action: none;
}
.palanca {
    position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
    border-radius: 50%; background: rgba(197,160,89,.55); border: 2px solid var(--oro-claro);
}
body.tactil .joystick { display: block; }
body.tactil .aviso-cerca { bottom: auto; top: 74px; }

/* --- Modales ------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5,7,12,.6); }
.modal-caja {
    position: relative; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto;
    background: rgba(16,20,34,.97); border: 1px solid var(--borde); border-radius: 16px;
    padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-caja h2 { font-family: 'Playfair Display', serif; color: var(--oro-claro); margin: 0 0 8px; font-size: 1.5rem; }
.modal-caja p { color: var(--tenue); line-height: 1.55; }
.ayuda-lista { padding-left: 18px; line-height: 1.9; color: var(--texto); font-size: .93rem; }
body.tactil .solo-escritorio, body:not(.tactil) .solo-tactil { display: none; }
kbd {
    display: inline-block; min-width: 22px; padding: 1px 6px; margin-right: 2px; text-align: center;
    border: 1px solid #6d6555; border-bottom-width: 2px; border-radius: 4px; font: 600 .75rem 'Inter', sans-serif;
}
.nota-salida { font-size: .85rem; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.btn-oro {
    display: inline-flex; justify-content: center; align-items: center; width: 100%; margin-top: 8px;
    background: var(--oro); color: #1a1a1a; border: 0; border-radius: 26px; padding: 13px 22px;
    font: 600 .95rem 'Inter', sans-serif; cursor: pointer; text-decoration: none; transition: background .2s;
}
.btn-oro:hover, .btn-oro:focus-visible { background: var(--oro-claro); outline: none; }
.btn-oro:disabled { opacity: .6; cursor: default; }
.cerrar {
    position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,.06); border: 0; color: var(--texto); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.cerrar:hover, .cerrar:focus-visible { background: rgba(255,255,255,.14); outline: none; }
.modal-lista { max-width: 520px; }
.lista-nombres { list-style: none; padding: 0; margin: 12px 0 0; columns: 2 220px; }
.lista-nombres li { break-inside: avoid; }
/* Encabezado de cada pasillo (mes) dentro de la lista */
.lista-mes {
    font-family: 'Playfair Display', serif; color: var(--oro); font-size: .95rem;
    letter-spacing: .04em; margin: 14px 0 4px; padding-bottom: 4px;
    border-bottom: 1px solid var(--borde); break-after: avoid;
}
.lista-nombres .lista-mes:first-child { margin-top: 0; }

/* --- Ficha ----------------------------------------------------------- */
.ficha {
    position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
    background: rgba(14,18,30,.96); border-left: 1px solid var(--borde);
    box-shadow: -20px 0 60px rgba(0,0,0,.5); animation: entrar .35s ease;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
@keyframes entrar { from { transform: translateX(40px); opacity: 0; } }
.ficha-scroll { height: 100%; overflow: auto; padding: 56px 24px 32px; overscroll-behavior: contain; }
.ficha-cabecera { display: flex; gap: 16px; align-items: center; }
.ficha-cabecera img {
    width: 96px; height: 120px; object-fit: cover; flex-shrink: 0;
    border: 3px solid var(--oro); border-radius: 6px; background: #222;
}
.ficha-en-memoria { color: var(--oro); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; }
.ficha h2 { font-family: 'Playfair Display', serif; font-size: 1.45rem; margin: 4px 0 6px; line-height: 1.2; color: #fff; }
.ficha-fechas { margin: 0; color: var(--tenue); font-size: .9rem; letter-spacing: .04em; }
.ofrendas-titulo { font-family: 'Playfair Display', serif; color: var(--oro-claro); font-weight: 400; font-size: 1.05rem; margin: 22px 0 10px; }
.ofrendas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 18px; }
.ofrenda {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px 8px;
    background: rgba(255,255,255,.04); border: 1px solid var(--borde); border-radius: 14px;
    color: var(--texto); cursor: pointer; font: 500 .74rem 'Inter', sans-serif; line-height: 1.25; text-align: center; transition: .2s;
}
.ofrenda:hover, .ofrenda:focus-visible { border-color: var(--oro); background: rgba(197,160,89,.1); outline: none; transform: translateY(-1px); }
.ofrenda.hecha { border-color: var(--oro); background: rgba(197,160,89,.18); cursor: default; transform: none; }
.ofrenda:disabled { opacity: .6; }
.ofrenda-icono { font-size: 1.45rem; }
.ofrenda-n { color: var(--oro-claro); font-weight: 600; }
.ficha-bio { white-space: pre-line; color: #ddd6c8; line-height: 1.65; font-size: .93rem; font-style: italic; }
.ficha-servicio { display: grid; gap: 10px; margin: 18px 0; }
.ficha-servicio div {
    border-left: 3px solid var(--oro); background: rgba(255,255,255,.03); padding: 10px 14px; border-radius: 0 8px 8px 0;
    font-size: .88rem; line-height: 1.5; color: #ddd6c8;
}
.ficha-servicio strong { color: var(--oro-claro); display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.libro h3 { font-family: 'Playfair Display', serif; color: var(--oro-claro); font-weight: 400; margin: 26px 0 12px; }
.form-condolencia { display: grid; gap: 10px; }
.form-condolencia input, .form-condolencia textarea {
    width: 100%; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.15); border-radius: 10px;
    padding: 11px 13px; color: var(--texto); font: 400 .92rem 'Inter', sans-serif; resize: vertical;
}
.form-condolencia input:focus, .form-condolencia textarea:focus { outline: none; border-color: var(--oro); }
.form-estado { margin: 0; font-size: .85rem; min-height: 1.2em; color: var(--oro-claro); }
.mensajes { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.mensajes li { background: rgba(255,255,255,.04); border-radius: 10px; padding: 12px 14px; font-size: .9rem; line-height: 1.5; }
.mensajes strong { color: var(--oro-claro); }
.mensajes time { float: right; color: var(--tenue); font-size: .75rem; }
.mensajes p { margin: 4px 0 0; white-space: pre-line; color: #ddd6c8; overflow-wrap: anywhere; }
.mensajes .vacio { color: var(--tenue); text-align: center; border: 1px dashed rgba(255,255,255,.15); background: none; }
.ficha-pie { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.btn-linea {
    flex: 1; text-align: center; padding: 10px 14px; border: 1px solid var(--borde); border-radius: 22px;
    color: var(--texto); text-decoration: none; font-size: .85rem;
}
.btn-linea:hover, .btn-linea:focus-visible { border-color: var(--oro); outline: none; }

@media (min-width: 761px) {
    body.ficha-abierta .hud-acciones { margin-right: min(420px, 100vw); }
    body.ficha-abierta .btn-clasica { display: none; }
}

/* --- Móvil ----------------------------------------------------------- */
@media (max-width: 760px) {
    .marca small { display: none; }
    .marca strong { font-size: 1rem; }
    .btn-clasica, #btn-lista span { display: none; }
    .buscador input { width: 132px; }
    .buscador input:focus { width: 180px; }
    .resultados { width: min(280px, calc(100vw - 32px)); }
    .ficha { width: 100%; top: auto; height: 65vh; border-left: 0; border-top: 1px solid var(--borde); border-radius: 18px 18px 0 0; animation-name: subir; }
    @keyframes subir { from { transform: translateY(40px); opacity: 0; } }
    .ficha-scroll { padding-top: 48px; }
}
@media (max-width: 420px) {
    .marca span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
