/* ============================================================
   SAAD BIN SHAHBAZ — PORTFOLIO
   Dark, lowercase, motion-first. One accent. Nothing else.
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --bg-2: #171717;
  --ink: #fafafa;
  --dim: rgba(250, 250, 250, 0.55);
  --faint: rgba(250, 250, 250, 0.28);
  --line: rgba(250, 250, 250, 0.14);
  --accent: #21ffc0;
  --font: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "Fragment Mono", ui-monospace, monospace;
  --pad: clamp(16px, 2.2vw, 30px);
  --ease: cubic-bezier(0.65, 0.05, 0, 1);
}

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

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: -0.03em;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
}

body {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: relative;
}

/* film grain over everything */
body::after {
  content: "";
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 200;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4%, 3%); }
  50% { transform: translate(3%, -4%); }
  75% { transform: translate(-3%, -2%); }
  100% { transform: translate(4%, 3%); }
}

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  letter-spacing: inherit;
}
a { color: inherit; text-decoration: none; }
img { display: block; }

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

/* ============================================================
   ROLLING-LETTER BUTTONS  (two stacked rows of letters; hover
   rolls each letter up with a tiny stagger)
   ============================================================ */
.btn-roll {
  display: inline-block;
  font-size: 14px;
  text-transform: lowercase;
}
.btn-roll .rl {
  display: inline-block;
  position: relative;
  white-space: pre;
  overflow: hidden;
}
.btn-roll .rl > span {
  display: block;
  transition: transform 0.55s var(--ease);
  transition-delay: var(--d, 0s);
}
.btn-roll .rl > span:last-child {
  position: absolute;
  left: 0;
  top: 100%;
  color: var(--accent);
}
.btn-roll:hover .rl > span,
.btn-roll:focus-visible .rl > span { transform: translateY(-100%); }

/* ============================================================
   ENTER SCREEN
   ============================================================ */
#enter {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.enter-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  text-align: center;
}
.enter-progress {
  width: min(280px, 60vw);
  height: 1px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
#enter-bar {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
}
.enter-tagline {
  font-size: clamp(15px, 1.6vw, 19px);
  font-weight: 400;
  text-transform: lowercase;
  color: var(--dim);
  opacity: 0;
}
.enter-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.enter-btn {
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 13px 26px;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: border-color 0.4s var(--ease), background 0.4s var(--ease);
}
.enter-btn:hover { border-color: var(--accent); }
.enter-btn.is-ghost { border-color: var(--line); color: var(--dim); }
body[data-state="enter"] .enter-btn { pointer-events: auto; }
.enter-foot {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);
  display: flex;
  justify-content: space-between;
  color: var(--faint);
}

/* ============================================================
   WEBGL CANVAS
   ============================================================ */
#webgl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  touch-action: none;
}
body[data-view="list"] #webgl { pointer-events: none; }

/* ============================================================
   HEADER
   ============================================================ */
#hdr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--pad);
  opacity: 0;
  pointer-events: none;
}
body[data-state="ready"] #hdr { pointer-events: auto; }
.logo { display: flex; flex-direction: column; gap: 5px; }
.logo-name {
  font-size: 15px;
  font-weight: 500;
  text-transform: lowercase;
}
.logo-name sup { font-size: 8px; color: var(--accent); }
.logo-tag { color: var(--faint); }

/* spiral / list switch */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.4s var(--ease);
}
body[data-page="open"] .switch { opacity: 0; pointer-events: none; }
.switch-btn { color: var(--dim); transition: color 0.4s var(--ease); }
.switch-btn.is-active { color: var(--ink); }
.switch-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.55s var(--ease);
}

.menu-btn { font-size: 14px; }

/* ============================================================
   MENU OVERLAY
   ============================================================ */
#menu {
  position: fixed;
  inset: 0;
  z-index: 60;
  visibility: hidden;
}
body[data-menu="open"] #menu { visibility: visible; }
.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
}
.menu-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100%);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--pad);
  /* offscreen transform owned by GSAP (ui.js) */
}
.menu-close { align-self: flex-end; font-size: 14px; color: var(--dim); }
.menu-links { display: flex; flex-direction: column; gap: 6px; margin: auto 0; }
.menu-link { overflow: hidden; }
.menu-link a {
  display: inline-block;
  font-size: clamp(44px, 6vw, 64px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.05em;
  line-height: 1.12;
}
.menu-link a span {
  display: inline-block;
  /* offscreen transform owned by GSAP (ui.js) */
  transition: color 0.4s var(--ease);
}
.menu-link a:hover span { color: var(--accent); }
.menu-foot {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.menu-mail {
  font-size: 15px;
  text-transform: lowercase;
  color: var(--dim);
  transition: color 0.4s var(--ease);
}
.menu-mail:hover { color: var(--accent); }
.menu-social { display: flex; gap: 18px; }
.menu-social a {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: lowercase;
  color: var(--faint);
  transition: color 0.4s var(--ease);
}
.menu-social a:hover { color: var(--ink); }

/* ============================================================
   LIST VIEW
   ============================================================ */
#list {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  overflow-y: auto;
  padding: calc(var(--pad) + 70px) var(--pad) calc(var(--pad) + 140px);
  scrollbar-width: none;
}
#list::-webkit-scrollbar { display: none; }
body[data-view="list"] #list { display: block; }
.list-rows { list-style: none; }
.list-row {
  border-top: 1px solid var(--line);
  overflow: hidden;
}
.list-row:last-child { border-bottom: 1px solid var(--line); }
.list-row a {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  align-items: baseline;
  gap: 18px;
  padding: 22px 0;
  position: relative;
}
.list-num { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.list-title {
  font-size: clamp(22px, 3.2vw, 40px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.04em;
  transition: transform 0.55s var(--ease), color 0.4s var(--ease);
}
.list-cat { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.list-year { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.list-row a:hover .list-title { transform: translateX(16px); color: var(--accent); }

/* floating hover preview */
#list-preview {
  position: fixed;
  z-index: 25;
  width: 300px;
  aspect-ratio: 16 / 10;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transform: translate(-50%, -50%);
}
#list-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   ACTIVE PROJECT HUD (spiral view)
   ============================================================ */
#hud {
  position: fixed;
  left: var(--pad);
  bottom: calc(var(--pad) + 132px);
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
}
.hud-index { color: var(--faint); }
.hud-title {
  font-size: clamp(34px, 5.4vw, 76px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.05em;
  line-height: 1.02;
  max-width: 12ch;
  overflow: hidden;
}
.hud-title .hl { display: inline-block; white-space: pre; }
.hud-meta { color: var(--dim); }

/* ============================================================
   FEATURED CHIP  (corner thumbnail + letter-train marquee)
   ============================================================ */
#chip {
  position: fixed;
  left: var(--pad);
  bottom: var(--pad);
  z-index: 30;
  opacity: 0;
}
.chip-frame {
  display: block;
  position: relative;
  width: 176px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  transition: border-color 0.4s var(--ease);
}
#chip:hover .chip-frame { border-color: var(--accent); }
#chip-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease);
}
#chip:hover #chip-img { transform: scale(1.07); }
.chip-marquee {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 14px;
  margin-top: -7px;
  overflow: hidden;
}
.chip-marquee span {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 14px;
  color: var(--ink);
  text-shadow: 0 0 6px rgba(10, 10, 10, 0.9);
  animation: chip-train var(--t) linear infinite;
  animation-delay: var(--d);
  will-change: transform;
}
@keyframes chip-train {
  from { transform: translateX(var(--chip-w)); }
  to { transform: translateX(calc(var(--chip-w) - var(--travel))); }
}

/* ============================================================
   SOUND TOGGLE
   ============================================================ */
#sound {
  position: fixed;
  right: var(--pad);
  bottom: var(--pad);
  z-index: 30;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: border-color 0.4s var(--ease);
}
#sound:hover { border-color: var(--accent); }
.sound-bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.sound-bars i {
  width: 2px;
  height: 100%;
  background: var(--ink);
  transform: scaleY(0.18);
  transform-origin: bottom;
  transition: background 0.3s;
}
#sound[aria-pressed="true"] .sound-bars i {
  background: var(--accent);
  animation: bar 0.9s ease-in-out infinite alternate;
}
#sound[aria-pressed="true"] .sound-bars i:nth-child(1) { animation-delay: 0s; }
#sound[aria-pressed="true"] .sound-bars i:nth-child(2) { animation-delay: 0.18s; }
#sound[aria-pressed="true"] .sound-bars i:nth-child(3) { animation-delay: 0.34s; }
#sound[aria-pressed="true"] .sound-bars i:nth-child(4) { animation-delay: 0.52s; }
@keyframes bar {
  from { transform: scaleY(0.15); }
  to { transform: scaleY(1); }
}

/* ============================================================
   PAGE OVERLAY  (project + about)
   ============================================================ */
#page {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  /* initial offscreen transform is owned by GSAP (pages.js) —
     a CSS % transform here would be parsed as a px offset */
  visibility: hidden;
}
body[data-page="open"] #page { visibility: visible; }
.page-scroll {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}
.page-scroll::-webkit-scrollbar { display: none; }
.page-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(var(--pad) + 64px) var(--pad) calc(var(--pad) + 40px);
}
.page-close {
  position: fixed;
  top: var(--pad);
  right: var(--pad);
  font-size: 14px;
  z-index: 55;
}

/* --- project page --- */
.pj-kicker {
  display: flex;
  justify-content: space-between;
  color: var(--faint);
  margin-bottom: 22px;
}
.pj-title {
  font-size: clamp(40px, 7.5vw, 104px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.05em;
  line-height: 0.98;
  margin-bottom: 40px;
  overflow: hidden;
}
.pj-title .hl { display: inline-block; white-space: pre; }
.pj-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
  margin-bottom: 48px;
  list-style: none;
}
.pj-meta li { display: flex; flex-direction: column; gap: 8px; }
.pj-meta .k { font-family: var(--mono); font-size: 10px; color: var(--faint); text-transform: lowercase; }
.pj-meta .v { font-size: 14px; text-transform: lowercase; }
.pj-hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin-bottom: 56px;
}
.pj-cols {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 48px;
  margin-bottom: 64px;
}
.pj-summary {
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 400;
  text-transform: lowercase;
  letter-spacing: -0.04em;
  line-height: 1.18;
}
.pj-desc p {
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: var(--dim);
  margin-bottom: 18px;
}
.pj-section-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 20px;
}
.pj-high { list-style: none; margin-bottom: 64px; }
.pj-high li {
  border-top: 1px solid var(--line);
  padding: 16px 0;
  display: flex;
  gap: 18px;
  align-items: baseline;
  font-size: 15px;
  text-transform: lowercase;
  letter-spacing: -0.01em;
}
.pj-high li::before {
  content: "→";
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}
.pj-frames {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 72px;
}
.pj-frames img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.pj-next {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 32px;
}
.pj-next .mono { color: var(--faint); display: block; margin-bottom: 12px; }
.pj-next-title {
  font-size: clamp(30px, 4.6vw, 60px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.05em;
  transition: color 0.4s var(--ease), transform 0.55s var(--ease);
  display: inline-block;
}
.pj-next:hover .pj-next-title { color: var(--accent); transform: translateX(14px); }

/* --- about page --- */
.ab-name {
  font-size: clamp(40px, 7.5vw, 104px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.05em;
  line-height: 0.98;
  margin-bottom: 48px;
}
.ab-lede p {
  font-size: clamp(19px, 2.1vw, 26px);
  line-height: 1.35;
  letter-spacing: -0.03em;
  margin-bottom: 22px;
  max-width: 36ch;
}
.ab-lede strong { font-weight: 500; color: var(--accent); }
.ab-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 48px;
  margin: 56px 0 72px;
}
.ab-facts { list-style: none; }
.ab-facts li {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.ab-facts .k { font-family: var(--mono); font-size: 10px; color: var(--faint); text-transform: lowercase; }
.ab-facts .v { font-size: 13px; text-align: right; text-transform: lowercase; }
.ab-xp { list-style: none; }
.ab-xp li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding: 22px 0;
}
.ab-xp .period { font-family: var(--mono); font-size: 10px; color: var(--faint); padding-top: 4px; }
.ab-xp h3 { font-size: 18px; font-weight: 500; text-transform: lowercase; margin-bottom: 6px; }
.ab-xp .org { font-family: var(--mono); font-size: 10px; color: var(--dim); display: block; margin-bottom: 12px; }
.ab-xp p { font-size: 14px; line-height: 1.5; color: var(--dim); letter-spacing: -0.01em; }
.ab-caps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 64px;
}
.ab-cap { border-top: 1px solid var(--line); padding-top: 18px; }
.ab-cap .num { font-family: var(--mono); font-size: 10px; color: var(--accent); display: block; margin-bottom: 14px; }
.ab-cap h3 { font-size: 17px; font-weight: 500; text-transform: lowercase; margin-bottom: 14px; }
.ab-cap ul { list-style: none; }
.ab-cap li { font-size: 13px; color: var(--dim); padding: 5px 0; text-transform: lowercase; }
.ab-contact { border-top: 1px solid var(--line); padding-top: 32px; }
.ab-contact a {
  font-size: clamp(24px, 3.6vw, 44px);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: -0.04em;
  transition: color 0.4s var(--ease);
}
.ab-contact a:hover { color: var(--accent); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 760px) {
  .logo-tag { display: none; }
  .list-row a { grid-template-columns: 36px 1fr auto; }
  .list-cat { display: none; }
  #list-preview { display: none; }
  #hud { bottom: calc(var(--pad) + 116px); }
  .chip-frame { width: 132px; }
  .pj-meta { grid-template-columns: repeat(2, 1fr); }
  .pj-cols, .ab-grid { grid-template-columns: 1fr; gap: 28px; }
  .pj-frames, .ab-caps { grid-template-columns: 1fr; }
  .menu-panel { width: 100%; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
  .chip-marquee span { animation: none; }
  #sound[aria-pressed="true"] .sound-bars i { animation: none; transform: scaleY(0.7); }
}
