/* ALAN.BBS — CRT Terminal Stylesheet */

:root {
  --terminal-bg: #0a0a0a;
  --terminal-fg: #afffbc;
  --terminal-dim: #3dba5e;
  --terminal-bright: #e0ffe8;
  --terminal-amber: #ffb000;
  --terminal-red: #ff4444;
  --terminal-cyan: #00ffff;
  --terminal-white: #e0e0e0;
  --terminal-gray: #555;
  --font-mono: 'Courier New', 'Lucida Console', monospace;
  --scanline-opacity: 0.05;
  --glow-color: rgba(180, 255, 200, 0.35);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  min-height: 100%;
}

.bbs-body {
  background: var(--terminal-bg);
  color: var(--terminal-fg);
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.6;
  min-height: 100dvh;
  cursor: text;
}

/* Main terminal container — grows with content, input sticks to bottom */
#terminal {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 0;
}

/* Phosphor glow — tight focus + soft bloom */
#terminal-output,
.sysop-ambient {
  text-shadow:
    0 0 3px var(--glow-color),
    0 0 10px rgba(150, 255, 180, 0.2);
}

/* CRT scanlines — fixed overlay */
.crt-overlay {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 4px
  );
  pointer-events: none;
  z-index: 100;
}

/* Output area — grows naturally, page scrolls */
#terminal-output {
  flex: 1;
  overflow: visible;
  word-wrap: break-word;
  white-space: pre-wrap;
  padding-bottom: 8px;
}

/* Output lines */
.output-line {
  display: block;
  min-height: 1.6em;
}

.output-line--command {
  color: var(--terminal-white);
}

.output-line--error {
  color: var(--terminal-red);
}

.output-line--system {
  color: var(--terminal-dim);
}

.output-line--bright {
  color: var(--terminal-bright);
  font-weight: bold;
}

.output-line--amber {
  color: var(--terminal-amber);
}

.output-line--sysop {
  color: var(--terminal-cyan);
}

.output-line--board-header {
  color: var(--terminal-bright);
  border-bottom: 1px solid var(--terminal-dim);
  margin-bottom: 4px;
  padding-bottom: 2px;
  font-weight: bold;
}

.output-line--entry {
  padding-left: 2ch;
}

.output-line--blank {
  display: block;
  height: 1.6em;
}

/* Sysop ambient — shown above input line */
.sysop-ambient {
  font-style: italic;
  color: var(--terminal-dim);
  font-size: 15px;
  min-height: 1.6em;
  padding: 2px 0;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.sysop-ambient.visible {
  opacity: 1;
}

/* Input line */
.input-line {
  display: flex;
  align-items: center;
  padding: 8px 0 10px;
  border-top: 1px solid var(--terminal-dim);
}

.prompt-label {
  color: var(--terminal-bright);
  font-weight: bold;
  white-space: nowrap;
}

.input-display {
  color: var(--terminal-fg);
  white-space: pre;
}

/* Blinking cursor */
.cursor-block {
  display: inline-block;
  background: var(--terminal-fg);
  color: var(--terminal-bg);
  animation: blink 1s step-end infinite;
  min-width: 0.6em;
  text-shadow: none;
}

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

/* Hidden input — invisible but focusable */
.terminal-hidden-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  left: 0;
  top: 0;
  background: transparent;
  border: none;
  outline: none;
  color: transparent;
  caret-color: transparent;
  pointer-events: none;
}

/* Mobile tap-to-type button */
.mobile-keyboard-btn {
  display: none;
  position: fixed;
  bottom: 60px;
  right: 16px;
  background: var(--terminal-dim);
  color: var(--terminal-bg);
  border: 1px solid var(--terminal-fg);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 200;
}

@media (max-width: 768px) {
  .mobile-keyboard-btn {
    display: block;
  }

  .bbs-body {
    font-size: 15px;
  }
}

/* Who's online badge */
.who-badge {
  position: fixed;
  top: 10px;
  right: 14px;
  font-size: 13px;
  color: var(--terminal-dim);
  z-index: 50;
}

/* Progress bar for boot */
.progress-bar {
  display: inline-block;
  color: var(--terminal-bright);
}

/* Entry list styles */
.entry-id {
  color: var(--terminal-amber);
  display: inline-block;
  min-width: 4ch;
}

.entry-title {
  color: var(--terminal-fg);
}

.entry-date {
  color: var(--terminal-dim);
  font-size: 14px;
}

/* Sysop chat */
.sysop-response {
  color: var(--terminal-cyan);
}

/* Typewriter cursor for streaming */
.streaming-cursor::after {
  content: '▋';
  animation: blink 0.6s step-end infinite;
}

/* Board divider */
.board-divider {
  color: var(--terminal-dim);
  display: block;
}

/* Inline photo */
.terminal-image {
  display: block;
  max-width: min(640px, 100%);
  max-height: 420px;
  object-fit: cover;
  border: 1px solid var(--terminal-dim);
  box-shadow: 0 0 12px rgba(51, 255, 102, 0.15);
  margin: 6px 0;
  filter: saturate(85%) brightness(0.95);
}

/* Clickable entries */
.clickable-entry {
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
}

.clickable-entry:hover {
  background: rgba(0, 255, 65, 0.08);
  color: var(--terminal-bright);
  padding-left: 0;
}

.clickable-entry:hover::before {
  content: '▶';
  color: var(--terminal-amber);
  margin-right: 4px;
}

/* Sticky footer — wraps fkey-bar and input-line */
.terminal-footer {
  position: sticky;
  bottom: 0;
  background: var(--terminal-bg);
  z-index: 10;
}

/* F-key nav bar */
.fkey-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px 0 4px;
  border-top: 1px solid var(--terminal-dim);
}

.fkey-btn {
  background: none;
  border: 1px solid var(--terminal-dim);
  color: var(--terminal-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  line-height: 1.4;
}

.fkey-btn:hover,
.fkey-btn:focus {
  background: var(--terminal-dim);
  color: var(--terminal-bg);
  outline: none;
}

.fkey-label {
  color: var(--terminal-amber);
  margin-right: 2px;
}

.fkey-btn:hover .fkey-label,
.fkey-btn:focus .fkey-label {
  color: var(--terminal-bg);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lightbox--open {
  opacity: 1;
}

.lightbox-img {
  max-width: min(90vw, 1000px);
  max-height: 80vh;
  object-fit: contain;
  border: 1px solid var(--terminal-dim);
  box-shadow:
    0 0 20px rgba(100, 255, 150, 0.2),
    0 0 60px rgba(100, 255, 150, 0.08);
  filter: none;
}

.lightbox-caption {
  font-family: var(--font-mono);
  color: var(--terminal-fg);
  font-size: 15px;
  text-shadow: 0 0 6px var(--glow-color);
  max-width: min(90vw, 1000px);
  text-align: center;
}

.lightbox-hint {
  font-family: var(--font-mono);
  color: var(--terminal-dim);
  font-size: 13px;
}

/* Make thumbnail images show pointer cursor */
img.terminal-image {
  cursor: zoom-in;
}

/* List keyboard navigation highlight */
.output-line--selected {
  color: var(--terminal-bright);
  background: rgba(0, 255, 65, 0.07);
  outline: 1px solid rgba(0, 255, 65, 0.25);
}
.output-line--selected::before {
  content: '▶ ';
}

/* Dim output (ghost users, system msgs, random events) */
.output-line--dim {
  color: var(--terminal-dim);
  opacity: 0.7;
  font-style: italic;
}

/* Easter egg special effects */
@keyframes glitch {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-2px); filter: brightness(1.5); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-1px); filter: brightness(0.8); }
  80% { transform: translateX(2px); }
}

.glitch {
  animation: glitch 0.35s steps(1) 2;
}

/* Screensaver overlay */
.screensaver {
  position: fixed;
  inset: 0;
  background: var(--terminal-bg);
  z-index: 500;
  cursor: none;
}

.screensaver-logo {
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: bold;
  color: var(--terminal-fg);
  text-shadow:
    0 0 8px var(--glow-color),
    0 0 20px rgba(150, 255, 180, 0.3);
  white-space: nowrap;
  user-select: none;
}

.screensaver-sub {
  font-size: 14px;
  color: var(--terminal-dim);
  font-weight: normal;
  text-align: center;
  margin-top: 2px;
}

/* Vignette — subtle CRT edge darkening */
#terminal::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 65%,
    rgba(0, 0, 0, 0.45) 100%
  );
  pointer-events: none;
  z-index: 90;
}
