/* ============================================================
   Pirate Piggies — Dedicated Character Story Page
   Layout: full-page, no 3D wrapper, no overlay issues
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;600&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background: #050e1a;
    color: #fff;
}

/* ── Background ── */
.pp-bg {
    position: fixed;
    inset: -2%;
    background: url('../img/BG_CARDS.webp') no-repeat center center;
    background-size: cover;
    z-index: 0;
    pointer-events: none;
}

.pp-bg-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.75) 100%);
    z-index: 1;
    pointer-events: none;
}

/* ── Bubbles ── */
.pp-bubbles {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.pp-bubble {
    position: absolute;
    bottom: -60px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.45), rgba(180,220,255,0.08) 60%, transparent);
    border: 1px solid rgba(255,255,255,0.18);
    animation: ppBubbleRise linear infinite;
    will-change: transform, opacity;
}

@keyframes ppBubbleRise {
    0%   { transform: translateY(0) translateX(0) scale(1);    opacity: 0.7; }
    50%  { transform: translateY(-45vh) translateX(var(--drift)) scale(1.04); opacity: 0.5; }
    100% { transform: translateY(-105vh) translateX(calc(var(--drift)*1.6)) scale(0.95); opacity: 0; }
}

/* ── Contact navigation (Imagine Logo) ── */
.contact-nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 3vw 5vw;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none; /* Let clicks pass through empty header area */
}

.contact-nav * {
    pointer-events: auto; /* Re-enable clicks for logo and links */
}

.contact-nav .contact-logo {
    max-width: 140px;
    opacity: 0.95;
    transition: opacity 0.3s ease;
}

.contact-nav .contact-logo:hover {
    opacity: 1;
}

/* ── Main layout ── */
.pp-main {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    gap: 5rem;
    padding: 0 4rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ── Portrait side ── */
.pp-portrait-side {
    flex: 1.2;
    max-width: 580px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1; /* Keep portrait side below the interactive content side */
    perspective: 1200px;
    transform-style: preserve-3d;
    --brushstroke-x: 0px;
    --brushstroke-y: 0px;
    pointer-events: none; /* Allow clicks to pass through to the menu buttons on smaller screens */
}

.pp-brushstroke {
    position: absolute;
    top: -20%;
    left: -30%;
    width: 160%;
    height: 140%;
    background: url('../img/BG PINCELADAS.webp') no-repeat center center;
    background-size: contain;
    opacity: 0.95;
    z-index: 1;
    pointer-events: none;
    transform: translate3d(var(--brushstroke-x), var(--brushstroke-y), -30px) rotateY(-5deg);
    will-change: transform;
}

.pp-portrait-img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: auto;
    max-height: 82vh;
    object-fit: contain;
    filter: drop-shadow(0 15px 35px rgba(0,0,0,0.65));
    transform: translateZ(80px);
    will-change: transform;
    pointer-events: none; /* Prevent the image from blocking clicks on the menu */
}

/* ── Content side ── */
.pp-content-side {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    position: relative;
    z-index: 100; /* Stack completely on top of all background/portrait elements */
}

/* ── Character icon menu ── */
.pp-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0.3rem 0.6rem;
    width: 100%;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 20; /* Keep on top of overlapping portrait side */
}

.pp-menu-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.3rem 0.4rem;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.16,1,0.3,1),
                filter 0.3s ease,
                border-color 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.pp-menu-btn img {
    height: 100px;
    width: auto;
    display: block;
    object-fit: contain;
    filter: grayscale(0.6) brightness(0.7);
    transition: filter 0.3s ease, transform 0.3s cubic-bezier(0.16,1,0.3,1);
}

.pp-menu-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: #D4AF37;
    transition: width 0.3s cubic-bezier(0.16,1,0.3,1);
}

.pp-menu-btn:hover img {
    filter: grayscale(0) brightness(1);
    transform: scale(1.05) translateY(-2px);
}

.pp-menu-btn.active img {
    filter: grayscale(0) brightness(1.1);
    transform: scale(1.08) translateY(-3px);
}

.pp-menu-btn.active::after {
    width: 70%;
}

.pp-name-img {
    max-width: 504px;
    width: auto;
    height: 90px; /* Fixed height to prevent vertical shifts */
    object-fit: contain;
    display: block;
    margin: 0 auto 1.5rem;
}

/* ── Story carousel ── */
.pp-carousel {
    width: 100%;
    max-width: 520px;
    height: 280px; /* Increased height to comfortably fit all story texts without clipping */
    position: relative;
    overflow: hidden;
}

.pp-cards-track {
    width: 100%;
    height: 100%;
    position: relative;
}

.pp-card {
    width: 100%;
    height: 100%;
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(10px);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: opacity, transform;
}

.pp-card.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.pp-card p {
    font-size: 1.15rem;
    font-weight: 300;
    line-height: 1.7;
    color: rgba(255,255,255,0.88);
    text-align: center;
    font-style: italic;
    text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}

/* ── Navigation controls ── */
.pp-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 520px;
    margin-top: 2rem;
    position: relative;
    z-index: 20; /* Keep on top of overlapping portrait side */
}

.pp-nav-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.25s ease, opacity 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pp-nav-btn img {
    height: 51px;
    width: auto;
    display: block;
    object-fit: contain;
}

.pp-nav-btn:hover {
    transform: scale(1.08);
}

.pp-nav-btn:disabled,
.pp-nav-btn.pp-dimmed {
    opacity: 0.3;
    cursor: default;
    transform: none;
}

/* ── Dots ── */
.pp-dots {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.3s ease, transform 0.3s ease;
}

.pp-dot.active {
    background: #D4AF37;
    transform: scale(1.35);
}

/* ── Character switch transition ── */
.pp-content-side.switching .pp-name-img,
.pp-content-side.switching .pp-carousel {
    opacity: 0;
    transform: translateY(6px);
}

.pp-name-img,
.pp-carousel {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ── Portrait transition ── */
.pp-portrait-img {
    transition: opacity 0.35s ease;
}

.pp-portrait-img.fading {
    opacity: 0;
}

/* ── Decorative Barrels ── */
.pp-decor-barrel {
    position: absolute;
    height: auto;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.6));
    will-change: transform;
}
.pp-decor-barrel.barrel-1 {
    left: -30%;
    bottom: -5%;
    width: 216px;
    animation: ppBarrelFloat1 9s ease-in-out infinite;
    z-index: 4; /* Explicitly on top of barrel-2 */
}

.pp-decor-barrel.barrel-2 {
    left: -48%;
    bottom: 25%;
    width: 158px;
    animation: ppBarrelFloat2 11s ease-in-out infinite;
    animation-delay: -3.5s;
    opacity: 0.9;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5)) blur(1px);
    z-index: 2; /* Behind barrel-1 */
}


@keyframes ppBarrelFloat1 {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-45px) rotate(-8deg);
    }
    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

@keyframes ppBarrelFloat2 {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-35px) rotate(7deg);
    }
    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

@keyframes ppBarrelFloatMobile1 {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-25px) rotate(-6deg);
    }
    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

@keyframes ppBarrelFloatMobile2 {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(5deg);
    }
    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

/* ── Falling Coins ── */
.pp-coins-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.pp-coin-wrapper {
    position: absolute;
    top: -120px;
    will-change: transform;
    animation: ppCoinFall linear infinite;
}

.pp-coin-inner {
    display: block;
    height: auto;
    will-change: transform;
    animation: ppCoinSway ease-in-out infinite alternate;
}

@keyframes ppCoinFall {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(calc(100vh + 150px));
    }
}

@keyframes ppCoinSway {
    0% {
        transform: translateX(0) rotate(0deg);
    }
    100% {
        transform: translateX(var(--sway-drift, 20px)) rotate(var(--sway-rotate, 360deg));
    }
}

/* ── CTA Image Button ── */
.pp-cta-btn-img {
    display: inline-block;
    margin-top: 2.5rem;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    max-width: 270px;
    animation: ppFloatSubmerged 6s ease-in-out infinite;
    will-change: transform;
    position: relative;
    z-index: 20; /* Keep on top of overlapping portrait side */
}

@keyframes ppFloatSubmerged {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    33% {
        transform: translateY(-6px) rotate(0.8deg);
    }
    66% {
        transform: translateY(4px) rotate(-0.8deg);
    }
    100% {
        transform: translateY(0) rotate(0deg);
    }
}

.pp-cta-btn-img img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 4px 15px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), filter 0.3s ease;
}

.pp-cta-btn-img:hover img {
    transform: scale(1.04) rotate(-1deg);
    filter: drop-shadow(0 8px 25px rgba(212, 175, 55, 0.35)) brightness(1.05);
}

.pp-cta-btn-img:active img {
    transform: scale(0.98);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .pp-main {
        gap: 3rem;
        padding: 0 2.5rem;
    }
    .pp-portrait-side {
        max-width: 440px;
    }
    .pp-menu-btn img {
        height: 80px;
    }
    .pp-name-img {
        max-width: 408px;
    }
    .pp-decor-barrel.barrel-1 {
        width: 173px;
        left: -25%;
    }
    .pp-decor-barrel.barrel-2 {
        width: 122px;
        left: -40%;
        bottom: 25%;
    }
}

@media (max-width: 800px) {
    .contact-nav {
        position: absolute;
        justify-content: center;
        padding: 6vw 8vw;
    }
    html, body {
        overflow: auto;
    }
    .pp-main {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 5rem 1.5rem 3rem;
        gap: 1.5rem;
    }
    .pp-portrait-side {
        max-width: 320px;
        width: 80%;
    }
    .pp-brushstroke {
        opacity: 0.5;
    }
    .pp-portrait-img {
        max-height: 42vh;
    }
    .pp-content-side {
        width: 100%;
    }
    .pp-carousel {
        height: 260px; /* Responsive fixed height for mobile wrapped text */
    }
    .pp-menu-btn img {
        height: 64px;
    }
    .pp-name-img {
        max-width: 312px;
        height: 60px; /* Responsive fixed height for mobile */
        margin-bottom: 1rem;
    }
    .pp-card p {
        font-size: 1rem;
    }
    .pp-nav-btn img {
        height: 41px;
    }
    .pp-cta-btn-img {
        margin: 2.2rem auto 0;
        max-width: 215px;
    }
    .pp-decor-barrel.barrel-1 {
        width: 130px;
        left: -15%;
        bottom: -2%;
        animation: ppBarrelFloatMobile1 9s ease-in-out infinite;
    }
    .pp-decor-barrel.barrel-2 {
        width: 94px;
        left: -25%;
        bottom: 20%;
        animation: ppBarrelFloatMobile2 11s ease-in-out infinite;
        animation-delay: -3.5s;
    }
}
