/* =========================================================
   TS Galerie : un mur neutre pour laisser parler les photos,
   l'ambre du logo comme seul accent.
   ========================================================= */

:root {
  --mur: #ECEBE8;
  --surface: #FFFFFF;
  --encre: #1C1B19;
  --discret: #64615B;
  --trait: #D5D2CB;
  --ambre: #DD983D;
  --ambre-texte: #8F5410;
  --voile: rgba(14, 13, 12, 0.95);

  --police-titre: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --police: 'Figtree', ui-sans-serif, system-ui, sans-serif;

  --gouttiere: clamp(16px, 3vw, 40px);
  --ecart: clamp(6px, 0.9vw, 14px);
  --largeur-max: 1840px;
  --rayon: 6px;
  --pilule: 999px;
  --anim: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --mur: #171614;
    --surface: #23211E;
    --encre: #F1EEE8;
    --discret: #A39E95;
    --trait: #36332E;
    --ambre-texte: #E9AC5C;
    color-scheme: dark;
  }
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--mur);
  color: var(--encre);
  font-family: var(--police);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body:has(dialog[open]) {
  overflow: hidden;
}

main {
  flex: 1;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ambre);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.evitement {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: var(--rayon);
  background: var(--encre);
  color: var(--mur);
  text-decoration: none;
}

.evitement:focus {
  top: 12px;
}

/* ---------- En-tête ---------- */

.entete {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--mur) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--trait);
}

.entete-interieur {
  max-width: var(--largeur-max);
  margin: 0 auto;
  padding: 10px var(--gouttiere);
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 48px);
}

.marque {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  border-radius: var(--rayon);
}

.marque img {
  width: 40px;
  height: 40px;
}

@media (prefers-color-scheme: dark) {
  /* Le noir du logo disparaîtrait sur fond sombre. */
  .marque img {
    background: #F1EEE8;
    border-radius: 50%;
    padding: 3px;
  }
}

.marque-nom {
  font-family: var(--police-titre);
  font-weight: 700;
  font-size: 1.25rem;
  font-variation-settings: 'wdth' 85;
  letter-spacing: -0.02em;
}

.recherche {
  flex: 1;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 20px;
  background: var(--surface);
  border: 1.5px solid var(--trait);
  border-radius: var(--pilule);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.recherche:focus-within {
  border-color: var(--ambre);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ambre) 22%, transparent);
}

.recherche input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: transparent;
  font-size: 1.0625rem;
}

.recherche input:focus {
  outline: none;
}

.recherche input::placeholder {
  color: var(--discret);
}

.recherche input::-webkit-search-cancel-button {
  display: none;
}

.recherche-raccourci {
  padding: 1px 8px;
  border: 1px solid var(--trait);
  border-radius: 4px;
  color: var(--discret);
  font-family: var(--police);
  font-size: 0.8125rem;
}

.recherche:focus-within .recherche-raccourci,
.recherche:has(input:not(:placeholder-shown)) .recherche-raccourci {
  display: none;
}

.recherche-effacer,
.recherche-valider {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
}

.recherche-effacer {
  background: transparent;
  color: var(--discret);
}

.recherche-effacer:hover {
  color: var(--encre);
  background: color-mix(in srgb, var(--encre) 7%, transparent);
}

.recherche-valider {
  background: var(--ambre);
  color: #1C1B19;
  transition: background 0.2s, transform 0.2s var(--anim);
}

.recherche-valider:hover {
  background: color-mix(in srgb, var(--ambre) 85%, #000);
}

.recherche-valider:active {
  transform: scale(0.94);
}

/* ---------- Introduction (accueil) ---------- */

.intro {
  max-width: var(--largeur-max);
  margin: 0 auto;
  padding: clamp(36px, 7vw, 96px) var(--gouttiere) clamp(28px, 4vw, 48px);
}

.intro h1 {
  max-width: 12ch;
  font-family: var(--police-titre);
  font-size: clamp(2.6rem, 7.5vw, 6.5rem);
  font-weight: 750;
  font-variation-settings: 'wdth' 75, 'opsz' 96;
  line-height: 0.92;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.intro-texte {
  max-width: 52ch;
  margin-top: clamp(16px, 2vw, 24px);
  color: var(--discret);
  font-size: clamp(1rem, 1.3vw, 1.1875rem);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding: 0;
  list-style: none;
}

.puce {
  padding: 8px 16px;
  border: 1px solid var(--trait);
  border-radius: var(--pilule);
  background: var(--surface);
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.puce:hover {
  border-color: var(--encre);
  background: var(--encre);
  color: var(--mur);
}

/* ---------- Barre d'outils ---------- */

.barre-outils {
  max-width: var(--largeur-max);
  margin: 0 auto;
  padding: 20px var(--gouttiere) 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
}

.resume {
  font-family: var(--police-titre);
  font-size: clamp(1.125rem, 1.6vw, 1.375rem);
  font-weight: 600;
  font-variation-settings: 'wdth' 90;
  letter-spacing: -0.01em;
}

.reglages {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.reglage {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
}

.reglage legend {
  float: left;
  color: var(--discret);
  font-size: 0.875rem;
}

.segment {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--pilule);
}

.segment label {
  position: relative;
}

.segment input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.segment span {
  display: block;
  min-width: 34px;
  padding: 5px 12px;
  border-radius: var(--pilule);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.segment input:hover + span {
  background: color-mix(in srgb, var(--encre) 7%, transparent);
}

.segment input:checked + span {
  background: var(--encre);
  color: var(--mur);
}

.segment input:focus-visible + span {
  outline: 2px solid var(--ambre);
  outline-offset: 1px;
}

/* ---------- Galerie ---------- */

.galerie {
  max-width: var(--largeur-max);
  margin: 0 auto;
  padding: 0 var(--gouttiere);
  display: flex;
  align-items: flex-start;
  gap: var(--ecart);
}

.galerie:focus {
  outline: none;
}

.colonne {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ecart);
}

.tuile {
  position: relative;
  aspect-ratio: var(--ratio);
  overflow: hidden;
  border-radius: var(--rayon);
  background: var(--teinte);
}

.tuile-ouvrir {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.tuile-ouvrir:focus-visible {
  outline: 3px solid var(--ambre);
  outline-offset: -3px;
}

.tuile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.7s var(--anim);
}

.tuile img.chargee {
  opacity: 1;
}

.tuile figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 40px 14px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.tuile figcaption a {
  text-decoration: none;
  pointer-events: auto;
}

.tuile figcaption a:hover {
  text-decoration: underline;
}

@media (hover: hover) {
  .tuile:hover img {
    transform: scale(1.03);
  }

  .tuile:hover figcaption,
  .tuile:focus-within figcaption {
    opacity: 1;
  }
}

/* ---------- États : chargement, vide, erreur, fin ---------- */

#sentinelle {
  height: 1px;
}

.statut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 60ch;
  margin: 0 auto;
  padding: 48px var(--gouttiere) 64px;
  color: var(--discret);
  text-align: center;
}

.statut:empty {
  padding: 32px 0;
}

.statut-titre {
  color: var(--encre);
  font-family: var(--police-titre);
  font-size: 1.375rem;
  font-weight: 650;
  font-variation-settings: 'wdth' 90;
}

.roue {
  width: 28px;
  height: 28px;
  border: 3px solid var(--trait);
  border-top-color: var(--ambre);
  border-radius: 50%;
  animation: tourner 0.8s linear infinite;
}

@keyframes tourner {
  to { transform: rotate(360deg); }
}

.bouton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--trait);
  border-radius: var(--pilule);
  background: var(--surface);
  color: var(--encre);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.bouton:hover {
  border-color: var(--encre);
}

.bouton-plein {
  border-color: var(--ambre);
  background: var(--ambre);
  color: #1C1B19;
}

.bouton-plein:hover {
  border-color: color-mix(in srgb, var(--ambre) 85%, #000);
  background: color-mix(in srgb, var(--ambre) 85%, #000);
}

.bouton svg {
  width: 18px;
  height: 18px;
}

/* ---------- Pied de page ---------- */

.pied {
  padding: 24px var(--gouttiere) 32px;
  border-top: 1px solid var(--trait);
  color: var(--discret);
  font-size: 0.875rem;
  text-align: center;
}

.pied a {
  color: var(--ambre-texte);
  font-weight: 600;
}

.bouton-haut {
  position: fixed;
  right: var(--gouttiere);
  bottom: 24px;
  z-index: 15;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--trait);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  animation: apparaitre 0.25s var(--anim);
}

.bouton-haut:hover {
  border-color: var(--encre);
}

@keyframes apparaitre {
  from { opacity: 0; transform: translateY(8px); }
}

/* ---------- Visionneuse ---------- */

.visionneuse {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  padding: 0;
  border: 0;
  background: var(--voile);
  color: #F1EEE8;
  color-scheme: dark;
}

.visionneuse[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  animation: fondu 0.2s ease;
}

.visionneuse::backdrop {
  background: transparent;
}

@keyframes fondu {
  from { opacity: 0; }
}

.v-scene {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 0;
  padding: 20px 16px 8px;
}

.v-figure {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
}

.v-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  border-radius: 4px;
  background: var(--teinte);
  transition: opacity 0.25s;
}

.v-image.v-attente {
  opacity: 0.55;
}

.v-nav,
.v-fermer {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #F1EEE8;
  transition: background 0.15s, opacity 0.15s;
}

.v-nav:hover:not(:disabled),
.v-fermer:hover {
  background: rgba(255, 255, 255, 0.18);
}

.v-nav:disabled {
  opacity: 0.2;
  cursor: default;
}

.v-nav svg,
.v-fermer svg {
  width: 24px;
  height: 24px;
}

.v-fermer {
  position: absolute;
  top: 14px;
  right: 14px;
}

.v-infos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px var(--gouttiere) 20px;
}

.v-texte {
  min-width: 0;
  flex: 1 1 320px;
}

.v-titre {
  overflow: hidden;
  font-family: var(--police-titre);
  font-size: 1.125rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v-titre::first-letter {
  text-transform: uppercase;
}

.v-credit {
  color: #B4AEA4;
  font-size: 0.9375rem;
}

.v-auteur {
  color: #F1EEE8;
  font-weight: 600;
}

.v-dimensions {
  margin-left: 8px;
  color: #8D877E;
}

.v-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.v-actions .bouton:not(.bouton-plein) {
  border-color: rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #F1EEE8;
}

.v-actions .bouton:not(.bouton-plein):hover {
  border-color: #F1EEE8;
}

/* ---------- Petits écrans ---------- */

@media (max-width: 640px) {
  .marque-nom,
  .recherche-raccourci {
    display: none;
  }

  .marque img {
    width: 36px;
    height: 36px;
  }

  .recherche {
    padding-left: 16px;
  }

  .recherche input {
    font-size: 1rem;
  }

  .recherche-effacer,
  .recherche-valider {
    width: 38px;
    height: 38px;
  }

  .reglage legend {
    display: none;
  }

  .reglages {
    width: 100%;
  }

  .v-scene {
    grid-template-columns: minmax(0, 1fr);
    padding: 64px 8px 8px;
  }

  .v-nav {
    position: absolute;
    bottom: 16px;
    z-index: 1;
    background: rgba(0, 0, 0, 0.45);
  }

  .v-precedent {
    left: 12px;
  }

  .v-suivant {
    right: 12px;
  }

  .v-image {
    max-height: calc(100dvh - 230px);
  }

  .v-actions {
    width: 100%;
  }

  .v-actions .bouton {
    flex: 1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .roue {
    animation: none;
    border-top-color: var(--trait);
  }
}
