/* ==========================================================
   ZAWAR KHAN — PORTFOLIO
   1. Tokens  2. Base  3. Header  4. Hero  5. About
   6. Work (dark)  7. Skills  8. Contact  9. Footer  10. Motion
   ========================================================== */

/* Self-hosted fonts (variable, Latin subset) */
@font-face {
  font-family: "Bodoni Moda";
  src: url("assets/fonts/BodoniModa-Variable.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("assets/fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* 1. TOKENS */
:root {
  --color-background: #F6F1E7;
  --color-foreground: #111111;
  --color-muted: #655F55;
  --color-border: #DFD7C7;

  --color-dark-background: #111111;
  --color-dark-foreground: #F6F1E7;
  --color-dark-muted: #B9B4AD;
  --color-dark-border: #383838;

  --font-display: "Bodoni Moda", Georgia, "Times New Roman", serif;
  --font-body: "Inter", Arial, sans-serif;

  --content-width: 1200px;
  --page-gutter: clamp(20px, 5vw, 80px);
  --section-spacing: clamp(80px, 12vw, 160px);
  --radius-small: 2px;
  --display-opsz: 72; /* Bodoni optical size: higher = thinner hairlines, more contrast */
  --header-height: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* 2. BASE */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--header-height); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.menu-open { overflow: hidden; }
img { display: block; max-width: 100%; height: auto; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

.container { width: 100%; max-width: calc(var(--content-width) + var(--page-gutter) * 2); margin-inline: auto; padding-inline: var(--page-gutter); }
.section { position: relative; z-index: 1; background: var(--color-background); padding-block: var(--section-spacing); overflow-x: clip; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--color-foreground); color: var(--color-background); padding: 10px 14px; font-size: .85rem; }
.skip-link:focus { top: 12px; }

.eyebrow { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--color-muted); }

.display {
  font-family: var(--font-display);
  font-weight: 500;
  text-transform: uppercase;
  line-height: .92;
  letter-spacing: -.02em;
  font-variation-settings: "opsz" var(--display-opsz);
  font-size: clamp(2.6rem, 8.5vw, 7.5rem);
}

/* Headline words are wrapped in masks by script.js for the reveal */
.mask { display: inline-block; overflow: hidden; vertical-align: top; padding-block: .08em; margin-block: -.08em; }
.mask__inner { display: inline-block; }

.section-label { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 28px; }
.work .section-label { color: var(--color-dark-muted); }

/* Arrow link */
.link-arrow {
  display: inline-flex; gap: .5em; align-items: baseline;
  font-size: .8rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
  padding-block: 10px; border-bottom: 1px solid currentColor;
}
.link-arrow span { display: inline-block; }

/* 3. HEADER */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--header-height);
  border-bottom: 1px solid transparent;
  transition: background-color .25s var(--ease), border-color .25s var(--ease), backdrop-filter .25s;
}
.site-header.is-scrolled {
  background: rgba(246, 241, 231, .85);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom-color: var(--color-border);
}
.site-header__inner {
  height: 100%; display: flex; align-items: center; justify-content: space-between;
  max-width: calc(var(--content-width) + var(--page-gutter) * 2); margin-inline: auto; padding-inline: var(--page-gutter);
}
.brand { font-family: var(--font-display); font-weight: 500; font-size: 1.25rem; letter-spacing: .01em; }
.site-nav ul { display: flex; gap: clamp(20px, 3.5vw, 48px); }
.site-nav a {
  font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  position: relative; padding: 10px 0;
  color: var(--color-muted);
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 4px; height: 1px;
  background: currentColor; transform: scaleX(0);
}
.site-nav a.is-active { color: var(--color-foreground); }
.site-nav a.is-active::after { transform: scaleX(1); }
.menu-toggle { display: none; }

@media (max-width: 767px) {
  .menu-toggle {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px;
    background: none; border: 0; cursor: pointer;
    font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  }
  .site-nav {
    position: fixed; inset: var(--header-height) 0 0 0;
    background: var(--color-background);
    padding: 32px var(--page-gutter);
    visibility: hidden; opacity: 0;
    transition: opacity .25s var(--ease), visibility 0s .25s;
  }
  .site-nav.is-open { visibility: visible; opacity: 1; transition-delay: 0s; }
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav li { border-bottom: 1px solid var(--color-border); }
  .site-nav a {
    display: block; padding: 20px 0; border: 0;
    font-family: var(--font-display); font-size: 2.4rem; text-transform: uppercase;
    letter-spacing: -.01em; color: var(--color-foreground);
  }
  .site-nav a::after { display: none; }
  .site-header.menu-is-open { background: var(--color-background); border-bottom-color: var(--color-border); }
}

/* 4. HERO */
.hero { min-height: 100svh; display: flex; padding-top: var(--header-height); overflow-x: clip; }
.hero__inner { display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding-block: clamp(24px, 5vh, 56px) clamp(32px, 6vh, 64px); }
.hero__title {
  font-family: var(--font-display); font-weight: 500; text-transform: uppercase;
  font-size: clamp(3.4rem, min(19vw, 20svh), 15rem);
  line-height: .86; letter-spacing: -.025em;
  font-variation-settings: "opsz" 96;
  margin-block: auto;
}
.hero__line { display: block; will-change: transform; padding-block: .06em; margin-block: -.06em; overflow: hidden; }
/* Curtain: the hero stays pinned and the next sections slide over it */
@media (min-height: 600px) and (prefers-reduced-motion: no-preference) {
  .hero { position: sticky; top: 0; }
  /* If the hero is ever taller than the screen, do not pin it or its bottom would be cut off. */
  .hero.is-tall { position: static; }
}
.hero__line--indent { padding-left: 12vw; }
.hero__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 24px 48px; border-top: 1px solid var(--color-border); padding-top: 24px; }
.hero__lede { max-width: 42ch; font-size: 1.05rem; color: var(--color-muted); }
.hero__links { display: flex; flex-wrap: wrap; gap: 8px 32px; }

/* 5. ABOUT */
.about { border-top: 1px solid var(--color-border); }
.about__grid { display: grid; gap: 40px; grid-template-columns: 1fr; }
.about__body { display: grid; gap: 20px; max-width: 56ch; color: var(--color-muted); }
.about__lead { font-family: var(--font-display); font-size: clamp(1.5rem, 2.6vw, 2.1rem); line-height: 1.2; color: var(--color-foreground); }
@media (min-width: 900px) {
  .about__grid { grid-template-columns: 1.1fr 1fr; gap: 80px; align-items: end; }
}

/* 6. WORK (dark) */
.work { background: var(--color-dark-background); color: var(--color-dark-foreground); }
.work__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: clamp(56px, 9vw, 120px); padding-bottom: 24px; border-bottom: 1px solid var(--color-dark-border); }
.work__sub { color: var(--color-dark-muted); font-size: .95rem; }

.project { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); padding-bottom: clamp(56px, 9vw, 120px); }
.project + .project { padding-top: clamp(56px, 9vw, 120px); border-top: 1px solid var(--color-dark-border); }
.project:last-child { padding-bottom: 0; }

.project__media { display: block; overflow: hidden; border: 1px solid var(--color-dark-border); border-radius: 14px; background: #1a1a1a; aspect-ratio: 16 / 10; }
.project > * { min-width: 0; }
.project__media { position: relative; }
.project__media img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: top; }
.project__placeholder {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px;
}
/* Screenshots: nothing but a blank frame while loading, then the image fades in.
   The placeholder text only appears if the image file is really missing. */
.js .project__media img { transition: opacity .6s var(--ease); }
.js .project__media:not(.is-loaded) img { opacity: 0; }
.js .project__media:not(.is-missing) .project__placeholder { visibility: hidden; }
.project__media.is-missing img { display: none; }
.project__placeholder span { font-family: var(--font-display); text-transform: uppercase; font-size: clamp(1.6rem, 4vw, 3rem); }
.project__placeholder small { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--color-dark-muted); }

.project__info { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; align-self: center; }
.project__index { font-size: .75rem; letter-spacing: .14em; color: var(--color-dark-muted); }
.project__name { font-variation-settings: "opsz" var(--display-opsz); font-family: var(--font-display); font-weight: 500; text-transform: uppercase; font-size: clamp(2.2rem, 5vw, 4.2rem); line-height: .95; }
.project__desc { color: var(--color-dark-muted); max-width: 44ch; }
.tags { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.tags li + li::before { content: "/"; margin-right: 20px; color: var(--color-dark-border); }
.project__note { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--color-dark-muted); padding-block: 10px; }
.work :focus-visible { outline-color: var(--color-dark-foreground); }

@media (min-width: 768px) {
  .project { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(32px, 6vw, 96px); }
  .project:nth-of-type(even) { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .project:nth-of-type(even) .project__media { order: 2; }
}

/* Stacked projects (laptops and up). script.js adds .is-stacked only when the screen is big
   enough and every project fits; otherwise the normal layout above is used.
   Each project is a rounded card. Cards pin a little lower than the one before, so the
   edge of every covered card stays visible under the next. */
.work.is-stacked .project {
  --stack-offset: 18px;
  position: sticky;
  top: calc(var(--header-height) + 16px + var(--i, 0) * var(--stack-offset));
  min-height: calc(100svh - var(--header-height) - 100px);
  align-items: center;
  margin-bottom: 4svh;
  padding: 4svh clamp(28px, 4.5vw, 72px);
  background: #161616;
  border: 1px solid var(--color-dark-border);
  border-radius: 22px;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, .55);
  transform: scale(calc(1 - var(--p, 0) * .05));
  transform-origin: 50% 0;
  will-change: transform;
}
.work.is-stacked .project + .project { padding-top: 4svh; }
.work.is-stacked .project:last-child { padding-bottom: 4svh; margin-bottom: 0; }
.work.is-stacked .project:nth-of-type(1) { --i: 0; z-index: 1; }
.work.is-stacked .project:nth-of-type(2) { --i: 1; z-index: 2; }
.work.is-stacked .project:nth-of-type(3) { --i: 2; z-index: 3; }
.work.is-stacked .project:nth-of-type(n+4) { --i: 3; z-index: 4; }
.work.is-stacked .project__media { max-height: calc(100svh - var(--header-height) - 100px - 12svh); }
.work.is-stacked .project__media,
.work.is-stacked .project__info { opacity: calc(1 - var(--p, 0) * .75); }

/* 7. SKILLS */
.skills__title { margin-bottom: clamp(48px, 7vw, 96px); }
.skills__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 40px 32px; }
.skill-group { border-top: 1px solid var(--color-foreground); padding-top: 16px; }
.skill-group h3 { font-size: .75rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 20px; }
.skill-group li { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.25; padding-block: 8px; border-bottom: 1px solid var(--color-border); }

/* 8. CONTACT */
.contact { padding-bottom: clamp(64px, 9vw, 120px); }
.contact__title { font-size: clamp(2.8rem, 11vw, 10rem); }
.contact__lede { margin-top: 32px; max-width: 40ch; font-size: 1.15rem; color: var(--color-muted); }
.contact__actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 40px; }
.btn {
  display: inline-flex; align-items: center; gap: .5em; min-height: 52px; padding: 0 28px;
  background: var(--color-foreground); color: var(--color-background);
  border: 1px solid var(--color-foreground); border-radius: var(--radius-small); cursor: pointer;
  font-size: .8rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
}
.btn--ghost { background: transparent; color: var(--color-foreground); }
.contact__fallback { margin-top: 20px; font-size: .9rem; color: var(--color-muted); }
.contact__fallback input { font: inherit; color: var(--color-foreground); background: transparent; border: 0; border-bottom: 1px solid var(--color-foreground); padding: 4px 0; width: min(100%, 300px); }

/* 9. FOOTER */
.site-footer { position: relative; z-index: 1; background: var(--color-background); border-top: 1px solid var(--color-border); padding-block: 28px; font-size: .85rem; color: var(--color-muted); }
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; }
.site-footer ul { display: flex; gap: 24px; }
.site-footer a { display: inline-block; padding-block: 6px; }

/* 10. MOTION (only when JS is running; all one-shot, nothing loops) */

/* Headings: words rise out of a mask */
.js [data-mask] .mask__inner { translate: 0 110%; transition: translate 1s var(--ease) calc(var(--i, 0) * .07s); }
.js [data-mask].is-in .mask__inner { translate: 0 0; }

/* Generic fade-up */
.js [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js [data-reveal].is-visible { opacity: 1; transform: none; }

/* Projects: image wipes open, then the text follows in sequence */
.js .project[data-reveal] { opacity: 1; transform: none; }
.js .project__media { clip-path: inset(0 0 100% 0); transition: clip-path 1.1s var(--ease); }
.js .project__media > * { scale: 1.12; transition: scale 1.6s var(--ease); }
.js .project.is-visible .project__media { clip-path: inset(0 0 0 0); }
.js .project.is-visible .project__media > * { scale: 1; }
.js .project__info > * { opacity: 0; translate: 0 16px; transition: opacity .7s var(--ease), translate .7s var(--ease); }
.js .project.is-visible .project__info > * { opacity: 1; translate: 0 0; }
.js .project__info > :nth-child(1) { transition-delay: .35s; }
.js .project__info > :nth-child(2) { transition-delay: .43s; }
.js .project__info > :nth-child(3) { transition-delay: .51s; }
.js .project__info > :nth-child(4) { transition-delay: .59s; }
.js .project__info > :nth-child(5) { transition-delay: .67s; }

/* Skills: rules draw across, then items fade in */
.js .skills__grid[data-reveal] { opacity: 1; transform: none; }
.js .skill-group { border-top-color: transparent; }
.skill-group::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--color-foreground); transform-origin: left; }
.js .skill-group::before { transform: scaleX(0); transition: transform 1s var(--ease) calc(var(--g, 0) * .1s); }
.js .skill-group > * { opacity: 0; transition: opacity .8s var(--ease) calc(var(--g, 0) * .1s + .3s); }
.js .skills__grid.is-visible .skill-group::before { transform: scaleX(1); }
.js .skills__grid.is-visible .skill-group > * { opacity: 1; }
.js .skill-group:nth-child(2) { --g: 1; }
.js .skill-group:nth-child(3) { --g: 2; }
.js .skill-group:nth-child(4) { --g: 3; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; animation: none !important; }
  .js [data-mask] .mask__inner, .js [data-reveal], .js .project__media, .js .project__media > *, .js .project__info > *,
  .js .skill-group > * { translate: 0 0; scale: 1; opacity: 1; transform: none; clip-path: none; }
  .js .skill-group::before { transform: none; }
}