/* ---------- themes ---------- */
:root {
  --fg: #5cff9d;
  --bg: #020a05;
  --dim: color-mix(in srgb, var(--fg) 58%, transparent);
  --faint: color-mix(in srgb, var(--fg) 18%, transparent);
  --glow: color-mix(in srgb, var(--fg) 55%, transparent);
  --warn: #ffd166;
  --err: #ff6b6b;
  --radius: 18px;
}
[data-theme="amber"] { --fg: #ffb641; --bg: #0b0602; --warn: #fff1a8; }
[data-theme="ice"]   { --fg: #7fdcff; --bg: #020810; }
[data-theme="white"] { --fg: #e6efe9; --bg: #08090a; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #000; }
body {
  font-family: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  font-size: clamp(13px, 0.55vw + 10px, 16px);
  line-height: 1.55;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--fg); color: var(--bg); text-shadow: none; }
.dim { color: var(--dim); }
a { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
a:hover, a:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }

/* ---------- crt ---------- */
.crt {
  position: fixed;
  inset: 0;
  padding: clamp(0px, 1.6vw, 22px);
  background: radial-gradient(ellipse at center, #111 0%, #000 75%);
}
.screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--fg) 6%, var(--bg)) 0%, var(--bg) 75%);
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, .85),
    0 0 0 1px var(--faint),
    0 0 50px color-mix(in srgb, var(--fg) 10%, transparent);
  text-shadow: 0 0 1px var(--fg), 0 0 7px var(--glow);
  animation: power-on .55s cubic-bezier(.2, .8, .2, 1) both, flicker 7s infinite 1s;
}
/* scanlines + vignette */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, .28) 0 1px, transparent 1px 3px);
}
/* slow rolling refresh band */
.screen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -30%;
  height: 30%;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--fg) 5%, transparent), transparent);
  animation: roll 9s linear infinite;
}
.no-crt .screen { text-shadow: none; animation: none; }
.no-crt .screen::before, .no-crt .screen::after { display: none; }

@keyframes power-on {
  0%   { transform: scale(1, .004); filter: brightness(4); opacity: .2; }
  45%  { transform: scale(1, .004); filter: brightness(4); opacity: 1; }
  100% { transform: scale(1, 1);    filter: brightness(1); }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 1; }
  48% { opacity: .93; }
  49% { opacity: 1; }
  82% { opacity: .97; }
  83% { opacity: 1; }
}
@keyframes roll { to { top: 100%; } }

/* ---------- chrome ---------- */
.statusbar, .chips {
  display: flex;
  align-items: center;
  gap: .6rem 1rem;
  padding: .55rem 1.25rem;
  font-size: .85em;
}
.statusbar { justify-content: space-between; border-bottom: 1px solid var(--faint); }
.chips { flex-wrap: wrap; border-top: 1px solid var(--faint); }
.chips button {
  font: inherit;
  color: var(--fg);
  text-shadow: inherit;
  background: transparent;
  border: 1px solid var(--faint);
  border-radius: 4px;
  padding: .1rem .7rem;
  cursor: pointer;
}
.chips button:hover, .chips button:focus-visible {
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

/* ---------- terminal ---------- */
.term {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
  cursor: text;
}
.line { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.55em; }
.ok   { color: var(--fg); font-weight: 700; }
.warn { color: var(--warn); }
.err  { color: var(--err); }
.b    { font-weight: 700; }

.prompt { display: flex; gap: 1ch; }
.prompt[hidden] { display: none; }
.ps1 { font-weight: 700; white-space: nowrap; }
.input-wrap { position: relative; flex: 1; min-width: 0; }
.mirror { white-space: pre-wrap; overflow-wrap: anywhere; }
.input-wrap input {
  position: absolute;
  inset: 0;
  width: 100%;
  font-size: 16px; /* no iOS zoom */
  opacity: 0;
  border: 0;
  padding: 0;
  background: transparent;
  caret-color: transparent;
}
.cursor {
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
  box-shadow: 0 0 8px var(--glow);
  animation: blink 1.05s steps(1) infinite;
}
.prompt:not(.focused) .cursor {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 0 0 1px var(--fg);
  animation: none;
}
@keyframes blink { 50% { background: transparent; color: inherit; box-shadow: none; } }

/* ---------- neofetch ---------- */
.fetch {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 2.5rem;
  align-items: center;
  margin: .4rem 0 1rem;
}
.avatar svg {
  display: block;
  width: clamp(110px, 16vw, 170px);
  height: auto;
  color: var(--fg);
  filter: drop-shadow(0 0 4px var(--glow));
}
/* mask on the inner span, glow on the wrapper, so the mask doesn't clip the glow */
.avatar.photo {
  width: clamp(170px, 22vw, 260px);
  filter: drop-shadow(0 0 4px var(--glow));
}
.avatar.photo span {
  display: block;
  aspect-ratio: 1;
  background: var(--fg);
  mask: url(../img/avatar.png) center / contain no-repeat luminance;
}
.avatar .face-fill { fill: currentColor; fill-opacity: .1; }
.avatar .hair { stroke-width: 1.6; opacity: .7; }
.avatar .eyes { transform-origin: 60px 63.5px; animation: eye-blink 6s infinite; }
.avatar .beard { transform-origin: 60px 84px; animation: sway 5s ease-in-out infinite; }
.avatar .glint { opacity: 0; animation: glint 7s ease-in-out infinite 2s; }
@keyframes eye-blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes sway { 0%, 100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.2deg); } }
@keyframes glint { 0%, 88%, 100% { opacity: 0; } 92% { opacity: 1; } }

.kv .line { min-height: 0; }
.kv .k { font-weight: 700; display: inline-block; min-width: 10ch; }
.kv .title { font-weight: 700; }
.bar { letter-spacing: -.05em; }
.swatches { margin-top: .5rem; display: flex; gap: 0; }
.swatches span { width: 3ch; height: 1.2em; background: var(--fg); box-shadow: 0 0 6px var(--glow); }

/* ---------- apps ---------- */
.app {
  display: grid;
  grid-template-columns: 10ch 10ch minmax(14ch, max-content) 1fr;
  gap: 2ch;
  padding: 0 .4ch;
  margin: 0 -.4ch;
  text-decoration: none;
}
.app .name { font-weight: 700; }
.app .desc, .app .perm { color: var(--dim); }
.app:hover .desc, .app:focus-visible .desc, .app:hover .perm, .app:focus-visible .perm { color: var(--bg); }

.help { display: grid; grid-template-columns: max-content 1fr; gap: 0 3ch; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .crt { padding: 0; }
  .screen { border-radius: 0; }
  .term { padding: .8rem .9rem 1.2rem; }
  .statusbar, .chips { padding: .5rem .9rem; }
  .fetch { grid-template-columns: 1fr; }
  .app { grid-template-columns: 10ch 1fr; gap: 0 1.5ch; }
  .app .perm { display: none; }
  .app .desc { grid-column: 1 / -1; padding-left: 0; }
  .help { grid-template-columns: 1fr; }
  .help .dim { padding-left: 2ch; margin-bottom: .3em; }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .screen::after, .cursor, .avatar * { animation: none !important; }
  .screen::after { display: none; }
}
