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

:root {
  /* Default zsh */
  --bg: #000000;
  --bg-highlight: #1a1a1a;
  --fg: #e0e0e0;
  --fg-dim: #808080;
  --blue: #ffffff;
  --cyan: #ffffff;
  --green: #ffffff;
  --orange: #ffffff;
  --purple: #ffffff;
  --red: #ffffff;
  --yellow: #ffffff;
  --teal: #ffffff;
  --border: rgba(255, 255, 255, 0.1);
  --window-bg: rgba(0, 0, 0, 0.9);
  --cursor-bg: rgba(255, 255, 255, 0.06);
  --cursor-border: #ffffff;
  --font: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-size: 14px;
  --line-height: 1.7;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Background Noise ─────────────────────────── */
#background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

#background::before {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.24;
  animation: noise-drift 8s steps(11) infinite;
}

@keyframes noise-drift {
  0%   { transform: translate(0, 0); }
  10%  { transform: translate(-5%, -5%); }
  20%  { transform: translate(-10%, 5%); }
  30%  { transform: translate(5%, -10%); }
  40%  { transform: translate(-5%, 15%); }
  50%  { transform: translate(-10%, 5%); }
  60%  { transform: translate(15%, 0); }
  70%  { transform: translate(0, 10%); }
  80%  { transform: translate(-15%, 0); }
  90%  { transform: translate(10%, 5%); }
  100% { transform: translate(5%, 0); }
}

/* ── Terminal Window ─────────────────────────── */
#terminal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(900px, 92vw);
  height: min(600px, 85vh);
  background: var(--window-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 25px 60px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(255, 255, 255, 0.03);
  overflow: hidden;
}


/* ── Content Area ────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  position: relative;
}

#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-track { background: transparent; }
#content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
#content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── File Tree ───────────────────────────────── */
.file-tree {
  padding: 8px 0;
}

.file-line {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 32px;
  cursor: pointer;
  position: relative;
  transition: background 0.08s;
}

.file-line.cursor {
  background: var(--cursor-bg);
}

.file-line:hover {
  background: var(--cursor-bg);
}

.file-line.cursor::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--cursor-border);
}

/* ── Line Numbers (relative) ─────────────────── */
.line-number {
  width: 48px;
  text-align: right;
  color: var(--fg-dim);
  font-size: 12px;
  margin-right: 16px;
  flex-shrink: 0;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.file-line.cursor .line-number {
  color: var(--blue);
  font-weight: 600;
}

.file-icon {
  width: 20px;
  text-align: center;
  margin-right: 8px;
  color: var(--teal);
  font-size: 13px;
}

.file-name {
  color: var(--fg);
  font-size: 14px;
}

.file-name .ext {
  color: var(--fg-dim);
}

.file-meta {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 11px;
}

/* ── Content Lines (line-based rendering) ────── */
.content-lines {
  padding: 8px 0 60px;
}

.content-line {
  display: flex;
  align-items: flex-start;
  padding: 0 20px;
  min-height: 28px;
  line-height: 28px;
  position: relative;
  transition: background 0.08s;
}

.content-line.cursor {
  background: var(--cursor-bg);
}

.content-line:hover {
  background: var(--cursor-bg);
}

.content-line.cursor::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--cursor-border);
}

.content-line .line-number {
  width: 48px;
  text-align: right;
  color: var(--fg-dim);
  font-size: 12px;
  margin-right: 16px;
  flex-shrink: 0;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.content-line.cursor .line-number {
  color: var(--blue);
  font-weight: 600;
}

.content-line .line-text {
  flex: 1;
  font-size: 13px;
  line-height: 28px;
  white-space: pre-wrap;
  word-break: break-word;
}

.content-line .heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--blue);
}

.content-line .subheading {
  color: var(--fg-dim);
  font-size: 13px;
}

.content-line .divider-line {
  color: var(--fg-dim);
  opacity: 0.4;
}

.content-line .prompt {
  color: var(--green);
}

.content-line .link {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  transition: border-color 0.2s, color 0.2s;
}

.content-line .link:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ── Old File Content (kept for fallback) ────── */
.file-content {
  padding: 20px 28px 40px;
  min-height: 100%;
}

.file-content .section {
  margin-bottom: 24px;
}

.file-content .heading {
  font-size: 17px;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 4px;
}

.file-content .subheading {
  color: var(--fg-dim);
  font-size: 13px;
  margin-bottom: 12px;
}

.file-content .divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 20px 0;
}

.file-content .body {
  color: var(--fg);
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.file-content .link {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  transition: border-color 0.2s, color 0.2s;
}

.file-content .link:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.file-content .prompt {
  color: var(--green);
  margin-right: 4px;
}

.file-content .tag {
  display: inline-block;
  color: var(--orange);
  font-size: 12px;
}

/* ── Splash Screen ───────────────────────────── */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  user-select: none;
}

.splash .name {
  font-size: 32px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.splash .bio {
  color: var(--fg-dim);
  font-size: 14px;
  margin-bottom: 4px;
}

.splash .links {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.splash .links a {
  color: var(--cyan);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}

.splash .links a:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.splash .hint {
  margin-top: 32px;
  color: var(--fg-dim);
  font-size: 13px;
  animation: pulse 2s ease-in-out infinite;
  cursor: pointer;
}

.splash .hint kbd {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--blue);
}

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

/* ── Status Bar ──────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
  user-select: none;
}

#mode-indicator {
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--green);
}

#mode-indicator.search-mode {
  background: rgba(255, 255, 255, 0.08);
  color: var(--yellow);
}

#current-path {
  color: var(--fg-dim);
}

#cursor-pos {
  color: var(--fg-dim);
  min-width: 40px;
  text-align: right;
}

.readonly-badge {
  color: var(--fg-dim);
  font-size: 11px;
}

/* ── Count Display ───────────────────────────── */
#count-display {
  color: var(--orange);
  font-size: 11px;
  margin-right: 8px;
  font-weight: 600;
  min-width: 0;
}

/* ── Search Bar ──────────────────────────────── */
#search-bar {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  z-index: 20;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.search-prefix {
  color: var(--yellow);
  font-size: 14px;
  margin-right: 4px;
  font-weight: 600;
}

#search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  width: 200px;
  caret-color: var(--yellow);
}

#search-input::placeholder {
  color: var(--fg-dim);
}

/* ── Back Button ──────────────────────────────── */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px;
  color: var(--fg-dim);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.08s, color 0.08s;
  border-bottom: 1px solid var(--border);
}

.back-btn:hover {
  background: var(--cursor-bg);
  color: var(--blue);
}

.back-arrow {
  font-size: 14px;
}

/* ── No Results ──────────────────────────────── */
.no-results {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--fg-dim);
  font-size: 13px;
  font-style: italic;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  #terminal {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    transform: none;
    top: 0;
    left: 0;
  }

  .splash .name { font-size: 24px; }

  .file-content { padding: 16px 16px 40px; }
  .file-line { padding: 0 12px; }
  .line-number { width: 36px; font-size: 11px; }
  #search-input { width: 160px; }
}

/* ── Selection ───────────────────────────────── */
::selection {
  background: rgba(255, 255, 255, 0.2);
  color: var(--fg);
}
