:root {
    --color-bg: #0a0a0a;
    --color-paper: #fcfaf7;
    --color-forest: #1b4332;
    --color-gold: #c5a059;
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Montserrat', sans-serif;
    --font-accent: 'Montserrat', sans-serif;
    --base-font-size: clamp(0.8rem, 2vw, 0.95rem);
    --text-color: #444444;
    --heading-color: #1b4332;
    --accent-color: #c5a059;
    --cover-text-color: #ffffff;
    --sheet-transition: 0.9s cubic-bezier(0.645, 0.045, 0.355, 1);

    /* Dimensiones Desktop */
    --book-w: 900px;
    --book-h: 620px;
    --anim-speed: 0.9s;
    --spine-width: 45px;
    --paper-opacity: 0.2;
}

/* Root (Desktop) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--color-bg);
    background-image: radial-gradient(circle at center, #1a1a1a 0%, #0a0a0a 100%);
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-sans);
    cursor: pointer;
    /* Prevenir zoom por doble toque */
    touch-action: manipulation;
}

@media (max-width: 1024px) {
    html, body {
        touch-action: manipulation;
        -ms-touch-action: manipulation;
    }

    body,
    html {
        overflow: visible !important;
        height: 100%;
        width: 100%;
    }
}

/* UI Superior */
.top-bar {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2000;
    pointer-events: none;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.mini-logo {
    width: 35px;
    height: 35px;
    background: white;
    border-radius: 50%;
    padding: 4px;
    border: 1px solid var(--accent-color);
}

.brand-text {
    color: white;
    letter-spacing: 0.15em;
    font-size: 0.75rem;
    font-weight: 300;
}

.brand-text span {
    color: var(--accent-color);
    font-weight: 600;
}

/* Escena del Libro */
.book-scene {
    width: var(--book-w);
    height: var(--book-h);
    position: relative;
    transform-style: preserve-3d;
    perspective: 2000px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.book-container {
    width: 100%;
    height: 100%;
    position: relative;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.8s ease;
    opacity: 0;
    transform: scale(0.95);
}

.book-container.ready {
    opacity: 1;
    transform: scale(1);
}

@media (max-width: 1024px) {
    .book-scene {
        width: 100vw !important;
        height: var(--book-h) !important;
        position: relative !important;
        margin: 0 !important;
        top: 0 !important;
        left: 0 !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
        z-index: 10;
        transform: none !important;
        perspective: 2000px;
    }

    .book-container {
        width: 100% !important;
        height: 100% !important;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
    }
}

.book-spine {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--spine-width);
    height: 100%;
    background-color: var(--color-forest);
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.2) 40%, transparent);
    z-index: 1000;
    transform: translateX(-100%);
    border-radius: 5px 0 0 5px;
    box-shadow: -10px 0 20px rgba(0, 0, 0, 0.5);
}

/* Hojas */
.sheet {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform-origin: left center;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transition: transform var(--sheet-transition);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    z-index: 1;
}

.sheet.flipped {
    transform: rotateY(-180deg);
    -webkit-transform: rotateY(-180deg);
}

.sheet-page {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background-color: var(--color-paper);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    contain: strict;
}

/* Sombra del lomo (Profundidad central) */
.sheet-page::after {
    content: '';
    position: absolute;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* En la página frontal (derecha), la sombra está a la izquierda */
.sheet-page.front::after {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.05) 50%, transparent 100%);
}

/* En la página trasera (izquierda al girar), la sombra está a la derecha */
.sheet-page.back::after {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.05) 50%, transparent 100%);
}

/* Textura de papel */
.sheet-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('https://www.transparenttextures.com/patterns/natural-paper.png');
    opacity: var(--paper-opacity);
    pointer-events: none;
    z-index: 1;
}

.sheet-page.back {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    background-color: var(--color-paper);
    /* Sincronizado con el frente */
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

/* Contenido Magazine */
.mag-layout {
    width: 100%;
    height: 100%;
    display: flex;
    padding: clamp(25px, 5vw, 60px);
    box-sizing: border-box;
    position: relative;
    z-index: 5;
}

.layout-intro {
    flex-direction: column;
    overflow-y: auto;
}

.intro-text {
    flex: 0 0 auto;
    margin-bottom: 20px;
}

.cat-label {
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.6rem;
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-accent);
}

h2 {
    font-family: var(--font-serif);
    font-size: clamp(1.4rem, 5vw, 2.8rem);
    color: var(--heading-color);
    margin-bottom: 12px;
    line-height: 1.1;
}

.desc-text {
    font-size: var(--base-font-size);
    line-height: 1.6;
    color: var(--text-color);
}

@media (max-width: 480px) {
    .mag-layout { padding: 25px 15px !important; }
    h2 { font-size: 1.5rem !important; margin-bottom: 8px; }
    .desc-text { font-size: 0.8rem !important; line-height: 1.4; }
}

.main-visual {
    flex: 1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    min-height: 200px;
}

.main-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.layout-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 600px) {
    .layout-gallery {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

.gallery-item {
    border-radius: 4px;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Rótulo de Identidad */
.page-tag {
    position: absolute;
    bottom: 20px;
    right: 25px;
    text-align: right;
    border-right: 2px solid var(--accent-color);
    padding-right: 10px;
    z-index: 20;
    background: rgba(252, 250, 247, 0.7);
    padding: 5px 10px;
}

.page-tag span {
    display: block;
    text-transform: uppercase;
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    font-family: var(--font-accent);
}

.page-tag b {
    font-family: var(--font-serif);
    font-size: 0.8rem;
    color: var(--color-forest);
}

/* Portada */
.cover-mag {
    background-color: var(--color-forest) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--cover-text-color) !important;
    text-align: center;
    padding: 40px;
    height: 100%;
    width: 100%;
}

.cover-mag h1 {
    color: var(--cover-text-color) !important;
    font-size: clamp(2rem, 8vw, 4.5rem);
    margin: 0;
    line-height: 1;
    letter-spacing: 0.1em;
    font-family: var(--font-serif);
}

.cover-mag .divider {
    width: 80px;
    height: 1.5px;
    background-color: var(--cover-text-color) !important;
    margin: 30px auto;
}

.cover-mag .subtitle {
    color: var(--cover-text-color) !important;
    font-size: 0.8rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    opacity: 0.9;
}

@media (max-width: 1024px) {
    .cover-mag {
        padding: 20px !important;
        width: 100% !important;
        height: 100% !important;
    }

    .cover-mag.layout-split {
        flex-direction: column !important;
        justify-content: center !important;
    }

    .cover-left,
    .cover-right {
        width: 100% !important;
        padding: 10px !important;
    }
}

/* Layouts de Portada */
.cover-mag.layout-centered,
.cover-mag.layout-minimal,
.cover-mag.layout-hero {
    flex-direction: column !important;
    text-align: center !important;
}

.cover-mag.layout-centered .cover-left,
.cover-mag.layout-minimal .cover-left,
.cover-mag.layout-hero .cover-left {
    width: 100% !important;
}

.cover-mag.layout-centered .cover-right,
.cover-mag.layout-minimal .cover-right,
.cover-mag.layout-hero .cover-right {
    width: 100% !important;
}

.cover-mag.layout-minimal .logo-hero {
    display: none !important;
}

.cover-mag.layout-minimal h1 {
    font-size: 4rem;
    margin-bottom: 0;
}

.cover-mag.layout-minimal .divider {
    width: 80% !important;
    height: 2px;
    margin: 30px auto !important;
}

/* Split Layout */
.cover-mag.layout-split {
    flex-direction: row;
    padding: 0;
    align-items: stretch;
    text-align: left;
}

.cover-mag.layout-split .cover-left {
    flex: 0 0 40%;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.cover-mag.layout-split .cover-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
}

.cover-mag.layout-split h1 {
    font-size: clamp(1.8rem, 6vw, 3.5rem);
}

.cover-mag.layout-split .logo-hero {
    width: 80%;
    border-radius: 8px;
}

/* Overlap Layout (Stack) */
.cover-mag.layout-overlap {
    position: relative;
    padding: 60px;
}

.cover-mag.layout-overlap .logo-hero {
    position: absolute;
    top: 15%;
    left: 15%;
    width: 120px;
    z-index: 1;
    opacity: 0.8;
    mix-blend-mode: overlay;
    border: none;
}

.cover-mag.layout-overlap h1 {
    position: relative;
    z-index: 2;
    font-size: 5rem;
    line-height: 0.9;
    margin-top: 40px;
}

.cover-mag.layout-overlap .subtitle {
    margin-top: auto;
    letter-spacing: 0.5em;
    border-top: 1px solid var(--color-gold);
    padding-top: 15px;
}

.logo-hero {
    width: auto;
    height: auto;
    max-width: 210px;
    max-height: 210px;
    object-fit: contain;
    margin: 0 auto 35px auto;
    border-radius: 50%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 3px solid white;
    transition: transform 0.4s ease;
    z-index: 10;
    display: block;
}

@media (max-width: 480px) {
    .logo-hero { max-width: 140px !important; max-height: 140px !important; margin-bottom: 15px !important; }
    .cover-mag h1 { font-size: 2rem !important; letter-spacing: 0.1em; }
    .cover-mag .subtitle { font-size: 0.6rem !important; }
}

.logo-hero:hover {
    transform: scale(1.05);
}

.cover-mag h1 {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3.4rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 20px 0;
    line-height: 1.1;
    font-weight: 500;
    color: var(--heading-color, white);
}

.cover-mag .divider {
    width: 70px;
    height: 1.5px;
    background: var(--accent-color);
    margin: 30px auto;
}

.cover-mag .subtitle {
    font-size: 0.7rem;
    letter-spacing: 0.5em;
    opacity: 0.9;
    text-transform: uppercase;
    font-weight: 300;
    color: var(--accent-color, white);
    font-family: var(--font-accent);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
}

/* UI Libro Navegación */
.nav-magazine {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.page-info {
    color: white;
    font-size: 0.75rem;
    font-family: var(--font-sans);
    letter-spacing: 0.1em;
    min-width: 60px;
    text-align: center;
}

/* Redes Sociales Cierre */
.social-links {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    justify-content: center;
    flex-wrap: wrap;
}

.social-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.3s ease, filter 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.social-btn:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
}

.social-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.end-page-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    background: var(--color-paper) !important;
}

.end-page-container.layout-hero img {
    width: 150px !important;
    margin-bottom: 30px;
}

.end-page-container.layout-minimal img {
    display: none;
}

/* Spinner de Carga */
.loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader-wrapper.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: none !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 215, 0, 0.1);
    border-top: 3px solid var(--color-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Lightbox Mejorado */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
}

/* --- CONSOLIDADO FINAL MÓVIL (SÓLO CELULARES) --- */
@media (max-width: 480px) {
    :root {
        --book-h: 72vh !important;
        --base-font-size: 0.85rem;
    }
    
    .mag-layout { padding: 15px 12px !important; }
    h2 { font-size: 1.4rem !important; margin-bottom: 6px !important; line-height: 1.1 !important; }
    .desc-text { font-size: 0.78rem !important; line-height: 1.4 !important; }
    
    .logo-hero { 
        max-width: 130px !important; 
        max-height: 130px !important; 
        margin-bottom: 15px !important; 
    }
    
    .cover-mag h1 { font-size: 1.7rem !important; }
    
    .nav-magazine {
        bottom: calc(env(safe-area-inset-bottom) + 15px) !important;
        background: rgba(0, 0, 0, 0.7) !important;
        padding: 6px 12px !important;
    }
    .nav-btn { width: 36px !important; height: 36px !important; }
    .nav-btn svg { width: 18px !important; }
    .page-info { font-size: 0.65rem !important; min-width: 45px !important; }
}
