:root {
  --bg: #000;
  --surface: rgba(6, 20, 26, 0.55);
  --text: #e8fbff;
  --muted: #88aab2;
  --line: rgba(34, 211, 238, 0.18);
  --line-strong: rgba(34, 211, 238, 0.45);
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.1);
  --ok: #4ade80;
  --wip: #fbbf24;
  --pause: #64748b;
  --radius: 18px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 70% 20%, #062a33, transparent 60%);
}
a { color: inherit; }
::selection { background: var(--accent); color: #001318; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 32px; } }

/* Header */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; }
.logo-mark {
  width: 22px; height: 24px; background: var(--accent);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  box-shadow: inset 0 0 0 4px #000;
}
nav { display: flex; gap: 4px; }
nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 15px; }
nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* Accessibility helpers */
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 10px;
  background: var(--accent); color: #001318; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Hero */
.hero { position: relative; min-height: 100vh; min-height: 100svh; display: flex; align-items: center; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-content {
  position: relative; z-index: 1; width: 100%; padding-top: 96px; padding-bottom: 72px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.eyebrow { font: 14px var(--mono); color: var(--accent); letter-spacing: 0.15em; text-transform: uppercase; margin: 0 0 4px; }
h1 { font-size: clamp(60px, 11vw, 128px); line-height: 0.9; letter-spacing: -0.045em; margin: 0 0 22px; }
.tagline { font-size: clamp(19px, 2.4vw, 23px); line-height: 1.4; max-width: 32ch; margin: 0 0 14px; color: #c6eef4; }
.about { color: var(--muted); max-width: 56ch; margin: 0 0 32px; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* Puzzle cube */
.cube-wrap { display: flex; flex-direction: column; align-items: center; margin-bottom: 36px; }
.cube-stage {
  --s: 56px;
  width: calc(var(--s) * 6.6); height: calc(var(--s) * 6.6);
  perspective: 1000px; position: relative; cursor: grab; touch-action: none;
  border-radius: 50%; user-select: none; -webkit-user-select: none;
}
.cube-stage.orbiting { cursor: grabbing; }
.cube-stage.turning, .cube-stage.turning * { cursor: grabbing; }
/* Glow behind the cube */
.cube-stage::before {
  content: ""; position: absolute; inset: 18%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(34, 211, 238, 0.22), transparent); pointer-events: none;
  transition: background .4s;
}
.cube-stage.solved::before { background: radial-gradient(closest-side, rgba(74, 222, 128, 0.5), transparent); }
/* Ring that marks the area for rotating the whole cube */
.cube-stage::after {
  content: ""; position: absolute; inset: 2px; border-radius: 50%; pointer-events: none;
  border: 1px dashed rgba(34, 211, 238, 0.28); transition: border-color .2s, box-shadow .2s;
}
.cube-stage:hover::after, .cube-stage.orbiting::after { border-color: rgba(34, 211, 238, 0.6); }
.cube-stage.orbiting::after { box-shadow: 0 0 30px rgba(34, 211, 238, 0.18) inset; }
.orbit-label {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); white-space: nowrap;
  font: 11px var(--mono); letter-spacing: .08em; color: rgba(34, 211, 238, 0.6); pointer-events: none;
  background: #000; padding: 0 8px; opacity: 0; transition: opacity .2s;
}
.cube-stage:hover .orbit-label { opacity: 1; }
.cube-stage.turning .orbit-label { opacity: 0; }
@media (max-width: 480px) { .cube-stage { --s: 44px; } }
.cube { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.cubie { position: absolute; transform-style: preserve-3d; }
.face {
  position: absolute; left: 0; top: 0; box-sizing: border-box; padding: 3px;
  background: #05080a; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.sticker {
  display: block; width: 100%; height: 100%; border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), inset 0 -6px 12px rgba(0, 0, 0, 0.18);
}
.face.has-sticker { cursor: pointer; }
.sticker { transition: filter .12s, box-shadow .12s; }
.cube-stage:not(.orbiting):not(.turning) .face.has-sticker:hover .sticker {
  filter: brightness(1.2);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 14px rgba(255, 255, 255, 0.35);
}
.cubie.active .sticker { filter: brightness(1.12); }
.cube-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.btn.btn-small { padding: 7px 14px; font-size: 13px; border-radius: 10px; }
.btn.btn-icon { width: 36px; height: 34px; padding: 0; justify-content: center; font-size: 16px; border-radius: 10px; cursor: pointer; color: var(--text); }
.btn-small { cursor: pointer; color: var(--text); }
.cube-help { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; }
.cube-help .hi { color: var(--accent); margin-right: 4px; }
.motion-toggle {
  position: absolute; right: 16px; bottom: 20px; z-index: 2;
  font: 500 12px var(--sans); color: var(--muted); padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.12); cursor: pointer;
}
.motion-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.btn {
  display: inline-flex; align-items: center; padding: 12px 22px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(6, 20, 26, 0.6); text-decoration: none;
  font-weight: 500; font-size: 15px; transition: border-color .2s, transform .2s, box-shadow .2s;
  backdrop-filter: blur(6px);
}
.btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #001318; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { box-shadow: 0 0 24px rgba(34, 211, 238, 0.45); }

/* Sections */
.section { padding-top: 96px; padding-bottom: 32px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
h2 { font-size: clamp(30px, 4vw, 40px); letter-spacing: -0.03em; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 13px var(--sans); padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--accent); color: #001318; border-color: var(--accent); }

/* Project cards */
.grid { display: grid; grid-template-columns: 1fr; gap: 20px; perspective: 1000px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 24px;
  min-height: 220px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  transform-style: preserve-3d; transition: transform .15s ease-out, border-color .2s;
}
.card:hover { border-color: var(--line-strong); }
.card[hidden] { display: none; }
.card.featured { border-color: rgba(34, 211, 238, 0.3); }
.card-top, .card p, .card-bottom { transform: translateZ(24px); }
.card h3 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.status {
  flex-shrink: 0; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.1);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pause); }
.status-active::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-in-progress::before { background: var(--wip); }
.card-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tags li { font: 12px var(--mono); padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: #7fe3f5; }
.card-links { display: flex; gap: 14px; }
.card-links a { font-size: 14px; font-weight: 600; text-decoration: none; color: var(--accent); }
.card-links a:hover { text-decoration: underline; }

/* Links */
.links { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .links { grid-template-columns: repeat(2, 1fr); } }
.link-item {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .2s, transform .2s;
}
.link-item:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.link-icon {
  display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 18px;
}
.link-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.link-text small { color: var(--muted); font-size: 13px; }
.link-arrow { color: var(--muted); }
.link-item:hover .link-arrow { color: var(--accent); }

/* Footer */
.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding-top: 32px; padding-bottom: 40px; margin-top: 72px;
  border-top: 1px solid rgba(255, 255, 255, 0.06); color: #4f6a71; font: 13px var(--mono);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .btn, .link-item { transition: none; }
}

/* About me */
.about-me { display: grid; grid-template-columns: 1fr; gap: 32px; }
@media (min-width: 860px) { .about-me { grid-template-columns: 1.4fr 1fr; } }
.about-text p { margin: 0 0 16px; color: #c6eef4; font-size: 17px; max-width: 62ch; }
.facts {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; margin: 0; align-content: start;
  padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.facts dt { color: var(--muted); font: 13px var(--mono); padding-top: 2px; }
.facts dd { margin: 0; }

/* Footer links */
.legal-links { display: flex; flex-wrap: wrap; gap: 18px; }
.legal-links a { color: var(--muted); text-decoration: none; }
.legal-links a:hover { color: var(--accent); }

/* Legal pages */
.legal { max-width: 760px; padding-top: 112px; }
.legal h1 { font-size: clamp(36px, 6vw, 56px); margin-bottom: 28px; }
.legal h2 { font-size: 22px; margin: 36px 0 10px; letter-spacing: -0.01em; }
.legal h3 { font-size: 17px; margin: 24px 0 6px; }
.legal p, .legal li { color: #c6eef4; }
.legal a { color: var(--accent); }
.legal address { font-style: normal; }
.legal .todo { background: rgba(251, 191, 36, 0.15); color: #fde68a; padding: 0 4px; border-radius: 4px; }
.back { display: inline-block; margin-bottom: 24px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }

/* Paused motion */
[data-motion="off"] .card, [data-motion="off"] .btn, [data-motion="off"] .link-item { transition: none; }

/* Watchlist page */
.watch-page { padding-top: 104px; }
.watch-head h1 { font-size: clamp(48px, 9vw, 96px); margin-bottom: 12px; }
.watch-head .about { margin-bottom: 28px; }
.watch-tools { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.watch-selects { display: flex; flex-wrap: wrap; gap: 8px; }
.watch-selects input, .watch-selects select {
  font: 14px var(--sans); color: var(--text); background: rgba(6, 20, 26, 0.7);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.watch-selects input:focus, .watch-selects select:focus { border-color: var(--accent); outline: none; }
.watch-count { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.watch-grid-public { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.wcard {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.wcard:hover { border-color: var(--line-strong); }
.wposter { position: relative; align-self: start; }
.wposter img, .poster-empty { width: 120px; aspect-ratio: 2 / 3; height: auto; object-fit: cover; border-radius: 10px; display: block; background: #071216; }
.poster-empty { display: grid; place-items: center; font-size: 40px; font-weight: 700; color: var(--line-strong); }
.wtype {
  position: absolute; left: 6px; top: 6px; font: 600 11px var(--sans); padding: 2px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.75); color: var(--accent);
}
.wrating {
  position: absolute; right: 6px; bottom: 6px; font: 700 13px var(--sans); padding: 3px 8px; border-radius: 8px;
  background: var(--accent); color: #001318;
}
.wbody { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.wbody h2 { font-size: 18px; letter-spacing: -0.01em; line-height: 1.25; }
.wmeta { margin: 0; color: var(--muted); font-size: 13px; }
.wdesc { margin: 2px 0 0; color: #b5d3da; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wdesc.open { -webkit-line-clamp: unset; display: block; }
.more { align-self: flex-start; background: none; border: 0; padding: 0; color: var(--accent); font: 600 13px var(--sans); cursor: pointer; }
.wwhere { margin: 2px 0 0; font-size: 13px; color: #c6eef4; }
.wwhere span { color: var(--muted); }
.attribution { margin-top: 48px; color: #4f6a71; font-size: 12px; max-width: 80ch; }
.attribution a { color: var(--muted); }
@media (max-width: 420px) { .wcard { grid-template-columns: 90px 1fr; } .wposter img, .poster-empty { width: 90px; } }
