/* ============================================================
   L'Heure Bleue — heure-bleue.eu
   Séquence : nuit étoilée → l'aube se lève (gradient 400lvh
   translaté, compositor only) → le contenu se révèle.
   Tout l'orchestrage temporel est en CSS ; stars.js ne pilote
   que la voûte étoilée WebGL.
   ============================================================ */

:root {
  --night: #030a18;
  --ink: #ffffff;

  /* Timeline */
  --sky-duration: 20s;     /* nuit → aube */
  --sky-delay: 0s;       /* l'aube se met en route presque tout de suite */
  --reveal-at: 1s;       /* apparition du contenu, sous les dernières étoiles */

  /* Métriques */
  --mx: clamp(20px, 3.4vw, 68px);
  --my: var(--mx);

  /* Grain anti-banding (≤ 5 % d'alpha, tuilé) */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

@font-face {
  font-family: "Acumin VF";
  src: url("acuminvf-regular.woff2") format("woff2"),
       url("acuminvf-regular.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

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

html {
  color-scheme: dark;
  height: 100%;
}

body {
  height: 100svh;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: "Acumin VF", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Pile du socle : montagne + bande noire calées en bas, en flux
     normal (les couches fixed n'y participent pas). Surtout pas de
     wrapper fixed : il isolerait le multiply de la montagne. */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
}

::selection { background: rgba(84, 112, 150, 0.6); }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.85);
  outline-offset: 5px;
}

/* ------------------------------------------------------------
   1. Le ciel — 400 lvh, on remonte jusqu'à ce que son bas
      atteigne le bas du viewport : translateY(-75 %) exactement.
   ------------------------------------------------------------ */
.sky {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 400vh;
  height: 400lvh;
  background-image:
    var(--noise),
    radial-gradient(
      ellipse 62% 22% at 50% 88%,
      rgba(255, 178, 62, 0.22) 0%,
      rgba(255, 178, 62, 0.08) 45%,
      rgba(255, 178, 62, 0) 100%
    ),
    linear-gradient(
      to bottom,
      #030a18 0%,
      #061630 16%,
      #123760 32%,
      #547096 50%,
      #a09da7 66%,
      #dab784 78%,
      #ef9b34 90%,
      #ffbe45 100%
    );
  background-repeat: repeat, no-repeat, no-repeat;
  background-size: 180px 180px, 100% 100%, 100% 100%;
  animation: sky-rise var(--sky-duration) cubic-bezier(0.45, 0.05, 0.38, 0.96)
             var(--sky-delay) forwards;
}

@keyframes sky-rise {
  to { transform: translateY(-60%); }
}

/* ------------------------------------------------------------
   2. La voûte étoilée — peinte et déformée par stars.js,
      retirée du DOM une fois éteinte.
   ------------------------------------------------------------ */
.stars {
  position: fixed;
  inset: 0;
  /* pas de z-index : l'ordre DOM place la voûte au-dessus du ciel et
     sous le socle (montagne + bande noire), qui occulte les étoiles */
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ------------------------------------------------------------
   3. Le socle — pile en bas de viewport : le panorama, puis la
      bande noire du pied de page qui le chevauche de var(--my)
      (fondu transparent → #000 sur cette même distance).

      ⚠ Pas de z-index sur .scene-base : un stacking context en
      ferait un groupe isolé et le multiply de la montagne ne se
      mélangerait plus avec le ciel derrière. L'ordre DOM suffit.

      La montagne : hauteur responsive, calée à gauche, multiply
      pour se teinter avec l'aube. Masque en canal ALPHA
      (mask-alpha.png, dérivé de mask.png : luminance → alpha —
      Chrome ≤ 119 ignore mask-mode: luminance).
   ------------------------------------------------------------ */
.scene-base {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: none;
}

.mountain {
  display: block;
  width: max(100vw, 168vh);
  width: max(100vw, 168lvh);
  height: auto;
  margin-bottom: calc(-1 * var(--my)); /* chevauche la bande noire */
  mix-blend-mode: multiply;
  -webkit-mask-image: url("mask-alpha.png");
  -webkit-mask-size: 100% 100%;
  mask-image: url("mask-alpha.png");
  mask-size: 100% 100%;
  user-select: none;
  -webkit-user-select: none;
}

.ground {
  position: relative; /* peint au-dessus de la montagne */
  width: 100%;
  padding: calc(var(--my) * 2) var(--mx) var(--my);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), #000 var(--my));
  pointer-events: auto;
}

/* ------------------------------------------------------------
   4. Révélation du contenu — orchestrée en cascade (--i),
      indépendante du JS.
   ------------------------------------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: reveal 8s cubic-bezier(0.22, 0.61, 0.36, 1)
             calc(var(--reveal-at) + var(--i, 0) * 0.3s) forwards;
}

@keyframes reveal {
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------
   5. La marque
   ------------------------------------------------------------ */
.brand {
  position: fixed;
  left: var(--mx);
  bottom: var(--my);
  z-index: 3;
}

.brand__logo svg {
  display: block;
  width: calc(clamp(14px, 0.55vw + 9px, 17px) * 16); /* 8 : magic number pour faire matcher la typo */
  height: auto;
  color: var(--ink);
}

.brand__tagline {
  margin-top: clamp(18px, 2.2vh, 30px);
  font-size: clamp(14px, 0.55vw + 9px, 17px);
  line-height: 1.55;
}

.brand__tagline span { display: block; }

/* L'indentation du FR répond au décroché « Heure / Bleue » du logo */
.brand__tagline-fr { padding-left: 2.6em; }

/* ------------------------------------------------------------
   6. Les liens
   ------------------------------------------------------------ */
.links {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: clamp(30px, 3.6vw, 72px);
  font-size: clamp(12px, 0.3vw + 9px, 14px);
  line-height: 1.7;
  text-transform: uppercase;
}

.links__group {
  display: grid;
  justify-items: start;
  font-style: normal; /* address */
}

.link {
  text-decoration: underline 1px transparent;
  text-underline-offset: 0.45em;
  transition: text-decoration-color 0.35s ease, opacity 0.35s ease;
}

.link:hover { text-decoration-color: currentColor; }

.link__arrow {
  width: 0.78em;
  height: auto;
  margin-right: 0.55em;
  vertical-align: -0.08em;
}

/* ------------------------------------------------------------
   7. Mobile — logo en tête, liens en grille au pied
   ------------------------------------------------------------ */
@media (max-width: 820px) {
  .brand {
    left: var(--mx);
    right: var(--mx);
    top: var(--my);
    bottom: auto;
  }

  .brand__logo svg { width: min(58vw, 270px); }

  .mountain{
    width: max(100vw, 100svh);
  }
  
  .links {
    display: grid;
    grid-template-areas:
      "contact portfolio"
      "address social";
    grid-template-columns: 1fr auto;
    gap: var(--my);
  }

  .links__group--portfolio { grid-area: portfolio; }
  .links__group--contact   { grid-area: contact; }
  .links__group--social    { grid-area: social; }
  .links__group--address   { grid-area: address; }

  .reveal {
    animation: reveal 8s cubic-bezier(0.22, 0.61, 0.36, 1)
              calc(var(--reveal-at) + var(--im, 0) * 0.3s) forwards;
  }
}

/* Écrans très bas (paysage mobile) : on compacte */
@media (max-height: 480px) {
  .brand__logo svg { width: clamp(150px, 22vh, 220px); }
  .brand__tagline { margin-top: 10px; }
}

/* ------------------------------------------------------------
   8. Mouvement réduit — état « heure bleue » statique,
      contenu immédiatement visible, pas d'étoiles animées.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .sky {
    animation: none;
    transform: translateY(-37.5%);
  }
  .stars { display: none; }
  .reveal {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
