/* ---------- Tokens ---------- */
:root {
  --bg: #07090f;
  --bg-2: #0c1018;
  --text: #e8ecf3;
  --muted: #8b93a7;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #5eead4;   /* teal */
  --accent-2: #a78bfa; /* violet */
  --accent-3: #f472b6; /* pink, used sparingly */
  /* Categorical palette for the Stack ring, one hue per language in this fixed order. */
  --lang-1: #2dd4bf;
  --lang-2: #a78bfa;
  --lang-3: #fbbf24;
  --lang-4: #f472b6;
  --lang-5: #38bdf8;
  --lang-6: #a3e635;
  --lang-7: #fb923c;
  --lang-8: #818cf8;
  --lang-other: #5b6474;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
  --max: 1120px;
  --pad: clamp(20px, 5vw, 48px);
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(167, 139, 250, 0.16), transparent 60%),
    radial-gradient(900px 600px at 10% 20%, rgba(94, 234, 212, 0.10), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
}

::selection { background: rgba(94, 234, 212, 0.3); }

/* ---------- Background layers ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--pad);
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease), padding 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  padding: 12px var(--pad);
  background: rgba(7, 9, 15, 0.6);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(94, 234, 212, 0.45);
}
.brand-text { font-size: 15px; }

.nav-links { display: flex; gap: 28px; font-size: 14px; color: var(--muted); }
.nav-links a { position: relative; transition: color 0.25s; }
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: -4px;
  height: 1px;
  background: var(--accent);
  transition: right 0.3s var(--ease);
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { right: 0; }

/* ---------- Layout ---------- */
main { position: relative; z-index: 2; }

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 12vw, 140px) var(--pad);
}

.section-head { max-width: 640px; margin-bottom: 48px; }
.kicker {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
h2 { font-size: clamp(30px, 4.2vw, 46px); }
.sub { color: var(--muted); margin: 16px 0 0; font-size: 17px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 140px var(--pad) 100px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px;
  padding: 7px 14px 7px 10px;
  width: fit-content;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.18);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.18); }
  50%      { box-shadow: 0 0 0 7px rgba(94, 234, 212, 0.06); }
}

h1 {
  font-size: clamp(44px, 8.4vw, 104px);
  max-width: 14ch;
  text-wrap: balance;
}
.gradient-text {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  animation: shimmer 9s ease-in-out infinite alternate;
}
@keyframes shimmer {
  from { background-position: 0% 50%; }
  to   { background-position: 100% 50%; }
}

.lede {
  max-width: 520px;
  margin: 28px 0 0;
  font-size: clamp(17px, 1.6vw, 20px);
  color: var(--muted);
}

.cta-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 40px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s, border-color 0.25s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  color: #061012;
  background: linear-gradient(135deg, var(--accent), #8ff2e4);
  box-shadow: 0 10px 30px -10px rgba(94, 234, 212, 0.6);
}
.btn-primary:hover { box-shadow: 0 16px 40px -12px rgba(94, 234, 212, 0.75); }
.btn-ghost {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}
.btn-ghost:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.06); }

.scroll-hint {
  position: absolute;
  left: var(--pad);
  bottom: 36px;
  width: 24px;
  height: 40px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  display: grid;
  place-items: start center;
  padding-top: 6px;
}
.scroll-hint span {
  width: 3px; height: 8px;
  border-radius: 2px;
  background: var(--accent);
  animation: scrollhint 1.8s ease-in-out infinite;
}
@keyframes scrollhint {
  0%   { transform: translateY(0); opacity: 1; }
  70%  { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- Cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  transition: transform 0.35s var(--ease), border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.card::before {
  /* cursor-following glow, driven by --mx / --my from main.js */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(94, 234, 212, 0.12), transparent 45%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}
.card:hover::before { opacity: 1; }

.card-icon {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(94, 234, 212, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.18);
  margin-bottom: 22px;
}
.card-icon svg { width: 22px; height: 22px; }

.pill {
  position: absolute;
  top: 22px; right: 22px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pill-live { color: var(--accent); background: rgba(94, 234, 212, 0.1); border: 1px solid rgba(94, 234, 212, 0.25); }
.pill-soon { color: var(--accent-2); background: rgba(167, 139, 250, 0.1); border: 1px solid rgba(167, 139, 250, 0.3); }

.card h3 { font-size: 21px; margin-bottom: 10px; }
.card p { margin: 0 0 22px; color: var(--muted); font-size: 15px; flex: 1; }
.card-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.card-link span { transition: transform 0.25s var(--ease); display: inline-block; }
.card:hover .card-link span { transform: translateX(4px); }

/* ---------- Panels (Activity calendar, Stack ring) ---------- */
.activity, .stack-panel {
  --cell: 13px;
  --gap: 4px;
  --days: 34px;
  padding: 24px 26px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.activity-head, .activity-foot, .stack-head, .stack-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
  font-size: 14px;
  color: var(--muted);
}
.activity-head, .stack-head { margin-bottom: 22px; }
.activity-foot, .stack-foot { margin-top: 18px; font-size: 13px; }
.activity-total, .stack-total { margin: 0; font-size: 17px; color: var(--text); }
.activity-count, .stack-count { font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.02em; }
.panel-link { font-weight: 600; color: var(--text); display: inline-flex; gap: 6px; align-items: center; }
.panel-link span { transition: transform 0.25s var(--ease); display: inline-block; }
.panel-link:hover { color: var(--accent); }
.panel-link:hover span { transform: translateX(4px); }
.panel-status { margin: 0; color: var(--muted); font-size: 15px; grid-column: 1 / -1; }
.panel-status a { color: var(--text); border-bottom: 1px solid var(--accent); }

.activity-body { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding-bottom: 6px; }

.heatmap {
  display: grid;
  grid-template-columns: var(--days) 1fr;
  grid-template-rows: auto 1fr;
  gap: 6px 0;
  width: max-content;
  min-width: 100%;
}
.heatmap-months, .heatmap-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cell);
  gap: var(--gap);
}
.heatmap-months { grid-column: 2; grid-template-rows: 1em; font-size: 12px; color: var(--muted); line-height: 1; }
.heatmap-months span { grid-row: 1; white-space: nowrap; }
.heatmap-days {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: var(--gap);
  font-size: 12px;
  color: var(--muted);
  line-height: var(--cell);
}
.heatmap-cells { grid-column: 2; grid-row: 2; grid-template-rows: repeat(7, var(--cell)); }

.cell {
  display: block;
  width: var(--cell);
  height: var(--cell);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.cell.l1 { background: rgba(94, 234, 212, 0.22); box-shadow: none; }
.cell.l2 { background: rgba(94, 234, 212, 0.45); box-shadow: none; }
.cell.l3 { background: rgba(94, 234, 212, 0.72); box-shadow: none; }
.cell.l4 { background: var(--accent); box-shadow: 0 0 8px rgba(94, 234, 212, 0.45); }
.cell.pad { visibility: hidden; }
.heatmap-cells .cell { transition: transform 0.15s var(--ease); }
.heatmap-cells .cell:hover { transform: scale(1.35); outline: 1px solid rgba(255, 255, 255, 0.5); }

.legend { display: inline-flex; align-items: center; gap: 4px; }
.legend .cell { width: 11px; height: 11px; }
.legend .cell:first-of-type { margin-left: 4px; }
.legend .cell:last-of-type { margin-right: 4px; }

/* ---------- Stack (languages across the repositories) ---------- */
.stack-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 40px;
  align-items: center;
}
.stack-scene, .stack-side { min-width: 0; } /* long labels truncate instead of widening the grid */
.stack-scene {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
  margin: 0 auto;
}
.stack-scene::before {
  /* soft glow behind the ring */
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.16), rgba(167, 139, 250, 0.1) 45%, transparent 70%);
  filter: blur(28px);
  pointer-events: none;
}
#stack-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y; /* a sideways drag spins the ring; an up-down one still scrolls */
  cursor: grab;
}
#stack-canvas.dragging { cursor: grabbing; }
.stack-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 4%;
  pointer-events: none;
}
.readout-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(30px, 4vw, 42px);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.readout-name { margin-top: 8px; font-weight: 600; font-size: 15px; }
.readout-meta { margin-top: 2px; color: var(--muted); font-size: 12.5px; }

.stack-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.stack-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  grid-template-areas:
    "sw name share"
    "sw bar  bar";
  column-gap: 10px;
  row-gap: 7px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s;
}
.stack-row:hover, .stack-row.is-active { background: rgba(255, 255, 255, 0.045); }
.stack-row[aria-pressed="true"] { background: rgba(255, 255, 255, 0.07); }
.stack-swatch {
  grid-area: sw;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
  transition: box-shadow 0.25s;
}
.stack-row.is-active .stack-swatch { box-shadow: 0 0 12px var(--c); }
.stack-name { grid-area: name; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack-sub { margin-left: 8px; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.stack-share {
  grid-area: share;
  min-width: 5ch;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.stack-bar {
  grid-area: bar;
  display: block;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.stack-bar i {
  display: block;
  height: 100%;
  width: 0; /* grows to --w once the panel is revealed */
  border-radius: 0 3px 3px 0;
  background: var(--c);
  transition: width 1.2s var(--ease);
}
.reveal.in .stack-bar i { width: var(--w); }

/* Without WebGL the ring is replaced by a thin segmented bar above the list. */
.stack-strip { display: none; height: 8px; margin: 4px 10px 18px; border-radius: 999px; overflow: hidden; gap: 2px; }
.stack-strip i { display: block; min-width: 2px; }
body.no-webgl .stack-scene { display: none; }
body.no-webgl .stack-body { grid-template-columns: 1fr; }
body.no-webgl .stack-strip { display: flex; }

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}
.about-text p { color: var(--muted); font-size: 17px; margin: 18px 0 0; }
.about-text h2 { margin-bottom: 6px; }
.about-text a {
  color: var(--text);
  border-bottom: 1px solid var(--accent);
  transition: color 0.2s;
}
.about-text a:hover { color: var(--accent); }

.stack {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;
  border-top: 1px solid var(--line);
}
.stack li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.stack-k { color: var(--muted); }
.stack-v { font-family: var(--font-display); font-weight: 500; }

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 2;
  max-width: var(--max);
  margin: 0 auto;
  padding: 32px var(--pad) 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.footer p { margin: 0; }
.footer nav { display: flex; gap: 22px; }
.footer a:hover { color: var(--text); }

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }
.grid .card:nth-child(2) { transition-delay: 0.08s; }
.grid .card:nth-child(3) { transition-delay: 0.16s; }
.grid .card:nth-child(4) { transition-delay: 0.24s; }
.grid .card:nth-child(5) { transition-delay: 0.32s; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .about { grid-template-columns: 1fr; }
  .activity { --cell: 11px; --gap: 3px; --days: 30px; padding: 20px; }
  .stack-panel { padding: 20px; }
  .stack-body { grid-template-columns: 1fr; gap: 20px; }
  .stack-scene { max-width: 400px; }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .nav-links { gap: 18px; font-size: 13px; }
  .brand-text { display: none; }
  .hero { padding-top: 120px; }
  .scroll-hint { display: none; }
}

/* ---------- Motion / fallback ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .dot, .scroll-hint span, .gradient-text { animation: none; }
  .btn, .card, .card-link span, .panel-link span, .heatmap-cells .cell, .stack-row, .stack-swatch, .stack-bar i { transition: none; }
}
body.no-webgl #scene { display: none; }
