/* ===== MAGAZINE FLIP STYLE ===== */
/* Simulates a real magazine page-by-page experience */

.catalog-magazine .catalog-brand {
    z-index: 1001;
}

.magazine-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
    position: relative;
    overflow: hidden;
}

/* Ambient glow */
.magazine-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.08) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.magazine-container {
    width: 100%;
    max-width: 460px;
    height: 85vh;
    max-height: 750px;
    position: relative;
    perspective: 1200px;
    margin: 30px auto;
}

.magazine-page {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    background: var(--section-bg);
    transform-origin: right center;
    transition: transform 0.65s cubic-bezier(0.4, 0.0, 0.2, 1),
        opacity 0.65s ease,
        box-shadow 0.65s ease;
    backface-visibility: hidden;
    overflow-y: auto;
    will-change: transform, opacity;
}

.magazine-page::-webkit-scrollbar {
    width: 4px;
}

.magazine-page::-webkit-scrollbar-track {
    background: transparent;
}

.magazine-page::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* ===== Page Fold States ===== */

/* Visible / active page */
.magazine-page.mag-visible {
    transform: perspective(1800px) rotateY(0deg) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Stacked behind (next pages not yet shown) */
.magazine-page.mag-stacked {
    transform: perspective(1800px) translateX(2%) scale(0.98);
    opacity: 0;
    pointer-events: none;
}

/* Folding out to the left — page curls like physically lifting and turning */
.magazine-page.mag-fold-out {
    transform: perspective(1800px) rotateY(55deg) translateX(-15%) scale(0.92);
    opacity: 0.3;
    pointer-events: none;
    box-shadow: 20px 10px 60px rgba(0, 0, 0, 0.6),
        inset -30px 0 40px rgba(0, 0, 0, 0.15);
}

/* Fully gone left (after turning) */
.magazine-page.mag-gone-left {
    transform: perspective(1800px) rotateY(90deg) translateX(-30%);
    opacity: 0;
    pointer-events: none;
    transition: none;
}

/* Fading in from stack (next page appearing) */
.magazine-page.mag-fade-in {
    transform: perspective(1800px) rotateY(0deg) scale(1);
    opacity: 1;
    pointer-events: none;
}

/* Fading back to stack (when going backwards) */
.magazine-page.mag-fade-back {
    transform: perspective(1800px) translateX(3%) scale(0.97);
    opacity: 0;
    pointer-events: none;
}

/* Unfolding back in from left (returning to view) */
.magazine-page.mag-unfold-in {
    transform: perspective(1800px) rotateY(0deg) scale(1);
    opacity: 1;
    pointer-events: none;
    box-shadow: 15px 8px 50px rgba(0, 0, 0, 0.5);
}

/* Page spine shadow on left edge */
.magazine-page.mag-visible::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 15px;
    height: 100%;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
    pointer-events: none;
    z-index: 100;
}

/* Page curl hint on right edge — subtle shadow showing the page can be turned */
.magazine-page.mag-visible::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 50px;
    height: 100%;
    background: linear-gradient(to left,
            rgba(0, 0, 0, 0.06) 0%,
            rgba(0, 0, 0, 0.03) 40%,
            transparent 100%);
    pointer-events: none;
    z-index: 100;
}

/* ===== Glossy Magazine Paper Shine ===== */
.page-shine {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 99;
    background: linear-gradient(110deg,
            transparent 35%,
            rgba(255, 255, 255, 0.03) 42%,
            rgba(255, 255, 255, 0.07) 50%,
            rgba(255, 255, 255, 0.03) 58%,
            transparent 65%);
    transition: opacity 0.5s ease;
}

/* Sweeping shine during page turn */
.page-shine.shine-sweep {
    animation: shineSweep 0.65s ease-out forwards;
}

@keyframes shineSweep {
    0% {
        opacity: 1;
        background: linear-gradient(110deg,
                transparent 35%,
                rgba(255, 255, 255, 0.03) 42%,
                rgba(255, 255, 255, 0.07) 50%,
                rgba(255, 255, 255, 0.03) 58%,
                transparent 65%);
    }

    40% {
        opacity: 1;
        background: linear-gradient(110deg,
                transparent 10%,
                rgba(255, 255, 255, 0.2) 25%,
                rgba(255, 255, 255, 0.4) 40%,
                rgba(255, 255, 255, 0.2) 55%,
                transparent 70%);
    }

    100% {
        opacity: 0;
        background: linear-gradient(110deg,
                transparent 0%,
                rgba(255, 255, 255, 0.1) 10%,
                rgba(255, 255, 255, 0.0) 30%,
                transparent 50%);
    }
}

/* ===== Cover inside magazine ===== */
.magazine-page .cover-page {
    min-height: 100%;
    border-radius: 12px;
}

.magazine-page .cover-title {
    font-size: clamp(22px, 5vw, 38px);
    padding: 0 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.magazine-page .cover-subtitle {
    font-size: clamp(13px, 2.5vw, 17px);
    max-width: 90%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* ===== Article inside magazine ===== */
.magazine-page .article-page {
    border-radius: 12px;
}

.magazine-page .article-title {
    font-size: clamp(18px, 3.5vw, 26px);
    text-align: center;
    padding: 0 10px;
}

.magazine-page .article-image-full {
    max-height: 40%;
}

.magazine-page .article-text-area {
    padding: 20px 16px;
}

.magazine-page .article-content {
    font-size: 14px;
    line-height: 1.6;
}

/* ===== Catalog inside magazine ===== */
.magazine-page .catalog-page {
    padding: 14px 10px;
    padding-bottom: 50px;
}

/* Remove default catalog-page backdrop inside magazine, use a better one */
.magazine-page .catalog-page::before {
    background: rgba(0, 0, 0, 0.45);
}

.magazine-page .catalog-section-title {
    font-size: clamp(16px, 3vw, 22px);
    margin-bottom: 4px;
    padding: 0 4px;
}

.magazine-page .catalog-section-subtitle {
    font-size: 12px;
    margin-bottom: 10px;
    padding: 0 8px;
}

.magazine-page .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.magazine-page .product-card {
    background: var(--product-bg, rgba(0, 0, 0, 0.55));
    backdrop-filter: blur(10px);
    border-color: var(--product-border, rgba(255, 255, 255, 0.12));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.magazine-page .product-image {
    height: 60px;
}

.magazine-page .product-info {
    padding: 6px;
}

.magazine-page .product-category {
    font-size: 9px;
    letter-spacing: 0.5px;
}

.magazine-page .product-name {
    font-size: 11px;
    margin: 2px 0 4px;
    color: var(--product-name-color, #fff);
}

/* Hide description inside magazine to save space */
.magazine-page .product-desc {
    display: none;
}

.magazine-page .product-price {
    font-size: 13px;
}

.magazine-page .product-details {
    font-size: 9px;
    gap: 3px;
    margin-bottom: 4px;
    color: var(--product-details-color, rgba(255, 255, 255, 0.6));
}

/* List format inside magazine — compact for 2-col */
.magazine-page .products-list .list-category-group {
    margin-bottom: 8px;
}

.magazine-page .products-list .list-category-title {
    font-size: 13px;
    padding: 6px 10px;
    background: var(--category-bg, rgba(0, 0, 0, 0.6));
    color: var(--category-title-color, #fff);
    margin-bottom: 4px;
}

.magazine-page .products-list .list-product-row {
    padding: 6px 8px;
    gap: 8px;
    background: var(--list-row-bg, rgba(0, 0, 0, 0.5));
    border-radius: 6px;
    margin-bottom: 2px;
}

.magazine-page .products-list .list-product-img {
    width: 30px;
    height: 30px;
    border-radius: 6px;
}

.magazine-page .products-list .list-product-info h4 {
    font-size: 12px;
    color: var(--product-name-color, #fff);
}

.magazine-page .products-list .list-product-info p {
    font-size: 10px;
    color: var(--product-desc-color, rgba(255, 255, 255, 0.75));
}

.magazine-page .products-list .list-product-price {
    font-size: 13px;
}

.magazine-page .products-list .list-meta {
    font-size: 10px;
}

/* Compact inside magazine */
.magazine-page .products-compact {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.magazine-page .compact-card {
    background: var(--product-bg, rgba(0, 0, 0, 0.55));
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.magazine-page .compact-card img {
    height: 60px;
}

.magazine-page .compact-card .compact-info {
    padding: 6px;
}

.magazine-page .compact-card .compact-info h4 {
    font-size: 11px;
    color: var(--product-name-color, #fff);
}

.magazine-page .compact-card .compact-dosage {
    font-size: 9px;
}

.magazine-page .compact-card .compact-price {
    font-size: 13px;
}

/* Navigation */
.magazine-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 30px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    border-radius: 50px;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0.55;
    transition: opacity 0.3s ease;
}

.magazine-nav:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.4);
}

.mag-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mag-nav-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

.mag-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mag-nav-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.mag-page-info {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

/* Swipe indicator */
.magazine-page.mag-visible .cover-overlay::after {
    content: '← Deslize para navegar →';
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    animation: pulse 2s ease infinite;
    white-space: nowrap;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

/* Desktop: widen */
@media (min-width: 769px) {
    .magazine-container {
        max-width: 520px;
        max-height: 800px;
    }
}

/* Large desktop: book spread */
@media (min-width: 1200px) {
    .magazine-container {
        max-width: 560px;
        height: 88vh;
        max-height: 880px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .magazine-container {
        max-width: 100%;
        height: 80vh;
        margin: 10px;
        border-radius: 16px;
    }

    .magazine-page {
        border-radius: 16px;
    }

    .magazine-nav {
        bottom: 16px;
        padding: 12px 20px;
        gap: 14px;
    }

    .mag-nav-btn {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .magazine-page .catalog-page {
        padding: 14px 10px;
        padding-bottom: 50px;
    }

    .magazine-page .catalog-section-title {
        font-size: clamp(16px, 4vw, 22px);
    }

    .magazine-page .catalog-section-subtitle {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .magazine-page .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .magazine-page .product-image {
        height: 80px;
    }

    .magazine-page .product-info {
        padding: 8px;
    }

    .magazine-page .product-name {
        font-size: 12px;
    }

    .magazine-page .product-desc {
        font-size: 10px;
    }

    .magazine-page .product-price {
        font-size: 13px;
    }

    .magazine-page .product-details {
        font-size: 10px;
        gap: 4px;
    }

    /* List inside magazine mobile */
    .magazine-page .products-list .list-category-title {
        font-size: 14px;
        padding: 8px 10px;
    }

    .magazine-page .products-list .list-product-row {
        padding: 8px 8px;
        gap: 8px;
    }

    .magazine-page .products-list .list-product-img {
        width: 36px;
        height: 36px;
        border-radius: 6px;
    }

    .magazine-page .products-list .list-product-info h4 {
        font-size: 12px;
    }

    .magazine-page .products-list .list-product-info p {
        font-size: 10px;
    }

    .magazine-page .products-list .list-product-price {
        font-size: 13px;
    }

    /* Compact inside magazine mobile */
    .magazine-page .compact-card .compact-info {
        padding: 6px;
    }

    .magazine-page .compact-card .compact-info h4 {
        font-size: 11px;
    }

    .magazine-page .compact-card .compact-price {
        font-size: 12px;
    }

    /* Article inside magazine mobile */
    .magazine-page .article-title {
        font-size: clamp(16px, 4vw, 22px);
    }

    .magazine-page .article-content {
        font-size: 13px;
    }

    .magazine-page .cover-title {
        font-size: clamp(20px, 5vw, 32px);
    }

    .magazine-page .cover-subtitle {
        font-size: clamp(12px, 2.5vw, 16px);
    }
}

@media (max-width: 480px) {
    .magazine-container {
        height: 78vh;
        margin: 6px;
        border-radius: 12px;
    }

    .magazine-page {
        border-radius: 12px;
    }

    .magazine-nav {
        bottom: 10px;
        padding: 10px 16px;
        gap: 10px;
    }

    .mag-nav-btn {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .mag-page-info {
        font-size: 12px;
    }

    .magazine-page .catalog-page {
        padding: 10px 8px;
        padding-bottom: 46px;
    }

    .magazine-page .products-list .list-product-img {
        display: none;
    }

    .magazine-page .products-list .list-product-row {
        grid-template-columns: 1fr auto;
    }
}

@media (max-width: 400px) {
    .magazine-page .products-grid {
        grid-template-columns: 1fr;
    }
}