/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Cursor Blink (hidden — using native caret instead) ── */
.cursor {
  display: none;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── CRT Scanline Overlay ── */
#crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
}

#crt-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* ── Glitch Effect ── */
@keyframes glitch {
  0%   { transform: translate(0); }
  20%  { transform: translate(-2px, 1px); }
  40%  { transform: translate(2px, -1px); }
  60%  { transform: translate(-1px, -2px); }
  80%  { transform: translate(1px, 2px); }
  100% { transform: translate(0); }
}

.glitch {
  animation: glitch 0.3s ease-in-out;
}

/* ── Flicker for Alert Lines ── */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  33% { opacity: 0.8; }
  66% { opacity: 0.95; }
}

.flicker {
  animation: flicker 0.15s ease-in-out 3;
}

/* ── Typing Cursor during typeout ── */
.typing-cursor::after {
  content: '\2588'; /* full block character */
  color: #33ff33;
  animation: cursor-blink 0.6s step-end infinite;
}

/* ── Fade In ── */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fade-in 0.5s ease-in;
}

/* ── Screen Flash (for alerts) ── */
@keyframes screen-flash {
  0%   { background-color: rgba(255, 0, 0, 0.1); }
  50%  { background-color: rgba(255, 0, 0, 0.05); }
  100% { background-color: transparent; }
}

.screen-flash {
  animation: screen-flash 0.5s ease-out;
}

/* ── Boot Sequence Glow ── */
@keyframes text-glow {
  0%   { text-shadow: 0 0 4px currentColor; }
  50%  { text-shadow: 0 0 12px currentColor, 0 0 24px currentColor; }
  100% { text-shadow: 0 0 4px currentColor; }
}

.glow {
  animation: text-glow 2s ease-in-out infinite;
}

/* ── Attack Screen Shake ── */
@keyframes screen-shake {
  0%   { transform: translate(0); }
  10%  { transform: translate(-4px, 2px); }
  20%  { transform: translate(4px, -2px); }
  30%  { transform: translate(-3px, -3px); }
  40%  { transform: translate(3px, 3px); }
  50%  { transform: translate(-2px, 1px); }
  60%  { transform: translate(2px, -1px); }
  70%  { transform: translate(-1px, 2px); }
  80%  { transform: translate(1px, -1px); }
  100% { transform: translate(0); }
}

.attack-shake {
  animation: screen-shake 0.5s ease-in-out;
}

/* ── Attack Red Flash Overlay ── */
#attack-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 45;
  background: transparent;
}

#attack-overlay.attack-active {
  animation: attack-red-flash 0.8s ease-out;
}

@keyframes attack-red-flash {
  0%   { background: rgba(255, 0, 0, 0.3); }
  15%  { background: rgba(255, 0, 0, 0.05); }
  30%  { background: rgba(255, 0, 0, 0.2); }
  50%  { background: rgba(255, 0, 0, 0.05); }
  70%  { background: rgba(255, 0, 0, 0.1); }
  100% { background: transparent; }
}

/* ── HUD Overlay ── */
#hud-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 1s ease-in;
}

#hud-overlay.hud-visible {
  opacity: 1;
}

#hud-top, #hud-bottom {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 16px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: rgba(0, 204, 255, 0.85);
  letter-spacing: 0.5px;
}

#hud-top {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 15, 30, 0.75), transparent);
  border-bottom: 1px solid rgba(0, 204, 255, 0.1);
}

#hud-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 15, 30, 0.75), transparent);
  border-top: 1px solid rgba(0, 204, 255, 0.1);
}

.hud-item {
  white-space: nowrap;
}

.hud-good { color: #44ff44; }
.hud-warn { color: #ffaa00; }
.hud-critical { color: #ff4444; }

.hud-pulse {
  animation: hud-blink 1s ease-in-out infinite;
}

@keyframes hud-blink {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── HUD Danger Mode (continuous red border pulse) ── */
#hud-overlay.hud-danger-mode {
  animation: danger-glow 2s ease-in-out infinite;
}

@keyframes danger-glow {
  0%, 100% { box-shadow: inset 0 0 30px rgba(255, 0, 0, 0.08); }
  50%      { box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.2); }
}

/* ── HUD corner brackets ── */
#hud-overlay::before,
#hud-overlay::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: rgba(0, 204, 255, 0.2);
  border-style: solid;
}

#hud-overlay::before {
  top: 28px; left: 10px;
  border-width: 1px 0 0 1px;
}

#hud-overlay::after {
  bottom: 28px; right: 10px;
  border-width: 0 1px 1px 0;
}

/* ── Certificate Overlay ── */
#certificate-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in;
}

#certificate-overlay.certificate-visible {
  opacity: 1;
  pointer-events: auto;
}

#certificate-card {
  font-family: 'Courier New', 'Consolas', 'Liberation Mono', monospace;
  color: #00ccff;
  background: #0a0a0a;
  border: 2px solid #00ccff;
  box-shadow: 0 0 30px rgba(0, 204, 255, 0.15), inset 0 0 30px rgba(0, 204, 255, 0.05);
  padding: 32px 40px;
  max-width: 520px;
  width: 90%;
  text-align: center;
}

.cert-header { margin-bottom: 16px; }

.cert-title {
  font-size: 16px;
  font-weight: bold;
  color: #44ff44;
  letter-spacing: 2px;
}

.cert-subtitle {
  font-size: 12px;
  color: #00ccff;
  letter-spacing: 1px;
  margin-top: 4px;
}

.cert-divider {
  color: #00ccff;
  opacity: 0.5;
  font-size: 11px;
  margin: 8px 0;
  overflow: hidden;
}

.cert-body {
  text-align: left;
  padding: 12px 0;
}

.cert-field {
  margin: 6px 0;
  font-size: 14px;
}

.cert-label {
  color: #888;
  margin-right: 8px;
}

.cert-value {
  color: #00ccff;
  font-weight: bold;
}

.cert-clear { color: #44ff44; }
.cert-spacer { height: 12px; }

.cert-assessment {
  border: 1px solid rgba(0, 204, 255, 0.2);
  padding: 12px;
  margin: 8px 0;
}

.cert-assess-title {
  text-align: center;
  color: #00ccff;
  font-size: 12px;
  margin-bottom: 8px;
}

.cert-bar {
  font-size: 13px;
  margin: 4px 0;
  color: #c0c0c0;
}

.cert-bar-label { color: #888; }
.cert-bar-fill { color: #44ff44; }

.cert-rating {
  text-align: center;
  margin-top: 8px;
  font-weight: bold;
  color: #ffd700;
}

.cert-stars { color: #ffd700; }

.cert-quote { text-align: center; margin: 8px 0; }

.cert-quote-text {
  color: #ffd700;
  font-style: italic;
  font-size: 15px;
}

.cert-quote-attr {
  color: #888;
  font-size: 12px;
  margin-top: 4px;
}

.cert-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.cert-btn {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  padding: 8px 20px;
  border: 1px solid #00ccff;
  background: transparent;
  color: #00ccff;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.cert-btn:hover {
  background: rgba(0, 204, 255, 0.15);
  color: #fff;
}

.cert-btn:active {
  background: rgba(0, 204, 255, 0.3);
}

@media (max-width: 600px) {
  #certificate-card {
    padding: 20px 16px;
    max-width: 95%;
  }
  .cert-title {
    font-size: 13px;
    letter-spacing: 1px;
  }
  .cert-field { font-size: 13px; }
  .cert-bar { font-size: 12px; }
  .cert-btn {
    font-size: 12px;
    padding: 6px 14px;
  }
}
