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

/* === theme tokens === */
:root,
[data-theme="dark"] {
  --bg: #1e1e2e;
  --bg-elev: #181825;
  --fg: #cdd6f4;
  --muted: #6c7086;
  --accent: #89b4fa;
  --green: #a6e3a1;
  --red: #f38ba8;
  --mauve: #cba6f7;
  --yellow: #f9e2af;
  --prompt: #cba6f7;
  --link: #89b4fa;
  --title-bar: #313244;
  --border: #45475a;
}

[data-theme="light"] {
  --bg: #eff1f5;
  --bg-elev: #e6e9ef;
  --fg: #4c4f69;
  --muted: #6c6f85;
  --accent: #1e66f5;
  --green: #40a02b;
  --red: #d20f39;
  --mauve: #8839ef;
  --yellow: #df8e1d;
  --prompt: #8839ef;
  --link: #1e66f5;
  --title-bar: #ccd0da;
  --border: #bcc0cc;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #eff1f5;
    --bg-elev: #e6e9ef;
    --fg: #4c4f69;
    --muted: #6c6f85;
    --accent: #1e66f5;
    --green: #40a02b;
    --red: #d20f39;
    --mauve: #8839ef;
    --yellow: #df8e1d;
    --prompt: #8839ef;
    --link: #1e66f5;
    --title-bar: #ccd0da;
    --border: #bcc0cc;
  }
}

/* === base === */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 2rem 1rem;
}

a { color: var(--link); }
a:hover { text-decoration: underline; }
code { color: var(--green); }
em { color: var(--mauve); font-style: normal; }

/* === fallback (no JS) layout === */
#content {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.bio-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2rem;
}

.bio-header img {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.bio-header h1 {
  margin: 1rem 0 0.25rem;
  color: var(--accent);
}

.tagline { color: var(--muted); margin: 0; }

#content section { margin-bottom: 2rem; }
#content h2 { color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
#content article { margin-bottom: 1rem; }
#content article h3 { margin: 0.5rem 0 0.25rem; }
#content ul { padding-left: 1.5rem; }

/* === terminal (visible only when JS unhides) === */
#terminal {
  max-width: 900px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 80vh;
  max-height: 90vh;
}

.title-bar {
  background: var(--title-bar);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.traffic-lights { display: flex; gap: 6px; }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red    { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green  { background: #27c93f; }

.title-bar .title { flex: 1; text-align: center; }
.title-bar .fish-version { color: var(--muted); }

#transcript {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

#transcript .line { margin: 0; }
#transcript .cmd-line .prompt { color: var(--prompt); }
#transcript .cmd-line .cmd { color: var(--fg); }
#transcript .output { color: var(--fg); }
#transcript .output.error { color: var(--red); }
#transcript .output a { color: var(--link); }
#transcript .ascii { line-height: 1; font-size: 12px; }

#prompt-form {
  display: flex;
  align-items: center;
  padding: 0.25rem 1rem 0.75rem;
  position: relative;
}

.prompt-label { color: var(--prompt); white-space: pre; }

#prompt-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  caret-color: var(--accent);
  z-index: 1;
}

#prompt-form { position: relative; }
#autosuggest {
  position: absolute;
  top: 0.25rem;
  left: 0;
  right: 0;
  padding: 0 1rem;
  padding-left: calc(1rem + 2ch); /* 2ch = '~ ' label width */
  color: var(--muted);
  pointer-events: none;
  white-space: pre;
  z-index: 0;
}

#pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

#pills button {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

#pills button:hover,
#pills button:focus-visible {
  background: var(--title-bar);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* === JS-active: visually hide fallback (kept in DOM for Reader/SEO/a11y), show terminal === */
html.js-active #content {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html.js-active #terminal { display: flex; }

/* override the bare `hidden` attribute when JS activates */
html.js-active #terminal[hidden] { display: flex; }

/* === blinking cursor (rendered into transcript when input idle) === */
@keyframes blink {
  0%, 50%   { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
.cursor {
  display: inline-block;
  width: 0.6ch;
  background: var(--fg);
  color: var(--bg);
  animation: blink 1s steps(1) infinite;
}

/* === responsive === */
@media (max-width: 600px) {
  body { padding: 0; }
  #terminal {
    max-width: 100%;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  #content {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
