/* =========================================================
   Abhishek Munjal — Portfolio
   Design tokens extracted from Figma (file VyAxh6aHed8BH3QEcpWTol)
   ========================================================= */

:root {
  /* ---- Colors ---- */
  --color-bg: #fdeee2;          /* cream — projects + footer */
  --color-header-bg: #000000;   /* black — hero band */
  --color-text: #000000;
  --color-muted: rgba(0, 0, 0, 0.5);

  /* ---- Typography ---- */
  --font-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-bold: 700;

  --fs-label: 16px;             /* card labels */
  --fs-contact: 28.876px;       /* footer contact links (from design) */
  --fs-legal: 14px;             /* footer fine print only */

  /* ---- Spacing & layout ---- */
  --container-max: 1900px;
  --container-pad: clamp(16px, 4vw, 50px);  /* caps at 50px on desktop */
  --grid-gap: clamp(28px, 4vw, 40px);
  --card-gap: 24px;             /* player -> label */
  --footer-gap: clamp(40px, 8vw, 77px);
  --section-pad-block: clamp(32px, 5vw, 50px);

  --card-ratio: 16 / 9;         /* video players — shorter than the original still */
}

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

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

/* Safety net against accidental horizontal scrolling on small screens */
html, body { overflow-x: clip; }

/* Page background is black; the portfolio & contact sections keep the cream */
html { background-color: var(--color-header-bg); }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: var(--fw-regular);
  color: var(--color-text);
  background-color: var(--color-header-bg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
picture,
svg,
video { display: block; max-width: 100%; }

a { color: inherit; }

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

button { font: inherit; color: inherit; }

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

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

/* =========================================================
   Hero / header
   ========================================================= */
/* Registered so the glow position can ease (follow the cursor smoothly) */
@property --glow-x {
  syntax: "<length-percentage>";
  inherits: false;
  initial-value: 100%;
}
@property --glow-y {
  syntax: "<length-percentage>";
  inherits: false;
  initial-value: 0%;
}

.hero {
  background-color: var(--color-header-bg);
  /* Soft glow — defaults to the upper-right; follows the cursor via main.js */
  background-image:
    radial-gradient(60% 95% at var(--glow-x, 100%) var(--glow-y, 0%),
      rgba(253, 238, 226, 0.58) 0%,
      rgba(253, 238, 226, 0.24) 34%,
      transparent 66%);
  background-repeat: no-repeat;
  transition: --glow-x 0.25s ease-out, --glow-y 0.25s ease-out;
}

.hero__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: clamp(24px, 5vw, 50px);
}

.hero__media {
  position: relative;
  width: 100%;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.hero__name,
.hero__fallback,
.hero__fallback img {
  width: 100%;
  height: auto;
}

.hero__fallback { position: relative; z-index: 1; }

/* Video overlays the lettering and is masked by it. main.js adds .is-playing
   once the footage can play; it then fades + scales in over the static name. */
.hero__video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;   /* frame the subject a touch higher in the lettering */
  -webkit-mask: url("../assets/hero-name.png") center / contain no-repeat;
          mask: url("../assets/hero-name.png") center / contain no-repeat;
  /* No entrance animation — the footage simply appears (quick fade). */
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.hero__media.is-playing .hero__video {
  opacity: 1;
}

/* =========================================================
   Projects grid
   ========================================================= */
.projects {
  background-color: var(--color-bg);
  padding-block: var(--section-pad-block);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* mobile-first; minmax(0,...) lets the column shrink below content width */
  gap: var(--grid-gap);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

/* ---- Inline video player (facade -> iframe) ---- */
.player {
  position: relative;
  width: 100%;
  aspect-ratio: var(--card-ratio);
  background-color: #000;
  overflow: hidden;
}

.player__btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: block;
}

.player__btn picture,
.card__img {
  width: 100%;
  height: 100%;
}

.card__img {
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1),
              filter 0.5s ease;
}

/* Play button glyph */
.player__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  transition: background 0.25s ease, transform 0.25s ease;
}

.player__play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent #fff;
}

.player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (hover: hover) {
  .player__btn:hover .card__img { transform: scale(1.03); filter: brightness(0.9); }
  .player__btn:hover .player__play { background: rgba(0, 0, 0, 0.78); transform: translate(-50%, -50%) scale(1.06); }
}

.player__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* ---- Card label row ---- */
/* Mobile-first: title and role stacked, left-aligned (matches the design). */
.card__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  font-size: var(--fs-label);
  text-transform: uppercase;
}

.card__title {
  min-width: 0;
}

/* Role rendered as a solid pill/tag */
.card__role {
  align-self: flex-start;          /* tag hugs its text (mobile, left) */
  max-width: 100%;
  background: var(--color-text);
  color: var(--color-bg);
  font-weight: var(--fw-bold);
  font-size: 13px;
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-align: center;
  padding: 8px 16px;
  border-radius: 8px;
}

/* =========================================================
   Footer / contact  — all text 14px
   ========================================================= */
.contact {
  background-color: var(--color-bg);
  padding-block: var(--section-pad-block);
}

.contact__inner {
  display: flex;
  flex-direction: column;
  gap: var(--footer-gap);
}

.contact__heading {
  width: 80%;       /* "Contact me" reduced ~20% */
  height: auto;
  align-self: center;
}

/* Contact links — mobile: stacked & centered (matches mobile frame) */
.contact__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: clamp(16px, 5vw, var(--fs-contact));
  text-transform: uppercase;
}

.contact__links a {
  display: inline-block;
  text-decoration: underline;
  text-decoration-skip-ink: none;
  text-underline-offset: 2px;
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (hover: hover) {
  .contact__links a:hover { opacity: 0.55; }
}

.contact__links a:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

/* Legal — mobile: stacked & centered */
.contact__legal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-legal);   /* 14px — fine print only */
  text-transform: uppercase;
  color: var(--color-muted);
  text-align: center;
}

/* =========================================================
   Breakpoint — tablet / desktop (>= 768px)
   ========================================================= */
@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--grid-gap);
  }

  /* Desktop: title left, role tag right */
  .card__meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 48%);
    align-items: start;
    gap: 16px;
  }

  .card__role {
    justify-self: end;   /* tag hugs its text, aligned right */
  }

  .contact__links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 16px 48px;
  }

  .contact__legal {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    gap: 24px;
  }
}

/* =========================================================
   Entrance animations — applied to every reveal item
   Gated by [data-reveal] on <html> so content is visible if JS is off.
   ========================================================= */
[data-reveal] .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: var(--rd, 0ms);
  will-change: opacity, transform;
}

[data-reveal] .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Hero gets its own entrance: fade + gentle scale on the title media
   (overrides the generic slide-up, which reads oddly on the black band). */
[data-reveal] .hero__inner.reveal {
  opacity: 1;
  transform: none;
}

[data-reveal] .hero__inner.reveal .hero__media {
  opacity: 0;
  transition: opacity 0.8s ease;
  will-change: opacity;
}

[data-reveal] .hero__inner.reveal.is-visible .hero__media {
  opacity: 1;
}

/* Gentle stagger: right-column cards trail the left ones */
@media (min-width: 768px) {
  [data-reveal] .grid .card:nth-child(even) { --rd: 90ms; }
}

/* Footer items cascade */
[data-reveal] .contact__links.reveal { --rd: 90ms; }
[data-reveal] .contact__legal.reveal { --rd: 160ms; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] .reveal,
  [data-reveal] .hero__inner.reveal .hero__media {
    opacity: 1; transform: none; transition: none;
  }
  .hero__video {
    transition: none;
    -webkit-clip-path: none;
            clip-path: none;
  }
  .card__img { transition: none; }
  * { scroll-behavior: auto; }
}

/* =========================================================
   Pointer micro-interactions
   Enabled by main.js (adds .pointer-fine on <html>) only on
   fine-pointer devices with motion allowed. No effect otherwise.
   ========================================================= */

/* Smooth 3D tilt on the project players */
.pointer-fine .player {
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
}

/* Native cursor hidden over players — the custom PLAY cursor takes over */
.pointer-fine .player:not(:has(iframe)) { cursor: none; }

/* Static play glyph fades out while the custom cursor is shown */
.pointer-fine .player.is-hovered .player__play { opacity: 0; }

/* Custom "PLAY" cursor */
.cursor-play {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 95;
  pointer-events: none;
  transform: translate3d(-300px, -300px, 0);
}

.cursor-play__dot {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: var(--color-bg);
  font-family: var(--font-sans);
  font-weight: var(--fw-bold);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
}

.cursor-play.is-active .cursor-play__dot {
  opacity: 1;
  transform: scale(1);
}

.contact__links a { will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .pointer-fine .player,
  .hero__media { transition: none; }
  .cursor-play { display: none; }
}
