/* ============================================================
   Mode application (écran d'accueil) — barre d'onglets, transitions,
   tirer-pour-actualiser, notifications. Actif via html.app-mode.
   ============================================================ */

/* Transition douce entre les pages (Chrome / Android) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
.site-header { view-transition-name: app-header; }
.app-tabbar  { view-transition-name: app-tabbar; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* Bande d'état sombre : garde l'heure et la batterie lisibles sous l'encoche (iPhone) */
html.app-mode body::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 1100;
    height: env(safe-area-inset-top, 0px); background: #0f172a; pointer-events: none;
}
html.app-mode .site-header { padding-top: env(safe-area-inset-top, 0px); }

/* Ressenti « appli » : pas de sélection ni de menu contextuel sur l'interface */
html.app-mode { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
html.app-mode .site-header, html.app-mode .app-tabbar, html.app-mode .mobile-menu {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html.app-mode .icon-btn, html.app-mode .btn, html.app-mode .mobile-menu-link, html.app-mode button {
    transition: transform .15s ease, background-color .2s ease, border-color .2s ease;
}
html.app-mode .icon-btn:active, html.app-mode .btn:active, html.app-mode .mobile-menu-link:active { transform: scale(.95); }

/* Apparition du contenu après l'écran de lancement */
@keyframes appIn { from { opacity: 0; transform: translateY(14px); } }
html.app-mode .container-fluid > * { animation: appIn .5s cubic-bezier(.2, .8, .2, 1) backwards; }
html.app-mode .container-fluid > *:nth-child(2) { animation-delay: .06s; }
html.app-mode .container-fluid > *:nth-child(3) { animation-delay: .12s; }
html.app-mode .container-fluid > *:nth-child(4) { animation-delay: .18s; }
html.app-mode .container-fluid > *:nth-child(5) { animation-delay: .24s; }
html.app-mode .container-fluid > *:nth-child(n+6) { animation-delay: .3s; }
html.app-splash:not(.splash-out) .container-fluid > * { animation: none; }
@media (prefers-reduced-motion: reduce) { html.app-mode .container-fluid > * { animation: none; } }

/* Barre d'onglets du bas */
.app-tabbar { display: none; }
@media (max-width: 900px) {
    html.app-mode .app-tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
        justify-content: space-around; align-items: stretch;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
        background: var(--card-bg);
        background: color-mix(in srgb, var(--card-bg) 86%, transparent);
        -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
        border-top: 1px solid var(--card-border);
        box-shadow: 0 -8px 30px -12px rgba(15, 23, 42, .18);
    }
    html.app-mode body { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
    html.app-mode .burger-btn { display: none; }
    html.app-mode .app-footer-nav, html.app-mode .app-footer-top { display: none; }
}
@media (max-width: 600px) {
    html.app-mode .container-fluid { padding-left: 14px !important; padding-right: 14px !important; }
}
.app-tab {
    flex: 1 1 0; max-width: 124px; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 2px 2px 0; border: 0; background: none; cursor: pointer;
    color: var(--text-muted); font: inherit; font-size: .66rem; font-weight: 700; letter-spacing: .01em;
    text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.app-tab .ic {
    width: 58px; height: 31px; border-radius: 16px; display: grid; place-items: center; font-size: 1.22rem;
    transition: background-color .25s ease, color .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1.3);
}
.app-tab .lb { line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.app-tab.active { color: var(--accent); }
.app-tab.active .ic { background: var(--accent-soft); transform: translateY(-1px); }
.app-tab:active .ic { transform: scale(.88); }
@keyframes tabPop { 0% { transform: scale(.82); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
.app-tab.active .ic i { animation: tabPop .4s cubic-bezier(.2, .8, .2, 1); }

/* Notifications (hors-ligne, mise à jour) */
.app-toast {
    position: fixed; left: 50%; bottom: 20px; z-index: 1200;
    transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
    display: flex; align-items: center; gap: 12px; max-width: min(92vw, 420px);
    padding: 11px 14px 11px 16px; border-radius: 16px;
    background: #0f172a; color: #fff; font-size: .84rem; font-weight: 600; line-height: 1.3;
    box-shadow: 0 14px 36px -10px rgba(2, 6, 23, .55), 0 0 0 1px rgba(255, 255, 255, .08);
    transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s ease;
}
.app-toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.app-toast::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #60a5fa; flex-shrink: 0; }
.app-toast.warn::before { background: #fbbf24; }
.app-toast.ok::before { background: #34d399; }
.app-toast button {
    margin-left: 4px; border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: .8rem;
    color: #0f172a; background: #fff; padding: 6px 12px; border-radius: 999px;
}
@media (max-width: 900px) {
    html.app-mode .app-toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
}

/* Tirer pour actualiser */
.ptr {
    position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 1150;
    width: 42px; height: 42px; margin-left: -21px; border-radius: 50%;
    display: grid; place-items: center; font-size: 1.1rem; color: var(--accent);
    background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: 0 10px 26px -8px rgba(15, 23, 42, .35);
    opacity: 0; transform: translateY(-60px) scale(.6); pointer-events: none;
}
.ptr.snap { transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .2s ease; }
.ptr.ready { background: var(--accent); color: #fff; border-color: var(--accent); }
.ptr i { display: block; transition: transform .1s linear; }
.ptr.spin i { animation: ptrSpin .7s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }
