:root {
  --bg: #050505;
  --bg-2: #0d0d0d;
  --fg: #e8e8e8;
  --dim: #8a8a8a;
  --red: #e5092b;
  --green: #3ddc84;
  --line: #1e1e1e;
  --font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:target, section[id] { scroll-margin-top: 72px; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.skip-link { position: fixed; left: 8px; top: -60px; z-index: 300; background: var(--red); color: #fff; padding: 10px 14px; }
.skip-link:focus { top: 8px; }
::selection { background: var(--red); color: #fff; }

.red { color: var(--red); }
.dim { color: var(--dim); }

/* ---------- CRT overlay ---------- */
.crt {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 100;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.65) 100%);
  animation: flicker 6s infinite steps(1);
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: .85; }
  48% { opacity: 1; }
  82% { opacity: .92; }
}

/* ---------- Boot ---------- */
.boot {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  padding: max(32px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; justify-content: flex-end;
  transition: opacity .5s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot pre {
  font-family: var(--font);
  font-size: 13px;
  color: var(--dim);
  white-space: pre-wrap;
  max-width: 900px;
}
.boot pre .ok { color: var(--green); }
.boot pre .warn { color: var(--red); }
.boot-skip {
  position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right));
  min-height: 44px; min-width: 44px; padding: 0 12px;
  background: none; border: 0; color: var(--dim);
  font: inherit; font-size: 12px; cursor: pointer;
}
.boot-skip:hover { color: var(--fg); }
.boot { cursor: pointer; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px max(clamp(16px, 4vw, 48px), env(safe-area-inset-right)) 12px max(clamp(16px, 4vw, 48px), env(safe-area-inset-left));
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
}
.nav-logo { font-weight: 800; letter-spacing: .02em; display: inline-flex; align-items: center; min-height: 44px; }
.nav nav { display: flex; gap: clamp(12px, 3vw, 28px); font-size: 13px; }
.nav nav a { color: var(--dim); transition: color .2s; display: inline-flex; align-items: center; min-height: 44px; }
.nav nav a:hover, .nav nav a.nav-cta { color: var(--fg); }
.nav nav a.nav-cta { border-bottom: 1px solid var(--red); }

.cursor { animation: blink 1s steps(1) infinite; color: var(--red); }
@keyframes blink { 50% { opacity: 0; } }
.blink { animation: blink 1.2s steps(1) infinite; }

/* ---------- Layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 0 max(clamp(16px, 4vw, 48px), env(safe-area-inset-right)) 0 max(clamp(16px, 4vw, 48px), env(safe-area-inset-left)); }

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  gap: 22px;
  padding-top: 80px;
}
.prompt { font-size: 14px; min-height: 1.6em; }

h1, h2, h3 { font-weight: 800; letter-spacing: -.02em; }

.hero-lead { font-size: clamp(16px, 2vw, 20px); max-width: 720px; }
.hero-lead strong { color: #fff; }
.hero-sub { font-size: 13px; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.btn {
  display: inline-flex; align-items: center; min-height: 44px;
  overflow-wrap: anywhere;
  padding: 12px 20px;
  border: 1px solid var(--line);
  font-size: 14px;
  transition: border-color .2s, background .2s, color .2s;
}
@media (hover: hover) { .btn:hover { border-color: var(--fg); } }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
@media (hover: hover) { .btn-red:hover { background: transparent; color: var(--red); border-color: var(--red); } }

.section { padding: clamp(64px, 10vw, 120px) 0; border-top: 1px dashed var(--line); }
.section h2 { font-size: clamp(20px, 3vw, 28px); margin-bottom: 36px; }

/* ---------- Glitch ---------- */
.glitch {
  position: relative;
  font-size: clamp(28px, 9.5vw, 112px);
  line-height: 1;
  color: #fff;
  text-transform: lowercase;
}
.glitch.small { font-size: clamp(22px, 7.4vw, 64px); margin-bottom: 24px; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  overflow: hidden;
}
.glitch::before {
  color: var(--red);
  animation: glitch-a 3.2s infinite linear alternate-reverse;
}
.glitch::after {
  color: #0ff;
  opacity: .6;
  animation: glitch-b 2.4s infinite linear alternate-reverse;
}
@keyframes glitch-a {
  0%, 88%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  89% { clip-path: inset(10% 0 60% 0); transform: translate(-4px, 0); }
  91% { clip-path: inset(50% 0 20% 0); transform: translate(4px, 0); }
  93% { clip-path: inset(80% 0 5% 0);  transform: translate(-2px, 0); }
  95% { clip-path: inset(30% 0 50% 0); transform: translate(3px, 0); }
}
@keyframes glitch-b {
  0%, 90%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  91% { clip-path: inset(60% 0 10% 0); transform: translate(3px, 0); }
  94% { clip-path: inset(20% 0 55% 0); transform: translate(-3px, 0); }
  97% { clip-path: inset(5% 0 80% 0);  transform: translate(2px, 0); }
}

/* ---------- Whoami ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
.grid-2 > * { min-width: 0; }
.term { border: 1px solid var(--line); background: var(--bg-2); }
.term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--dim);
}
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #2a2a2a; }
.term-bar i:first-child { background: var(--red); }
.term-bar span { margin-left: 8px; }
.term-body { padding: 18px; font-family: var(--font); font-size: 13px; overflow-x: auto; }
.term-body .k { color: #9a9a9a; }
.term-body .s { color: var(--fg); }
.term-body .s.red { color: var(--red); }

.about p { margin-bottom: 16px; color: #cfcfcf; }
.stats { list-style: none; display: flex; gap: 28px; margin-top: 28px; flex-wrap: wrap; }
.stats b { display: block; font-size: 36px; color: var(--red); line-height: 1.1; }
.stats span { font-size: 12px; color: var(--dim); }

/* ---------- Services ---------- */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.card {
  background: var(--bg);
  padding: 28px 24px;
  position: relative;
  transition: background .25s;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--red); transform: scaleY(0); transform-origin: top;
  transition: transform .3s ease;
}
@media (hover: hover) {
  .card:hover { background: var(--bg-2); }
  .card:hover::before { transform: scaleY(1); }
  .card:hover h3 { color: var(--red); }
}
.card-perm { font-size: 11px; margin-bottom: 10px; }
.card h3 { font-size: 17px; margin-bottom: 10px; }
.card p:last-child { font-size: 14px; color: #b5b5b5; }

/* ---------- Pipeline ---------- */
.pipeline { list-style: none; }
.pipeline li {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.pipeline .step { color: var(--dim); }
.pipeline b { color: #fff; }
.pipeline p { font-size: 14px; color: #b5b5b5; }
.pipeline .ok { color: var(--green); font-weight: 700; font-size: 13px; }
.pipeline .ok.blink { color: var(--red); }

/* ---------- Stack ---------- */
.stack { font-size: clamp(15px, 2vw, 19px); line-height: 2; color: #cfcfcf; max-width: 900px; }

/* ---------- Contact ---------- */
.contact { text-align: left; }
.contact .hero-lead { margin-bottom: 18px; }

.footer {
  max-width: 1100px; margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 48px) 40px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 12px;
  border-top: 1px dashed var(--line);
}

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive (mobile-first base above; tablet / desktop below) ---------- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .grid-2 { grid-template-columns: 1fr; gap: 28px; }
  .nav nav { gap: 14px; font-size: 12px; }
  .nav-logo { font-size: 14px; }
  .boot pre { font-size: 11px; }
  .pipeline li { grid-template-columns: 44px 1fr; }
  .pipeline .ok { display: none; }
  .hero-actions .btn { flex: 1 1 100%; justify-content: center; }
  .crt { animation: none; }
}
@media (max-width: 360px) {
  .nav nav { gap: 10px; }
  .stats { gap: 20px; }
}
@media (min-width: 600px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 761px) and (max-width: 1023px) {
  .grid-2 { gap: 28px; }
  .term-body { font-size: 12px; }
}
@media (min-width: 1024px) { .cards { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1440px) {
  body { font-size: 16px; }
  main, .footer { max-width: 1240px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .hero { padding-top: 96px; padding-bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .glitch::before, .glitch::after { display: none; }
}
