/*
 * Maintelio : couche responsive globale (chargée en dernier par les mises en page ghmr, app et guest).
 * - Règles de base sûres (médias, longs textes, formulaires, zones tactiles, encoches) ;
 * - classes posées par public/js/gh-responsive.js uniquement sur les éléments qui débordent réellement sous 1024 px :
 *   .gh-rsp-scroll (tableau défilant), .gh-rsp-stack (grille repliée sur une colonne), .gh-rsp-wrap (ligne flex qui passe à la ligne), .gh-rsp-fit (largeur bornée).
 * Aucune règle ne s'applique au-dessus de 1024 px : l'affichage ordinateur est inchangé.
 */

/* ---------- Base (tous écrans, sans effet visuel sur ordinateur) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; }
:is(.gh-main, .gh-rsp-root) { min-width: 0; }
:is(.gh-main, .gh-rsp-root) :where(img, video, svg, iframe, embed, object) { max-width: 100%; }
:is(.gh-main, .gh-rsp-root) :where(img, video) { height: auto; }
:is(.gh-main, .gh-rsp-root) :where(pre) { max-width: 100%; overflow-x: auto; }
:is(.gh-main, .gh-rsp-root) :where(p, li, dd, dt, td, th, h1, h2, h3, h4, label, a, small) { overflow-wrap: break-word; }
:is(.gh-main, .gh-rsp-root) :where(input, select, textarea) { max-width: 100%; }

/* ---------- Défilement horizontal d'un tableau qui ne tient pas ---------- */
.gh-rsp-scroll { display: block; position: relative; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.gh-rsp-scroll > table { min-width: max-content; }

/* ---------- Tablette et mobile (< 1024 px) ---------- */
@media (max-width: 1023.98px) {
    .gh-rsp-stack { grid-template-columns: minmax(0, 1fr) !important; grid-auto-flow: row !important; }
    .gh-rsp-stack > * { min-width: 0; grid-column: auto !important; }
    .gh-rsp-wrap { flex-wrap: wrap !important; }
    .gh-rsp-wrap > * { min-width: 0; }
    .gh-rsp-fit { max-width: 100% !important; box-sizing: border-box; }
    /* Fenêtres et panneaux : jamais plus larges que l'écran */
    [role="dialog"], .modal-box, dialog { max-width: calc(100vw - 1rem); }
}

/* ---------- Mobile (< 640 px) ---------- */
@media (max-width: 639.98px) {
    /* 16 px minimum : iOS ne zoome plus à la saisie */
    :is(.gh-main, .gh-rsp-root) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) { font-size: 16px; }
    /* Zones tactiles confortables */
    :is(.gh-main, .gh-rsp-root) :where(button, [type="button"], [type="submit"], .gd-btn, .btn, a.gd-btn) { min-height: 40px; }
    :is(.gh-main, .gh-rsp-root) :where(h1) { font-size: clamp(1.25rem, 5.6vw, 1.6rem); line-height: 1.2; }
    :is(.gh-main, .gh-rsp-root) :where(h2) { font-size: clamp(1.05rem, 4.6vw, 1.3rem); }
    /* Barres d'actions : boutons empilés plutôt que tronqués */
    :is(.gh-main, .gh-rsp-root) :where(.gr-head-actions, .gd-actions, .page-actions) { display: flex; flex-wrap: wrap; gap: .5rem; }
    /* Pagination et onglets : défilement doux plutôt que débordement */
    :is(.gh-main, .gh-rsp-root) :where(nav[aria-label*="agination"], .tabs, .gd-tabs, [role="tablist"]) { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    :is(.gh-main, .gh-rsp-root) :where(nav[aria-label*="agination"], .tabs, .gd-tabs, [role="tablist"])::-webkit-scrollbar { display: none; }
}

/* ---------- Très petit écran (< 380 px) ---------- */
@media (max-width: 379.98px) {
    .gh-main { padding-left: .5rem; padding-right: .5rem; }
}

/* ---------- Écrans tactiles : survol non requis ---------- */
@media (hover: none) {
    :is(.gh-main, .gh-rsp-root) :where(a, button) { -webkit-tap-highlight-color: rgba(37, 99, 235, .12); }
}

/* ---------- Impression : la couche responsive ne change rien ---------- */
@media print {
    .gh-rsp-scroll { overflow: visible; }
    .gh-rsp-stack { grid-template-columns: revert-layer !important; }
}

/* Lignes de liste : sous-texte à la ligne plutôt que tronqué sur mobile */
@media (max-width: 639.98px) {
    .gd-line-sub { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
}
