* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0c0c0c;
    color: #eee;
    font-family: 'Lora', serif;
    overflow-x: hidden;
}

.scroll-container {
    /* Height will be set dynamically by JS to allow scrolling */
    width: 100%;
}

.book-wrapper {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 3500px;
    background: radial-gradient(circle at 60% 30%, #1e130d 0%, #0a0604 55%, #020101 100%);
    overflow: hidden;
}

/* Subtle cinematic god-rays from upper right */
.book-wrapper::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -10%;
    width: 90%;
    height: 130%;
    background: radial-gradient(
        ellipse at 85% 15%,
        rgba(255, 220, 140, 0.12) 0%,
        rgba(255, 180, 80, 0.05) 40%,
        rgba(0, 0, 0, 0) 70%
    );
    pointer-events: none;
    z-index: 1;
}

#particles-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

.floating-anchor {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    z-index: 2;
    animation: antigravity-float 6s ease-in-out infinite;
}

@keyframes antigravity-float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-16px);
    }
}

.book {
    width: 85vw;
    height: 85vh;
    max-width: 1400px;
    max-height: 900px;
    display: flex;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 
        0 40px 100px rgba(0, 0, 0, 0.95),
        0 0 35px rgba(218, 165, 32, 0.18),
        0 0 70px rgba(180, 100, 40, 0.1);
    border-radius: 6px;
    /* initial rotation to show some 3D */
    transform: rotateX(10deg);
}

.left-side, .right-side {
    width: 50%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.left-side {
    transition: opacity 0.3s ease;
}

.book-cover-back {
    position: absolute;
    width: 100%; height: 100%;
    background: #150a06;
    border-radius: 12px 0 0 12px;
    border: 2px solid #2a150d;
    border-right: none;
    box-shadow: inset -10px 0 30px rgba(0,0,0,0.9);
}

.page {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    border-radius: 0 10px 10px 0;
}

.front, .back {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    overflow: hidden;
}

.front {
    background: #fbf8ef;
    background-image: linear-gradient(90deg, rgba(0,0,0,0.15) 0%, rgba(255,255,255,0) 8%);
    color: #111;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    border-radius: 0 10px 10px 0;
    border-left: 1px solid rgba(0,0,0,0.1);
    box-shadow: inset 10px 0 20px rgba(0,0,0,0.03);
}

.back {
    background: #f2ecd9;
    transform: rotateY(180deg);
    border-radius: 10px 0 0 10px;
    background-image: linear-gradient(270deg, rgba(0,0,0,0.15) 0%, rgba(255,255,255,0) 8%);
    box-shadow: inset -10px 0 20px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 2.5rem;
}

/* Left Page Title Block on Spread */
.left-page-title-block {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 85%;
    pointer-events: none;
    user-select: none;
}

.left-page-accent {
    color: #bfa15f;
    font-size: 1.1rem;
    margin-bottom: 0.9rem;
    opacity: 0.9;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.left-page-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    font-weight: 700;
    color: #2b1208;
    letter-spacing: clamp(2px, 0.25vw, 3.5px);
    line-height: 1.35;
    text-transform: uppercase;
    margin: 0;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.6));
}

.left-page-rule {
    width: 50px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(191, 161, 95, 0.85), transparent);
    margin: 1.1rem 0;
}

.left-page-subtitle {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.72rem, 0.95vw, 0.86rem);
    font-variant: small-caps;
    text-transform: uppercase;
    letter-spacing: clamp(3px, 0.35vw, 5px);
    color: #845f3e;
    font-weight: 600;
    line-height: 1.55;
    margin: 0;
}

/* Texture for paper */
.back-design, .front::before {
    content: '';
    position: absolute;
    top:0; left:0; right:0; bottom:0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.06'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.front > * {
    position: relative;
    z-index: 1;
}

/* The actual Luxury Hardcover Book Cover */
.cover .front {
    padding: 2.5rem;
    overflow: hidden;
    background: radial-gradient(circle at 45% 35%, #2c120a 0%, #170904 60%, #0c0402 100%);
    border-radius: 0 12px 12px 0;
    border: 2px solid #5a3219;
    border-left: none;
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.95),
        inset 15px 0 35px rgba(0, 0, 0, 0.9),
        inset 0 0 60px rgba(0, 0, 0, 0.7),
        0 0 30px rgba(255, 200, 100, 0.12);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Subtle leather texture for front cover */
.cover .front::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.02) 0%, transparent 100%),
        url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

/* Specular gold sheen catching the light */
.cover .front::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,225,120,0.14) 0%, rgba(255,255,255,0.02) 40%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
    border-radius: 0 10px 10px 0;
    z-index: 3;
}

/* Filigree SVG covering the frame */
.cover-filigree-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

/* Centered content */
.cover-content {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 90%;
    gap: 1.2rem;
}

.cover-badge {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #e6ca65;
    letter-spacing: 4px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.9));
    opacity: 0.9;
}

.cover-title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, 
        #bf953f 0%, 
        #fcf6ba 25%, 
        #b38728 50%, 
        #fbf5b7 75%, 
        #aa771c 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.95))
            drop-shadow(0 0 20px rgba(212, 175, 55, 0.35));
}

.cover-title .title-shri {
    font-size: clamp(2rem, 3.8vw, 3.4rem);
    letter-spacing: clamp(8px, 1.4vw, 14px);
}

.cover-title .title-neem {
    font-size: clamp(2.4rem, 4.4vw, 3.8rem);
    letter-spacing: clamp(6px, 1.2vw, 10px);
}

.cover-title .title-babaji {
    font-size: clamp(2.2rem, 4vw, 3.6rem);
    letter-spacing: clamp(8px, 1.3vw, 12px);
}

.cover-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 65%;
    max-width: 320px;
    margin: 0.5rem 0 0.8rem;
}

.cover-divider .divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.8), transparent);
}

.cover-divider .divider-diamond {
    color: #e6ca65;
    font-size: 1rem;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

.scroll-instruction {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    font-weight: 600;
    letter-spacing: 5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #d4af37 0%, #fff2a3 50%, #aa771c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.9));
    animation: gold-pulse 3s ease-in-out infinite;
}

@keyframes gold-pulse {
    0%, 100% {
        opacity: 0.85;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(3px);
        filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 12px rgba(255, 215, 0, 0.6));
    }
}

.page h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    margin: 0.5rem 0 2rem;
    color: #2b1208;
    text-align: center;
    letter-spacing: 2px;
}

.img-container {
    width: 100%;
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    background: #000;
    /* Optional elegant border for images */
    border: 4px solid #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.img-container picture {
    display: block;
    width: 100%;
    height: 100%;
}

.img-container img,
.img-container picture img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* User requested NOT to crop */
    display: block;
    pointer-events: auto;
    background: #0a0604; /* avoids white flash while loading */
    -webkit-user-drag: none;
    user-select: none;
}

/* Opacity-only hover affordance (Dark overlay + expand icon; NEVER transform/scale to prevent flicker & animation conflicts) */
.img-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.35);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6'/%3E%3Cpath d='M9 21H3v-6'/%3E%3Cpath d='M21 3l-7 7'/%3E%3Cpath d='M3 21l7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 28px 28px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none; /* Mouse/touch clicks pass directly through to container */
    z-index: 2;
}

.img-container:hover::after {
    opacity: 1;
}

/* Hide hover overlay when cinematic animation is active */
.img-container.cinematic-target::after,
body.cinematic-active .img-container::after {
    display: none !important;
}

/* Book spine shading */
.book::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 60px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, rgba(0,0,0,0.8) 0%, rgba(255,255,255,0.05) 20%, rgba(0,0,0,0.2) 50%, rgba(255,255,255,0.05) 80%, rgba(0,0,0,0.8) 100%);
    z-index: 100;
    pointer-events: none;
    opacity: var(--spine-opacity, 0);
    transition: opacity 0.4s ease;
}

/* Lightbox Styles - Single Reusable Overlay */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    overflow: hidden;
    touch-action: manipulation;
}

.lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0,0,0,0.95);
    user-select: none;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 3rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10000;
    transition: color 0.3s ease, transform 0.2s ease;
    user-select: none;
    touch-action: manipulation;
}

.lightbox-close:hover {
    color: #dfb15b;
    transform: scale(1.1);
}



/* Narrate Button */
.narrate-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #dfb15b;
    border: 2px solid #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    cursor: pointer;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s, background 0.3s;
}

/* Keyboard accessibility — visible focus ring for interactive controls */
.narrate-btn:focus-visible,
.lightbox-close:focus-visible {
    outline: 2px solid #dfb15b;
    outline-offset: 3px;
    border-radius: 50%;
}

.lightbox-close:focus-visible {
    border-radius: 4px;
}

.narrate-btn:hover {
    transform: scale(1.1);
    background: #e5c175;
}

.narrate-btn.playing {
    animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(223, 177, 91, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(223, 177, 91, 0); }
    100% { box-shadow: 0 0 0 0 rgba(223, 177, 91, 0); }
}

/* Cinematic Mode Styles */
body.cinematic-active {
    overflow: hidden !important; /* Disable scrolling during cinematic */
}

body.cinematic-active .scroll-container {
    pointer-events: none;
}

body.cinematic-active .book-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 999;
    animation: fadeIn 1s forwards;
}

.img-container.cinematic-target {
    position: relative;
    z-index: 1000 !important;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.4);
    border: 4px solid #dfb15b;
}

.img-container.cinematic-target img {
    transition: transform 2s ease-in-out, transform-origin 2s ease-in-out !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* SEO/GEO/AEO text fallback — crawlable, off-screen, never display:none (Google discounts it) */
.seo-fallback {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
/* If JS fails, show fallback as normal content */
noscript .seo-fallback {
    position: static;
    width: auto;
    height: auto;
    margin: 2rem auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    max-width: 720px;
    padding: 2rem;
    background: #fbf8ef;
    color: #2b1208;
    border-radius: 8px;
}

/* Guide Instruction Text Below Each Comic Panel */
.scene-instruction {
    margin-top: 14px;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.68rem, 0.8vw, 0.78rem);
    color: #845f3e;
    text-align: center;
    max-width: 90%;
    line-height: 1.5;
    letter-spacing: 0.8px;
    font-weight: 600;
    user-select: none;
    opacity: 0.88;
    position: relative;
    z-index: 1;
}

/* ==========================================
   RESPONSIVE — phones / tablets / short screens
   ========================================== */

/* Tablet portrait + large phones */
@media (max-width: 1024px) {
    .book {
        width: 94vw;
        height: 82vh;
        height: 82dvh;
    }
    .front { padding: 1.5rem; }
    .back { padding: 2rem 1.5rem; }
}

/* Phones (portrait) — spread must fit narrow viewport */
@media (max-width: 768px) {
    .book-wrapper {
        perspective: 1800px;
        padding: 0 2vw;
    }
    .book {
        width: 96vw;
        height: 76vh;
        height: 76dvh;
        max-height: none;
        transform: rotateX(4deg);
    }
    /* Spine shadow narrower on small spread */
    .book::after { width: 30px; }
    .front { padding: 0.9rem; border-radius: 0 8px 8px 0; }
    .back { padding: 1.2rem 0.9rem; border-radius: 8px 0 0 8px; }
    .img-container { border-width: 2px; }
    .cover-content { gap: 0.8rem; max-width: 94%; }
    .cover-badge { font-size: 1.1rem; }
    .cover-title .title-shri { font-size: clamp(1.4rem, 8vw, 2rem); letter-spacing: 6px; }
    .cover-title .title-neem { font-size: clamp(1.6rem, 9vw, 2.4rem); letter-spacing: 4px; }
    .cover-title .title-babaji { font-size: clamp(1.5rem, 8.5vw, 2.2rem); letter-spacing: 5px; }
    .scroll-instruction { font-size: 0.72rem; letter-spacing: 3px; }
    .left-page-title { font-size: clamp(1rem, 4.5vw, 1.3rem); }
    .left-page-subtitle { font-size: 0.62rem; letter-spacing: 2px; }
    .scene-instruction { font-size: 0.62rem; margin-top: 8px; letter-spacing: 0.4px; }
    .page h2 { font-size: 1.4rem; margin: 0.4rem 0 1rem; }
    /* Softer float on small screens (less motion sickness + GPU) */
    @keyframes antigravity-float {
        0%, 100% { transform: translateY(0px); }
        50% { transform: translateY(-8px); }
    }
    /* Buttons reachable + above mobile browser chrome */
    .narrate-btn {
        width: 52px; height: 52px;
        bottom: calc(18px + env(safe-area-inset-bottom));
        right: calc(16px + env(safe-area-inset-right));
    }
    .lightbox-close {
        top: calc(10px + env(safe-area-inset-top));
        right: 18px;
        font-size: 2.6rem;
        padding: 8px;
    }
    .lightbox img { max-width: 96vw; max-height: 86vh; max-height: 86dvh; }
}

/* Small phones */
@media (max-width: 480px) {
    .book { height: 72vh; height: 72dvh; }
    .front { padding: 0.6rem; }
    .back { padding: 1rem 0.6rem; }
    .cover-divider { width: 80%; }
}

/* Touch devices — no hover overlay (prevents stuck highlight), keep tap affordance */
@media (hover: none) {
    .img-container:hover::after { opacity: 0; }
}

/* Short landscape (phones rotated) — height is the constraint */
@media (max-height: 500px) {
    .book {
        width: auto;
        aspect-ratio: 16 / 10;
        height: 92vh;
        height: 92dvh;
        max-width: 96vw;
    }
    .front { padding: 0.8rem; }
    .back { padding: 1rem; }
    .scene-instruction { display: none; }
    .narrate-btn { width: 46px; height: 46px; bottom: 12px; right: 12px; }
}

/* Reduced motion — respect OS setting */
@media (prefers-reduced-motion: reduce) {
    .floating-anchor { animation: none; }
    .scroll-instruction { animation: none; }
}

