/* ============================================================
   LARUGA.FR — main.css
   Global styles, variables, typography, header, footer,
   animations, grain canvas, utilities.
   ============================================================ */

/* ------------------------------------------------------------
   1. GOOGLE FONTS IMPORTS
   ------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ------------------------------------------------------------
   2. CSS CUSTOM PROPERTIES
   ------------------------------------------------------------ */
:root {
  /* — Color Palette — */
  --parchemin:        #e8e4dc;   /* main background          */
  --parchemin-mid:    #ddd8ce;   /* subtle alternate bg      */
  --parchemin-dark:   #cdc8bc;   /* darker section bg        */
  --anthracite:       #1a1a18;   /* primary text             */
  --anthracite-light: #3d3d3a;   /* secondary text           */
  --mono-grey:        #7a7570;   /* metadata, muted          */
  --border:           #c0bbb0;   /* separators               */
  --cardinal:         #8b1a1a;   /* accent color             */
  --cardinal-dark:    #6e1414;   /* accent hover             */
  --cardinal-light:   #a52020;   /* accent light             */
  --white-warm:       #f4f1ec;   /* near-white               */

  /* — Chromatic Accent Palette (Pôles & Archives) — */
  --color-p01: #c83228;   /* Rouge cardinal vif / Terre cuite (Design fiction) */
  --color-p02: #1d5bbf;   /* Bleu cobalt / Cyan minéral (Ludologie & Systèmes) */
  --color-p03: #c2781b;   /* Ambre doré / Ocre photographique (Photographie) */
  --color-p04: #1f7a55;   /* Vert émeraude / Sorbier profond (Écriture) */
  --color-p05: #7033a8;   /* Violet électrique / Indigo archive (Interfaces) */
  --color-p06: #b85226;   /* Cuivre martelé / Rouille (Recherche & Objets) */
  --color-p07: #b38f00;   /* Jaune soufre / Ocre critique (Dispositifs critiques) */
  --color-p08: #0e7085;   /* Pétrole / Bleu d'encre (Couverture presse) */
  --color-p09: #6b21a8;   /* Violet magnétique / Signal analogique (Entretiens & Vidéos) */

  /* — Typography — */
  --font-display: 'Bebas Neue', 'Arial Narrow', Arial, sans-serif;
  --font-mono:    'Space Mono', 'Courier New', Courier, monospace;
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;

  /* — Spacing scale — */
  --space-xs:   0.25rem;
  --space-sm:   0.5rem;
  --space-md:   1rem;
  --space-lg:   1.5rem;
  --space-xl:   2rem;
  --space-2xl:  3rem;
  --space-3xl:  4rem;

  /* — Layout — */
  --header-height: 60px;
  --max-width:     1600px;
  --sidebar-width: 320px;

  /* — Transitions — */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast:   150ms;
  --duration-base:   250ms;
  --duration-slow:   400ms;
  --duration-xslow:  600ms;
}

/* ------------------------------------------------------------
   3. CSS RESET & NORMALIZE
   ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
}

body {
  background-color: var(--parchemin);
  color: var(--anthracite);
  font-family: var(--font-body);
  font-weight: 400;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

img {
  height: auto;
}

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

button {
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

ol,
ul {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: inherit;
  line-height: 1;
}

p {
  max-width: 72ch;
}

/* Prevent font-boost in some mobile browsers */
p,
li,
label,
input,
textarea,
button {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Remove default fieldset styles */
fieldset {
  border: none;
  padding: 0;
}

/* Remove animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------
   4. SCROLLBAR STYLES
   ------------------------------------------------------------ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--parchemin-mid);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 0;
  transition: background var(--duration-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--mono-grey);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--parchemin-mid);
}

/* ------------------------------------------------------------
   5. SELECTION COLOR
   ------------------------------------------------------------ */
::selection {
  background-color: var(--cardinal);
  color: var(--white-warm);
}

::-moz-selection {
  background-color: var(--cardinal);
  color: var(--white-warm);
}

/* ------------------------------------------------------------
   6. GLOBAL TYPOGRAPHY
   ------------------------------------------------------------ */

/* Display / Titles — Bebas Neue */
.display,
.t-display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 0.9;
  text-transform: uppercase;
}

/* Mono / Metadata — Space Mono */
.mono,
.t-mono {
  font-family: var(--font-mono);
  font-weight: 400;
}

/* Body — DM Sans */
.body-text,
.t-body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
}

/* Global heading fallbacks using display font */
h1 {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 8rem);
  color: var(--anthracite);
  line-height: 0.9;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 5rem);
  color: var(--anthracite);
  line-height: 0.9;
}

h3 {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--anthracite-light);
}

/* ------------------------------------------------------------
   7. GRAIN CANVAS — fixed full-screen noise overlay
   ------------------------------------------------------------ */
#grain-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  opacity: 0.07;
  /* Ensures canvas is above content but below overlays (z-index 200+) */
}

/* ------------------------------------------------------------
   8. SITE HEADER
   ------------------------------------------------------------ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  background-color: var(--parchemin);
  border-bottom: 1px solid var(--border);
  /* Subtle shadow for depth without heaviness */
  box-shadow: 0 1px 0 0 rgba(26, 26, 24, 0.04);
}

/* — Identity (left side) — */
.header-identity {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.header-identity a,
a.header-name,
.header-name {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--anthracite);
  text-transform: uppercase;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  transition: color var(--duration-base);
}

.header-identity a:hover,
a.header-name:hover,
.header-name:hover {
  color: var(--cardinal);
}

.header-tagline {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--mono-grey);
  line-height: 1;
  letter-spacing: 0.03em;
}

/* — Navigation (right side) — */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--anthracite);
  position: relative;
  display: inline-flex;
  align-items: center;
  transition: color var(--duration-base), letter-spacing var(--duration-base), text-shadow var(--duration-base);
}

/* Indicateur rétro terminal en chevron avant le lien au survol */
.nav-link::before {
  content: '//';
  position: absolute;
  left: -14px;
  color: var(--cardinal);
  font-size: 9px;
  font-weight: 700;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

/* Ligne laser luminescente sous le lien */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cardinal), var(--cardinal-light), transparent);
  box-shadow: 0 0 6px rgba(139, 26, 26, 0.6);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.nav-link:hover {
  color: var(--cardinal);
  letter-spacing: 0.12em;
  text-shadow:
    0 0 8px rgba(139, 26, 26, 0.45),
    -1px 0 rgba(220, 30, 30, 0.35),
    1px 0 rgba(0, 220, 255, 0.25);
}

.nav-link:hover::before {
  opacity: 1;
  transform: translateX(0);
}

.nav-link:hover::after {
  width: 100%;
}

.nav-link.active,
.nav-link.nav-active {
  color: var(--cardinal);
  font-weight: 700;
}

.nav-link.active::after,
.nav-link.nav-active::after {
  width: 100%;
}

/* — Mobile hamburger button — */
.header-mobile-menu {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 160;
}

.header-mobile-menu span {
  width: 100%;
  height: 2px;
  background-color: var(--anthracite);
  transition: all 0.3s ease;
}

/* — Mobile navigation overlay — */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--parchemin);
  z-index: 155;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.mobile-nav-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.mobile-nav-link {
  font-family: var(--font-display);
  font-size: clamp(32px, 8vw, 48px);
  text-transform: uppercase;
  color: var(--anthracite);
  transition: color 0.2s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link.nav-active {
  color: var(--cardinal);
}

.mobile-nav-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--anthracite);
  cursor: pointer;
}

/* — Language Toggle — Tactile Archival Switch — */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--parchemin-mid);
  border: 1px solid var(--border);
  padding: 2px;
  border-radius: 0;
}

.lang-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--mono-grey);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0.25rem 0.55rem;
  line-height: 1;
  transition: all var(--duration-fast) ease;
}

.lang-btn:hover {
  color: var(--anthracite);
}

.lang-btn.active,
.lang-toggle .active {
  color: var(--white-warm) !important;
  background: var(--cardinal) !important;
  border-color: var(--cardinal) !important;
  box-shadow: 0 1px 3px rgba(139, 26, 26, 0.25);
}

.lang-sep {
  display: none;
}

/* Mobile: hide tagline on narrow screens */
@media (max-width: 767px) {
  .header-tagline {
    display: none;
  }

  .site-header {
    padding: 0 var(--space-md);
  }

  .header-nav {
    display: none;
  }

  .header-mobile-menu {
    display: flex;
  }
}

/* ------------------------------------------------------------
   9. SITE FOOTER
   ------------------------------------------------------------ */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-xl);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mono-grey);
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border);
  background-color: var(--parchemin);
}

.site-footer a {
  color: var(--mono-grey);
  transition: color var(--duration-base);
}

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

.site-footer .footer-copy {
  text-transform: uppercase;
}

.site-footer .footer-links {
  display: flex;
  gap: var(--space-lg);
}

@media (max-width: 767px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-lg);
  }
}

/* ------------------------------------------------------------
   10. PAGE INTRO
   ------------------------------------------------------------ */
.page-intro {
  padding: calc(var(--header-height) + var(--space-2xl)) var(--space-xl) var(--space-xl);
  overflow: hidden;
}

.page-intro-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--mono-grey);
  margin-bottom: var(--space-md);
}

.page-intro-title {
  font-family: var(--font-display);
  font-size: clamp(4rem, 14vw, 16rem);
  color: var(--anthracite);
  line-height: 0.85;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------
   11. ANIMATIONS
   ------------------------------------------------------------ */

/* Fade in from opacity 0 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Slide in from the right */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from below */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reveal left-to-right (for decorative underlines etc.) */
@keyframes revealWidth {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/* Subtle pulse for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Grain animation: random texture shift */
@keyframes grainShift {
  0%,
  100% { transform: translate(0, 0); }
  10%   { transform: translate(-2%, -3%); }
  20%   { transform: translate(3%, 1%); }
  30%   { transform: translate(-1%, 4%); }
  40%   { transform: translate(4%, -2%); }
  50%   { transform: translate(-3%, 2%); }
  60%   { transform: translate(2%, -4%); }
  70%   { transform: translate(-4%, 1%); }
  80%   { transform: translate(1%, 3%); }
  90%   { transform: translate(3%, -1%); }
}

/* Animation utility classes */
.anim-fade-in {
  animation: fadeIn var(--duration-slow) var(--ease-standard) both;
}

.anim-slide-in-right {
  animation: slideInRight var(--duration-slow) var(--ease-out-expo) both;
}

.anim-slide-in-up {
  animation: slideInUp var(--duration-slow) var(--ease-standard) both;
}

/* Stagger delays for list items */
.anim-stagger > *:nth-child(1)  { animation-delay: 50ms; }
.anim-stagger > *:nth-child(2)  { animation-delay: 100ms; }
.anim-stagger > *:nth-child(3)  { animation-delay: 150ms; }
.anim-stagger > *:nth-child(4)  { animation-delay: 200ms; }
.anim-stagger > *:nth-child(5)  { animation-delay: 250ms; }
.anim-stagger > *:nth-child(6)  { animation-delay: 300ms; }
.anim-stagger > *:nth-child(7)  { animation-delay: 350ms; }
.anim-stagger > *:nth-child(8)  { animation-delay: 400ms; }

/* ------------------------------------------------------------
   12. UTILITY CLASSES
   ------------------------------------------------------------ */

/* Visually hidden but accessible to screen readers */
.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;
}

/* Cardinal accent color for text */
.text-cardinal {
  color: var(--cardinal);
}

/* Space Mono monospace text style */
.text-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* Helpful display utilities */
.d-flex     { display: flex; }
.d-grid     { display: grid; }
.d-none     { display: none; }
.d-block    { display: block; }

.items-center   { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Text alignment */
.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* Text transform */
.uppercase { text-transform: uppercase; }

/* Color utilities */
.color-mono-grey        { color: var(--mono-grey); }
.color-anthracite       { color: var(--anthracite); }
.color-anthracite-light { color: var(--anthracite-light); }

/* Truncate text to single line */
.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Divider line */
.divider {
  width: 100%;
  height: 1px;
  background-color: var(--border);
  margin: var(--space-lg) 0;
}

/* Focus ring — accessible, brand-colored */
:focus-visible {
  outline: 2px solid var(--cardinal);
  outline-offset: 2px;
}

/* Suppress focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ------------------------------------------------------------
   13. DISCREET ADMIN ACCESS
   ------------------------------------------------------------ */
.nav-link.nav-admin {
  font-size: 10px;
  opacity: 0.6;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background-color: rgba(221, 216, 206, 0.4);
  transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.nav-link.nav-admin:hover {
  opacity: 1;
  color: var(--cardinal);
  border-color: var(--cardinal);
  background-color: var(--white-warm);
}

.footer-admin-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mono-grey);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background-color: var(--parchemin-mid);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.footer-admin-btn:hover {
  color: var(--white-warm);
  background-color: var(--anthracite);
  border-color: var(--anthracite);
}

/* ------------------------------------------------------------
   14. RETRO ANALOG INTERFERENCES & GLITCH SYSTEM
   Variable analog disturbances across the viewport & UI
   ------------------------------------------------------------ */

/* Fullscreen overlay container for analog beam / tracking bands */
.analog-interference-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
  overflow: hidden;
}

/* Tracking Bar: VHS / CRT horizontal tracking error line */
.interference-tracking-bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 24px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255, 255, 255, 0.09) 20%,
    rgba(220, 40, 40, 0.28) 45%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(0, 230, 255, 0.22) 55%,
    rgba(255, 255, 255, 0.08) 80%,
    transparent 100%
  );
  box-shadow: 0 0 16px rgba(255, 50, 50, 0.35);
  mix-blend-mode: color-burn, overlay;
  pointer-events: none;
  opacity: 0;
  top: -40px;
}

.interference-tracking-bar.active {
  animation: trackingSweep 0.58s cubic-bezier(0.25, 0.85, 0.3, 1) forwards;
}

@keyframes trackingSweep {
  0% {
    top: -30px;
    opacity: 0;
    transform: scaleY(0.7);
  }
  15% {
    opacity: 0.95;
    transform: scaleY(1.3);
  }
  85% {
    opacity: 0.9;
    transform: scaleY(1);
  }
  100% {
    top: 105vh;
    opacity: 0;
    transform: scaleY(0.6);
  }
}

/* --- Glitch Variation A: Upper Slice RGB Dislocation --- */
.has-interference-tear-a {
  animation: glitchTearA 0.22s cubic-bezier(0.12, 0.85, 0.2, 1) forwards !important;
}

@keyframes glitchTearA {
  0% {
    transform: translate(0, 0);
    filter: none;
  }
  20% {
    transform: translate(-5px, 1px) skewX(-1.8deg);
    text-shadow: -3px 0 rgba(220, 30, 30, 0.85), 3px 0 rgba(0, 220, 255, 0.8);
    clip-path: polygon(0 12%, 100% 12%, 100% 42%, 0 42%);
  }
  45% {
    transform: translate(4px, -1px) skewX(1.2deg);
    text-shadow: 3.5px 0 rgba(220, 30, 30, 0.85), -3.5px 0 rgba(0, 220, 255, 0.8);
    clip-path: polygon(0 55%, 100% 55%, 100% 82%, 0 82%);
  }
  75% {
    transform: translate(-1.5px, 0.5px);
    text-shadow: -1.5px 0 rgba(220, 30, 30, 0.5), 1.5px 0 rgba(0, 220, 255, 0.45);
    clip-path: none;
  }
  100% {
    transform: translate(0, 0);
    filter: none;
    clip-path: none;
    text-shadow: none;
  }
}

/* --- Glitch Variation B: Lower Diagonal Slice Amber/Violet Dislocation --- */
.has-interference-tear-b {
  animation: glitchTearB 0.28s cubic-bezier(0.15, 0.9, 0.25, 1) forwards !important;
}

@keyframes glitchTearB {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(6px, -2px) skewX(2.8deg);
    filter: brightness(1.4) contrast(1.25);
    text-shadow: 4px 0 rgba(255, 90, 20, 0.9), -4px 0 rgba(160, 30, 255, 0.8);
    clip-path: polygon(0 32%, 100% 26%, 100% 68%, 0 74%);
  }
  60% {
    transform: translate(-4px, 1px) skewX(-1.5deg);
    text-shadow: -2.5px 0 rgba(255, 90, 20, 0.7), 2.5px 0 rgba(160, 30, 255, 0.65);
    clip-path: polygon(0 65%, 100% 60%, 100% 95%, 0 99%);
  }
  85% {
    transform: translate(1px, -0.5px);
    clip-path: none;
  }
  100% {
    transform: translate(0, 0);
    filter: none;
    clip-path: none;
    text-shadow: none;
  }
}

/* --- Glitch Variation C: Micro-Jitter Static Buzz (Click / Tactile Feedback) --- */
.has-interference-buzz {
  animation: interferenceBuzz 0.18s steps(4) forwards !important;
}

@keyframes interferenceBuzz {
  0% {
    transform: translate(1.5px, -1px);
    filter: contrast(1.4) brightness(1.2);
    text-shadow: -1.5px 0 var(--cardinal);
  }
  25% {
    transform: translate(-2px, 1.5px);
    filter: contrast(0.9) invert(0.06);
    text-shadow: 2px 0 #00e5ff;
  }
  50% {
    transform: translate(1.5px, 1px);
    filter: brightness(1.3);
  }
  75% {
    transform: translate(-1px, -0.5px);
    text-shadow: -1px 0 var(--cardinal);
  }
  100% {
    transform: translate(0, 0);
    filter: none;
    text-shadow: none;
  }
}

/* --- Glitch Variation D: CRT Phosphor Exposure Flutter --- */
.has-phosphor-flutter {
  animation: phosphorFlutter 0.14s ease-out forwards;
}

@keyframes phosphorFlutter {
  0%   { filter: brightness(1) contrast(1); }
  30%  { filter: brightness(1.35) contrast(1.2) saturate(1.3); }
  60%  { filter: brightness(0.85) contrast(0.95); }
  85%  { filter: brightness(1.15); }
  100% { filter: brightness(1) contrast(1); }
}

/* --- Glitch Variation E: Analog Scanline Desync --- */
.has-scanline-desync {
  position: relative;
}

.has-scanline-desync::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(26, 26, 24, 0.25) 0px,
    rgba(26, 26, 24, 0.25) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 10;
  animation: desyncFade 0.2s ease-out forwards;
}

@keyframes desyncFade {
  0%   { opacity: 0.9; transform: translateY(-2px); }
  50%  { opacity: 0.6; transform: translateY(2px); }
  100% { opacity: 0; transform: translateY(0); }
}

/* ============================================================
   RETRO CRT PAGE TRANSITION (BETWEEN PROJETS, ÉCHOS, CONTACT)
   ============================================================ */
.retro-page-transition {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, #8b1a1a 0%, #6e1414 55%, #460c0c 100%);
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.retro-page-transition-lines {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 235, 220, 0.08) 0px,
      rgba(255, 235, 220, 0.08) 1.5px,
      transparent 1.5px,
      transparent 3.5px
    ),
    repeating-linear-gradient(
      to right,
      rgba(255, 50, 50, 0.05) 0px,
      rgba(50, 255, 220, 0.04) 1px,
      transparent 2px,
      transparent 4px
    );
  pointer-events: none;
}

.retro-page-transition-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  background: linear-gradient(90deg, transparent 5%, #ffcc88 25%, #ffffff 50%, #ffcc88 75%, transparent 95%);
  box-shadow: 0 0 25px rgba(255, 180, 100, 0.9), 0 0 50px rgba(139, 26, 26, 0.8);
  transform: translateY(-50%) scaleX(0);
  opacity: 0;
}

/* OUT animation: balayage analogique doux et coloré vers la nouvelle page */
.retro-page-transition.is-transitioning-out {
  pointer-events: all;
  animation: retroWarmPageOut 0.26s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

.retro-page-transition.is-transitioning-out .retro-page-transition-beam {
  animation: retroWarmBeamOut 0.26s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

@keyframes retroWarmPageOut {
  0% {
    opacity: 0;
    transform: scaleY(0.02);
  }
  35% {
    opacity: 0.92;
    transform: scaleY(0.4);
  }
  75% {
    opacity: 0.98;
    transform: scaleY(1);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes retroWarmBeamOut {
  0% { opacity: 0; transform: translateY(-50%) scaleX(0); }
  50% { opacity: 1; transform: translateY(-50%) scaleX(1); }
  100% { opacity: 0.85; transform: translateY(-50%) scaleX(1); }
}

/* IN animation: expand from center beam into full viewport with phosphor bloom */
/* IN animation: ouverture fluide par faisceau lumineux et dissipation du rouge cardinal */
.retro-page-transition.is-transitioning-in {
  pointer-events: none;
  animation: retroWarmPageIn 0.32s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

.retro-page-transition.is-transitioning-in .retro-page-transition-beam {
  animation: retroWarmBeamIn 0.32s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

@keyframes retroWarmPageIn {
  0% {
    opacity: 1;
    transform: scaleY(1);
  }
  45% {
    opacity: 0.85;
    transform: scaleY(0.35);
  }
  80% {
    opacity: 0.3;
    transform: scaleY(0.02);
  }
  100% {
    opacity: 0;
    transform: scaleY(0);
  }
}

@keyframes retroWarmBeamIn {
  0% { opacity: 1; transform: translateY(-50%) scaleX(1); }
  50% { opacity: 0.8; transform: translateY(-50%) scaleX(0.7); }
  100% { opacity: 0; transform: translateY(-50%) scaleX(0); }
}

/* ------------------------------------------------------------
   CRITICAL DESIGN FICTION: ANTS INACTIVITY SIMULATION
   ------------------------------------------------------------ */
#ants-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 250; /* Au-dessus du tiroir des fiches projets (z-index 201) et de l'overlay (200) */
}

@keyframes antsBadgeReveal {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ants-toggle-btn {
  position: fixed;
  bottom: 1.25rem;
  right: 1.5rem;
  left: auto;
  z-index: 260; /* Au-dessus des fiches projets pour rester visible et contrôlable */
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(232, 228, 220, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--anthracite);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 0;
  cursor: pointer;
  display: none; /* Masqué de base tant qu'il n'est pas déployé depuis la fiche projet */
  align-items: center;
  gap: 7px;
  user-select: none;
  box-shadow: 0 4px 14px rgba(26, 26, 24, 0.10);
  transition: background-color var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast);
}

.ants-toggle-btn.is-mounted {
  display: inline-flex;
  animation: antsBadgeReveal 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ants-toggle-btn .ants-action {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cardinal);
  transition: color var(--duration-fast);
}

.ants-toggle-btn:hover {
  background-color: var(--cardinal);
  color: var(--white-warm);
  border-color: var(--cardinal);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(139, 26, 26, 0.25);
}

.ants-toggle-btn:hover .ants-action {
  color: var(--white-warm);
}

.ants-toggle-btn .ants-icon {
  font-size: 12px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
}

.ants-toggle-btn:hover .ants-icon {
  transform: scale(1.15);
}

.ants-toggle-btn.is-deactivating {
  opacity: 0.85;
  background-color: var(--cardinal);
  color: var(--white-warm);
  border-color: var(--cardinal);
  transform: scale(0.96);
}

.ants-toggle-btn.is-disabled {
  opacity: 0.65;
  border-style: dashed;
}

/* Masquer le curseur système natif lorsqu'il est recouvert par les fourmis */
html.ants-cursor-hidden,
html.ants-cursor-hidden *,
body.ants-cursor-hidden,
body.ants-cursor-hidden * {
  cursor: none !important;
}

/* Masquer sur les appareils exclusivement tactiles sans aucun pointeur fin (souris / trackpad) */
@media (hover: none) and (not (any-pointer: fine)), (pointer: coarse) and (not (any-pointer: fine)) {
  #ants-canvas,
  .ants-toggle-btn {
    display: none !important;
  }
}

/* Dès qu'un pointeur précis (souris / trackpad sur iPad ou ordinateur) est actif */
html.ants-mouse-active #ants-canvas {
  display: block !important;
}
html.ants-mouse-active .ants-toggle-btn.is-mounted {
  display: inline-flex !important;
}



