/* ================================ CSS Reset =============================== */

/*
  Stolen from:
  - https://www.joshwcomeau.com/css/custom-css-reset/
  - https://piccalil.li/blog/a-more-modern-css-reset/
*/

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

@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

h1,
h2,
h3,
h4,
button,
input,
label {
  line-height: 1.1;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin-block-end: 0;
}

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* ========================================================================== */

/* ===== Terminal chrome (wana semantic tokens) ===== */

/* Subset of FiraCode/Symbols Nerd Font: only the git-branch glyph (U+E0A0),
   used for the starship prompt. unicode-range scopes it to that codepoint. */
@font-face {
  font-family: "Nerd Glyphs";
  src: url("fonts/nerd-glyphs.woff") format("woff");
  unicode-range: U+E0A0;
  font-display: swap;
}

:root {
  /* Terminal display font: Fira Code, with a Nerd Font subset for glyphs. */
  --font: "Fira Code", "Nerd Glyphs", var(--font-mono);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  display: flex;
  padding: clamp(0px, 2vmin, 24px);
  transition:
    background var(--duration-base) var(--easing),
    color var(--duration-base) var(--easing);
}

a {
  color: var(--info);
  text-decoration: none;
}
a:hover,
a:focus {
  text-decoration: underline;
}

/* Skip link: visually hidden until keyboard-focused. */
.skip-link {
  position: fixed;
  top: var(--space-s);
  left: var(--space-s);
  z-index: 20;
  padding: var(--space-2xs) var(--space-s);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  transform: translateY(-200%);
}
.skip-link:focus {
  transform: none;
}

/* ============================ Terminal window ============================ */

.terminal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2xs) var(--space-s);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
}
.window-title {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.titlebar-right {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  flex: 0 0 auto;
}
.titlebar-dots {
  color: var(--muted);
  letter-spacing: 0.15em;
}

/* ============================ Tab bar ============================ */

.tabbar {
  display: flex;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem 0;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.4rem 0.8rem;
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* ============================ Screen ============================ */

.screen {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-m);
  line-height: 1.55;
}

.cmd-output {
  margin: 0 0 1.2rem;
  min-width: 0;
}
.cmd-output p {
  margin: 0.15rem 0;
}

/* Wide blocks (tree, ls -l, ascii art) scroll horizontally instead of
   forcing the whole terminal wider than the viewport. */
pre {
  margin: 0.15rem 0;
  max-width: 100%;
  overflow-x: auto;
}
.tree a {
  color: var(--info);
}

/* `ls` lays its entries out in a wrapping grid so they never overflow. */
.ls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.4rem;
}

.green {
  color: var(--accent);
}
.blue {
  color: var(--info);
}
.yellow {
  color: var(--warning);
}
.err {
  color: var(--error);
}
.dim {
  color: var(--muted);
}

.project {
  margin-bottom: 1rem;
}
.project h2 {
  font-size: 1rem;
  margin: 0;
}
.tags {
  color: var(--muted);
  font-size: 0.85rem;
}

/* neofetch easter egg */
.neofetch {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}
.nf-logo {
  color: var(--accent);
  margin: 0;
}
.nf-info {
  margin: 0;
}
.nf-title {
  color: var(--accent);
}
.nf-key {
  color: var(--warning);
}

/* ============================ Prompt ============================ */

/* The prompt is the last line of the scroll log, not a fixed bar. */
.promptbar {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.2rem;
}
.prompt-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.prompt-char {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}
.prompt-char.is-error {
  color: var(--error);
}
.seg-user {
  color: var(--warning);
  font-weight: 700;
}
.seg-op {
  color: var(--muted);
}
.seg-dir {
  color: var(--info);
  font-weight: 700;
}
.seg-git {
  color: var(--magenta);
  font-weight: 700;
}
.cmd {
  color: var(--warning);
}

/* ============================ Theme toggle ============================ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.15rem;
  border-radius: var(--radius);
}
.theme-toggle:hover {
  color: var(--text);
}
.theme-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
/* Show the icon for the active theme (moon = dark, sun = light). */
.icon-sun {
  display: none;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun {
    display: inline-block;
  }
  :root:not([data-theme]) .icon-moon {
    display: none;
  }
}
[data-theme="light"] .icon-sun {
  display: inline-block;
}
[data-theme="light"] .icon-moon {
  display: none;
}
[data-theme="dark"] .icon-sun {
  display: none;
}
[data-theme="dark"] .icon-moon {
  display: inline-block;
}

/* ============================ Shortcut overlay ============================ */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius);
}
.icon-btn:hover {
  color: var(--text);
}
.icon-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-m);
  background: color-mix(in oklch, var(--bg) 70%, transparent);
  z-index: 10;
}
.overlay[hidden] {
  display: none;
}
.overlay-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--overlay);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-m);
}
.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-s);
}
.shortcut-list {
  margin: 0;
  display: grid;
  gap: 0.35rem 0.8rem;
}
.shortcut-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.shortcut-list dt {
  color: var(--warning);
  white-space: nowrap;
}
.shortcut-list dd {
  margin: 0;
  text-align: right;
}
.overlay-foot {
  margin: var(--space-s) 0 0;
  font-size: 0.85rem;
}
.prompt-input {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  caret-color: var(--accent);
}
.prompt-input:focus {
  outline: none;
}

/* blinking inline cursor used during the boot typewriter */
.cursor-inline::after {
  content: "█";
  color: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cursor-inline::after {
    animation: none;
  }
}

/* ============================ Responsive ============================ */

@media (max-width: 600px) {
  body {
    padding: 0;
    font-size: 14px;
  }
  .terminal {
    border: none;
    border-radius: 0;
  }
  .screen {
    padding: var(--space-s);
  }
  .tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
  }
  .prompt-input {
    font-size: 0.9rem;
  }
  /* Wrap long ls -l / tree rows on phones instead of scrolling sideways. */
  pre.long,
  pre.tree {
    white-space: pre-wrap;
    word-break: break-word;
  }
}
