:root {
  --bg-color: #08090a;
  --text-color: #00e5ff; /* Cyan */
  --accent-color: #ff00cc; /* Neon Pink for highlights */
  --dim-color: #008ba3; /* Dimmer cyan for details */
  --font-family: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', 'Courier New', monospace;
  --glow-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  line-height: 1.6;
  padding: 2rem;
  overflow-x: hidden;
  position: relative;
}

#crt-static {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 3;
  opacity: 0.12; /* Subtle background */
  pointer-events: none;
  image-rendering: pixelated; /* Sharp chunky noise */
}

#crt-media {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen; 
  opacity: 0.8; /* Boosted base opacity slightly to survive the aggressive darkening from the grid overlay */
}

#horizon-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  mix-blend-mode: hard-light; /* Aggressively shadows the media passing beneath the ocean grid while retaining bright glowing lines */
  /* Mask out the sky region so the darkening blend only applies to the physical ocean geometry, allowing images to show above the horizon */
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 5%, rgba(0,0,0,1) 20%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 5%, rgba(0,0,0,1) 20%);
}

/* Scanline effect */
body::before {
  content: " ";
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.2) 50%
  ),
  linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.05),
    rgba(0, 255, 0, 0.02),
    rgba(0, 0, 255, 0.05)
  );
  z-index: 2000; /* On top of everything */
  pointer-events: none;
}

#crt-lines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 11000; /* Above post-overlay (10000) and everything else */
  pointer-events: none;
  opacity: 0.8;
  image-rendering: pixelated;
}

.gutter {
  max-width: 800px;
  margin: 2rem auto;
  z-index: 100;
  /* Top 75% is solid, bottom 25% fades for background bleed */
  /* Reactive transparency: content container clears out during aberration spikes */
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, calc(1.0 - var(--crt-aberration, 0) * 5.0)) 0%,
    rgba(0, 0, 0, calc(1.0 - var(--crt-aberration, 0) * 5.0)) 75%,
    rgba(0, 0, 0, calc(0.15 - var(--crt-aberration, 0) * 1.5)) 100%
  );
  border: 1px solid var(--dim-color);
  box-shadow: var(--glow-shadow);
  padding: 2rem;
  /* Removed backdrop-filter to prevent Chrome mix-blend-mode inheritance bug which crushed text contrast */
  position: relative;
  /* Sync movement with background aberrations - Upped for more effect */
  transform: translateX(calc(var(--crt-aberration, 0) * 80px));
  /* Smoothing the jitter just slightly so it feels like physical mass */
  transition: transform 0.05s linear;
}

/* Tearing effect for the bottom 1/8th */
.gutter::before, .window::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: inherit;
  border: inherit;
  box-shadow: inherit;
  /* Only the bottom 1/64 slice (subtle tear) */
  clip-path: polygon(0 98.4%, 100% 98.4%, 100% 100%, 0 100%);
  /* Shift even more than the main frame for the "tear" feel - Now using lingering tear + stochastic offset */
  transform: translateX(calc(var(--crt-tear, 0) * 150px + var(--crt-tear-rand, 0) * 1px));
  z-index: -1;
  pointer-events: none;
}

/* Also tear the CONTENT itself (the text inside) */
.gutter > * {
  /* Only applied to the text/elements themselves */
  position: relative;
  z-index: 5; /* Ensure text is above the tearing overlay */
}

.gutter::after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Replace solid background inheritance with translucent signal refraction */
  background: rgba(0, 229, 255, 0.05);
  backdrop-filter: blur(3px) contrast(1.5) hue-rotate(15deg);
  /* Only the bottom 1/64 slice of the CONTENT area */
  clip-path: polygon(0 98.4%, 100% 98.4%, 100% 100%, 0 100%);
  transform: translateX(calc(var(--crt-tear, 0) * 80px + var(--crt-tear-rand, 0) * 0.5 * 1px));
  z-index: 1; /* Below the content */
  pointer-events: none;
  opacity: 0.6; /* Increased transparency by default */
}

header {
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--dim-color);
  padding-bottom: 1rem;
}

.intro {
  font-style: italic;
  color: var(--dim-color);
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
}

.post-item {
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
  padding: 1rem;
  transition: all 0.2s ease;
}

.post-item:hover {
  border-color: var(--text-color);
  box-shadow: var(--glow-shadow);
  transform: translateX(5px);
}

.post-id {
  color: var(--accent-color);
  margin-right: 1rem;
  font-weight: bold;
}

.post-link {
  color: var(--text-color);
  text-decoration: none;
  font-size: 1.2rem;
}

.post-link:hover {
  text-decoration: underline;
}

.post-date {
  display: block;
  font-size: 0.8rem;
  color: var(--dim-color);
  margin-top: 0.5rem;
}

footer {
  text-align: center;
  margin-top: 5rem;
  font-size: 0.7rem;
  color: var(--dim-color);
  letter-spacing: 2px;
}

h1 {
  font-size: 2.5rem;
  text-transform: uppercase;
  letter-spacing: 4px;
  margin-bottom: 1rem;
  text-shadow: var(--glow-shadow);
}
/* Overlay Viewer */
#post-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  overflow-x: hidden;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#post-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.window {
  position: absolute;
  width: 90%;
  max-width: 900px;
  height: 85%;
  display: flex;
  flex-direction: column;
  /* Reactive transparency: only flashes clear for an instant during aberration spikes for readability */
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, calc(1.0 - var(--crt-aberration, 0) * 5.0)) 0%,
    rgba(0, 0, 0, calc(1.0 - var(--crt-aberration, 0) * 5.0)) 75%,
    rgba(0, 0, 0, calc(0.15 - var(--crt-aberration, 0) * 1.0)) 100%
  );
  border: 1px solid var(--dim-color);
  box-shadow: var(--glow-shadow);
  overflow: hidden;
  /* Global jitter sync - Upped for more effect */
  transform: translateX(calc(var(--crt-aberration, 0) * 80px));
  transition: transform 0.05s linear;
}

/* Internal content tear for popups */
#post-frame {
  transform: translateX(calc(var(--crt-tear, 0) * 120px));
}

.window-header {
  background: rgba(0, 229, 255, 0.05);
  border-bottom: 1px solid var(--dim-color);
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  user-select: none;
}

.window-title {
  font-size: 0.7rem;
  color: var(--dim-color);
  letter-spacing: 2px;
}

#post-frame {
  width: 100%;
  flex-grow: 1;
  border: none;
}

.hacker-btn {
  background: transparent;
  color: var(--text-color);
  border: 1px solid var(--text-color);
  padding: 0.4rem 0.8rem;
  font-family: var(--font-family);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.hacker-btn:hover {
  background: var(--text-color);
  color: var(--bg-color);
  box-shadow: var(--glow-shadow);
}

/* Animations */
@keyframes gravity-spike {
  0% { transform: scale(1, 1); filter: brightness(1); }
  4% { transform: scale(1, 0.05); filter: brightness(2) contrast(2); }
  6% { transform: scale(1.2, 0.1) skewX(10deg); filter: contrast(1.5); }
  12% { transform: scale(0.9, 1.3) skewX(-5deg); }
  20% { transform: scale(1, 1); filter: brightness(1); }
}

.window.gravity-spike {
  animation: gravity-spike 0.5s cubic-bezier(0.1, 0.9, 0.2, 1);
}


@keyframes flicker {
  0% { opacity: 0.97; }
  5% { opacity: 0.95; }
  10% { opacity: 0.9; }
  15% { opacity: 0.95; }
  25% { opacity: 0.98; }
  30% { opacity: 1; }
  100% { opacity: 1; }
}

body {
  animation: flicker 0.1s infinite alternate;
}

/* --- STOCHASTIC_DECRYPT (Chat) Styles --- */
#signal-input-container {
  position: fixed;
  bottom: 0px;
  left: 0;
  width: 100vw;
  background: rgba(0, 0, 0, 0.9);
  border-top: 1px solid var(--dim-color);
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  z-index: 12000;
  backdrop-filter: blur(8px);
}

.signal-prompt {
  color: var(--text-color);
  font-size: 0.7rem;
  letter-spacing: 2px;
  margin-right: 1rem;
  text-shadow: var(--glow-shadow);
  white-space: nowrap;
}

#signal-broadcast {
  background: transparent;
  border: none;
  color: var(--accent-color);
  font-family: var(--font-family);
  font-size: 0.8rem;
  width: 100%;
  outline: none;
  letter-spacing: 1px;
}

.falling-signal {
  position: fixed;
  z-index: 500; /* Behind content boxes, above CRT noise */
  font-family: var(--font-family);
  color: var(--text-color);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: var(--glow-shadow);
  animation: fall-and-fade 10s linear forwards;
}

@keyframes fall-and-fade {
  0% { transform: translateY(-5vh); opacity: 0; }
  5% { opacity: 0.8; }
  85% { opacity: 0.8; }
  100% { transform: translateY(105vh); opacity: 0; }
}

/* --- STOCHASTIC_ENCRYPT (Redaction) Styles --- */
.redacted {
  display: inline-block;
  background: rgba(0, 229, 255, 0.1);
  color: transparent;
  position: relative;
  cursor: help;
  transition: all 0.3s ease;
  user-select: none;
  overflow: hidden;
  border-radius: 2px;
  padding: 0 4px;
}

.redacted::after {
  content: "██████████";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  opacity: 0.5;
  animation: redacted-flicker 2s infinite;
  pointer-events: none;
}

@keyframes redacted-flicker {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

.redacted.revealed {
  background: transparent !important;
  color: var(--accent-color) !important;
  text-shadow: var(--glow-shadow);
  cursor: text;
}

.redacted.revealed::after {
  display: none !important;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
  background: var(--dim-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-color);
  box-shadow: var(--glow-shadow);
}

/* STOCHASTIC_HIGHLIGHT (Syntax Colors) */
.syn-keyword { color: var(--accent-color); font-weight: bold; }
.syn-function { color: var(--text-color); }
.syn-comment { color: var(--dim-color); font-style: italic; opacity: 0.8; }
.syn-string { color: #f9d71c; } /* Cyber-Yellow */
.syn-number { color: #00ff88; } /* Bright Green */
.syn-literal { color: #ff00cc; }
.syn-type { color: #00e5ff; text-decoration: underline dotted var(--dim-color); }

/* MOBILE_OPTIMIZATION_LAYER */
@media screen and (max-width: 768px) {
  html { font-size: 14px; }
  
  .gutter { 
    width: 95% !important; 
    margin: 1rem auto !important;
    padding: 1rem !important; 
    /* Significantly dampen jitter translation on narrow screens so it doesn't push off screen */
    transform: translateX(calc(var(--crt-aberration, 0) * 15px)) !important;
  }
  
  /* Dampen the tearing overlay */
  .gutter::before, .window::before {
    transform: translateX(calc(var(--crt-tear, 0) * 30px + var(--crt-tear-rand, 0) * 1px)) !important;
  }
  
  .gutter::after {
    transform: translateX(calc(var(--crt-tear, 0) * 15px + var(--crt-tear-rand, 0) * 0.5 * 1px)) !important;
  }

  .window { 
    width: 95% !important; 
    height: 95% !important; 
    padding: 0 !important; 
    transform: translateX(calc(var(--crt-aberration, 0) * 15px)) !important;
  }
  
  #post-frame {
    transform: translateX(calc(var(--crt-tear, 0) * 20px)) !important;
  }

  h1 { 
    font-size: clamp(1.5rem, 6vw, 2.5rem) !important; 
  }
  
  #signal-input-container {
    padding: 0.5rem;
  }
  
  .signal-prompt {
    display: none; /* Hide the prompt string [SIGNAL_OUT] to give input field max space */
  }

  #stochastic-player { 
    top: auto !important; bottom: 50px !important; right: 10px !important; 
    font-size: 0.7rem !important; padding: 5px 8px !important;
  }
}
