* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body { background: #fbf9f7; color: #222; font-family: 'Montserrat', system-ui, sans-serif; }

/* Barra superior */
.stickyhead { position: fixed; top: 0; right: 0; z-index: 60; }
.topbar { display: flex; gap: 8px; padding: 12px 14px; }
@media (max-width: 700px) {
    .stickyhead { top: auto; right: 14px; bottom: 14px; }
    .topbar { flex-direction: column-reverse; gap: 12px; padding: 0; }
}
.secnav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 880px; margin: 18px auto 0; padding: 0 14px; }
.secnav a { white-space: nowrap; text-decoration: none; color: #6b6358; font-size: .85rem; font-weight: 600; padding: 7px 16px; border-radius: 999px; border: 1px solid #e7ddcd; background: #fff; cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.secnav a:hover { border-color: #b89a6a; color: #2a2118; }
.secnav a.active { background: #b89a6a; border-color: #b89a6a; color: #2a2118; }
.tool-btn { display: inline-flex; align-items: center; gap: 7px; background: #fff; color: #5b5246; border: 1px solid #e0d7c9;
    padding: 8px 14px; border-radius: 999px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.14); transition: .2s; }
.tool-btn:hover { border-color: #b89a6a; color: #2a2118; }
.tool-btn svg { width: 16px; height: 16px; }
@media (max-width: 700px) {
    .tool-btn { justify-content: center; width: 52px; height: 52px; padding: 0; gap: 0; font-size: 0; border-radius: 50%; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
    .tool-btn svg { width: 24px; height: 24px; }
    #btn-download-all { display: none; }
}
.tool-btn.primary { background: #b89a6a; color: #2a2118; border-color: #b89a6a; }
.tool-btn.primary:hover { background: #c9ab7b; color: #2a2118; border-color: #c9ab7b; }

/* Cabecera */
.boda-header { text-align: center; padding: 30px 16px 6px; }
.boda-header a.titulo-boda { text-decoration: none; }
.logo-link { display: inline-block; line-height: 0; }
.boda-logo { height: 96px; width: auto; display: block; margin: 0 auto 10px; }
@media (max-width: 600px) { .boda-logo { height: 74px; } }
.titulo-boda { font-family: 'Great Vibes', cursive; font-weight: 400; font-size: clamp(2.6rem, 7vw, 4rem); color: #1d1d1d; margin: 0; line-height: 1.05; }
.subtitulo-boda { color: #8a8279; font-size: clamp(.95rem, 2.5vw, 1.15rem); letter-spacing: .08em; margin: 14px 0 0; }
.hint { text-align: center; color: #a89f93; font-size: .82rem; margin: 12px auto 0; max-width: 560px; padding: 0 16px; }

main { padding: 6px 0 70px; }
.masonry-section { max-width: 1480px; margin: 0 auto; padding: 16px 14px 8px; }
.cat-title { text-align: center; font-size: 1.05rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: #b89a6a; margin: 26px 0 18px; }
.cat-title::after { content: ""; display: block; width: 46px; height: 2px; background: #e4d8c4; margin: 10px auto 0; }
.vacio { text-align: center; color: #999; padding: 40px; }

/* Índice de álbumes (/albumes) */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; max-width: 1100px; margin: 10px auto 0; }
.album-card { display: block; text-decoration: none; color: inherit; background: #fff; border: 1px solid #ece3d4; border-radius: 14px; overflow: hidden; box-shadow: 0 6px 16px rgba(0,0,0,.08); transition: transform .2s, box-shadow .2s; }
.album-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px rgba(0,0,0,.16); }
.album-cover { aspect-ratio: 3/2; background: #ece7e0; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: #aaa; font-size: .9rem; }
.album-info { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.album-name { font-weight: 700; color: #2a2118; }
.album-count { font-size: .85rem; color: #8a8279; }

/* Fallback sin JS: columnas CSS */
.gallery { column-count: 4; column-gap: 12px; }
@media (max-width: 1200px) { .gallery:not(.js-masonry) { column-count: 3; } }
@media (max-width: 760px)  { .gallery:not(.js-masonry) { column-count: 2; column-gap: 8px; } }
/* Masonry real (JS): columnas flex, cada foto en la más corta -> rellena todas */
.gallery.js-masonry { display: flex; align-items: flex-start; gap: 12px; column-count: initial; }
.gallery.js-masonry .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 760px) { .gallery.js-masonry, .gallery.js-masonry .col { gap: 8px; } }
.item { position: relative; break-inside: avoid; margin: 0 0 12px; }
.gallery.js-masonry .item { margin: 0; }
@media (max-width: 760px) { .gallery:not(.js-masonry) .item { margin-bottom: 8px; } }
.item img {
    width: 100%; height: auto; display: block; border-radius: 8px; cursor: pointer; background: #ece7e0;
    box-shadow: 0 6px 14px rgba(0,0,0,.14), 0 3px 6px rgba(0,0,0,.10);
    transition: box-shadow .3s ease, transform .3s ease;
}
.item img:hover { box-shadow: 0 12px 24px rgba(0,0,0,.24), 0 6px 12px rgba(0,0,0,.16); transform: translateY(-2px); }

/* Modo selección */
body.selecting .item { cursor: pointer; }
body.selecting .item img:hover { transform: none; }
body.selecting .item::after {
    content: ""; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid #fff; background: rgba(0,0,0,.30); box-shadow: 0 0 0 1px rgba(0,0,0,.18);
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: bold; pointer-events: none;
}
body.selecting .item.sel::after { content: "\2713"; background: #b89a6a; border-color: #b89a6a; }
body.selecting .item.sel img { outline: 3px solid #b89a6a; outline-offset: -3px; }

/* Lightbox */
.lightbox { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.92); justify-content: center; align-items: center; }
.lightbox-image { max-width: 92%; max-height: 84%; object-fit: contain; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,.6); }
.lightbox-close { position: absolute; top: 18px; right: 28px; color: #fff; font-size: 40px; font-weight: bold; cursor: pointer; line-height: 1; z-index: 10000; transition: color .25s; }
.lightbox-close:hover { color: #d9b06a; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 50px; font-weight: bold; cursor: pointer; z-index: 10000; line-height: 1; padding: 20px; user-select: none; opacity: .82; transition: color .25s, opacity .25s; }
.lightbox-nav:hover { color: #d9b06a; opacity: 1; }
.lightbox-nav.prev { left: 16px; } .lightbox-nav.next { right: 16px; }
.lightbox-nav.disabled { opacity: .25; cursor: default; }
.lightbox-actions { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 10000; }
.lb-btn { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.14); color: #fff; text-decoration: none;
    padding: 11px 18px; border-radius: 999px; font: inherit; font-size: .9rem; font-weight: 600; border: 1px solid rgba(255,255,255,.35);
    backdrop-filter: blur(6px); cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.lb-btn:hover { background: #d9b06a; border-color: #d9b06a; color: #2a2118; }
.lb-btn svg { width: 18px; height: 18px; }
@media (max-width: 768px) {
    .lightbox-close { top: 10px; right: 18px; font-size: 32px; }
    .lightbox-nav { font-size: 36px; padding: 14px; } .lightbox-nav.prev { left: 6px; } .lightbox-nav.next { right: 6px; }
    .lightbox-image { max-width: 96%; max-height: 76%; }
    .lightbox-actions { bottom: 14px; } .lb-btn { padding: 10px 15px; font-size: .85rem; }
}

/* Menú contextual (clic derecho) */
.ctx-menu { position: fixed; z-index: 10050; min-width: 232px; background: #fff; border: 1px solid #e6ddcf; border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,.22); padding: 6px; display: none; }
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; text-align: left;
    padding: 10px 12px; border-radius: 8px; font: inherit; font-size: .92rem; color: #3a342c; cursor: pointer; }
.ctx-menu button:hover { background: #f5efe4; color: #2a2118; }
.ctx-menu button svg { width: 17px; height: 17px; color: #b89a6a; flex: 0 0 auto; }
.ctx-sep { height: 1px; background: #efe9e1; margin: 4px 6px; }

/* Barra de acción de selección */
.selbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(140%); z-index: 9000;
    display: flex; align-items: center; gap: 14px; background: #1d1d1d; color: #fff; padding: 10px 14px; border-radius: 999px;
    box-shadow: 0 14px 34px rgba(0,0,0,.35); transition: transform .28s ease; max-width: calc(100vw - 24px); }
.selbar.show { transform: translateX(-50%) translateY(0); }
.selbar #sel-count { font-size: .9rem; font-weight: 600; white-space: nowrap; padding-left: 6px; }
.selbar-actions { display: flex; gap: 8px; }
.sb { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25); padding: 9px 14px; border-radius: 999px;
    font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; transition: .2s; white-space: nowrap; }
.sb:hover { background: rgba(255,255,255,.26); }
.sb.primary { background: #b89a6a; border-color: #b89a6a; color: #2a2118; }
.sb.primary:hover { background: #c9ab7b; }
.sb:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) {
    .selbar { gap: 8px; padding: 8px 10px; bottom: 10px; flex-wrap: wrap; justify-content: center; }
    .sb { padding: 8px 11px; font-size: .82rem; }
    .selbar #sel-count { padding-left: 2px; font-size: .82rem; width: 100%; text-align: center; }
}

/* Modal compartir */
.modal { display: none; position: fixed; inset: 0; z-index: 10100; background: rgba(0,0,0,.55); align-items: center; justify-content: center; padding: 16px; }
.modal.show { display: flex; }
.modal-box { background: #fff; border-radius: 16px; padding: 26px 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-box h3 { margin: 0 0 4px; font-size: 1.3rem; color: #1d1d1d; }
.modal-box p { margin: 0 0 14px; color: #6b6358; font-size: .9rem; }
.modal-box input[type=text], .ms-link input { width: 100%; padding: 11px 13px; border: 1px solid #ddd3c4; border-radius: 10px; font: inherit; font-size: .95rem; }
.modal-box input[type=text]:focus { outline: none; border-color: #b89a6a; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .sb, .ms-result .sb { background: #f1ece2; color: #4a4236; border-color: #e3d9c8; }
.modal-actions .sb.primary { background: #b89a6a; color: #2a2118; border-color: #b89a6a; }
.ms-result { margin-top: 18px; border-top: 1px solid #eee; padding-top: 16px; }
.ms-link { display: flex; gap: 8px; margin: 8px 0 12px; }
.ms-link input { flex: 1; background: #faf7f1; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px); z-index: 10200;
    background: #1d1d1d; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: .88rem; font-weight: 600;
    opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; box-shadow: 0 10px 26px rgba(0,0,0,.3); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Volver arriba */
/* "Subir arriba": círculo blanco abajo a la derecha; oculto hasta hacer scroll.
   En móvil queda igual y alineado con el botón "Seleccionar" (justo encima). */
.scroll-top { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: none; align-items: center; justify-content: center;
    width: 56px; height: 56px; background: #fff; color: #5b5246; border: 1px solid #e0d7c9; border-radius: 50%; cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,.18); transition: .2s; }
.scroll-top.show { display: inline-flex; }
.scroll-top:hover { border-color: #b89a6a; color: #2a2118; }
.scroll-top svg { width: 24px; height: 24px; }
@media (max-width: 700px) { .scroll-top { width: 52px; height: 52px; right: 14px; bottom: 78px; } }

footer { text-align: center; color: #b3aaa0; font-size: .82rem; padding: 24px 16px 30px; }
footer a { color: #b89a6a; text-decoration: none; font-weight: 600; }

/* Pantalla de carga: anima el logo REAL + revela el resto en cascada (escalonado) */
#intro { position: fixed; inset: 0; z-index: 11000; background: #fbf9f7; }
#intro.fade { opacity: 0; transition: opacity .7s ease .2s; pointer-events: none; }
.has-intro .logo-link { position: relative; z-index: 12000; }
.has-intro .boda-logo { opacity: 0; will-change: transform, opacity; }

/* estado inicial: todo oculto y un poco abajo (menos el logo, que lo anima el JS) */
.has-intro .stickyhead,
.has-intro .titulo-boda,
.has-intro .subtitulo-boda,
.has-intro .secnav,
.has-intro footer,
.has-intro .masonry-section { opacity: 0; transform: translateY(30px); }

/* revelado en cascada */
.has-intro.reveal .titulo-boda,
.has-intro.reveal .subtitulo-boda,
.has-intro.reveal .secnav,
.has-intro.reveal .masonry-section,
.has-intro.reveal .stickyhead,
.has-intro.reveal footer,
.has-intro.reveal .boda-logo {
    opacity: 1; transform: none;
    transition: opacity .7s ease, transform .85s cubic-bezier(.2,.75,.25,1);
}
.has-intro.reveal .titulo-boda    { transition-delay: .15s; }
.has-intro.reveal .subtitulo-boda { transition-delay: .28s; }
.has-intro.reveal .secnav         { transition-delay: .40s; }
.has-intro.reveal .masonry-section:nth-of-type(1) { transition-delay: .54s; }
.has-intro.reveal .masonry-section:nth-of-type(2) { transition-delay: .66s; }
.has-intro.reveal .masonry-section:nth-of-type(3) { transition-delay: .78s; }
.has-intro.reveal .masonry-section:nth-of-type(4) { transition-delay: .90s; }
.has-intro.reveal .masonry-section:nth-of-type(5) { transition-delay: 1.02s; }
.has-intro.reveal .masonry-section:nth-of-type(6) { transition-delay: 1.14s; }
.has-intro.reveal .masonry-section:nth-of-type(n+7) { transition-delay: 1.26s; }
.has-intro.reveal .stickyhead     { transition-delay: .95s; }
.has-intro.reveal footer          { transition-delay: 1.0s; }

@media (prefers-reduced-motion: reduce) { .has-intro .boda-logo, #intro, .has-intro .reveal * { transition: none !important; } }
