/* Font Gotham */
@font-face {
    font-family: 'Gotham';
    src: url('../assets/fonts/Gotham-Light.ttf');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Gotham';
    src: url('../assets/fonts/Gotham-Book.ttf');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Gotham';
    src: url('../assets/fonts/Gotham-Medium.ttf');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Gotham';
    src: url('../assets/fonts/Gotham-Bold.ttf');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Gotham';
    src: url('../assets/fonts/Gotham-Black.ttf');
    font-weight: 900;
    font-style: normal;
}

/* Homepage Styles */
.homepage {
    background-image: url('../assets/sfondo.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    font-family: 'Gotham', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh; /* Fallback per browser che non supportano custom properties */
    height: calc(var(--vh, 1vh) * 100); /* Usa l'altezza reale calcolata da JS */
    padding: 15px;
    color: #000;
    overflow: hidden;
}

.homepage-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-height: calc(var(--vh, 1vh) * 100 - 30px);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.logo-section {
    margin-top: 40px;
    flex-shrink: 0;
}

.main-logo {
    width: 260px;
    height: auto;
    max-width: 90%;
}

.content-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 30px 0;
    max-width: 100%;
}

.celebration-text {
    font-family: 'Gotham', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 1.7rem;
    line-height: 1.2;
    margin-bottom: 25px;
    letter-spacing: 0.5px;
    color: #000;
}

.hashtag {
    font-family: 'Gotham', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #000;
    margin-top: 10px;
    line-height: 1.4;
}

.action-section {
    margin-bottom: 40px;
    flex-shrink: 0;
}

.start-button {
    display: inline-block;
    background-color: #000;
    padding: 15px 25px;
    border-radius: 8px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.button-logo {
    width: 120px;
    height: auto;
    filter: brightness(0) invert(1);
}

/* Media Queries per responsive design */
@media (max-width: 480px) {
    .homepage {
        padding: 10px;
    }
    
    .homepage-container {
        max-height: calc(var(--vh, 1vh) * 100 - 20px);
    }
    
    .logo-section {
        margin-top: 30px;
    }
    
    .main-logo {
        width: 220px;
    }
    
    .celebration-text {
        font-size: 1.4rem;
    }
    
    .hashtag {
        font-size: 0.9rem;
    }
    
    .button-logo {
        width: 100px;
    }
    
    .action-section {
        margin-bottom: 30px;
    }
    
    .content-section {
        margin: 20px 0;
    }
}

@media (max-height: 700px) {
    .homepage-container {
        max-height: calc(var(--vh, 1vh) * 100 - 20px);
    }
    
    .logo-section {
        margin-top: 25px;
    }
    
    .main-logo {
        width: 200px;
    }
    
    .content-section {
        margin: 20px 0;
    }
    
    .celebration-text {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    
    .action-section {
        margin-bottom: 25px;
    }
}

@media (max-height: 600px) {
    .homepage-container {
        max-height: calc(var(--vh, 1vh) * 100 - 15px);
    }
    
    .logo-section {
        margin-top: 15px;
    }
    
    .main-logo {
        width: 180px;
    }
    
    .content-section {
        margin: 15px 0;
    }
    
    .celebration-text {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    
    .hashtag {
        font-size: 0.8rem;
    }
    
    .action-section {
        margin-bottom: 15px;
    }
}

/* Reset CSS di base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    background-color: #000000; /* Sfondo nero di base per tutta la pagina */
}

/* Altezza 100% per html e body solo per le pagine che non devono scrollare */
html.homepage-html,
html.selfie-html,
body:not(.preview-body) {
    height: 100%;
}

/* Altezza 100% solo per le pagine che non devono scrollare */
body:not(.preview-body) {
    font-family: sans-serif;
    color: #FFFFFF;
    display: flex; /* Per centrare .selfie-page se necessario, ma .selfie-page sarà 100% width/height */
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0; 
    margin: 0;
    /* overflow: hidden; */ /* Rimuoviamo l'overflow hidden globale */
}

/* Overflow hidden solo per pagine specifiche che non devono scrollare */
body:not(.preview-body) {
    overflow: hidden; /* Previene scroll per tutte le pagine tranne preview */
}

/* Rimuoviamo header e footer dalla pagina selfie, dato che vogliamo un'esperienza fullscreen */
/* Se servono su altre pagine, andranno gestiti condizionalmente o rimossi da index.html */

.button {
    /* Stili per pulsanti generici, come quello di Start in index.html */
    display: inline-block;
    background-color: #FFFFFF;
    color: #000000;
    padding: 12px 25px;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: bold;
    border: 2px solid #FFFFFF;
    border-radius: 100px; /* Modificato: da 50% a 100px per ottenere l'effetto pill-shape come nell'immagine */
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
    cursor: pointer;
    min-width: 160px; /* Larghezza minima per i pulsanti a pillola */
    text-align: center;
}

.button:hover, .button:focus {
    background-color: #000000;
    color: #FFFFFF;
    border-color: #FFFFFF;
    transform: scale(1.03); /* Leggero effetto di zoom al hover */
}

/* Pagina Selfie (selfie.html) - Layout Fullscreen */
.selfie-page {
    width: 100%;
    height: 100%; /* Occupa l'intera altezza visibile */
    display: flex; /* Contenitore principale flex */
    flex-direction: column; /* Per organizzare camera-display-area */
    justify-content: center; /* Centra .camera-display-area verticalmente */
    align-items: center; /* Centra .camera-display-area orizzontalmente */
    background-color: #000000; /* Sfondo nero per la pagina */
}

.camera-display-area {
    position: relative; /* Contenitore per posizionamento assoluto dei controlli */
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.camera-container {
    position: relative; /* Mantenuto per coerenza interna */
    width: 100%; /* Occupa la larghezza del .camera-display-area */
    aspect-ratio: 9 / 16; /* FORZA L'ASPECT RATIO 9:16 */
    background-color: #111; /* Sfondo di fallback */
    overflow: hidden;
    /* Non più un bordo fisso qui, l'aspetto sarà più integrato */
    /* max-height: 100vh; o 100% del genitore */
    /* max-width calcolato per mantenere aspect ratio se l'altezza è il limite */
    /* Esempio: se camera-display-area è più larga che alta (landscape screen per errore?) */
    max-width: calc(var(--vh, 1vh) * 100 * 9 / 16); /* Usa l'altezza reale della viewport */
    max-height: 100%; /* O 100vh */
}

#camera-preview, #live-overlay, #camera-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Nascondiamo il video - lo useremo solo come sorgente per il canvas */
#camera-preview {
    opacity: 0; /* Completamente nascosto */
    visibility: hidden; /* Nascosto ma ancora attivo */
    /* Rimuovi tutte le trasformazioni problematiche */
    transform: none; 
}

/* Il canvas sarà dove disegniamo il video */
#camera-canvas {
    background-color: #000;
    z-index: 5; /* Sopra il video ma sotto l'overlay */
}

/* Overlay sopra tutto */
#live-overlay {
    object-fit: cover;
    z-index: 10;
}

#live-overlay[src=""], #live-overlay:not([src]) {
    display: none;
}

.controls-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 10px); /* Ridotto fallback per safe area */
    padding-top: 8px; /* Ridotto padding top */
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0) 100%); /* Sfumatura un po' più scura e corta */
    z-index: 20;
}

.effects-title {
    font-size: 0.8rem; /* Ridotto */
    color: #FFFFFF;
    margin-bottom: 5px; /* Ridotto */
    margin-top: 15px; /* Aggiunto 15px di margine superiore */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.overlay-thumbnails {
    display: flex;
    justify-content: center;
    gap: 6px; /* Ridotto */
    margin-bottom: 10px; /* Ridotto spazio prima del pulsante di scatto */
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding: 5px 10px; /* Ridotto padding verticale per le miniature */
    -webkit-overflow-scrolling: touch;
}

.thumbnail-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px; /* Ridotto */
    padding: 3px; /* Ridotto */
    border-radius: 4px;
    flex-shrink: 0;
}

.overlay-thumbnails .thumbnail {
    width: 50px;  /* Ridotte a 50px */
    height: calc(50px * 16/9); /* Ripristinato alle proporzioni 9:16 */
    object-fit: cover;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    background-color: #2c2c2c; /* Leggermente più chiaro per visibilità */
    border-radius: 8px; /* Ripristinato a 8px per renderlo rettangolare con angoli arrotondati */
}

.overlay-thumbnails .thumbnail:hover {
    transform: scale(1.05); /* Leggero ingrandimento al hover */
}

.overlay-thumbnails .thumbnail.no-overlay-thumb[src=""] {
    border: 2px dashed #555;
    display: flex; /* Per centrare eventuale testo/icona interna se l'immagine è vuota */
    align-items: center;
    justify-content: center;
}

.overlay-thumbnails .thumbnail.active {
    border-color: #FFFFFF;
    transform: scale(1.1); /* Leggermente più grande quando attiva */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5); /* Aggiunto glow attorno al thumbnail attivo */
}

.overlay-thumbnails .thumbnail.no-overlay-thumb.active {
    border-style: solid;
}

.thumbnail-wrapper span {
    font-size: 0.65rem; /* Ridotto */
    color: #FFFFFF;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.7);
}

.snap-button-round {
    width: 60px; /* Ridotto a 60px */
    height: 60px; /* Ridotto a 60px */
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    border: 2px solid #000000; /* Bordo più sottile */
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    padding: 0;
}

.snap-button-round:hover {
    background-color: #FFFFFF; /* Bianco pieno al hover */
    transform: scale(1.03);
}

.snap-button-round .snap-icon {
    width: 42px; /* Ridotto */
    height: 42px; /* Ridotto */
    background-color: red;
    border-radius: 50%;
}

/* Stili per Pagina Preview (preview.html) */
.preview-body {
    position: relative;
    font-family: 'Gotham', sans-serif;
    color: #000;
    overflow-y: auto; /* Abilita lo scroll verticale */
    min-height: 100vh;
    background-image: url('../assets/sfondo.png');
    background-size: 200%; /* Ridotto del 50% da 200px a 100px */
    background-position: 0 0;
    background-repeat: repeat;
    background-attachment: scroll;
    margin: 0;
    padding: 0;
}

.preview-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.preview-header {
    margin-top: 40px;
    margin-bottom: 30px;
    text-align: center;
}

.preview-logo {
    width: 200px;
    height: auto;
    max-width: 80%;
}

.preview-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

#preview-image {
    max-width: 90%;
    max-width: min(350px, 90vw);
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.preview-content {
    max-width: 350px;
    width: 100%;
    margin-bottom: 30px;
    text-align: center;
}

.share-instructions {
    font-family: 'Gotham', sans-serif;
    font-weight: 400;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #000;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.share-instructions strong {
    font-weight: 700;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
    align-items: center;
    margin-bottom: 40px;
}

.action-buttons .button {
    width: 100%;
    margin: 0;
    padding: 15px 20px;
    font-size: 1rem;
    text-align: center;
    font-family: 'Gotham', sans-serif;
    font-weight: 600;
    border-radius: 50px;
    transition: all 0.3s ease;
}

/* Stili specifici per i bottoni */
#retry-button {
    background-color: transparent;
    color: #000;
    border: 2px solid #000;
}

#retry-button:hover, #retry-button:focus {
    background-color: #000;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#download-button, #share-button {
    background-color: #000;
    color: #fff;
    border: 2px solid #000;
}

#download-button:hover, #download-button:focus,
#share-button:hover, #share-button:focus {
    background-color: #333;
    border-color: #333;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Media Queries per la pagina preview */
@media (max-width: 480px) {
    .preview-page {
        padding: 15px;
    }
    
    .preview-header {
        margin-top: 30px;
        margin-bottom: 20px;
    }
    
    .preview-logo {
        width: 160px;
    }
    
    .preview-content {
        max-width: 300px;
        margin-bottom: 20px;
    }
    
    .share-instructions {
        font-size: 0.8rem;
        padding: 15px;
    }
    
    .preview-container {
        margin-bottom: 20px;
    }
    
    #preview-image {
        max-width: min(300px, 90vw);
        border-radius: 8px;
    }
    
    .action-buttons {
        max-width: 280px;
        margin-bottom: 30px;
    }
    
    .action-buttons .button {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    #preview-image {
        max-height: 60vh; /* Altezza massima ridotta su mobile */
    }
}

@media (max-height: 700px) {
    .preview-header {
        margin-top: 20px;
        margin-bottom: 15px;
    }
    
    .preview-content {
        margin-bottom: 15px;
    }
    
    .preview-container {
        margin-bottom: 20px;
    }
    
    .action-buttons {
        margin-bottom: 20px;
    }
} 