/* ───────────────────────────────────────────
   Terminal CSS – retro green-on-black theme
   ─────────────────────────────────────────── */

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

/* Color values here are fallbacks matching the default theme (config.defaultTheme).
   They are overridden at runtime by js/themes.js when a theme is applied. */
:root {
  --bg: #0a0a0a;
  --bg-outer: #1a1a2e;
  --fg: #33ff33;
  --fg-dim: #1a9e1a;
  --fg-bright: #66ff66;
  --accent: #00ccff;
  --error: #ff4444;
  --font: "Courier New", "Lucida Console", Monaco, monospace;
  --font-size: 15px;
  --line-height: 1.5;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* ── Terminal container ── */

#terminal {
  width: 100%;
  height: 100%;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-dim) var(--bg);
}

/* ── Output area ── */

#output {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding-bottom: 4px;
}

#terminal::-webkit-scrollbar {
  width: 6px;
}

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

#terminal::-webkit-scrollbar-thumb {
  background: var(--fg-dim);
  border-radius: 3px;
}

/* Output line types */

#output .line {
  margin: 0;
  padding: 0;
}

#output .prompt-echo {
  color: var(--fg-dim);
}

#output .command-echo {
  color: var(--fg-bright);
}

#output .result {
  color: var(--fg);
}

#output .error {
  color: var(--error);
}

#output .accent {
  color: var(--accent);
}

#output .dim {
  color: var(--fg-dim);
}

#output .bright {
  color: var(--fg-bright);
}

/* Render HTML content inside results */
#output .result h2 {
  color: var(--accent);
  margin-bottom: 0.3em;
  font-size: 1.1em;
}

#output .result h3 {
  color: var(--fg-bright);
  margin-bottom: 0.2em;
  font-size: 1em;
}

#output .result p {
  margin-bottom: 0.5em;
}

#output .result a {
  color: var(--accent);
  text-decoration: underline;
}

#output .result ul, #output .result ol {
  margin-left: 1.5em;
  margin-bottom: 0.5em;
}

#output .result hr {
  border: none;
  border-top: 1px solid var(--fg-dim);
  margin: 0.5em 0;
}

/* ── Input line ── */

#input-line {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 4px 0;
}

#prompt {
  color: var(--fg-dim);
  white-space: nowrap;
  user-select: none;
}

#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg-bright);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  caret-color: var(--fg-bright);
}

/* Blinking caret animation override for browsers that support it */
@supports (caret-color: var(--fg-bright)) {
  #input {
    animation: blink-caret 1s step-end infinite;
  }
}

@keyframes blink-caret {
  50% { caret-color: transparent; }
}

/* ── Tab-completion hint ── */

#input-line .tab-hint {
  color: var(--fg-dim);
  font-style: italic;
  margin-left: 0.5em;
  white-space: nowrap;
}

/* ── Responsive ── */

@media (max-width: 600px) {
  :root {
    --font-size: 12px;
  }

  #terminal {
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  /* Prevent iOS zoom on input focus — must be >= 16px */
  #input {
    font-size: 16px;
  }

  #prompt {
    font-size: 12px;
  }

  #input-line {
    padding: 6px 0;
    min-height: 44px;
  }
}

@media (max-width: 400px) {
  :root {
    --font-size: 10px;
  }

  #input {
    font-size: 16px;
  }

  #prompt {
    font-size: 10px;
  }

  #terminal {
    padding: 4px 6px;
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }

  #input-line {
    min-height: 44px;
  }
}

/* ── Selection color ── */
::selection {
  background: var(--fg-dim);
  color: var(--bg);
}
