/* ---------- Onyx design tokens ---------- */
:root {
  --bg: #0a0a0b;
  --bg-2: #111113;
  --surface: #161618;
  --surface-2: #1d1d20;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --muted: #8e8e93;
  --dim: #5a5a60;
  --accent: #d6d6dc;
  --glow: rgba(214, 214, 230, 0.12);
  --radius: 28px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--text); color: var(--bg); }

/* ---------- Nav (Apple-style glass bar) ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: 52px;
  background: rgba(10, 10, 11, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1080px; height: 100%; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; color: var(--text); }
.nav-logo span { color: var(--muted); }
.nav-links { display: flex; gap: 28px; font-size: 13px; color: var(--muted); }
.nav-links a { transition: color .2s; }
.nav-links a:hover { color: var(--text); }
@media (max-width: 640px) {
  .nav-links { gap: 18px; }
  .nav-links .hide-sm { display: none; }
}

/* ---------- Layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 22px; }
section { padding: 140px 0; position: relative; }
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 18px;
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::before { content: ""; width: 6px; height: 6px; background: var(--text); border-radius: 1px; }
.h-xl {
  font-size: clamp(44px, 8vw, 96px); font-weight: 700;
  letter-spacing: -0.045em; line-height: 1.02;
}
.h-lg {
  font-size: clamp(36px, 5.6vw, 64px); font-weight: 700;
  letter-spacing: -0.035em; line-height: 1.06;
}
.lead { font-size: clamp(19px, 2.2vw, 24px); color: var(--muted); line-height: 1.4; max-width: 640px; font-weight: 500; }
.lead b { color: var(--text); font-weight: 600; }
.grad {
  background: linear-gradient(180deg, #ffffff 0%, #9a9aa2 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(40px); transition: opacity 1s cubic-bezier(.2,.7,.2,1), transform 1s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; } .reveal.d2 { transition-delay: .16s; } .reveal.d3 { transition-delay: .24s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-size: 15px; font-weight: 500;
  transition: transform .2s, background .2s, color .2s;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: #fff; transform: scale(1.03); }
.btn-ghost { color: var(--text); border: 1px solid var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.arrow { transition: transform .2s; }
a:hover .arrow { transform: translateX(3px); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 36px; position: relative; overflow: hidden;
}
.card-label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--line); padding: 28px 0 40px;
  font-size: 12px; color: var(--dim); font-family: var(--mono);
}
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ---------- HUD bits (shared by lab pages) ---------- */
.hud { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.hud b { color: var(--text); font-weight: 500; }

/* ---------- Page transitions (iOS-like) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .28s cubic-bezier(.4,0,1,1) both; }
::view-transition-new(root) { animation: vt-in .42s cubic-bezier(.2,.8,.2,1) both; }
@keyframes vt-out { to { opacity: 0; transform: scale(.97); filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; transform: scale(1.03); filter: blur(4px); } }
.nav { view-transition-name: nav; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ---------- Language button ---------- */
.lang-btn {
  font: 500 11px var(--mono); letter-spacing: .08em; color: var(--muted); background: transparent;
  border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 9px; cursor: pointer; transition: all .2s;
}
.lang-btn:hover { color: var(--text); border-color: var(--text); }

/* ---------- Toast ---------- */
.site-toast {
  position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 20px); opacity: 0; z-index: 300;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font: 500 14px var(--sans);
  transition: all .3s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.site-toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 290; }

/* ---------- Terminal ---------- */
.term { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: rgba(0,0,0,.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s; }
.term[hidden] { display: none; }
.term.open { opacity: 1; }
.term-win { width: min(760px, 100%); height: min(480px, 80vh); display: flex; flex-direction: column;
  background: rgba(14,14,16,.94); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); transform: translateY(14px) scale(.98); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.term.open .term-win { transform: none; }
.term-bar { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 12px; border-bottom: 1px solid var(--line); font: 12px var(--mono); color: var(--dim); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a3a40; }
.term-bar i:nth-child(1) { background: #ff5f57; } .term-bar i:nth-child(2) { background: #febc2e; } .term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { flex: 1; text-align: center; margin-right: 30px; }
.term-x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }
.term-out { flex: 1; overflow-y: auto; padding: 14px 16px 4px; font: 13px/1.6 var(--mono); color: var(--text); }
.term-out .tl { white-space: pre-wrap; word-break: break-word; }
.term-out .dim { color: var(--muted); } .term-out .err { color: #ff6b6b; }
.term-out .nf { color: var(--muted); }
.term-out a { text-decoration: underline; text-underline-offset: 3px; }
.term-ps { color: #28c840; }
.term-in { display: flex; gap: 10px; align-items: center; padding: 8px 16px 14px; font: 13px var(--mono); }
.term-in input { flex: 1; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; caret-color: #28c840; }
.term-hint { background: none; border: 0; color: var(--dim); font: inherit; cursor: pointer; }
.term-hint:hover { color: var(--text); }

/* ---------- Personal message popup ---------- */
.dm { position: fixed; inset: 0; z-index: 260; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; transition: opacity .3s; }
.dm.show { opacity: 1; }
.dm-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 26px; padding: 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); transform: translateY(20px) scale(.96); transition: transform .4s cubic-bezier(.2,1.3,.4,1); }
.dm.show .dm-card { transform: none; }
.dm-top { display: flex; gap: 12px; align-items: center; }
.dm-top b { display: block; } .dm-top small { color: var(--muted); font-size: 13px; }
.dm-ava { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; letter-spacing: -0.04em;
  background: linear-gradient(140deg, #f5f5f7, #6d6d73); color: #0a0a0b; }
.dm-card p { font-size: 18px; line-height: 1.5; margin: 18px 0 22px; white-space: pre-wrap; word-wrap: break-word; }

/* ---------- Countdown (home page) ---------- */
.countdown { position: relative; z-index: 2; margin-top: 30px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px 22px; border-radius: 22px; background: rgba(22,22,24,.55); border: 1px solid var(--line-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.countdown[hidden] { display: none; }
.cd-title { font: 500 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.cd-n { display: flex; gap: 16px; }
.cd-n span { display: flex; align-items: baseline; gap: 4px; }
.cd-n b, .countdown > b { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cd-n small { font: 12px var(--mono); color: var(--dim); }

/* ---------- Site modes ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; }
.garland { position: absolute; left: 0; right: 0; bottom: -7px; display: flex; justify-content: space-between; padding: 0 10px; pointer-events: none; }
.garland i { width: 7px; height: 10px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; animation: bulb 1.4s ease-in-out infinite; }
.garland i:nth-child(4n+1) { background: #ff453a; } .garland i:nth-child(4n+2) { background: #ffd400; }
.garland i:nth-child(4n+3) { background: #33d17a; } .garland i:nth-child(4n) { background: #7cc4ff; }
@keyframes bulb { 50% { opacity: .25; filter: none; } 0%, 100% { filter: drop-shadow(0 0 6px currentColor); } }
html.mode-halloween { --accent: #ff7a1a; }
html.mode-halloween .grad { background: linear-gradient(180deg, #ffb066, #ff6a00); -webkit-background-clip: text; background-clip: text; }
html.mode-halloween .eyebrow::before { background: #ff7a1a; }
html.mode-halloween .btn-primary { background: #ff7a1a; color: #120800; }
html.mode-party .nav-logo { background: linear-gradient(90deg, #ff453a, #ffd400, #33d17a, #7cc4ff, #bf5af2, #ff453a); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: rainbow 3s linear infinite; }
html.mode-party .nav-logo span { color: transparent; }
@keyframes rainbow { to { background-position: 200% 0; } }

/* ---------- Easter egg: hacker mode ---------- */
html.hacker {
  --bg: #000; --bg-2: #020a02; --surface: #031103; --surface-2: #062006;
  --text: #33ff66; --muted: #1fbf4a; --dim: #127a2e; --accent: #33ff66;
  --line: rgba(51,255,102,.14); --line-2: rgba(51,255,102,.3);
}
html.hacker body { background: #000; font-family: var(--mono); }
html.hacker .grad { background: none; color: #33ff66; -webkit-text-fill-color: #33ff66; }
html.hacker body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 400;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); }
