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

:root {
  --bg: #1e1e2e;
  --fg: #cdd6f4;
  --prompt-user: #a6e3a1;
  --prompt-dir: #89b4fa;
  --accent: #f38ba8;
  --dim: #6c7086;
  --dir-color: #89b4fa;
  --file-color: #cdd6f4;
  --exec-color: #a6e3a1;
  --link-color: #89dceb;
  --window-bg: #181825;
  --titlebar: #11111b;
  --scrollbar-thumb: #45475a;
  --scrollbar-track: transparent;
  --radius: 10px;
  --font: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

body.light {
  --bg: #eff1f5;
  --fg: #4c4f69;
  --prompt-user: #40a02b;
  --prompt-dir: #1e66f5;
  --accent: #d20f39;
  --dim: #9ca0b0;
  --dir-color: #1e66f5;
  --file-color: #4c4f69;
  --exec-color: #40a02b;
  --link-color: #04a5e5;
  --window-bg: #e6e9ef;
  --titlebar: #ccd0da;
  --scrollbar-thumb: #bcc0cc;
}

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

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, #1e1e2e 0%, #11111b 100%);
}

body.light {
  background: radial-gradient(ellipse at center, #eff1f5 0%, #ccd0da 100%);
}

/* ========== Terminal Window ========== */
#terminal-container {
  width: 100%;
  max-width: 860px;
  height: 640px;
  min-height: 300px;
  max-height: calc(100vh - 48px);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 16px 48px rgba(0,0,0,0.45),
    0 2px 8px rgba(0,0,0,0.25);
  z-index: 1;
  resize: vertical;
}

/* ========== Resize Handle ========== */
.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: ns-resize;
  z-index: 10;
}
.resize-handle::before {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  opacity: 0.4;
  transition: opacity 0.2s;
}
.resize-handle:hover::before {
  opacity: 0.8;
}

/* ========== Title Bar ========== */
#terminal-container::before {
  content: '';
  display: block;
  height: 38px;
  min-height: 38px;
  background: var(--titlebar);
  position: relative;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#terminal-container::after {
  content: '\25CF \25CF \25CF';
  position: absolute;
  top: 0;
  left: 16px;
  height: 38px;
  display: flex;
  align-items: center;
  font-size: 12px;
  letter-spacing: 6px;
  color: #45475a;
  z-index: 2;
  pointer-events: none;
}

/* Window title */
.window-title {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--dim);
  z-index: 1;
  pointer-events: none;
}

/* ========== Terminal Body ========== */
#terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  scroll-behavior: smooth;
}

#terminal-body::-webkit-scrollbar {
  width: 6px;
}
#terminal-body::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
#terminal-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* ========== CRT Scanline Overlay ========== */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.03) 0px,
    rgba(0, 0, 0, 0.03) 1px,
    transparent 1px,
    transparent 2px
  );
  mix-blend-mode: multiply;
}

/* ========== Input Line ========== */
.command-line {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.05);
  min-height: 36px;
}

.prompt {
  white-space: nowrap;
  color: var(--prompt-user);
  font-weight: 600;
}

.prompt .dir {
  color: var(--prompt-dir);
}

#cmd-input {
  flex: 1;
  outline: none;
  color: var(--fg);
  caret-color: transparent;
  white-space: pre-wrap;
  word-break: break-all;
}

.cursor {
  color: var(--fg);
  animation: blink 1s step-end infinite;
  font-size: 14px;
  line-height: 1;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ========== Output Blocks ========== */
.output-block {
  margin: 4px 0 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.input {
  color: var(--dim);
  margin: 8px 0 2px;
}

/* ========== Links ========== */
a.post-link {
  color: var(--link-color);
  text-decoration: none;
  cursor: pointer;
}
a.post-link:hover {
  text-decoration: underline;
}

.dir-entry {
  color: var(--dir-color);
  font-weight: 600;
  cursor: pointer;
}
.dir-entry:hover {
  text-decoration: underline;
}

.file-entry {
  color: var(--file-color);
  cursor: pointer;
}
.file-entry:hover {
  text-decoration: underline;
}

.exec-entry {
  color: var(--exec-color);
}

/* ========== Neofetch ========== */
.neofetch {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.neofetch-art {
  color: var(--accent);
  font-size: 13px;
  line-height: 1.3;
  white-space: pre;
  flex-shrink: 0;
}

.neofetch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
}

.info-line {
  font-size: 13px;
}

.info-label {
  color: var(--accent);
  font-weight: 600;
}

/* Info value color blocks */
.neofetch-colors {
  display: flex;
  gap: 0;
  margin-top: 6px;
}
.neofetch-colors span {
  width: 24px;
  height: 16px;
  display: inline-block;
}

/* ========== Command output helpers ========== */
.error { color: var(--accent); }
.dim { color: var(--dim); }

/* ========== Tech badges ========== */
.tech-badge {
  display: inline-block;
  background: rgba(137,180,250,0.15);
  color: var(--prompt-dir);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  margin-right: 4px;
}

/* ========== Post content rendering ========== */
.post-content {
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 16px;
  margin: 8px 0;
  border-left: 3px solid var(--accent);
}

.post-content h1, .post-content h2, .post-content h3 {
  color: var(--accent);
  margin: 12px 0 6px;
}
.post-content h1 { font-size: 1.4em; }
.post-content h2 { font-size: 1.2em; }
.post-content h3 { font-size: 1.1em; }

.post-content p {
  margin: 6px 0;
}

.post-content code {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.9em;
}

.post-content pre {
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content a {
  color: var(--link-color);
}

.post-content ul, .post-content ol {
  margin: 6px 0 6px 20px;
}

.post-content blockquote {
  border-left: 3px solid var(--dim);
  color: var(--dim);
  margin: 8px 0;
  padding-left: 12px;
}

/* ========== Typewriter cursor ========== */
.typewriter-line {
  min-height: 1.5em;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
  body { padding: 8px; }
  #terminal-container {
    max-height: none;
    height: calc(100vh - 16px);
    border-radius: 6px;
  }
  .neofetch { flex-direction: column; gap: 8px; }
  #terminal-body { padding: 10px; }
}
