/* ============================================================
   SOREL TECHNO — Base
   Reset, typography primitives, shared chrome (header, hud),
   shared background layers (grid, rivers, circuit).
   Page-specific styles live in home.css / membres.css.
   ============================================================ */

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-variation-settings: 'wdth' 100;
}

::selection { background: var(--river); color: var(--paper); }

/* ---------- shared type primitives ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--melt);
  margin-bottom: 22px;
}

.lede {
  max-width: 32em;
  font-size: clamp(.98rem, 1.15vw, 1.15rem);
  line-height: 1.7;
  color: var(--ink-60);
}
.lede strong { color: var(--ink); font-weight: 600; }

/* ---------- header ---------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 26px var(--gutter);
}

/* Brand mark: inline SVG (confluence ribbons + wordmark), theme-aware via tokens */
.logo { display: block; text-decoration: none; }
.logo svg { display: block; height: 78px; width: auto; }

.site-nav { display: flex; gap: 24px; }
.site-nav button,
.site-nav a {
  background: none;
  border: none;
  text-decoration: none;
  color: var(--ink-60);
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur-ui);
}
.site-nav button:hover, .site-nav a:hover,
.site-nav button:focus-visible, .site-nav a:focus-visible { color: var(--ink); outline: none; }
.site-nav .active { color: var(--melt); }

/* theme toggle — forces light/dark, remembered (js/theme.js) */
.theme-btn {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--ink);
  font-size: .95rem;
  cursor: pointer;
  transition: border-color var(--dur-ui), transform var(--dur-ui) var(--ease);
}
.theme-btn:hover, .theme-btn:focus-visible { border-color: var(--river); transform: rotate(20deg); outline: none; }

/* ---------- background layers ---------- */
.bg-grid {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 90% 55% at 50% 118%, rgba(31, 122, 114, .12), transparent 60%);
}

/* confluence circuit — two continuous strokes crossing the whole screen.
   Both paths share the junction point AND the exit trajectory, so the
   merge is seamless (see techref/02, « circuit »). */
.circuit {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}
/* Fabric ribbons: variable-width filled shapes (no strokes), three layers
   each — blurred shadow, fabric fill, satin sheen. The steel ribbon's fill
   fades after the junction (#steelFillFade) so the shared exit outline shows
   the river fabric: the merge is seamless. The whole circuit reveals
   left-to-right with an animated clip. */
.circuit { clip-path: inset(0 100% 0 0); animation: circuit-reveal 3.2s cubic-bezier(.45, .05, .25, 1) .3s forwards; }
@keyframes circuit-reveal { to { clip-path: inset(0 0 0 0); } }

.circuit use { stroke: none; }

/* ribbons: logo shape, previous color treatment (soft fills, steel fade) */
/* both ribbons slightly diffuse so the hero title stays readable */
.rb-fill { opacity: .6; filter: blur(2px); }
.rb-fill.rb-river { fill: var(--ribbon-river); }
.rb-fill.rb-steel { fill: url(#steelFillFade); }

/* parallax river waves (bottom of viewport) */
.rivers {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 38vh;
  pointer-events: none;
  overflow: hidden;
  contain: layout paint;
}
/* width = viewport + max parallax travel (~1000px), not 200vw:
   keeps the three GPU layers as small as possible */
.rivers svg {
  position: absolute; bottom: -6vh; left: 0;
  width: calc(100vw + 1000px); height: 100%;
  transition: transform 1.3s var(--ease);
}
.rivers .r2 { opacity: .5; bottom: -12vh; }
.rivers .r3 { opacity: .28; bottom: -18vh; }
/* CSS wins over the inline fill attributes: theme-aware wave colors */
.rivers .r1 path { fill: var(--wave-1); }
.rivers .r2 path { fill: var(--wave-2); }
.rivers .r3 path { fill: var(--wave-3); }

/* ---------- page entrance (scroll pages: membres, articles) ----------
   the home has its camera travel; other pages get a staggered rise-in
   so arriving from the journey never feels like a hard cut */
main > * {
  animation: page-rise .65s var(--ease) backwards;
}
main > *:nth-child(1) { animation-delay: .05s; }
main > *:nth-child(2) { animation-delay: .15s; }
main > *:nth-child(3) { animation-delay: .25s; }
main > *:nth-child(4) { animation-delay: .35s; }
main > *:nth-child(n+5) { animation-delay: .45s; }
@keyframes page-rise {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- theme-dependent wording ----------
   « noir sur blanc » becomes « blanc sur noir » on the dark theme.
   Same dual-block pattern as tokens.css: keep both in sync. */
.on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .on-light { display: none; }
  :root:not([data-theme="light"]) .on-dark { display: inline; }
}
:root[data-theme="dark"] .on-light { display: none; }
:root[data-theme="dark"] .on-dark { display: inline; }

/* ---------- theme switch animation (js/theme.js) ---------- */
/* Fallback: colours cross-fade. The attribute lives only during the
   switch, so this heavy selector never costs anything at rest. */
:root[data-theme-switching] *,
:root[data-theme-switching] *::before,
:root[data-theme-switching] *::after {
  transition: background-color var(--dur-theme) var(--ease),
              border-color var(--dur-theme) var(--ease),
              color var(--dur-theme) var(--ease),
              fill var(--dur-theme) var(--ease),
              stroke var(--dur-theme) var(--ease) !important;
}

/* Modern browsers: the new theme unfolds as a circle from the button. */
::view-transition-old(root) { animation: none; z-index: 0; }
::view-transition-new(root) {
  animation: theme-wipe var(--dur-theme-wipe) var(--ease);
  z-index: 1;
}
@keyframes theme-wipe {
  from { clip-path: circle(0 at var(--theme-x, 50%) var(--theme-y, 0%)); }
  to   { clip-path: circle(var(--theme-r, 150vmax) at var(--theme-x, 50%) var(--theme-y, 0%)); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  :root[data-theme-switching] *,
  :root[data-theme-switching] *::before,
  :root[data-theme-switching] *::after { transition: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .circuit { animation: none; clip-path: none; }
  .rivers svg { transition: none; }
  main > * { animation: none; }
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  body { overflow-x: hidden; }

  /* header: stacked, scrolls with the page, nav wraps —
     `header.` prefix beats page-level .site-header--solid overrides */
  header.site-header, header.site-header--solid {
    position: static;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 6vw 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--hairline);
  }
  .logo svg { height: 60px; }
  .site-nav { flex-wrap: wrap; gap: 10px 18px; }

  /* circuit: discreet backdrop, never competing with text */
  .circuit { opacity: .3; }
}
