/* Barre de navigation mobile Toubarennes (« dock ») + feuilles + tirer-pour-actualiser.
   Contenu : main/dock.py — balisage : templates/includes/dock.html — comportement :
   static/js/tb-dock.js, static/js/tb-pull-refresh.js. Uniquement sous 992px. */

:root {
    --tb-vert: #1b5e20;
    --tb-vert-moyen: #2e7d32;
    --tb-vert-nuit: #0b3d2e;
    --tb-or: #f5c542;
    --tb-encre: #14261d;
    --tb-gris: #5f6f66;
    --tb-ligne: rgba(11, 61, 46, .09);
    --tb-dock-h: 68px;
    --tb-bas: env(safe-area-inset-bottom, 0px);
}

.tb-dock, .tb-feuille, .tb-ptr { display: none; }
.tb-dock, .tb-feuille { font-size: 16px; line-height: 1.4; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

@media (max-width: 991.98px) {

/* ---------------------------------------------------------------- Barre ------ */
.tb-dock {
    display: block; position: fixed; z-index: 1040;
    left: 10px; right: 10px; bottom: calc(10px + var(--tb-bas));
    transition: transform .32s cubic-bezier(.2, .9, .25, 1), opacity .25s;
    -webkit-tap-highlight-color: transparent;
}
.tb-dock.is-cache { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.tb-dock.is-entree { animation: tbEntree .6s cubic-bezier(.2, .9, .25, 1.1) both; }
@keyframes tbEntree { from { transform: translateY(120%); opacity: 0; } }

.tb-dock-barre {
    position: relative; display: flex; align-items: stretch; height: var(--tb-dock-h);
    padding: 0 6px; border-radius: 26px;
    background: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
    box-shadow: 0 14px 34px -10px rgba(11, 61, 46, .35), 0 2px 6px rgba(11, 61, 46, .08), inset 0 0 0 1px var(--tb-ligne);
}
.tb-dock-cote { flex: 1 1 0; display: flex; min-width: 0; }

.tb-onglet {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 0; border: 0; background: none; cursor: pointer; font: inherit;
    color: var(--tb-gris) !important; text-decoration: none !important;
    transition: color .2s;
}
.tb-onglet-ic {
    position: relative; display: grid; place-items: center; width: 54px; height: 30px; border-radius: 15px;
    transition: background-color .25s, transform .2s;
}
.tb-onglet svg, .tb-fab svg, .tb-tuile svg, .tb-spirit-tuile svg, .tb-fermer svg, .tb-compte svg, .tb-recherche svg, .tb-pied-btn svg, .tb-ptr svg {
    width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tb-onglet-txt {
    max-width: 100%; padding: 0 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    font-size: clamp(9.5px, 2.85vw, 11px); font-weight: 700; letter-spacing: 0; line-height: 1.1;
}
.tb-onglet.is-actif { color: var(--tb-vert) !important; }
.tb-onglet.is-actif .tb-onglet-ic { background: #dff1e3; }
.tb-onglet.is-actif .tb-onglet-txt { font-weight: 800; }
.tb-onglet:active .tb-onglet-ic, .tb-onglet.is-ouvert .tb-onglet-ic { transform: scale(.9); background: #e8f3ea; }
.tb-onglet.is-charge .tb-onglet-ic::after, .tb-fab.is-charge .tb-fab-rond::after {
    content: ""; position: absolute; inset: auto 50% -5px auto; width: 5px; height: 5px; margin-right: -2.5px; border-radius: 50%;
    background: var(--tb-vert-moyen); animation: tbPoint .8s ease-in-out infinite alternate;
}
@keyframes tbPoint { to { transform: translateY(-3px); opacity: .3; } }

/* Bouton central, en relief */
.tb-fab-place { flex: 0 0 72px; display: flex; justify-content: center; }
.tb-fab {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
    width: 76px; padding: 0 0 9px; margin-top: -26px; border: 0; background: none; cursor: pointer; font: inherit;
    color: var(--tb-vert) !important; text-decoration: none !important;
}
.tb-fab-rond {
    position: relative; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%;
    color: var(--tb-or);
    background: radial-gradient(circle at 30% 22%, #4caf50 0%, var(--tb-vert-moyen) 30%, var(--tb-vert) 62%, var(--tb-vert-nuit) 100%);
    box-shadow: 0 0 0 4px #fff, 0 14px 26px -8px rgba(11, 61, 46, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
    transition: transform .2s cubic-bezier(.2, .9, .25, 1.3);
}
.tb-fab-rond svg { width: 28px; height: 28px; }
.tb-fab .tb-onglet-txt { font-weight: 800; }
.tb-fab:active .tb-fab-rond, .tb-fab.is-ouvert .tb-fab-rond { transform: scale(.92) rotate(-8deg); }
.tb-fab.is-or .tb-fab-rond { color: #3b2f00; background: radial-gradient(circle at 30% 22%, #ffe08a, var(--tb-or) 45%, #d99a00 100%);
    box-shadow: 0 0 0 4px #fff, 0 14px 26px -8px rgba(217, 154, 0, .75), inset 0 1px 0 rgba(255, 255, 255, .5); }
.tb-fab.is-or { color: #8a6500 !important; }
.tb-fab.is-direct .tb-fab-rond { color: #fff; background: radial-gradient(circle at 30% 22%, #ff6b74, #ff2d3d 45%, #8f0f1a 100%);
    box-shadow: 0 0 0 4px #fff, 0 14px 26px -8px rgba(255, 45, 61, .75); }
.tb-fab.is-direct { color: #c8102e !important; }
.tb-fab.is-direct .tb-fab-rond::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(255, 45, 61, .55);
    animation: tbOnde 1.6s ease-out infinite; }
@keyframes tbOnde { to { transform: scale(1.35); opacity: 0; } }
.tb-fab-point { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px #ff2d3d; }

.tb-badge {
    position: absolute; top: -4px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    display: grid; place-items: center; font-size: .62em; font-weight: 800; line-height: 1; color: #fff;
    background: #e5383b; box-shadow: 0 0 0 2px #fff;
}

body.has-tb-dock { padding-bottom: calc(var(--tb-dock-h) + 30px + var(--tb-bas)) !important; }

/* ---------------------------------------------------------------- Feuilles --- */
.tb-feuille { display: block; position: fixed; inset: 0; z-index: 1080; }
.tb-feuille[hidden] { display: none; }
.tb-feuille-fond {
    position: absolute; inset: 0; background: rgba(6, 22, 15, .5);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .3s;
}
.tb-feuille-panneau {
    position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
    max-height: 90vh; max-height: 90dvh; padding: 8px 16px calc(18px + var(--tb-bas));
    border-radius: 28px 28px 0 0; background: #f6f8f6; color: var(--tb-encre);
    box-shadow: 0 -18px 50px rgba(6, 22, 15, .3);
    transform: translateY(105%); transition: transform .42s cubic-bezier(.2, .9, .25, 1);
}
.tb-feuille.is-ouverte .tb-feuille-fond { opacity: 1; }
.tb-feuille.is-ouverte .tb-feuille-panneau { transform: none; }
.tb-feuille-panneau.is-glisse { transition: none; }
.tb-feuille-poignee { flex: none; width: 44px; height: 5px; margin: 2px auto 10px; border-radius: 3px; background: #c9d3cd; }
.tb-feuille-tete { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tb-feuille-sur { font-size: .7em; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tb-vert-moyen); }
.tb-feuille-titre { font-size: 1.45em; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--tb-encre); }
.tb-fermer {
    flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
    color: var(--tb-encre); background: #e6ece8;
}
.tb-fermer svg { width: 20px; height: 20px; }

/* Spiritualité : 4 grandes tuiles */
.tb-spirit-tete .tb-feuille-sur { color: #b8860b; }
.tb-spirit-grille { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tb-spirit-tuile {
    position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-height: 132px; padding: 16px;
    border-radius: 22px; color: #fff !important; text-decoration: none !important;
    box-shadow: 0 12px 24px -12px rgba(0, 0, 0, .45);
    opacity: 0; transform: translateY(14px) scale(.97);
    transition: transform .45s cubic-bezier(.2, .9, .25, 1.2), opacity .3s;
    transition-delay: calc(var(--i) * 45ms + 80ms);
}
.tb-feuille.is-ouverte .tb-spirit-tuile { opacity: 1; transform: none; }
.tb-spirit-tuile::after { content: ""; position: absolute; right: -28px; bottom: -28px; width: 96px; height: 96px; border-radius: 50%; background: rgba(255, 255, 255, .13); }
.tb-spirit-tuile:active { transform: scale(.97); }
.tb-spirit-ic { width: 46px; height: 46px; margin-bottom: auto; border-radius: 15px; display: grid; place-items: center; background: rgba(255, 255, 255, .2); }
.tb-spirit-ic svg { width: 25px; height: 25px; }
.tb-spirit-tuile b { margin-top: 12px; font-size: 1.05em; line-height: 1.15; }
.tb-spirit-tuile small { font-size: .76em; line-height: 1.25; opacity: .88; }
.tb-spirit-tuile.ton-vert { background: linear-gradient(140deg, #2e7d32, #0b3d2e); }
.tb-spirit-tuile.ton-or { background: linear-gradient(140deg, #e0a800, #9a6a00); }
.tb-spirit-tuile.ton-rouge { background: linear-gradient(140deg, #e53945, #8f0f1a); }
.tb-spirit-tuile.ton-bleu { background: linear-gradient(140deg, #2b7de9, #1a3f8f); }

/* Menu */
.tb-menu-defile { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -16px; padding: 0 16px 6px; -webkit-overflow-scrolling: touch; }
.tb-compte {
    display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 12px; border-radius: 20px;
    color: #fff !important; text-decoration: none !important;
    background: radial-gradient(120% 120% at 100% 0%, rgba(245, 197, 66, .35), transparent 55%), linear-gradient(135deg, var(--tb-vert-moyen), var(--tb-vert-nuit));
}
.tb-avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.2em; font-weight: 800;
    color: var(--tb-vert-nuit); background: var(--tb-or); }
.tb-compte-txt { flex: 1; min-width: 0; line-height: 1.25; }
.tb-compte-txt small { display: block; font-size: .72em; opacity: .8; }
.tb-compte-txt b { display: block; font-size: 1.02em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-compte-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; font-weight: 800; font-size: .85em;
    color: var(--tb-vert-nuit) !important; background: #fff; text-decoration: none !important; }
.tb-compte-btn svg { width: 18px; height: 18px; }
.tb-compte-fleche { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .18); }
.tb-compte-fleche svg { width: 18px; height: 18px; }

.tb-recherche { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 0 14px; height: 48px; border-radius: 16px;
    background: #fff; box-shadow: inset 0 0 0 1px var(--tb-ligne); color: var(--tb-gris); cursor: text; }
.tb-recherche input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 1em; color: var(--tb-encre); }
.tb-recherche:focus-within { box-shadow: inset 0 0 0 2px var(--tb-vert-moyen); }
.tb-rien { margin: 18px 0; text-align: center; color: var(--tb-gris); font-size: .9em; }

.tb-section { margin-top: 16px; }
.tb-section[hidden] { display: none; }
.tb-section h3 { margin: 0 0 8px 4px; font-size: .72em; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tb-gris); }
.tb-tuiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tb-tuile {
    display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px 11px; border-radius: 18px; text-align: center;
    color: var(--tb-encre) !important; text-decoration: none !important; background: #fff; box-shadow: inset 0 0 0 1px var(--tb-ligne);
    transition: transform .15s;
}
.tb-tuile[hidden] { display: none; }
.tb-tuile:active { transform: scale(.95); }
.tb-tuile-ic { position: relative; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.tb-tuile-ic .tb-badge { top: -6px; right: -8px; }
.tb-tuile-txt { font-size: .78em; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tb-tuile-txt small { display: block; margin-top: 2px; font-size: .85em; font-weight: 600; color: var(--tb-gris); }
.ton-vert .tb-tuile-ic { color: var(--tb-vert); background: #e3f3e6; }
.ton-or .tb-tuile-ic { color: #8a6500; background: #fff1c9; }
.ton-rouge .tb-tuile-ic { color: #b3242f; background: #fde4e4; }
.ton-bleu .tb-tuile-ic { color: #1d5fc2; background: #e4effd; }
.ton-gris .tb-tuile-ic { color: #4b5a52; background: #eaeeeb; }

.tb-menu-pied { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 4px; }
.tb-pied-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer;
    font: inherit; font-size: .86em; font-weight: 700; color: var(--tb-encre) !important; background: #e6ece8; text-decoration: none !important; }
.tb-pied-btn svg { width: 18px; height: 18px; }
.tb-pied-btn.is-rouge { color: #b3242f !important; background: #fde4e4; }
.tb-pied-btn.is-actif { color: #fff !important; background: var(--tb-vert-moyen); }
.tb-pied-btn[hidden] { display: none; }

/* Focus clavier visible partout */
.tb-dock a:focus-visible, .tb-dock button:focus-visible, .tb-feuille a:focus-visible, .tb-feuille button:focus-visible {
    outline: 3px solid var(--tb-or); outline-offset: 2px; border-radius: 14px;
}

/* ------------------------------------------------- Tirer pour actualiser ----- */
.tb-ptr {
    display: grid; place-items: center; position: fixed; top: 0; left: 50%; z-index: 10050; width: 44px; height: 44px; border-radius: 50%;
    color: var(--tb-vert); background: #fff; box-shadow: 0 6px 18px rgba(11, 61, 46, .28);
    transform: translate(-50%, -56px); opacity: 0; pointer-events: none;
}
.tb-ptr svg { width: 22px; height: 22px; stroke-width: 2.4; }
.tb-ptr.is-pret { color: #fff; background: var(--tb-vert-moyen); }
.tb-ptr.is-retour { transition: transform .3s, opacity .3s; }
.tb-ptr.is-actualise { color: #fff; background: var(--tb-vert-moyen); transition: transform .2s; }
.tb-ptr.is-actualise svg { animation: tbTourne .7s linear infinite; }
@keyframes tbTourne { to { transform: rotate(360deg); } }

/* ------------------------------------------- Site public : en-tête allégé ----- */
.top-bar, .main-navbar { display: none !important; }
.top-nav .navbar-toggler, .top-nav .navbar-collapse { display: none !important; }
.top-nav { padding-top: 6px !important; padding-bottom: 6px !important; }
.top-nav > .container { justify-content: center !important; }

/* Bannière « Restez informé » : carte compacte au-dessus de la barre, plus en plein écran */
#push-notification-banner {
    top: auto !important; left: 12px !important; right: 12px !important; bottom: calc(var(--tb-dock-h) + 22px + var(--tb-bas)) !important;
    border-radius: 20px; animation: tbEntree .5s cubic-bezier(.2, .9, .25, 1) both !important;
}
#push-notification-banner .container { padding: 12px 14px !important; }
#push-notification-banner .row { flex-wrap: wrap; --bs-gutter-x: .7rem; --bs-gutter-y: 0; }
#push-notification-banner .col-auto:first-child > div { width: 40px !important; height: 40px !important; }
#push-notification-banner .col-auto:first-child i { font-size: 18px !important; }
#push-notification-banner .col { min-width: 0; }
#push-notification-banner h5 { font-size: 1rem; margin-bottom: 2px !important; }
#push-notification-banner p { font-size: .8rem !important; line-height: 1.35; }
#push-notification-banner .col-auto:last-child { flex: 0 0 100%; display: flex; gap: 8px; margin-top: 10px; }
#push-notification-banner .col-auto:last-child .btn { margin: 0 !important; padding: .45rem .9rem !important; font-size: .88rem; white-space: nowrap; }
#push-notification-banner .col-auto:last-child .btn:first-child { flex: 1; }

/* Ancienne barre des espaces : remplacée par la barre commune */
.gm-dock { display: none !important; }
}

@media (max-width: 991.98px) and (prefers-reduced-motion: reduce) {
    .tb-dock, .tb-dock.is-entree, .tb-feuille-panneau, .tb-feuille-fond, .tb-spirit-tuile, .tb-fab-rond { animation: none !important; transition: none !important; }
    .tb-fab.is-direct .tb-fab-rond::before { display: none; }
}
