/* ============================================
   VOID — The Collapse
   Digital Horror / System Deterioration
   Something is fundamentally wrong.
   ============================================ */

/* --- Base --- */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--black);
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--green-terminal);
  overflow: hidden;
}

/* --- Phase Color Transitions --- */
body.phase-1 {
  transition: color 3s ease;
}

body.phase-2 {
  color: var(--red-bright);
  transition: color 2s ease;
}

body.phase-3 {
  color: var(--red-bright);
}

body.phase-blackout {
  background: #000 !important;
}

body.phase-4 {
  background: #000;
  color: var(--text-primary);
}

/* --- Void Container --- */
.void-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
  transition: opacity 0.3s, filter 0.3s;
}

.void-container.corrupting {
  animation: container-jitter 0.15s infinite;
}

.void-container.collapsed {
  opacity: 0;
  pointer-events: none;
}

@keyframes container-jitter {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, -1px); }
}

/* --- Header --- */
.void-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--green-dark);
  background: var(--near-black);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  z-index: 20;
  transition: border-color 2s, background 2s;
}

.void-header__title {
  color: var(--green-terminal);
  text-shadow: 0 0 8px rgba(51, 170, 51, 0.4);
  transition: color 2s, text-shadow 2s;
}

.void-header__status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-terminal);
  box-shadow: 0 0 4px var(--green-terminal);
  animation: pulse-dot 2s ease-in-out infinite;
  transition: background 2s, box-shadow 2s;
}

.status-dot.warning {
  background: #aa8822;
  box-shadow: 0 0 4px #aa8822;
}

.status-dot.critical {
  background: var(--red-bright);
  box-shadow: 0 0 6px var(--red-bright);
  animation: pulse-dot-critical 0.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes pulse-dot-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* --- Main Content --- */
.void-main {
  flex: 1;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: filter 1s;
}

/* --- Status Grid --- */
.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--green-dark);
  border: 1px solid var(--green-dark);
  transition: border-color 2s, background 2s;
}

.status-block {
  background: var(--black);
  padding: 16px 14px;
  transition: transform 0.3s, background 1s, opacity 0.3s;
}

.status-block.displaced {
  transition: transform 0.15s;
}

.status-label {
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--green-muted);
  margin-bottom: 8px;
  transition: color 2s;
}

.status-value {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--green-terminal);
  text-shadow: 0 0 6px rgba(51, 170, 51, 0.3);
  transition: color 2s, text-shadow 2s;
  word-break: break-all;
}

.status-value--large {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-shadow: 0 0 12px rgba(51, 170, 51, 0.5);
}

/* --- Color Shift States --- */
.color-shift-warn .status-label { color: #553311; }
.color-shift-warn .status-value {
  color: #aa8822;
  text-shadow: 0 0 6px rgba(170, 136, 34, 0.3);
}
.color-shift-warn .void-header { border-color: #331a00; }
.color-shift-warn .status-grid { border-color: #331a00; background: #331a00; }
.color-shift-warn .void-header__title {
  color: #aa8822;
  text-shadow: 0 0 8px rgba(170, 136, 34, 0.4);
}

.color-shift-danger .status-label { color: var(--red-muted); }
.color-shift-danger .status-value {
  color: var(--red-bright);
  text-shadow: 0 0 6px rgba(204, 51, 51, 0.3);
}
.color-shift-danger .void-header { border-color: var(--red-dark); background: #0d0000; }
.color-shift-danger .status-grid { border-color: var(--red-dark); background: var(--red-dark); }
.color-shift-danger .void-header__title {
  color: var(--red-bright);
  text-shadow: 0 0 8px rgba(204, 51, 51, 0.4);
}
.color-shift-danger .log-header {
  color: var(--red-bright);
}
.color-shift-danger .status-dot {
  background: var(--red-bright);
  box-shadow: 0 0 6px var(--red-bright);
}

/* --- Log Section --- */
.log-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--green-dark);
  background: rgba(0, 0, 0, 0.3);
  transition: border-color 2s;
}

.log-header {
  padding: 8px 14px;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--green-terminal);
  border-bottom: 1px solid var(--green-dark);
  text-shadow: 0 0 6px rgba(51, 170, 51, 0.3);
  transition: color 2s;
}

.log-output {
  flex: 1;
  padding: 10px 14px;
  overflow-y: auto;
  max-height: 35vh;
  font-size: 0.6rem;
  line-height: 1.7;
}

.log-line {
  color: var(--text-dim);
  opacity: 0;
  animation: log-fade 0.3s ease-out forwards;
}

.log-line--system { color: var(--green-muted); }
.log-line--warn { color: #aa8822; }
.log-line--error { color: var(--red-glow); }
.log-line--critical {
  color: var(--red-bright);
  text-shadow: 0 0 4px rgba(204, 51, 51, 0.4);
}

@keyframes log-fade {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Footer --- */
.void-footer {
  padding: 8px 20px;
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  border-top: 1px solid var(--green-dark);
  background: var(--near-black);
  display: flex;
  gap: 4px;
  transition: border-color 2s;
}

.void-footer__divider {
  color: var(--green-muted);
  margin: 0 6px;
}

/* --- Error Overlay --- */
.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
}

.error-msg {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--red-bright);
  text-shadow: 0 0 4px rgba(204, 51, 51, 0.5);
  white-space: nowrap;
  opacity: 0;
  animation: error-flash 2s ease-out forwards;
  pointer-events: none;
}

.error-msg--large {
  font-size: 0.9rem;
}

@keyframes error-flash {
  0% { opacity: 0; transform: translateX(-10px); }
  10% { opacity: 1; transform: translateX(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(5px); }
}

/* --- Cross-page Fragments --- */
.page-fragment {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
  opacity: 0;
  animation: fragment-appear 3s ease-out forwards;
  pointer-events: none;
  z-index: 501;
}

.page-fragment--index {
  color: var(--text-dim);
  text-shadow: 0 0 8px rgba(85, 85, 85, 0.5);
}

.page-fragment--gate {
  color: var(--green-terminal);
  text-shadow: 0 0 8px rgba(51, 170, 51, 0.5);
}

.page-fragment--sigil {
  color: var(--red-glow);
  text-shadow: 0 0 8px rgba(170, 34, 34, 0.5);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
}

@keyframes fragment-appear {
  0% { opacity: 0; }
  15% { opacity: 0.9; }
  60% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* --- Tear Lines --- */
.tear-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 400;
}

.tear-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  pointer-events: none;
  opacity: 0;
}

.tear-line--subtle {
  background: rgba(51, 170, 51, 0.15);
  animation: tear-subtle 0.2s linear forwards;
}

.tear-line--heavy {
  height: 4px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(204, 51, 51, 0.4) 20%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(204, 51, 51, 0.4) 80%,
    transparent 100%
  );
  animation: tear-heavy 0.3s linear forwards;
  box-shadow: 0 0 8px rgba(204, 51, 51, 0.3);
}

.tear-line--massive {
  height: 8px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 30%,
    rgba(204, 51, 51, 0.8) 50%,
    rgba(255, 255, 255, 0.5) 70%,
    transparent 100%
  );
  animation: tear-massive 0.4s linear forwards;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

@keyframes tear-subtle {
  0% { opacity: 0.6; transform: translateX(-5px); }
  100% { opacity: 0; transform: translateX(5px); }
}

@keyframes tear-heavy {
  0% { opacity: 0.8; transform: scaleX(0.5) translateX(-20px); }
  50% { opacity: 1; transform: scaleX(1) translateX(0); }
  100% { opacity: 0; transform: scaleX(0.8) translateX(10px); }
}

@keyframes tear-massive {
  0% { opacity: 1; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Kernel Panic --- */
.kernel-panic {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.kernel-panic.active {
  display: flex;
}

.kernel-panic__content {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 2;
  letter-spacing: 0.1em;
  color: var(--white);
  text-shadow: 0 0 4px rgba(224, 224, 224, 0.3);
  animation: panic-flicker 0.1s steps(2) infinite;
}

@keyframes panic-flicker {
  0% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* --- Channel Splitting (RGB Shift) --- */
.rgb-shift {
  position: relative;
}

.rgb-shift::before,
.rgb-shift::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.rgb-shift::before {
  color: rgba(255, 0, 0, 0.5);
  animation: rgb-shift-r 0.3s steps(2) infinite;
  clip-path: inset(0 0 50% 0);
}

.rgb-shift::after {
  color: rgba(0, 255, 255, 0.5);
  animation: rgb-shift-b 0.25s steps(2) infinite;
  clip-path: inset(50% 0 0 0);
}

@keyframes rgb-shift-r {
  0% { transform: translate(-2px, -1px); }
  50% { transform: translate(2px, 1px); }
  100% { transform: translate(-2px, -1px); }
}

@keyframes rgb-shift-b {
  0% { transform: translate(2px, 1px); }
  50% { transform: translate(-2px, -1px); }
  100% { transform: translate(2px, 1px); }
}

/* --- Background Flicker --- */
.bg-flicker {
  animation: bg-flicker-anim 0.15s steps(2) infinite;
}

@keyframes bg-flicker-anim {
  0% { background-color: var(--black); }
  25% { background-color: #0a0000; }
  50% { background-color: #000a00; }
  75% { background-color: #000; }
  100% { background-color: var(--black); }
}

.bg-flicker-intense {
  animation: bg-flicker-intense-anim 0.08s steps(3) infinite;
}

@keyframes bg-flicker-intense-anim {
  0% { background-color: #0d0000; }
  16% { background-color: #1a0000; }
  33% { background-color: #000; }
  50% { background-color: #110000; }
  66% { background-color: #000000; }
  83% { background-color: #1a0505; }
  100% { background-color: #050000; }
}

/* --- Heavy Noise Overlay --- */
.noise-heavy::before {
  opacity: 0.12 !important;
  animation: noise-drift 0.15s steps(5) infinite !important;
}

.noise-max::before {
  opacity: 0.35 !important;
  animation: noise-drift 0.08s steps(8) infinite !important;
}

/* --- Scanline Intensification --- */
.scanlines-heavy::after {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 3px
  ) !important;
}

/* --- Element Scatter --- */
.scatter {
  transition: none !important;
}

/* --- Static Burst (full-screen white noise flash) --- */
.static-burst {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 700;
  pointer-events: none;
  opacity: 0;
}

.static-burst.active {
  opacity: 1;
  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='1'/%3E%3C/svg%3E");
  animation: static-noise 0.05s steps(10) infinite;
}

@keyframes static-noise {
  0% { transform: translate(0, 0) scale(1.1); }
  25% { transform: translate(-5px, 3px) scale(1.15); }
  50% { transform: translate(3px, -5px) scale(1.1); }
  75% { transform: translate(-3px, -3px) scale(1.12); }
  100% { transform: translate(5px, 5px) scale(1.1); }
}

/* --- Aftermath --- */
.aftermath {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.aftermath.active {
  display: flex;
}

.aftermath__content {
  text-align: center;
}

.aftermath__line {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--text-primary);
  opacity: 0;
  margin-bottom: 16px;
  line-height: 1.8;
}

.aftermath__line.visible {
  animation: aftermath-fade 3s ease-out forwards;
}

@keyframes aftermath-fade {
  from { opacity: 0; }
  to { opacity: 0.8; }
}

.aftermath__link-container {
  margin-top: 40px;
  opacity: 0;
}

.aftermath__link-container.visible {
  animation: aftermath-link-fade 5s ease-out forwards;
}

@keyframes aftermath-link-fade {
  from { opacity: 0; }
  to { opacity: 0.15; }
}

.aftermath__link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.5em;
  padding: 20px 40px;
  cursor: default;
  transition: color 2s, letter-spacing 2s;
  text-decoration: none;
  display: inline-block;
}

.aftermath__link:hover {
  color: var(--text-dim);
  letter-spacing: 0.8em;
  cursor: pointer;
}

.aftermath__depth {
  position: fixed;
  bottom: 12px;
  left: 16px;
  font-size: 0.5rem;
  letter-spacing: 0.15em;
  color: #0d0d0d;
  transition: color 2s;
}

.aftermath__depth:hover {
  color: var(--text-faint);
}

/* --- Vignette --- */
.vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 200px 80px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  z-index: 950;
}

/* --- CRT Curvature --- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.5) 100%
  );
  pointer-events: none;
  z-index: 951;
}

/* --- Glitch Line (screen tear) --- */
.screen-glitch-line {
  position: fixed;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(204, 51, 51, 0.2);
  pointer-events: none;
  z-index: 300;
  animation: glitch-line-anim 0.15s linear forwards;
}

@keyframes glitch-line-anim {
  0% { opacity: 0.8; }
  100% { opacity: 0; transform: translateX(4px); }
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .void-header {
    flex-direction: column;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.55rem;
  }

  .status-value--large {
    font-size: 1.3rem;
  }

  .log-output {
    max-height: 25vh;
  }

  .aftermath__line {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
  }

  .kernel-panic__content {
    font-size: 0.6rem;
  }
}
