/* ============================================
   XRFXRC TERMINAL — STYLES v3.0
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=VT323&display=swap');

/* ─── RESET ─────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

/* ─── TOKENS ─────────────────────────────────── */
:root {
  --bg:        #000;
  --panel:     #040404;
  --border:    #1c1c1c;
  --border-hi: #444;
  --text:      #d8d8d8;
  --text-dim:  #555;
  --text-mute: #333;
  --accent:    #fff;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
  --font-vt:   'VT323', 'Courier New', monospace;
  --scanline-alpha: 0.06;
  --glow: 0 0 12px rgba(255,255,255,0.06);
}

/* ─── BASE ───────────────────────────────────── */
html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
}

/* ─── NOISE CANVAS ───────────────────────────── */
#noiseCanvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9990;
  opacity: 0.03;
  mix-blend-mode: screen;
}

/* ─── SCANLINES ──────────────────────────────── */
body::before {
  content: "";
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 3px,
    rgba(0,0,0,var(--scanline-alpha)) 3px, rgba(0,0,0,var(--scanline-alpha)) 4px
  );
  pointer-events: none;
  z-index: 9991;
}

/* ─── VIGNETTE ───────────────────────────────── */
body::after {
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 50%, rgba(0,0,0,0.82) 100%);
  pointer-events: none;
  z-index: 9989;
  animation: flicker 6s ease-in-out infinite;
}

/* ─── CRT CORNERS ────────────────────────────── */
.corner {
  position: fixed;
  width: 22px; height: 22px;
  border-color: var(--border-hi);
  border-style: solid;
  z-index: 9995;
  pointer-events: none;
}
.corner-tl { top: 14px; left: 14px; border-width: 1px 0 0 1px; }
.corner-tr { top: 14px; right: 14px; border-width: 1px 1px 0 0; }
.corner-bl { bottom: 36px; left: 14px; border-width: 0 0 1px 1px; }
.corner-br { bottom: 36px; right: 14px; border-width: 0 1px 1px 0; }

/* ─── HEADER ─────────────────────────────────── */
.terminal-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 36px;
  background: rgba(0,0,0,0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  z-index: 9998;
}

.header-left, .header-right { display: flex; align-items: center; gap: 10px; flex: 1; }
.header-right { justify-content: flex-end; }
.header-center { flex: 0; white-space: nowrap; }

.header-logo {
  font-family: var(--font-vt);
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.4em;
  line-height: 1;
  text-shadow: var(--glow);
}

.header-tag { color: var(--text-dim); font-size: 9px; }
.header-session { color: #444; font-size: 9px; }
.header-sep { color: var(--text-mute); }

.blink-dot {
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: blink 1.2s step-end infinite;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}

/* ─── MAIN BODY ──────────────────────────────── */
.terminal-body {
  padding: 72px 0 60px;
  max-width: 860px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── SEARCH BLOCK ───────────────────────────── */
.search-block {
  padding: 48px 32px 36px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.search-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.25em;
  margin-bottom: 16px;
}
.search-label-sub { color: var(--text-mute); font-size: 9px; }

.search-row {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.search-prompt {
  font-size: 18px;
  color: var(--text-dim);
  margin-right: 14px;
  flex-shrink: 0;
  transition: color 0.2s;
  line-height: 1;
}
.search-row:focus-within .search-prompt { color: var(--accent); }

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--accent);
  font-family: var(--font-vt);
  font-size: 26px;
  letter-spacing: 0.12em;
  padding: 4px 0;
  caret-color: var(--accent);
  text-transform: uppercase;
}

#searchInput::placeholder {
  color: var(--text-mute);
  font-size: 22px;
}

#accessBtn {
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 8px 20px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: 16px;
  min-height: 38px;
}
#accessBtn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }
#accessBtn:active { transform: scale(0.97); }

.search-underline {
  height: 1px;
  background: linear-gradient(to right, var(--accent), transparent);
  margin-top: 12px;
  width: 0%;
  transition: width 0.4s ease;
}
.search-row:focus-within ~ .search-underline { width: 100%; }

.history-hint {
  margin-top: 10px;
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.15em;
}

/* Autocomplete dropdown */
#autocompleteList {
  position: absolute;
  top: 100%;
  left: 28px;
  background: #080808;
  border: 1px solid var(--border);
  border-top: none;
  z-index: 9997;
  min-width: 200px;
  display: none;
}
#autocompleteList.open { display: block; }
.autocomplete-item {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background 0.1s;
}
.autocomplete-item:hover,
.autocomplete-item.selected { background: #111; color: var(--accent); }

/* ─── OUTPUT SECTION ─────────────────────────── */
.output-section {
  padding: 0 32px;
  flex: 1;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

#outputLabel {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.25em;
}

.output-meta {
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
}

/* ─── FEEDBACK / FILE LINKS ──────────────────── */
#searchFeedback {
  padding: 20px 0 40px;
  font-size: 13px;
  letter-spacing: 0.08em;
  line-height: 2;
  min-height: 60px;
}

/* Normal link */
.file-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-left: 2px solid var(--border);
  margin: 4px 0;
  cursor: pointer;
  transition: all 0.12s;
  position: relative;
  overflow: hidden;
  background: transparent;
  width: 100%;
  text-align: left;
}
.file-link::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0;
  background: rgba(255,255,255,0.03);
  transition: width 0.2s;
}
.file-link:hover::before { width: 100%; }
.file-link:hover {
  border-left-color: var(--accent);
  color: var(--accent);
}

.file-link-icon {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}
.file-link:hover .file-link-icon { color: var(--accent); }

.file-link-name { flex: 1; }
.file-link-badge {
  font-size: 8px;
  color: var(--text-mute);
  border: 1px solid var(--border);
  padding: 1px 6px;
  letter-spacing: 0.1em;
  flex-shrink: 0;
  transition: all 0.12s;
}
.file-link:hover .file-link-badge { border-color: var(--text-dim); color: var(--text-dim); }

/* Error link */
.file-link.error {
  border-left-color: #1a1a1a;
  color: #404040;
}
.file-link.error .file-link-icon { color: #2a2a2a; }
.file-link.error:hover { border-left-color: #333; color: #606060; background: transparent; }
.file-link.error::before { display: none; }

/* Special / action */
.file-link.special { border-left-color: #2a2a2a; color: #888; }
.file-link.special:hover { border-left-color: var(--border-hi); color: var(--text); }

/* Download link */
.file-link.download { border-left-color: #2e2e2e; }
.file-link.download .file-link-badge { border-style: dashed; }
.file-link.download:hover { border-left-color: var(--accent); }

/* Content / info */
.file-link.content-item { border-left-color: #1a1a1a; color: #666; cursor: default; }
.file-link.content-item:hover::before { display: none; }
.file-link.content-item:hover { color: #666; border-left-color: #1a1a1a; }

/* ─── ERROR DISPLAY ───────────────────────────── */
.error-display {
  padding: 20px 0;
  line-height: 2.2;
}
.error-code { color: #444; font-size: 13px; display: block; }
.error-msg { color: #606060; font-size: 12px; display: block; }
.error-target { color: #333; font-size: 11px; display: block; }

/* ─── HELP OUTPUT ─────────────────────────────── */
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 12px;
}

.help-category {
  display: block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.12s;
  background: transparent;
  text-align: left;
  font-family: var(--font-mono);
}
.help-category:hover { border-color: var(--border-hi); color: var(--accent); background: rgba(255,255,255,0.02); }

.help-section-label {
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.2em;
  display: block;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.help-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px;
}
.help-chip {
  font-size: 9px;
  color: var(--text-mute);
  border: 1px solid var(--border);
  padding: 4px 10px;
  letter-spacing: 0.1em;
}

/* ─── SUGGEST OUTPUT ─────────────────────────── */
.suggest-word {
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border-hi);
  transition: color 0.1s;
}
.suggest-word:hover { color: var(--accent); }

/* ─── LORE BOX ────────────────────────────────── */
#loreBox {
  display: none;
  position: relative;
  max-width: 100%;
  margin: 0 32px 0;
  padding: 20px 20px 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: #707070;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: 0.06em;
  animation: fadeIn 0.3s ease;
}

.lore-corner {
  position: absolute;
  width: 8px; height: 8px;
  border-color: var(--border-hi);
  border-style: solid;
  pointer-events: none;
}
.lc-tl { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.lc-tr { top: -1px; right: -1px; border-width: 1px 1px 0 0; }
.lc-bl { bottom: -1px; left: -1px; border-width: 0 0 1px 1px; }
.lc-br { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

#loreTitle {
  color: var(--text);
  display: block;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 0.2em;
}

/* ─── ARCHIVE IMAGE ───────────────────────────── */
.image-container {
  display: none;
  position: relative;
  margin: 32px 32px 0;
  border: 1px solid var(--border);
  overflow: hidden;
  animation: neonWake 0.5s ease-out;
}

.image-scanline-overlay {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 2px,
    rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 3px
  );
  pointer-events: none;
  z-index: 2;
}

.Archive {
  display: block;
  width: 100%; height: auto;
  pointer-events: none;
  filter: grayscale(100%) contrast(1.1);
}

.image-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.8);
  padding: 8px 14px;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  z-index: 3;
  border-top: 1px solid var(--border);
}

/* ─── STATUS BAR ──────────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  background: rgba(0,0,0,0.97);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  z-index: 9998;
}

.status-left { display: flex; align-items: center; gap: 8px; }
.status-right { display: flex; align-items: center; gap: 6px; color: var(--text-mute); }
.status-center { color: var(--text-mute); font-size: 9px; }
.status-sep { color: var(--border-hi); }

.status-indicator {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
  transition: all 0.3s;
}
.status-indicator.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
  animation: blink 1.6s ease-in-out infinite;
}
.status-indicator.error { background: #444; }

/* ─── ANIMATIONS ──────────────────────────────── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

@keyframes flicker {
  0%, 97%, 100% { opacity: 1; }
  98%            { opacity: 0.92; }
  99%            { opacity: 1; }
}

@keyframes neonWake {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  18%  { opacity: 0.3; }
  28%  { opacity: 1; }
  40%  { opacity: 0.6; }
  100% { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scanSlide {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

/* Typing boot effect */
.boot-line {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  opacity: 0;
  animation: fadeIn 0.2s ease forwards;
}

/* Access button pulse on search */
#accessBtn.pulsing {
  animation: btnPulse 0.3s ease;
}
@keyframes btnPulse {
  0%   { box-shadow: none; }
  50%  { box-shadow: 0 0 16px rgba(255,255,255,0.2); }
  100% { box-shadow: none; }
}

/* ─── SCROLLBAR ───────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 700px) {
  .terminal-body { max-width: 100%; }
  .search-block { padding: 36px 20px 24px; }
  .output-section { padding: 0 20px; }
  #loreBox { margin: 0 20px; }
  .image-container { margin: 24px 20px 0; }
  #searchInput { font-size: 20px; }
  .header-left, .header-right { display: none; }
  .help-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .search-block { padding: 28px 14px 20px; }
  .output-section { padding: 0 14px; }
  #loreBox { margin: 0 14px; }
  .image-container { margin: 20px 14px 0; }
}