/* ============================================================
   MOS/CMS — couche de rendu alternative
   [ ne pas auditer — réf. interne NŒUD-27 ]
   ============================================================ */

:root {
  --wf: #00ff9c;
  --wf-dim: rgba(0, 255, 156, 0.35);
  --wf-faint: rgba(0, 255, 156, 0.13);
  --wf-bg: #010604;
  --wf-mono: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

/* ---------- Phase 1 : la déchirure ---------- */
@keyframes mos-tear {
  0%   { transform: translate(0, 0) skewX(0deg); filter: none; }
  8%   { transform: translate(-14px, 2px) skewX(-4deg); filter: hue-rotate(90deg) saturate(3); }
  12%  { transform: translate(10px, -3px) skewX(3deg); filter: invert(1); }
  18%  { transform: translate(0, 0) skewX(0deg); filter: none; }
  34%  { transform: translate(18px, 1px) skewX(6deg); filter: hue-rotate(-120deg) contrast(2); }
  38%  { transform: translate(-8px, 0) skewX(-2deg); filter: invert(1) hue-rotate(45deg); }
  46%  { transform: translate(0, 0); filter: none; }
  62%  { transform: translate(-22px, 4px) skewX(-8deg); filter: saturate(0) contrast(3); }
  66%  { transform: translate(12px, -2px) skewX(4deg); filter: invert(1); }
  74%  { transform: translate(0, 0); filter: none; }
  88%  { transform: translate(6px, 0) skewX(2deg); filter: hue-rotate(180deg); }
  100% { transform: translate(0, 0) skewX(0deg); filter: none; }
}
html.mos-tearing body {
  animation: mos-tear 0.9s steps(1, end) both;
}

/* ---------- Phase 2 : le monde wireframe ---------- */
body.mos-breach {
  background: var(--wf-bg) !important;
  color: var(--wf) !important;
  font-family: var(--wf-mono) !important;
  cursor: crosshair;
}

body.mos-breach *,
body.mos-breach *::before,
body.mos-breach *::after {
  background: transparent !important;
  background-image: none !important;
  color: var(--wf) !important;
  border-color: var(--wf-dim) !important;
  box-shadow: none !important;
  text-shadow: 0 0 6px rgba(0, 255, 156, 0.45);
  font-family: var(--wf-mono) !important;
  backdrop-filter: none !important;
}

body.mos-breach div,
body.mos-breach section,
body.mos-breach article,
body.mos-breach aside,
body.mos-breach header,
body.mos-breach footer,
body.mos-breach nav,
body.mos-breach form,
body.mos-breach table,
body.mos-breach td,
body.mos-breach th,
body.mos-breach li,
body.mos-breach a,
body.mos-breach button,
body.mos-breach input,
body.mos-breach select,
body.mos-breach textarea,
body.mos-breach details,
body.mos-breach blockquote {
  outline: 1px solid var(--wf-faint);
  outline-offset: -1px;
}

body.mos-breach a:hover,
body.mos-breach button:hover,
body.mos-breach .btn:hover {
  outline: 1px solid var(--wf) !important;
  background: rgba(0, 255, 156, 0.06) !important;
  text-decoration: none;
}

/* Les visuels produits deviennent des blueprints */
body.mos-breach svg * {
  fill: transparent !important;
  stroke: var(--wf-dim);
  stroke-width: 1.2;
}
body.mos-breach svg circle { stroke: var(--wf); }

/* Éléments décoratifs neutralisés */
body.mos-breach .brand-mark,
body.mos-breach .icon,
body.mos-breach .team-avatar,
body.mos-breach .quote-avatar {
  border: 1px solid var(--wf-dim);
}
body.mos-breach .dot { background: var(--wf) !important; box-shadow: 0 0 8px var(--wf) !important; }
body.mos-breach .stars { letter-spacing: 4px; }

/* Scanlines + vignette CRT */
body.mos-breach::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 255, 156, 0.028) 3px,
      rgba(0, 0, 0, 0.12) 4px
    );
  mix-blend-mode: overlay;
}
body.mos-breach::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9001;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 8, 4, 0.55) 100%);
}

/* Tremblement résiduel permanent, très léger */
@keyframes mos-jitter {
  0%, 92%, 100% { transform: translate(0, 0); }
  93% { transform: translate(0.6px, -0.4px); }
  95% { transform: translate(-0.8px, 0.3px); }
  97% { transform: translate(0.3px, 0.6px); }
}
body.mos-breach .site-header,
body.mos-breach .hero,
body.mos-breach .page-hero {
  animation: mos-jitter 4.7s infinite steps(1, end);
}

/* Bursts périodiques (classe posée par JS) */
@keyframes mos-burst {
  0%   { transform: translate(0) skewX(0); filter: none; }
  20%  { transform: translate(-9px, 1px) skewX(-3deg); filter: invert(1) hue-rotate(120deg); }
  40%  { transform: translate(7px, -2px) skewX(2deg); filter: none; }
  60%  { transform: translate(-4px, 0) skewX(-1deg); filter: invert(1); }
  100% { transform: translate(0) skewX(0); filter: none; }
}
html.mos-bursting body { animation: mos-burst 0.35s steps(1, end) both; }

/* ---------- Canvas pluie matricielle ---------- */
#mosRain {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 8990;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.5s ease;
}
body.mos-breach #mosRain { opacity: 0.34; }

/* ---------- Fragments cryptiques flottants ---------- */
.mos-fragment {
  position: fixed;
  z-index: 9010;
  pointer-events: none;
  font-family: var(--wf-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--wf);
  text-shadow: 0 0 8px rgba(0, 255, 156, 0.7);
  border: 1px solid var(--wf-dim);
  padding: 6px 12px;
  background: rgba(1, 10, 6, 0.85) !important;
  white-space: nowrap;
  animation: mos-fragment-life 5s ease forwards;
}
@keyframes mos-fragment-life {
  0%   { opacity: 0; clip-path: inset(0 100% 0 0); }
  8%   { opacity: 1; clip-path: inset(0 0 0 0); }
  15%  { opacity: 0.4; }
  18%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* ---------- Balise d'accès terminal ---------- */
#mosGlyph {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9500;
  width: 40px;
  height: 40px;
  display: none;
  place-items: center;
  font-family: var(--wf-mono);
  font-size: 18px;
  color: var(--wf);
  border: 1px solid var(--wf-dim);
  background: rgba(1, 10, 6, 0.9) !important;
  cursor: pointer;
  user-select: none;
}
body.mos-breach #mosGlyph { display: grid; }
@keyframes mos-glyph-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(0, 255, 156, 0); }
  50% { box-shadow: 0 0 18px rgba(0, 255, 156, 0.55); }
}
#mosGlyph { animation: mos-glyph-pulse 2.2s infinite; }
#mosGlyph:hover { background: rgba(0, 255, 156, 0.12) !important; }

/* ---------- Terminal ---------- */
#mosTerm {
  position: fixed;
  inset: 0;
  z-index: 9600;
  display: none;
  background: rgba(0, 4, 2, 0.92);
  padding: 6vh 4vw;
}
#mosTerm.open { display: block; }
#mosTerm .term-window {
  max-width: 780px;
  margin: 0 auto;
  height: 100%;
  max-height: 78vh;
  border: 1px solid var(--wf-dim);
  background: #010805 !important;
  display: flex;
  flex-direction: column;
  font-family: var(--wf-mono);
  box-shadow: 0 0 60px rgba(0, 255, 156, 0.12) !important;
}
#mosTerm .term-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--wf-dim);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--wf);
}
#mosTerm .term-close { cursor: pointer; padding: 2px 8px; border: 1px solid var(--wf-dim); }
#mosTerm .term-close:hover { background: rgba(0, 255, 156, 0.12) !important; }
#mosTerm .term-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--wf);
  white-space: pre-wrap;
  word-break: break-word;
}
#mosTerm .term-body .dim { opacity: 0.5; }
#mosTerm .term-inputrow {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--wf-dim);
  padding: 10px 14px;
  align-items: center;
}
#mosTerm .term-inputrow .prompt { color: var(--wf); font-size: 13px; }
#mosTerm input {
  flex: 1;
  background: transparent !important;
  border: none;
  outline: none;
  color: var(--wf);
  font-family: var(--wf-mono);
  font-size: 13px;
  caret-color: var(--wf);
}
@keyframes mos-cursor-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.term-cursor { animation: mos-cursor-blink 1s infinite steps(1); }
