/* ─── alert.css ────────────────────────────────────────────────────────────────
   Intercepted Transmission Alert (#tx-alert) and Access Log Panel (#tx-log).
   z-alert: 20, z-log: 15 — both above terminal (z=10) and CRT overlays.
──────────────────────────────────────────────────────────────────────────── */

/* ─── Shared blink keyframe ──────────────────────────────────────────────── */
/* Referenced by .tx-blink and .bg-cursor (intro.css) */
@keyframes tx-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Transmission Alert
   z-index 20 — above terminal (10) and all CRT overlays
═══════════════════════════════════════════════════════════════════════════ */

#tx-alert {
  position: fixed;
  top:  50%;
  left: 50%;
  transform: translate(-50%, -160%);   /* starts off-screen above center */
  z-index: 20;
  width: clamp(360px, 48vw, 660px);
  background: rgba(7, 13, 7, 0.97);
  border: 1px solid rgba(127, 170, 108, 0.50);
  box-shadow: 0 0 32px rgba(127, 170, 108, 0.20), inset 0 0 60px rgba(7, 13, 7, 0.5);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.62;
  color: var(--text-primary);
  overflow: hidden;

  /* Hidden by default — JS adds .tx-alert--visible to trigger drop-in */
  opacity: 0;
  pointer-events: none;
}

/* Corner bracket decorations */
#tx-alert::before,
#tx-alert::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--text-bright);
  border-style: solid;
  opacity: 0.65;
  pointer-events: none;
  z-index: 2;
}
#tx-alert::before { top: -1px;    left: -1px;  border-width: 2px 0 0 2px; }
#tx-alert::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

#tx-alert.tx-alert--visible {
  animation: tx-slidein 0.55s cubic-bezier(0.15, 0.6, 0.35, 1) forwards,
             tx-border-pulse 2s ease-in-out 0.6s infinite;
  pointer-events: auto;
}

#tx-alert.tx-alert--out {
  animation: tx-slideout 0.35s cubic-bezier(0.6, 0, 0.85, 0.35) forwards;
  pointer-events: none;
}

@keyframes tx-slidein {
  from { opacity: 0; transform: translate(-50%, -160%); }
  to   { opacity: 1; transform: translate(-50%, -50%);  }
}

@keyframes tx-slideout {
  from { opacity: 1; transform: translate(-50%, -50%);  }
  to   { opacity: 0; transform: translate(-50%, -160%); }
}

@keyframes tx-border-pulse {
  0%, 100% { border-color: rgba(127, 170, 108, 0.40); }
  50%      { border-color: rgba(127, 170, 108, 0.75); }
}

/* ── Scanning line (travels top → bottom on loop) ────────────────────────── */
.tx-scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(168, 200, 144, 0.35);
  pointer-events: none;
  z-index: 1;
  animation: tx-scan 3.8s linear infinite;
}

@keyframes tx-scan {
  0%   { top: 0%;   opacity: 0.35; }
  85%  { top: 100%; opacity: 0.35; }
  100% { top: 100%; opacity: 0;    }
}

/* ── Alert Header ─────────────────────────────────────────────────────────── */
.tx-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px 12px;
  background: rgba(127, 170, 108, 0.06);
  border-bottom: 1px solid rgba(127, 170, 108, 0.30);
  color: var(--text-bright);
  font-size: 13px;
  letter-spacing: 0.07em;
  user-select: none;
}

.tx-blink {
  color: #c05050;
  animation: tx-blink 0.9s step-end infinite;
  flex-shrink: 0;
}

.tx-title {
  text-align: center;
}

/* ── Alert Body ───────────────────────────────────────────────────────────── */
.tx-body {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Meta table */
.tx-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tx-meta-row {
  display: flex;
  font-size: 11.5px;
}

.tx-meta-label {
  color: var(--text-bright);
  min-width: 120px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.tx-meta-value {
  color: var(--text-dim);
}

/* ── Auth / password gate ─────────────────────────────────────────────────── */
.tx-auth {
  border-top: 1px solid rgba(127, 170, 108, 0.18);
  padding-top: 10px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tx-auth-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.tx-auth-caret { color: var(--text-dim); flex-shrink: 0; }
.tx-auth-label { color: var(--text-primary); white-space: nowrap; }

.tx-auth-input {
  background: none;
  border: none;
  border-bottom: 1px solid rgba(127, 170, 108, 0.35);
  color: var(--text-bright);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  width: 100%;
  caret-color: var(--text-bright);
  letter-spacing: 0.08em;
}

.tx-auth-error {
  color: #e05555;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  display: none;
  padding-left: 2px;
}

.tx-auth-error--visible { display: block; }

/* Static status label */
.tx-received {
  display: block;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 10px 0 6px;
  margin-top: 4px;
  border-top: 1px solid rgba(127, 170, 108, 0.18);
  user-select: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Access Log Panel
   z-index 15 — above terminal, below alert
═══════════════════════════════════════════════════════════════════════════ */

#tx-log {
  position: fixed;
  bottom: clamp(16px, 4vh, 48px);
  right:  clamp(16px, 4vw, 56px);
  z-index: 15;
  min-width: 280px;
  max-width: clamp(280px, 32vw, 420px);
  max-height: 180px;
  overflow-y: auto;
  background: rgba(7, 13, 7, 0.94);
  border: 1px solid rgba(127, 170, 108, 0.28);
  font-family: var(--font);
  font-size: 11.5px;
  line-height: 1.62;
  color: var(--text-primary);

  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#tx-log.tx-log--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tx-log-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(127, 170, 108, 0.18);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.07em;
  user-select: none;
}

.tx-log-header-title { flex: 1; }

.tx-log-toggle {
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  transition: color 0.08s ease;
  user-select: none;
  flex-shrink: 0;
}
.tx-log-toggle:hover { color: var(--text-primary); }
.tx-log-toggle:focus-visible {
  outline: 1px solid var(--text-dim);
  outline-offset: 1px;
}

.tx-log-entry {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(127, 170, 108, 0.07);
}

.tx-log-entry:last-child {
  border-bottom: none;
}

.tx-log-time {
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
}

.tx-log-label {
  color: var(--text-primary);
  flex: 1;
}

.tx-log-replay {
  color: var(--text-cmd);
  cursor: pointer;
  transition: color 0.08s ease;
  flex-shrink: 0;
  user-select: none;
}

.tx-log-replay:hover { color: var(--text-cmd-hover); }

.tx-log-replay:focus-visible {
  outline: 1px solid var(--text-dim);
  outline-offset: 1px;
}

.tx-log-stop {
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.08s ease;
  flex-shrink: 0;
  user-select: none;
}

.tx-log-stop:hover { color: var(--text-primary); }

.tx-log-stop:focus-visible {
  outline: 1px solid var(--text-dim);
  outline-offset: 1px;
}

/* ── Access Log Hub (expanded state) ─────────────────────────────────────── */

#tx-log.tx-log--expanded {
  max-width: clamp(320px, 42vw, 520px);
  max-height: clamp(280px, 40vh, 420px);
  border-color: rgba(127, 170, 108, 0.5);
  box-shadow: 0 0 20px rgba(127, 170, 108, 0.07), inset 0 0 40px rgba(7, 13, 7, 0.6);
  transition: max-width 0.2s ease, max-height 0.2s ease, border-color 0.2s ease,
              opacity 0.3s ease, transform 0.3s ease;
}

/* Corner bracket decorations */
#tx-log.tx-log--expanded::before,
#tx-log.tx-log--expanded::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: rgba(127, 170, 108, 0.6);
  border-style: solid;
  pointer-events: none;
}
#tx-log.tx-log--expanded::before {
  top: -1px; left: -1px;
  border-width: 2px 0 0 2px;
}
#tx-log.tx-log--expanded::after {
  bottom: -1px; right: -1px;
  border-width: 0 2px 2px 0;
}

/* Hub entry — block format used when expanded */
.tx-log-entry--hub {
  display: block;
  padding: 7px 10px 9px;
  border-bottom: 1px solid rgba(127, 170, 108, 0.1);
}

.tx-log-entry--hub:last-child { border-bottom: none; }

.tx-log-entry-title {
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 11.5px;
}

.tx-log-entry-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(127, 170, 108, 0.18);
}

.tx-log-hub-caret {
  color: var(--text-dim);
  flex-shrink: 0;
}

.tx-log-entry-meta {
  color: var(--text-dim);
  font-size: 10.5px;
  padding-left: 14px;
  line-height: 1.6;
}

.tx-log-entry-actions {
  display: flex;
  gap: 10px;
  padding-left: 14px;
  margin-top: 4px;
  font-size: 11px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #tx-alert {
    top:    auto;
    bottom: 0;
    left:   0;
    right:  0;
    width:  100%;
    transform: translateY(110%);   /* reset to bottom-sheet start */
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
  }

  #tx-alert::before { display: none; }
  #tx-alert::after  { display: none; }

  @keyframes tx-slidein {
    from { opacity: 0; transform: translateY(110%); }
    to   { opacity: 1; transform: translateY(0);    }
  }

  @keyframes tx-slideout {
    from { opacity: 1; transform: translateY(0);    }
    to   { opacity: 0; transform: translateY(110%); }
  }

  #tx-log {
    bottom: auto;
    top:    clamp(16px, 4vh, 40px);
    right:  0;
    left:   0;
    max-width: 100%;
    border-left: none;
    border-right: none;
  }
}

/* ── Reduced Motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #tx-alert,
  #tx-alert.tx-alert--visible,
  #tx-alert.tx-alert--out,
  #tx-log {
    animation: none !important;
    transition: opacity 0.15s ease !important;
    transform: none !important;
  }
  .tx-blink { animation: none !important; }
}
