/* Terminal Colors */
:root {
  --bg-dark: #0a0a0f;
  --bg-terminal: #0d1117;
  --bg-header: #161b22;
  --bg-selection: #1f6feb33;

  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  --green: #00d4aa;
  --green-bright: #00ffcc;
  --green-dim: #00d4aa44;

  --blue: #58a6ff;
  --purple: #bc8cff;
  --pink: #f778ba;
  --orange: #d29922;
  --red: #f85149;
  --yellow: #e3b341;
  --cyan: #39d0d8;

  --border: #30363d;
  --border-bright: #00d4aa;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-size: 14px;

  --glow-green: 0 0 10px #00d4aa33, 0 0 40px #00d4aa11;
  --glow-text: 0 0 10px currentColor;
}

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

/* Base */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-dark);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
}

/* Scanline effect */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.03) 1px,
    rgba(0, 0, 0, 0.03) 2px
  );
}

/* CRT overlay */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    rgba(0, 0, 0, 0.25) 100%
  );
}

/* Terminal window */
.terminal-window {
  width: 100%;
  max-width: 900px;
  height: 90vh;
  max-height: 700px;
  background: var(--bg-terminal);
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--border),
    var(--glow-green),
    0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Terminal header */
.terminal-header {
  background: var(--bg-header);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.terminal-buttons {
  display: flex;
  gap: 8px;
}

.terminal-buttons span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.btn-close { background: #ff5f56; }
.btn-minimize { background: #ffbd2e; }
.btn-maximize { background: #27c93f; }

.terminal-title {
  flex: 1;
  text-align: center;
}

.title-text {
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 0.5px;
}

.terminal-tabs {
  display: flex;
  gap: 8px;
}

.tab {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
}

.tab.active {
  color: var(--text-primary);
  background: var(--bg-terminal);
}

/* Terminal body */
.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.terminal-body::-webkit-scrollbar {
  width: 8px;
}

.terminal-body::-webkit-scrollbar-track {
  background: transparent;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Status bar */
.status-bar {
  background: var(--bg-header);
  padding: 6px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

.status-separator {
  margin: 0 8px;
  color: var(--text-muted);
}

/* Terminal text styles */
.prompt {
  color: var(--green);
  font-weight: 600;
}

.prompt-user {
  color: var(--cyan);
}

.prompt-path {
  color: var(--purple);
}

.command {
  color: var(--text-primary);
}

.output {
  margin: 10px 0;
  line-height: 1.6;
}

.ascii-art {
  color: var(--green);
  white-space: pre;
  font-size: 12px;
  line-height: 1.2;
  text-shadow: var(--glow-green);
}

.ascii-art.gradient {
  background: linear-gradient(135deg, var(--green), var(--cyan), var(--purple), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Box styles */
.box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  background: rgba(0, 212, 170, 0.02);
  position: relative;
}

.box.highlight {
  border-color: var(--green);
  box-shadow: 0 0 10px var(--green-dim);
}

.box.warning {
  border-color: var(--orange);
  background: rgba(210, 153, 34, 0.05);
}

.box.error {
  border-color: var(--red);
  background: rgba(248, 81, 73, 0.05);
}

.box.success {
  border-color: var(--green);
  background: rgba(0, 212, 170, 0.05);
}

.box-title {
  font-weight: 600;
  color: var(--green);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.box-content {
  color: var(--text-primary);
  line-height: 1.6;
}

/* Menu items */
.menu {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.menu-item {
  padding: 12px 16px;
  margin: 4px 0;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.menu-item:hover {
  background: var(--bg-selection);
  border-color: var(--green);
}

.menu-item.selected {
  background: rgba(0, 212, 170, 0.1);
  border-color: var(--green);
  box-shadow: 0 0 10px var(--green-dim);
}

.menu-icon {
  font-size: 20px;
  width: 30px;
  text-align: center;
}

.menu-label {
  font-weight: 600;
  color: var(--text-primary);
}

.menu-desc {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: auto;
}

/* Question styles */
.question-number {
  color: var(--green);
  font-weight: 600;
}

.question-topic {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.question-text {
  color: var(--text-primary);
  font-weight: 500;
  margin: 12px 0;
  line-height: 1.5;
}

.options {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.option {
  padding: 10px 16px;
  margin: 6px 0;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.option:hover {
  background: var(--bg-selection);
  border-color: var(--blue);
}

.option.selected {
  background: rgba(88, 166, 255, 0.1);
  border-color: var(--blue);
}

.option.correct {
  background: rgba(0, 212, 170, 0.1);
  border-color: var(--green);
  color: var(--green);
}

.option.wrong {
  background: rgba(248, 81, 73, 0.1);
  border-color: var(--red);
  color: var(--red);
}

.option-letter {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  background: var(--bg-header);
  border: 1px solid var(--border);
}

.option.correct .option-letter {
  background: var(--green);
  color: var(--bg-dark);
  border-color: var(--green);
}

.option.wrong .option-letter {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-header);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--bg-selection);
  border-color: var(--green);
}

.btn.primary {
  background: var(--green);
  color: var(--bg-dark);
  border-color: var(--green);
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--green-bright);
}

.btn-group {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat-card {
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--green);
  display: block;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Progress bar */
.progress-bar {
  height: 8px;
  background: var(--bg-header);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--green-dim);
}

/* Achievement */
.achievement {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  margin: 4px;
}

.achievement.unlocked {
  border-color: var(--yellow);
  background: rgba(227, 179, 65, 0.1);
}

.achievement-icon {
  font-size: 16px;
}

.achievement-name {
  color: var(--text-primary);
  font-weight: 500;
}

/* Typing animation */
.typing {
  overflow: hidden;
  border-right: 2px solid var(--green);
  white-space: nowrap;
  animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
  width: 0;
  display: inline-block;
}

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: var(--green) }
}

/* Cursor blink */
.cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--green);
  animation: blink 1s infinite;
  vertical-align: middle;
  margin-left: 2px;
}

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

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0) }
}

/* Topic tag */
.topic-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Flashcard */
.flashcard {
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 16px 0;
  cursor: pointer;
  transition: all 0.3s ease;
  perspective: 1000px;
}

.flashcard:hover {
  border-color: var(--green);
  box-shadow: var(--glow-green);
}

.flashcard-question {
  color: var(--text-primary);
  font-weight: 500;
}

.flashcard-answer {
  color: var(--green);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: none;
}

.flashcard.revealed .flashcard-answer {
  display: block;
}

.flashcard-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 8px;
}

.flashcard.revealed .flashcard-hint {
  display: none;
}

/* Code block */
.code-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  overflow-x: auto;
  margin: 8px 0;
}

.code-keyword { color: var(--purple); }
.code-string { color: var(--green); }
.code-comment { color: var(--text-muted); }
.code-function { color: var(--blue); }

/* Illustration */
.illustration {
  color: var(--cyan);
  white-space: pre;
  font-size: 11px;
  line-height: 1.3;
  margin: 12px 0;
  padding: 12px;
  background: rgba(57, 208, 216, 0.02);
  border: 1px solid rgba(57, 208, 216, 0.1);
  border-radius: 6px;
  overflow-x: auto;
}

/* Scroll to bottom helper */
.scroll-bottom {
  margin-top: 20px;
}

/* Link */
a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .terminal-window {
    height: 95vh;
    max-height: none;
    border-radius: 8px;
  }

  .terminal-body {
    padding: 12px;
    font-size: 13px;
  }

  .ascii-art {
    font-size: 8px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .menu-desc {
    display: none;
  }
}

/* Selection */
::selection {
  background: var(--green);
  color: var(--bg-dark);
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
