/* =====================================================
   PAGINA DI BENVENUTO - UNDERWATER EXPERIENCE
   ===================================================== */

/* Layout di base */
html {
    height: -webkit-fill-available;
    /* Fix per nascondere la barra Safari su iOS senza fullscreen API */
    height: 100%;
    width: 100%;
    position: fixed;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    width: 100vw;
    overflow: hidden;
    /* Fix per iOS: impedisce scroll ma permette alla barra di nascondersi */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Gradiente animato di backup con complementari */
    background: linear-gradient(
        135deg,
        #FFA742 0%,      /* Arancione chiaro */
        #F19628 25%,     /* Arancione principale */
        #088395 50%,     /* Teal principale */
        #00bcd4 75%,     /* Cyan */
        #FFA742 100%     /* Arancione chiaro (loop) */
    );
    background-size: 400% 400%;
    animation: underwaterFlow 20s ease infinite;
}

.ctaDiv {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: transparent; /* FIX CRITICO: trasparente per vedere il gradiente */
    z-index: 99;
}

/* =====================================================
   CONTAINER PRINCIPALE CON EFFETTO GLASS
   ===================================================== */

#startARDiv {
    /* FIX CRITICO: position fixed per coprire tutto il viewport */
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    /* Gradiente animato fluido - colori complementari underwater sunset */
    background: linear-gradient(
        135deg,
        #FFA742 0%,      /* Arancione chiaro */
        #F19628 25%,     /* Arancione principale */
        #088395 50%,     /* Teal principale */
        #00bcd4 75%,     /* Cyan */
        #FFA742 100%     /* Arancione chiaro (loop) */
    );
    background-size: 400% 400%;
    animation: underwaterFlow 20s ease infinite;
    overflow: hidden;
}

/* Animazione gradiente fluido */
@keyframes underwaterFlow {
    0% { background-position: 100% 50%; }
    25% { background-position: 50% 20%; }
    50% { background-position: 0% 50%; }
    75% { background-position: 50% 80%; }
    100% { background-position: 100% 50%; }
}

/* Overlay radiale pulsante per profondità con complementari */
#startARDiv::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(255, 167, 66, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(0, 188, 212, 0.2) 0%, transparent 50%);
    animation: waveShift 15s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes waveShift {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

.welcome-container {
    position: relative;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 30px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    padding: 50px 30px 40px 30px;
    max-width: 380px;
    width: 70%;
    min-height: 70vh;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 4px 16px rgba(255, 167, 66, 0.2),
        0 2px 8px rgba(0, 217, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-align: center;
    z-index: 1;
    animation: cardSlideUp 1s ease backwards;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smartphone in portrait */
@media (max-width: 600px) {
    .welcome-container {
        padding: 40px 25px 35px 25px;
        width: 75%;
        min-height: 65vh;
    }
}

/* Schermi bassi (landscape o device piccoli) */
@media (max-height: 700px) {
    .welcome-container {
        padding: 35px 25px 30px 25px;
        min-height: 60vh;
    }
}

/* Tablet */
@media (min-width: 601px) and (max-width: 1024px) {
    .welcome-container {
        padding: 45px 30px 38px 30px;
        width: 68%;
        max-width: 450px;
    }
}

/* =====================================================
   LOGO PEPO ANIMATO
   ===================================================== */

.pepo-logo {
    width: 150px;
    height: auto;
    margin: 0 auto 20px; /* Logo resta dentro il container senza uscire */
}

.pepo-logo img {
    width: 100%;
    height: auto;
    object-fit: contain;
    animation: logoFloat 3s ease-in-out infinite, logoGlow 4s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(0, 217, 255, 0.7))
            drop-shadow(0 0 15px rgba(255, 167, 66, 0.4));
}

@keyframes logoGlow {
    0%, 100% {
        filter: drop-shadow(0 0 30px rgba(0, 217, 255, 0.7))
                drop-shadow(0 0 15px rgba(255, 167, 66, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 40px rgba(0, 217, 255, 0.9))
                drop-shadow(0 0 25px rgba(255, 167, 66, 0.6));
    }
}

@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0) rotate(-5deg);
    }
    50% {
        transform: translateY(-15px) rotate(5deg);
    }
}

/* Responsive logo size */
@media (max-width: 600px) {
    .pepo-logo {
        width: 120px;
        margin: 0 auto 15px;
    }
}

@media (max-height: 700px) {
    .pepo-logo {
        width: 100px;
        margin: 0 auto 12px;
    }
}

/* =====================================================
   TESTI - TITOLO E SOTTOTITOLO
   ===================================================== */

.title-main {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 20px 0;
    background: linear-gradient(135deg, #ffffff 0%, #FFA742 50%, #00d9ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleFadeIn 1s ease 0.5s backwards, titleShimmer 6s ease-in-out infinite;
    text-shadow: 0 0 30px rgba(255, 167, 66, 0.4);
    font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
    line-height: 1.1;
    width: 100%;
}

@keyframes titleShimmer {
    0%, 100% {
        filter: brightness(1) saturate(1);
    }
    50% {
        filter: brightness(1.2) saturate(1.3);
    }
}

@keyframes titleFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 600px) {
    .title-main {
        font-size: 2rem;
        margin-bottom: 15px;
    }
}

@media (max-height: 700px) {
    .title-main {
        font-size: 1.8rem;
        margin-bottom: 12px;
    }
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin: 0 0 35px 0;
    line-height: 1.6;
    animation: fadeIn 1s ease 0.7s backwards;
    font-family: Arial, sans-serif;
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .subtitle {
        font-size: 1rem;
        margin-bottom: 30px;
    }
}

@media (max-height: 700px) {
    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 25px;
    }
}

/* =====================================================
   SELECT CAMERA PERSONALIZZATO
   ===================================================== */

#chooseCamSel {
    display: block;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    color: white;
    padding: 12px 20px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    margin: 0 auto 30px;
    width: auto;
    max-width: 280px;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

#chooseCamSel:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

@media (max-width: 600px) {
    #chooseCamSel {
        font-size: 13px;
        padding: 10px 18px;
        margin-bottom: 25px;
    }
}

@media (max-height: 700px) {
    #chooseCamSel {
        margin-bottom: 20px;
    }
}

/* =====================================================
   BOTTONE "INIZIA ESPERIENZA"
   ===================================================== */

/* Nascondi inizialmente il pulsante */
#startARButton {
    display: none !important;
}

#startARButton.visible {
    display: inline-flex !important;
}

.start-button {
    position: relative;
    padding: 20px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #088395 0%, #05bfdb 50%, #00d9ff 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
    box-shadow:
      0 10px 30px rgba(8, 131, 149, 0.5),
      0 5px 15px rgba(0, 217, 255, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: buttonScaleIn 1s ease 0.9s backwards, buttonPulse 2s ease-in-out 2s infinite;
    overflow: hidden;
    font-family: Arial, sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto;
    width: auto;
    max-width: 90%;
}

@keyframes buttonScaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes buttonPulse {
    0%, 100% {
        box-shadow:
            0 10px 30px rgba(8, 131, 149, 0.5),
            0 5px 15px rgba(0, 217, 255, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow:
            0 10px 40px rgba(8, 131, 149, 0.7),
            0 5px 20px rgba(0, 217, 255, 0.5),
            inset 0 1px 0 rgba(255, 255, 255, 0.3),
            0 0 30px rgba(255, 167, 66, 0.4);
    }
}

.start-button::before {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    background-image: url('alborella.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    z-index: 2;
}

.start-button::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
      45deg,
      transparent,
      rgba(255, 255, 255, 0.3),
      rgba(255, 167, 66, 0.4),
      rgba(0, 217, 255, 0.5),
      rgba(8, 131, 149, 0.5),
      rgba(255, 255, 255, 0.3),
      transparent
    );
    transform: rotate(45deg);
    animation: shimmerEnhanced 3s linear infinite;
    z-index: 1;
}

@keyframes shimmerEnhanced {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.start-button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow:
      0 15px 40px rgba(8, 131, 149, 0.6),
      0 8px 20px rgba(0, 217, 255, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.4);
    animation: none;
}

.start-button:active {
    transform: translateY(-2px) scale(0.98);
    box-shadow:
      0 8px 20px rgba(8, 131, 149, 0.4),
      0 4px 10px rgba(0, 217, 255, 0.3);
}

@media (max-width: 600px) {
    .start-button {
        padding: 18px 40px;
        font-size: 1.1rem;
    }
}

@media (max-height: 700px) {
    .start-button {
        padding: 16px 35px;
        font-size: 1rem;
    }
}

/* =====================================================
   BOLLE ANIMATE DI SFONDO
   ===================================================== */

.bubble {
    position: absolute;
    bottom: -50px;
    background: radial-gradient(
        circle at 30% 30%,
        rgba(255, 255, 255, 0.6),
        rgba(255, 167, 66, 0.2),
        rgba(0, 217, 255, 0.2),
        rgba(8, 131, 149, 0.1)
    );
    border-radius: 50%;
    box-shadow:
        inset 0 0 10px rgba(255, 255, 255, 0.5),
        0 0 20px rgba(255, 167, 66, 0.3);
    animation: riseEnhanced linear infinite;
    z-index: 10;
}

@keyframes riseEnhanced {
    0% {
        bottom: -100px;
        transform: translateX(0) scale(1);
        opacity: 0;
    }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% {
        bottom: 110%;
        transform: translateX(20px) scale(0.3);
        opacity: 0;
    }
}

.bubble:nth-child(1) {
    width: 40px;
    height: 40px;
    left: 10%;
    animation-duration: 8s;
    animation-delay: 0s;
}

.bubble:nth-child(2) {
    width: 20px;
    height: 20px;
    left: 25%;
    animation-duration: 6s;
    animation-delay: 1s;
}

.bubble:nth-child(3) {
    width: 30px;
    height: 30px;
    left: 45%;
    animation-duration: 7s;
    animation-delay: 2s;
}

.bubble:nth-child(4) {
    width: 25px;
    height: 25px;
    left: 65%;
    animation-duration: 9s;
    animation-delay: 0.5s;
}

.bubble:nth-child(5) {
    width: 35px;
    height: 35px;
    left: 80%;
    animation-duration: 8.5s;
    animation-delay: 1.5s;
}

.bubble:nth-child(6) {
    width: 15px;
    height: 15px;
    left: 90%;
    animation-duration: 6.5s;
    animation-delay: 2.5s;
}

/* =====================================================
   ONDE DECORATIVE IN BASSO
   ===================================================== */

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 100' preserveAspectRatio='none'%3E%3Cpath d='M0,50 Q300,0 600,50 T1200,50 L1200,100 L0,100 Z' fill='rgba(255,255,255,0.1)'/%3E%3C/svg%3E");
    background-size: cover;
    opacity: 0.5;
    z-index: 2;
}

/* =====================================================
   GPU ACCELERATION & PERFORMANCE
   ===================================================== */

.welcome-container,
.start-button,
.bubble {
    will-change: transform;
    transform: translateZ(0);
}

/* =====================================================
   ACCESSIBILITY - REDUCED MOTION
   ===================================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =====================================================
   BROWSER COMPATIBILITY - FALLBACKS
   ===================================================== */

/* Fallback per backdrop filter */
@supports not (backdrop-filter: blur(20px)) {
    .welcome-container {
        background: rgba(255, 255, 255, 0.15);
    }
}
