/* ==========================================================================
   blog.th0t3p.com — terminal
   Monochrome: white on black, with the signal colours kept for meaning
   (red errors, green "done", blue links). Hierarchy is carried by
   brightness steps — white accents, light body, grey secondary.
   Two deliberate changes from the original spec, both for accessibility
   (see README):
     --link  is one step lighter than --signal-info, so 14px link text
             clears WCAG AA (4.5:1) against --bg-surface
     --fs-*  is 16px on phones because iOS zooms any focused field below
             16px, which breaks the keyboard experience
     scanlines sit at 2.5% rather than 3% so they stay barely perceptible
   ========================================================================== */

:root {
  /* surfaces */
  --bg-void: #0a0a0b;
  --bg-surface: #111114;
  --bg-raised: #1a1a1f;

  /* text */
  --text-primary: #d9d9d9;
  --text-secondary: #8a8a8e;
  --text-muted: #55555a;

  /* accents — monochrome */
  --accent-primary: #ffffff;
  --accent-dim: #7c7c81;

  /* signals */
  --signal-success: #5c8a6a;
  --signal-danger: #c45c5c;
  --signal-info: #5c7a9a;

  --link: #6b8cb0;
  --border-subtle: rgba(255, 255, 255, 0.06);

  /* spacing scale — 4px base */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --fs-base: 14px;
  --lh: 1.6;
  --measure: 112ch;   /* wide enough for the skills.json rows; prose stays ≤76ch */
  --statusbar-h: 28px;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--bg-raised); color: var(--text-primary); }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* ---------- shell ---------- */

.terminal {
  position: fixed;
  inset: 0 0 var(--statusbar-h) 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-surface);
  padding: var(--sp-6);
  padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom));
  box-shadow: inset 0 0 150px rgba(255, 255, 255, 0.03);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
  -webkit-overflow-scrolling: touch;
}

/* faint scanlines — barely perceptible by design */
.terminal::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025) 0,
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 2px
  );
}

.terminal::-webkit-scrollbar { width: 10px; height: 10px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); }
.terminal::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.14); }

.screen { max-width: var(--measure); }

/* ---------- output ---------- */

.line { white-space: pre-wrap; overflow-wrap: break-word; }
.line--blank { height: 1.6em; }
.line--pre { white-space: pre-wrap; }
.line--listing { padding-left: 2ch; text-indent: -2ch; }
.line--secondary { color: var(--text-secondary); }
.line--accent { color: var(--accent-primary); }
.line--danger { color: var(--signal-danger); }
.line--ok { color: var(--signal-success); }
.dir { color: var(--accent-primary); }
.arrow { color: var(--accent-dim); }

.art {
  margin: 0;
  color: var(--accent-dim);
  /* Whole-pixel sizes only: half-block glyphs tile cleanly when the line
     advance lands on a whole pixel. A vw-based clamp can resolve to
     fractional sizes and leave hairline seams through the letters. */
  font-size: 12px;
  line-height: 1;
  white-space: pre;
  padding-bottom: var(--sp-2);
}

/* ---------- identity block ---------- */

.fetch {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-6);
}

.fetch .art { padding-bottom: 0; }

.fetch__info {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: var(--sp-4);
  row-gap: 2px;
  align-content: start;
}

.fetch__user { grid-column: 1 / -1; color: var(--accent-primary); }
.fetch__rule { grid-column: 1 / -1; color: var(--accent-dim); margin-bottom: var(--sp-1); }
.fetch__key { color: var(--text-secondary); }
.fetch__val { color: var(--text-primary); }

.grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--sp-4);
  row-gap: 2px;
  align-items: baseline;
}
.grid__key { color: var(--accent-primary); }
.grid__val { color: var(--text-secondary); }
.grid--values .grid__val { color: var(--text-primary); }
.grid--history .grid__key { color: var(--text-secondary); white-space: pre; }

/* ---------- prompt ---------- */

.promptline {
  display: flex;
  align-items: baseline;
}
.promptline[hidden] { display: none; }

.prompt { color: var(--accent-primary); white-space: pre; flex: none; }

.inputwrap { position: relative; display: block; flex: 1 1 auto; min-width: 0; }

.input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: inherit;
  line-height: var(--lh);
  caret-color: transparent;
}

.input-mirror {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  white-space: pre;
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: inherit;
  line-height: var(--lh);
  pointer-events: none;
}

.suggest {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--text-muted);
  white-space: pre;
  pointer-events: none;
}
.suggest[hidden] { display: none; }

.caret {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--text-primary);
  pointer-events: none;
  will-change: transform;
  animation: blink 1s steps(1, end) infinite;
}
.caret--typing { animation: none; opacity: 1; }

/* visible focus state: prompt, text and cursor lift to full strength */
.promptline:not(.is-focused) .caret { animation: none; color: var(--accent-dim); }
.promptline:not(.is-focused) .prompt { opacity: 0.6; }
.promptline:not(.is-focused) .input { color: var(--text-secondary); }

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

/* ---------- status bar ---------- */

.statusbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: var(--statusbar-h);
  padding: 0 var(--sp-6);
  background: var(--bg-void);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
}

.statusbar__cell { white-space: nowrap; }
.statusbar__cell--mid {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
}
.statusbar__cell--clock { font-variant-numeric: tabular-nums; }

/* ---------- command palette (touch) ---------- */

.palette-toggle {
  position: fixed;
  right: var(--sp-4);
  bottom: calc(max(var(--sp-4), env(safe-area-inset-bottom)) + var(--statusbar-h));
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: rgba(26, 26, 31, 0.72);
  color: var(--accent-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0.7;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: opacity 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.palette-toggle:hover,
.palette-toggle:focus-visible,
.palette-toggle[aria-expanded='true'] {
  opacity: 1;
  color: var(--accent-primary);
  border-color: rgba(255, 255, 255, 0.35);
}
.palette-toggle:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

@media (hover: none), (max-width: 639px) {
  .palette-toggle { display: inline-flex; }
}

.palette {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-content: end;
  justify-items: center;
  padding: var(--sp-4);
  padding-bottom: calc(max(var(--sp-6), env(safe-area-inset-bottom)) + var(--sp-2));
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease-out, visibility 150ms ease-out;
}
.palette.is-open { opacity: 1; visibility: visible; }

.palette__backdrop { position: absolute; inset: 0; background: rgba(10, 10, 11, 0.72); }

.palette__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  max-height: min(60vh, 460px);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  transform: translateY(8px);
  transition: transform 150ms ease-out;
}
.palette.is-open .palette__panel { transform: none; }

.palette__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}
.palette__title { margin: 0; font-size: var(--fs-base); font-weight: 500; color: var(--text-secondary); }

.palette__close {
  padding: 2px var(--sp-2);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}
.palette__close:hover { color: var(--text-primary); border-color: rgba(255, 255, 255, 0.14); }
.palette__close:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.palette__list {
  margin: 0;
  padding: var(--sp-2) 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.palette__item {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: var(--sp-4);
  width: 100%;
  padding: var(--sp-2) var(--sp-4);
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-base);
  text-align: left;
  cursor: pointer;
}
.palette__item:hover { background: var(--bg-raised); }
.palette__item:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: -2px; background: var(--bg-raised); }
.palette__item .cmd { color: var(--accent-primary); white-space: pre; }
.palette__item .desc { color: var(--text-secondary); }

/* ---------- utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- small screens ---------- */

@media (max-width: 639px) {
  :root {
    --fs-base: 16px;   /* keeps iOS from zooming the input on focus */
    --measure: 100%;
  }
  .terminal {
    padding: var(--sp-4);
    padding-bottom: calc(max(var(--sp-4), env(safe-area-inset-bottom)) + 56px);
  }
  /* cap the label column so values keep room to read instead of breaking
     into slivers on narrow screens */
  .grid { grid-template-columns: fit-content(45%) minmax(0, 1fr); column-gap: var(--sp-3); }

  .statusbar { padding: 0 var(--sp-4); }
  .statusbar__cell--mid { display: none; }
  .art { font-size: 11px; }
  .fetch { flex-direction: column; gap: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .caret { animation: none !important; }
}
