/* ==========================================================================
   Home /wip – maquette Figma « Wip version » › « HP Grille » (1440 × 2518)
   Les cotes desktop sont exprimées en --u (1px de la maquette à 1440px de large)
   ========================================================================== */
@font-face {
  font-family: "Cormorant Upright";
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/cormorant-upright-400.woff2") format("woff2");
}

@font-face {
  font-family: "Cormorant Upright";
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/cormorant-upright-600.woff2") format("woff2");
}

@font-face {
  font-family: "Cormorant Upright";
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/cormorant-upright-700.woff2") format("woff2");
}

:root {
  --u: calc(100vw / 393);
  --color-bg: #fcfcfc;
  --color-text: #000;
  /* Figma : #8E8E8E (contraste 3,2:1) → assombri à #767676 pour atteindre AA, comme sur la landing */
  --color-muted: #767676;
  --font-serif: "Cormorant Upright", "Cormorant", Garamond, "Times New Roman", serif;

  /* Mobile (non maquetté) : déduit du desktop */
  --margin: calc(31 * var(--u));
  --header-top: 34px;
  --fs-header: 20px;
  --fs-intro: 26px;
  --intro-top: 160px;
  --intro-width: 100%;
  --projects-top: 56px;
  --columns: 1;
  --gap-x: 0px;
  --gap-y: 40px;
  --fs-name: 18px;
  --fs-type: 16px;
  --footer-top: 120px;
  --footer-bottom: 40px;
  --fs-footer: 18px;

  /* Grille de fond : traits #E2E3E9 de 1px */
  --grid-color: #e2e3e9;
  --grid-count: 3;
  --grid-margin: var(--margin);

  /* Taches de couleur (mesh gradient Figma rendu en image) */
  --b: calc(100vw / 700);

  /* Grain animé (repris de la landing) */
  --grain-image: url("../img/grain.png");
  --grain-size: 160px;
  --grain-opacity: 0.4;
}

@media (min-width: 768px) {
  :root {
    --u: calc(100vw / 1440);
    --margin: calc(42 * var(--u));
    --columns: 2;
    --gap-x: calc(37 * var(--u));
    --gap-y: 45px;
    --intro-width: calc(615 * 100vw / 1024);
    --b: calc(100vw / 1100);
  }
}

@media (min-width: 1024px) {
  :root {
    --header-top: 85px;
    --fs-header: 24px;
    --fs-intro: max(26px, 30 * var(--u));
    --intro-top: calc(439 * var(--u) - 85px - 52px);
    --intro-width: calc(615 * var(--u));
    --projects-top: calc(44 * var(--u));
    --fs-footer: 20px;
    --footer-top: calc(241 * var(--u));
    --footer-bottom: calc(51 * var(--u));
    --grid-count: 5;
    --grid-margin: calc(41 * var(--u));
    --b: var(--u);
  }
}

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

html {
  overflow-x: hidden;
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  padding-inline: var(--margin);
  background-color: var(--color-bg);
  background-image: linear-gradient(to right, var(--grid-color) 1px, transparent 1px);
  background-size: calc((100% - 2 * var(--grid-margin)) / (var(--grid-count) - 1)) 100%;
  background-position: calc(var(--grid-margin) - 0.5px) 0;
  background-repeat: repeat-x;
  color: var(--color-text);
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.21;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overflow: clip;
}

/* Grain qui saute, en « overlay » : invisible sur le blanc, visible sur les taches */
body::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--grain-size));
  z-index: -1;
  background: var(--grain-image) repeat;
  background-size: var(--grain-size);
  mix-blend-mode: overlay;
  opacity: var(--grain-opacity);
  animation: grain-jump 1.2s steps(1) infinite;
  pointer-events: none;
}

@keyframes grain-jump {
  0% { transform: translate3d(0, 0, 0); }
  10% { transform: translate3d(-37px, 52px, 0); }
  20% { transform: translate3d(61px, -18px, 0); }
  30% { transform: translate3d(-84px, -66px, 0); }
  40% { transform: translate3d(23px, 97px, 0); }
  50% { transform: translate3d(-12px, -121px, 0); }
  60% { transform: translate3d(108px, 34px, 0); }
  70% { transform: translate3d(-139px, 9px, 0); }
  80% { transform: translate3d(47px, -88px, 0); }
  90% { transform: translate3d(-70px, 130px, 0); }
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
  }
}

/* Grain redessiné en WebGL pour réagir à la souris (voir grain-hover.js, comme sur la landing).
   Même fondu « overlay » : l'effet se voit sur le rose (taches et zone de grain), jamais sur le blanc.
   Sans WebGL, sur mobile ou avec « réduire les animations », le grain CSS ci-dessus reste en place */
.grain-canvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  mix-blend-mode: overlay;
  opacity: var(--grain-opacity);
  pointer-events: none;
}

.grain-gl body::after {
  content: none;
}

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

h1,
h2,
p,
ul {
  margin: 0;
  padding: 0;
  font-weight: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

.link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-decoration-skip-ink: none;
  text-underline-position: from-font;
}

/* ==========================================================================
   Taches de couleur (Figma : Ellipse 1, 2, 3 en mesh gradient flouté)
   Positions = centres des ellipses dans la maquette, en --b
   ========================================================================== */
.blobs {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.blob {
  position: absolute;
  max-width: none;
}

/* Ellipse 3 : centre (-209.5, 41.4), rotation -73.79° */
.blob--top {
  width: calc(1447.81 * var(--b));
  height: calc(1368.8 * var(--b));
  left: calc((-209.52 - 723.9) * var(--b));
  top: calc((41.38 - 684.4) * var(--b));
  transform: rotate(-73.79deg);
}

/* Ellipse 2 : centre (1640.1, 1232.7 sur 2518 = 49 % de la page), rotation 71.33° */
.blob--right {
  width: calc(1447.81 * var(--b));
  height: calc(1368.8 * var(--b));
  left: calc(100% + (1640.11 - 1440 - 723.9) * var(--b));
  top: calc(48.96% - 684.4 * var(--b));
  transform: rotate(71.33deg);
}

/* Ellipse 1 : centre (380, 2911), sous le bas de la page dont on ne voit que le haut */
.blob--bottom {
  width: calc(2188 * var(--b));
  height: calc(1640 * var(--b));
  left: calc((380 - 1094) * var(--b));
  bottom: calc((2518 - 2911 - 820) * var(--b));
  transform: scaleY(-1);
}

/* ==========================================================================
   En-tête
   ========================================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-top: var(--header-top);
  font-size: var(--fs-header);
  line-height: 26px;
}

.header__name strong {
  font-weight: 600;
}

.header__social {
  font-size: 20px;
  line-height: 1.21;
}

/* Textes calés sur la grille : le nom ferré à gauche sur la ligne de gauche,
   LinkedIn ferré à droite sur la ligne de droite */
.header__social {
  position: absolute;
  top: var(--header-top);
  right: calc(var(--grid-margin) + 1px);
}

/* ==========================================================================
   Accroche et projets
   ========================================================================== */
.intro {
  max-width: var(--intro-width);
  margin-top: var(--intro-top);
  font-size: var(--fs-intro);
}



.projects {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  column-gap: var(--gap-x);
  row-gap: var(--gap-y);
  margin-top: var(--projects-top);
  list-style: none;
}

.project__open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.project__image {
  width: 100%;
  aspect-ratio: 660 / 410;
  object-fit: cover;
  background: #3d3d3d;
}

.project__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 15px;
}

.project__name {
  font-size: var(--fs-name);
}

.project__type {
  color: var(--color-muted);
  font-size: var(--fs-type);
  text-align: right;
}

/* ==========================================================================
   Pied de page : texte aligné à droite, photo dans la dernière colonne
   ========================================================================== */
.footer {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: calc(30 * var(--u));
  margin-top: var(--footer-top);
  padding-bottom: var(--footer-bottom);
}

.footer__text {
  font-size: var(--fs-footer);
  line-height: 26px;
  text-align: right;
}

/* Desktop : la ligne de base de la dernière ligne tombe sur le bas de la photo
   (sous la ligne de base, la boîte de ligne de 26px en 20px dépasse de 6,5px) */
@media (min-width: 1024px) {
  .footer__text {
    margin-bottom: -6.5px;
  }
}

.footer__media {
  position: relative;
  display: block;
  flex: none;
  overflow: hidden;
}

.footer__photo {
  flex: none;
  width: 179px;
  aspect-ratio: 179 / 239;
  object-fit: cover;
}

@media (max-width: 767px) {
  .footer {
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 20px;
  }

  .footer__photo,
  .footer__media {
    width: calc(140 * var(--u));
  }
}

/* ==========================================================================
   Pop-in de confidentialité (Figma : « Desktop / WIP PAGE » › « Pop-in »)
   ========================================================================== */
.popin {
  width: min(600px, 100vw - 2 * var(--margin));
  max-width: none;
  padding: 0;
  border: 0;
  background: #fff;
  color: var(--color-text);
}

.popin::backdrop {
  background: rgb(0 0 0 / 0.11);
}

.popin__box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 53px 44px 62px;
}

.popin__title {
  align-self: stretch;
  padding-left: 4px;
  font-size: 30px;
  font-weight: 600;
}

.popin__text {
  margin-top: 12px;
  font-size: 24px;
  line-height: 26px;
}

.popin__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 163px;
  height: 48px;
  position: relative;
  left: -4.5px; /* centré sur la pop-in, pas sur le texte */
  margin-top: 37px;
  padding: 16px 21px 18px;
  background: #000;
  color: #f9f9f9;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.27;
  text-decoration: none;
}

.popin__close {
  position: absolute;
  /* Tracé de la croix à la même distance du haut et de la droite de la boîte ;
     zone cliquable de 40 × 40 px centrée sur l'icône (marge négative de 12 px) */
  top: 27px;
  right: 27px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: -12px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

@media (max-width: 600px) {
  .popin__box {
    padding: 56px 24px 32px;
  }

  .popin__title {
    padding-left: 0;
  }

  .popin__text {
    font-size: 20px;
  }
}

/* ==========================================================================
   Animations (seulement si JS actif et sans « réduire les animations »)
   ========================================================================== */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Grille de fond (réf. marimba.design) : les traits se dessinent de haut en bas à l'arrivée */
.motion body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--color-bg);
  transform-origin: 50% 100%;
  transition: transform 1.6s var(--ease-out);
  pointer-events: none;
}

.motion.is-loaded body::before {
  transform: scaleY(0);
}

/* Taches : apparition en fondu puis dérive au scroll */
.motion .blob {
  opacity: 0;
  translate: 0 var(--drift, 0px);
  transition: opacity 2s ease 0.3s;
}

.motion.is-loaded .blob {
  opacity: 1;
}

/* Textes découpés : chaque ligne monte depuis son masque */
.split .word {
  display: inline-block;
  vertical-align: top;
  clip-path: inset(-0.2em -0.1em -0.25em -0.1em);
}

.motion .split .word {
  transform: translateY(105%);
  transition: transform 1s var(--ease-out);
  transition-delay: calc(var(--delay, 0s) + var(--line, 0) * 0.09s);
}

/* Le soulignement ne passe pas aux mots en inline-block : on le remet sur chaque mot des liens */
.link .word,
.link .char {
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-decoration-skip-ink: none;
  text-underline-position: from-font;
}

/* À l'arrivée : nom, LinkedIn, puis accroche */
.motion.is-loaded .header .word,
.motion.is-loaded .intro .word {
  transform: none;
}

.header__social {
  --delay: 0.15s;
}

.intro {
  --delay: 0.35s;
}

/* Au scroll : légendes des projets et pied de page */
.motion .is-visible .word,
.motion .is-visible.split .word {
  transform: none;
}

.project__meta .word {
  transition-delay: calc(var(--delay, 0s) + 0.25s);
}

/* Projets : le cadre se découvre du haut vers le bas, l'image se pose en dézoomant,
   puis glisse dans son cadre au scroll (parallaxe, réf. fluid.glass / akqa.com) */
.project__frame {
  display: block;
  overflow: hidden;
}

.motion .project__frame {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.2s var(--ease-out) var(--delay, 0s);
}

.motion .project.is-visible .project__frame {
  clip-path: inset(0 0 0 0);
}

.motion .project__image,
.motion .footer__photo {
  scale: 1.25;
  translate: 0 calc(var(--parallax, 0) * 1%);
  transition: scale 1.8s var(--ease-out) var(--delay, 0s);
}

.motion .project.is-visible .project__image,
.motion .footer__media.is-visible .footer__photo {
  scale: 1.12;
}

/* Décalage de la deuxième colonne */
@media (min-width: 768px) {
  .project:nth-child(even) {
    --delay: 0.12s;
  }
}

.motion .footer__media {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.8s var(--ease-out) 0.15s;
}

/* Portrait : un peu plus lent que les projets, pour qu'on ait le temps de voir l'apparition */
.motion .footer__photo {
  transition: scale 2.4s var(--ease-out) 0.15s;
}

.motion .footer__media.is-visible {
  clip-path: inset(0 0 0 0);
}

/* Vidéos au survol : posées sur l'image, en fondu */
.project__frame {
  position: relative;
}

.hover-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.is-playing .hover-video {
  opacity: 1;
}

/* Lettres à l'arrivée : du flou au net, une à une (réf. aikawakenichi.com/about) */
.chars .word {
  clip-path: none;
}

.motion .chars .word {
  transform: none;
}

.motion .chars .char {
  display: inline-block;
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.9s ease, filter 0.9s ease;
  transition-delay: calc(var(--delay, 0s) + var(--i, 0) * 0.016s);
}

.motion.is-loaded .chars .char {
  opacity: 1;
  filter: blur(0);
}

/* Zone de grain rose, qui sort de la tache du haut et suit un chemin au scroll */
.grain-zone {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 60vmax;
  height: 60vmax;
  margin: -30vmax 0 0 -30vmax;
  /* Grain fondu dans un rose pris aux taches (Figma : rgba(245, 150, 234)) */
  background:
    var(--grain-image) repeat 0 0 / 80px,
    radial-gradient(closest-side, rgb(245 150 234 / 0.35), rgb(253 199 250 / 0.2) 55%, rgb(253 199 250 / 0) 100%);
  background-blend-mode: overlay;
  mix-blend-mode: multiply;
  opacity: 0.22;
  -webkit-mask-image: radial-gradient(closest-side, #000 0%, rgb(0 0 0 / 0.6) 50%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 0%, rgb(0 0 0 / 0.6) 50%, transparent 100%);
  animation: grain-shift 1.2s steps(1) infinite;
  pointer-events: none;
  will-change: transform;
}

@keyframes grain-shift {
  0% { background-position: 0 0, 0 0; }
  20% { background-position: -37px 52px, 0 0; }
  40% { background-position: 61px -18px, 0 0; }
  60% { background-position: -84px -66px, 0 0; }
  80% { background-position: 23px 97px, 0 0; }
}

/* Vidéo de survol à la même échelle et au même décalage que l'image (pas de saut) */
.motion .project .hover-video,
.motion .footer__media .hover-video {
  scale: 1.12;
  translate: 0 calc(var(--parallax, 0) * 1%);
}

/* Pop-in : le voile arrive en fondu, puis la boîte monte en apparaissant (de 0 à 100 %,
   pour éviter tout « pop ») ; à la fermeture, ordre inverse, un peu plus rapide */
.motion .popin {
  opacity: 0;
  translate: 0 8px;
  scale: 1;
  will-change: opacity, translate;
  transition:
    opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    translate 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    scale 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.motion .popin:not(.is-open):not(.is-closing) {
  translate: 0 16px;
  scale: 0.985;
}

.motion .popin.is-open {
  opacity: 1;
  translate: 0 0;
  scale: 1;
  transition:
    opacity 0.7s var(--ease-out) 0.08s,
    translate 0.7s var(--ease-out) 0.08s,
    scale 0.7s var(--ease-out) 0.08s;
}

.motion .popin::backdrop {
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

.motion .popin.is-open::backdrop {
  opacity: 1;
  transition: opacity 0.6s var(--ease-out);
}
