/* ===== RedKatana: Visual Effects ===== */

/* Ambient canvases */
#matrix-canvas,
#hex-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Light theme: keep ambient layers very subtle or off */
#matrix-canvas { opacity: 0.04; }
#hex-canvas { opacity: 0.06; z-index: 1; }

body.matrix-off #matrix-canvas { opacity: 0; }
body.crt-off .scanlines,
body.crt-off .noise { opacity: 0; }

/* CRT scanlines - disabled for light readability */
.scanlines {
  display: none !important;
}

/* Soft edge wash - fully driven by active team theme accents */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(var(--accent-rgb), 0.12), transparent 48%),
    radial-gradient(ellipse at 80% 100%, var(--mesh-b), transparent 52%),
    radial-gradient(ellipse at center, transparent 52%, rgba(15, 23, 42, 0.05) 100%);
  transition: background 0.45s ease, opacity 0.4s ease;
}

body.theme-dark .vignette,
body.theme-black-team .vignette {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(var(--accent-rgb), 0.14), transparent 45%),
    radial-gradient(ellipse at 80% 100%, rgba(56, 189, 248, 0.1), transparent 50%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
}

body.theme-white-team .vignette {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(148, 163, 184, 0.12), transparent 45%),
    radial-gradient(ellipse at 80% 100%, rgba(226, 232, 240, 0.4), transparent 50%),
    radial-gradient(ellipse at center, transparent 55%, rgba(148, 163, 184, 0.1) 100%);
}

body.theme-red-team .vignette {
  background:
    radial-gradient(ellipse at 18% 0%, rgba(225, 29, 72, 0.14), transparent 48%),
    radial-gradient(ellipse at 85% 100%, rgba(249, 115, 22, 0.1), transparent 52%),
    radial-gradient(ellipse at center, transparent 55%, rgba(76, 29, 39, 0.05) 100%);
}

body.theme-blue-team .vignette {
  background:
    radial-gradient(ellipse at 18% 0%, rgba(2, 132, 199, 0.14), transparent 48%),
    radial-gradient(ellipse at 85% 100%, rgba(6, 182, 212, 0.1), transparent 52%),
    radial-gradient(ellipse at center, transparent 55%, rgba(15, 23, 42, 0.05) 100%);
}

body.theme-purple-team .vignette {
  background:
    radial-gradient(ellipse at 18% 0%, rgba(124, 58, 237, 0.14), transparent 48%),
    radial-gradient(ellipse at 85% 100%, rgba(219, 39, 119, 0.1), transparent 52%),
    radial-gradient(ellipse at center, transparent 55%, rgba(26, 11, 51, 0.05) 100%);
}

body.theme-yellow-team .vignette {
  background:
    radial-gradient(ellipse at 18% 0%, rgba(217, 119, 6, 0.14), transparent 48%),
    radial-gradient(ellipse at 85% 100%, rgba(202, 138, 4, 0.1), transparent 52%),
    radial-gradient(ellipse at center, transparent 55%, rgba(74, 52, 20, 0.04) 100%);
}

body.theme-orange-team .vignette {
  background:
    radial-gradient(ellipse at 18% 0%, rgba(234, 88, 12, 0.14), transparent 48%),
    radial-gradient(ellipse at 85% 100%, rgba(245, 158, 11, 0.1), transparent 52%),
    radial-gradient(ellipse at center, transparent 55%, rgba(74, 40, 20, 0.04) 100%);
}

/* Film noise off for light UI */
.noise {
  display: none !important;
}

/* Optional: subtle noise drift only during boot */
body:not(.bg-frozen) .noise {
  inset: -50%;
  width: 200%;
  height: 200%;
  animation: noiseShift 0.4s steps(4) infinite;
}

@keyframes noiseShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -1%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(0, 0); }
}

/* Static background stays quiet for readability */
body.bg-frozen #matrix-canvas {
  opacity: 0.03;
}
body.bg-frozen #hex-canvas {
  opacity: 0.05;
}

/* Hide legacy effect chrome when not present */
.scanlines,
.noise,
#cursor-glow,
#cursor-dot,
.boot-screen,
.terminal {
  display: none !important;
}

/* Custom cursor */
#cursor-glow {
  position: fixed;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.15s, height 0.15s, opacity 0.15s;
  mix-blend-mode: screen;
  opacity: 0.85;
}

#cursor-dot {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
}

body.cursor-hover #cursor-glow {
  width: 48px;
  height: 48px;
  opacity: 1;
}

/* Glitch text */
.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  opacity: 0.8;
}

.glitch::before {
  color: var(--accent-2);
  z-index: -1;
  animation: glitchA 3.5s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}

.glitch::after {
  color: var(--danger);
  z-index: -2;
  animation: glitchB 2.8s infinite linear alternate-reverse;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

@keyframes glitchA {
  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); }
}

@keyframes glitchB {
  0% { transform: translate(0); }
  20% { transform: translate(2px, 0); }
  40% { transform: translate(-2px, 1px); }
  60% { transform: translate(1px, -1px); }
  80% { transform: translate(-1px, 0); }
  100% { transform: translate(0); }
}

/* Boot screen */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: #020405;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s var(--ease), visibility 0.6s;
}

.boot-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  width: min(560px, 92vw);
  font-family: var(--font-mono);
}

.boot-ascii {
  color: var(--accent);
  font-size: clamp(0.45rem, 1.4vw, 0.7rem);
  line-height: 1.15;
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.45);
  margin-bottom: 1.5rem;
  white-space: pre;
  overflow: hidden;
}

.boot-log {
  min-height: 8rem;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.boot-log .ok { color: var(--accent); }
.boot-log .warn { color: var(--warn); }
.boot-log .info { color: var(--accent-2); }

.boot-bar {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent);
  transition: width 0.15s linear;
}

.boot-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  opacity: 0.7;
}

/* Floating terminal */
.terminal {
  position: fixed;
  bottom: 2.5rem;
  right: 1.5rem;
  width: min(520px, calc(100vw - 2rem));
  height: min(340px, 50vh);
  z-index: 800;
  display: flex;
  flex-direction: column;
  background: rgba(4, 10, 12, 0.94);
  border: 1px solid var(--border-hot);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.5),
    0 20px 60px rgba(0,0,0,0.6),
    0 0 40px rgba(0, 255, 136, 0.08);
  backdrop-filter: blur(16px);
  overflow: hidden;
  animation: termIn 0.3s var(--ease);
}

.terminal.hidden { display: none; }

@keyframes termIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.term-titlebar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}

.term-titlebar:active { cursor: grabbing; }

.term-dots {
  display: flex;
  gap: 0.35rem;
}

.term-dots i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #333;
}

.term-dots i:nth-child(1) { background: #ff5f56; }
.term-dots i:nth-child(2) { background: #ffbd2e; }
.term-dots i:nth-child(3) { background: #27c93f; }

.term-title {
  flex: 1;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.term-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: none;
  padding: 0 0.25rem;
}
.term-close:hover { color: var(--danger); }

.term-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.term-body::-webkit-scrollbar { width: 4px; }
.term-body::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 2px;
}

.term-line { word-break: break-word; white-space: pre-wrap; }
.term-line.cmd { color: var(--text-bright); }
.term-line.out { color: var(--text); }
.term-line.err { color: var(--danger); }
.term-line.sys { color: var(--accent-2); }

.term-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
}

.term-prompt {
  color: var(--accent);
  font-size: 0.78rem;
  white-space: nowrap;
}

#term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-size: 0.82rem;
  caret-color: var(--accent);
  min-width: 0;
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

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

@keyframes scanY {
  0% { top: -5%; }
  100% { top: 105%; }
}

/* Card reveal */
.post-card,
.lab-card,
.tool-card,
.featured-card {
  animation: cardIn 0.5s var(--ease) both;
}

.post-card:nth-child(1), .lab-card:nth-child(1), .tool-card:nth-child(1) { animation-delay: 0.02s; }
.post-card:nth-child(2), .lab-card:nth-child(2), .tool-card:nth-child(2) { animation-delay: 0.06s; }
.post-card:nth-child(3), .lab-card:nth-child(3), .tool-card:nth-child(3) { animation-delay: 0.1s; }
.post-card:nth-child(4), .lab-card:nth-child(4), .tool-card:nth-child(4) { animation-delay: 0.14s; }
.post-card:nth-child(5), .lab-card:nth-child(5), .tool-card:nth-child(5) { animation-delay: 0.18s; }
.post-card:nth-child(6), .lab-card:nth-child(6), .tool-card:nth-child(6) { animation-delay: 0.22s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Hex corner decorations on panels */
.panel {
  position: relative;
}

.panel::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  opacity: 0.4;
  pointer-events: none;
}

.panel::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border-bottom: 1px solid var(--accent);
  border-left: 1px solid var(--accent);
  opacity: 0.4;
  pointer-events: none;
  z-index: 1;
}

/* Severity pulse on critical cards */
.post-card[data-sev="critical"] .pc-sev {
  animation: pulse 2s ease-in-out infinite;
}

/* Focus rings for a11y */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
