:root {
  --bg: #0b0f0c;
  --bg-2: #0f1511;
  --fg: #cfe8d6;
  --dim: #6f8a78;
  --accent: #39ff88;
  --accent-2: #7cf5ff;
  --warn: #ffd166;
  --err: #ff6b6b;
  --glow: 0 0 6px rgba(57, 255, 136, 0.45);
  --font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="amber"] {
  --bg: #0e0a04;
  --bg-2: #160f06;
  --fg: #f0d9a8;
  --dim: #8f7a52;
  --accent: #ffb000;
  --accent-2: #ffd77a;
  --glow: 0 0 6px rgba(255, 176, 0, 0.45);
}

:root[data-theme="paper"] {
  --bg: #f6f3ea;
  --bg-2: #efeadc;
  --fg: #2a2a26;
  --dim: #7a776d;
  --accent: #1f6feb;
  --accent-2: #b53389;
  --warn: #b26a00;
  --err: #c0392b;
  --glow: none;
}

:root[data-theme="blue"] {
  --bg: #050a14;
  --bg-2: #0a1222;
  --fg: #cbd9ff;
  --dim: #6a7aa8;
  --accent: #7cf5ff;
  --accent-2: #a78bfa;
  --glow: 0 0 6px rgba(124, 245, 255, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at center, var(--bg-2) 0%, var(--bg) 75%);
}

/* CRT overlay */
.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0px, rgba(0, 0, 0, 0.18) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
  opacity: 0.6;
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.6);
}
:root[data-theme="paper"] .crt { display: none; }
:root[data-crt="off"] .crt { display: none; }

.screen {
  flex: 1;
  padding: 24px 16px 96px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  text-shadow: var(--glow);
}

.boot, .output, .prompt { white-space: pre-wrap; word-break: break-word; }

.boot { color: var(--dim); }
.boot .ok { color: var(--accent); }

.line { min-height: 1.55em; }
.line.cmd-echo .ps1 { color: var(--accent); }
.line.cmd-echo .typed { color: var(--fg); }

.muted { color: var(--dim); }
.accent { color: var(--accent); }
.accent-2 { color: var(--accent-2); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.bold { font-weight: 700; }

a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}
a:hover { border-bottom-style: solid; }

.banner {
  color: var(--accent);
  font-size: clamp(7px, 1.6vw, 14px);
  line-height: 1.15;
  margin: 8px 0 12px;
  overflow-x: auto;
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0 16px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; }

.row { display: flex; gap: 16px; }
.row .k { color: var(--accent); min-width: 14ch; }

.neofetch { display: flex; gap: 24px; align-items: flex-start; }
.neofetch pre { margin: 0; color: var(--accent); line-height: 1.1; font-size: 12px; }

.prompt {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.ps1 { color: var(--accent); white-space: nowrap; }
.ps1 .user { color: var(--accent-2); }
.ps1 .host { color: var(--accent); }
.ps1 .cwd { color: var(--warn); }

.cmd {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg);
  font: inherit;
  caret-color: var(--accent);
  text-shadow: inherit;
  padding: 0;
}

/* blinking block cursor substitute when input not focused */
.prompt.idle .cmd { caret-color: transparent; }
.prompt.idle::after {
  content: "";
  width: 0.6em;
  height: 1.1em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
  align-self: center;
  margin-left: -0.3em;
}
@keyframes blink { 50% { opacity: 0; } }

.quick {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  justify-content: center;
  flex-wrap: wrap;
  z-index: 20;
}
.quick button {
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
.quick button:hover { border-color: var(--accent); box-shadow: var(--glow); }

@media (min-width: 900px) {
  .quick { display: none; }
  .screen { padding-bottom: 40px; }
}

/* typewriter */
.typing::after { content: "▌"; color: var(--accent); animation: blink 0.8s steps(1) infinite; }

/* glitch effect used on exit / sudo */
.glitch { animation: glitch 0.35s steps(2) 3; }
@keyframes glitch {
  0% { transform: translate(0); filter: none; }
  25% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
  50% { transform: translate(2px, -1px); filter: invert(0.2); }
  75% { transform: translate(-1px, 2px); }
  100% { transform: translate(0); filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .glitch, .prompt.idle::after, .typing::after { animation: none; }
}

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

@media (max-width: 600px) {
  .row { flex-direction: column; gap: 2px; margin-bottom: 8px; }
  .row .k { min-width: 0; }
  .neofetch { flex-direction: column; gap: 8px; }
}

/* photo: tinted to the active theme, true colour on hover */
.avatar, .photo img {
  display: block;
  object-fit: cover;
  border: 1px solid var(--dim);
  border-radius: 4px;
  filter: grayscale(1) contrast(1.1) brightness(0.95) sepia(1) hue-rotate(70deg) saturate(2.2);
  transition: filter 0.4s ease;
  text-shadow: none;
}
:root[data-theme="amber"] .avatar, :root[data-theme="amber"] .photo img { filter: grayscale(1) sepia(1) saturate(2.5) brightness(0.95); }
:root[data-theme="blue"] .avatar, :root[data-theme="blue"] .photo img { filter: grayscale(1) sepia(1) hue-rotate(150deg) saturate(2.2); }
:root[data-theme="paper"] .avatar, :root[data-theme="paper"] .photo img { filter: none; }
.avatar:hover, .photo img:hover { filter: none; }
.avatar { width: 160px; height: 200px; flex-shrink: 0; }
.photo { margin: 4px 0; }
.photo img { width: 240px; height: 300px; max-width: 100%; }
.photo figcaption { margin-top: 6px; }

/* Arabic poetry: classical two-hemistich layout */
.poem {
  font-family: "Amiri", "Noto Naskh Arabic", serif;
  font-size: 1.35em;
  line-height: 2;
  color: var(--accent);
  border-right: 2px solid var(--accent);
  padding: 4px 16px;
  margin: 4px 0;
  max-width: 640px;
}
.poem .bayt { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2.5em; }
.poem .poet { font-size: 0.75em; color: var(--dim); margin-top: 4px; }
.poem .poet::before { content: "— "; }
@media (max-width: 600px) {
  .poem .bayt { grid-template-columns: 1fr; margin-bottom: 8px; }
}
.ar { font-family: "Amiri", "Noto Naskh Arabic", serif; font-size: 1.2em; }

/* overview: profile as code */
.overview { display: flex; gap: 24px; align-items: flex-start; margin: 4px 0 8px; }
.overview .code { min-width: 0; overflow-x: auto; }
.c-kw { color: var(--accent-2); }
.c-var { color: var(--fg); font-weight: 700; }
.c-key { color: var(--accent); }
.c-str { color: var(--warn); }
.c-com { color: var(--dim); font-style: italic; }
.c-str a { color: var(--accent-2); }
.c-cmd {
  font: inherit;
  color: var(--accent-2);
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: 4px;
  padding: 0 8px;
  margin: 2px 2px 2px 0;
  cursor: pointer;
  text-shadow: inherit;
}
.c-cmd:hover, .c-cmd:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
@media (max-width: 760px) {
  .overview { flex-direction: column; gap: 12px; }
  .overview .avatar { width: 120px; height: 150px; }
  .overview .code { white-space: pre-wrap; font-size: 13px; }
}
.overview .ln { padding-left: calc((var(--i) + 4) * 1ch); text-indent: -4ch; }

/* ghost-text autocomplete */
.input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.input-wrap .cmd { position: relative; z-index: 1; width: 100%; }
.ghost {
  position: absolute; inset: 0;
  color: var(--dim); opacity: 0.7;
  white-space: pre; overflow: hidden; pointer-events: none;
  text-shadow: none; direction: ltr; text-align: left;
}
.ghost-typed { color: transparent; }

