/* =========================================================
   MUSÉE NATIONAL DE WAWAN — Styles
   ========================================================= */

:root {
  --bg: #121212;
  --bg-deep: #0b0b0b;
  --ink: #f2ede4;
  --ink-soft: rgba(242, 237, 228, 0.62);
  --ink-faint: rgba(242, 237, 228, 0.32);
  --gold: #c9a96e;
  --gold-light: #e3cb98;
  --beige: #d9c7a7;
  --line: rgba(201, 169, 110, 0.28);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1.25rem, 5vw, 5rem);
  --gap: clamp(0.85rem, 2.2vw, 2rem);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Grain cinématographique très léger */
body::before {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 100;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

body.is-locked { overflow: hidden; }

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 4px;
}

/* ---------- Typographie commune ---------- */
.eyebrow {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(0.62rem, 1.6vw, 0.74rem);
  font-weight: 400;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--gold);
}

.rule {
  display: block;
  width: 56px;
  height: 1px;
  margin: 1.6rem auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ---------- Barre de progression de la visite ---------- */
.visit-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 60;
  background: rgba(255, 255, 255, 0.04);
}
.visit-progress span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--beige), var(--gold));
  box-shadow: 0 0 12px rgba(201, 169, 110, 0.5);
  will-change: transform;
}

/* ---------- Barre de navigation ---------- */
.topbar {
  position: fixed;
  top: 2px; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem var(--gutter);
  padding-top: max(1.1rem, env(safe-area-inset-top));
  transition: background 0.6s var(--ease), padding 0.6s var(--ease), opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.topbar.is-scrolled {
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.92), rgba(18, 18, 18, 0));
  padding-top: max(0.8rem, env(safe-area-inset-top));
  padding-bottom: 1.6rem;
}
.topbar.is-hidden { opacity: 0; transform: translateY(-100%); pointer-events: none; }

.topbar__mark {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--gold);
  width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: border-color 0.4s var(--ease), color 0.4s var(--ease);
}
.topbar__mark:hover { border-color: var(--gold); color: var(--gold-light); }

.topbar__nav { display: flex; gap: clamp(1.1rem, 3.5vw, 2.6rem); }
.topbar__nav a {
  position: relative;
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.4rem 0;
  transition: color 0.4s var(--ease);
}
.topbar__nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transition: transform 0.5s var(--ease-out);
}
.topbar__nav a:hover,
.topbar__nav a.is-active { color: var(--ink); }
.topbar__nav a.is-active::after { transform: scaleX(1); }

/* ---------- Salles ---------- */
.room {
  position: relative;
  padding: clamp(6rem, 14vh, 10rem) var(--gutter);
}

.room__header { text-align: center; margin-bottom: clamp(3rem, 8vw, 6rem); }
.room__title {
  margin: 0.9rem 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 3.8rem);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

/* ---------- Entrée ---------- */
.room--hero {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
  padding-top: 7rem;
  padding-bottom: 6rem;
}
.hero__light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 42% at 50% 0%, rgba(227, 203, 152, 0.13), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(201, 169, 110, 0.06), transparent 70%);
  animation: breathe 9s ease-in-out infinite alternate;
}
@keyframes breathe {
  from { opacity: 0.7; }
  to { opacity: 1; }
}
.hero__inner { position: relative; width: 100%; max-width: 760px; }

.hero__title { margin: 2rem 0 0; font-family: var(--serif); font-weight: 400; line-height: 1; }
.hero__title-small {
  display: block;
  font-size: clamp(0.95rem, 2.8vw, 1.35rem);
  font-style: italic;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--beige);
  margin-bottom: 1rem;
}
.hero__title-main {
  display: block;
  font-size: clamp(4rem, 19vw, 10.5rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  margin-right: -0.08em;
  background: linear-gradient(180deg, #fbf7ef 10%, #d9c7a7 75%, #b89458 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__subtitle {
  margin: 0 auto;
  max-width: 30ch;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 3vw, 1.4rem);
  color: var(--ink-soft);
}

/* ---------- Lecteur audio ---------- */
.player {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(100%, 460px);
  margin: 2.6rem auto 0;
  padding: 0.8rem 1.1rem 0.8rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.player__play {
  flex: none;
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  transition: background 0.4s var(--ease), color 0.4s var(--ease), transform 0.3s var(--ease);
}
.player__play:hover { background: var(--gold); color: var(--bg); }
.player__play:active { transform: scale(0.94); }
.player__play svg { width: 1.05rem; height: 1.05rem; fill: currentColor; }
.player__play .icon-pause { display: none; }
.player.is-playing .icon-play { display: none; }
.player.is-playing .icon-pause { display: block; }
.player.is-unavailable { opacity: 0.55; }
.player.is-unavailable .player__play { cursor: not-allowed; }

.player__track { flex: 1; min-width: 0; text-align: left; }
.player__times {
  display: flex;
  justify-content: space-between;
  margin-top: 0.15rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.player__volume { flex: none; display: flex; align-items: center; gap: 0.45rem; }
.player__mute {
  width: 1.9rem; height: 1.9rem;
  display: grid; place-items: center;
  background: none; border: 0; padding: 0;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.player__mute:hover { color: var(--gold); }
.player__mute svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
.player.is-muted .wave { opacity: 0.15; }

/* Curseurs */
.range {
  --pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.range--volume { width: 72px; }
.range::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold) var(--pct), rgba(242, 237, 228, 0.14) var(--pct));
}
.range::-moz-range-track { height: 2px; border-radius: 2px; background: rgba(242, 237, 228, 0.14); }
.range::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--gold); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 0;
  box-shadow: 0 0 0 4px rgba(201, 169, 110, 0.12);
  transition: transform 0.2s var(--ease);
}
.range::-moz-range-thumb {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 0;
}
.range:hover::-webkit-slider-thumb { transform: scale(1.25); }

/* ---------- Bouton « Entrer dans le musée » ---------- */
.btn-enter {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  margin-top: 3.4rem;
  padding: 1.15rem 2.6rem;
  border: 1px solid var(--line);
  overflow: hidden;
  isolation: isolate;
  transition: border-color 0.6s var(--ease), color 0.6s var(--ease);
}
.btn-enter::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(120deg, var(--beige), var(--gold));
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.7s var(--ease-out);
}
.btn-enter::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 245, 220, 0.18), transparent);
  animation: shimmer 4.5s var(--ease) 2.5s infinite;
}
@keyframes shimmer {
  0% { left: -60%; }
  35%, 100% { left: 130%; }
}
.btn-enter__label {
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  margin-right: -0.36em;
}
.btn-enter__line {
  width: 1px; height: 0;
  background: currentColor;
  position: absolute;
  bottom: -1px; left: 50%;
}
.btn-enter:hover { border-color: var(--gold); color: var(--bg); }
.btn-enter:hover::before { transform: scaleY(1); }

.scroll-cue {
  position: absolute;
  bottom: 2rem; left: 50%;
  width: 1px; height: 52px;
  transform: translateX(-50%);
  background: rgba(242, 237, 228, 0.1);
  overflow: hidden;
}
.scroll-cue span {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, var(--gold));
  animation: cue 2.4s var(--ease) infinite;
}
@keyframes cue {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

/* ---------- Galerie (mise en page irrégulière) ---------- */
.gallery {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  max-width: 1440px;
  margin: 0 auto;
}
.gallery__col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.artwork {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #1a1916;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(201, 169, 110, 0.06);
  transition: box-shadow 0.8s var(--ease);
}
.artwork img {
  width: 100%;
  height: auto;
  transform: scale(1.001);
  transition: transform 1.4s var(--ease-out), filter 1.2s var(--ease);
  filter: saturate(0.95);
}
.artwork::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(227, 203, 152, 0);
  transition: box-shadow 0.8s var(--ease);
}
@media (hover: hover) {
  .artwork:hover img { transform: scale(1.045); filter: saturate(1.05); }
  .artwork:hover { box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(201, 169, 110, 0.25); }
  .artwork:hover::after { box-shadow: inset 0 0 0 1px rgba(227, 203, 152, 0.18); }
}

/* Apparition des œuvres */
.artwork.reveal { transform: translateY(40px); }

/* ---------- Porte dérobée ---------- */
.secret-access {
  display: flex;
  justify-content: center;
  margin-top: clamp(5rem, 12vw, 8rem);
}
.secret-door {
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: rgba(201, 169, 110, 0.22);
  cursor: pointer;
  transition: color 0.6s var(--ease), border-color 0.6s var(--ease), transform 0.6s var(--ease);
}
.secret-door svg { width: 1rem; height: 1rem; fill: currentColor; }
.secret-door:hover,
.secret-door:focus-visible { color: var(--gold); border-color: var(--line); transform: rotate(-8deg); }
.secret-door.is-open { color: var(--gold); border-color: var(--gold); }

/* ---------- Archives secrètes ---------- */
.room--archives {
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(201, 169, 110, 0.08), transparent 70%),
    var(--bg-deep);
  border-top: 1px solid rgba(201, 169, 110, 0.12);
  border-bottom: 1px solid rgba(201, 169, 110, 0.12);
}
.room--archives .room__title { font-style: italic; }
.archives__veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--bg-deep);
  transform-origin: top;
  transform: scaleY(0);
}
.room--archives.is-opening .archives__veil { animation: veil 1.6s var(--ease-out) forwards; }
@keyframes veil {
  from { transform: scaleY(1); }
  to { transform: scaleY(0); }
}
.gallery--archives .artwork { background: #161513; }
.gallery--archives .artwork img { filter: sepia(0.12) saturate(0.9); }

/* ---------- Salle du cinéma ---------- */
.room--videos {
  background: radial-gradient(ellipse 70% 40% at 50% 0%, rgba(201, 169, 110, 0.05), transparent 70%);
}
.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 700px) {
  .video-grid { grid-template-columns: repeat(3, 1fr); }
}
.video-frame {
  position: relative;
  background: #1a1916;
  border: 1px solid rgba(201, 169, 110, 0.08);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}
.video-frame video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
}

/* ---------- Fin de visite ---------- */
.room--end {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(ellipse 60% 50% at 50% 50%, rgba(201, 169, 110, 0.07), transparent 70%);
}
.end__inner { max-width: 820px; }
.end__quote { margin: 1rem 0; }
.end__quote p {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 5vw, 3rem);
  line-height: 1.3;
  color: var(--ink);
}
.end__quote p + p { margin-top: 0.8rem; }
.end__quote em { color: var(--beige); }

.btn-ghost {
  margin-top: 2.6rem;
  padding: 1rem 2.2rem;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.5s var(--ease), color 0.5s var(--ease), background 0.5s var(--ease);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-light); background: rgba(201, 169, 110, 0.05); }

/* ---------- Retour en haut ---------- */
.to-top {
  position: fixed;
  right: max(1.1rem, env(safe-area-inset-right));
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  z-index: 40;
  width: 2.9rem; height: 2.9rem;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--gold);
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), border-color 0.4s var(--ease);
}
.to-top svg { width: 1.1rem; height: 1.1rem; }
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--gold); }

/* ---------- Visionneuse plein écran ---------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 8, 0.97);
  opacity: 0;
  transition: opacity 0.5s var(--ease);
  touch-action: pan-y;
}
.viewer[hidden] { display: none; }
.viewer.is-open { opacity: 1; }

.viewer__stage {
  margin: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(3.5rem, 8vh, 5rem) clamp(0.75rem, 8vw, 7rem);
}
.viewer__stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.5s var(--ease), transform 0.8s var(--ease-out);
  user-select: none;
  -webkit-user-drag: none;
}
.viewer__stage img.is-shown { opacity: 1; transform: none; }

.viewer__close,
.viewer__nav {
  position: absolute;
  z-index: 2;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.viewer__close:hover,
.viewer__nav:hover { color: var(--gold-light); border-color: var(--line); background: rgba(255, 255, 255, 0.03); }
.viewer__close {
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  width: 2.9rem; height: 2.9rem;
}
.viewer__close svg { width: 1.3rem; height: 1.3rem; }
.viewer__nav { top: 50%; width: 3.4rem; height: 3.4rem; transform: translateY(-50%); }
.viewer__nav svg { width: 1.6rem; height: 1.6rem; }
.viewer__nav--prev { left: clamp(0.4rem, 2vw, 2rem); }
.viewer__nav--next { right: clamp(0.4rem, 2vw, 2rem); }

/* ---------- Apparitions au défilement ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1.2s var(--ease), transform 1.4s var(--ease-out);
  transition-delay: var(--delay, 0s);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Smartphones ---------- */
@media (max-width: 640px) {
  .topbar { padding-left: 1.1rem; padding-right: 1.1rem; }
  .topbar__nav a { font-size: 0.6rem; letter-spacing: 0.22em; }

  .player {
    flex-wrap: wrap;
    border-radius: 22px;
    padding: 0.9rem 1rem;
    gap: 0.75rem 0.9rem;
  }
  .player__track { flex: 1 1 calc(100% - 4rem); }
  .player__volume { flex: 1 1 100%; justify-content: center; }
  .range--volume { width: 120px; }

  .btn-enter { padding: 1.1rem 1.8rem; margin-top: 2.8rem; }
  .btn-enter__label { letter-spacing: 0.28em; margin-right: -0.28em; }

  .viewer__nav { top: auto; bottom: max(1rem, env(safe-area-inset-bottom)); transform: none; }
  .viewer__nav--prev { left: calc(50% - 4rem); }
  .viewer__nav--next { right: calc(50% - 4rem); }
  .viewer__stage { padding: 4rem 0.75rem 5.5rem; }
}

/* ---------- Accessibilité : réduire les animations ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
