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

/* === Base === */
html, body {
  height: 100%;
  background-color: var(--body-bg, #111111);
  color: var(--text-color);
  font-family: 'JetBrains Mono', 'Courier New', Courier, monospace;
  font-size: 16px;
  line-height: 1.6;
}

/* === Terminal Container === */
#terminal {
  max-width: 850px;
  height: calc(100vh - 64px);
  margin: 32px auto;
  background-color: var(--bg-color);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

/* === Title Bar === */
#title-bar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background-color: var(--titlebar-bg, var(--selection-color));
  flex-shrink: 0;
  user-select: none;
}

.title-bar-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot-red { background-color: #ff5f57; }
.dot-yellow { background-color: #febc2e; }
.dot-green { background-color: #28c840; }

.title-bar-text {
  flex: 1;
  text-align: center;
  font-size: 0.8em;
  color: var(--text-color);
  opacity: 0.6;
  margin-right: 52px; /* offset for dot width to center text */
}

/* === Terminal Body (scrollable area) === */
#terminal-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-color: var(--selection-color) var(--bg-color);
  scrollbar-width: thin;
}

/* === Terminal Content === */
#output,
#input-line {
  margin-left: 24px;
  margin-right: 24px;
}

#output {
  padding-top: 16px;
}

/* === Output Sections === */
.output-section {
  margin: 8px 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.output-command {
  display: flex;
  gap: 8px;
}

/* === Input Line === */
#input-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  padding-bottom: 24px;
}

/* === Prompt === */
.prompt {
  white-space: nowrap;
  color: var(--text-color);
}

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

/* === Command Text (in output) === */
.command-text {
  color: var(--input-color);
  min-width: 0;
  word-wrap: break-word;
}

/* === Custom Block Cursor === */
#input-wrapper {
  position: relative;
  flex: 1;
}

#command-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font: inherit;
  color: var(--input-color);
  caret-color: transparent;
}

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

#cursor-block {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  pointer-events: none;
  background-color: var(--accent-color);
  opacity: 0.7;
  height: 1.2em;
  width: 0.6em;
  animation: blink 1s step-end infinite;
}

/* Normal mode: solid, no blink */
#cursor-block.normal {
  animation: none;
  opacity: 0.7;
}

/* === Vim Mode Indicator === */
#vim-mode {
  color: var(--accent-color);
  font-size: 0.85em;
  white-space: nowrap;
}

/* === Links === */
a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* === Selection === */
::selection {
  background-color: var(--selection-color);
}

/* === Scrollbar === */
#terminal-body::-webkit-scrollbar {
  width: 8px;
}

#terminal-body::-webkit-scrollbar-track {
  background: var(--bg-color);
}

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

#terminal-body::-webkit-scrollbar-thumb:hover {
  background: var(--prompt-color);
}

/* === ASCII Art === */
.ascii-art {
  color: var(--accent-color);
  font-size: 0.85em;
}

/* === Welcome Typing Animation === */
.typing-line {
  opacity: 0;
  transition: opacity 0.1s ease-in;
}

.typing-line.visible {
  opacity: 1;
}

/* === Responsive === */
@media (max-width: 768px) {
  html, body {
    font-size: 14px;
  }

  #terminal {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    height: 100vh;
  }

  #output,
  #input-line {
    margin-left: 16px;
    margin-right: 16px;
  }
}
