/* V190 — Les effets du terminal Domain.exe (src/ui/terminal-fx.js).
   transform et opacity seulement (règle V109) ; couleurs des thèmes (--term-*)
   et, à l'exécution, l'encre du Domain (--tfx-encre). */

/* ------------------------------------------------------------- allumage */
@keyframes tfx-allumage {
  0%   { transform: scale(1.06, 0.012); opacity: 1; }
  38%  { transform: scale(1.02, 0.012); opacity: 1; }
  62%  { transform: scale(1, 1.06); }
  100% { transform: scale(1, 1); opacity: 1; }
}
@keyframes tfx-allumage-eclair {
  0%   { opacity: 0.95; transform: scaleY(1); }
  45%  { opacity: 0.7; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(0.2); }
}
#domainHackModal .domain-hack-terminal.tfx-allumage { animation: tfx-allumage 520ms cubic-bezier(0.2, 0.9, 0.2, 1) both; transform-origin: 50% 50%; }
#domainHackModal .domain-hack-terminal.tfx-allumage::after {
  content: "";
  position: absolute;
  inset: 0;
  height: auto;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 40%, var(--term-ink-strong, #eafff0) 50%, transparent 60%);
  animation: tfx-allumage-eclair 520ms ease-out both;
}
#domainHackModal .domain-hack-terminal.tfx-allumage.tfx-sans-flash::after { display: none; }
@keyframes tfx-apparait { from { opacity: 0; } to { opacity: 1; } }
#domainHackModal .domain-hack-terminal.tfx-apparait { animation: tfx-apparait 260ms ease-out both; }

/* Les lignes du journal, l'une après l'autre. */
@keyframes tfx-ligne { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
#domainHackModal .domain-hack-log > span.tfx-ligne { animation: tfx-ligne 220ms ease-out both; animation-delay: calc(260ms + var(--tfx-rang, 0) * 110ms); }

/* ---------------------------------------------------------------- frappe */
@keyframes tfx-frappe { 0% { transform: translateY(0); } 40% { transform: translateY(1.5px); } 100% { transform: translateY(0); } }
#domainHackModal .domain-hack-command-row.tfx-frappe { animation: tfx-frappe 130ms ease-out; }
/* Un programme du registre reconnu : la ligne prend l'encre du Domain. */
#domainHackModal .domain-hack-terminal.tfx-reconnu .domain-hack-command-row {
  border-color: var(--tfx-encre, var(--term-accent)) !important;
  box-shadow: 0 0 0 1px var(--tfx-encre, var(--term-accent)), 0 0 18px -4px var(--tfx-encre, var(--term-accent)) !important;
}
#domainHackModal .domain-hack-terminal.tfx-reconnu .domain-hack-command-row input,
#domainHackModal .domain-hack-terminal.tfx-reconnu .domain-hack-suffix { color: var(--tfx-encre, var(--term-accent)) !important; }

/* ---------------------------------------------------------------- refus */
@keyframes tfx-refus {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px); }
  30% { transform: translateX(9px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(5px); }
  78% { transform: translateX(-2px); }
}
@keyframes tfx-bande-rouge { from { transform: translateY(-120%); opacity: 0.85; } to { transform: translateY(520%); opacity: 0; } }
#domainHackModal .domain-hack-terminal.tfx-refus {
  animation: tfx-refus 380ms cubic-bezier(0.3, 0.8, 0.3, 1);
  /* La bordure passe au rouge le temps du refus (changement d'état, pas d'animation). */
  border-color: #ff5a64 !important;
  box-shadow: 0 0 0 1px #ff5a64, 0 0 36px -6px #ff3040 !important;
}
#domainHackModal .domain-hack-terminal.tfx-refus .domain-hack-command-row { border-color: #ff5a64 !important; }
#domainHackModal .domain-hack-terminal.tfx-refus::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 22%;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(255, 60, 70, 0.55), transparent);
  animation: tfx-bande-rouge 380ms ease-out both;
}
#domainHackModal .domain-hack-terminal.tfx-refus-calme .domain-hack-command-row { border-color: #ff6b70 !important; }
@keyframes tfx-tampon { 0% { transform: scale(1.35); opacity: 0; } 60% { transform: scale(0.97); opacity: 1; } 100% { transform: scale(1); } }
#domainHackModal .domain-hack-feedback.tfx-tampon { animation: tfx-tampon 300ms cubic-bezier(0.2, 0.9, 0.3, 1.2); transform-origin: 0 50%; }

/* --------------------------------------------- le compte à rebours qui presse */
@keyframes tfx-presse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
#domainHackModal .domain-hack-timer.danger { animation: domainHackDanger .36s steps(2,end) infinite, tfx-presse 500ms ease-in-out infinite; }

/* ----------------------------------------- la copie fantôme (exécution, sortie) */
.tfx-calque { position: fixed; inset: 0; pointer-events: none; z-index: 2147483000; }
.tfx-copie { position: fixed !important; margin: 0 !important; box-sizing: border-box; transform-origin: 50% 50%; }

/* L'exécution : la fenêtre prend l'encre du Domain, la barre se remplit,
   les lignes défilent, puis la télé s'éteint (ligne, puis point). */
.tfx-calque .tfx-copie.tfx-execution { border-color: var(--tfx-encre) !important; box-shadow: 0 0 0 1px var(--tfx-encre), 0 0 48px -8px var(--tfx-encre) !important; animation: tfx-extinction-tele 300ms cubic-bezier(0.6, 0, 0.9, 0.4) 600ms both; }
.tfx-calque .tfx-copie.tfx-execution .domain-hack-header h2,
.tfx-calque .tfx-copie.tfx-execution .domain-hack-kicker { color: var(--tfx-encre) !important; }
/* Le nom du programme claque à l'entrée de l'exécution. */
@keyframes tfx-titre { 0% { transform: scale(1.8); opacity: 0; } 45% { transform: scale(0.95); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.tfx-calque .tfx-copie.tfx-execution .domain-hack-header h2 { display: inline-block; transform-origin: 0 50%; text-shadow: 0 0 14px var(--tfx-encre) !important; animation: tfx-titre 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
@keyframes tfx-extinction-tele {
  0%   { transform: scale(1, 1); opacity: 1; }
  55%  { transform: scale(1.04, 0.014); opacity: 1; }
  100% { transform: scale(0, 0.014); opacity: 0.6; }
}
.tfx-ligne-exec { display: block; color: var(--tfx-encre); animation: tfx-ligne 140ms ease-out both; animation-delay: calc(var(--tfx-rang, 0) * 120ms + 60ms); }
.tfx-progression { display: grid; gap: 8px; padding: 10px 0 4px; }
.tfx-progression-texte { color: var(--tfx-encre); letter-spacing: 0.3em; font-weight: 700; }
.tfx-progression-piste { display: block; height: 14px; border: 1px solid var(--tfx-encre); overflow: hidden; }
@keyframes tfx-remplir { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.tfx-progression-plein { display: block; height: 100%; background: var(--tfx-encre); transform-origin: 0 50%; animation: tfx-remplir 480ms cubic-bezier(0.5, 0, 0.2, 1) both; }

/* Le tampon d'un code secret. */
@keyframes tfx-secret { 0% { transform: translate(-50%, -50%) rotate(-8deg) scale(2.2); opacity: 0; } 55% { transform: translate(-50%, -50%) rotate(-8deg) scale(0.94); opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 1; } }
.tfx-secret {
  position: absolute;
  left: 50%; top: 46%;
  padding: 8px 16px;
  border: 3px solid var(--tfx-encre);
  color: var(--tfx-encre);
  /* À la largeur d'un téléphone, le tampon le plus long (SCHRÖDINGER) tient encore. */
  font: 700 clamp(11px, 3.8vw, 22px)/1 "Press Start 2P", "Courier New", monospace;
  letter-spacing: 0.08em;
  background: rgba(5, 6, 10, 0.82);
  white-space: nowrap;
  animation: tfx-secret 320ms cubic-bezier(0.2, 0.9, 0.3, 1.2) 180ms both;
}

/* Le voile de chaque Domain : le même geste que son « moment » sur le canevas. */
.tfx-voile { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.tfx-calque .tfx-execution-calme .tfx-voile { display: none; }
.tfx-calque .tfx-execution-calme .tfx-ligne-exec { animation: none; }
@keyframes tfx-voile-monte { from { transform: scaleY(0); opacity: 0.55; } to { transform: scaleY(1); opacity: 0.55; } }
@keyframes tfx-voile-ouvre { from { transform: scale(0.15); opacity: 0; } 60% { opacity: 0.5; } to { transform: scale(1); opacity: 0.4; } }
@keyframes tfx-voile-passe { from { transform: translateX(-110%); opacity: 1; } 70% { transform: translateX(0); opacity: 1; } to { transform: translateX(0) scale(1.25); opacity: 0.9; } }
@keyframes tfx-voile-double { 0% { transform: translate(0, 0); opacity: 0; } 25% { opacity: 0.95; } 100% { transform: translate(-12px, 9px); opacity: 0.75; } }
@keyframes tfx-voile-eteint { 0% { opacity: 0; } 20% { opacity: 0.8; } 28% { opacity: 0.2; } 40% { opacity: 0.85; } 100% { opacity: 0.88; } }
@keyframes tfx-voile-file { from { transform: translateX(-100%); opacity: 0.8; } to { transform: translateX(100%); opacity: 0.8; } }
@keyframes tfx-voile-rembobine { from { transform: translateY(40%); opacity: 0.6; } to { transform: translateY(-40%); opacity: 0.6; } }
@keyframes tfx-voile-rouge { 0%, 100% { opacity: 0.1; } 25%, 75% { opacity: 0.5; } 50% { opacity: 0.2; } }

/* SWAMP — l'eau monte par le bas. */
[data-tfx-domaine="swamp"] .tfx-voile { background: linear-gradient(0deg, var(--tfx-encre), transparent 70%); transform-origin: 50% 100%; animation: tfx-voile-monte 560ms cubic-bezier(0.3, 0.7, 0.3, 1) both; }
/* CONSTRUCT — le plan se trace depuis le centre. */
[data-tfx-domaine="construct"] .tfx-voile {
  background:
    repeating-linear-gradient(0deg, var(--tfx-encre) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(90deg, var(--tfx-encre) 0 1px, transparent 1px 22px);
  animation: tfx-voile-ouvre 480ms cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
/* 007 — le canon doré traverse puis vise. */
[data-tfx-domaine="007"] .tfx-voile {
  left: 50%; top: 50%; right: auto; bottom: auto;
  width: 150px; height: 150px; margin: -75px 0 0 -75px;
  border-radius: 50%;
  border: 6px solid var(--tfx-encre);
  background: radial-gradient(circle, transparent 0 46%, rgba(0, 0, 0, 0.55) 47% 60%, transparent 61%);
  animation: tfx-voile-passe 520ms cubic-bezier(0.3, 0.8, 0.3, 1) both;
}
/* PHASE — le cadre se dédouble. */
[data-tfx-domaine="phase"] .tfx-voile { inset: 10px; border: 2px solid var(--tfx-encre); border-radius: 8px; box-shadow: 0 0 14px var(--tfx-encre), inset 0 0 14px var(--tfx-encre); animation: tfx-voile-double 520ms ease-out both; }
/* BLACKOUT — la lumière tombe, il reste un cercle. */
[data-tfx-domaine="blackout"] .tfx-voile { background: radial-gradient(circle at 50% 55%, transparent 0 16%, #000 42%); animation: tfx-voile-eteint 560ms steps(1, end) both; }
/* FLASH — des traînées traversent à toute vitesse. */
[data-tfx-domaine="flash"] .tfx-voile { background: repeating-linear-gradient(0deg, transparent 0 9px, var(--tfx-encre) 9px 11px, transparent 11px 26px); animation: tfx-voile-file 190ms linear 3 both; }
/* INVERSION — l'image rembobine ; le journal se lit à l'envers. */
[data-tfx-domaine="inversion"] .tfx-voile { background: repeating-linear-gradient(180deg, transparent 0 30px, var(--tfx-encre) 30px 33px, transparent 33px 70px); animation: tfx-voile-rembobine 240ms linear 2 both; }
@keyframes tfx-miroir { 0%, 30% { transform: scaleX(1); } 55%, 100% { transform: scaleX(-1); } }
.tfx-calque .tfx-execution[data-tfx-domaine="inversion"] .domain-hack-log { animation: tfx-miroir 560ms steps(1, end) both; }
/* E.N.D — le rouge bat. */
[data-tfx-domaine="end"] .tfx-voile { background: var(--tfx-encre); animation: tfx-voile-rouge 300ms steps(2, end) 2 both; }

/* Abandon et délai dépassé : la télé s'éteint, en gris. */
.tfx-calque .tfx-copie.tfx-extinction { animation: tfx-extinction-tele 360ms cubic-bezier(0.6, 0, 0.9, 0.4) both; }
.tfx-calque .tfx-copie.tfx-extinction.tfx-delai { border-color: #ff6b70 !important; box-shadow: 0 0 0 1px #ff6b70, 0 0 30px -6px #ff3040 !important; }
.tfx-calque .tfx-copie.tfx-extinction-calme, .tfx-calque .tfx-copie.tfx-execution-calme { animation: tfx-fondu 240ms ease-out both; }
@keyframes tfx-fondu { from { opacity: 1; } to { opacity: 0; } }
.tfx-calque .tfx-copie.tfx-execution-calme { border-color: var(--tfx-encre) !important; }

@media (prefers-reduced-motion: reduce) {
  #domainHackModal .domain-hack-terminal.tfx-allumage, #domainHackModal .domain-hack-terminal.tfx-refus, #domainHackModal .domain-hack-timer.danger,
  .tfx-calque .tfx-copie.tfx-execution, .tfx-calque .tfx-copie.tfx-extinction { animation-duration: 1ms !important; }
}
