/* =====================================================================
   mobile.css — Patrimoine Félinois
   Chargé par inc/menu.php sur toutes les pages publiques.
   1) Barre de navigation commune + panneau de menu
   2) Corrections communes smartphone / tablette
   Toutes les classes du menu commencent par "pf-" pour ne jamais
   entrer en conflit avec le style propre à chaque page.
   ===================================================================== */

:root {
    --pf-bar-h: 56px;
    --pf-or: #d8b06a;
    --pf-or-clair: #f0d28b;
    --pf-fond: #140c05;
    --pf-fond-2: #22160b;
    --pf-texte: #fff4d6;
}

/* ---------- 1. BARRE DU HAUT ---------- */

html { scroll-padding-top: calc(var(--pf-bar-h) + 10px); }

body { padding-top: var(--pf-bar-h) !important; }

.pf-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--pf-bar-h);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    background: rgba(20, 12, 5, .96);
    border-bottom: 2px solid var(--pf-or);
    box-shadow: 0 2px 12px rgba(0,0,0,.5);
    box-sizing: border-box;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.pf-bar-home {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--pf-texte) !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .5px;
}
.pf-bar-icon { font-size: 1.3rem; line-height: 1; }
.pf-bar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pf-bar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border: 2px solid var(--pf-or-clair);
    border-radius: 10px;
    background: linear-gradient(to bottom, #c9a15d, #7a5321);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.pf-burger { display: inline-flex; flex-direction: column; gap: 4px; }
.pf-burger span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 2px; }

/* ---------- PANNEAU DU MENU ---------- */

.pf-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: rgba(0,0,0,.6);
}
.pf-backdrop[hidden] { display: none; }

.pf-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(420px, 100%);
    z-index: 2147483001;
    display: flex;
    flex-direction: column;
    background: var(--pf-fond);
    border-left: 2px solid var(--pf-or);
    box-shadow: -6px 0 30px rgba(0,0,0,.6);
    transform: translateX(105%);
    transition: transform .3s ease;
    visibility: hidden;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    box-sizing: border-box;
}
.pf-menu-ouvert .pf-panel { transform: none; visibility: visible; }
.pf-menu-ouvert, .pf-menu-ouvert body { overflow: hidden; }

.pf-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--pf-bar-h);
    padding: 0 12px 0 18px;
    border-bottom: 1px solid rgba(216,176,106,.4);
    flex-shrink: 0;
}
.pf-panel-title { color: var(--pf-or-clair); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: .95rem; }
.pf-close {
    width: 44px; height: 44px;
    border: 2px solid var(--pf-or);
    border-radius: 10px;
    background: transparent;
    color: var(--pf-texte);
    font-size: 1.2rem;
    cursor: pointer;
}

.pf-panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px 0 calc(30px + env(safe-area-inset-bottom));
}

.pf-section { border-bottom: 1px solid rgba(216,176,106,.18); }
.pf-section summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 0 18px;
    color: var(--pf-or-clair);
    font-weight: 700;
    font-size: 1.02rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.pf-section summary::-webkit-details-marker { display: none; }
.pf-section summary::after {
    content: "▾";
    font-size: 1rem;
    transition: transform .2s;
}
.pf-section[open] summary::after { transform: rotate(180deg); }
.pf-section[open] summary { background: var(--pf-fond-2); }

.pf-section ul { list-style: none; margin: 0; padding: 4px 0 10px; background: var(--pf-fond-2); }
.pf-section li { margin: 0; }
.pf-section a {
    display: block;
    padding: 12px 18px 12px 30px;
    color: var(--pf-texte) !important;
    text-decoration: none !important;
    font-family: Georgia, 'EB Garamond', 'Times New Roman', serif;
    font-size: 1.05rem;
    line-height: 1.3;
    border-left: 4px solid transparent;
}
.pf-section a:hover, .pf-section a:focus { background: rgba(216,176,106,.15); }
.pf-section a.pf-actif {
    border-left-color: var(--pf-or);
    background: rgba(216,176,106,.22);
    color: #fff !important;
    font-weight: 700;
}

/* Écrans très étroits : on raccourcit le titre */
@media (max-width: 360px) {
    .pf-bar-title { font-size: .9rem; }
    .pf-toggle-label { display: none; }
}

/* ---------- TEXTE DU BOUTON "ÉCOUTER" (tous écrans) ----------
   Le texte s'ouvre vers le haut depuis le bas de l'écran : on limite
   sa hauteur pour qu'il ne passe jamais sous la barre du menu, et on
   le rend défilable pour pouvoir lire le début. */
.narration-transcript {
    max-height: calc(100vh - var(--pf-bar-h) - 170px);
    max-height: calc(100dvh - var(--pf-bar-h) - 170px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ---------- 2. CORRECTIONS COMMUNES SMARTPHONE ---------- */

@media (max-width: 768px) {

    /* rien ne doit dépasser de la largeur de l'écran */
    html, body { overflow-x: hidden; max-width: 100%; }
    img, video, iframe, embed, object, canvas, svg { max-width: 100%; }
    img, video { height: auto; }
    table { display: block; max-width: 100%; overflow-x: auto; }
    pre, code { white-space: pre-wrap; word-break: break-word; }
    h1, h2, h3 { overflow-wrap: anywhere; hyphens: auto; }

    /* champs de formulaire : 16px minimum sinon l'iPhone zoome tout seul */
    input, select, textarea { font-size: 16px !important; max-width: 100%; }

    /* musique d'ambiance : le lecteur ne flotte plus par-dessus le texte,
       il se place normalement dans la page, en pleine largeur */
    body > audio[loop] {
        position: static !important;
        display: block;
        width: calc(100% - 24px) !important;
        margin: 10px auto !important;
        opacity: 1 !important;
    }

    /* bouton "Écouter" : rond, bien en bas, hors du texte */
    .narration-widget { bottom: calc(14px + env(safe-area-inset-bottom)); }
}
