/* Values from Figma frame "MacBook Pro 14' - 5" (1512px wide). */
:root {
  --bg: #040404;
  --fg: #ffffff;
  --muted: #393939;
  --chip-bg: rgba(132, 132, 132, 0.29);
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --card-w: 990px;
  --card-ratio: 2500 / 1405; /* Simple Plan - Nothing Changes still */
  --card-gap: 75px;

  /* Video page vertical layout (desktop):
     - first card centered in the window (never closer than 132px to the top)
     - category row centered between the VIDEO/PHOTO text (bottom at 65.5px) and that card */
  --nav-bottom: 65.5px;
  --filter-h: 17px;
  --header-h: 82px;
  /* Card width: 990px, or narrower if the window is narrow, or short enough that a full
     card couldn't sit centered below the header (keeps it centered on iPad landscape
     and short laptop windows). */
  --card-w-fit: min(var(--card-w), 100vw - 32px, (100svh - 264px) * 2500 / 1405);
  --card-h: calc(var(--card-w-fit) * 1405 / 2500);
  --card-top: max(132px, calc(50svh - var(--card-h) / 2));
  --filter-top: calc((var(--nav-bottom) + var(--card-top)) / 2 - var(--filter-h) / 2);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

/* Always reserve scrollbar space so centered content doesn't jump when a
   filter makes the page too short to scroll. */
html { scrollbar-gutter: stable; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  position: relative;
  height: 82px; /* spacer only; logo, nav and Contact are fixed */
}

.logo-link {
  position: fixed; /* stays put while scrolling */
  z-index: 20;
  left: 27px;
  top: 25px;
  display: block;
  width: 150px;
  height: 66px;
}
.logo { display: block; width: 100%; height: 100%; object-fit: cover; }

.media-nav {
  position: fixed;      /* stays put while scrolling, like the logo + Contact */
  top: 34px;            /* 274 x 47 hit area from Figma, text lands at y=48 */
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 5px;
}
.media-link {
  display: grid;
  place-items: center;
  width: 107px;
  height: 47px;
  font-size: 14px;
  color: var(--muted);  /* inactive: grey */
  transition: color 0.2s;
}
.media-link.is-active { color: var(--fg); }  /* current page: white */
.media-link:not(.is-active):hover { color: #6a6a6a; }

.contact-link {
  position: fixed; /* stays put while scrolling */
  z-index: 20;
  top: 46px;
  right: 87px; /* text starts at x=1372 in a 1512px window */
  font-size: 15px;
}
.contact-link:hover { opacity: 0.7; }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: calc(var(--filter-top) - var(--header-h));
}
.filter {
  font: inherit;
  font-size: 15px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}
.filter:hover { color: #6a6a6a; }
.filter.is-active { color: var(--fg); }

/* ---------- Projects ---------- */
.projects {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--card-gap);
  /* Card top = --card-top (see :root). Bottom pad lets the last card scroll past center. */
  padding: calc(var(--card-top) - var(--filter-top) - var(--filter-h)) 16px 50vh;
}
.project {
  position: relative;
  display: block;
  width: min(var(--card-w-fit), 100%);
  aspect-ratio: var(--card-ratio);
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  /* Own compositing layer + mask: makes Safari clip the video to the rounded
     corners and edges exactly (it otherwise lets a sliver of the layer below show). */
  isolation: isolate;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  transform: translateZ(0);
}
.project[hidden] { display: none; }
.project img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* crop to the shared ratio, centered */
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.3s, opacity 0s;
}

/* Hover loop: sits over the cover still, fades in only once frames are playing.
   Scaled 1% so it always overdraws the card edges (no cover hairline at the sides). */
.project .clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.01);
  transition: opacity 0.35s ease-out, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.project .clip.is-playing { opacity: 1; }
/* Once the clip is fully faded in, hide the cover underneath; it comes back instantly when the clip stops. */
.project:has(.clip.is-playing) img {
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.3s, opacity 0s linear 0.35s;
}

/* Cards ease up + fade in on page load, staggered 120ms apart. Only when JS is running
   (html.js-reveal) so cards never stay hidden if scripts fail; off for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .js-reveal .project:not(.is-in) { opacity: 0; transform: translate3d(0, 24px, 0); }
  .js-reveal .project.is-in {
    transition:
      opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
      transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--reveal-delay, 0ms);
  }
}

/* Hover zoom only where there's a real pointer (no sticky hover after a tap on touch screens). */
@media (hover: hover) {
  .project:hover img { transform: scale(1.015); filter: brightness(1.08); }
  .project:hover .clip { transform: scale(1.025); }
}

/* ---------- REEL view: no scroll, full reel playing in place ---------- */
.reel-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
.reel-mode, .reel-mode body { overflow: hidden; height: 100%; }
.reel-mode .projects { padding-bottom: 0; }
.reel-mode .title-chip { display: none; }   /* would sit on top of the player controls */

.empty { color: var(--muted); font-size: 15px; margin: 80px 0 0; }

/* ---------- Fixed title chip ---------- */
.title-chip {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  --chip-pad: 14px;
  height: 40px;
  padding: 0 var(--chip-pad);
  border-radius: 10px;
  background: var(--chip-bg);
  /* Glass frost from Figma: heavy background blur, slight color lift, no edge highlight, flat */
  -webkit-backdrop-filter: blur(var(--frost, 14px)) saturate(1.25) brightness(1.04);
  backdrop-filter: blur(var(--frost, 14px)) saturate(1.25) brightness(1.04);
  font-size: 16px;
  line-height: 40px;
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.38s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;   /* WIDTH_MS in script.js */
}
/* Intro (first open): a frosted ball pops in, stretches into the rectangle, text fades in. */
.title-chip.intro {
  transition:
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    width 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    border-radius 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.title-chip.intro-ball,
.title-chip.intro-pop { width: 40px !important; border-radius: 20px; padding: 0; }
.title-chip.intro-ball { transform: translate(-50%, -50%) scale(0); }
.title-chip.intro .title-text { opacity: 0; transition: opacity 0.25s ease-out; }
.title-chip.intro.intro-text .title-text { opacity: 1; }

.title-chip.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; transition: none; }

/* Text is centered on the chip's (fixed) center, so while the chip resizes to the new
   title the text only travels vertically, never sideways. */
.title-track { position: relative; display: block; height: 40px; text-align: center; }
.title-text {
  display: block;
  transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.title-text.leaving {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}
.title-text.from-below { transform: translateY(100%); opacity: 0; }
.title-text.to-above  { transform: translateY(-100%); opacity: 0; }
.title-text.from-above { transform: translateY(-100%); opacity: 0; }
.title-text.to-below  { transform: translateY(100%); opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .title-chip, .title-text, .project img { transition: none; }
}

/* ---------- Phones: Figma frame "iPhone 18 Pro - 1" (402 x 874) ----------
   VIDEO / PHOTO top-left, Contact top-right, logo centered between that row and
   the first card, first card centered in the screen. All top items stay fixed. */
@media (max-width: 700px) {
  :root {
    --nav-bottom: 37px;                                   /* nav text 20px + 17px line */
    --card-w-fit: calc(100vw - 24px);
    --card-h: calc(var(--card-w-fit) * 1405 / 2500);
    --card-top: max(151px, calc(50svh - var(--card-h) / 2)); /* 151 = room for the logo */
    --logo-top: calc((var(--nav-bottom) + var(--card-top)) / 2 - 37px); /* = 147px in the 874px frame */
  }
  .site-header { height: 0; }

  .media-nav { top: 5px; left: 13px; transform: none; gap: 19px; }
  .media-link { width: auto; padding: 0 12px; }          /* VIDEO text at x=25, PHOTO at x=109 */

  .contact-link { top: 19px; right: 18px; font-size: 14px; }

  .logo-link {
    left: 50%;
    top: var(--logo-top);
    transform: translateX(-50%);
    width: 150px;
    height: 66px;
  }

  .filters { display: none; }                             /* not in the phone design */

  .projects { gap: 20px; padding: var(--card-top) 12px 50vh; }
  .project { border-radius: 5px; }
}
