:root {
  --bg: #fef3c7;
  --ink: #0a0a0a;
  --paper: #fff;
  --yellow: #fde047;
  --pink: #f472b6;
  --lime: #a3e635;
  --blue: #60a5fa;
  /* Shadow is slightly transparent so it separates from the solid black
     border instead of merging into one black mass. */
  --shadow-color: rgba(10, 10, 10, 0.5);
  --shadow: 6px 6px 0 var(--shadow-color);
  --shadow-sm: 4px 4px 0 var(--shadow-color);
  --border: 3px solid var(--ink);
  --maxw: 1140px;
}

/* Register the tilt/lift variables as typed <angle>/<length> so the browser
   can interpolate them independently inside the single `transform` property.
   Lift (--tx/--ty) gets a transition for smooth hover-press; tilt (--rx/--ry)
   stays un-transitioned so it tracks the cursor instantly. Without @property
   the variables are untyped and the browser can't transition transform via
   custom properties — so we couldn't have one smooth and the other instant. */
@property --rx {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
@property --ry {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
@property --tx {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --ty {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Dot pattern background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--ink) 1.4px, transparent 1.4px);
  background-size: 22px 22px;
  opacity: 0.06;
}

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

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--yellow);
  border-bottom: var(--border);
}
.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--ink);
}
.logo-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-family: "Archivo Black", sans-serif;
  font-size: 1.4rem;
  background: var(--ink);
  color: var(--pink);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transform: rotate(-3deg);
}
.logo-text {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
  cursor: pointer;
}
.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--shadow-color);
}
.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow-color);
}
.btn:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.btn-dark {
  background: var(--ink);
  color: var(--yellow);
}
.btn-pink {
  background: var(--pink);
  color: var(--ink);
}
.btn-blue {
  background: var(--blue);
  color: var(--ink);
}
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
}
.btn-mini {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--shadow-color);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.btn-mini:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--shadow-color);
}
.btn-mini:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.btn-mini-dim {
  background: var(--bg);
}

/* Layout */
main {
  display: block;
}
section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* Hero */
.hero {
  padding-top: 90px;
  padding-bottom: 90px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  border: var(--border);
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}
.badge-yellow {
  background: var(--yellow);
}
.blink {
  color: #ef4444;
  animation: blink 1.2s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.title {
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(2.8rem, 9vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.hl {
  display: inline-block;
  padding: 0 10px;
  background: var(--ink);
  color: var(--paper);
  transform: rotate(-1deg);
}
/* Pixel-art heart in the hero title. The path is the heart's outer silhouette
   (a single closed contour), so stroke runs around the perimeter — same
   brutal border as the .hl badges and buttons. paint-order keeps the pink
   fill on top of the stroke so corners stay sharp. */
.pixel-heart {
  display: inline-block;
  vertical-align: -0.08em;
  shape-rendering: crispEdges;
  /* Stroke sits outside the path and would be clipped by the SVG's viewBox;
     let it spill so the border renders fully. */
  overflow: visible;
  fill: var(--pink);
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linejoin: miter;
  paint-order: stroke fill;
  width: 0.9em;
  height: 0.77em;
  margin-block-start: -0.5em;
  transform-origin: center;
  transition: transform 0.25s ease;
}
/* Heartbeat on hover — two quick beats (lub-dub) then a rest, like a real
   pulse. Guarded by prefers-reduced-motion so it only runs for users who
   opt in to motion. */
@media (prefers-reduced-motion: no-preference) {
  .pixel-heart:hover {
    animation: heartbeat 1.25s ease-in-out infinite;
  }
}
@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  /* lub */
  15% {
    transform: scale(1.08);
  }
  30% {
    transform: scale(1);
  }
  /* dub */
  45% {
    transform: scale(1.15);
  }
  70% {
    transform: scale(1);
  }
  100% {
    transform: scale(1);
  }
}
.hl-pink {
  background: var(--pink);
  color: var(--ink);
}
.hl-lime {
  background: var(--lime);
  color: var(--ink);
}
.lede {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  max-width: 600px;
  margin-bottom: 40px;
  font-weight: 500;
}
.lede strong {
  color: var(--blue);
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

/* Projects */
.projects {
  padding-bottom: 90px;
}
.section-title {
  margin-bottom: 40px;
}
.marker {
  display: inline-block;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: -0.02em;
  background: var(--ink);
  color: var(--yellow);
  padding: 6px 18px;
  transform: rotate(-1.5deg);
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}

/* Tilt applies to every [data-tilt] element (cards + contact card).
   Tilt (--rx/--ry) and hover-lift (--tx/--ty) share a single transform so
   neither cancels the other — fixes the bug where JS inline-transform /
   :hover override fought each other in the original script.js.
   Only --tx/--ty transition (smooth hover-press); --rx/--ry do NOT, so tilt
   tracks the cursor instantly. .is-resetting additionally transitions
   --rx/--ry for the smooth return-to-flat on mouseleave. Made possible by
   the @property registrations above (typed custom properties). */
[data-tilt] {
  --rx: 0deg;
  --ry: 0deg;
  --tx: 0px;
  --ty: 0px;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry))
    translate(var(--tx), var(--ty));
  transform-style: preserve-3d;
  transition:
    --tx 0.18s ease,
    --ty 0.18s ease,
    box-shadow 0.16s ease;
}
[data-tilt].is-resetting {
  transition:
    --rx 0.4s ease,
    --ry 0.4s ease,
    --tx 0.18s ease,
    --ty 0.18s ease,
    box-shadow 0.16s ease;
}

/* Card */
.card {
  /* Bold tilt for the brutal aesthetic — read by shared.js. */
  --tilt-strength: 14;
  grid-column: span 2;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 24px;
  min-height: 220px;
  background: var(--paper);
  border: var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry))
    translate(var(--tx), var(--ty));
  transform-style: preserve-3d;
  transition: box-shadow 0.16s ease;
}

.card:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
}
.card-lg {
  grid-column: span 4;
  grid-row: span 2;
  min-height: 0;
}

/* Card colors by tier — flagship gets the boldest, minors stay quiet. */
.card-pink {
  background: var(--pink);
}
.card-lime {
  background: var(--lime);
}
.card-yellow {
  background: var(--yellow);
}
.card-blue {
  background: var(--blue);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.card-tag {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--ink);
}
.card-tag-blue {
  background: var(--blue);
  color: var(--ink);
  border-color: var(--ink);
}
/* Outlined, muted tag for secondary projects (WRAPPER / DEMO). */
.card-tag-minor {
  background: transparent;
  color: var(--ink);
  opacity: 0.65;
}
/* Open-source badge — lime, high-contrast, sits in card-meta alongside the
   plain #tags but reads as a label rather than a topic. */
.card-tag-os {
  color: var(--ink);
  background: var(--lime);
  border: 2px solid var(--ink);
}
.card-no {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 0.9rem;
}
.card-title {
  font-family: "Archivo Black", sans-serif;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  margin-bottom: 10px;
}
.card-lg .card-title {
  font-size: clamp(2rem, 4vw, 2.8rem);
}
.card-desc {
  font-size: 0.98rem;
  font-weight: 500;
  flex: 1;
}
.card-lg .card-desc {
  font-size: 1.1rem;
  max-width: 480px;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  font-family: "Space Mono", monospace;
  font-size: 0.82rem;
  font-weight: 700;
}

/* Contact */
.contact {
  padding-bottom: 90px;
}
.contact-card {
  --tilt-strength: 10;
  background: var(--paper);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 48px 32px;
  text-align: center;
}
.contact-title {
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}
.contact-sub {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 32px;
}
.contact-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

/* Footer */
.footer {
  border-top: var(--border);
  background: var(--ink);
  color: var(--yellow);
  text-align: center;
  padding: 28px;
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 0.9rem;
}
.footer .hl {
  background: var(--pink);
  color: var(--ink);
  padding: 0 6px;
  transform: none;
}

/* Reveal */
.reveal.is-visible {
  opacity: 1;
}
/* Non-tilt reveal elements settle to no transform. */
.reveal.is-visible:not([data-tilt]) {
  transform: none;
}
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition:
      opacity 0.6s ease,
      transform 0.6s ease;
  }
  /* Tilt elements: opacity + lift (--tx/--ty) transition; --rx/--ry do NOT,
     so tilt tracks the cursor instantly. .is-resetting adds --rx/--ry for
     the smooth return-to-flat. */
  [data-tilt].reveal {
    transition:
      opacity 0.6s ease,
      --tx 0.18s ease,
      --ty 0.18s ease;
    transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry))
      translate(var(--tx), var(--ty)) translateY(20px);
  }
  [data-tilt].reveal.is-visible {
    transition:
      opacity 0.6s ease,
      --tx 0.18s ease,
      --ty 0.18s ease;
    transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry))
      translate(var(--tx), var(--ty));
  }
  [data-tilt].reveal.is-resetting {
    transition:
      --rx 0.4s ease,
      --ry 0.4s ease,
      --tx 0.18s ease,
      --ty 0.18s ease,
      opacity 0.6s ease;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .card {
    grid-column: span 2;
  }
  .card-lg {
    grid-column: span 4;
    grid-row: auto;
  }
}
@media (max-width: 600px) {
  .nav {
    padding: 12px 16px;
  }
  .logo-text {
    display: none;
  }
  .nav-links .btn-mini:not(.btn-mini-dim) {
    display: none;
  }
  section {
    padding: 0 16px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .card,
  .card-lg {
    grid-column: span 1;
  }
  .hero-cta .btn {
    flex: 1;
    justify-content: center;
  }
}

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
