/* ============ themes ============ */
:root {
  /* "black" — monochrome default */
  --bg: #050505;
  --bg-panel: #0c0c0c;
  --bg-raise: #151515;
  --fg: #d8d8d8;
  --dim: #8f8f8f;
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, .09);
  --warn: #ffd966;
  --err: #ff6b6b;
  --border: #272727;
  --glow: 0 0 7px rgba(255, 255, 255, .3);
  --scanline-opacity: .14;
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="green"] {
  --bg: #060906;
  --bg-panel: #0a100a;
  --bg-raise: #0e160e;
  --fg: #b8f5c4;
  --dim: #7cab87;
  --accent: #39ff7a;
  --accent-soft: rgba(57, 255, 122, .12);
  --border: #1d2f1f;
  --glow: 0 0 6px rgba(57, 255, 122, .35);
}

[data-theme="blue"] {
  --bg: #04070d;
  --bg-panel: #070d18;
  --bg-raise: #0b1322;
  --fg: #b3cdf2;
  --dim: #7f97ba;
  --accent: #57a5ff;
  --accent-soft: rgba(87, 165, 255, .12);
  --border: #16233a;
  --glow: 0 0 6px rgba(87, 165, 255, .4);
}

[data-theme="amber"] {
  --bg: #0a0602;
  --bg-panel: #120b03;
  --bg-raise: #1a1005;
  --fg: #ffd9a0;
  --dim: #b39058;
  --accent: #ffb000;
  --accent-soft: rgba(255, 176, 0, .12);
  --warn: #ffe9b0;
  --err: #ff7a5c;
  --border: #33230c;
  --glow: 0 0 6px rgba(255, 176, 0, .35);
}

[data-theme="paper"] {
  --bg: #efece3;
  --bg-panel: #f7f4ec;
  --bg-raise: #fffdf6;
  --fg: #20251f;
  --dim: #5d635a;
  --accent: #0a7d3b;
  --accent-soft: rgba(10, 125, 59, .1);
  --warn: #9a6b00;
  --err: #b3261e;
  --border: #d4cfc0;
  --glow: none;
  --scanline-opacity: 0;
  color-scheme: light;
}

/* ============ base ============ */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
}
a:hover, a:focus-visible { background: var(--accent); color: var(--bg); text-decoration: none; }

strong { color: var(--accent); font-weight: 600; }
kbd {
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 3px;
  padding: 0 .35em; font-family: inherit; font-size: .85em;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ============ CRT overlay ============ */
.crt {
  position: fixed; inset: 0; z-index: 9; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.32) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,var(--scanline-opacity)) 0 1px, transparent 1px 3px);
}
.js .crt { animation: flicker 4s infinite; }

@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: .82; }
  94% { opacity: 1; }
  97% { opacity: .92; }
  98% { opacity: 1; }
}

/* ============ terminal window ============ */
.terminal {
  max-width: 880px;
  margin: 24px auto 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 24px 64px rgba(0,0,0,.5);
  overflow: clip; /* not `hidden` — hidden makes this a scroll container and kills position:sticky */
}

.titlebar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-raise);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--dim);
}
.dots { display: flex; gap: 6px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--border); }
.dots i:first-child { background: var(--err); }
.dots i:nth-child(2) { background: var(--warn); }
.dots i:last-child { background: var(--accent); }
.title { flex: 1; text-align: center; }
.titlebar-right { display: flex; gap: 12px; align-items: center; }
#clock { font-variant-numeric: tabular-nums; }
#theme-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--dim); font: inherit; padding: 2px 8px; cursor: pointer;
}
#theme-btn:hover { color: var(--accent); border-color: var(--accent); }

.screen { padding: 28px clamp(14px, 4vw, 40px) 0; }

/* ============ blocks ============ */
.block, .cmd-block { margin-bottom: 40px; }
.cmd-block, #banner { scroll-margin-top: 64px; }

/* banner */
.banner-name {
  margin: 14px 0 6px;
  font-size: clamp(30px, 6.5vw, 62px);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: var(--glow);
}
.js .banner-name:hover { animation: glitch .28s steps(2) infinite; }
@keyframes glitch {
  0%   { text-shadow: 2px 0 var(--err), -2px 0 var(--accent-soft), var(--glow); }
  50%  { text-shadow: -2px 0 var(--err), 2px 0 var(--accent-soft), var(--glow); }
  100% { text-shadow: 2px 0 var(--err), -2px 0 var(--accent-soft), var(--glow); }
}
.banner-sub {
  margin: 0 0 12px;
  color: var(--dim);
  letter-spacing: .3em;
  text-transform: uppercase;
  font-size: clamp(9px, 1.7vw, 13px);
}
.motd { color: var(--dim); margin: 0; }

.cmd { margin: 0 0 10px; }
.ps1 { color: var(--accent); text-shadow: var(--glow); user-select: none; }
.typed { color: var(--fg); }

/* typing reveal (JS only) */
.js .cmd-block .output {
  opacity: 0; transform: translateY(6px);
  transition: opacity .45s ease, transform .45s ease;
}
.js .cmd-block.done .output { opacity: 1; transform: none; }
.js .cmd-block .typed::after,
.prompt-line input:focus + .fake-caret { content: ""; }
.js .cmd-block:not(.done) .typed::after {
  content: "▋"; color: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.output p { margin: 0 0 8px; }
.big { font-size: clamp(20px, 3.4vw, 28px); color: var(--accent); text-shadow: var(--glow); font-weight: 700; }
.dim { color: var(--dim); }

.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; box-shadow: var(--glow);
}
.js .status-dot { animation: pulse 2s ease infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* experience tree */
.tree { list-style: none; margin: 0; padding: 0; }
.tree li {
  position: relative;
  padding: 0 0 18px 22px;
  display: grid;
  gap: 2px;
}
.tree li::before {
  content: "├──"; position: absolute; left: 0; top: 0; color: var(--dim);
}
.tree li:last-child::before { content: "└──"; }
.tree li:not(:last-child)::after {
  content: ""; position: absolute; left: .55ch; top: 22px; bottom: 0;
  border-left: 1px solid var(--border);
}
.when { color: var(--dim); font-size: 13px; }
.desc { color: var(--fg); opacity: .85; }

/* project cards */
.card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--dim);
  background: var(--bg-raise);
  padding: 14px 16px;
  margin-bottom: 14px;
  transition: border-color .2s ease, transform .2s ease;
}
.card:hover { border-left-color: var(--accent); transform: translateX(4px); }
.card.featured { border-left-color: var(--accent); }
.card-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.perm { color: var(--dim); font-size: 12px; }
.tag { color: var(--warn); font-size: 12px; }
.year { margin-left: auto; color: var(--dim); font-size: 12px; }
.stack-line { color: var(--dim); font-size: 13px; margin-bottom: 0 !important; }

/* skills chips */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  border: 1px solid var(--border); padding: 3px 10px; border-radius: 3px;
  background: var(--bg-raise); font-size: 13px;
  transition: all .15s ease;
}
.chips li:hover {
  border-color: var(--accent); color: var(--accent);
  box-shadow: var(--glow); transform: translateY(-2px);
}

/* achievements / links */
.plain, .links { list-style: none; margin: 0; padding: 0; }
.plain li, .links li { padding: 3px 0; }
.match { background: var(--accent-soft); color: var(--accent); padding: 0 4px; }

/* ============ REPL ============ */
#log-wrap { border-top: 1px dashed var(--border); padding-top: 22px; }
#log:empty::before {
  content: "// command output lands here — prompt is docked below ↓";
  color: var(--dim); opacity: .6;
}
#log .echo .ps1 { opacity: .9; }
#log p, #log pre { margin: 0 0 6px; white-space: pre-wrap; word-break: break-word; }
#log pre { line-height: 1.45; overflow-x: auto; }
#log .err { color: var(--err); }
#log .ok { color: var(--accent); }
#log .warn { color: var(--warn); }

.prompt-line { display: flex; gap: 8px; align-items: baseline; cursor: text; }
#cmd-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--fg); font: inherit; caret-color: var(--accent);
  padding: 4px 0;
}
#cmd-input::placeholder { color: var(--dim); opacity: .7; }

.prompt-dock {
  position: sticky; bottom: 0; z-index: 6;
  margin: 0 calc(-1 * clamp(14px, 4vw, 40px));
  padding: 10px clamp(14px, 4vw, 40px) 14px;
  background: var(--bg-raise);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, .35);
}

.hints { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cmd-link {
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: 3px;
  color: var(--dim); font: inherit; font-size: 12px; padding: 2px 9px; cursor: pointer;
}
.cmd-link:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow); }

.footer { margin-bottom: 24px; font-size: 12.5px; }

/* ============ motion & small screens ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .crt { animation: none; }
  .js .status-dot { animation: none; }
  .js .banner-name:hover { animation: none; }
  .js .cmd-block .output { transition: none; }
  .card, .chips li { transition: none; }
}

@media (max-width: 600px) {
  body { font-size: 14px; }
  .terminal { margin: 0; border: none; border-radius: 0; }
  .title { display: none; }
  .titlebar { justify-content: space-between; }
  #cmd-input { font-size: 16px; } /* prevents iOS focus zoom */
  .hints { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
}
