@import url('./form-controls.css');
@import url('./ui-chrome.css');
@import url('./rate-limit.css');

/* ============================================================
   Base — reset, typographie, primitives globales.
   ============================================================ */

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

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

/* Keeps centred chrome (nav, etc.) steady when scrollbar appears/disappears
   between short and long routes (e.g. Nouvelles vs Accueil). */
@supports (scrollbar-gutter: stable) {
  html {
    scrollbar-gutter: stable;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  /* Flex column → le footer reste collé en bas du viewport tant que le
     contenu ne remplit pas la hauteur. Le `main`/section principal
     pousse sur `flex: 1` via `.site-footer` ci-dessous. Ça évite le
     classique « footer flottant au milieu » sur les pages courtes. */
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-1);
  background: var(--bg-0);
  background-image: var(--grad-radial);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body,
button,
input,
select,
textarea {
  max-width: 100%;
}

p,
li,
dd,
dt,
label,
span,
strong,
a {
  overflow-wrap: break-word;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 80%);
}

main,
footer {
  position: relative;
  z-index: 1;
}

/* Un seul <main> direct sous body (évite d’appliquer flex à un main imbriqué p.ex. /compte). */
body > main {
  min-width: 0;
  width: 100%;
  flex: 1;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--text-0);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  margin: 0 0 0.6em;
  font-weight: 600;
}

h1 {
  font-size: var(--fs-4xl);
  font-weight: 700;
}

h2 {
  font-size: clamp(2rem, 4vw, 3rem);
}

h3 {
  font-size: var(--fs-xl);
}

h4 {
  font-size: var(--fs-lg);
}

p {
  margin: 0 0 1rem;
  color: var(--text-1);
}

p.lead {
  font-size: var(--fs-md);
  color: var(--text-1);
  line-height: var(--lh-loose);
  max-width: 62ch;
}

small,
.eyebrow {
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-2);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(124, 255, 91, 0.25);
  border-radius: var(--radius-pill);
  font-weight: 500;
}

.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

code,
pre,
kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---------- Sélection ---------- */
::selection {
  background: var(--accent);
  color: var(--bg-0);
}

/* ---------- Scrollbars personnalisées ---------- */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-0);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1e2632, #111720);
  border-radius: 8px;
  border: 3px solid var(--bg-0);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
}

/* ---------- Focus accessible ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- Utilitaires ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-accent {
  color: var(--accent);
}

.text-mono {
  font-family: var(--font-mono);
}

.text-center {
  text-align: center;
}

.text-balance {
  text-wrap: balance;
}

.gradient-text {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-1) 20%, var(--border-1) 80%, transparent);
  margin: clamp(2rem, 5vw, 4rem) 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
