/* PATRIMOINE-ID -- styles propres au site, en complement du design system Modernist (_ds/.../styles.css) */

body { margin: 0; background: var(--color-bg); color: var(--color-text); overflow-x: hidden; }
a { color: var(--color-accent-700); text-decoration: none; }
a:hover { color: var(--color-accent); }

.pid-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; font: 600 12px var(--font-body);
  border: 2px solid; letter-spacing: .02em;
}
.pid-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,16,15,.82), rgba(20,16,15,.9));
  pointer-events: none;
}
.pid-navlink {
  background: none; border: none; font: 600 14px var(--font-body);
  color: var(--color-text); cursor: pointer; padding: 8px 4px;
}
.pid-navlink:hover { color: var(--color-accent-700); }
.pid-navlink[aria-expanded="true"] { color: var(--color-accent-700); }

.pid-col { display: flex; flex-direction: column; gap: 6px; font: 14px var(--font-body); }
.pid-col b {
  font-family: var(--font-heading); font-size: 13px;
  letter-spacing: .03em; text-transform: uppercase;
}
.pid-col a { color: var(--color-text); opacity: .75; font-size: 13px; }

.pid-dropdown {
  position: absolute; top: 64px; left: 0; right: 0;
  background: var(--color-bg); border-bottom: 2px solid var(--color-divider);
  box-shadow: var(--shadow-lg); z-index: 40;
  padding: var(--space-6) var(--space-6);
}
.pid-dropdown[hidden] { display: none; }

.pid-mobile-panel {
  position: fixed; inset: 0; background: #fff; z-index: 80;
  display: flex; flex-direction: column;
}
.pid-mobile-panel[hidden] { display: none; }

.pid-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.pid-photo-box { overflow: hidden; background: var(--color-neutral-200); }

.pid-status-radio { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 14px; cursor: pointer; }

/* Bascule de vue (liste / grille) : état actif sur les liens .seg-opt. */
.seg-opt[data-active] { background: var(--color-accent); color: var(--color-bg); }

@media (max-width: 900px) {
  .pid-hide-mobile { display: none !important; }
  /* Le panneau de menu mobile (pid-mobile-panel) reprend deja ces liens :
     eviter que la barre du haut deborde et rende le bouton hamburger
     inatteignable sur petit ecran. */
  .pid-navlink { display: none !important; }

  /* Rail des filtres (page recherche) : largeur fixe de 250px en desktop,
     mais doit s'empiler en pleine largeur sous ~900px -- sinon la colonne
     de resultats est ecrasee et la page deborde horizontalement. */
  .pid-search-filters { width: 100% !important; border-right: none !important; border-bottom: 2px solid var(--color-divider); }
}

/* Hero de l'accueil : sur petit ecran, les enfants en flex item
   (titre, formulaire, acces rapides) ne doivent pas rester bloques a leur
   largeur max-content -- sinon ils debordent de l'ecran. */
.pid-hero h1 { font-family: var(--font-heading); font-size: 44px; max-width: 760px; line-height: 1.15; }
@media (max-width: 700px) {
  .pid-hero > * { min-width: 0; }
  .pid-hero h1 { font-size: 28px; }
  .pid-hero .pid-quicklinks { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
}

/* Accordeon FAQ (comprendre.php, page/faq...) -- <details class="pid-faq"><summary>Q</summary>
   <div class="pid-faq-body">R</div></details>, un par item, empiles sans conteneur specifique. */
.pid-faq { border-top: 1px solid var(--color-divider); }
.pid-faq + .pid-faq { border-top: none; }
.pid-faq:last-of-type { border-bottom: 1px solid var(--color-divider); }
.pid-faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  list-style: none; cursor: pointer; padding: var(--space-3) 0;
  font-family: var(--font-heading); font-weight: 600; font-size: 14px;
}
.pid-faq summary::-webkit-details-marker { display: none; }
.pid-faq summary::after {
  content: '+'; flex: none; font-size: 18px; line-height: 1; color: var(--color-accent);
  transition: transform .15s ease;
}
.pid-faq[open] summary::after { transform: rotate(45deg); }
.pid-faq summary:hover { color: var(--color-accent-700); }
.pid-faq summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.pid-faq-body { padding: 0 0 var(--space-4); font-size: 14px; line-height: 1.7; opacity: .85; max-width: 68ch; }

/* ══════════════════════════════════════════════════════════════════════════
   Sommaire de "Comprendre le registre" -- sidebar sticky avec sections
   groupees + surlignage de la section active (scrollspy, cf. site.js),
   plus une variante mobile en chips horizontales (le sidebar est masque
   sous 900px via .pid-hide-mobile).
   ══════════════════════════════════════════════════════════════════════ */
.pid-toc {
  width: 240px; flex: none; align-self: flex-start;
  border-right: 2px solid var(--color-divider);
  padding: var(--space-6) var(--space-4);
  position: sticky; top: var(--space-6);
  max-height: calc(100vh - var(--space-8));
  overflow-y: auto;
}
.pid-toc-title {
  font-family: var(--font-heading); font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; display: block; margin-bottom: var(--space-5);
}
.pid-toc-group { margin-bottom: var(--space-5); }
.pid-toc-group:last-child { margin-bottom: 0; }
.pid-toc-group-label {
  display: block; font-family: var(--font-heading); font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em;
  color: color-mix(in srgb, var(--color-text) 45%, transparent);
  margin-bottom: var(--space-2);
}
.pid-toc-group a {
  display: block; font-size: 13.5px; line-height: 1.4;
  padding: 6px 0 6px 13px; margin-left: -1px;
  border-left: 2px solid var(--color-divider);
  color: var(--color-text); opacity: .72; text-decoration: none;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease, background .15s ease;
}
.pid-toc-group a:hover { opacity: 1; color: var(--color-accent-700); }
.pid-toc-group a.pid-toc-active {
  opacity: 1; color: var(--color-accent-700); font-weight: 600;
  border-left-color: var(--color-accent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--color-accent) 8%, transparent), transparent 85%);
}

/* Bandeaux de chiffres cles (4 colonnes) -- recherche.php et comprendre.php :
   2 colonnes sur mobile plutot que 4 cellules ecrasees, sans casser les
   filets verticaux (on retire juste le filet de la colonne devenue derniere). */
@media (max-width: 600px) {
  .pid-stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .pid-stat-grid > :nth-child(2n) { border-right: none !important; }
}

.pid-toc-mobile { display: none; }
@media (max-width: 900px) {
  .pid-toc-mobile {
    display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: var(--space-3) var(--space-6);
    border-bottom: 2px solid var(--color-divider); background: var(--color-bg);
    position: sticky; top: 0; z-index: 20;
    scrollbar-width: none;
  }
  .pid-toc-mobile::-webkit-scrollbar { display: none; }
  .pid-toc-mobile a {
    flex: none; font-size: 12.5px; padding: 7px 14px;
    border: 1.5px solid var(--color-divider); border-radius: 999px;
    color: var(--color-text); text-decoration: none; white-space: nowrap;
  }
  .pid-toc-mobile a.pid-toc-active { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
}

/* Bandeau d'identite OIMAP (en-tete de "Comprendre le registre") -- remplace
   une photo generique sans rapport avec le sujet par un traitement
   typographique assume, coherent avec le reste du site. */
.pid-oimap-banner {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 200px; margin-bottom: var(--space-6);
  background: var(--color-text); color: #fff;
  display: flex; align-items: center;
  padding: var(--space-6);
}
.pid-oimap-banner-mark {
  position: absolute; inset: 0; z-index: -1;
  display: flex; align-items: center;
  padding-left: var(--space-4);
  font-family: var(--font-heading); font-weight: 800; font-size: 20vw;
  line-height: 1; white-space: nowrap; color: #fff; opacity: .06;
}

/* ══════════════════════════════════════════════════════════════════════════
   Impression (fiche bien -> dossier officiel) -- masque par defaut a l'ecran,
   revele uniquement dans @media print ci-dessous. Le bouton "Imprimer la
   fiche" (data-print, cable dans site.js) declenche window.print() : ce
   sont ces regles qui transforment la page-site en document imprimable,
   sans dependre d'une fenetre ou d'un gabarit separe.
   ══════════════════════════════════════════════════════════════════════ */
.pid-print-only { display: none; }

@media print {
  @page { size: A4; margin: 16mm 14mm; }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  html, body { background: #fff; }
  body { color: #171514; }
  a { color: inherit; text-decoration: none; }

  /* Chrome du site (navigation, menus, newsletter, pied de page) : jamais imprime. */
  .nav, .pid-dropdown, .pid-mobile-panel, footer, .pid-print-hide { display: none !important; }

  .pid-print-only { display: block; }
  .pid-print-letterhead {
    display: flex !important; justify-content: space-between; align-items: flex-end; gap: var(--space-6);
    border-bottom: 2px solid #000; padding: var(--space-6) var(--space-6) 10pt; margin-bottom: 0;
  }
  .pid-print-brand { font-family: var(--font-heading); font-weight: 800; font-size: 19pt; }
  .pid-print-brand-tag { font-size: 8pt; opacity: .8; max-width: 44ch; margin-top: 3pt; line-height: 1.5; }
  .pid-print-meta { font-size: 8.5pt; text-align: right; opacity: .85; line-height: 1.7; white-space: nowrap; }
  .pid-print-footer { margin-top: 20pt; padding: 0 var(--space-6); font-size: 8.5pt; opacity: .8; line-height: 1.7; }
  .pid-print-footer p { margin: 0 0 4pt; }

  /* En-tete du dossier : plus de bandeau gris, une simple regle noire. */
  .pid-bien-header { background: none !important; border-top: none !important; border-bottom: 1px solid #000 !important; break-inside: avoid; }

  /* Deux colonnes ecran -> un seul flux imprime, fiche d'identite en tete
     (l'ordre visuel change via flex `order`, le HTML n'est pas duplique). */
  .pid-bien-body { display: flex !important; flex-direction: column !important; }
  .pid-bien-main, .pid-bien-aside { width: 100% !important; max-width: none !important; flex: none !important; padding: var(--space-4) var(--space-6) !important; }
  .pid-bien-aside { order: -1; padding-bottom: 0 !important; }

  /* Cartes : plus de fond gris ni d'ombre -- aspect document, pas widget web. */
  .card { background: none !important; border: 1px solid #999; box-shadow: none !important; break-inside: avoid; }

  /* Photo principale : hauteur raisonnable pour ne pas monopoliser une page. */
  .pid-gallery .pid-photo-box { height: 280px !important; break-inside: avoid; }

  /* Chronologie de l'historique : une entree ne doit pas etre coupee entre deux pages. */
  .pid-bien-main [style*="border-left"] > div { break-inside: avoid; }
}
