/* jeremybrice.com: Linux (GNOME / Ubuntu) terminal-style landing and error pages.
   No external resources. The terminal window keeps its dark palette in both themes,
   as a real terminal does; only the page around it follows the system theme. */

:root {
  /* Page */
  --page: #121212;
  --foot: #8a8a8a;

  /* Window chrome (Adwaita / Yaru dark header bar) */
  --bar: #303030;
  --bar-text: #e6e6e6;
  --btn-bg: rgba(255, 255, 255, 0.10);
  --btn-bg-hover: rgba(255, 255, 255, 0.18);
  --btn-icon: #e6e6e6;
  --border: #1b1b1b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);

  /* Terminal (Ubuntu aubergine with the Tango palette) */
  --term: #300a24;
  --text: #eeeeec;
  --muted: #a8a49f;
  --prompt: #8ae234;
  --path: #729fcf;
  --accent: #ad7fa8;
  --error: #ef2929;
  --cursor: #eeeeec;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --page: #f2f2f2;
    --foot: #6a6a6a;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.08);
    color-scheme: light;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem 16px;
  background: var(--page);
  color: var(--text);
  font-family: "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Noto Sans Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 16px;
  line-height: 1.5;
}

/* ---- Window ------------------------------------------------------------------------------ */

.term {
  width: 100%;
  max-width: 740px;
  background: var(--term);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.term-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 46px;
  padding: 0 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
  font-family: "Ubuntu", "Cantarell", "Noto Sans", "DejaVu Sans", system-ui, sans-serif;
}

.term-title {
  position: absolute;
  left: 112px;
  right: 112px;
  text-align: center;
  color: var(--bar-text);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-btns {
  display: flex;
  gap: 12px;
}

/* GNOME-style round window controls drawn in CSS: minimize, maximize, close. */
.wbtn {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--btn-bg);
}

.wbtn::before,
.wbtn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: var(--btn-icon);
}

.wbtn-min::before {
  width: 8px;
  height: 2px;
  transform: translate(-50%, 2px);
}

.wbtn-max::before {
  width: 8px;
  height: 8px;
  background: transparent;
  border: 1.5px solid var(--btn-icon);
  border-radius: 1px;
  transform: translate(-50%, -50%);
}

.wbtn-close::before,
.wbtn-close::after {
  width: 10px;
  height: 1.75px;
  border-radius: 1px;
}

.wbtn-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.wbtn-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* Narrow screens: keep the title readable by dropping the left inset. */
@media (max-width: 480px) {
  .term-title {
    left: 12px;
    text-align: left;
  }
}

/* ---- Terminal body ----------------------------------------------------------------------- */

.term-body {
  margin: 0;
  padding: 10px 12px 16px;
  /* Source newlines between .line blocks are collapsed; each .line keeps its own spacing. */
  white-space: normal;
  overflow-wrap: anywhere;
  font: inherit;
}

.line {
  display: block;
  white-space: pre-wrap;
}

.gap {
  display: block;
  height: 0.5em;
}

.ps1-user { color: var(--prompt); font-weight: 700; }
.ps1-path { color: var(--path); font-weight: 700; }
.out { color: var(--text); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.err { color: var(--error); font-weight: 700; }

.code {
  font-size: clamp(2.5rem, 12vw, 4.5rem);
  line-height: 1.1;
  font-weight: 700;
  color: var(--error);
  letter-spacing: 0.04em;
}

a {
  color: var(--path);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
  color: var(--accent);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Block cursor. The static pages use an empty span; the interactive prompt puts the
   character under the cursor inside it, shown inverted like a real terminal. */
.cursor {
  background: var(--cursor);
  color: var(--term);
  animation: blink 1.1s steps(1, end) infinite;
}

.cursor:empty {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% {
    background: transparent;
    color: var(--text);
  }
}

/* Solid while keys are pressed, blinking again once typing stops. The blink deliberately
   ignores prefers-reduced-motion: it is a steady on/off cursor, as in a real terminal. */
.term.typing .cursor {
  animation: none;
}

/* ---- Interactive prompt (assets/term.js) ------------------------------------------------- */

.term.interactive {
  cursor: text;
}

.live {
  position: relative;
}

.typed {
  color: var(--text);
}

/* While a command runs, the prompt line keeps its space but shows nothing. */
.live.running {
  color: transparent;
}

.live.running span {
  visibility: hidden;
}

/* The real input is invisible and receives focus from a click anywhere in the window.
   16px keeps iOS from zooming on focus. */
.term-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  pointer-events: none;
  outline: none;
}

/* Reverse-i-search label and other prompt text. */
.ps1 {
  white-space: pre-wrap;
}

/* ---- Command output helpers (assets/term.js) --------------------------------------------- */

/* Big text and the train keep their shape; they scroll sideways rather than wrap. */
.pre {
  white-space: pre;
  overflow-x: auto;
}

/* Full-screen commands (top, cmatrix, sl) are clipped to the window, like a real terminal. */
.screen {
  white-space: pre;
  overflow: hidden;
}

/* Measures the character width; never visible. */
.probe {
  position: absolute;
  visibility: hidden;
  white-space: pre;
}

.inv { background: var(--text); color: var(--term); }
.hit { color: var(--error); font-weight: 700; }
.grep-n { color: var(--prompt); }
.bold { font-weight: 700; }

/* lolcat */
.rb0 { color: #ff5f5f; }
.rb1 { color: #ff8f3f; }
.rb2 { color: #ffbf3f; }
.rb3 { color: #e5e53f; }
.rb4 { color: #9fe53f; }
.rb5 { color: #4fe56f; }
.rb6 { color: #3fe5b5; }
.rb7 { color: #3fcfe5; }
.rb8 { color: #4f9fff; }
.rb9 { color: #7f7fff; }
.rb10 { color: #b56fff; }
.rb11 { color: #ef5fd5; }

/* cmatrix */
.mx { color: #22c55e; }
.mx-dim { color: #15803d; }
.mx-head { color: #eaffea; text-shadow: 0 0 6px #4ade80; }

/* ---- Themes ("theme <name>"); the window chrome stays as it is ---------------------------- */

.term.theme-green {
  --term: #0b120b;
  --text: #33ff66;
  --muted: #1fa045;
  --prompt: #7dffa0;
  --path: #33ff66;
  --accent: #a6ffbe;
  --error: #c8ffd6;
  --cursor: #33ff66;
}

.term.theme-amber {
  --term: #140c00;
  --text: #ffb000;
  --muted: #b37a00;
  --prompt: #ffc94d;
  --path: #ffb000;
  --accent: #ffd98a;
  --error: #ffe6b3;
  --cursor: #ffb000;
}

.term.theme-solarized {
  --term: #002b36;
  --text: #93a1a1;
  --muted: #657b83;
  --prompt: #859900;
  --path: #268bd2;
  --accent: #d33682;
  --error: #dc322f;
  --cursor: #93a1a1;
}

.term.theme-halloween {
  --term: #1a0d1f;
  --text: #f5e6d3;
  --muted: #a8957f;
  --prompt: #ff7518;
  --path: #b084f5;
  --accent: #8fd14f;
  --error: #ff3b3b;
  --cursor: #ff7518;
}

/* ---- CRT mode (unlocked with the Konami code) -------------------------------------------- */

.term.crt {
  border-radius: 18px;
}

.term.crt .term-body {
  position: relative;
  text-shadow: 0 0 2px currentColor, 0 0 8px rgba(255, 255, 255, 0.12);
}

/* Scanlines */
.term.crt .term-body::before,
.term.crt .term-body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.term.crt .term-body::before {
  background: repeating-linear-gradient(to bottom,
    rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.32) 2px, rgba(0, 0, 0, 0.32) 4px);
}

/* Vignette */
.term.crt .term-body::after {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.45) 100%);
}

@media (prefers-reduced-motion: no-preference) {
  .term.crt .term-body { animation: crt-flicker 5s infinite; }
  .term.crt-boot .term-body { animation: crt-boot 0.6s ease-out; }
}

@keyframes crt-flicker {
  0%, 46%, 49%, 76%, 79%, 100% { opacity: 1; }
  47% { opacity: 0.93; }
  77% { opacity: 0.97; }
}

@keyframes crt-boot {
  0% { transform: scale(0.6, 0.005); filter: brightness(3); }
  40% { transform: scale(1, 0.005); filter: brightness(2); }
  100% { transform: none; filter: none; }
}

/* ---- "exit": fade to black, then reconnect ----------------------------------------------- */

.term {
  transition: background-color 0.8s ease;
}

.term-body {
  transition: opacity 0.8s ease;
}

.term.disconnected {
  background: #000;
}

.term.disconnected .term-body {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .term,
  .term-body {
    transition: none;
  }
}

.foot {
  color: var(--foot);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .term-body { padding: 8px 10px 14px; }
}
