:root {
  --bg: #050805;
  --bg-screen: #0a0f0a;
  --titlebar: #0e160e;
  --titlebar-text: #4f8f63;
  --fg: #b9f5c9;
  --dim: #4d8761;
  --accent: #39ff8a;
  --accent-2: #d97757;
  --green: #39ff8a;
  --cyan: #46e0d0;
  --yellow: #d9e36a;
  --blue: #59c9ff;
  --magenta: #c08fd6;
  --red: #ff5f6d;
  --selection: rgba(var(--glow-rgb), 0.28);
  --border: #1c3322;
  --glow-rgb: 57, 255, 138;
  --glow: 0 0 6px rgba(var(--glow-rgb), 0.35);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.7), 0 0 60px rgba(var(--glow-rgb), 0.06);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="amber"] {
  --bg: #0a0703; --bg-screen: #0f0a04; --titlebar: #160f06;
  --titlebar-text: #8f6d3f; --fg: #ffd9a0; --dim: #966f3a;
  --accent: #ffb000; --green: #ffb000; --cyan: #ffcf6a;
  --blue: #ffc24d; --border: #33260f; --selection: rgba(255, 176, 0, 0.28);
  --glow-rgb: 255, 176, 0;
}
:root[data-theme="coral"] {
  --bg: #14110f; --bg-screen: #1a1714; --titlebar: #221d19;
  --titlebar-text: #9a8e84; --fg: #ede4dc; --dim: #998a7e;
  --accent: #d97757; --green: #cc9b7a; --cyan: #c9a98f;
  --blue: #c2a896; --border: #332a23; --selection: rgba(217, 119, 87, 0.30);
  --glow-rgb: 217, 119, 87;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 700px at 70% -10%, #0c1f12 0%, transparent 60%),
    radial-gradient(900px 600px at 0% 110%, #08160e 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 3vw, 40px);
  gap: 14px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); }

#matrix {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.42;
  pointer-events: none;
}
.terminal, .hint { position: relative; z-index: 1; }

:root.no-fx #matrix,
:root.no-fx .terminal::after,
:root.no-fx .terminal::before { display: none !important; }
:root.no-fx .screen,
:root.no-fx .banner,
:root.no-fx .reveal { text-shadow: none !important; animation: none !important; }

@keyframes lineReveal {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: none; }
}
.reveal { animation: lineReveal 0.16s ease both; }

.copyable {
  cursor: pointer;
  color: var(--cyan);
  border-bottom: 1px dotted var(--cyan);
}
.copyable:hover { color: var(--accent); border-bottom-color: var(--accent); }
.copyable::after { content: " ⧉"; opacity: 0.6; font-size: 0.85em; }
.copyable.copied { border-bottom-color: transparent; }
.copyable.copied::after { content: none; }

.terminal {
  position: relative;
  width: min(960px, 100%);
  height: min(680px, 86vh);
  display: flex;
  flex-direction: column;
  background: var(--bg-screen);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0.18) 3px
    ),
    radial-gradient(120% 120% at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
  background-size: 100% 3px, 100% 100%;
  mix-blend-mode: multiply;
  animation: crtflicker 6s steps(60) infinite;
}
@keyframes crtflicker {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.7; }
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(var(--titlebar), #060c07);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.lights { display: flex; gap: 8px; }
.light { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.light.red { background: #ff5f57; }
.light.yellow { background: #febc2e; }
.light.green { background: #28c840; }
.title {
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  color: var(--titlebar-text);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.titlebar-right { color: var(--dim); font-size: 13px; width: 40px; text-align: right; }

.quicknav {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 8px 12px;
  background: rgba(8, 16, 10, 0.6);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.quicknav::-webkit-scrollbar { height: 0; }
.navchip {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color .12s, border-color .12s, box-shadow .12s;
}
.navchip:hover, .navchip:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--glow);
  outline: none;
}
.navchip::before { content: "› "; opacity: 0.6; }

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 0;
  outline: none;
  text-shadow: 0 0 4px rgba(var(--glow-rgb), 0.18);
}
.screen:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.terminal::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -140px;
  height: 140px;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(180deg, transparent, rgba(var(--glow-rgb), 0.05), transparent);
  animation: scanbeam 7s linear infinite;
}
@keyframes scanbeam {
  0% { top: -140px; }
  100% { top: 100%; }
}

#output {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  white-space: pre-wrap;
  word-break: break-word;
  padding-bottom: 6px;
  user-select: text;
  -webkit-user-select: text;
}
#output::-webkit-scrollbar { width: 10px; }
#output::-webkit-scrollbar-track { background: transparent; }
#output::-webkit-scrollbar-thumb { background: #1f4a30; border-radius: 8px; }
#output::-webkit-scrollbar-thumb:hover { background: #2c6b44; }

.line { white-space: pre-wrap; word-break: break-word; }
.block { margin: 2px 0 12px; }

.prompt { white-space: nowrap; }
.user { color: var(--green); font-weight: 500; }
.colon { color: var(--dim); }
.path { color: var(--blue); }
.dollar { color: var(--accent); margin: 0 8px 0 2px; }

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

.input-line { display: flex; align-items: baseline; flex: 0 0 auto; padding: 4px 0 16px; }
.input-wrap { position: relative; flex: 1; display: inline-flex; align-items: baseline; }
#cmdInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  caret-color: transparent;
  padding: 0;
}
.fake-cursor {
  display: inline-block;
  width: 9px;
  height: 1.05em;
  background: var(--accent);
  transform: translateY(2px);
  position: absolute;
  pointer-events: none;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.accent { color: var(--accent); }
.green { color: var(--green); }
.cyan { color: var(--cyan); }
.yellow { color: var(--yellow); }
.blue { color: var(--blue); }
.magenta { color: var(--magenta); }
.red { color: var(--red); }
.dim { color: var(--dim); }
.bold { font-weight: 700; }
.under { text-decoration: underline; text-underline-offset: 3px; }

a, .link {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dotted var(--cyan);
  cursor: pointer;
}
a:hover, .link:hover { color: var(--accent); border-bottom-color: var(--accent); }

.cmd-chip {
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}
.cmd-chip:hover { border-bottom-color: var(--accent); }

.banner {
  color: var(--green);
  font-weight: 700;
  line-height: 1.04;
  font-size: clamp(7px, 1.85vw, 15px);
  letter-spacing: -0.5px;
  margin: 4px 0 8px;
  overflow-x: auto;
  white-space: pre;
  text-shadow:
    0 0 5px rgba(var(--glow-rgb), 0.65),
    0 0 14px rgba(var(--glow-rgb), 0.35),
    0 0 28px rgba(var(--glow-rgb), 0.18);
  animation: flicker 4.5s infinite;
}
.banner::-webkit-scrollbar { height: 0; }
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.72; }
  94% { opacity: 1; }
  96% { opacity: 0.85; }
  97% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; }
}

.kvtable { display: grid; grid-template-columns: max-content 1fr; gap: 2px 18px; }
.kvtable .k { color: var(--dim); }
.kvtable .v { color: var(--fg); }

.role-head { color: var(--fg); font-weight: 700; }
.role-meta { color: var(--dim); }
.bullet { color: var(--fg); }
.bullet::before { content: "› "; color: var(--accent); }
.tag {
  display: inline-block;
  color: var(--accent);
  border: 1px solid var(--border);
  background: rgba(var(--glow-rgb), 0.06);
  border-radius: 5px;
  padding: 0 7px;
  margin: 2px 4px 2px 0;
  font-size: 12.5px;
}
.skill-cat { color: var(--cyan); font-weight: 700; }

.hint {
  color: var(--dim);
  font-size: 12.5px;
  text-align: center;
}
.hint kbd {
  background: #0e160e;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 7px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11.5px;
}

@media (max-width: 640px) {
  html, body { height: 100%; overflow: hidden; }
  body { font-size: 13.5px; padding: 0; }

  .terminal {
    height: 100vh;
    height: 100svh;
    width: 100%;
    border-radius: 0;
    border: none;
  }

  /* the full-screen opaque terminal hides the rain — don't waste CPU on it */
  #matrix { display: none; }

  .titlebar { padding-top: calc(10px + env(safe-area-inset-top)); }
  .title { font-size: 11px; }

  .quicknav { padding: 7px 10px; gap: 5px; }
  .navchip { font-size: 12px; padding: 4px 10px; }

  .screen { padding: 14px 14px 0; }

  #output { -webkit-overflow-scrolling: touch; overflow-wrap: anywhere; }

  /* 16px keeps iOS from zooming in when the input is focused */
  #cmdInput { font-size: 16px; }
  .input-line { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  /* scale the ASCII banner to the viewport so it never overflows */
  .banner { font-size: clamp(7px, 2.45vw, 13px); letter-spacing: 0; }

  .kvtable { grid-template-columns: 1fr; gap: 0; }
  .kvtable .k { margin-top: 8px; }

  .tag { font-size: 12px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fake-cursor { animation: none; }
  .screen { scroll-behavior: auto; }
  .reveal { animation: none; }
}

@media print {
  body { background: #fff !important; color: #111 !important; display: block; padding: 24px; }
  #matrix, .titlebar, .quicknav, .input-line, .hint,
  .terminal::after, .terminal::before { display: none !important; }
  .terminal {
    box-shadow: none; border: none; border-radius: 0;
    width: 100%; height: auto; background: #fff;
  }
  .screen { overflow: visible; height: auto; padding: 0; text-shadow: none !important; }
  .banner { color: #111 !important; text-shadow: none !important; animation: none; font-size: 11px; }
  .reveal { animation: none !important; }
  .screen, .line, .bold, .echo-cmd,
  .accent, .green, .cyan, .blue, .yellow, .magenta,
  .user, .dollar, .path, .colon, .role-head, .role-meta,
  .skill-cat, .bullet, .kvtable .k, .kvtable .v {
    color: #111 !important;
  }
  .dim { color: #555 !important; }
  a, .link, .copyable { color: #111 !important; border: none !important; text-decoration: underline; }
  .copyable::after { content: none !important; }
  .tag { color: #111 !important; border-color: #aaa !important; background: none !important; }
}
