/* ============================================
   VARIABLES : modifier ici pour changer les
   couleurs ou la police sur tout le site
   ============================================ */
:root {
    --color-black: #000;
    --color-white: #fff;
    --color-gray: rgb(160, 160, 160);
    --font-main: "Myriad Pro", Verdana, sans-serif;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    font-weight: bold;
    margin: 0;
    padding: 0;
    color: var(--color-black);
    /* Permet au pied de page de rester collé en bas
       même quand le contenu est court (page contact) */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
header {
    background-color: var(--color-white);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
}

/* Nom de l'agence : <h1> sur l'accueil, <span> sur les autres pages */
header .brand-title {
    display: block;
    margin: 0;
    font-size: 1.872em;
}

nav {
    display: flex;
    font-size: 1.4em;
}

nav a {
    text-decoration: none;
    color: var(--color-gray);
    margin-right: 16px;
    transition: color 0.4s;
}

nav a:hover {
    color: var(--color-black);
}

nav a.actuel {
    color: var(--color-black);
}

.brand {
    text-decoration: none;
    color: inherit;
}

/* Texte lu par Google et les lecteurs d'écran, mais invisible */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    /* En bas du flux de la page (pas en superposition) */
    margin-top: auto;
    padding: 8px 24px;
    background-color: var(--color-white);
    color: var(--color-black);
    font-size: 0.85em;
}

.site-footer p {
    margin: 0;
    font-weight: normal;
}

/* Accueil : footer transparent, superposé au bas de la photo */
.accueil + .site-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    background-color: transparent;
    color: var(--color-white);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.accueil + .site-footer a {
    color: inherit;
}

/* ============================================
   MAIN : décalage sous le header fixe
   ============================================ */
main {
    padding: 0;
    margin-top: 90px;
}

/* ============================================
   PAGE ACCUEIL (index.html)
   ============================================ */
.accueil {
    /* Remplit l'écran moins la hauteur du pied de page */
    flex: 1;
    display: flex;
    background-image: url('../images/Accueil.jpg');
    background-size: cover;
    background-position: center;
    color: var(--color-white);
    position: relative;
    z-index: 1;
}

.accueil header {
    width: 100%;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 40px 0 0 40px;
    position: relative;
}

.accueil header .brand-title {
    font-size: 3.312em;
    margin: 0;
}

/* Titre et liens sur la photo : contour net + ombre douce.
   paint-order dessine le contour derrière le texte : sur les 2px de
   trait, seul 1px extérieur reste visible (comme l'ancien contour). */
.accueil header .brand-title,
.accueil nav a {
    -webkit-text-stroke: 2px var(--color-black);
    paint-order: stroke fill;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* Logo "CA" à gauche du titre (au-dessus sur mobile) */
.accueil .brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    width: 64px;
    height: 64px;
}

.accueil header nav {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.5em;
    justify-content: center;
    /* Sur petit écran, les liens passent à la ligne
       au lieu de déborder de l'écran */
    width: 100%;
    flex-wrap: wrap;
}

.accueil nav a {
    position: relative;
    /* Garde le panneau du survol (z-index: -1) derrière le texte,
       mais devant la photo */
    isolation: isolate;
    color: var(--color-white);
    margin-right: 72px;
    margin-bottom: 28px;
}

/* Filet blanc sous chaque lien : visible au repos (pour repérer un lien
   sans survol, notamment sur mobile). Au survol et au focus clavier, un
   panneau sombre translucide monte derrière le texte.
   Tailles en em : elles suivent la taille du texte à chaque breakpoint.
   Halo sombre doux sur le filet pour rester lisible sur les zones claires. */
.accueil nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: max(2px, 0.08em);
    background-color: var(--color-white);
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.75));
}

.accueil nav a::before {
    content: "";
    position: absolute;
    z-index: -1;
    left: -0.38em;
    right: -0.38em;
    bottom: -0.16em;
    height: 0;
    border-radius: 0.16em;
    background-color: rgba(0, 0, 0, 0.45);
    transition: height 0.3s;
}

.accueil nav a:hover::before,
.accueil nav a:focus-visible::before {
    height: calc(100% + 0.33em);
}

/* ============================================
   PAGE AGENCE (agence.html)
   ============================================ */
.agence {
    padding: 40px;
    max-width: 1300px;
    margin-left: auto;
    margin-right: auto;
}

.agence h1 {
    font-size: 1.3em;
    margin-top: 0;
    margin-bottom: 20px;
}

.agence p {
    font-size: 1em;
    line-height: 1.6;
    margin: 20px 0;
    text-align: justify;
}

.agence-hero {
    width: 100%;
    margin-bottom: 40px;
    overflow: hidden;
    text-align: center;
}

.agence-hero-img {
    width: 900px;
    max-width: 100%;
    height: auto;
    max-height: 500px;
    display: inline-block;
    object-fit: contain;
}

/* ============================================
   PAGE CONTACT (contact.html)
   ============================================ */
.contact {
    padding: 40px;
    max-width: 1300px;
    margin-left: auto;
    margin-right: auto;
}

.contact-hero {
    width: 100%;
    margin-bottom: 30px;
    overflow: hidden;
}

.contact-hero-img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 500px;
    object-fit: cover;
}

.contact h1 {
    font-size: 1.3em;
    /* marge haute par défaut d'un h2, conservée à l'identique */
    margin-top: 0.83em;
    margin-bottom: 20px;
}

.contact p {
    font-size: 1em;
    margin: 15px 0;
    text-align: justify;
}

.contact a {
    color: var(--color-black);
}

/* ============================================
   PAGE PROJETS (projets.html)
   ============================================ */
.projets {
    padding: 0 40px 40px 40px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Filtre de catégories */
.categories-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
    width: 100%;
    padding: 0 0 15px 0;
    background-color: var(--color-white);
}

.cat-btn {
    padding: 10px 20px;
    background-color: transparent;
    border: none;
    color: var(--color-gray);
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: bold;
    font-size: 0.71em;
    transition: color 0.4s, background-color 0.4s;
}

.cat-btn:hover {
    color: var(--color-black);
}

.cat-btn--active {
    background-color: var(--color-black);
    color: var(--color-white);
    border-radius: 8px;
}

/* Grille de projets */
.grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.project {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    width: 18%;
    aspect-ratio: 3 / 2;
    margin: 7px;
    background-color: #e8e8e8;
}

.project:focus {
    outline: 2px solid var(--color-black);
    outline-offset: 2px;
}

.project:focus:not(:focus-visible) {
    outline: none;
}

.project-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.project.hidden {
    display: none;
}

/* Overlay au survol */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    color: var(--color-white);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
}

/* Lieu et date sous le nom du projet */
.overlay-meta {
    margin-top: 4px;
    font-size: 0.85em;
    font-weight: normal;
}

.project:hover .overlay,
.project:focus-visible .overlay {
    opacity: 1;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 4;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    position: relative;
    margin: 2% auto;
    width: 90%;
    max-width: 1440px;
}

.close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    background-color: rgba(0, 0, 0, 0.45);
    color: var(--color-white);
    border: none;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 10px;
    line-height: 1;
    border-radius: 4px;
}

.close:hover {
    background-color: rgba(0, 0, 0, 0.75);
}

.carousel {
    position: relative;
}

.carousel img {
    display: block;
    max-width: 100%;
    /* --photo-max-h est calculée par script.js pour que la photo
       et les infos du projet tiennent ensemble dans l'écran */
    max-height: min(810px, var(--photo-max-h, 810px));
    height: auto;
    margin: 0 auto;
}

/* Flèches de navigation du carrousel */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background-color: rgba(0, 0, 0, 0.45);
    color: var(--color-white);
    border: none;
    font-size: 26px;
    font-weight: bold;
    cursor: pointer;
    padding: 10px 14px;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.carousel-arrow:hover,
.carousel-arrow:focus {
    background-color: rgba(0, 0, 0, 0.8);
    outline: none;
}

.carousel-arrow--prev { left: 12px; }
.carousel-arrow--next { right: 12px; }

.carousel-arrow.hidden {
    display: none;
}

/* Points de navigation du carrousel */
.carousel-dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.45);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.3s;
}

.dot.active,
.dot:hover {
    background-color: rgba(255, 255, 255, 0.95);
}

.project-info {
    background-color: rgba(0, 0, 0, 0.6);
    color: var(--color-white);
    padding: 14px 24px;
    text-align: center;
    line-height: 1.4;
}

.project-info h3 {
    color: var(--color-white);
    margin: 0 0 6px 0;
    font-size: 1.05em;
}

.project-info p {
    color: var(--color-white);
    margin: 4px 0;
    font-size: 0.9em;
}

/* ============================================
   RESPONSIVE : Écran moyen (≤ 1400px) : 4 images par ligne
   ============================================ */
@media (max-width: 1400px) {
    .project {
        width: 23%;
    }
}

/* ============================================
   RESPONSIVE : Tablette (≤ 1024px) : accueil centré
   (marges des liens réparties des deux côtés)
   ============================================ */
@media (max-width: 1024px) {
    .accueil header {
        align-items: center;
        padding-left: 0;
    }

    .accueil header .brand-title {
        text-align: center;
    }

    .accueil nav a {
        margin: 0 36px 28px;
    }
}

/* ============================================
   RESPONSIVE : Demi-écran / fenêtre étroite (≤ 900px) : 3 images par ligne
   ============================================ */
@media (max-width: 900px) {
    .project {
        width: 31%;
    }
}

/* ============================================
   RESPONSIVE : Tablette 741-860px : logo sur une ligne
   (sur deux lignes, l'en-tête recouvre le haut du contenu)
   ============================================ */
@media (min-width: 741px) and (max-width: 860px) {
    body > header .brand-title {
        white-space: nowrap;
        font-size: 1.4em;
    }
}

/* ============================================
   RESPONSIVE : Tablette (≤ 740px) : 2 images par ligne
   ============================================ */
@media (max-width: 740px) {
    header {
        padding: 15px 20px;
    }

    header .brand-title {
        font-size: 1.1em;
    }

    nav {
        font-size: 1.1em;
    }

    nav a {
        margin-right: 12px;
        font-size: 1.296em;
    }

    .accueil header .brand-title {
        font-size: 2.592em;
    }

    /* "header" nécessaire pour l'emporter sur .accueil header nav
       (liens un peu plus petits que le titre) */
    .accueil header nav {
        font-size: 1.75em;
    }

    .accueil nav a {
        margin: 0 18px 28px;
    }

    main {
        margin-top: 70px;
    }

    .categories-nav {
        gap: 8px;
        padding: 0 0 12px 0;
    }

    .projets {
        padding: 20px;
        margin-top: 70px;
    }

    .cat-btn {
        padding: 8px 15px;
        font-size: 0.64em;
    }

    .project {
        width: 48%;
    }

    .agence, .contact {
        padding: 20px;
    }
}

/* ============================================
   RESPONSIVE : Petit écran (≤ 520px) : logo sur une ligne, menu
   en dessous (sur une seule ligne, le menu déborde de l'écran).
   body > header : l'accueil (header dans .accueil) n'est pas concerné.
   ============================================ */
@media (max-width: 520px) {
    body > header {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    body > header .brand-title {
        white-space: nowrap;
    }

    body > header nav {
        flex-basis: 100%;
    }

    /* En-tête plus haut : le contenu descend d'autant */
    main,
    .projets {
        margin-top: 82px;
    }
}

/* ============================================
   RESPONSIVE : Mobile (≤ 442px)
   ============================================ */
@media (max-width: 442px) {
    header {
        padding: 10px 15px;
    }

    header .brand-title {
        font-size: 1.08em;
    }

    nav {
        font-size: 1em;
    }

    nav a {
        margin-right: 8px;
        font-size: 1.008em;
    }

    /* Accueil : titre centré en haut, liens empilés et centrés
       entre le titre et le bas de la photo */
    .accueil header {
        padding: 32px 20px 0 20px;
        align-items: center;
    }

    .accueil .brand {
        flex-direction: column;
        gap: 12px;
    }

    .brand-logo {
        width: 48px;
        height: 48px;
    }

    .accueil header .brand-title {
        font-size: min(2.5em, 10.5vw);
        padding-left: 0;
        text-align: center;
    }

    .accueil header nav {
        position: static;
        transform: none;
        margin: auto 0;
        padding: 0 0 32px 0;
        flex-direction: column;
        align-items: center;
        font-size: 2.1em;
    }

    .accueil nav a {
        margin: 0 0 12px 0;
    }

    main {
        margin-top: 59px;
    }

    .projets {
        padding: 15px;
        margin-top: 54px;
    }

    .categories-nav {
        gap: 6px;
        padding: 0 0 10px 0;
    }

    .cat-btn {
        padding: 6px 12px;
        font-size: 0.56em;
    }

    .project {
        width: 100%;
        margin: 5px;
    }

    .agence-hero-img {
        width: 100%;
    }

    .agence, .contact {
        padding: 15px;
    }

    .agence h1, .contact h1 {
        font-size: 1em;
    }

    .agence p, .contact p {
        font-size: 0.9em;
    }
}

/* ============================================
   RESPONSIVE : Très petit écran (≤ 323px)
   ============================================ */
/* Note : le bloc smartphone paysage ci-dessous est placé en dernier
   pour prendre le dessus sur tous les breakpoints de largeur */
@media (max-width: 323px) {
    header {
        padding-top: 5px;
    }

    header .brand-title {
        font-size: 0.8em;
    }

    main,
    .projets {
        margin-top: 59px;
    }

    /* .project hérite de width: 100% et aspect-ratio: 3/2 */
}

/* ============================================
   RESPONSIVE : Smartphone en mode paysage : 1 image par ligne
   (max-height: 450px identifie un téléphone en paysage,
   pas une tablette ni un écran de bureau)
   ============================================ */
@media (orientation: landscape) and (max-height: 450px) {
    .project {
        width: 100%;
    }
}
