/* =====================================================================
   PIERRE PINTO — Portfolio v2 (refonte)
   ---------------------------------------------------------------------
   Base partagée + home + à propos + contact.
   Pages projet : voir css/project.css (chargé en plus).
   Tokens centralisés ci-dessous : tout se règle ici.
   ===================================================================== */

:root {
  /* --- Couleurs --- */
  --bg:        #cfcfcf;   /* gris clair de l'original */
  --ink:       #111111;   /* texte */
  --ink-soft:  #6f6f6f;   /* texte secondaire */
  --line:      rgba(17, 17, 17, .18);
  --frame-bg:  #bfbfbf;   /* fond des médias avant chargement */

  /* --- Typo ---
     Grotta (commerciale) : décommenter le @font-face ci-dessous,
     déposer les .woff2 dans /fonts, puis le bloc :root prendra le relais. */
  --font-main: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --w-light: 300;
  --w-thin:  200;

  /* --- Échelle --- */
  --pad-x: 4vw;
  --pad-y: 4.5vh;
  --fs-work:    clamp(22px, 5.4vh, 64px);   /* titres projets (home) */
  --fs-display: clamp(40px, 9vw, 130px);    /* très grands titres (pages) */
  --fs-ui:      clamp(11px, 1.6vh, 14px);   /* header / footer / méta */
  --fs-eyebrow: clamp(10px, 1.4vh, 12px);
  --fs-body:    clamp(14px, 1.15vw, 18px);

  /* --- Mouvement --- */
  --ease-out:  cubic-bezier(.22, 1, .36, 1);
  --ease-roll: cubic-bezier(.77, 0, .18, 1);
  --t-roll: .55s;
  --t-fade: .9s;
}

/* --- Grotta : à activer quand les fichiers sont en place ---
@font-face {
  font-family: "Grotta";
  src: url("../fonts/Grotta-Light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
:root { --font-main: "Grotta", "Helvetica Neue", Arial, sans-serif; }
*/

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

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-main);
  font-weight: var(--w-light);
  font-size: var(--fs-ui);
  letter-spacing: .02em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; }

/* --- Pages plein écran (home, à propos, contact) : aucun scroll --- */
body.page-fixed {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

/* --- Pages défilantes (projets, R&D) --- */
body.page-scroll { min-height: 100dvh; }
body.page-scroll .site-head {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  transition: background .5s var(--ease-out), backdrop-filter .5s var(--ease-out);
  padding-bottom: 2vh;
}
body.page-scroll .site-head.is-scrolled {
  background: rgba(207, 207, 207, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ===================== HEADER ===================== */
.site-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--pad-y) var(--pad-x) 0;
}

.brand { display: flex; flex-direction: column; gap: .35em; }
.brand__name { text-transform: uppercase; letter-spacing: .14em; }
.brand__role { color: var(--ink-soft); }

.site-nav { display: flex; gap: 2.4em; text-transform: uppercase; letter-spacing: .12em; }
.site-nav a[aria-current="page"] { color: var(--ink-soft); pointer-events: none; }

/* ===================== FOOTER ===================== */
.site-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 2vw;
  padding: 0 var(--pad-x) var(--pad-y);
}
body.page-scroll .site-foot { padding-top: 8vh; }

.site-foot__place {
  display: flex;
  gap: 1.6em;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
}

.site-foot__social {
  display: flex;
  gap: 2em;
  justify-content: end;
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* ===================== ROLL DE LETTRES =====================
   Chaque lettre est doublée verticalement (JS) ; au survol,
   la pile bascule de -100% avec un délai en cascade. */
.char { display: inline-block; overflow: hidden; vertical-align: top; }

.char__roll {
  display: block;
  position: relative;
  transition: transform var(--t-roll) var(--ease-roll);
  transition-delay: var(--d, 0s);
}
.char__roll::after {
  content: attr(data-letter);
  position: absolute;
  top: 100%;
  left: 0;
}

a:hover .char__roll,
a:focus-visible .char__roll,
.work:hover .char__roll,
.work:focus-visible .char__roll { transform: translateY(-100%); }

/* ===================== ENTRÉE EN SCÈNE =====================
   body.is-loading retiré au chargement → tout se révèle. */
[data-reveal] {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
  transition-delay: var(--d-in, 0s);
}
.is-loading [data-reveal] { opacity: 0; transform: translateY(12px); }

/* Lignes masquées (titres) : montée en cascade */
.line-mask { display: block; overflow: hidden; }
.line-mask > span {
  display: block;
  transform: translateY(0);
  transition: transform 1s var(--ease-out);
  transition-delay: var(--d-in, 0s);
}
.is-loading .line-mask > span { transform: translateY(110%); }

/* ===================== RÉVÉLATION AU SCROLL ===================== */
[data-io] {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}
[data-io]:not(.in-view) { opacity: 0; transform: translateY(40px); }

/* médias : balayage vertical en plus */
.p-media[data-io] {
  transition: opacity 1s var(--ease-out), transform 1.2s var(--ease-out),
              clip-path 1.2s var(--ease-roll);
  clip-path: inset(0 0 0 0);
}
.p-media[data-io]:not(.in-view) { clip-path: inset(0 0 18% 0); }

/* =====================================================================
   HOME
   ===================================================================== */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: 4vw;
  padding: 0 var(--pad-x);
  min-height: 0;
}

.works { min-width: 0; }

.works__eyebrow {
  font-size: var(--fs-eyebrow);
  text-transform: uppercase;
  letter-spacing: .22em;
  color: var(--ink-soft);
  margin-bottom: 2.2vh;
}

.works__list { display: flex; flex-direction: column; }
.works__list li { overflow: hidden; }

.work {
  display: block;
  font-size: var(--fs-work);
  line-height: 1.22;
  font-weight: var(--w-thin);
  letter-spacing: -.01em;
  white-space: nowrap;
  width: max-content;
  max-width: 100%;
  transform: translateY(0);
  transition: transform .9s var(--ease-out), opacity .45s var(--ease-out);
  transition-delay: var(--d-in, 0s), 0s;
}
.is-loading .work { transform: translateY(110%); }
.works__list:hover .work:not(:hover) { opacity: .22; }

/* --- Moniteur 16/9 --- */
.monitor { min-width: 0; }

.monitor__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  margin-left: auto;
  background: var(--frame-bg);
  overflow: hidden;
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.2s var(--ease-roll) .35s;
}
.is-loading .monitor__frame { clip-path: inset(0 0 100% 0); }

.monitor__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity var(--t-fade) var(--ease-out), transform 1.4s var(--ease-out);
  will-change: opacity, transform;
}
.monitor__img.is-active { opacity: 1; transform: scale(1); }

.monitor__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 1.6vh;
  padding-top: 1.2vh;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.counter { display: inline-flex; gap: .5em; align-items: baseline; }
.counter__strip {
  display: inline-flex;
  flex-direction: column;
  height: 1.45em;
  line-height: 1.45;
  overflow: hidden;
}
.counter__strip span {
  display: block;
  transition: transform .6s var(--ease-roll);
  transform: translateY(calc(var(--n, 0) * -100%));
}
.counter__total { color: var(--ink-soft); }

.monitor__title { text-transform: uppercase; letter-spacing: .16em; }

/* =====================================================================
   À PROPOS (plein écran)
   ===================================================================== */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: center;
  gap: 5vw;
  padding: 0 var(--pad-x);
  min-height: 0;
}

.about__intro {
  font-size: var(--fs-body);
  color: var(--ink-soft);
  max-width: 34ch;
  margin-bottom: 4.5vh;
}

.about__statement {
  font-size: clamp(26px, 6.4vh, 76px);
  line-height: 1.18;
  font-weight: var(--w-thin);
  letter-spacing: -.01em;
}

.about__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3vw;
  align-content: center;
}

.about__cols h2 {
  font-size: var(--fs-eyebrow);
  font-weight: var(--w-light);
  text-transform: uppercase;
  letter-spacing: .22em;
  color: var(--ink-soft);
  margin-bottom: 2.2vh;
  padding-bottom: 1.2vh;
  border-bottom: 1px solid var(--line);
}

.about__cols li {
  font-size: clamp(13px, 2.2vh, 20px);
  line-height: 1.9;
  font-weight: var(--w-light);
}

/* =====================================================================
   CONTACT (plein écran)
   ===================================================================== */
.contact {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: 5vw;
  padding: 0 var(--pad-x);
  min-height: 0;
}

.contact__title {
  font-size: var(--fs-display);
  line-height: 1;
  font-weight: var(--w-thin);
  letter-spacing: -.015em;
  margin-bottom: 4vh;
}

.contact__txt {
  font-size: var(--fs-body);
  color: var(--ink-soft);
  max-width: 40ch;
  margin-bottom: 5vh;
}

.contact__links { display: flex; flex-direction: column; gap: 1.6vh; }
.contact__links a {
  width: max-content;
  font-size: clamp(15px, 2.6vh, 26px);
  font-weight: var(--w-thin);
}
.contact__links .is-small {
  font-size: var(--fs-ui);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-top: 1.4vh;
}

.contact__side { display: flex; flex-direction: column; gap: 1.4vh; }

.contact__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 64vh;
  background: var(--frame-bg);
  overflow: hidden;
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.2s var(--ease-roll) .3s;
}
.is-loading .contact__frame { clip-path: inset(0 0 100% 0); }

.contact__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact__meta {
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px), (orientation: portrait) {
  .stage { grid-template-columns: 1fr; position: relative; }

  .monitor { position: absolute; inset: 0; z-index: 0; opacity: .35; }
  .monitor__frame { max-height: none; height: 100%; aspect-ratio: auto; }
  .monitor__meta { display: none; }

  .works { position: relative; z-index: 1; }
  .work { white-space: normal; font-size: clamp(26px, 4.8vh, 48px); }

  .site-foot { grid-template-columns: 1fr; gap: 1.2vh; }
  .site-foot__social { justify-content: start; }
  .site-foot__place { display: none; }

  /* à propos / contact : on autorise le défilement vertical au besoin */
  body.page-fixed.allow-portrait-scroll { overflow: auto; height: auto; min-height: 100dvh; }
  .about, .contact { grid-template-columns: 1fr; gap: 5vh; padding-top: 4vh; padding-bottom: 4vh; }
  .contact__frame { max-height: 48vh; aspect-ratio: 4 / 3; }
}

/* ===================== ACCESSIBILITÉ ===================== */
:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
  [data-io]:not(.in-view) { opacity: 1; transform: none; }
}
