/* Veilleuse — fondations : polices, jetons, couches vivantes. */

@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/fraunces-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 100 900; font-display: swap; src: url('/fonts/fraunces-italic-latin.woff2') format('woff2'); }
@font-face { font-family: 'Jost'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/jost-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'Jost'; font-style: italic; font-weight: 100 900; font-display: swap; src: url('/fonts/jost-italic-latin.woff2') format('woff2'); }

:root {
  --nuit-950: #05060c;
  --nuit-900: #0a0d18;
  --nuit-850: #0e1220;
  --nuit-800: #121729;
  --nuit-700: #1c2338;
  --nuit-600: #2a3350;
  --ardoise: #5e6684;
  --brume: #9aa0b8;
  --lune: #ece4d4;
  --lune-92: rgba(236, 228, 212, 0.92);
  --flamme: #f0b35e;
  --miel: #fadba8;
  --braise: #d9793f;
  --crepuscule: #d6918a;
  --givre: #8fb8c9;

  --glow: rgba(240, 179, 94, 0.32);
  --glow-soft: rgba(240, 179, 94, 0.14);
  --line: rgba(236, 228, 212, 0.08);
  --line-strong: rgba(236, 228, 212, 0.16);
  --surface: rgba(18, 23, 41, 0.62);
  --surface-2: rgba(28, 35, 56, 0.55);

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans: 'Jost', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;

  --souffle: cubic-bezier(.33, 0, .15, 1);
  --lune-ease: cubic-bezier(.65, 0, .35, 1);
  --sortie: cubic-bezier(.55, 0, .75, .2);

  --t-micro: 320ms;
  --t-comp: 820ms;
  --t-screen: 1300ms;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* Haut de l'interface : en plein écran, la barre remonte au ras de l'encoche
     (les boutons commencent juste sous la caméra, le libellé central ne la touche jamais). */
  --top: max(6px, calc(var(--safe-t) - 14px));
  --gutter: 22px;
  --radius: 22px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--nuit-950); }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--nuit-950);
  color: var(--lune-92);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 1px solid rgba(250, 219, 168, .6); outline-offset: 4px; border-radius: 12px; }

.serif { font-family: var(--serif); font-variation-settings: 'SOFT' 100, 'WONK' 0; }
.caps {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--brume);
}
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Le ciel vivant ─────────────────────────────────────────── */
#sky {
  position: fixed;
  inset: -40px 0 -240px 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(120% 70% at 50% 108%, #1a1b33 0%, #10132a 38%, #090b17 70%, #05060c 100%);
  transform: translate3d(0, var(--sky-y, 0px), 0);
  transition: transform 2400ms var(--souffle), opacity 1600ms var(--souffle);
  will-change: transform;
}
.sky-drift {
  position: absolute;
  inset: -8% -12%;
  animation: drift 240s var(--lune-ease) infinite alternate;
  will-change: transform;
}
.sky-canvas { width: 100%; height: 100%; display: block; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(-4%, -2.5%, 0) rotate(1.2deg); }
}
.twinkles span {
  position: absolute;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  border-radius: 50%;
  background: #fff6e4;
  box-shadow: 0 0 5px 1px rgba(255, 240, 210, .5);
  opacity: .15;
  animation: twinkle var(--d, 6s) var(--lune-ease) var(--delay, 0s) infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: .12; transform: scale(.7); }
  45% { opacity: .95; transform: scale(1); }
  60% { opacity: .5; }
}
.mist {
  position: absolute;
  left: -40%;
  width: 180%;
  height: 46%;
  border-radius: 50%;
  opacity: .5;
}
.mist-a {
  bottom: 4%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(120, 136, 186, .16), rgba(120, 136, 186, 0) 70%);
  animation: mist-a 130s var(--lune-ease) infinite alternate;
}
.mist-b {
  bottom: -14%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(214, 145, 138, .09), rgba(214, 145, 138, 0) 70%);
  animation: mist-b 170s var(--lune-ease) infinite alternate;
}
@keyframes mist-a { from { transform: translate3d(-8%, 0, 0) scale(1); } to { transform: translate3d(10%, -4%, 0) scale(1.12); } }
@keyframes mist-b { from { transform: translate3d(9%, 0, 0) scale(1.1); } to { transform: translate3d(-9%, -3%, 0) scale(1); } }
.horizon-glow {
  position: absolute;
  left: 50%;
  bottom: calc(240px - 30vh);
  width: 140vw;
  height: 70vh;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, rgba(240, 179, 94, .10), rgba(217, 121, 63, .04) 45%, rgba(0, 0, 0, 0) 72%);
  opacity: var(--horizon, .9);
  transition: opacity 2000ms var(--souffle);
}
.shooting {
  position: absolute;
  top: 18%;
  left: 70%;
  width: 150px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 244, 220, 0), rgba(255, 244, 220, .55));
  transform: rotate(-24deg) translate3d(0, 0, 0);
  opacity: 0;
  border-radius: 1px;
}
.shooting.go { animation: shoot 2600ms var(--souffle) forwards; }
@keyframes shoot {
  0% { opacity: 0; transform: rotate(-24deg) translate3d(0, 0, 0) scaleX(.2); }
  18% { opacity: .5; }
  100% { opacity: 0; transform: rotate(-24deg) translate3d(-260px, 0, 0) scaleX(1); }
}
body.dim #sky { opacity: .55; }

/* ─── La veilleuse ───────────────────────────────────────────── */
#veilleuse {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
  transform: translate3d(var(--vx, 50vw), var(--vy, 30vh), 0) scale(var(--vs, 1));
  transition: transform 1500ms var(--souffle), opacity 1400ms var(--souffle);
  will-change: transform;
}
#veilleuse > * { position: absolute; left: 0; top: 0; border-radius: 50%; }
.v-aura {
  width: 520px; height: 520px; margin: -260px 0 0 -260px;
  background: radial-gradient(closest-side, rgba(240, 179, 94, .16), rgba(217, 121, 63, .07) 45%, rgba(217, 121, 63, 0) 100%);
}
.v-halo {
  width: 230px; height: 230px; margin: -115px 0 0 -115px;
  background: radial-gradient(closest-side, rgba(250, 219, 168, .42), rgba(240, 179, 94, .18) 45%, rgba(240, 179, 94, 0) 100%);
}
.v-ring {
  width: 150px; height: 150px; margin: -75px 0 0 -75px;
  border: 1px solid rgba(250, 219, 168, .0);
  box-shadow: 0 0 0 0 rgba(250, 219, 168, 0);
  opacity: 0;
}
.v-core {
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  background: radial-gradient(closest-side, #fff4dc 0%, #fadba8 30%, rgba(240, 179, 94, .75) 55%, rgba(240, 179, 94, 0) 100%);
}
.v-spark {
  width: 12px; height: 12px; margin: -6px 0 0 -6px;
  background: radial-gradient(closest-side, #fffaf0, rgba(255, 246, 226, 0));
}
.v-embers { width: 360px; height: 480px; margin: -300px 0 0 -180px; border-radius: 0; }
#veilleuse.repos .v-aura { animation: breathe-aura 10s var(--lune-ease) infinite; }
#veilleuse.repos .v-halo { animation: breathe-halo 10s var(--lune-ease) infinite; }
#veilleuse.repos .v-core { animation: breathe-core 10s var(--lune-ease) infinite; }
#veilleuse.repos .v-spark { animation: flicker 6s var(--lune-ease) infinite; }
@keyframes breathe-aura { 0%, 100% { transform: scale(.86); opacity: .75; } 40% { transform: scale(1.06); opacity: 1; } }
@keyframes breathe-halo { 0%, 100% { transform: scale(.9); opacity: .8; } 40% { transform: scale(1.08); opacity: 1; } }
@keyframes breathe-core { 0%, 100% { transform: scale(.94); } 40% { transform: scale(1.04); } }
@keyframes flicker { 0%, 100% { opacity: .92; } 50% { opacity: 1; } }
#veilleuse.eteinte { opacity: 0; }
#veilleuse.veille { opacity: .45; }

/* ─── Haut d'écran fondu dans le noir ─────────────────────────────
   En plein écran, Android réserve une bande noire autour de la caméra. Plutôt qu'une bordure,
   le ciel s'obscurcit doucement jusqu'au noir pur : la bande devient la suite de la nuit. */
body::before {
  content: '';
  position: fixed;
  left: 0; right: 0; top: 0;
  height: calc(var(--safe-t) + 64px);
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .74) 26%, rgba(0, 0, 0, .3) 60%, rgba(0, 0, 0, 0) 100%);
}

/* ─── Grain (anti-escaliers dans les dégradés sombres) ────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background-image: url('/img/grain.png');
  background-size: 180px 180px;
  opacity: .045;
}

/* ─── Mouvement réduit ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sky-drift, .mist, .twinkles span { animation: none !important; }
  .twinkles span { opacity: .5; }
  .shooting { display: none; }
  #veilleuse, #sky { transition-duration: 400ms; }
  #veilleuse.repos .v-aura, #veilleuse.repos .v-halo, #veilleuse.repos .v-core { animation-duration: 16s; }
}
