:root {
    --hu-reveal-y: 14px;
    --hu-reveal-dur: .55s;
    --hu-filter-from: none;
}

@media (min-width: 768px) {
    :root {
        --hu-reveal-y: 24px;
        --hu-reveal-dur: .7s;
        --hu-filter-from: blur(8px);
    }
}

/* ---------- Base ---------- */
html {
    scroll-padding-top: 72px;
    /* les ancres ne passent plus sous le header sticky (60 px sur mobile) */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: color-mix(in srgb, var(--hu-primary-soft) 28%, transparent);
}

@media (min-width: 992px) {
    html {
        scroll-padding-top: 96px;
    }
}

/* Supprime le délai et le zoom au double-tap sur les éléments interactifs */
a,
button,
input,
select,
textarea,
label,
summary,
[role="button"] {
    touch-action: manipulation;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }

    /* Transitions fluides entre pages (Chrome/Edge/Safari récents, ignoré ailleurs) */
    @view-transition {
        navigation: auto;
    }
}

body {
    font-family: var(--hu-font-body);
    color: var(--dark-gray-color);
    font-size: var(--hu-fs-body);
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    font-family: var(--hu-font-heading);
    line-height: 1.15;
    text-wrap: balance;
    letter-spacing: -.025em;
}

h1 {
    font-size: var(--hu-fs-h1);
}

h2 {
    font-size: var(--hu-fs-h2);
}

h3 {
    font-size: var(--hu-fs-h3);
}

p,
li {
    text-wrap: pretty;
}

::selection {
    background: var(--hu-primary-soft);
    color: #fff;
}

img,
video {
    max-width: 100%;
    height: auto;
}

/* Focus clavier visible et élégant (accessibilité) */
:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--hu-info) 70%, white);
    outline-offset: 3px;
    border-radius: var(--hu-radius-s);
}

#hero .hero-title,
#hero .hero-subtitle {
    color: var(--white-color);
    text-shadow: 0 2px 12px var(--text-shadow);
}

#hero .hero-subtitle {
    font-size: clamp(1.1rem, 0.9rem + 1vw, 1.6rem);
    line-height: 1.4;
}

/* ==========================================================================
   BOUTONS, FORMULAIRES ET ÉLÉMENTS D'INTERFACE
   ========================================================================== */
/* ---------- Éléments d'interface ---------- */
/* Boutons : on ne touche pas aux couleurs (custom.css), seulement au ressenti */
.btn {
    font-family: var(--hu-font-heading);
    transition: transform .2s var(--hu-ease-spring), box-shadow .2s var(--hu-ease),
        background-color .3s var(--hu-ease), color .3s var(--hu-ease);
}

.btn:active {
    transform: scale(.97);
}

/* retour au toucher (le survol est plus bas, souris uniquement) */

/* Formulaires */
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="range"], [type="file"], [type="hidden"], [type="color"], [type="image"], [type="reset"]),
select,
textarea,
.form-control,
.form-select {
    border-radius: var(--hu-radius-s);
    border: 1px solid color-mix(in srgb, var(--dark-gray-color) 22%, transparent);
    padding: .7rem .95rem;
    font-size: max(1rem, 16px);
    /* sous 16 px, Safari iPhone zoome la page à la saisie */
    background-color: var(--white-color);
    transition: border-color .2s var(--hu-ease), box-shadow .2s var(--hu-ease);
}

input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="range"], [type="file"], [type="hidden"], [type="color"], [type="image"], [type="reset"]):focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--hu-primary-soft);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--hu-primary-soft) 25%, transparent);
    outline: none;
}

/* Pagination en pastilles */
.pagination {
    gap: .35rem;
    flex-wrap: wrap;
}

.pagination>li>a,
.pagination>li>span,
.pagination .page-link {
    border-radius: var(--hu-radius-pill);
    border: 1px solid var(--hu-line);
    min-width: 2.5rem;
    text-align: center;
    transition: background-color .2s var(--hu-ease), transform .2s var(--hu-ease);
}

/* Tags en chips */
.tags>li a {
    border-radius: var(--hu-radius-pill);
    padding: .25rem .8rem;
    font-size: .8rem;
}

/* Bouton retour en haut */
.scroll-up {
    border-radius: var(--hu-radius-pill);
    box-shadow: var(--hu-shadow-m);
    transition: transform .25s var(--hu-ease-spring), opacity .25s var(--hu-ease);
}

/* ---------- Zones de toucher (écrans tactiles) ----------
   Cibles d'au moins 44 px : un doigt n'est pas un curseur. */
@media (pointer: coarse) {

    .btn {
        min-height: 44px;
        padding-block: .65rem;
    }

    .pagination>li>a,
    .pagination>li>span,
    .pagination .page-link {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .tags>li a {
        min-height: 44px;
        padding: .5rem 1rem;
        display: inline-flex;
        align-items: center;
    }

    input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="range"], [type="file"], [type="hidden"], [type="color"], [type="image"], [type="reset"]),
    select,
    .form-control,
    .form-select {
        min-height: 48px;
    }
}

@media (hover: hover) and (pointer: fine) {
    #header .logo a:hover img {
        transform: scale(1.03);
    }

    .scroll-up:hover {
        transform: translateY(-4px);
    }
}

/* ==========================================================================
   HERO
   ========================================================================== */
/* ---------- Hero : logo masqué sur téléphone ----------
   Le logo est déjà dans le header : on libère de la place pour le titre.
   On cache aussi le lien qui l'entoure (sinon il reste un vide), et il faut !important
   car Bootstrap force display:inline-block !important sur ce lien (classe d-inline-block).
   Seuil : 767 px. Pour changer, modifier uniquement ce nombre. */
@media (max-width: 767.98px) {

    #hero .hero-premium a:has(> .hero-logo),
    #hero .hero-logo {
        display: none !important;
    }
}

/* ---------- Hero : structure unique (hauteur, image de fond, texte) ----------
   Seul endroit qui dimensionne et positionne le hero : ne pas le redéfinir dans base.css.
   - min-height (et non height) : la section grandit si le texte est long sur petit écran.
   - L'image est en absolute et recadrée (object-fit) : jamais déformée.
   - overflow hidden : coupe le zoom Ken Burns (section animations) qui déborde. */
#hero {
    position: relative;
    width: 100%;
    min-height: 70vh;
    /* repli anciens navigateurs */
    min-height: clamp(320px, 70svh, 800px);
    overflow: hidden;
}

#hero .hero-media {
    position: absolute;
    inset: 0;
}

#hero .hero-media img,
#hero .imagefond {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

#hero .hero-premium {
    position: relative;
    z-index: 2;
    min-height: inherit;
}

#hero::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 160px;
    background:
        linear-gradient(to bottom,
            color-mix(in srgb, var(--body-background-color) 0%, transparent) 0%,
            var(--body-background-color) 100%),
        url("/images/masques/vague.svg") no-repeat bottom center;
    background-size: cover;
    pointer-events: none;
    z-index: 1;
}

/* ==========================================================================
   FOOTER ET MINI-PORTFOLIO
   ========================================================================== */
#footer a {
    transition: color .2s var(--hu-ease), opacity .2s var(--hu-ease);
}

/* ==========================================================
   9b. MINI-PORTFOLIO DU FOOTER
   Masonry + GLightbox
   ========================================================== */
.bottom-col--portfolio {
    min-width: 0;
}

.bottom-col--portfolio h3 {
    margin-bottom: 18px;
}

/* ----------------------------------------------------------
   Grille classique : fonctionnement sans JavaScript
---------------------------------------------------------- */
.bottom-portfolio-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

/* ----------------------------------------------------------
   Vignettes
---------------------------------------------------------- */
.bottom-portfolio-item {
    position: relative;
    display: block;
    min-width: 0;
    overflow: hidden;
    border-radius: 10px;
    background: var(--dark-green-color);
    text-decoration: none;
}

.bottom-portfolio-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform .4s ease;
}

/* ----------------------------------------------------------
   Masonry activé par JavaScript
---------------------------------------------------------- */
.bottom-portfolio-grid.is-masonry {
    display: block;
    position: relative;
}

.bottom-portfolio-grid.is-masonry .bottom-portfolio-item {
    width: calc((100% - 10px) / 2);
    margin-bottom: 10px;
}

/* ----------------------------------------------------------
   Légende
---------------------------------------------------------- */
.bottom-portfolio-caption {
    position: absolute;
    inset: auto 0 0;
    padding: 25px 8px 9px;
    color: var(--white-color);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    background: linear-gradient(to top,
            rgba(0, 0, 0, .78),
            rgba(0, 0, 0, 0));
}

/* ----------------------------------------------------------
   Survol
---------------------------------------------------------- */

@media (hover: hover) {
    .bottom-portfolio-item:hover img {
        transform: scale(1.08);
    }

    .bottom-portfolio-item:hover .bottom-portfolio-caption {
        background: linear-gradient(to top,
                rgba(0, 0, 0, .9),
                rgba(0, 0, 0, .1));
    }
}

/* ----------------------------------------------------------
   Accessibilité clavier
---------------------------------------------------------- */
.bottom-portfolio-item:focus-visible {
    outline: 3px solid var(--dark-yellow-color);
    outline-offset: 3px;
}

/* ----------------------------------------------------------
   Mouvement réduit
---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .bottom-portfolio-item img {
        transition: none;
    }
}



/* ==========================================================================
   APPARITION AU SCROLL ET COMPTEURS
   ========================================================================== */
/* ---------- Apparition au scroll (piloté par js/custom.js) ---------- */
/* La classe hu-js n'est posée que si le JS tourne : sans JS, tout reste visible.
   Pas de will-change ici : sur téléphone, des dizaines d'éléments promus en calques
   gaspillent de la mémoire ; le navigateur les promeut tout seul pendant la transition. */
.hu-js .hu-reveal {
    opacity: 0;
    transform: translateY(var(--hu-reveal-y));
    transition: opacity var(--hu-reveal-dur) var(--hu-ease), transform var(--hu-reveal-dur) var(--hu-ease);
    transition-delay: var(--hu-delay, 0ms);
}

.hu-js .hu-reveal.is-visible {
    opacity: 1;
    transform: none;
}


/* ---------- 10a. Compteurs page Accueil ---------- */
.hdl-counters-sec {
    padding: clamp(24px, 4vw, 44px) 0 0;
}

.hdl-counters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    background: #fff;
    border: 1px solid #e4decb;
    border-radius: 16px;
    padding: clamp(20px, 3vw, 32px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.03);
}

.hdl-counter-item {
    text-align: center;
    padding: 8px 12px;
    position: relative;
}

.hdl-counter-item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: -10px;
    top: 15%;
    height: 70%;
    width: 1px;
    background: #ece6d6;
}

.hdl-counter-val {
    display: block;
    font-size: clamp(32px, 4vw, 46px);
    line-height: 1.1;
    color: #1F6F78;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.hdl-counter-item p {
    margin: 0;
    font-size: 14px;
    color: #555;
    line-height: 1.4;
}

@media (max-width: 900px) {
    .hdl-counters-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hdl-counter-item:nth-child(2)::after {
        display: none;
    }
}

@media (max-width: 480px) {
    .hdl-counters-grid {
        grid-template-columns: 1fr;
    }

    .hdl-counter-item::after {
        display: none;
    }
}

/* ---------- 10b. Animations dynamiques ----------
   Tout est dans prefers-reduced-motion: no-preference : les visiteurs qui ont réduit
   les animations dans leur système ne voient rien bouger. */
@media (prefers-reduced-motion: no-preference) {

    /* Titres : flou qui se précise (tablette et plus seulement : --hu-filter-from vaut « none » sur mobile) */
    .hu-js .hu-reveal:is(h1, h2, h3, h4) {
        filter: var(--hu-filter-from);
        transition: opacity var(--hu-reveal-dur) var(--hu-ease), transform var(--hu-reveal-dur) var(--hu-ease),
            filter var(--hu-reveal-dur) var(--hu-ease);
        transition-delay: var(--hu-delay, 0ms);
    }

    .hu-js .hu-reveal:is(h1, h2, h3, h4).is-visible {
        filter: none;
    }

    /* Petites icônes Font Awesome dans les textes : rebond à l'apparition */
    .txt i.fas {
        display: inline-block;
    }

    .txt i.fas.hu-icon-in {
        animation: hu-icon-pop .7s var(--hu-ease-spring) .25s backwards;
    }

    @keyframes hu-icon-pop {
        from {
            scale: 0;
            rotate: -25deg;
        }
    }

    /* --- Hero : entrée en scène (au chargement) --- */
    /* On anime les propriétés indépendantes translate / scale : elles se combinent avec
       le transform existant (le titre garde sa rotation de -5°). Sans « to » : l'arrivée
       se fait sur l'état normal défini dans custom.css. */
    @keyframes hu-hero-in {
        from {
            opacity: 0;
            translate: 0 28px;
            scale: .96;
            filter: var(--hu-filter-from);
        }
    }

    .hero-logo {
        animation: hu-hero-in 1s var(--hu-ease) .10s backwards;
    }

    .hero-title {
        animation: hu-hero-in 1.1s var(--hu-ease) .35s backwards;
    }

    /* Cartes d'hébergement Thelis : pas de « lever » de la carte (le carrousel
       coupe ce qui dépasse) ; zoom lent sur la photo, souris seulement. */
    .thr-favorite .thr-box-picture {
        overflow: hidden;
    }

    .thr-favorite .thr-box-picture>span {
        transition: transform .9s var(--hu-ease);
    }

    /* --- Enrichissements « grand écran » --- */
    @media (min-width: 768px) {

        /* Photo de fond : lent zoom arrière (effet « Ken Burns »).
           Réservé aux écrans larges : sur téléphone, on évite une animation continue sur une grande image. */
        @keyframes hu-kenburns {
            from {
                scale: 1.12;
            }
        }

        #hero .fond-aleatoire {
            overflow: hidden;
        }

        .imagefond {
            animation: hu-kenburns 14s var(--hu-ease) backwards;
            transform-origin: 50% 30%;
        }
    }

    /* Souris : survols animés */
    @media (hover: hover) and (pointer: fine) {
        .thr-favorite:hover .thr-box-picture>span {
            transform: scale(1.07);
        }
    }

    /* La carte de France flotte doucement (on garde son fadeUp d'origine).
       Boucle infinie : écran large + souris seulement (économie de batterie). */
    @media (min-width: 768px) and (hover: hover) {
        @keyframes hu-float {
            50% {
                translate: 0 -7px;
            }
        }

        #hero .hero-map {
            animation: fadeUp 1.6s ease forwards, hu-float 6s ease-in-out 1.8s infinite;
        }
    }

    /* --- Pilotées par le scroll (CSS pur, zéro JavaScript, très fluide) ---
       Navigateurs récents seulement ; les autres ignorent ce bloc sans rien casser. */
    @supports (animation-timeline: scroll()) {

        /* Barre de progression de lecture, tout en haut de l'écran */
        @keyframes hu-progress {
            to {
                transform: scaleX(1);
            }
        }

        html::after {
            content: "";
            position: fixed;
            inset: 0 0 auto 0;
            height: 4px;
            z-index: 100000;
            pointer-events: none;
            background: linear-gradient(90deg, var(--hu-primary-soft), var(--hu-info), var(--dark-yellow-color));
            transform: scaleX(0);
            transform-origin: 0 50%;
            animation: hu-progress linear both;
            animation-timeline: scroll(root block);
        }
    }
}

/* ==========================================================================
   ACCESSIBILITÉ ET IMPRESSION
   ========================================================================== */
/* ---------- Respect des préférences utilisateur ---------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }

    .hu-js .hu-reveal {
        opacity: 1;
        transform: none;
    }
}

/* Impression : on retire les effets */
@media print {
    #header {
        position: static;
        box-shadow: none;
    }

    #header::before {
        display: none;
    }

    .hu-js .hu-reveal {
        opacity: 1;
        transform: none;
    }
}
