/* ==========================================================================
   3D MAGAZINE EXPERIENCE
   ========================================================================== */

/* Intro Screen */
#intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 1s ease, visibility 1s ease;
}

.intro-logo {
    font-family: var(--font-heading);
    font-size: clamp(4rem, 15vw, 15rem);
    color: #111;
    margin: 0;
    line-height: 1;
}

.intro-loading {
    font-family: var(--font-body);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #666;
    margin-top: 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Magazine Scene */
#magazine-scene {
    width: 100vw;
    height: 100vh;
    perspective: 2500px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f7f7f7;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9000;
}

.magazine-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    /* Will be scaled by GSAP */
}

.magazine {
    aspect-ratio: 3 / 4;
    height: clamp(450px, 85vh, 900px);
    width: auto;
    position: relative;
    transform-style: preserve-3d;
    /* Simulate lying on a table slightly angled */
    transform: rotateX(15deg) rotateY(-10deg) rotateZ(2deg);
    box-shadow: 30px 40px 80px rgba(0,0,0,0.25);
    transition: box-shadow 0.5s ease;
}

/* Pages */
.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    background-color: #fff;
    /* Thick page borders */
    border-right: 2px solid #ddd;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

/* Z-translation to create physical thickness */
.page-cover { transform: translateZ(6px); z-index: 10; }
.page-2 { transform: translateZ(4px); z-index: 9; }
.page-3 { transform: translateZ(2px); z-index: 8; }
.page-backcover { transform: translateZ(0px); z-index: 7; }

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-color: #fff;
    overflow: hidden;
}

.back {
    transform: rotateY(180deg);
}

/* Spine */
.spine {
    position: absolute;
    top: 0;
    left: -15px; /* Adjust based on total thickness */
    width: 15px;
    height: 100%;
    background: linear-gradient(to right, #111, #444, #111);
    transform: rotateY(-90deg);
    transform-origin: right center;
    z-index: 1;
}

/* Textures & Lighting */
.paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
    opacity: 0.15;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 100;
}

.glossy-overlay {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(135deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    z-index: 50;
}

/* Dynamic shadows for inner crease */
.shadow-gradient-left {
    position: absolute;
    top: 0;
    right: 0;
    width: 15%;
    height: 100%;
    background: linear-gradient(to left, rgba(0,0,0,0.6), transparent);
    z-index: 40;
    pointer-events: none;
}

.shadow-gradient-right {
    position: absolute;
    top: 0;
    left: 0;
    width: 15%;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.6), transparent);
    z-index: 40;
    pointer-events: none;
}

/* Editorial Content Styles */
.cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
}

.cover-text {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    color: #fff;
    z-index: 5;
}

.cover-text h1 {
    font-family: var(--font-heading);
    font-size: 8rem;
    line-height: 0.8;
    margin: 0;
}

.cover-text p {
    font-family: var(--font-body);
    font-size: 0.9rem;
    letter-spacing: 0.2em;
    margin-top: 1rem;
}

.editorial-layout {
    padding: 3rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.editorial-layout.right-align {
    text-align: right;
    align-items: flex-end;
}

.editorial-title {
    font-family: var(--font-heading);
    font-size: clamp(3rem, 5vw, 6rem);
    line-height: 0.9;
    color: #111;
}

.editorial-body {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.6;
    color: #333;
    max-width: 90%;
}

.editorial-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
}

.portal-content {
    position: relative;
    width: 100%;
    height: 100%;
}

.portal-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) contrast(120%);
}

.portal-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.portal-text h1 {
    font-family: var(--font-heading);
    font-size: 4rem;
    color: #fff;
    line-height: 0.85;
}

/* Actual Website Container */
#actual-website {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    position: relative;
    z-index: 1;
    margin-top: -100vh; /* Pull it up to overlap the magazine scene */
}

#actual-website.visible {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 9999;
}
