/* ============================================================
 * TapNow - CSS publicités côté visiteur (style Digipharm)
 * À ajouter à la fin de assets/css/scan.css (ou inclus séparément)
 * ============================================================ */

/* ============ Pub INLINE (encart_transmission + encart_confirmation) ============ */
/* Structure : wrapper avec header "Publicité" au-dessus + zone visuel */

.pub-v {
    display: block;
    margin: 28px auto 16px;
    width: 100%;
    max-width: 340px;
    background: white;
    border: 1px solid rgba(3, 28, 73, 0.08);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.pub-v-cliquable { cursor: pointer; }
.pub-v-cliquable:hover,
.pub-v-cliquable:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    border-color: rgba(3, 28, 73, 0.15);
}

/* Header gris au-dessus avec label "Publicité" */
.pub-v-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(3, 28, 73, 0.06);
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}
.pub-v-header-icon {
    flex-shrink: 0;
    color: #94a3b8;
}
.pub-v-header-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 10.5px;
}

/* Zone visuel : aspect ratio carré 1:1 ou portrait 9:16 */
.pub-v-visuel {
    position: relative;
    width: 100%;
    overflow: hidden;
}
.pub-v-visuel.pub-v-square { aspect-ratio: 1 / 1; }
.pub-v-visuel.pub-v-portrait { aspect-ratio: 9 / 16; max-height: 480px; }
.pub-v-visuel.pub-v-banner { aspect-ratio: 16 / 5; }

.pub-v-inner {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.pub-v-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pub-v-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    word-wrap: break-word;
}
.pub-v-text-content {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

/* ============ Pub INTERSTITIELLE plein écran - STYLE DIGIPHARM ============ */
/* Fond marine, header avec spinner + texte, frame téléphone avec la pub, */
/* barre progression verte, footer sécurité avec icône lock                */

.pub-inter-overlay {
    position: fixed;
    inset: 0;
    background: #031C49;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s ease-out;
    overflow: hidden;
}
.pub-inter-overlay.is-visible {
    opacity: 1;
}

.pub-inter-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    gap: 18px;
    box-sizing: border-box;
}

/* Header en haut : spinner + texte */
.pub-inter-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}
.pub-inter-header-text {
    letter-spacing: 0.01em;
}

/* Spinner cercle qui tourne (façon Digipharm) */
.pub-inter-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(34, 197, 94, 0.25);
    border-top-color: #22c55e;
    animation: pubInterSpin 0.85s linear infinite;
    flex-shrink: 0;
}
@keyframes pubInterSpin {
    to { transform: rotate(360deg); }
}

/* Frame téléphone centrée avec la pub */
.pub-inter-frame {
    position: relative;
    /* On fixe la HAUTEUR (min entre hauteur dispo et 640px), la largeur est calculée
       automatiquement via aspect-ratio. Ainsi le cadre est TOUJOURS strict 9:16 et
       l'image 9:16 le remplit sans bandes ni coupures.
       100dvh (dynamic viewport height) plutôt que 100vh : Safari iOS prend en compte
       la barre d'URL escamotable, donc la hauteur visible réelle. */
    height: min(calc(100vh - 220px), 640px);   /* fallback navigateurs anciens */
    height: min(calc(100dvh - 220px), 640px);
    aspect-ratio: 9 / 16;
    max-width: 100%;
    background: #000;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    transform: scale(0.96);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}
.pub-inter-overlay.is-visible .pub-inter-frame {
    transform: scale(1);
}

/* Visuel pub à l'intérieur de la frame */
.pub-inter-media {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pub-inter-media .pub-v-media {
    width: 100%;
    height: 100%;
    display: block;
}
/* Image : on préserve l'intégralité du visuel (bandes possibles si pas 9:16 strict).
   Le commerçant peut recadrer son image avant upload pour un rendu plein cadre. */
.pub-inter-media img.pub-v-media {
    object-fit: contain;
}
/* Vidéo : on remplit le cadre (zoom centré). Si la vidéo est presque 9:16 c'est invisible ;
   si elle est très différente, ça peut couper les côtés ou le haut/bas. */
.pub-inter-media video.pub-v-media {
    object-fit: cover;
}
.pub-inter-media .pub-v-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 24px;
    text-align: center;
}
.pub-inter-media .pub-v-text-content {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
}

/* Label "Publicité" subtil en haut à droite de la frame */
.pub-v-label-inter {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    font-size: 9.5px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 100px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    z-index: 6;
    pointer-events: none;
}

/* Barre de progression verte en bas (sous la frame, dans le wrap marine) */
.pub-inter-progress {
    width: 100%;
    max-width: 360px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    overflow: hidden;
    flex-shrink: 0;
}
.pub-inter-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
    border-radius: 100px;
}

/* Footer en bas : icône lock + texte sécurité */
.pub-inter-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}
.pub-inter-footer svg {
    color: rgba(255, 255, 255, 0.65);
    flex-shrink: 0;
}

/* Responsive interstitiel */
@media (max-width: 380px) {
    .pub-inter-wrap {
        padding: 20px 16px;
        gap: 14px;
    }
    .pub-inter-header { font-size: 13.5px; }
    .pub-inter-footer { font-size: 12px; }
    .pub-inter-frame { height: min(calc(100vh - 180px), 640px); height: min(calc(100dvh - 180px), 640px); }
}
@media (max-height: 640px) {
    .pub-inter-wrap { gap: 12px; padding: 16px; }
    .pub-inter-frame { height: min(calc(100vh - 160px), 640px); height: min(calc(100dvh - 160px), 640px); }
}

/* ============ Popup confirmation copie email ============ */
.copy-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 28, 73, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}
.copy-modal-overlay.is-visible {
    opacity: 1;
}

.copy-modal {
    background: white;
    border-radius: 20px;
    padding: 32px 28px 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.92);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.copy-modal-overlay.is-visible .copy-modal {
    transform: scale(1);
}

.copy-modal-icon {
    margin: 0 auto 16px;
    display: flex;
    justify-content: center;
}

.copy-modal-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 700;
    color: #031C49;
    line-height: 1.2;
}

.copy-modal-email {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: #031C49;
    word-break: break-all;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.copy-modal-hint {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.5;
    color: #64748b;
}

.copy-modal-btn {
    display: block;
    width: 100%;
    padding: 13px 16px;
    background: #031C49;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.copy-modal-btn:hover {
    background: #052a6f;
}
.copy-modal-btn:active {
    transform: scale(0.98);
}

/* ============ Bouton "Renvoyer un autre document" ============ */
.btn-renvoyer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto 0;
    padding: 13px 22px;
    background: white;
    color: #031C49;
    border: 2px solid #031C49;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    font-family: inherit;
    cursor: pointer;
}
.btn-renvoyer:hover {
    background: #031C49;
    color: white;
}
.btn-renvoyer:active {
    transform: scale(0.98);
}

/* ============ Responsive global ============ */
@media (max-width: 380px) {
    .pub-v {
        max-width: 100%;
    }
    .pub-v-visuel.pub-v-portrait {
        max-height: 400px;
    }
    .copy-modal {
        padding: 28px 22px 20px;
    }
    .copy-modal-title { font-size: 18px; }
}
/* ============================================================
   Hold-to-pause (style Instagram Stories)
   - Pendant le hold : fade-out du chrome (header, footer, progress)
   - La pub elle-même reste pleinement visible
   ============================================================ */
.pub-inter-overlay.is-paused .pub-inter-header,
.pub-inter-overlay.is-paused .pub-inter-footer,
.pub-inter-overlay.is-paused .pub-inter-progress {
    opacity: 0;
    pointer-events: none;
}
.pub-inter-header,
.pub-inter-footer,
.pub-inter-progress {
    transition: opacity 0.2s ease;
}

/* ============================================================
   Bouton replay discret en haut-GAUCHE de la frame téléphone.
   (Le coin haut-droit est occupé par le label "Publicité")
   ============================================================ */
.pub-inter-replay {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.15s, transform 0.15s, opacity 0.2s;
    opacity: 0.75;
}
.pub-inter-replay:hover,
.pub-inter-replay:focus-visible {
    background: rgba(0, 0, 0, 0.65);
    opacity: 1;
    outline: none;
}
.pub-inter-replay:active {
    transform: scale(0.92);
}
/* Petite anim de rotation au clic pour donner du feedback */
.pub-inter-replay:active svg {
    transform: rotate(-60deg);
    transition: transform 0.2s ease-out;
}

/* En mode paused, on cache aussi le replay (le visiteur est en train de lire) */
.pub-inter-overlay.is-paused .pub-inter-replay {
    opacity: 0;
    pointer-events: none;
}

/* En mode paused, on cache aussi le badge "Publicité" (laisse le visiteur en immersion) */
.pub-v-label-inter {
    transition: opacity 0.18s ease;
}
.pub-inter-overlay.is-paused .pub-v-label-inter {
    opacity: 0;
}

/* La frame téléphone doit être en position:relative pour que le bouton replay
   se positionne par rapport à elle (et pas par rapport à l'overlay entier) */
.pub-inter-frame {
    position: relative;
}


/* Désactive le menu contextuel iOS (force touch / long press) sur les médias des pubs.
   Sans casser le clic : pointer-events reste actif pour suivre l'urlCible. */
.pub-v-media,
.pub-inter-frame img,
.pub-inter-frame video,
.pub-v-visuel img,
.pub-v-visuel video {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}
