/* ============================
   HCJINATOR — Fuitoscope
   Monochrome noir/blanc/gris
   (palette bobinator)
   ============================ */

/* --- Panel base --- */
.fuitoscope-panel {
  background: #0A0E14;
  color: #E8E8E8;
  font-family: 'JetBrains Mono', monospace;
  border-right: 1px solid #2A2E35;
}

/* --- Scanline overlay (subtil, gris) --- */
.fuitoscope-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(200, 204, 212, 0.02) 2px,
    rgba(200, 204, 212, 0.02) 4px
  );
  z-index: 1;
}

.fuitoscope-panel > * {
  position: relative;
  z-index: 2;
}

/* --- Header --- */
.fuitoscope-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid #2A2E35;
}

.fuitoscope-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fuitoscope-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #E8E8E8;
  margin: 0;
}

.fuitoscope-close {
  background: none;
  border: 1px solid #2A2E35;
  color: #8A8F98;
  font-size: 24px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 2px;
  line-height: 1;
  padding: 0;
}

.fuitoscope-close:hover {
  color: #E8E8E8;
  border-color: #C8CCD4;
}

.fuitoscope-subtitle {
  font-size: 11px;
  color: #4A4F58;
  letter-spacing: 1px;
  margin-top: 4px;
  text-transform: uppercase;
}

/* --- Body --- */
.fuitoscope-body {
  padding: 20px;
}

.fuitoscope-intro {
  font-size: 13px;
  color: #8A8F98;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* --- Input row --- */
.fuitoscope-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  background: #111318;
  border: 1px solid #2A2E35;
  border-radius: 2px;
  padding: 4px 8px;
}

.fuitoscope-prompt {
  color: #C8CCD4;
  font-size: 16px;
  font-weight: bold;
  flex-shrink: 0;
}

.fuitoscope-select {
  flex: 1;
  background: transparent;
  border: none;
  color: #E8E8E8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 8px 28px 8px 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23C8CCD4' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.fuitoscope-select:focus {
  outline: 1px solid rgba(200, 204, 212, 0.35);
  outline-offset: 2px;
}

/* Le drop-down natif garde les couleurs systeme sur certains navigateurs —
   on force le theme sombre sur chaque option. */
.fuitoscope-select option {
  background: #111318;
  color: #E8E8E8;
  font-family: 'JetBrains Mono', monospace;
}

.fuitoscope-select option[disabled] {
  color: #4A4F58;
}

/* --- Results --- */
.fuitoscope-result {
  min-height: 40px;
}

.fuitoscope-result .result-section {
  margin-bottom: 16px;
}

.fuitoscope-result .result-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #E8E8E8;
  margin-bottom: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.fuitoscope-result .result-alert {
  font-size: 13px;
  color: #C45C5C;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-left: 2px solid #C45C5C;
  background: rgba(196, 92, 92, 0.05);
}

.fuitoscope-result .result-line {
  font-size: 12px;
  color: #8A8F98;
  padding: 3px 0;
  line-height: 1.5;
}

.fuitoscope-result .result-line .label {
  color: #C8CCD4;
}

.fuitoscope-result .result-line .value {
  color: #E8E8E8;
}

.fuitoscope-result .result-positive {
  color: #7AC47A;
  font-size: 13px;
  padding: 8px 12px;
  border-left: 2px solid #7AC47A;
  background: rgba(122, 196, 122, 0.05);
  margin-bottom: 12px;
}

.fuitoscope-result .result-error {
  color: #C45C5C;
  font-size: 13px;
  padding: 10px;
  text-align: center;
}

.fuitoscope-result .result-empty {
  color: #4A4F58;
  font-size: 12px;
  padding: 10px;
  text-align: center;
}

/* ============================
   PASSWORD GLITCH — EXTREME
   ============================ */

.fuitoscope-result .result-password-section {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #2A2E35;
  background: #111318;
  border-radius: 2px;
}

.fuitoscope-result .result-password-label {
  font-size: 12px;
  color: #C45C5C;
  margin-bottom: 10px;
  font-weight: 600;
}

/* --- Wrapper: contient tout le chaos --- */
.glitch-password-wrapper {
  position: relative;
  overflow: hidden;
  background: #0A0E14;
  border: 1px solid #2A2E35;
  padding: 16px;
}

/* Scanline traversante */
.glitch-password-wrapper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(200, 204, 212, 0.2);
  animation: pw-scanline 1.8s linear infinite;
  z-index: 10;
  pointer-events: none;
}

@keyframes pw-scanline {
  0% { top: -2px; }
  100% { top: 100%; }
}

/* Bruit de grain anime */
.glitch-password-wrapper::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  mix-blend-mode: overlay;
  animation: pw-noise 0.1s steps(4) infinite;
  z-index: 5;
}

@keyframes pw-noise {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-8px, -4px); }
  50% { transform: translate(5px, 7px); }
  75% { transform: translate(-3px, 2px); }
  100% { transform: translate(0, 0); }
}

/* --- Container des caracteres --- */
.glitch-password {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  position: relative;
  z-index: 6;
  min-height: 40px;
  line-height: 1.4;
}

/* Copie fantome aberration chromatique — pseudo-element sur le container */
.glitch-password::before {
  content: attr(data-password);
  position: absolute;
  top: 0;
  left: 2px;
  color: rgba(200, 204, 212, 0.15);
  pointer-events: none;
  animation: aberration-left 3s steps(2) infinite;
  z-index: -1;
}

.glitch-password::after {
  content: attr(data-password);
  position: absolute;
  top: 0;
  left: -2px;
  color: rgba(138, 143, 152, 0.12);
  pointer-events: none;
  animation: aberration-right 2.5s steps(3) infinite;
  clip-path: inset(20% 0 30% 0);
  z-index: -1;
}

@keyframes aberration-left {
  0% { transform: translate(2px, 0); clip-path: inset(0 0 60% 0); }
  25% { transform: translate(-1px, 1px); clip-path: inset(30% 0 20% 0); }
  50% { transform: translate(3px, -1px); clip-path: inset(50% 0 10% 0); }
  75% { transform: translate(-2px, 0); clip-path: inset(10% 0 50% 0); }
  100% { transform: translate(2px, 0); clip-path: inset(0 0 60% 0); }
}

@keyframes aberration-right {
  0% { transform: translate(-2px, 1px); clip-path: inset(40% 0 20% 0); }
  33% { transform: translate(1px, -1px); clip-path: inset(10% 0 60% 0); }
  66% { transform: translate(-3px, 0); clip-path: inset(60% 0 5% 0); }
  100% { transform: translate(-2px, 1px); clip-path: inset(40% 0 20% 0); }
}

/* --- Chaque caractere individuel --- */
.glitch-char {
  display: inline-block;
  color: #E8E8E8;
  position: relative;
  transition: none;
  min-width: 0.55em;
  text-align: center;
}

/* Ombre fantome decalee par caractere */
.glitch-char::before {
  content: attr(data-char);
  position: absolute;
  top: -1px;
  left: 1px;
  color: rgba(200, 204, 212, 0.2);
  pointer-events: none;
}

.glitch-char::after {
  content: attr(data-char);
  position: absolute;
  top: 1px;
  left: -1px;
  color: rgba(138, 143, 152, 0.15);
  pointer-events: none;
}

/* --- EFFETS INDIVIDUELS (appliques par JS) --- */

.glitch-char--blink {
  animation: char-blink 0.1s steps(1) 1;
}
@keyframes char-blink {
  0%, 60% { opacity: 0; }
  100% { opacity: 1; }
}

.glitch-char--shift-up {
  animation: char-shift-up 0.15s ease 1;
}
@keyframes char-shift-up {
  0% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.glitch-char--shift-down {
  animation: char-shift-down 0.15s ease 1;
}
@keyframes char-shift-down {
  0% { transform: translateY(0); }
  40% { transform: translateY(6px); }
  100% { transform: translateY(0); }
}

.glitch-char--jitter {
  animation: char-jitter 0.12s steps(3) 1;
}
@keyframes char-jitter {
  0% { transform: translate(0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -1px); }
  100% { transform: translate(0); }
}

.glitch-char--cursed {
  font-family: 'Times New Roman', 'Georgia', serif;
  font-style: italic;
  font-weight: 400;
}

.glitch-char--flash {
  animation: char-flash 0.06s steps(1) 1;
}
@keyframes char-flash {
  0% { color: #ffffff; text-shadow: 0 0 8px rgba(255,255,255,0.9); }
  100% { color: #E8E8E8; text-shadow: none; }
}

.glitch-char--big-shift {
  animation: char-big-shift 0.2s ease 1;
}
@keyframes char-big-shift {
  0% { transform: translateY(0); }
  25% { transform: translateY(-12px); }
  75% { transform: translateY(8px); }
  100% { transform: translateY(0); }
}

.glitch-char--rotate {
  animation: char-rotate 0.18s ease 1;
}
@keyframes char-rotate {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(25deg); }
  70% { transform: rotate(-15deg); }
  100% { transform: rotate(0deg); }
}

.glitch-char--stretch {
  animation: char-stretch 0.15s ease 1;
}
@keyframes char-stretch {
  0% { transform: scaleX(1); }
  40% { transform: scaleX(2.2); }
  100% { transform: scaleX(1); }
}

.glitch-char--invert {
  animation: char-invert 0.12s steps(1) 1;
}
@keyframes char-invert {
  0% { color: #0A0E14; background: #E8E8E8; padding: 0 1px; }
  100% { color: #E8E8E8; background: transparent; padding: 0; }
}

.glitch-char--chaos {
  color: #4A4F58;
  font-size: 14px;
}

.glitch-char--split-h {
  animation: char-split-h 0.2s ease 1;
}
@keyframes char-split-h {
  0% { clip-path: inset(0); transform: translate(0); }
  30% { clip-path: inset(0 0 50% 0); transform: translate(3px, -2px); }
  60% { clip-path: inset(50% 0 0 0); transform: translate(-3px, 2px); }
  100% { clip-path: inset(0); transform: translate(0); }
}

.glitch-char--skew {
  animation: char-skew 0.15s ease 1;
}
@keyframes char-skew {
  0% { transform: skewX(0deg); }
  40% { transform: skewX(25deg); }
  100% { transform: skewX(0deg); }
}

.glitch-char--squash {
  animation: char-squash 0.15s ease 1;
}
@keyframes char-squash {
  0% { transform: scaleY(1); }
  40% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* Symbole remplace — estompe */
.glitch-char--symbol {
  color: #4A4F58;
}

/* --- Barres de redaction (generees par JS) --- */
.glitch-redact {
  position: absolute;
  background: rgba(232, 232, 232, 0.08);
  z-index: 8;
  pointer-events: none;
  animation: redact-flicker 0.4s steps(1) 1 forwards;
}

@keyframes redact-flicker {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Lignes de perturbation horizontales --- */
.glitch-tearline {
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(200, 204, 212, 0.1);
  z-index: 9;
  pointer-events: none;
  animation: tearline-flicker 0.25s steps(1) 1 forwards;
}

@keyframes tearline-flicker {
  0% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Canvas noise overlay --- */
.glitch-noise-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 7;
  mix-blend-mode: screen;
  opacity: 0.12;
}

/* --- Stats --- */
.fuitoscope-stats {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #2A2E35;
}

.fuitoscope-stat {
  flex: 1;
  text-align: center;
}

.fuitoscope-stat-label {
  display: block;
  font-size: 10px;
  color: #4A4F58;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.fuitoscope-stat-value {
  display: block;
  font-size: 20px;
  font-weight: 600;
  color: #E8E8E8;
}

/* --- Footer scanline --- */
.fuitoscope-footer {
  padding: 0;
  position: relative;
  height: 2px;
}

.fuitoscope-scanline {
  display: block;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #C8CCD4, transparent);
  opacity: 0.2;
  animation: scanline-move 4s linear infinite;
}

@keyframes scanline-move {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* --- Static fallback pour prefers-reduced-motion --- */
.glitch-password-wrapper--static {
  padding: 16px;
}

.glitch-password--static {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: #E8E8E8;
  text-align: center;
  letter-spacing: 1px;
}

/* ============================
   ACCESSIBILITE — prefers-reduced-motion
   Coupe toutes les animations couteuses
   ============================ */
@media (prefers-reduced-motion: reduce) {
  .fuitoscope-panel::before,
  .glitch-password-wrapper::before,
  .glitch-password-wrapper::after,
  .glitch-password::before,
  .glitch-password::after,
  .fuitoscope-scanline,
  .glitch-noise-canvas,
  .glitch-redact,
  .glitch-tearline {
    animation: none !important;
    display: none !important;
  }

  .glitch-char,
  .glitch-char::before,
  .glitch-char::after {
    animation: none !important;
    transform: none !important;
    transition: none !important;
  }

  .fuitoscope-panel {
    transition: none !important;
  }
}
