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

:root {
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition-speed: 0.15s;
}

/* Theme Configurations */
.theme-matrix {
  --bg-color: #000000;
  --text-color: #00ff41;
  --cursor-color: #00ff41;
  --glow-color: rgba(0, 255, 65, 0.4);
  --accent-color: #00ff41;
  --success-color: #00ff41;
  --warning-color: #ffffff;
}

.theme-dracula {
  --bg-color: #1e1f29;
  --text-color: #f8f8f2;
  --cursor-color: #50fa7b;
  --glow-color: rgba(189, 147, 249, 0.3);
  --accent-color: #ff79c6;
  --success-color: #50fa7b;
  --warning-color: #f1fa8c;
}

.theme-nord {
  --bg-color: #2e3440;
  --text-color: #d8dee9;
  --cursor-color: #88c0d0;
  --glow-color: rgba(136, 192, 208, 0.2);
  --accent-color: #8fbcbb;
  --success-color: #a3be8c;
  --warning-color: #ebcb8b;
}

.theme-vaporwave {
  --bg-color: #18022a;
  --text-color: #00ffff;
  --cursor-color: #ff00ff;
  --glow-color: rgba(255, 0, 128, 0.35);
  --accent-color: #ff00ff;
  --success-color: #00ffff;
  --warning-color: #ffff00;
}

.theme-dos {
  --bg-color: #0000aa;
  --text-color: #ffffff;
  --cursor-color: #ffffff;
  --glow-color: transparent;
  --accent-color: #ffff55;
  --success-color: #55ff55;
  --warning-color: #ffff55;
}

/* Page Setup */
html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Fullscreen CRT Scanline Overlay */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.16) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  background-size: 100% 4px, 6px 100%;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.crt-active .crt-overlay {
  opacity: 1;
  animation: flicker 0.2s infinite;
}

@keyframes flicker {
  0% { opacity: 0.98; }
  50% { opacity: 1; }
  100% { opacity: 0.99; }
}

/* Full viewport TTY Container */
.tty-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}

.tty-screen {
  flex-grow: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  text-shadow: 0 0 2px var(--glow-color);
}

/* Webkit Scrollbar Styling (Minimal retro styling) */
.tty-screen::-webkit-scrollbar {
  width: 8px;
}
.tty-screen::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}
.tty-screen::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}
.tty-screen::-webkit-scrollbar-thumb:hover {
  background: var(--cursor-color);
}

/* Output Spacing (Tightened for realism) */
.terminal-output {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-history-row {
  margin-bottom: 2px;
  line-height: 1.45;
}

.command-line {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--text-color);
}

.command-line .prompt {
  color: var(--cursor-color);
  margin-right: 8px;
}

.command-line .entered-cmd {
  color: var(--text-color);
}

/* Pure CLI Output (No graphical borders or paddings) */
.output-content {
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-color);
  margin-top: 1px;
}

.welcome-banner {
  white-space: pre;
  font-size: 11px;
  line-height: 1.2;
  color: var(--accent-color);
  margin-bottom: 12px;
  overflow-x: auto;
}

.welcome-bio {
  line-height: 1.45;
  margin-bottom: 12px;
}

/* Text Highlights */
.command-highlight {
  color: var(--accent-color);
  font-weight: bold;
}

.link-highlight {
  color: var(--cursor-color);
  text-decoration: underline;
  cursor: pointer;
}

.link-highlight:hover {
  filter: brightness(1.2);
}

.success-text {
  color: var(--success-color);
}

.warning-text {
  color: var(--warning-color);
}

.title-text {
  color: var(--accent-color);
  font-weight: 700;
  font-size: 15px;
  margin: 6px 0 2px 0;
  display: inline-block;
}

/* Simple ASCII-like grids for skills */
.skills-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0;
}

.skill-row {
  display: flex;
  max-width: 480px;
  justify-content: space-between;
}

.skill-name {
  flex-basis: 40%;
}

.skill-visual {
  flex-grow: 1;
  color: var(--cursor-color);
}

/* Active Prompt Input area */
.terminal-input-line {
  display: flex;
  align-items: center;
  padding-top: 6px;
  margin-top: 4px;
}

.prompt-symbol {
  color: var(--cursor-color);
  font-weight: 600;
  margin-right: 8px;
  white-space: nowrap;
}

.input-wrapper {
  flex-grow: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.input-display {
  color: var(--text-color);
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 18px;
}

.hidden-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: default;
  background: transparent;
  border: none;
  color: transparent;
  outline: none;
  z-index: -1;
}

.custom-caret {
  width: 8px;
  height: 16px;
  background: var(--cursor-color);
  display: inline-block;
  margin-left: 2px;
  animation: caret-blink 1s step-end infinite;
}

@keyframes caret-blink {
  from, to { background-color: transparent; }
  50% { background-color: var(--cursor-color); }
}

/* Canvas Overlay for Visualizations (FullScreen absolute overlay) */
.canvas-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#math-canvas {
  width: 100%;
  height: 100%;
}

.close-canvas-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--cursor-color);
  color: var(--cursor-color);
  font-size: 24px;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 101;
}

.close-canvas-btn:hover {
  background: var(--cursor-color);
  color: var(--bg-color);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .tty-screen {
    padding: 12px;
    font-size: 12px;
  }
  
  .welcome-banner {
    font-size: 8px;
  }

  .custom-caret {
    height: 14px;
  }
}
