/*
 * Toul'Barz vitrine — feuille de style. cf docs/MANIFESTO.md.
 * SOUSTRACTION : l'image est le design, monochrome strict (§P6), ça flotte (§P2),
 * silence (§P1). Le contenu est VISIBLE par défaut ; body.intro ne fait que chorégraphier
 * l'entrée (jamais de visibilité conditionnée à une transition → zéro page blanche en headless).
 */
/* Archivo Variable self-hébergé (axe wght 100–900, sous-set latin → accents FR). */
@font-face {
  font-family: "Archivo Variable";
  src: url("./fonts/archivo-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/*
 * Palette art-dirigée de la vitrine. Monochrome strict (§P6) — toute couleur = ADR.
 * Volontairement proche, sans s'y figer, des tokens @toulbarz/design-system
 * (le shell app) : noir un cran plus profond et blanc adouci pour la scène
 * immersive, `muted` éclairci pour rester lisible par-dessus la photo.
 */
:root {
  --bg: #050505;
  --surface: #101010;
  --border: #242424;
  --text: #f4f4f4;
  --muted: #7d7d7d;
  --label: #c8c8c8; /* gris lisible pour les petits libellés (contraste > --muted) */
  --danger: #e55353; /* = design-system */
  --ui: "Archivo Variable", Archivo, system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Develop from black (§P1) — piloté par CSS, robuste sans JS ---------- */
#veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000;
  opacity: 0; /* défaut : absent → le contenu reste visible si l'anim ne tourne pas */
  pointer-events: none;
}
body.intro #veil {
  animation: veil-out 1.7s var(--ease) 0.05s forwards;
}
@keyframes veil-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ---------- Scène en 2 plans : fond argenté (matière, #scene-bg) + image TROUÉE au 1er plan ---------- */
#stage {
  position: fixed;
  inset: 0;
}
#scene-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #c4c4c4;
}
#scene {
  position: absolute;
  inset: 0;
  z-index: 1; /* premier plan (oculus découpé) au-dessus du fond argenté #scene-bg (z0) */
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%; /* remonte l'oculus pour bien cadrer le trou */
  transform-origin: 50% 20%; /* l'oculus : ancre du flottement ET du vol À TRAVERS le trou (§P4) */
  will-change: transform;
  cursor: pointer; /* la scène entière franchit le seuil au clic (cf app.js) */
}

/* Lueur de l'oculus (§P4) — douce, opacité pilotée par JS au seuil. */
#flare {
  position: fixed;
  top: 32%;
  left: 50%;
  width: 130vmax;
  height: 130vmax;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.7) 0%,
    rgba(255, 255, 255, 0.12) 32%,
    transparent 62%
  );
  mix-blend-mode: screen;
  pointer-events: none;
  opacity: 0;
  z-index: 40;
}

/* Grain — le seul bruit (§P5). */
#grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.07;
  z-index: 35;
}

/* ---------- UI : un murmure ---------- */
#hero-ui {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
#hero-ui > * {
  pointer-events: auto;
}

#monogram {
  position: absolute;
  top: max(clamp(1.6rem, 3.4vw, 2.6rem), env(safe-area-inset-top, 0px));
  left: max(clamp(1.6rem, 3.4vw, 2.6rem), env(safe-area-inset-left, 0px));
  width: clamp(40px, 5vw, 56px);
  height: auto;
  opacity: 0.9;
}

#enter {
  position: absolute;
  bottom: max(clamp(1.8rem, 4.5vh, 3rem), calc(env(safe-area-inset-bottom, 0px) + 1rem));
  left: max(clamp(1.6rem, 3.4vw, 2.6rem), env(safe-area-inset-left, 0px));
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0.62;
  padding: 0.3rem 0;
  transition: opacity 0.5s var(--ease);
}
/* Cible tactile ≥44px sans toucher à l'allure (l'entrée reste un murmure, §P3). */
#enter::before {
  content: "";
  position: absolute;
  inset: -0.7rem -1.1rem;
}
#enter::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 0.35rem;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.55s var(--ease);
}
#enter:hover,
#enter:focus-visible {
  opacity: 1;
}
#enter:hover::after,
#enter:focus-visible::after {
  transform: scaleX(1);
}

#trace {
  position: absolute;
  right: max(clamp(1.6rem, 3.4vw, 2.6rem), env(safe-area-inset-right, 0px));
  bottom: max(clamp(1.8rem, 4.5vh, 3rem), calc(env(safe-area-inset-bottom, 0px) + 1rem));
  z-index: 20;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.1;
  transition: opacity 0.6s var(--ease);
}
/* Cible tactile ≥44px autour de la trace, sans la révéler (§P3). */
#trace::before {
  content: "";
  position: absolute;
  inset: -1rem;
}
#trace:hover,
#trace:focus-visible {
  opacity: 0.55;
}

/* Focus clavier : anneau blanc partout — le contraste est notre seul signal
   (convention design-system ; cf docs/MANIFESTO.md §P6 monochrome). */
#enter:focus-visible,
#trace:focus-visible,
#login button:focus-visible,
.field input:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---------- Entrée chorégraphiée (visible par défaut ; body.intro REJOUE depuis le noir) ---------- */
.reveal {
  opacity: 1;
}
body.intro .reveal {
  animation: rise 1.2s var(--ease) both;
}
body.intro #monogram {
  animation-delay: 0.7s;
}
body.intro #enter {
  animation-delay: 0.95s;
}
body.intro #trace {
  animation-delay: 1.15s;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Pendant le plongeon, l'UI s'efface (§P4). */
#stage.diving #hero-ui,
#stage.diving #trace {
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

/* ---------- Le seuil : le formulaire naît dans la lumière (§P4) — sans glassmorphism ---------- */
#gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  overflow-y: auto; /* scroll de secours : jamais de bouton injoignable (paysage court / clavier ouvert) */
  padding: max(1.5rem, env(safe-area-inset-top, 0px)) 1rem
    max(1.5rem, env(safe-area-inset-bottom, 0px));
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 32%, transparent 0%, rgba(5, 5, 5, 0.66) 58%);
  transition: opacity 0.55s var(--ease) 0.15s;
}
#gate.open {
  opacity: 1;
  pointer-events: auto;
}

#login {
  width: min(89vw, 21rem);
  margin: auto; /* centré quand il y a la place ; scroll sans clip du haut quand c'est court */
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  transform: translateY(0.9rem);
  opacity: 0;
  transition: transform 0.75s var(--ease) 0.25s, opacity 0.75s var(--ease) 0.25s;
}
#gate.open #login {
  transform: none;
  opacity: 1;
}
.g-monogram {
  width: 56px;
  height: auto;
  align-self: center;
  opacity: 0.9;
  margin-bottom: 0.6rem;
}

.field {
  display: block;
}
.field span {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--label);
  margin-bottom: 0.5rem;
}
.field input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.9rem;
  padding: 0.72rem 0.78rem;
  outline: none;
  transition: border-color 0.3s var(--ease);
}
.field input:focus {
  border-color: var(--text);
}

#login button {
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  transition: opacity 0.3s var(--ease);
}
#submit:hover:not(:disabled) {
  opacity: 0.85;
}
#login button:disabled {
  opacity: 0.5;
  cursor: default;
}
#login .ghost {
  background: none;
  color: var(--muted);
  border-color: transparent;
}
#login .ghost:hover {
  color: var(--text);
}
.error {
  color: var(--danger);
  font-size: 0.78rem;
  min-height: 1rem;
  text-align: center;
}

/* ---------- Traversée du seuil (login réussi) : les champs s'inhalent en cascade (§P4) ---------- */
body.plunging #gate {
  pointer-events: none;
}
body.plunging #login > * {
  animation: tb-inhale 640ms cubic-bezier(0.5, 0, 0.78, 0.35) forwards;
}
body.plunging #login > *:nth-child(1) {
  animation-delay: 0ms;
}
body.plunging #login > *:nth-child(2) {
  animation-delay: 60ms;
}
body.plunging #login > *:nth-child(3) {
  animation-delay: 120ms;
}
body.plunging #login > *:nth-child(4) {
  animation-delay: 180ms;
}
body.plunging #login > *:nth-child(5) {
  animation-delay: 240ms;
}
body.plunging #login > *:nth-child(6) {
  animation-delay: 300ms;
}
/* aspirés vers le haut, vers la lumière : montée + dilution + flou, décalés (§P2) */
@keyframes tb-inhale {
  to {
    opacity: 0;
    transform: translateY(-24px) scale(0.96);
    filter: blur(8px);
  }
}

/* ---------- prefers-reduced-motion : on oriente, on n'agite pas ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  #veil {
    display: none;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
