:root {
  --bg: #3b3b3e;       /* tarmac */
  --surface: #232326;
  --text: #f3f1f6;
  --muted: #bab6c0;
  --accent: #8b45e6;   /* hoodie purple */
  --accent-2: #b98cff;
  --line: #141416;
  --soft-line: rgba(255, 255, 255, 0.16);
  --px: 4px;           /* one "pixel" */
  --pixel-font: "Press Start 2P", monospace;
  --body-font: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  /* hero layout: content width W split into text | portrait | text columns */
  --pad: clamp(16px, 4vw, 48px);
  --W: calc(min(100vw, 1600px) - 2 * var(--pad));
  --hero-text: clamp(15px, calc(var(--W) * 0.0165), 21px);
  /* portrait height; never wider than the middle 34% of W (image ratio is 52:90) */
  --av-h: min(calc(100vh - 110px), calc(var(--W) * 0.34 * 90 / 52));
  --av-half: calc(var(--av-h) * 26 / 90);
  --hero-gap: clamp(24px, 2.4vw, 40px);  /* text ↔ portrait */
}

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

html { scroll-behavior: smooth; overflow-x: clip; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: clip;
}

/* tarmac: dark grit + a few light aggregate flecks, pinned to the screen so it never scrolls.
   Sized to the *large* viewport (address bar hidden) rather than inset: 0, so when a phone's
   address bar slides away the newly exposed strip at the bottom is already covered. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;    /* fallback: on mobile Chrome/Safari vh is already the large viewport */
  height: 100lvh;
  z-index: -1;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  4 0 0 0 -2.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)' opacity='0.35'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
img { image-rendering: pixelated; display: block; }
strong { color: var(--accent-2); font-weight: 600; }

/* ---------- pixel primitives ---------- */
.px-box {
  background: var(--surface);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(var(--px) * -1) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line),
    calc(var(--px) * 2) calc(var(--px) * 2) 0 0 rgba(0, 0, 0, 0.45);
}

.px-title {
  font-family: var(--pixel-font);
  font-size: clamp(16px, 2.4vw, 22px);
  letter-spacing: 1px;
}

.px-btn {
  font-family: var(--pixel-font);
  font-size: 11px;
  color: var(--text);
  background: var(--accent);
  border: 0;
  padding: 12px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow:
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 rgba(0, 0, 0, 0.35),
    inset var(--px) var(--px) 0 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.1s;
}
.px-btn:hover { transform: translateY(-2px); }
.px-btn:active { transform: translateY(2px); }
.px-btn.big { font-size: clamp(9px, 2.2vw, 13px); padding: 16px 20px; word-break: break-all; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  font-size: 12px;
  padding: 2px 8px;
  border: 2px solid var(--soft-line);
  color: var(--muted);
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 20px 16px;
  pointer-events: none;
}
.topbar nav {
  pointer-events: auto;
  display: flex;
  gap: clamp(20px, 6vw, 72px);
  padding: 14px clamp(20px, 4vw, 40px);
}
.topbar nav a {
  font-family: var(--pixel-font);
  font-size: 10px;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s;
}
.topbar nav a:hover { color: var(--text); }

/* ---------- frames 1 & 2: intro ---------- */
.intro { position: relative; height: 380vh; }
/* nav targets, inside the about and skills stretches (timeline in script.js) */
.anchor { position: absolute; top: 70vh; }
.anchor-skills { top: 180vh; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--pad);
  transform: scale(calc(1 - var(--shrink, 0) * 0.18));
  opacity: calc(1 - var(--shrink, 0));  /* about vanishes completely */
  transform-origin: 50% 30%;
}
/* soft spotlight so the portrait is the focus */
.stage::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(90vw, 900px);
  height: 90vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 60%, rgba(255, 255, 255, 0.13), transparent 62%);
  transition: left 0.9s var(--ease);
  pointer-events: none;
}
.stage.is-about::before { left: 21%; }

.stage > * {
  position: absolute;
  transition: transform 0.9s var(--ease), opacity 0.9s var(--ease), left 0.9s var(--ease);
}

.avatar {
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.45));
}
.avatar img { height: var(--av-h); width: auto; }

/* side text hugs the portrait's edges rather than the page edges */
.hero-left {
  right: calc(50% + var(--av-half) + var(--hero-gap));
  top: 52%;
  transform: translateY(-50%);
  width: max-content;
  max-width: calc(var(--W) * 0.29);
  font-size: var(--hero-text);
}
.kicker { color: var(--muted); }
.hero-left h1 span { display: block; }
.hero-left h1 {
  font-family: var(--pixel-font);
  /* "Nishit DB" is 9 glyphs at 1em each; keep it inside the left column */
  font-size: min(46px, calc(var(--W) * 0.29 / 9.4));
  white-space: nowrap;
  line-height: 1.4;
  margin: 12px 0 16px;
}
.tagline { color: var(--accent-2); }

.hero-right {
  left: calc(50% + var(--av-half) + var(--hero-gap));
  top: 52%;
  transform: translateY(-50%);
  width: calc(var(--W) * 0.27);
  font-size: var(--hero-text);
  line-height: 1.6;
  color: var(--muted);
}
.hint {
  margin-top: 40px;
  font-family: var(--pixel-font);
  font-size: clamp(11px, 1vw, 13px);
  color: var(--accent-2);
  animation: bob 1.4s steps(2) infinite;
}
@keyframes bob { 50% { transform: translateY(6px); } }

/* side panels (about, skills) share one style */
.panel {
  right: clamp(16px, 4vw, 48px);
  top: 52%;
  width: min(56%, 760px);
  padding: clamp(24px, 2.6vw, 44px);
  font-size: var(--hero-text);  /* matches the hero side text */
  transform: translate(calc(100% + 80px), -50%);
  opacity: 0;
  pointer-events: none;
}
.panel h2 {
  font-family: var(--pixel-font);
  font-size: min(30px, calc(var(--W) * 0.29 / 14));  /* ~2/3 of the hero name */
  margin-bottom: 0.8em;
}
.panel p { margin-bottom: 0.8em; color: var(--muted); }
.panel p:first-of-type { color: var(--text); }

/* speech-bubble tail on the about panel, drawn as a stepped pixel triangle (4px
   steps) filled like the panel and outlined by the drop-shadows.
   Laptop: a right-angle triangle off the top-left corner — its top edge continues
   the panel's top border, the slope steps back down to the left edge.
   Phone: an isosceles tail at the bottom centre, pointing down (see media query). */
.bubble-tail {
  position: absolute;
  left: -24px;              /* the 4px base column covers the panel's left border */
  top: 0;
  width: 24px;
  height: 24px;
  filter:
    drop-shadow(-4px 0 0 var(--line))
    drop-shadow(0 4px 0 var(--line))
    drop-shadow(0 -4px 0 var(--line));
  pointer-events: none;
}
.bubble-tail::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--surface);
  clip-path: polygon(
    0 0, 24px 0, 24px 24px, 20px 24px, 20px 20px, 16px 20px, 16px 16px,
    12px 16px, 12px 12px, 8px 12px, 8px 8px, 4px 8px, 4px 4px, 0 4px
  );
}

.skills dt {
  font-family: var(--pixel-font);
  font-size: 0.55em;
  color: var(--accent-2);
  margin-top: 1.1em;
}
.skills dt:first-child { margin-top: 0; }
.skills dd { margin-top: 0.35em; color: var(--muted); }

/* frame 2 state: photo shifts left, text moves down, detail slides in from right */
.stage.is-about .avatar { left: 21%; transform: translateX(-50%) scale(0.88); }  /* room for the bubble tail */
.stage.is-about .hero-left {
  transform: translate(calc(-50vw - 100%), -50%);
  opacity: 0;
  pointer-events: none;
}
.stage.is-about .hero-right {
  transform: translateY(60vh);
  opacity: 0;
  pointer-events: none;
}
.stage.is-about .about {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}
/* frame 3 state: about scrolls right off screen, the portrait moves to the right
   side (staying on screen), and skills slides in from the left */
.skills {
  left: var(--pad);
  right: auto;
  transform: translate(calc(-100% - 50vw), -50%);
}
.stage.is-skills::before { left: 78%; }
.stage.is-skills .avatar { left: 78%; }
.stage.is-skills .about {
  transform: translate(calc(100% + 50vw), -50%);
  pointer-events: none;
}
.stage.is-skills .skills {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}

/* ---------- frame 3: projects (horizontal scroll) + contact card ---------- */
/* .projects height and the --card-w / --contact-w / --track-x vars are set by script.js */
/* pulled up so the cards rise in while the about panel fades out (no blank scroll) */
.projects { position: relative; margin-top: -60vh; }
.projects-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 96px 0 40px;
  pointer-events: none;  /* overlaps the about fade-out; only the cards take clicks */
}

/* section header: lines up with the cards' left edge, stays put while they slide,
   rises in with them, and fades out as the contact card arrives (--contact-in) */
.projects-head {
  width: var(--window-w, 100%);
  margin-bottom: clamp(4px, 1.2vh, 12px);
  opacity: 0;
  transform: translateY(120px);
  transition: transform 0.8s var(--ease), opacity 0.8s var(--ease);
}
.projects.in .projects-head { opacity: 1; transform: none; }
.projects-head h2 {
  font-family: var(--pixel-font);
  font-size: clamp(18px, 2.2vw, 30px);
  line-height: 1.4;
  opacity: calc(1 - var(--contact-in, 0));
}
.card { pointer-events: auto; }
/* clips the track to the content area; padding leaves room for the pixel shadows */
.track-window {
  --shadow-room: 16px;
  width: calc(var(--window-w, 100%) + 2 * var(--shadow-room));
  flex: 0 1 672px;          /* takes the height left under the header, up to 640px cards */
  min-height: 0;
  margin: 0 auto;
  padding: var(--shadow-room);
  overflow: hidden;
}
.track {
  display: flex;
  gap: var(--card-gap, 28px);
  height: 100%;
  transform: translateX(calc(var(--track-x, 0) * -1px));
}

.card {
  flex: 0 0 var(--card-w, 340px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* rise from the bottom when the section arrives */
  opacity: 0;
  transform: translateY(120px);
  transition: transform 0.8s var(--ease), opacity 0.8s var(--ease);
}
.projects.in .card { opacity: 1; transform: none; }
.projects.in .card:nth-child(2) { transition-delay: 0.08s; }
.projects.in .card:nth-child(3) { transition-delay: 0.16s; }
.projects.in .card:nth-child(n + 4) { transition-delay: 0.24s; }

/* project card: small image, title, brief, stack, highlights, view button */
.thumb {
  flex: none;
  height: clamp(72px, 16vh, 160px);   /* deliberately small */
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--pixel-font);
  font-size: clamp(20px, 2.2vw, 32px);
  color: var(--accent-2);
  background:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(139, 69, 230, 0.08) 8px 16px),
    #2c2c30;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.card-body {
  flex: 1;
  min-height: 0;
  padding: clamp(16px, 1.6vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h3 { font-family: var(--pixel-font); font-size: clamp(12px, 1.1vw, 15px); line-height: 1.4; }
.card .brief {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card h4 {
  font-family: var(--pixel-font);
  font-size: 9px;
  color: var(--accent-2);
  margin-bottom: 8px;
}
.card .tags { gap: 6px; }
.card .tags li { font-size: 12px; }
.features { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; line-height: 1.5; }
.features li { display: flex; gap: 10px; }
.features li::before {          /* pixel-square bullet */
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: 0.6em;
  background: var(--accent);
}
.card .view {
  margin-top: auto;               /* button sits at the bottom of the card */
  align-self: flex-start;
  font-size: 10px;
  padding: 10px 14px;
}

/* short laptop screens: tighter card so everything still fits */
@media (min-width: 761px) and (max-height: 650px) {
  .thumb { height: 56px; }
  .card-body { gap: 9px; }
  .card .brief { -webkit-line-clamp: 2; font-size: 13px; }
  .card h4 { display: none; }
  .features { gap: 3px; font-size: 12.5px; }
}

.contact-card {
  flex-basis: var(--contact-w, 100%);
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: clamp(24px, 5vw, 64px);
  text-align: center;
}
.contact-card h2 {
  font-family: var(--pixel-font);
  font-size: clamp(18px, 3vw, 40px);
  line-height: 1.4;
}
.contact-card > p { color: var(--muted); font-size: var(--hero-text); }
.socials { list-style: none; display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.socials a { font-family: var(--pixel-font); font-size: 11px; color: var(--muted); text-decoration: none; }
.socials a:hover { color: var(--text); }
.contact-card footer { color: var(--muted); font-size: 12px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar nav { gap: clamp(12px, 4vw, 20px); padding: 14px 16px; }
  .topbar nav a { font-size: 8px; }

  /* portrait fills whatever height is left under the hero text */
  .avatar img { height: max(160px, min(48vh, calc(100vh - 400px))); }
  .hero-left {
    top: 96px;
    left: 16px;
    right: auto;
    transform: none;
    width: auto;
    max-width: none;
    font-size: 16px;
  }
  .hero-left h1 { font-size: 26px; }
  .hero-left h1 { margin: 4px 0 6px; }
  .hero-right {
    top: 245px;
    left: 16px;
    right: 16px;
    transform: none;
    width: auto;
    font-size: 15px;
  }
  .hint { margin-top: 12px; }

  .stage.is-about::before { left: 50%; }
  /* portrait stays at the bottom, scaled to fill the space left under each panel
     (--av-scale-* are measured in script.js) */
  .stage.is-about .avatar { left: 50%; transform: translateX(-50%) scale(var(--av-scale-about, 0.55)); }
  .stage.is-about .hero-left { transform: translateX(calc(-100% - 40px)); }
  .stage.is-about .hero-right { transform: translateY(60vh); }

  .panel {
    top: 88px;
    left: 16px;
    right: 16px;
    width: auto;
    padding: 22px;
    font-size: 15px;
    transform: translateX(calc(100% + 40px));
  }
  .stage.is-about .about { transform: none; }
  .skills { transform: translateX(calc(-100% - 50vw)); }
  .stage.is-skills::before { left: 50%; }
  .stage.is-skills .avatar { left: 50%; transform: translateX(-50%) scale(var(--av-scale-skills, 0.55)); }
  .stage.is-skills .about { transform: translateX(calc(100% + 50vw)); }
  .stage.is-skills .skills { transform: none; }
  .panel h2 { font-size: 18px; }
  /* tail turns to point down at the portrait (rotation keeps the outline right) */
  .bubble-tail {
    left: calc(50% - 12px);
    top: calc(100% - 8px);
    height: 40px;
    transform: rotate(-90deg);
  }
  .bubble-tail::before {
    clip-path: polygon(
      24px 0, 24px 40px, 16px 40px, 16px 36px, 12px 36px, 12px 32px, 8px 32px,
      8px 28px, 4px 28px, 4px 24px, 0 24px, 0 16px, 4px 16px, 4px 12px, 8px 12px,
      8px 8px, 12px 8px, 12px 4px, 16px 4px, 16px 0
    );
  }

  /* projects: a plain vertical list on phones (no pinning, no sideways track) */
  .projects-pin {
    position: static;
    height: auto;
    overflow: visible;
    display: block;
    padding: 96px 16px 48px;
  }
  .projects-head { width: auto; margin-bottom: 20px; }
  .projects-head.in { opacity: 1; transform: none; }
  .track-window { width: auto; height: auto; padding: 0; overflow: visible; }
  .track { flex-direction: column; height: auto; gap: 24px; transform: none; }
  .card { flex: none; }
  .thumb { height: 140px; }
  /* the last card fills the screen below the nav, like it fills the track on desktop */
  /* extra space above it (112px in all with the gap) keeps the previous card,
     including its pixel border and shadow, off screen once it lands below the nav */
  .contact-card { flex-basis: auto; min-height: calc(100vh - 96px - 48px); margin-top: 88px; }
  .card.in { opacity: 1; transform: none; }
}

/* very short phones: tighten the about panel so it fits */
@media (max-width: 760px) and (max-height: 600px) {
  .panel { top: 76px; padding: 16px; font-size: 14px; line-height: 1.55; }
  .panel h2 { font-size: 15px; }
}

}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}
