/* Charles Rabagny — page d'accueil
   Réglages faciles à changer : les variables ci-dessous. */
:root {
  --bg: #f5f3ee;        /* fond : blanc cassé */
  --ink: #131313;       /* texte noir */
  --mute: #a5a29b;      /* textes gris */
  --list-grey: 0.36;    /* gris de la liste des projets (0 = invisible, 1 = noir) */
  --blur: 9px;          /* flou du fond quand une photo est ouverte */
  --dur: 0.95s;         /* durée du déplacement des photos */
  --ease: cubic-bezier(0.22, 0.8, 0.18, 1);
  --badge: clamp(112px, 18.5vh, 168px);   /* taille du bouton rond de contact */
}

/* trou dans la liste des projets, à l'endroit de la photo ouverte (1 = pas de trou) */
@property --hole {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--ink);
  font: 13px/1.35 "Times New Roman", Times, serif;
  letter-spacing: 0.005em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  animation: arrive 1.1s ease both;
}

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

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }

/* ---------- Navbar : au centre exact de l'écran, par-dessus les photos ----------
   Texte blanc en mode « différence » : il sort noir sur le fond clair et reste lisible
   sur les photos sombres. Pour un noir fixe partout : color: var(--ink) et retirer mix-blend-mode. */
.nav {
  position: fixed;
  z-index: 3;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  padding: 0 5vw;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  transition: filter 0.7s ease, opacity 0.7s ease;
}
.nav-links { display: contents; }
.nav-tag { margin: 0; }
.nav a {
  pointer-events: auto;
  transition: opacity 0.3s ease;
}
.nav a:hover { opacity: 0.5; }
.nav a[data-soon] { cursor: default; }

/* ---------- Liste verticale des projets : toute la hauteur, défile en boucle ---------- */
.index {
  --hole: 1;
  --hole-top: 40vh;
  --hole-bottom: 60vh;
  position: fixed;
  z-index: 4;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom,
    #000 calc(var(--hole-top) - 36px),
    rgba(0, 0, 0, var(--hole)) var(--hole-top),
    rgba(0, 0, 0, var(--hole)) var(--hole-bottom),
    #000 calc(var(--hole-bottom) + 36px));
  mask-image: linear-gradient(to bottom,
    #000 calc(var(--hole-top) - 36px),
    rgba(0, 0, 0, var(--hole)) var(--hole-top),
    rgba(0, 0, 0, var(--hole)) var(--hole-bottom),
    #000 calc(var(--hole-bottom) + 36px));
  transition: --hole 0.6s ease;
}
body.is-focus .index { --hole: 0; }
.index-track { will-change: transform; }
.index button {
  display: block;
  margin: 0 auto;
  padding: 0.24em 0.8em;
  border: 0;
  background: none;
  opacity: var(--list-grey);
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.35s ease;
}
.index button:hover,
.index button.is-active { opacity: 1; }

/* ---------- Bande de photos : au milieu de l'écran, alignée en haut ---------- */
.stage {
  position: absolute;     /* sans z-index : la navbar peut passer entre les photos et la photo ouverte */
  inset: 0;
  overflow: hidden;       /* les photos hors écran n'élargissent pas la page (important sur téléphone) */
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.ph {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  touch-action: pan-y;
  transform-origin: 50% 50%;
  will-change: transform;
  transition: opacity 0.45s ease, filter 0.7s ease;
  -webkit-tap-highlight-color: transparent;
}
.ph img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #e8e5de;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* survol d'un projet dans la liste : les autres photos s'effacent un peu */
.ph.is-dim { opacity: 0.2; }

/* ---------- Photo ouverte ---------- */
body.is-anim .ph {
  transition: transform var(--dur) var(--ease), opacity 0.6s ease, filter 0.7s ease;
}
.ph.is-out {
  opacity: 0;
  pointer-events: none;
}
.ph.is-side {
  filter: blur(var(--blur));
  opacity: 0.92;
}
.ph.is-current {
  z-index: 5;
  cursor: zoom-out;
}
body.is-focus .nav,
body.is-focus .badge {
  filter: blur(var(--blur));
  opacity: 0.6;
}
body.is-focus .nav a,
body.is-focus .badge { pointer-events: none; }
body.is-focus .stage { pointer-events: auto; cursor: zoom-out; }

/* ---------- Légende : nom du projet ---------- */
.caption {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: var(--cap-y, 76vh);
  transform: translateX(-50%);
  display: flex;
  gap: 1.5em;
  align-items: baseline;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, top var(--dur) var(--ease);
}
body.is-focus .caption {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.6s ease 0.35s, top var(--dur) var(--ease);
}
.caption span + span,
.caption button { color: var(--mute); }
.caption button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: color 0.3s ease;
}
.caption button:hover { color: var(--ink); }

/* ---------- Bouton rond de contact, en bas à droite ---------- */
.badge {
  position: fixed;
  z-index: 6;
  right: 30px;
  bottom: 30px;
  width: var(--badge);
  height: var(--badge);
  border-radius: 50%;
  mix-blend-mode: difference;   /* noir sur le fond, lisible si une photo passe dessous */
  transition: filter 0.7s ease, opacity 0.7s ease;
}
.badge svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.badge text {
  font: 500 13px ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  fill: #fff;
}
.badge .ring { transform-origin: 100px 100px; }
@media (hover: hover) {
  .badge:hover .ring-a { animation: turn 28s linear infinite; }
  .badge:hover .ring-b { animation: turn 28s linear infinite reverse; }
}
@keyframes turn { to { transform: rotate(360deg); } }

.noscript { position: fixed; left: 5vw; bottom: 5vh; margin: 0; }

/* ---------- Écrans étroits : la liste s'efface au passage de la navbar, pour ne pas écrire dessus ---------- */
@media (max-width: 1100px) {
  .index {
    --hole: 0;
    --hole-top: calc(50% - 16px);
    --hole-bottom: calc(50% + 16px);
  }
}

/* ---------- Téléphone ---------- */
@media (max-width: 760px) {
  :root { --badge: 110px; }
  .index {
    --hole-top: calc(50% - 34px);
    --hole-bottom: calc(50% + 34px);
  }
  .nav {
    flex-wrap: wrap;
    padding: 0 16px;
    row-gap: 1.1em;
  }
  .nav-name { order: 1; }
  .nav-tag { order: 2; }
  .nav-links {
    order: 3;
    display: flex;
    flex: 0 0 100%;
    justify-content: space-between;
  }
  .caption { gap: 1.1em; }
  .badge { right: 8px; bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0.01s; }
  body { animation: none; }
  .badge:hover .ring { animation: none; }
}
