.terminal {
  position: relative;
  height: 100%;
  background: var(--color-surface);
  border: var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.help {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  height: 100%;
  overflow: hidden;
}

.help__body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.3rem 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 0;
  min-height: 0;
  align-items: flex-start;
}

.help__body::-webkit-scrollbar {
  width: 6px;
}

.help__body::-webkit-scrollbar-thumb {
  background: rgba(143, 162, 189, 0.25);
  border-radius: 999px;
}

.help__block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.help__title {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-accent-blue);
}

.help__text {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.help__list {
  margin: 0;
  padding-left: 1rem;
  color: var(--color-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.help__list li {
  margin-bottom: 0.3rem;
}

.help__list li:last-child {
  margin-bottom: 0;
}

.help__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  padding: 0.1rem 0.35rem;
  margin-right: 0.35rem;
  border-radius: var(--radius-xxs);
  border: 1px solid rgba(221, 232, 247, 0.2);
  color: var(--color-text);
  font-size: 0.75rem;
  background: rgba(8, 12, 22, 0.6);
}

.help__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
  border-radius: var(--radius-xxs);
  border: 1px solid rgba(221, 232, 247, 0.2);
  font-size: 0.75rem;
  text-transform: lowercase;
}

.help__badge--page {
  color: var(--color-accent-green);
}

.help__badge--image {
  color: var(--color-accent-orange);
}

.help__cmd {
  padding: 0.1rem 0.4rem;
  background: rgba(58, 140, 255, 0.12);
  border-radius: 4px;
  color: var(--color-accent-blue);
  font-size: 0.82rem;
  font-family: inherit;
  white-space: nowrap;
}

.terminal::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.03);
  mix-blend-mode: soft-light;
  opacity: 0;
  animation: idle-flicker 6s ease-in-out infinite;
}

.terminal__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.95rem;
  background: var(--color-surface-alt);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.terminal__controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.terminal__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(173, 186, 206, 0.2);
  position: relative;
  cursor: pointer;
}

.terminal__dot::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
}

.terminal__dot:hover {
  transform: scale(1.1);
  transition: transform 0.15s ease;
}

.terminal__dot--close {
  background: #ff5f57;
}

.terminal__dot--min {
  background: #fbbb2f;
}

.terminal__dot--max {
  background: #28c840;
}

.terminal__title {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.terminal__output {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(6, 13, 22, 0.68);
  flex: 1 1 0;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  min-height: 0;
  max-height: 100%;
  padding: 2.5rem 3.5rem;
}

.terminal__output::-webkit-scrollbar {
  width: 8px;
}


.terminal__output::-webkit-scrollbar-thumb {
  background: rgba(143, 162, 189, 0.28);
  border-radius: 999px;
}

.terminal__line {
  margin: 0 0 0.75rem;
  font-size: 1.08rem;
  line-height: 1.75;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--color-text);
}

.terminal__line:last-child {
  margin-bottom: 0;
}

/* Empty lines for spacing */
.terminal__line:empty {
  margin: 0;
  height: 0.8rem;
}

/* Command prompts - cyan, visible, terminal-style */
.terminal__line--command {
  color: #00d9ff;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 1;
  margin-bottom: 0.8rem;
  margin-top: 1.2rem;
  text-shadow: 0 0 12px rgba(0, 217, 255, 0.6), 0 0 24px rgba(0, 217, 255, 0.3);
  letter-spacing: 0.02em;
  animation: command-glow 2s ease-in-out infinite alternate;
}

@keyframes command-glow {
  0% {
    text-shadow: 0 0 12px rgba(0, 217, 255, 0.6), 0 0 24px rgba(0, 217, 255, 0.3);
  }
  100% {
    text-shadow: 0 0 16px rgba(0, 217, 255, 0.8), 0 0 32px rgba(0, 217, 255, 0.4);
  }
}

/* Muted/secondary text - gray and small */
.terminal__line--muted {
  color: var(--color-muted);
  font-size: 0.85rem;
  opacity: 0.75;
}

/* Success messages - green */
.terminal__line--success {
  color: var(--color-accent-green);
  font-weight: 500;
}

/* Warning/info messages - orange */
.terminal__line--warning {
  color: var(--color-accent-orange);
}

/* Error messages - red */
.terminal__line--error {
  color: var(--color-warning);
}

/* Section headers - yellow/gold terminal style */
.terminal__line--header {
  color: #ffd700;
  font-weight: 700;
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.2);
  animation: header-flicker 4s ease-in-out infinite;
}

@keyframes header-flicker {
  0%, 100% {
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.2);
  }
  50% {
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.7), 0 0 40px rgba(255, 215, 0, 0.3);
  }
}

/* Project headers - magenta */
.terminal__line--project {
  color: #ff79c6;
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 1.8rem;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 8px rgba(255, 121, 198, 0.3);
}

/* Dividers - subtle blue */
.terminal__line--divider {
  color: rgba(100, 160, 255, 0.15);
  font-size: 0.75rem;
  opacity: 0.6;
  user-select: none;
  margin: 1rem 0;
}

/* Bullet points - cyan */
.terminal__line--bullet {
  color: #8be9fd;
  font-size: 1rem;
  margin-left: 0.5rem;
}

/* Position titles - green with [POSITION] tag */
.terminal__line--position {
  color: #50fa7b;
  font-weight: 700;
  font-size: 1.08rem;
  margin-top: 1.8rem;
  margin-bottom: 0.4rem;
  text-shadow: 0 0 10px rgba(80, 250, 123, 0.3);
}

.terminal__line--position::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #50fa7b;
  border-radius: 50%;
  margin-right: 0.6rem;
  box-shadow: 0 0 10px rgba(80, 250, 123, 0.6);
}

/* Status lines - bright green */
.terminal__line--status {
  color: #50fa7b;
  font-weight: 600;
  font-size: 1.05rem;
  text-shadow: 0 0 12px rgba(80, 250, 123, 0.6), 0 0 24px rgba(80, 250, 123, 0.3);
  animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {
  0%, 100% {
    text-shadow: 0 0 12px rgba(80, 250, 123, 0.6), 0 0 24px rgba(80, 250, 123, 0.3);
  }
  50% {
    text-shadow: 0 0 16px rgba(80, 250, 123, 0.8), 0 0 32px rgba(80, 250, 123, 0.4);
  }
}

/* Code/path elements */
.terminal__line--code {
  color: var(--color-accent-green);
  font-family: var(--font-mono);
}

/* Tree structure characters */
.terminal__line--tree {
  color: rgba(142, 160, 186, 0.5);
  user-select: none;
}

/* Inline syntax highlighting - terminal themed */
.terminal__line .syntax-string {
  color: #50fa7b;
  font-weight: 500;
}

.terminal__line .syntax-number {
  color: #bd93f9;
  font-weight: 500;
}

.terminal__line .syntax-operator {
  color: #ff79c6;
  font-weight: 600;
}

.terminal__line .syntax-url {
  color: #8be9fd;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(139, 233, 253, 0.3);
  padding-bottom: 1px;
}

.terminal__line .syntax-url:hover {
  color: #50fa7b;
  text-shadow: 0 0 8px rgba(80, 250, 123, 0.6);
  border-bottom-color: rgba(80, 250, 123, 0.6);
  transform: translateY(-1px);
}

.terminal__line .syntax-url:active {
  transform: translateY(0);
  color: #3aff9f;
}

/* Clickable lines (for hidden link functionality) */
.terminal__line--clickable {
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid rgba(139, 233, 253, 0.3);
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  position: relative;
}

.terminal__line--clickable::after {
  content: '→';
  position: absolute;
  right: 0;
  color: rgba(139, 233, 253, 0.4);
  font-size: 0.9rem;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.terminal__line--clickable:hover {
  border-left-color: var(--color-accent-blue);
  transform: translateX(3px);
  color: var(--color-accent-blue);
}

.terminal__line--clickable:hover::after {
  color: var(--color-accent-blue);
  opacity: 1;
  transform: translateX(3px);
}

.terminal__line .syntax-tag {
  color: #ffb86c;
  font-weight: 600;
  background: rgba(255, 184, 108, 0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* Emphasized important lines (bullet points, key info) */
.terminal__line:has(> span:first-child:is([class*="syntax"])),
.terminal__line[class*="--header"] + .terminal__line {
  font-size: 1.02rem;
}

/* Name/title on home page should be prominent - cyan glow */
.terminal__line:first-of-type:not(.terminal__line--command) {
  font-size: 2rem;
  font-weight: 700;
  color: #00d9ff;
  margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
  text-shadow: 0 0 20px rgba(0, 217, 255, 0.8), 0 0 40px rgba(0, 217, 255, 0.4), 0 0 60px rgba(0, 217, 255, 0.2);
  animation: title-pulse 3s ease-in-out infinite alternate;
}

@keyframes title-pulse {
  0% {
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.8), 0 0 40px rgba(0, 217, 255, 0.4), 0 0 60px rgba(0, 217, 255, 0.2);
  }
  100% {
    text-shadow: 0 0 25px rgba(0, 217, 255, 1), 0 0 50px rgba(0, 217, 255, 0.6), 0 0 75px rgba(0, 217, 255, 0.3);
  }
}

.terminal__preview-image {
  max-width: calc(100% - 7rem);
  border-radius: 12px;
  margin-top: 0.75rem;
  border: 1px solid rgba(221, 232, 247, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  display: block;
}

/* PDF viewer styles */
.pdf-container {
  width: 100%;
  min-height: 10000px; /* Large minimum to show all pages */
  height: 10000px; /* Will be calculated dynamically */
  margin-top: 0.75rem;
  border: 1px solid rgba(221, 232, 247, 0.12);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.pdf-iframe {
  width: 100%;
  height: 100%;
  min-height: 10000px;
  border: none;
  display: block;
}

.terminal__footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.5rem;
  background: var(--color-surface-alt);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.terminal__footer-wrap {
  background: var(--color-surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.terminal__prompt {
  color: var(--color-accent-green);
  font-size: 0.95rem;
}

.terminal__command {
  flex: 1;
  height: 1.3rem;
  display: flex;
  align-items: center;
  column-gap: 0.1rem;
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.3rem;
}

.terminal__buffer,
.terminal__ghost {
  display: inline-flex;
  align-items: center;
  white-space: pre;
  height: 100%;
  line-height: 1.3rem;
}

.terminal__ghost {
  color: rgba(221, 232, 247, 0.35);
}

.terminal__caret {
  display: inline-block;
  width: 2px;
  height: 1.3rem;
  background: transparent;
  border-left: 2px solid rgba(58, 140, 255, 0.9);
  animation: caret-blink 1.1s steps(1) infinite;
}

.terminal__caret--busy {
  animation: caret-run 180ms steps(2) 3;
  border-left-color: rgba(165, 120, 255, 0.9);
}

@keyframes caret-blink {
  0%,
  50% {
    opacity: 1;
  }
  50.01%,
  100% {
    opacity: 0;
  }
}

@keyframes caret-run {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes idle-flicker {
  0%,
  100% {
    opacity: 0;
  }
  50% {
    opacity: 0.08;
  }
}

@media (max-width: 768px) {
  .terminal {
    height: calc(100% - 2.5rem);
    border-radius: 12px;
  }

  .terminal__output {
    padding: 1.25rem 1.25rem;
  }
}

/* Scanline effect for terminal authenticity */
.terminal__output::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255, 255, 255, 0.01) 50%,
    transparent 100%
  );
  background-size: 100% 4px;
  pointer-events: none;
  animation: scanline 8s linear infinite;
  opacity: 0.5;
}

@keyframes scanline {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 100%;
  }
}

/* Subtle screen overlay (flicker removed) */
.terminal__output::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 217, 255, 0.03);
  pointer-events: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .terminal__caret {
    animation: none;
  }

  .terminal::after {
    animation: none;
    opacity: 0;
  }

  .terminal__caret--busy {
    animation: none;
  }

  .terminal__line--command {
    animation: none;
  }

  .terminal__line:first-of-type:not(.terminal__line--command) {
    animation: none;
  }

  .terminal__line--header {
    animation: none;
  }

  .terminal__line--status {
    animation: none;
  }

  .terminal__output::before {
    animation: none;
    opacity: 0;
  }
}
