/* ===================================================================
   selm4n.dev — terminal theme
   All colors/spacing are CSS custom properties so the palette is easy
   to retune from one place.
   =================================================================== */

:root {
  /* palette — near-black navy background, soft off-white text, blue/cyan accents */
  --bg: #05070d;
  --bg-raised: #0a0f1c;
  --fg: #dce6f5;
  --fg-dim: #8b9bc4;
  --accent-blue: #4da3ff;
  --accent-cyan: #5be3ff;
  --accent-error: #ff6b6b;
  --accent-hint: #7fe3b4;
  --accent-amber: #ffd166;
  --selection-bg: rgba(77, 163, 255, 0.35);

  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --content-max-width: 980px;
  --line-height: 1.6;

  --scanline-opacity: 0.06;
  --glow-opacity: 0.5;
}

/* ===================================================================
   Reset & base
   =================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* the terminal itself scrolls, not the page */
}

::selection {
  background: var(--selection-bg);
  color: var(--fg);
}

a {
  color: var(--accent-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(77, 163, 255, 0.5);
}

a:hover,
a:focus-visible {
  color: var(--accent-cyan);
  text-decoration-color: currentColor;
}

button {
  font-family: inherit;
}

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

noscript {
  display: block;
  padding: 2rem;
  color: var(--fg);
  font-family: var(--font-mono);
}

/* ===================================================================
   CRT flourishes — faint, always subordinate to readability, and
   fully disabled under prefers-reduced-motion.
   =================================================================== */

.crt-scanlines,
.crt-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.crt-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--scanline-opacity)) 0px,
    rgba(0, 0, 0, var(--scanline-opacity)) 1px,
    transparent 1px,
    transparent 3px
  );
}

.crt-vignette {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

@media (prefers-reduced-motion: no-preference) {
  .crt-scanlines {
    animation: flicker 6.5s infinite steps(1);
  }
}

@keyframes flicker {
  0%,
  96%,
  100% {
    opacity: 1;
  }
  97% {
    opacity: 0.85;
  }
  98% {
    opacity: 1;
  }
}

/* ===================================================================
   Terminal shell layout
   =================================================================== */

.terminal {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 0.75rem;
}

.terminal::before {
  /* faint blue glow behind the whole terminal, purely decorative */
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 70% 55% at 50% 0%, rgba(77, 163, 255, var(--glow-opacity)) 0%, transparent 60%);
  opacity: 0.08;
  pointer-events: none;
}

.output {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-blue) transparent;
}

.output::-webkit-scrollbar {
  width: 8px;
}

.output::-webkit-scrollbar-thumb {
  background: rgba(77, 163, 255, 0.35);
  border-radius: 4px;
}

.output::-webkit-scrollbar-track {
  background: transparent;
}

/* ===================================================================
   Scrollback content
   =================================================================== */

.line {
  white-space: pre-wrap;
  word-break: break-word;
}

.line.echo {
  margin-top: 0.35rem;
}

.line .prompt {
  color: var(--accent-blue);
  font-weight: 500;
}

.echo-text {
  color: var(--fg);
}

.ctrl-c {
  color: var(--accent-error);
  margin-left: 0.35em;
}

.boot-line {
  color: var(--fg-dim);
}

.block {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0.35rem 0 0.85rem;
}

.block.error {
  color: var(--accent-error);
}

.block.hint {
  color: var(--accent-hint);
}

/* boot banner */

.banner-block {
  margin: 0.5rem 0 0.85rem;
  opacity: 1;
}

.banner-block.fade-in {
  animation: none;
}

@media (prefers-reduced-motion: no-preference) {
  .banner-block.fade-in {
    animation: banner-fade 0.4s ease-out;
  }
}

@keyframes banner-fade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.banner-art {
  margin: 0;
  color: var(--accent-cyan);
  font-size: 0.95em;
  line-height: 1.2;
}

.banner-tagline {
  margin-top: 0.4rem;
  color: var(--fg-dim);
}

/* cat / contact detail blocks */

.cat-block {
  margin: 0.35rem 0 0.85rem;
  max-width: 70ch;
}

.cat-title {
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 1.05em;
}

.cat-rule {
  color: var(--fg-dim);
  opacity: 0.6;
}

.cat-oneliner {
  color: var(--fg-dim);
  font-style: italic;
}

.cat-meta {
  color: var(--fg-dim);
}

.cat-spacer {
  height: 0.6rem;
}

.cat-description {
  white-space: pre-wrap;
}

.cat-row {
  display: flex;
  gap: 0.5em;
}

.cat-label {
  color: var(--accent-blue);
  min-width: 6ch;
  flex: 0 0 auto;
}

.cat-link {
  word-break: break-all;
}

/* ls */

.ls-root {
  display: block;
}

.ls-dir {
  color: var(--accent-blue);
  font-weight: 600;
}

.ls-file {
  color: var(--fg);
}

/* neofetch */

.neofetch {
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
  margin: 0.35rem 0 0.85rem;
}

.nf-art {
  margin: 0;
  color: var(--accent-blue);
  line-height: 1.25;
  flex: 0 0 auto;
}

.nf-info {
  min-width: 18rem;
}

.nf-header {
  color: var(--accent-cyan);
  font-weight: 700;
}

.nf-rule {
  color: var(--fg-dim);
  opacity: 0.6;
}

.nf-row {
  white-space: pre;
}

.nf-label {
  color: var(--accent-blue);
}

.nf-value {
  color: var(--fg);
}

.nf-swatches {
  margin-top: 0.5rem;
  display: flex;
  gap: 4px;
}

.nf-swatch {
  display: inline-block;
  width: 1.4em;
  height: 1em;
  border-radius: 2px;
}

.sw-1 {
  background: var(--bg-raised);
}
.sw-2 {
  background: var(--accent-error);
}
.sw-3 {
  background: var(--accent-hint);
}
.sw-4 {
  background: var(--accent-blue);
}
.sw-5 {
  background: var(--accent-cyan);
}
.sw-6 {
  background: var(--fg);
}

/* ===================================================================
   snake — the `snake` command's game screen
   =================================================================== */

.snake-screen {
  margin: 0.35rem 0 0.85rem;
}

.snake-status {
  margin-bottom: 0.35rem;
}

.snake-message {
  color: var(--accent-cyan);
  font-weight: 700;
}

.snake-message.snake-gameover {
  color: var(--accent-error);
}

@media (prefers-reduced-motion: no-preference) {
  /* Purely cosmetic — the tick loop/timing never checks reduced-motion,
     only this little flourish on the "GAME OVER" text does. */
  .snake-message.snake-gameover {
    animation: snake-gameover-flash 0.5s ease-out;
  }
}

@keyframes snake-gameover-flash {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}

.snake-hint {
  color: var(--fg-dim);
}

.snake-field {
  margin: 0;
  line-height: 1.15;
}

.sk-border {
  color: var(--fg-dim);
}

.sk-head {
  color: var(--accent-cyan);
  font-weight: 700;
}

.sk-body {
  color: var(--accent-blue);
}

.sk-food {
  color: var(--accent-amber);
}

/* ===================================================================
   Live input line — pinned at the bottom
   =================================================================== */

.input-line {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem 0 0.9rem;
  border-top: 1px solid rgba(77, 163, 255, 0.12);
}

.input-line .prompt {
  color: var(--accent-blue);
  font-weight: 500;
  white-space: pre;
  flex: 0 0 auto;
}

.mirror {
  flex: 1 1 auto;
  min-width: 4ch;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
}

.cursor {
  display: inline-block;
  min-width: 0.6ch;
  background: var(--accent-blue);
  color: var(--bg);
}

@media (prefers-reduced-motion: no-preference) {
  .cursor {
    animation: blink 1s step-end infinite;
  }
}

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

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  outline: none;
  opacity: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-family: var(--font-mono);
  font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
  pointer-events: none;
}

/* ===================================================================
   Mobile quick-command chips
   =================================================================== */

.chip-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chip-bar button {
  flex: 0 0 auto;
  background: var(--bg-raised);
  color: var(--accent-cyan);
  border: 1px solid rgba(91, 227, 255, 0.3);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip-bar button:active {
  background: rgba(77, 163, 255, 0.25);
}

.chip-bar button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Swapped out for the snake D-pad while a game is running. */
.chip-bar.snake-hidden {
  display: none !important;
}

@media (hover: none) and (pointer: coarse) {
  .chip-bar {
    display: flex;
  }

  .terminal {
    padding-bottom: 3.5rem; /* keep scrollback clear of the fixed chip bar */
  }
}

/* Fallback for small viewports without reliable pointer:coarse support */
@media (max-width: 640px) {
  .chip-bar {
    display: flex;
  }

  .terminal {
    padding: 1rem 1rem 3.5rem;
  }

  body {
    font-size: 14px;
  }
}

/* ===================================================================
   Snake D-pad — touch controls, shown only while a game is active
   (JS toggles the .active class) and only on coarse-pointer devices.
   =================================================================== */

.snake-dpad {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  grid-template-columns: repeat(3, 3.2rem);
  grid-template-rows: repeat(2, 3.2rem);
  gap: 0.5rem;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  justify-content: center;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  color: var(--accent-cyan);
  border: 1px solid rgba(91, 227, 255, 0.3);
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: rgba(77, 163, 255, 0.25);
}

.dpad-btn:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.dpad-quit {
  color: var(--accent-error);
  border-color: rgba(255, 107, 107, 0.35);
}

.dpad-restart {
  color: var(--accent-hint);
  border-color: rgba(127, 227, 180, 0.35);
}

@media (hover: none) and (pointer: coarse) {
  .snake-dpad.active {
    display: grid;
  }
}

@media (max-width: 640px) {
  .snake-dpad.active {
    display: grid;
  }
}

/* ===================================================================
   Focus visibility (keyboard operability)
   =================================================================== */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
