/* ---------- tokens ----------
   Dark is the default and stays the default on a first visit — it is the
   design's signature. `data-theme="light"` on <html> flips the palette; the
   nav toggle sets it and stores the choice. Every value that differs between
   the two themes lives here, so no rule below hardcodes a theme colour. */
:root {
  color-scheme: dark;

  --canvas: #05060a;
  --ink: #f4f6fb;
  --muted: #9aa3b8;
  --faint: #6b7488;

  --glass: rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.075);
  --hair: rgba(255, 255, 255, 0.09);
  --hair-lit: rgba(255, 255, 255, 0.22);

  --nav-bg: rgba(10, 12, 20, 0.55);
  --nav-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  --chip-bg: rgba(255, 255, 255, 0.035);

  --card-inset: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  --card-inset-lit: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
  --card-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  --card-shadow-lit: 0 30px 70px rgba(0, 0, 0, 0.55);
  --spotlight: rgba(255, 255, 255, 0.09);
  --bloom: 0.42;
  --bloom-lit: 0.85;

  --veil:
    radial-gradient(ellipse 100% 70% at 50% 0%, transparent, rgba(5, 6, 10, 0.4) 100%),
    linear-gradient(180deg, rgba(5, 6, 10, 0.12) 0%, rgba(5, 6, 10, 0.45) 100%);
  --orb-opacity: 1;
  --grain-opacity: 0.16;

  --hero-grad: linear-gradient(96deg, #ffffff 4%, #d7ddff 30%, #8fb9ff 62%, #ff8fc6 96%);
  --live: #3ee08f;
  --live-glow: rgba(62, 224, 143, 0.6);
  --on-accent: #0a0b12;
  --select-bg: rgba(124, 92, 255, 0.4);
  --select-ink: #ffffff;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --shell: min(1180px, 100% - 2.5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="light"] {
  color-scheme: light;

  /* A cool off-white, not paper white — the frosted glass needs something to
     sit on or the cards disappear into the page. */
  --canvas: #eceff7;
  --ink: #0b0d14;
  --muted: #525a6e;
  --faint: #79819a;

  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --hair: rgba(11, 13, 20, 0.1);
  --hair-lit: rgba(11, 13, 20, 0.28);

  --nav-bg: rgba(255, 255, 255, 0.62);
  --nav-shadow: 0 8px 32px rgba(24, 30, 60, 0.12);
  --chip-bg: rgba(255, 255, 255, 0.6);

  --card-inset: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
  --card-inset-lit: 0 1px 0 rgba(255, 255, 255, 1) inset;
  --card-shadow: 0 14px 40px rgba(24, 30, 60, 0.1);
  --card-shadow-lit: 0 26px 60px rgba(24, 30, 60, 0.17);
  --spotlight: rgba(255, 255, 255, 0.75);
  --bloom: 0.26;
  --bloom-lit: 0.55;

  /* The veil lightens instead of darkens, or the blobs turn muddy. Kept thin
     on purpose: too much white here and the page reads as plain paper, which
     throws away the whole point of the gradient field. */
  --veil:
    radial-gradient(ellipse 100% 70% at 50% 0%, rgba(255, 255, 255, 0.06), rgba(236, 239, 247, 0.3) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(236, 239, 247, 0.4) 100%);
  --orb-opacity: 0.7;
  --grain-opacity: 0.05;

  --hero-grad: linear-gradient(96deg, #0b0d14 4%, #3b2fb8 34%, #8b2fc4 66%, #c2186f 96%);
  --live: #0d9f5d;
  --live-glow: rgba(13, 159, 93, 0.45);
  --select-bg: rgba(124, 92, 255, 0.22);
  --select-ink: #0b0d14;
}

/* Palette cross-fade.
   These are declared permanently on the surfaces that actually change colour,
   NOT toggled on around the switch with a universal `!important` rule. Adding
   and removing a transition mid-flight strands elements at the wrong value —
   rapid clicks on the toggle left the sun icon showing in light mode, and it
   never recovered. Rules further down that set their own `transition` (.card,
   .arrow, .nav-links a, .theme-toggle) already cover these properties. */
body,
.nav,
.chip,
.status,
.card-url,
.orb,
.grain {
  transition-property: background-color, border-color, color, box-shadow, opacity;
  transition-duration: 0.35s;
  transition-timing-function: var(--ease);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

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

/* ---------- gradient field ----------
   Soft blobs are painted as radial-gradients rather than blurred boxes.
   A `filter: blur()` on a 60vw element re-rasterizes every animation frame
   and tanks the whole page; gradients cost nothing and look the same. */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Two animated layers, not four. Each one is a full-viewport composited
   surface that repaints for the life of the page, so parallax is worth
   exactly two of them and no more. No `will-change` — the browser promotes
   these while the animation runs and releases them when it does not. */
.orb {
  position: absolute;
  inset: -30%;
  opacity: var(--orb-opacity);
}

.orb-1 {
  background:
    radial-gradient(38% 34% at 22% 16%, rgba(124, 92, 255, 0.85), transparent 70%),
    radial-gradient(30% 28% at 78% 8%, rgba(0, 211, 224, 0.55), transparent 70%),
    radial-gradient(32% 30% at 18% 84%, rgba(255, 176, 32, 0.3), transparent 72%);
  animation: drift-a 40s var(--ease) infinite alternate;
}
.orb-2 {
  background:
    radial-gradient(34% 30% at 72% 46%, rgba(255, 61, 129, 0.5), transparent 70%),
    radial-gradient(26% 24% at 30% 62%, rgba(77, 141, 255, 0.45), transparent 72%),
    radial-gradient(30% 26% at 88% 88%, rgba(124, 92, 255, 0.45), transparent 72%);
  animation: drift-b 56s var(--ease) infinite alternate;
}
/* folded into the two layers above — kept in the DOM so the markup stays symmetric */
.orb-3,
.orb-4 { display: none; }

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(4%, 3%, 0) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.08); }
  to   { transform: translate3d(-5%, 4%, 0) scale(0.95); }
}

/* film grain keeps the gradients from banding */
.grain {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
}

/* a vignette so text always wins over the blobs, whichever way it goes */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--veil);
}

/* ---------- nav ---------- */
.nav {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: var(--shell);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.7rem 0.6rem 0.8rem;
  border-radius: 999px;
  background: var(--nav-bg);
  border: 1px solid var(--hair);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--nav-shadow);
}

.nav-brand { display: flex; align-items: center; gap: 0.6rem; }

.nav-mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--on-accent);
  background: linear-gradient(135deg, #7c5cff, #00d3e0 55%, #ff3d81);
}

.nav-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.nav-links { display: flex; align-items: center; gap: 0.35rem; }

.nav-links a {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.nav-links a:hover { color: var(--ink); background: var(--glass-strong); }

/* ---------- theme toggle ----------
   Both icons are stacked in one grid cell and cross-faded, so the button
   never changes size and there is no layout shift on switch. The icon shows
   the theme you are going TO: sun while dark, moon while light. */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 0.15rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--hair);
  background: var(--chip-bg);
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    color 0.25s var(--ease),
    background 0.25s var(--ease),
    border-color 0.25s var(--ease);
}
.theme-toggle:hover {
  color: var(--ink);
  background: var(--glass-strong);
  border-color: var(--hair-lit);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  transition: opacity 0.28s var(--ease), transform 0.42s var(--ease);
}

.icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }
.icon-sun  { opacity: 1; transform: none; }

:root[data-theme="light"] .icon-moon { opacity: 1; transform: none; }
:root[data-theme="light"] .icon-sun  { opacity: 0; transform: rotate(90deg) scale(0.4); }

/* ---------- layout ---------- */
main { position: relative; z-index: 1; }

.hero,
.work { width: var(--shell); margin-inline: auto; }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8rem 0 5rem;
  position: relative;
}

.eyebrow {
  margin: 0 0 1.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--faint);
}

.hero-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.2rem, 13vw, 9.5rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
}

/* fit-content so the gradient maps across the word, not the whole column */
.hero-title .line {
  display: block;
  width: fit-content;
  max-width: 100%;
  background: var(--hero-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rise 1s var(--ease) both;
}
.hero-title .line:nth-child(2) { animation-delay: 0.1s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(0.35em); }
  to   { opacity: 1; transform: none; }
}

.hero-meta {
  margin-top: 2.4rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  animation: rise 1s var(--ease) 0.24s both;
}
.hero-meta strong { color: var(--ink); font-weight: 500; }
.hero-meta .sep { width: 1px; height: 12px; background: var(--hair-lit); }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live-glow);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.scroll-cue {
  position: absolute;
  bottom: 2.5rem;
  left: 0;
  width: 24px; height: 40px;
  border: 1px solid var(--hair-lit);
  border-radius: 999px;
  display: grid;
  place-items: start center;
  padding-top: 7px;
}
.scroll-cue span {
  width: 3px; height: 8px;
  border-radius: 999px;
  background: var(--muted);
  animation: cue 1.9s var(--ease) infinite;
}
@keyframes cue {
  0%   { opacity: 0; transform: translateY(-3px); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(14px); }
}

/* ---------- section head ---------- */
.work { padding-bottom: 7rem; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: 2rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--hair);
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--faint);
}

/* ---------- project grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1.15rem;
}

.card {
  --mx: 50%;
  --my: 0%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding: 1.7rem;
  min-height: 300px;
  border-radius: 26px;
  overflow: hidden;
  isolation: isolate;
  background: var(--glass);
  border: 1px solid var(--hair);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--card-inset), var(--card-shadow);
  transition:
    transform 0.5s var(--ease),
    border-color 0.4s var(--ease),
    box-shadow 0.5s var(--ease),
    background 0.4s var(--ease);
}

/* accent bloom, tinted per project via --a1/--a2 */
.card::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -45%;
  right: -25%;
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle closest-side, var(--a1), transparent 100%);
  opacity: var(--bloom);
  transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
}

/* cursor spotlight */
.card::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(360px circle at var(--mx) var(--my), var(--spotlight), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.card:hover,
.card:focus-visible {
  transform: translateY(-6px);
  border-color: var(--hair-lit);
  background: var(--glass-strong);
  box-shadow: var(--card-inset-lit), var(--card-shadow-lit);
  outline: none;
}
.card:hover::before,
.card:focus-visible::before { opacity: var(--bloom-lit); transform: scale(1.12); }
.card:hover::after,
.card:focus-visible::after { opacity: 1; }

.card:focus-visible { box-shadow: 0 0 0 2px var(--a1), var(--card-shadow-lit); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  letter-spacing: 0.1em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.24rem 0.6rem 0.24rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--hair);
  background: var(--chip-bg);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.status i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 8px var(--live);
}

.card-body { flex: 1; }

.card h3 {
  margin: 0 0 0.55rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: -0.025em;
}

.card p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.62;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.26rem 0.62rem;
  border-radius: 8px;
  border: 1px solid var(--hair);
  background: var(--chip-bg);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--hair);
}

.card-url {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}
.card:hover .card-url { color: var(--ink); }

.arrow {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--hair);
  color: var(--ink);
  transition: transform 0.45s var(--ease), background 0.35s var(--ease), border-color 0.35s var(--ease), color 0.35s var(--ease);
}
.card:hover .arrow {
  transform: translate(3px, -3px);
  background: linear-gradient(135deg, var(--a1), var(--a2));
  border-color: transparent;
  color: var(--on-accent);
}
.arrow svg { width: 15px; height: 15px; }

/* ---------- reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.75s var(--ease), transform 0.75s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

/* ---------- footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  width: var(--shell);
  margin: 0 auto;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--faint);
}
.footer a { transition: color 0.25s var(--ease); }
.footer a:hover { color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  :root { --shell: calc(100% - 1.75rem); }
  .nav { top: 0.6rem; padding: 0.5rem 0.5rem 0.5rem 0.7rem; }
  .nav-name { display: none; }
  .hero { padding-top: 7rem; }
  .hero-meta { flex-wrap: wrap; }
  .scroll-cue { display: none; }
  .card { padding: 1.4rem; min-height: 0; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .orb, .dot, .scroll-cue span, .hero-title .line, .hero-meta { animation: none !important; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .card, .arrow, .card::before, .card::after { transition: none; }
  body, .nav, .chip, .status, .card-url, .orb, .grain { transition: none; }
  .card:hover { transform: none; }
  /* icons still swap, they just do not spin */
  .theme-toggle svg { transition: opacity 0.01s; }
  .icon-moon, .icon-sun,
  :root[data-theme="light"] .icon-moon,
  :root[data-theme="light"] .icon-sun { transform: none; }
}
