/* ==========================================================================
   « 18 h 47 » — la couche qui rend le site vivant
   Chargée en dernier sur toutes les pages.
   1. Typographie : un mot par titre en italique à empattement.
   2. Titres qui montent mot à mot (js/vivant.js).
   3. L'en-tête « scène » : une lumière, une heure, trois notifications.
   4. Le récit au défilement : 18:47 → 8:02 le lendemain.
   ========================================================================== */

/* ---------------------------------------------------------------- 1. TYPOGRAPHIE */
:root { --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif; }
h1 em, h2 em, .hero-title em, .section-title em {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.02em;
    /* L'empattement paraît plus petit que le sans-serif à taille égale. */
    font-size: 1.08em;
    padding-right: 0.06em;
}
.section-title em {
    background: linear-gradient(180deg, #DBEAFE 10%, #93C5FD 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------------------------------------------------------------- 2. TITRES MOT À MOT
   Le JS enveloppe chaque mot ; sans JS, rien n'est caché. Le dégradé des
   titres est hérité mot par mot, sinon le texte disparaîtrait. */
.mot { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.12em; margin-bottom: -0.12em; background: inherit; -webkit-background-clip: text; background-clip: text; }
/* Le cadre de chaque mot masque ce qui dépasse (c'est ce qui fait « monter » le mot). Avec l'espacement serré
   des titres et l'italique, le bout de certaines lettres (« s », « t », le « p » penché) dépassait de ce cadre et
   était coupé sur certains PC, selon la police affichée. Le cadre est élargi de chaque côté, et la marge négative
   compense : le texte ne bouge pas. */
.mot { padding-left: 0.14em; padding-right: 0.14em; margin-left: -0.14em; margin-right: -0.14em; }
.mot > span {
    display: inline-block;
    background: inherit;
    -webkit-background-clip: text;
            background-clip: text;
    transform: translateY(108%);
    transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--i, 0) * 55ms);
}
.titre-vu .mot > span { transform: none; }

/* ---------------------------------------------------------------- 3. SCÈNE D'EN-TÊTE */
.scene-hero { padding: 12px; position: relative; z-index: 1; }
.scene {
    position: relative;
    min-height: min(calc(100svh - 24px), 900px);
    display: flex;
    align-items: center;
    border-radius: 34px;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(90% 70% at 10% 0%, #10275A 0%, transparent 60%),
        linear-gradient(180deg, #0A1730 0%, #060D1C 100%);
}
/* La lumière : un disque bleu, bord net et halo large, qui respire. */
.scene-lumiere {
    position: absolute;
    z-index: -1;
    width: min(64vw, 820px);
    aspect-ratio: 1;
    right: -6%;
    top: 50%;
    border-radius: 50%;
    translate: var(--lx, 0px) calc(-50% + var(--ly, 0px));
    background:
        radial-gradient(circle at 38% 34%, #BFDBFE 0%, #60A5FA 26%, #2563EB 52%, #1E3A8A 74%, #0F1F4D 100%);
    box-shadow:
        0 0 120px 20px rgba(59, 130, 246, 0.45),
        0 0 320px 80px rgba(37, 99, 235, 0.28);
    opacity: 0.92;
    animation: sceneRespire 9s ease-in-out infinite;
    transition: translate 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes sceneRespire {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50%      { transform: scale(1.035); filter: brightness(1.12); }
}
/* Grain de pellicule : c'est lui qui donne le côté « image » plutôt qu'« écran ». */
.scene-grain {
    position: absolute;
    inset: -50%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.16;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    animation: sceneGrain 1.2s steps(6) infinite;
}
@keyframes sceneGrain {
    0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); }
    40% { transform: translate(2%, -3%); } 60% { transform: translate(-2%, -1%); }
    80% { transform: translate(3%, 2%); } 100% { transform: translate(0, 0); }
}

.scene-contenu {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: center;
    gap: 40px;
    padding-top: 120px;
    padding-bottom: 80px;
    width: 100%;
}
.scene-texte { text-align: left; }
.scene-texte .hero-badge { color: #93C5FD; margin-bottom: 18px; }
.scene .hero-title {
    font-size: clamp(3.2rem, 6.8vw, 6.4rem);
    font-weight: 800;
    line-height: 0.96;
    letter-spacing: -0.055em;
    margin-bottom: 26px;
    text-align: left;
    background: none;
    -webkit-text-fill-color: #FFFFFF;
    color: #FFFFFF;
}
.scene .hero-title em { -webkit-text-fill-color: #BFDBFE; color: #BFDBFE; }
.scene-chapo { font-size: 1.12rem; line-height: 1.6; color: rgba(226, 232, 240, 0.72); max-width: 500px; margin: 0 0 34px; }
.scene .hero-cta { justify-content: flex-start; margin-bottom: 30px; }
.scene-preuves {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 0.86rem;
    color: rgba(226, 232, 240, 0.6);
}
.scene-preuves li { display: flex; align-items: center; gap: 8px; padding: 0; }
.scene-preuves li::before {
    content: '';
    position: static;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #34D399;
}

/* L'écran verrouillé, sans téléphone : l'heure et les notifications posées
   dans la lumière. */
.verrou { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
.verrou-legende { margin: 0; font-size: 0.95rem; font-weight: 500; color: rgba(255, 255, 255, 0.78); }
.verrou-heure {
    margin: 2px 0 26px;
    font-size: clamp(5rem, 10vw, 8.4rem);
    font-weight: 200;
    line-height: 1;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 10px 60px rgba(15, 31, 77, 0.55);
}
.verrou-notifs { display: flex; flex-direction: column; gap: 10px; width: min(370px, 100%); }
.notif {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    border-radius: 22px;
    text-align: left;
    background: rgba(12, 22, 44, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
    box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
    transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), filter 0.6s ease;
}
.notif div { display: flex; flex-direction: column; min-width: 0; }
.notif b { font-size: 0.92rem; color: #FFFFFF; }
.notif div span { font-size: 0.82rem; color: rgba(226, 232, 240, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif time { align-self: start; font-size: 0.72rem; color: rgba(226, 232, 240, 0.55); }
.notif-icone {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #FFFFFF;
}
.notif-icone svg { width: 20px; height: 20px; }
.notif-appel .notif-icone { background: linear-gradient(180deg, #5EE07A, #1FB141); }
.notif-automya .notif-icone { background: linear-gradient(160deg, #26262A 0%, #000000 70%); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16); }
.notif-rdv .notif-icone { background: linear-gradient(180deg, #4AA3FF, #1A73E8); }

/* Le scénario : chaque notification apparaît, l'appel se range derrière. */
.verrou.e1 .notif-appel, .verrou.e2 .notif-appel, .verrou.e3 .notif-appel,
.verrou.e2 .notif-automya, .verrou.e3 .notif-automya,
.verrou.e3 .notif-rdv { opacity: 1; transform: none; }
.verrou.e1 .notif-appel .notif-icone { animation: sceneSonne 0.9s ease-in-out infinite; }
.verrou.e3 .notif-appel { opacity: 0.5; filter: saturate(0.5); transform: scale(0.97); }
@keyframes sceneSonne {
    0%, 100% { transform: rotate(0); } 15% { transform: rotate(-12deg); } 30% { transform: rotate(12deg); }
    45% { transform: rotate(-8deg); } 60% { transform: rotate(8deg); } 75% { transform: rotate(0); }
}
/* Sans JavaScript, l'état final est affiché. */
.verrou:not(.e1):not(.e2):not(.e3):not(.e0) .notif { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- 4. RÉCIT */
.recit { padding: 150px 0 40px; position: relative; }
.recit-entete { text-align: center; max-width: 860px; margin: 0 auto 30px; }
.recit-entete .section-tag { text-align: center; }
.recit-entete .section-title { font-size: clamp(2.6rem, 5.4vw, 4.6rem); font-weight: 800; letter-spacing: -0.05em; line-height: 1.02; }
.recit-grille {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 60px;
    align-items: start;
}
.recit-etape {
    min-height: 78vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0.22;
    transition: opacity 0.6s ease;
}
.recit-etape.actif { opacity: 1; }
.recit-heure {
    margin: 0 0 12px;
    font-size: clamp(3rem, 5.6vw, 4.8rem);
    font-weight: 200;
    line-height: 1;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    color: #93C5FD;
}
.recit-heure small { font-size: 0.34em; font-weight: 500; letter-spacing: 0; color: #8E9BB0; margin-left: 10px; }
.recit-etape h3 {
    margin: 0 0 14px;
    font-size: clamp(1.8rem, 3.2vw, 2.7rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.04em;
    color: #FFFFFF;
    text-wrap: balance;
}
.recit-etape p:last-child { margin: 0; max-width: 460px; font-size: 1.12rem; line-height: 1.6; color: #8E9BB0; }

.recit-ecran { position: sticky; top: calc(50vh - 300px); height: 620px; display: flex; align-items: center; justify-content: center; }
.recit-ecran::before {
    content: '';
    position: absolute;
    width: 460px; height: 460px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.35) 0%, transparent 65%);
    filter: blur(10px);
    z-index: -1;
}
.telephone {
    position: relative;
    width: 290px;
    height: 600px;
    border-radius: 48px;
    background: #04070E;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.14),
        0 0 0 9px #0D1523,
        0 0 0 10px rgba(255, 255, 255, 0.08),
        0 70px 120px -40px rgba(0, 0, 0, 0.95);
    overflow: hidden;
    color: #EAF0F8;
    font-size: 13px;
}
.telephone::before {
    content: '';
    position: absolute;
    top: 12px; left: 50%;
    width: 96px; height: 28px;
    margin-left: -48px;
    border-radius: 20px;
    background: #000;
    z-index: 5;
}
.ecran-tel {
    position: absolute;
    inset: 0;
    padding: 64px 18px 26px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.55s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.telephone[data-actif="0"] [data-ecran="0"],
.telephone[data-actif="1"] [data-ecran="1"],
.telephone[data-actif="2"] [data-ecran="2"],
.telephone[data-actif="3"] [data-ecran="3"] { opacity: 1; transform: none; }
.ecran-tel p { margin: 0; }

/* écran 0 : l'appel entrant */
.ecran-sonne { background: radial-gradient(120% 70% at 50% 30%, #13305F 0%, #04070E 70%); align-items: center; text-align: center; }
.tel-mini { font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.tel-appelant { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 70px; }
.tel-avatar {
    position: relative;
    width: 92px; height: 92px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    font-size: 30px; font-weight: 600;
    background: linear-gradient(180deg, #8B96A8, #5B6577);
}
.tel-avatar::before, .tel-avatar::after {
    content: '';
    position: absolute; inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(147, 197, 253, 0.5);
    animation: telOnde 1.8s ease-out infinite;
}
.tel-avatar::after { animation-delay: 0.9s; }
@keyframes telOnde { from { opacity: 1; transform: scale(0.9); } to { opacity: 0; transform: scale(1.5); } }
.tel-appelant b { font-size: 26px; font-weight: 600; }
.tel-appelant span { color: rgba(255, 255, 255, 0.6); font-size: 14px; }
.tel-boutons { margin-top: auto; display: flex; justify-content: space-between; width: 100%; padding: 0 22px; }
.tel-boutons span { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.tel-boutons svg { width: 28px; height: 28px; }
.tel-refuser { background: #FF3B30; }
.tel-refuser svg { transform: rotate(135deg); }
.tel-accepter { background: #34C759; animation: telVibre 1.2s ease-in-out infinite; }
@keyframes telVibre { 0%, 100% { transform: none; } 10%, 30% { transform: translateX(-2px); } 20%, 40% { transform: translateX(2px); } 50% { transform: none; } }

/* entêtes communs */
.tel-entete { display: flex; align-items: center; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); margin-bottom: 18px; }
.tel-entete div { display: flex; flex-direction: column; }
.tel-entete b { font-size: 14px; }
.tel-entete span { font-size: 11.5px; color: rgba(255, 255, 255, 0.5); }
.tel-entete .tel-vert { color: #34D399; }
.tel-logo {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #26262A 0%, #000000 70%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

/* écran 1 : la conversation */
.ecran-appel { background: #04070E; }
.tel-onde { display: flex; align-items: center; justify-content: center; gap: 3px; height: 70px; margin: 6px 0 16px; }
.tel-onde i { width: 4px; height: var(--h); border-radius: 3px; background: linear-gradient(180deg, #BFDBFE, #3B82F6); }
.telephone[data-actif="1"] .tel-onde i { animation: telParle 0.9s ease-in-out infinite alternate; animation-delay: var(--r); }
@keyframes telParle { from { transform: scaleY(0.3); } to { transform: scaleY(1); } }
.tel-bulle { max-width: 88%; padding: 10px 13px; border-radius: 18px; line-height: 1.4; margin-bottom: 8px !important; }
.tel-bulle-patient { align-self: flex-start; background: rgba(255, 255, 255, 0.1); border-bottom-left-radius: 5px; }
.tel-bulle-ia { align-self: flex-end; background: #2F6BFF; border-bottom-right-radius: 5px; }

/* écran 2 : le SMS */
.ecran-sms { background: #04070E; }
.tel-sms { align-self: flex-start; max-width: 90%; padding: 11px 14px; border-radius: 18px; border-bottom-left-radius: 5px; background: rgba(255, 255, 255, 0.1); line-height: 1.45; }
.tel-agenda { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 12px; border-radius: 16px; background: rgba(52, 199, 89, 0.12); border: 1px solid rgba(52, 199, 89, 0.3); }
.tel-agenda-jour { width: 46px; height: 50px; border-radius: 10px; background: #fff; color: #0B1829; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; line-height: 1; }
.tel-agenda-jour small { font-size: 9px; color: #FF3B30; font-weight: 700; margin-bottom: 2px; }
.tel-agenda div { display: flex; flex-direction: column; }
.tel-agenda b { font-size: 13px; }
.tel-agenda div span { font-size: 11.5px; color: rgba(255, 255, 255, 0.6); }

/* écran 3 : le résumé */
.ecran-resume { background: #04070E; }
.tel-fiche { margin: 0; display: flex; flex-direction: column; }
.tel-fiche div { display: flex; flex-direction: column; gap: 3px; padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.tel-fiche dt { font-size: 11px; color: rgba(255, 255, 255, 0.45); }
.tel-fiche dd { margin: 0; font-size: 13.5px; }
.tel-puce { font-style: normal; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.tel-ambre { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.tel-vert-puce { background: rgba(52, 211, 153, 0.15); color: #34D399; }
.tel-lu { margin-top: auto !important; text-align: center; font-size: 12px; color: rgba(255, 255, 255, 0.45); }

/* ---------------------------------------------------------------- TÉLÉPHONE ET TABLETTE */
@media (max-width: 900px) {
    .scene { min-height: 0; border-radius: 26px; }
    .scene-contenu { grid-template-columns: 1fr; gap: 50px; padding-top: 110px; padding-bottom: 50px; }
    .scene-lumiere { width: 120vw; right: -35%; top: 78%; }
    .verrou-heure { font-size: 5.2rem; }
    .recit { padding-top: 110px; }
    /* Sur petit écran : le téléphone (réduit) reste épinglé en haut, le texte de l'étape
       en cours s'affiche dessous, et les deux changent au fil du défilement. */
    .recit-grille { display: flex; flex-direction: column; gap: 0; min-height: 360vh; }
    .recit-ecran {
        order: -1; position: sticky; top: 76px; z-index: 1;
        height: calc(600px * var(--k) + 24px); align-items: flex-start;
    }
    .recit-ecran::before { width: 300px; height: 300px; top: 20px; }
    .telephone { --k: 0.6; transform: scale(var(--k)); transform-origin: top center; flex: none; margin-top: 10px; }
    .recit-ecran { --k: 0.6; }
    .recit-etapes {
        position: sticky; top: calc(76px + 600px * var(--k) + 30px);
        display: grid; text-align: center; --k: 0.6;
    }
    .recit-etape {
        grid-area: 1 / 1; min-height: 0; justify-content: flex-start;
        opacity: 0; transform: translateY(14px);
        transition: opacity 0.45s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
        pointer-events: none;
    }
    .recit-etape.actif { opacity: 1; transform: none; pointer-events: auto; }
    .recit-heure { font-size: 2.4rem; margin-bottom: 8px; }
    .recit-etape h3 { font-size: 1.45rem; margin-bottom: 8px; }
    .recit-etape h3 br { display: none; }
    .recit-etape p:last-child { font-size: 0.98rem; margin: 0 auto; max-width: 420px; }
}
@media (max-width: 900px) and (max-height: 760px) {
    .recit-ecran, .telephone, .recit-etapes { --k: 0.5; }
}
@media (max-width: 900px) and (max-height: 640px) {
    .recit-ecran, .telephone, .recit-etapes { --k: 0.42; }
    .recit-etape p:last-child { font-size: 0.9rem; }
}
@media (max-width: 620px) {
    .scene-hero { padding: 8px; }
    .scene .hero-title { font-size: 3rem; }
    .verrou-heure { font-size: 4.2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .scene-lumiere, .scene-grain, .tel-avatar::before, .tel-avatar::after, .tel-accepter { animation: none; }
    .mot > span { transform: none; transition: none; }
    .notif { transition: none; }
}

/* Titres en dégradé : ils montent d'un bloc (le découpage mot à mot casse le dégradé dans Chrome). */
.titre-bloc { opacity: 0; transform: translateY(28px); transition: opacity 0.9s ease, transform 1s cubic-bezier(0.22, 1, 0.36, 1); }
.titre-bloc.titre-vu { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .titre-bloc { opacity: 1; transform: none; transition: none; } }
