/* ─── Fonts ───────────────────────────────────────────── */

@font-face {
  font-family: "IS Citadel";
  src: url("../fonts/ISCitadel-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "IS Citadel";
  src: url("../fonts/ISCitadel-Italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
}

/* ─── Variables ───────────────────────────────────────── */

:root {
  /* Interlignage (14px de corps) */
  --lh: 16.8px;
  /* Hauteur de la frise de vignettes */
  --thumb-h: 60px;
  /* Marge commune à tous les bords */
  --m: 1.25rem;
}

/* ─── Reset ───────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Pas de surlignage sombre au toucher sur mobile,
   ni de zoom au double-tap (le pincement reste possible) */
html {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: #fff;
  color: #000;
  font-family: "IS Citadel", Georgia, serif;
  font-size: 14px;
  font-weight: 400;
  line-height: var(--lh);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "calt" 0;
  font-variant-ligatures: no-contextual;
}

/* Tout le texte est noir ; ce qui est cliquable passe en gris au survol */
a {
  color: #000;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover,
a:focus-visible {
  color: #999;
}

/* ─── Stage (image centrée) ───────────────────────────── */

.stage {
  position: fixed;
  top: calc(var(--m) * 6);
  bottom: calc(var(--m) * 6);
  left: 10vw;
  right: 10vw;
  z-index: 0;
  pointer-events: none;
}

.stage img,
.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.stage .visible {
  opacity: 1;
}

/* Desktop : les portraits prennent toute la hauteur de l'écran
   (la zone image est étendue en haut et en bas, sans recadrage) */
@media (min-width: 769px) {
  .stage .portrait {
    top: calc(var(--m) * -6);
    bottom: auto;
    height: calc(100% + var(--m) * 12);
  }
}

/* ─── Header ──────────────────────────────────────────── */

.info {
  position: fixed;
  top: var(--m);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  /* Négatif par-dessus les images. En différence sur fond blanc,
     #fff s'affiche noir et #666 s'affiche gris #999. */
  mix-blend-mode: difference;
  color: #fff;
}

.info-name {
  font: inherit;
  color: #fff;
}

.menu-link {
  font: inherit;
  letter-spacing: inherit;
  color: #fff;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

/* Un seul mot, « Information » ↔ « Close » : fondu sortant,
   changement du texte, fondu entrant (géré en JS) */
.label {
  transition: opacity 0.15s ease;
}

.label.fading {
  opacity: 0;
}

.menu-link:hover,
.menu-link:focus-visible {
  color: #666;
}

/* ─── About ───────────────────────────────────────────── */

.about {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* En haut, sur la même ligne que le haut de la zone image
     (padding-top = top de .stage) */
  align-content: start;
  align-items: start;
  column-gap: var(--m);
  padding: calc(var(--m) * 6) var(--m) var(--m);
  overflow-y: auto;
  color: #000;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.35s ease,
    visibility 0s linear 0.35s;
}

.about.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}

.tel {
  font-variant-numeric: tabular-nums;
}

.about-text {
  max-width: 34rem;
}

.about-text p + p {
  margin-top: var(--lh);
}

/* ─── Navigation latérale ───────────────────────────── */
/* Deux grandes zones invisibles, sous la galerie, le header,
   la légende et l'about qui restent cliquables. */

.nav-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 5;
  /* Moitiés gauche / droite de l'écran */
  width: 50%;
  padding: 0;
  border: none;
  background: none;
}

.nav-prev {
  left: 0;
  cursor: w-resize;
}

.nav-next {
  right: 0;
  cursor: e-resize;
}

.nav-zone:focus,
.nav-zone:active {
  outline: none;
  background: none;
}

/* ─── Légende ─────────────────────────────────────────── */

.caption {
  position: fixed;
  left: var(--m);
  right: var(--m);
  bottom: var(--m);
  z-index: 10;
  /* Négatif par-dessus les images (voir .info) */
  mix-blend-mode: difference;
  color: #fff;
}

.caption-text {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Liens dans les descriptions : simple texte grisé.
   Transparence plutôt que couleur grise, qui s'inverserait mal :
   gris #999 sur fond blanc, gris moyen lisible sur image sombre. */
.caption-desc a {
  color: inherit;
  text-decoration: none;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.caption-desc a:hover,
.caption-desc a:focus-visible {
  opacity: 1;
}

.caption-title {
  margin-right: 0.5em;
  font-style: italic;
}

/* ─── Galerie ─────────────────────────────────────────── */

.gallery {
  position: fixed;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  /* Invisible tant qu'on ne la survole pas */
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Affichée au survol, ou au clavier (Tab) — pas après un clic */
.gallery:hover,
.gallery:has(:focus-visible) {
  opacity: 1;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.thumb {
  flex-shrink: 0;
  height: var(--thumb-h);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.25s ease;
}

.thumb:hover,
.thumb:focus-visible,
.thumb.active {
  opacity: 1;
}

.thumb img,
.thumb video {
  display: block;
  width: auto;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
}

@media (max-width: 768px) {
  :root {
    --m: 1rem;
  }

  .stage {
    left: var(--m);
    right: var(--m);
  }

  /* Mobile : les paysages prennent toute la largeur de l'écran */
  .stage .landscape {
    left: calc(var(--m) * -1);
    right: auto;
    width: calc(100% + var(--m) * 2);
  }

  /* Frise toujours visible, entre l'image et la légende :
     légende en bas, puis frise, puis image (même écart --m) */
  :root {
    --thumb-h: 48px;
    /* Zone fixe de 2 lignes réservée à la légende */
    --caption-h: calc(var(--lh) * 2);
  }

  .gallery {
    top: auto;
    bottom: calc(var(--m) * 2 + var(--caption-h));
    transform: none;
    opacity: 1;
  }

  .stage {
    bottom: calc(var(--m) * 3 + var(--caption-h) + var(--thumb-h));
  }

  /* Légende dans une zone fixe de 2 lignes : une seule ligne
     se centre verticalement ; au-delà de 2 lignes, coupée par « … » */
  .caption {
    height: var(--caption-h);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .caption-text {
    white-space: normal;
    text-wrap: balance;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .about {
    grid-template-columns: 1fr;
    row-gap: var(--lh);
    padding-top: calc(var(--m) * 6);
  }
}
