/* ==========================================================================
   Puromètre — fondations : tokens, fond animé, typo, layout, navigation
   ========================================================================== */

@property --h {
  syntax: '<number>';
  inherits: true;
  initial-value: 262;
}

:root {
  color-scheme: dark;
  --h: 262; /* teinte pilotée par la pureté : 200 = paradis · 350 = enfer */

  --bg: #07060d;
  --bg-2: #0c0a16;
  --ink: #f6f4ff;
  --ink-2: #cdc8e6;
  --muted: #9d98bb;
  --faint: #6c678a;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --glass: rgba(18, 15, 31, 0.72);
  --glass-2: rgba(255, 255, 255, 0.05);
  --glass-3: rgba(255, 255, 255, 0.09);

  --accent: hsl(var(--h) 95% 70%);
  --accent-2: hsl(calc(var(--h) + 45) 95% 66%);
  --accent-soft: hsl(var(--h) 95% 66% / 0.14);
  --accent-line: hsl(var(--h) 95% 70% / 0.35);
  --glow: hsl(var(--h) 95% 62% / 0.45);

  --angel: #7dd3fc;
  --angel-2: #a78bfa;
  --demon: #ff3d6e;
  --demon-2: #ff8a3d;
  --gold: #ffd873;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;

  --r-xs: 8px;
  --r-sm: 12px;
  --r: 18px;
  --r-lg: 26px;
  --r-xl: 34px;

  --font-display: 'Unbounded', 'Segoe UI', system-ui, sans-serif;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  --shadow-lg: 0 40px 100px -30px rgba(0, 0, 0, 0.85);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --nav-h: 70px;
  --tab-h: 66px;

  transition: --h 1.4s var(--ease);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 700px at 50% -12%, hsl(var(--h) 70% 16% / 0.9), transparent 62%),
    var(--bg);
  color: var(--ink);
  font: 500 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

::selection {
  background: hsl(var(--h) 95% 65% / 0.4);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Fond : aurore + particules + grain ---------- */

#ambient {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.aurora i {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

.aurora i:nth-child(1) {
  width: 70vmax;
  height: 70vmax;
  top: -32vmax;
  left: -22vmax;
  background: radial-gradient(circle, hsl(var(--h) 95% 58% / 0.34), transparent 62%);
  animation: drift-a 28s ease-in-out infinite alternate;
}

.aurora i:nth-child(2) {
  width: 64vmax;
  height: 64vmax;
  bottom: -34vmax;
  right: -24vmax;
  background: radial-gradient(circle, hsl(calc(var(--h) + 50) 95% 56% / 0.28), transparent 62%);
  animation: drift-b 34s ease-in-out infinite alternate;
}

.aurora i:nth-child(3) {
  width: 44vmax;
  height: 44vmax;
  top: 28%;
  left: 38%;
  background: radial-gradient(circle, hsl(calc(var(--h) - 40) 90% 62% / 0.16), transparent 62%);
  animation: drift-c 40s ease-in-out infinite alternate;
}

@keyframes drift-a {
  to {
    transform: translate(12vmax, 8vmax) scale(1.15);
  }
}
@keyframes drift-b {
  to {
    transform: translate(-10vmax, -12vmax) scale(1.1);
  }
}
@keyframes drift-c {
  to {
    transform: translate(-16vmax, 10vmax) scale(0.85);
  }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

#app {
  position: relative;
  z-index: 2;
  min-height: calc(100dvh - var(--nav-h));
  outline: none;
}

/* ---------- Typographie ---------- */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.06;
  text-wrap: balance;
}

p {
  margin: 0;
}

.display {
  font-size: clamp(2.2rem, 5.4vw, 4.3rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.h1 {
  font-size: clamp(2rem, 4.8vw, 3.4rem);
}

.h2 {
  font-size: clamp(1.55rem, 3.4vw, 2.5rem);
}

.h3 {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  letter-spacing: -0.01em;
}

.grad {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.grad-fire {
  background: linear-gradient(100deg, #ff3d6e, #ff8a3d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.grad-sky {
  background: linear-gradient(100deg, #7dd3fc, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font: 800 0.74rem/1 var(--font);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  50% {
    opacity: 0.35;
  }
}

.lead {
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  color: var(--ink-2);
  line-height: 1.62;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.small {
  font-size: 0.88rem;
}

.tiny {
  font-size: 0.76rem;
}

.num {
  font-variant-numeric: tabular-nums;
}

.center {
  text-align: center;
}

/* ---------- Layout ---------- */

.wrap {
  width: min(1200px, 100% - 32px);
  margin-inline: auto;
}

.wrap-sm {
  width: min(760px, 100% - 32px);
  margin-inline: auto;
}

@media (min-width: 768px) {
  .wrap {
    width: min(1200px, 100% - 64px);
  }
}

.section {
  padding: clamp(44px, 7vw, 92px) 0;
}

.page {
  padding: clamp(24px, 5vw, 56px) 0 clamp(56px, 8vw, 96px);
}

.page-head {
  display: grid;
  gap: 12px;
  margin-bottom: clamp(22px, 4vw, 38px);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: clamp(20px, 3vw, 32px);
}

.section-head > div {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stack-v {
  display: grid;
  gap: 16px;
}

.grid-2 {
  display: grid;
  gap: 18px;
}

.grid-3 {
  display: grid;
  gap: 18px;
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.spacer {
  flex: 1;
}

/* ---------- Navigation ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(16px, 3.5vw, 40px);
  background: linear-gradient(to bottom, rgba(7, 6, 13, 0.88), rgba(7, 6, 13, 0.6));
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 800 1.12rem/1 var(--font-display);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  filter: drop-shadow(0 0 12px var(--glow));
}

.brand-name span {
  color: var(--accent);
}

.topnav-links {
  display: flex;
  gap: 2px;
  margin: 0 auto;
}

.topnav-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.94rem;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}

@media (max-width: 1080px) {
  .topnav-links a {
    padding: 10px 10px;
  }
  .topnav-right .btn-glass {
    display: none;
  }
}

.topnav-links a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.topnav-links a.active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff3d6e;
  box-shadow: 0 0 10px #ff3d6e;
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.topnav-links + .topnav-right {
  margin-left: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 14px 5px 5px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  max-width: 200px;
}

.user-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(10, 8, 18, 0.88);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 4px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tabbar .ti {
  font-size: 1.32rem;
  line-height: 1;
  filter: grayscale(0.7) opacity(0.8);
  transition: transform 0.25s var(--spring), filter 0.25s;
}

.tabbar a.active {
  color: var(--ink);
}

.tabbar a.active .ti {
  filter: none;
  transform: translateY(-2px) scale(1.08);
}

@media (max-width: 860px) {
  .topnav-links {
    display: none;
  }
  .topnav {
    height: 60px;
  }
  .tabbar {
    display: grid;
  }
  body {
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  }
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 861px) {
  .only-mobile {
    display: none !important;
  }
}

/* Petits téléphones : la barre du haut tient sur 375 px */
@media (max-width: 420px) {
  .topnav {
    gap: 10px;
  }
  .topnav .brand {
    gap: 8px;
    font-size: 1rem;
  }
  .topnav .brand-mark {
    width: 32px;
    height: 32px;
  }
  .topnav-right {
    gap: 6px;
  }
  .topnav-right .btn-sm {
    padding-inline: 0.85em;
  }
  .user-chip {
    max-width: 150px;
  }
}

body.immersive .topnav,
body.immersive .tabbar,
body.immersive .footer {
  display: none;
}

body.immersive {
  padding-bottom: 0;
}

body.immersive #app {
  min-height: 100dvh;
}

/* ---------- Pied de page ---------- */

.footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line);
  padding: 40px 0 48px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  gap: 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.footer a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover {
  color: var(--ink);
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 1.3fr 1fr;
    align-items: start;
  }
  .footer-links {
    justify-content: flex-end;
  }
}

/* Mode « calme » (animations réduites) : on coupe le décor animé en boucle,
   on garde les retours visuels courts liés aux actions. */
html.calm {
  scroll-behavior: auto;
}

html.calm .aurora i,
html.calm .hero-orbit i,
html.calm .marquee-track,
html.calm .theme-orbit span,
html.calm .mascot,
html.calm .mascot .m-halo-spin,
html.calm .mascot .m-sparkle,
html.calm .mascot .m-flame,
html.calm .mini-stack i,
html.calm .rh-halo,
html.calm .qc-chap-go,
html.calm .eyebrow .dot,
html.calm .live-dot {
  animation: none !important;
}

html.calm .marquee {
  overflow-x: auto;
  scrollbar-width: none;
}

.motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.motion-toggle .seg button {
  min-height: 30px;
  padding: 0.3em 0.8em;
  font-size: 0.78rem;
}
