/* Reusable pieces: buttons, theme toggle, hero, cards, pillars, gallery, contact, toast. */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  min-height: 48px; /* Fitts: generous target */
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 550;
  font-size: var(--step-0);
  line-height: 1;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out), scale var(--dur-fast) var(--ease-out);
  will-change: transform;
}
.btn:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.btn:active { scale: 0.97; }
.btn .arrow { transition: translate var(--dur) var(--ease-spring); }
.btn:hover .arrow { translate: 0.25em 0; }

/* The single accent action on each page (Von Restorff). */
.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  box-shadow: 0 8px 24px -10px var(--accent);
}
.btn-primary:hover { box-shadow: 0 14px 32px -12px var(--accent); }
/* Bloom: a blurred copy of the accent behind the button that swells on hover (post-processing glow, in CSS). */
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 15% 10% -10%;
  z-index: -1;
  border-radius: inherit;
  background: var(--accent);
  filter: blur(18px);
  opacity: 0.35;
  transition: opacity var(--dur) var(--ease-out), inset var(--dur) var(--ease-out);
}
.btn-primary:hover::before { opacity: 0.7; inset: 5% 0 -18%; }
.btn-primary { isolation: isolate; }

.btn-quiet { box-shadow: none; padding-inline: 0.6rem; }
.btn-quiet:hover { box-shadow: none; text-decoration: underline; }

.btn-group { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease-out);
}
.theme-toggle:hover { background: var(--bg-raised); }
.theme-toggle svg { width: 20px; height: 20px; transition: rotate var(--dur-slow) var(--ease-spring); }
.theme-toggle:hover svg { rotate: 40deg; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  min-height: min(92svh, 920px);
  overflow-x: clip; /* the aura bleeds sideways; never let it cause horizontal scroll */
  display: grid;
  align-content: center;
  padding-block: var(--space-xl) var(--space-l);
}
.hero-aura {
  position: absolute;
  inset: -20% -10% 0;
  z-index: -1;
  pointer-events: none;
  filter: blur(70px) saturate(1.15);
  opacity: 0.75;
}
.hero-aura span {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: multiply;
  animation: drift 22s var(--ease-in-out) infinite alternate;
}
:root[data-theme="dark"] .hero-aura span { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-aura span { mix-blend-mode: screen; } }
.hero-aura span:nth-child(1) { width: 46vmax; height: 46vmax; left: 45%; top: 0; background: var(--glow-1); }
.hero-aura span:nth-child(2) { width: 38vmax; height: 38vmax; left: 62%; top: 30%; background: var(--glow-2); animation-duration: 28s; animation-delay: -8s; }
.hero-aura span:nth-child(3) { width: 30vmax; height: 30vmax; left: 30%; top: 40%; background: var(--glow-3); animation-duration: 34s; animation-delay: -16s; opacity: 0.6; }

/* WebGL ink field (js/modules/ink.js). The CSS aura above is the fallback and fades out once GL is running. */
.hero-gl {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
}
.hero.has-gl .hero-gl { opacity: 1; }
.hero.has-gl .hero-aura { opacity: 0; transition: opacity 1.2s var(--ease-out); }

.hero-name {
  margin-block: var(--space-m) var(--space-l);
  font-size: var(--step-hero);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.045em;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
}
.hero-name .word { display: inline-block; white-space: nowrap; }
.hero-name .char {
  display: inline-block;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144, "wght" var(--w, 400);
  transition: color var(--dur) var(--ease-out);
}
.hero-name .char.accent { color: var(--accent); font-style: italic; }

.hero-meta {
  display: grid;
  justify-items: start;
  gap: var(--space-m);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--step--1);
  color: var(--muted);
}
.status-dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
}
.status-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: ping 2.4s var(--ease-out) infinite;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: var(--space-m);
  translate: -50% 0;
  width: 1px;
  height: 56px;
  overflow: hidden;
  background: var(--line);
}
.scroll-cue::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ink);
  animation: cue 2.2s var(--ease-in-out) infinite;
}

/* ---------- Project cards (spotlight + tilt) ---------- */
.cards {
  display: grid;
  gap: var(--space-m);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); /* a lone card keeps card width */
}
.card {
  --mx: 50%;
  --my: 50%;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  min-height: 320px;
  padding: var(--space-m);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform var(--dur-slow) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.card::before {
  /* Cursor spotlight */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  background: radial-gradient(420px circle at var(--mx) var(--my), var(--accent-soft), transparent 60%);
  transition: opacity var(--dur) var(--ease-out);
}
.card::after {
  /* Rim light that follows the cursor */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  opacity: 0;
  background: radial-gradient(260px circle at var(--mx) var(--my), var(--accent), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  transition: opacity var(--dur) var(--ease-out);
  pointer-events: none;
}
.card.is-active { transition: transform 120ms linear, box-shadow var(--dur) var(--ease-out); }
.card:hover::before, .card:hover::after, .card:focus-visible::before { opacity: 1; }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-s); }
.card-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.card-icon img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.card h3 { font-size: var(--step-2); margin-top: var(--space-s); }
.card .chips { margin-top: auto; padding-top: var(--space-xs); } /* titles align across cards; chips sit on the floor */
.card p { color: var(--muted); }
.card-go {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), rotate var(--dur) var(--ease-spring);
}
.card:hover .card-go { background: var(--ink); color: var(--bg); rotate: -45deg; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
.chip.live { color: var(--accent); box-shadow: inset 0 0 0 1px currentColor; }

/* ---------- Pillars (what I work on) ---------- */
.pillars {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  background: var(--line);
  border-block: 1px solid var(--line);
}
.pillar {
  display: grid;
  gap: var(--space-s);
  align-content: start;
  padding: var(--space-l) var(--space-m);
  background: var(--bg);
}
.pillar-num { font-family: var(--font-display); font-style: italic; color: var(--accent); font-size: var(--step-1); }
.pillar h3 { font-size: var(--step-2); }
.pillar p { color: var(--muted); }

/* ---------- Big statement / marquee ---------- */
.marquee {
  overflow: hidden;
  padding-block: var(--space-l);
  border-block: 1px solid var(--line);
  -webkit-mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee-track {
  display: flex;
  width: max-content;
  gap: 3rem;
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  white-space: nowrap;
  animation: marquee 38s linear infinite;
}
.marquee-track span { display: inline-flex; align-items: center; gap: 3rem; }
.marquee-track span::after { content: "✳"; color: var(--accent); font-size: 0.6em; }
.marquee:hover .marquee-track { animation-play-state: paused; }

/* ---------- About ---------- */
.about-grid {
  display: grid;
  gap: var(--space-l);
  align-items: start;
}
@media (min-width: 860px) { .about-grid { grid-template-columns: 5fr 7fr; } }

.portrait {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 10%, var(--glow-1), transparent 60%),
    radial-gradient(100% 80% at 90% 90%, var(--glow-3), transparent 60%),
    var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow);
  view-transition-name: portrait;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(5rem, 14vw, 9rem);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  color: var(--ink);
  opacity: 0.85;
}
@media (min-width: 860px) { .portrait { position: sticky; top: 6rem; } }

.facts { display: grid; gap: 0; margin-top: var(--space-l); border-top: 1px solid var(--line); }
.facts li {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: var(--space-s);
  padding-block: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.facts dt, .facts .k { color: var(--muted); font-size: var(--step--1); padding-top: 0.15rem; }

/* ---------- Physics playground (js/modules/playground.js) ----------
   Without JS it's a plain wrapped list of round chips; with JS the bubbles fall, collide and can be thrown. */
.playground {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: var(--space-m);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  touch-action: pan-y;
}
.playground.is-sim { display: block; height: clamp(300px, 40vw, 380px); padding: 0; }
.bubble {
  display: grid;
  place-items: center;
  width: var(--size, 104px);
  height: var(--size, 104px);
  border-radius: 50%;
  background: var(--bubble-bg, var(--bg));
  color: var(--bubble-fg, var(--ink));
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 10px 24px -14px rgb(0 0 0 / 0.35);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 550;
  line-height: 1.15;
  user-select: none;
  -webkit-user-select: none;
}
.bubble span { display: block; font-size: 1.5rem; margin-bottom: 0.15rem; }
.playground.is-sim .bubble {
  position: absolute;
  left: 0;
  top: 0;
  cursor: grab;
  will-change: transform;
  touch-action: none; /* let a finger drag the bubble instead of scrolling the page */
}
.playground.is-sim .bubble.is-held { cursor: grabbing; box-shadow: inset 0 0 0 1px var(--ink), 0 18px 36px -14px rgb(0 0 0 / 0.45); }
.bubble.hot { --bubble-bg: var(--accent); --bubble-fg: var(--accent-ink); box-shadow: none; }
.bubble.inverse { --bubble-bg: var(--ink); --bubble-fg: var(--bg); box-shadow: none; }
.playground-hint {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  font-size: var(--step--1);
  color: var(--muted);
  pointer-events: none;
}

/* ---------- Off-the-clock gallery ---------- */
.gallery {
  display: grid;
  gap: var(--space-s);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.photo img { aspect-ratio: 4 / 3; object-fit: cover; }
.photo {
  position: relative;
  margin: 0;
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--bg-raised);
}
.photo img { width: 100%; transition: scale var(--dur-slow) var(--ease-out), filter var(--dur-slow) var(--ease-out); filter: saturate(0.9); }
.photo figcaption {
  position: absolute;
  inset: auto 0 0;
  padding: 2.5rem 1rem 0.9rem;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.65));
  color: #fff;
  font-size: var(--step--1);
  translate: 0 30%;
  opacity: 0;
  transition: translate var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.photo:hover img { scale: 1.05; filter: saturate(1.1); }
.photo:hover figcaption, .photo:focus-within figcaption { translate: 0 0; opacity: 1; }
@media (hover: none) { .photo figcaption { translate: 0 0; opacity: 1; } }

/* ---------- Contact ---------- */
.contact-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: var(--space-xl) var(--space-l);
  border-radius: calc(var(--radius) * 1.5);
  background: var(--ink);
  color: var(--bg);
  text-align: center;
}
.contact-band::before {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: -1;
  background: conic-gradient(from 0deg, transparent, var(--accent), transparent 30%, var(--glow-3), transparent 60%);
  filter: blur(80px);
  opacity: 0.35;
  animation: spin 18s linear infinite;
}
.contact-band h2 { font-size: var(--step-4); }
.contact-band p { margin: var(--space-m) auto var(--space-l); max-width: 40ch; opacity: 0.75; }
.contact-band .btn-group { justify-content: center; }
.contact-band .btn:not(.btn-primary) { --btn-fg: var(--bg); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25); }
:root[data-theme="dark"] .contact-band .btn:not(.btn-primary) { box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.25); }

.email-big {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 1rem + 4.5vw, 4.6rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat;
  transition: background-size var(--dur-slow) var(--ease-out), color var(--dur) var(--ease-out);
  overflow-wrap: anywhere;
}
.email-big:hover { background-size: 100% 2px; color: var(--accent); }

.links-list { border-top: 1px solid var(--line); margin-top: var(--space-l); }
.links-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  padding-block: 1.2rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--step-2);
  text-decoration: none;
  transition: padding var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.links-list a:hover { padding-inline: 0.75rem; color: var(--accent); }
.links-list small { font-family: var(--font-body); font-size: var(--step--1); color: var(--muted); }

/* ---------- Empty state (writing) ---------- */
.empty {
  display: grid;
  justify-items: start;
  gap: var(--space-m);
  padding: var(--space-l);
  border-radius: var(--radius);
  border: 1px dashed var(--line-strong);
}
.empty-art { font-family: var(--font-display); font-style: italic; font-size: var(--step-3); color: var(--accent); }
.topics { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 95;
  translate: -50% 150%;
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--step--1);
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: translate var(--dur) var(--ease-spring);
}
.toast.is-visible { translate: -50% 0; }

/* ---------- 404 ---------- */
.lost { text-align: center; padding-block: var(--space-xl); }
.lost-code {
  font-family: var(--font-display);
  font-size: clamp(7rem, 30vw, 18rem);
  line-height: 0.85;
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  color: var(--accent);
}
.lost .btn-group { justify-content: center; margin-top: var(--space-l); }
