/* ==========================================================================
   Units
   - rem  font sizes and spacing that belongs to text (label → value, lists)
   - %    layout: widths, columns, gaps, section spacing (vertical % margins
          and paddings are a share of the container width, like the Figma
          frame scaled down)
   - vw / svh / dvh  full-screen sections (hero, lightbox)
   - em   button padding
   - px   only hairlines, outlines and blur radii
   ========================================================================== */

:root {
  --color-bg: #131313;
  --color-text: #ffffff;
  --color-accent: #ff5900;
  --color-placeholder: #262626; /* solid fill used until real images exist */

  /* Two families: one for running text, one for titles and "Filmmaker".
     Swap these two lines when the final fonts arrive. */
  --font-base: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* One side margin for every page: content is 94% wide (3% each side). */
  --content-ratio: 0.94;
  --col-gap: 4.3%;          /* 60 / 1390 */
  --radius: 4.5% / 8%;      /* 30px corners on a 16:9 box, scaling with it */
  --nav-h: 7.5rem;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 56.25em) {
  :root {
    --content-ratio: 0.9;   /* 5% each side on tablets and phones */
    --nav-h: 5.25rem;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 1rem;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main { flex: 1; }

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

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
h1, h2, h3 { font-size: inherit; font-weight: inherit; }
ul { padding: 0; list-style: none; }

p {
  text-wrap: pretty;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.container {
  width: calc(var(--content-ratio) * 100%);
  margin-inline: auto;
}

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

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 3%;
  z-index: 100;
  padding: 0.5em 0.75em;
  background: var(--color-accent);
  color: var(--color-bg);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

.label { font-weight: 300; }

.link { transition: color 0.2s ease; }

@media (hover: hover) {
  .link:hover { color: var(--color-accent); }
}

/* ---------- Logo (navbar + footer) ---------- */

.logo {
  display: inline-flex;
  flex-direction: column;
  gap: 0.5625rem;
  white-space: nowrap;
}

.logo__name { font-weight: 300; }

.logo__role {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.1em;
  color: var(--color-accent);
}

.logo--footer { gap: 0.25rem; }
.logo--footer .logo__name { font-weight: 400; }

/* ---------- Navbar ---------- */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: var(--nav-h);
  pointer-events: none;
}

/* Progressive blur: stacked layers, each blurring a bit more and masked to a
   shorter band, so content fades into the blur instead of hitting a hard
   edge. The blurs compound, reaching roughly the 12.7px of the Figma navbar
   at the very top and zero at the bottom of the band. */
.site-header__blur {
  position: absolute;
  inset: 0 0 auto;
  height: calc(var(--nav-h) * 1.45);
}

.site-header__blur > span,
.site-header__blur::after {
  position: absolute;
  inset: 0;
}

.site-header__blur > span:nth-child(1) {
  -webkit-backdrop-filter: blur(0.75px);
  backdrop-filter: blur(0.75px);
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
}
.site-header__blur > span:nth-child(2) {
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
  -webkit-mask-image: linear-gradient(to bottom, #000 56%, transparent 84%);
  mask-image: linear-gradient(to bottom, #000 56%, transparent 84%);
}
.site-header__blur > span:nth-child(3) {
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(to bottom, #000 42%, transparent 70%);
  mask-image: linear-gradient(to bottom, #000 42%, transparent 70%);
}
.site-header__blur > span:nth-child(4) {
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  -webkit-mask-image: linear-gradient(to bottom, #000 28%, transparent 56%);
  mask-image: linear-gradient(to bottom, #000 28%, transparent 56%);
}
.site-header__blur > span:nth-child(5) {
  -webkit-backdrop-filter: blur(11px);
  backdrop-filter: blur(11px);
  -webkit-mask-image: linear-gradient(to bottom, #000 12%, transparent 42%);
  mask-image: linear-gradient(to bottom, #000 12%, transparent 42%);
}

/* A light tint (Figma: rgba(19,19,19,.17)) keeps the links readable over
   bright footage; it fades out together with the blur. */
.site-header__blur::after {
  content: "";
  background: linear-gradient(to bottom, rgba(19, 19, 19, 0.38), rgba(19, 19, 19, 0));
}

.site-header__inner {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2%;
}

.site-header__inner > * { pointer-events: auto; }

.site-nav {
  display: flex;
  justify-content: space-between;
  width: 40.6%;             /* 564 / 1390 */
}

.site-nav a[aria-current="page"] { color: var(--color-accent); }

@media (max-width: 56.25em) {
  .site-header .logo { font-size: 0.875rem; gap: 0.375rem; }
  /* rem, not %: a % gap on an auto-width row is added after its width is
     computed and pushes the last link past the margin */
  .site-nav { width: auto; gap: 1.125rem; font-size: 0.875rem; }
  .site-nav li { white-space: nowrap; }
}

/* ---------- Footer ---------- */

.site-footer {
  background: linear-gradient(to bottom, rgba(19, 19, 19, 0.1), rgba(255, 255, 255, 0.15));
  font-size: 1.25rem;
}

.site-footer__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 2%;
  padding-block: 5%;        /* ≈ 77 / 1512 → 206 tall in Figma */
}

.site-footer__email { justify-self: center; }

.social {
  display: flex;
  gap: 1.625rem;
  justify-self: end;
}

@media (max-width: 56.25em) {
  .site-footer { font-size: 1.125rem; }
  .site-footer__inner {
    grid-template-columns: 1fr;
    justify-items: start;
    row-gap: 1.75rem;
    padding-block: 15% 17%;
  }
  .site-footer__email,
  .social { justify-self: start; }
}

/* ---------- Cards (home mosaic + other projects) ---------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
  width: 100%;
}

.card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: var(--color-placeholder);
  background-size: cover;
  background-position: center;
  /* Safari: keep rounded corners while the image scales on hover */
  isolation: isolate;
}

.card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.8s var(--ease-out);
}

.card__media img.is-loaded { opacity: 1; }

@media (hover: hover) {
  .card:hover .card__media img { transform: scale(1.03); }
}

.card__title {
  font-weight: 700;
  text-transform: uppercase;
}

/* ---------- Home: hero with showreel ---------- */

.hero {
  position: relative;
  height: 100svh;
  min-height: 30rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  overflow: hidden;
  background: var(--color-placeholder);
}

.hero__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Darkens the footage a little and melts its bottom edge into the page. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(19, 19, 19, 0.2) 0%,
    rgba(19, 19, 19, 0.25) 65%,
    var(--color-bg) 100%
  );
  pointer-events: none;
}

/* Two overlapping texts: the name behind, "Filmmaker" in front.
   Pure CSS: the hero is a full-screen section, so the lettering is sized in
   vw from the same ratio as the page margins. --name-em is how many "em"
   the name is wide in the current font (plus a little slack): retune it
   when the final display font arrives and the name will span the content
   width again. */
.hero-title {
  --name-em: 11.7;          /* system font: 11.48em + ~2% slack */
  --hero-size: calc(var(--content-ratio) * 100vw / var(--name-em));
  position: relative;
  z-index: 1;
  width: calc(var(--content-ratio) * 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.hero-title > * { grid-area: 1 / 1; }

.hero-title__name {
  font-family: var(--font-display);
  font-size: var(--hero-size);
  font-weight: 800;
  line-height: 0.86;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
}

.hero-title__role {
  font-family: var(--font-display);
  font-size: calc(var(--hero-size) * 0.5);
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  white-space: nowrap;
  /* The Figma lettering uses a wide font: with the default one a moderate
     spacing reads better. Retune with the final font. */
  letter-spacing: 0.4em;
  /* letter-spacing also adds space after the last letter: pull it back so
     the word stays optically centred */
  margin-right: -0.4em;
  color: var(--color-accent);
}

/* Phones: the name breaks on two lines, so it can be much bigger. */
@media (max-width: 43.75em) {
  .hero-title { --name-em: 6; }   /* widest line "FRANCESCO": 5.88em */
  .hero-title__name > span { display: block; }
  .hero-title__role { font-size: calc(var(--hero-size) * 0.36); }
}

/* ---------- Home: works ---------- */

.works {
  padding-top: 4.6%;        /* 70 / 1512 */
  padding-bottom: 10.6%;
  scroll-margin-top: calc(var(--nav-h) * 0.6);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  column-gap: 4.8%;         /* 67 / 1390 */
  row-gap: 0.75rem;
  margin-bottom: 2.9%;      /* 40 / 1390 */
  font-size: 1.25rem;
  text-transform: uppercase;
  color: var(--color-accent);
}

.filters button {
  text-transform: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.375rem;
  transition: text-decoration-color 0.2s ease;
}

.filters button[aria-pressed="true"] { text-decoration-color: currentColor; }

@media (hover: hover) {
  .filters button:hover { text-decoration-color: currentColor; }
}

.mosaic {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  column-gap: var(--col-gap);
}

/* Vertical rhythm as a margin: % margins on grid items are a share of the
   cell width (60 / 665), while a % row-gap would depend on the grid height. */
.mosaic > * { margin-bottom: 9%; }

.mosaic__message {
  grid-column: 1 / -1;
  font-weight: 300;
}

@media (max-width: 56.25em) {
  .works { padding-top: 10%; padding-bottom: 14%; }
  .filters { font-size: 1rem; column-gap: 6%; margin-bottom: 8%; }
  .mosaic { grid-template-columns: minmax(0, 1fr); }
  .mosaic > * { margin-bottom: 12%; }
}

/* ---------- Lightbox ---------- */

.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #0b0b0b;
  color: var(--color-text);
  overflow: hidden;
}

.lightbox::backdrop { background: #0b0b0b; }

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.lightbox__top,
.lightbox__bottom,
.lightbox__stage {
  width: calc(var(--content-ratio) * 100%);
  margin-inline: auto;
}

.lightbox__top,
.lightbox__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.75rem;
}

.lightbox__caption {
  display: flex;
  gap: 1rem;
}

.lightbox__stage {
  position: relative;
  display: grid;
  /* a definite 1fr cell lets the photo's max-height: 100% resolve */
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox__stage img,
.lightbox__placeholder {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox__placeholder {
  height: 100%;
  background: var(--color-placeholder);
}

.lightbox__nav {
  display: flex;
  gap: 2rem;
}

.lightbox__nav button,
.lightbox__top button { padding: 0.5em 0; }

.lightbox__counter { font-weight: 300; font-variant-numeric: tabular-nums; }

/* ---------- Project page ---------- */

main.is-loading { min-height: 100svh; }

.project-hero {
  position: relative;
  overflow: hidden;
  padding-top: calc(var(--nav-h) + 12.2%);   /* 184 / 1512 below the navbar */
  padding-bottom: 5.4%;                      /* 82 / 1512 */
  /* vertical swipes still scroll; a sideways finger drag wipes the glass */
  touch-action: pan-y pinch-zoom;
}

/* Misted glass: the video is blurred here; js/fog.js adds a canvas on top
   that shows it sharp only where the pointer wipes, like a finger on a
   fogged window. */
.project-hero__bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--color-placeholder);
  --blur: 12px;
  --fog-scale: 1.08;   /* read by js/fog.js so the sharp trail lines up */
}

.project-hero__bg video,
.project-hero__bg img,
.project-hero__clear {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.project-hero__bg video,
.project-hero__bg img {
  object-fit: cover;
  /* the mist: blurred, a touch paler and flatter than the wiped trail */
  filter: blur(var(--blur)) brightness(1.08) saturate(0.8) contrast(0.88);
  /* scale up so the blur does not leave a dark halo at the edges */
  transform: scale(var(--fog-scale));
}

.project-hero__clear { pointer-events: none; }

.project-hero__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(19, 19, 19, 0.35) 0%,
    rgba(19, 19, 19, 0.45) 70%,
    var(--color-bg) 100%
  );
}


.project-hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--col-gap);
}

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-placeholder);
  isolation: isolate;
}

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

.player__poster img { object-fit: cover; }

/* Round play button: its size comes from the em padding around the icon. */
.player__play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  padding: 1.5em;
  border-radius: 50%;
  background: rgba(19, 19, 19, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%);
  transition: transform 0.4s var(--ease-out), background-color 0.2s ease;
}

.player__play svg {
  width: 1.375em;
  height: 1.625em;
  margin-left: 0.25em;
}

@media (hover: hover) {
  .player__poster:hover .player__play {
    transform: translate(-50%, -50%) scale(1.08);
    background-color: var(--color-accent);
  }
}

.project-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
}

.project-info__row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 0.5625rem;
}

.meta dd { font-weight: 500; }

.project-info__title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.project-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--col-gap);
  padding-top: 3.3%;        /* 50 / 1512 */
  padding-bottom: 10.7%;    /* 162 / 1512 */
}

.project-body .label { display: block; margin-bottom: 0.75rem; }

.prose { 
 display: flex;
 flex-direction: column;
 justify-content: space-between;
 gap: 1.5rem;
 line-height: 1.5rem;
}

.credits {
  display: flex;
  flex-direction: column;
  gap: 0.5625rem;
}

.credits li {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}

.credits li span:last-child { text-align: right; }

.other { padding-bottom: 14.6%; }

.section-title {
  margin-bottom: 2.9%;      /* 40 / 1390 */
  font-size: 1.25rem;
  text-transform: uppercase;
  color: var(--color-accent);
}

.other__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--col-gap);
}

.status {
  padding-top: calc(var(--nav-h) + 5%);
  padding-bottom: 10%;
}

.status p { margin-top: 1rem; }

@media (max-width: 56.25em) {
  .project-hero { padding-top: calc(var(--nav-h) + 8%); padding-bottom: 10%; }

  .project-hero__inner { grid-template-columns: minmax(0, 1fr); }
  .project-info { margin-top: 8%; }
  .project-info__title { font-size: 1.75rem; }

  .project-body { display: block; padding-top: 10%; padding-bottom: 16%; }
  .project-body > * + * { margin-top: 16%; }

  .section-title { font-size: 1rem; margin-bottom: 8%; }

  /* Other projects become a horizontal swipe row that bleeds to the screen
     edges: 5.556% of the 90% container is the 5% side margin. */
  .other__grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 78%;
    column-gap: 4%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-inline: -5.556%;
    padding-inline: 5.556%;
    scroll-padding-inline: 5.556%;
    scrollbar-width: none;
  }
  .other__grid::-webkit-scrollbar { display: none; }
  .other__grid > * { scroll-snap-align: start; }
}

/* ---------- About ---------- */

.about {
  display: grid;
  grid-template-columns: minmax(0, 645fr) minmax(0, 162fr) minmax(0, 583fr);
  padding-top: calc(var(--nav-h) + 3.1%);    /* 47 / 1512 */
  padding-bottom: 13.1%;                     /* 198 / 1512 */
}

.about__left { grid-column: 1; }
.about__right { grid-column: 3; }

.about__lead {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
}

.about__photo {
  margin-top: 16.3%;        /* 105 / 645 */
  aspect-ratio: 645 / 362;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-placeholder);
}

.about__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about__contacts { margin-top: 6.3%; }  /* 37 / 583 */

.about__contacts .label { display: block; margin-bottom: 0.5625rem; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5625rem;
}

@media (max-width: 75em) {
  .about__lead { font-size: 2.25rem; }
}

@media (max-width: 56.25em) {
  .about { display: block; padding-top: calc(var(--nav-h) + 8%); padding-bottom: 16%; }
  .about__lead { font-size: 1.75rem; }
  .about__photo { margin-top: 12%; }
  .about__right { margin-top: 14%; }
  .about__contacts { margin-top: 12%; }
}

/* ---------- Contact ---------- */

.contact {
  padding-top: calc(var(--nav-h) + 6.3%);    /* 96 / 1512 */
  padding-bottom: 13.1%;
}

.contact__title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
}

.contact__subtitle {
  margin-top: 1rem;
  font-size: 1.5rem;
}

.contact__block { margin-top: 4%; }
.contact__block--email { margin-top: 9.8%; }

.contact__block .label { display: block; margin-bottom: 1rem; }

.contact__email {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
  transition: color 0.2s ease;
}

.arrow {
  display: inline-block;
  transition: transform 0.35s var(--ease-out);
}

@media (hover: hover) {
  .contact__email:hover { color: var(--color-accent); }
  a:hover > .arrow { transform: translate(0.2rem, -0.2rem); }
}

.contact__copy {
  margin-top: 1.25rem;
  font-weight: 300;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3125rem;
}

.contact__social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.5rem;
  font-size: 1.5rem;
}

@media (max-width: 75em) {
  .contact__email { font-size: 3.5rem; }
}

@media (max-width: 56.25em) {
  .contact { padding-top: calc(var(--nav-h) + 12%); padding-bottom: 16%; }
  .contact__title { font-size: 2rem; }
  .contact__subtitle,
  .contact__social { font-size: 1.25rem; }
  .contact__block { margin-top: 14%; }
  .contact__block--email { margin-top: 20%; }
  .contact__email { font-size: 2rem; }
}

@media (max-width: 30em) {
  .contact__email { font-size: 1.375rem; }
}
