/* ============================================================
   Theme tokens
   ============================================================ */
:root,
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --body: #d4d4d4;
  --muted: #a3a3a3;
  --faint: #737373;
  --border: #262626;
  --border-strong: #404040;
  --card: #0f0f0f;
  --accent: #60a5fa;
  --tag-bg: rgba(59, 130, 246, 0.15);
  --tag-fg: #93c5fd;
  --banner: #3b5bff;
  --banner-fg: #ffffff;
  --toggle-bg: rgba(10, 10, 10, 0.72);
  --fade: #0a0a0a;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --fg: #171717;
  --body: #404040;
  --muted: #737373;
  --faint: #a3a3a3;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --card: #ffffff;
  --accent: #2563eb;
  --tag-bg: #eff6ff;
  --tag-fg: #1d4ed8;
  --banner: #3b5bff;
  --banner-fg: #ffffff;
  --toggle-bg: rgba(250, 250, 250, 0.72);
  --fade: #fafafa;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

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

img,
svg {
  display: block;
}

button {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* ============================================================
   Skip link
   ============================================================ */
.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.875rem;
  transform: translateY(-200%);
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ============================================================
   Page shell
   ============================================================ */
.page {
  position: relative;
  max-width: 56rem;
  margin: 0 auto;
  padding: 4rem 1.5rem 0;
}

@media (min-width: 768px) {
  .page {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 2.5rem;
  }
}

.container {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ============================================================
   Theme toggle
   ============================================================ */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--toggle-bg);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  position: absolute;
  inset: 0;
  width: 1rem;
  height: 1rem;
  margin: auto;
}

.theme-toggle .icon-sun {
  opacity: 1;
}

.theme-toggle .icon-moon {
  opacity: 0;
}

[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 0;
}

[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 1;
}

/* Icon swap: outgoing icon rotates away, incoming one springs in. */
@keyframes toggle-icon-in {
  from {
    opacity: 0;
    transform: rotate(-90deg) scale(0.4);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

@keyframes toggle-icon-out {
  from {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
  to {
    opacity: 0;
    transform: rotate(90deg) scale(0.4);
  }
}

.theme-toggle.is-toggling .icon-sun {
  animation: toggle-icon-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle.is-toggling .icon-moon {
  animation: toggle-icon-out 0.3s ease both;
}

[data-theme="light"] .theme-toggle.is-toggling .icon-sun {
  animation: toggle-icon-out 0.3s ease both;
}

[data-theme="light"] .theme-toggle.is-toggling .icon-moon {
  animation: toggle-icon-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   Theme wipe (View Transitions)
   ============================================================ */
:root[data-theme-wipe]::view-transition-old(root) {
  mix-blend-mode: normal;
  animation: none;
}

:root[data-theme-wipe]::view-transition-new(root) {
  z-index: 1;
  mix-blend-mode: normal;
  animation: 0.5s cubic-bezier(0.4, 0, 0.2, 1) theme-wipe;
}

@keyframes theme-wipe {
  from {
    clip-path: circle(0 at var(--wipe-x) var(--wipe-y));
  }
  to {
    clip-path: circle(var(--wipe-r) at var(--wipe-x) var(--wipe-y));
  }
}

/* Keep the new snapshot from catching half-finished color transitions. */
:root[data-theme-wipe] *,
:root[data-theme-wipe] *::before,
:root[data-theme-wipe] *::after {
  transition: none !important;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  margin-bottom: 2.5rem;
}

@media (min-width: 768px) {
  .sidebar {
    margin-bottom: 0;
  }
}

.avatar {
  display: grid;
  place-items: center;
  width: 96px;
  max-width: 200px;
  aspect-ratio: 1;
  margin-bottom: 1rem;
  border-radius: 30%;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), transparent 45%),
    linear-gradient(135deg, #1d4ed8, #0ea5e9);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  container-type: inline-size;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.avatar:hover {
  transform: scale(1.015);
}

.avatar-initials {
  font-family: Silkscreen, ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(1.75rem, 24cqw, 4rem);
  letter-spacing: 0.04em;
  color: #ffffff;
  line-height: 1;
  transform: translateY(-2%);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 768px) {
  .avatar {
    width: 100%;
  }
}

#site-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg);
}

.tagline {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 1.25rem;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .links {
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 1.5rem;
  }
}

.links a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  transition: color 0.15s ease;
}

.links a:hover {
  color: var(--fg);
}

.link-icon {
  display: flex;
}

.links svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ============================================================
   Organizations
   ============================================================ */
.orgs {
  margin-top: 2rem;
}

.orgs h2 {
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
}

.orgs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.orgs a {
  display: block;
  transition: opacity 0.15s ease;
}

.orgs a:hover {
  opacity: 0.7;
}

.orgs img {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  object-fit: cover;
}

/* ============================================================
   Main / hero
   ============================================================ */
main {
  min-width: 0;
}

.banner {
  position: relative;
  width: 100%;
  aspect-ratio: 1344 / 620;
  min-height: 12rem;
  overflow: hidden;
  border-radius: 0.75rem 0.75rem 0 0;
  background: var(--card);
  isolation: isolate;
  container-type: inline-size;
}

/* !important: MapLibre's own CSS sets position: relative on this element. */
.map-canvas {
  position: absolute !important;
  inset: 0;
}

.map-clouds,
.map-fade,
.map-plane {
  position: absolute;
  pointer-events: none;
}

/* Two see-through cloud layers. Each is two tiles wide, so the loop is seamless. */
.map-clouds {
  inset: 0 auto 0 0;
  width: 200%;
  opacity: 0.65; /* cloud strength */
  animation: map-drift 90s linear infinite;
}

.map-clouds::before,
.map-clouds::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/clouds.svg") 0 0 / 50% 100% repeat-x;
}

/* Second layer is flipped for depth. */
.map-clouds::after {
  transform: scaleY(-1);
  opacity: 0.45;
}

[data-theme="dark"] .map-clouds {
  opacity: 0.18;
}

@keyframes map-drift {
  to { transform: translateX(-50%); }
}

.map-plane {
  --size: clamp(22px, 6cqw, 40px); /* 50% of the old size */
  top: 78%;
  left: 0;
  width: var(--size);
  height: var(--size);
  animation: map-fly 16s linear infinite; /* flight speed */
}

.map-plane img {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotate(45deg);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}

/* Contrails: length and position follow the plane size */
.map-plane::before,
.map-plane::after {
  content: "";
  position: absolute;
  right: 55%;
  top: 26%;
  width: 160%;
  height: 1.5px;
  border-radius: 1.5px;
  background: linear-gradient(to left, rgba(255,255,255,.95), transparent);
}

.map-plane::after {
  top: 72%;
}

@keyframes map-fly {
  from { transform: rotate(-20deg) translateX(-45cqw); }
  to { transform: rotate(-20deg) translateX(135cqw); }
}

.map-fade {
  inset: auto 0 0;
  height: 22%;
  background: linear-gradient(to top, var(--bg), transparent);
}

.map-time {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  background: var(--toggle-bg);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.map-credit {
  position: absolute;
  right: 0.25rem;
  bottom: 0.25rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: var(--toggle-bg);
  color: var(--muted);
  font-size: 0.625rem;
}

.map-marker {
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #2f9bf4;
  box-shadow: 0 0 0 8px rgba(47,155,244,.22);
}

@media (prefers-reduced-motion: reduce) {
  .map-plane { display: none; }
}

/* ============================================================
   Section headings + about
   ============================================================ */
main h2,
.showcase-section h2 {
  margin: 2.5rem 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
}

.about p {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--body);
}

.about p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   Stack
   ============================================================ */
.stack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.625rem;
}

.stack-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  padding: 1.125rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.stack-card img {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}

/* Single-color logos turn white in dark mode */
[data-theme="dark"] .stack-card img.is-mono {
  filter: brightness(0) invert(1);
}

@media (max-width: 479px) {
  .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================================================
   Showcase
   ============================================================ */
.showcase-section {
  padding-bottom: 4rem;
}

.showcase-section h2 {
  margin-top: 2.5rem;
}

.bongo-stage {
  --bongo-panel: #12110f;
  --bongo-panel-top: #191816;
  --bongo-ink: #f3efe4;
  --bongo-soft: #b6ae9f;
  --bongo-faint: #7f7768;
  --bongo-line: #2f2c26;
  --bongo-grid: rgba(243, 239, 228, 0.05);
  --bongo-field: #1c1a17;
  --bongo-field-line: #d8d0bf;
  --bongo-field-shadow: rgba(0, 0, 0, 0.35);
  --bongo-key: #201e1a;
  --bongo-accent: #8aa0ff;
  --bongo-wrong: #ff7b72;
  --bongo-good: #7bd88f;
  --bongo-tip-bg: #f3efe4;
  --bongo-tip-fg: #14120f;
  position: relative;
  width: 100%;
  border: 1px solid rgba(243, 239, 228, 0.16);
  border-radius: 0.5rem;
  overflow: hidden;
  background:
    radial-gradient(75% 100% at 12% 0%, rgba(138, 160, 255, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bongo-panel-top), var(--bongo-panel));
  color: var(--bongo-ink);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.8);
  isolation: isolate;
}

[data-theme="light"] .bongo-stage {
  --bongo-panel: #f3efe4;
  --bongo-panel-top: #f7f3e9;
  --bongo-ink: #171410;
  --bongo-soft: #5f594e;
  --bongo-faint: #a49c8d;
  --bongo-line: #d6cfbf;
  --bongo-grid: rgba(23, 20, 16, 0.05);
  --bongo-field: rgba(255, 255, 255, 0.55);
  --bongo-field-line: #171410;
  --bongo-field-shadow: rgba(23, 20, 16, 0.08);
  --bongo-key: rgba(255, 255, 255, 0.5);
  --bongo-accent: #3b5bff;
  --bongo-wrong: #cf222e;
  --bongo-good: #2f7d4a;
  --bongo-tip-bg: #171410;
  --bongo-tip-fg: #f3efe4;
  border-color: rgba(23, 20, 16, 0.2);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.55);
}

.bongo-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--bongo-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bongo-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(90% 80% at 50% 40%, #000, transparent 85%);
  -webkit-mask-image: radial-gradient(90% 80% at 50% 40%, #000, transparent 85%);
}

.bongo-topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--bongo-line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--bongo-soft);
}

.bongo-dots {
  display: flex;
  gap: 0.3rem;
}

.bongo-dots i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--bongo-line);
}

.bongo-dots i:nth-child(1) {
  background: #e26d5c;
}

.bongo-dots i:nth-child(2) {
  background: #e8b44a;
}

.bongo-dots i:nth-child(3) {
  background: #6fb37a;
}

.bongo-label {
  font-weight: 700;
  color: var(--bongo-ink);
}

.bongo-hint {
  margin-left: auto;
  color: var(--bongo-faint);
}

.bongo-scene {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1.25rem 1.5rem;
}

.bongo-copy {
  max-width: 36rem;
  min-height: 0.5rem;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.3rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  text-align: center;
  color: var(--bongo-faint);
  white-space: pre-wrap;
}

.bongo-char.is-pending {
  color: var(--bongo-faint);
}

.bongo-char.is-correct {
  color: var(--bongo-ink);
}

.bongo-char.is-wrong {
  color: var(--bongo-wrong);
  text-decoration: underline wavy;
}

.bongo-field {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--bongo-field-line);
  border-radius: 0.375rem;
  background: var(--bongo-field);
  box-shadow: 0 2px 0 var(--bongo-field-shadow);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.bongo-field:focus-within {
  box-shadow: 0 0 0 3px rgba(59, 91, 255, 0.18);
}

.bongo-prompt {
  flex-shrink: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bongo-accent);
}

.bongo-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--bongo-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.4;
}

.bongo-input::placeholder {
  color: var(--bongo-faint);
}

.bongo-input:focus-visible {
  outline: none;
}

.bongo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: var(--bongo-faint);
}

.bongo-stats {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-variant-numeric: tabular-nums;
}

.bongo-meta kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--bongo-line);
  border-bottom-width: 2px;
  border-radius: 0.25rem;
  background: var(--bongo-key);
  color: var(--bongo-soft);
  font-family: inherit;
  font-size: 0.65rem;
}

.bongo-cat-wrap {
  position: relative;
  z-index: 2;
  width: clamp(190px, 42%, 340px);
  /* Crop the sprite's transparent bottom so the body sits on the input bar. */
  aspect-ratio: 397 / 175;
  margin: -0.15rem auto -0.65rem;
  transform-origin: 50% 100%;
  transition: transform 0.1s ease-out;
}

.bongo-cat-wrap.is-pulsing {
  transform: scale(1.06);
}

/* .bongo-cat {
  position: absolute;
  inset: 0;
  cursor: pointer;
  outline-offset: 6px;
} */

.bongo-cat {
  position: absolute;
  top: 105px;
  left: 40vh;
  width: 30%;
  aspect-ratio: 397 / 175;
  cursor: pointer;
  outline-offset: 6px;
}

.bongo-sprite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.bongo-cat:focus-visible {
  outline: 2px solid var(--bongo-accent);
  border-radius: 0.5rem;
}

/* .bongo-sprite {
  position: absolute;
  top: 105px;
  left: 40vh;
  width: 30%;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
} */

.bongo-tooltip {
  position: absolute;
  left: 45vh;
  /* bottom: calc(100% + 0.5rem); */
  top: 70px;
  z-index: 2;
  padding: 0.35rem 0.65rem;
  border-radius: 0.375rem;
  background: var(--bongo-tip-bg);
  color: var(--bongo-tip-fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.25rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.bongo-tooltip.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bongo-stage.is-complete .bongo-field {
  border-color: var(--bongo-good);
  box-shadow: 0 0 0 3px rgba(47, 125, 74, 0.16);
}

.bongo-stage.is-complete .bongo-meta {
  color: var(--bongo-good);
}
@media (max-width: 639px) {
  .bongo-topbar {
    padding: 0.45rem 0.7rem;
    font-size: 0.65rem;
  }

  .bongo-hint {
    display: none;
  }

  .bongo-scene {
    padding: 0.75rem 0.75rem 0.9rem;
    gap: 0.45rem;
  }

  .bongo-copy {
    font-size: 0.875rem;
    line-height: 1.55;
  }

  .bongo-field {
    padding: 0.45rem 0.6rem;
  }

  .bongo-prompt,
  .bongo-input {
    font-size: 0.8rem;
  }

  .bongo-meta {
    font-size: 0.625rem;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
  }

  .bongo-stats {
    gap: 0.3rem;
    white-space: nowrap;
  }

  .bongo-cat-wrap {
    width: clamp(180px, 64%, 240px);
    margin: 0 auto -0.45rem;
  }

  .bongo-cat {
    top: auto;
    bottom: 0;
    left: auto;
    right: -12%;
    width: 52%;
  }

  .bongo-tooltip {
    top: auto;
    bottom: 3.75rem;
    left: auto;
    right: -12%;
    max-width: 70vw;
    font-size: 0.65rem;
    white-space: normal;
    text-align: center;
    transform: translateY(0.25rem);
  }

  .bongo-tooltip.is-visible {
    transform: translateY(0);
  }
}
/* @media (max-width: 639px) {
  .bongo-topbar {
    padding: 0.6rem 0.8rem;
  }

  .bongo-hint {
    display: none;
  }

  .bongo-scene {
    padding: 1rem 1rem 1.25rem;
    gap: 0.6rem;
  }

  .bongo-copy {
    font-size: 0.75rem;
  }

  .bongo-field {
    padding: 0.55rem 0.65rem;
  }

  .bongo-cat-wrap {
    width: clamp(180px, 64%, 240px);
    margin: -0.1rem auto -0.6rem;
  }

  .bongo-tooltip {
    max-width: 70vw;
    white-space: normal;
    text-align: center;
  }
} */

/* ============================================================
   Project grid
   ============================================================ */
.projects-wrap {
  position: relative;
}

.projects-wrap::before,
.projects-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 2rem;
  pointer-events: none;
}

.projects-wrap::before {
  left: 0;
  background: linear-gradient(to right, var(--fade), transparent);
}

.projects-wrap::after {
  right: 0;
  background: linear-gradient(to left, var(--fade), transparent);
}

.projects {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(3, 18rem);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0.25rem 0 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.projects::-webkit-scrollbar {
  display: none;
}

@media (max-width: 639px) {
  .projects {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-template-rows: minmax(0, 1fr);
    grid-auto-columns: 18rem;
  }
}

@media (pointer: coarse) {
  .projects {
    scroll-snap-type: x mandatory;
  }

  .project {
    scroll-snap-align: start;
  }
}

.project {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
  background: var(--card);
  transition: border-color 0.2s ease;
}

.project:hover {
  border-color: var(--border-strong);
}

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 1;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  background:
    radial-gradient(
      110% 130% at 15% 0%,
      hsl(var(--hue) 90% 62% / 0.55),
      transparent 60%
    ),
    linear-gradient(
      135deg,
      hsl(var(--hue) 70% 42%),
      hsl(var(--hue2) 75% 24%)
    );
}

.thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.09) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

.thumb-initial {
  position: relative;
  font-family: Silkscreen, ui-monospace, monospace;
  font-size: 2.75rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
  text-transform: uppercase;
}

.thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1rem;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.project-owner {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.project-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-title:hover {
  text-decoration: underline;
}

.project-desc {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.tag {
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.lang {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.lang-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  background: var(--dot, var(--muted));
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  border-top: 1px solid var(--border);
}

.footer p {
  padding: 2rem 0;
  font-size: 0.75rem;
  color: var(--faint);
}

.footer a {
  color: var(--muted);
  transition: color 0.15s ease;
}

.footer a:hover {
  color: var(--fg);
}

/* ============================================================
   Noscript
   ============================================================ */
.noscript {
  max-width: 56rem;
  margin: 2rem auto;
  padding: 0 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .marquee {
    overflow-x: auto;
    mask-image: none;
    -webkit-mask-image: none;
  }

  .marquee-track {
    animation: none;
  }
}
.map-plane { transition: opacity 0.2s ease; }
.banner.is-moving .map-plane { opacity: 0; }

[data-theme="dark"] .stack-card img.light-only,
[data-theme="light"] .stack-card img.dark-only {
  display: none;
}