/* ===========================================
 *  Transmission Overlay (TX) — Optimized
 *  - No backdrop-filter (expensive)
 *  - Soft shadows, fewer layers
 *  - Transform-only animations
 *  - Reduced-motion safe
 *  - Optional eco mode: .tx--eco
 * =========================================== */

:root {
  --tx-bg: rgba(5, 6, 8, 0.86);
  --tx-pane: #0c0f12;
  --tx-neon: #00e5ff;
  --tx-accent: #8cff2e;
  --tx-mag: #ff2e9e;
  --tx-ring: rgba(0,229,255,.14);

  /* Intensity knobs (can be lowered on mobile) */
  --tx-scanline-opacity: .22;
  --tx-vignette-opacity: .75;
  --tx-noise-opacity: .26;
  --tx-shadow-outer: 0 14px 48px rgba(0,0,0,.55);
  --tx-shadow-inner: 0 0 0 1px var(--tx-ring) inset, 0 0 40px rgba(0,229,255,.05) inset;

  /* Layout */
  --tx-width: min(920px, 92vw);
  --tx-maxh: min(80vh, 780px);

  /* Typing */
  --tx-font: 14px/1.55 'Roboto Mono', ui-monospace, monospace;
  --tx-hint-font: 12px/1.3 'Roboto Mono', ui-monospace, monospace;

  /* Z index below gate/disclaimer if they sit higher */
  --tx-z: 99950;
}

/* ---------- Eco mode (lower power/heat) ---------- */
.tx--eco {
  --tx-scanline-opacity: .12;
  --tx-vignette-opacity: .6;
  --tx-noise-opacity: .18;
  --tx-shadow-outer: 0 10px 28px rgba(0,0,0,.45);
  --tx-shadow-inner: 0 0 0 1px rgba(0,229,255,.10) inset;
}

/* ---------- Overlay shell ---------- */
.tx-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--tx-z);
  display: grid;
  place-items: center;
  background: var(--tx-bg); /* Keep your dark tint */
  backdrop-filter: blur(12px); /* This blurs content BEHIND */
  -webkit-backdrop-filter: blur(12px); /* Safari */
  animation: txFadeIn 140ms ease-out;
  will-change: opacity, backdrop-filter;
}
@keyframes txFadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ---------- Panel ---------- */
.tx-pane {
  position: relative;
  width: var(--tx-width);
  max-height: var(--tx-maxh);
  border-radius: 14px;
  background:
    radial-gradient(140% 120% at 50% 0%, rgba(0,229,255,.05), rgba(0,0,0,.7)),
    var(--tx-pane);
  box-shadow: var(--tx-shadow-inner), var(--tx-shadow-outer);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  will-change: transform, clip-path, filter;
}

/* Scanlines + vignette (cheap) */
.tx-pane::before,
.tx-pane::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
}
.tx-pane::before {
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.02) 0 2px,
    rgba(255,255,255,0) 2px 4px
  );
  opacity: var(--tx-scanline-opacity);
  animation: txNoise 0.7s steps(2) infinite;
}
.tx-pane::after {
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 58%, rgba(0,0,0,.36) 100%);
  opacity: var(--tx-vignette-opacity);
}
@keyframes txNoise { 50% { transform: translateY(1px); } }

/* ---------- Header ---------- */
.tx-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,229,255,.10);
}
.tx-title {
  font: 600 14px/1 'Roboto Mono', ui-monospace, monospace;
  letter-spacing: .08em;
  color: var(--tx-neon);
  text-shadow:
    1px 0 rgba(255, 60, 60, .35),
   -1px 0 rgba( 60,160,255, .35);
}
.tx-actions { display: flex; gap: 8px; }
.tx-btn,
.tx-close {
  all: unset; cursor: pointer;
  min-width: 28px; height: 28px;
  padding: 6px 10px;
  border-radius: 8px;
  display: grid; place-items: center;
  font: 500 12px/1 'Roboto Mono', ui-monospace, monospace;
  color: #bff7ff; background: rgba(0,229,255,.06);
  box-shadow: 0 0 0 1px rgba(0,229,255,.10) inset;
}
.tx-btn:hover, .tx-close:hover { background: rgba(0,229,255,.12); }
.tx-btn:focus-visible, .tx-close:focus-visible { outline: 2px solid var(--tx-neon); outline-offset: 2px; }

/* ---------- Body ---------- */
.tx-body {
  position: relative;
  padding: 14px 16px;
  overflow: auto;
}
.tx-type {
  white-space: pre-wrap;
  font: var(--tx-font);
  color: var(--tx-neon);
  text-shadow: 0 0 8px rgba(0,229,255,.12);
  filter: contrast(1.05) brightness(1.02);
}
.tx-type .caret {
  display: inline-block; width: .6ch; height: 1.1em;
  transform: translateY(2px);
  background: linear-gradient(to bottom, #bfe, #7ad);
  margin-left: 2px;
  animation: tx-caret .9s steps(2) infinite;
}
@keyframes tx-caret { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

/* ---------- Footer ---------- */
.tx-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px;
  border-top: 1px solid rgba(0,229,255,.10);
  color: #95f0ff; font: var(--tx-hint-font);
  opacity: .95;
}
.tx-hint { letter-spacing: .04em; }
.tx-key { color: var(--tx-accent); }
.tx-mag { color: var(--tx-mag); }

/* ---------- Global overlay CRT layer ---------- */
.tx-overlay::before,
.tx-overlay::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none;
  mix-blend-mode: screen;
}
.tx-overlay::before {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03) 0 1px,
    rgba(0,0,0,0) 2px 3px
  );
  opacity: .42;                /* slightly lower */
  animation: tx-scan 6s linear infinite;
}
.tx-overlay::after {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.05) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,.04) 0 2px, transparent 3px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,.03) 0 2px, transparent 3px);
  opacity: var(--tx-noise-opacity);
  animation: tx-flicker 2.2s steps(2) infinite;
}
@keyframes tx-scan {
  0% { background-position-y: 0px; }
  100% { background-position-y: 4px; }
}
@keyframes tx-flicker { 0%,100% { opacity: .22; } 50% { opacity: .36; } }

/* ---------- Entrance FX (burst + wipe) ---------- */
.tx-pane.glitch-burst {
  animation: tx-burst 200ms ease-out, tx-wipe 560ms cubic-bezier(.2,.7,0,1) 120ms both;
}
@keyframes tx-burst {
  0% { transform: scale(0.985) translateY(3px); filter: brightness(1.35) saturate(1.2); }
  100% { transform: scale(1) translateY(0);     filter: brightness(1)    saturate(1); }
}
@keyframes tx-wipe {
  0%   { clip-path: inset(52% 0 48% 0); }
  100% { clip-path: inset(0 0 0 0); }
}

/* ---------- Auth form ---------- */
.tx-form { display: grid; gap: 12px; }
.tx-label { display: grid; gap: 6px; font-size: 12px; letter-spacing: .04em; color: #9bd; }
.tx-input {
  background: #0b0f14; border: 1px solid #2a3a4a; color: #cfe;
  padding: 10px 12px; border-radius: 8px; font-family: "Roboto Mono", monospace;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.tx-input:focus {
  outline: none; border-color: #59a; box-shadow: 0 0 0 2px rgba(80,150,190,.25);
  animation: tx-focus-flicker 1.2s steps(3) infinite;
}
.tx-actions-row { display: flex; justify-content: flex-end; gap: 8px; }
.tx-error { color: #f88; font-size: 12px; }
.tx-pane.shake { animation: tx-shake .18s linear 0s 1; }

@keyframes tx-focus-flicker {
  0%,100% { box-shadow: 0 0 0 2px rgba(80,150,190,.2); }
  50%      { box-shadow: 0 0 0 3px rgba(80,150,190,.35); }
}
@keyframes tx-shake { 
  0%,100%{ transform: translateX(0) } 
  25%{ transform: translateX(-6px)} 
  75%{ transform: translateX(6px)} 
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .tx-pane::before,
  .tx-overlay::before,
  .tx-overlay::after,
  .tx-pane.glitch-burst {
    animation: none !important;
  }
}
