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

:root {
  --black: #000;
  --white: #fff;
  --nav-h: 68px;
}

html { background: var(--black); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;               /* "clip" (not "hidden") so position: sticky keeps working */
}

img { display: block; max-width: 100%; user-select: none; -webkit-user-drag: none; }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,0));
  pointer-events: none;
}
.nav__brand {
  display: block;
  line-height: 0;
  pointer-events: auto;
  transition: opacity .3s ease, transform .3s ease;
}
.nav__brand img { height: 38px; width: auto; }
.nav__brand:hover { opacity: .8; transform: scale(1.06); }
.nav__brand:focus-visible { outline: 2px solid var(--white); outline-offset: 6px; border-radius: 4px; }

/* ---------- Stage (hero + bio share one pinned portrait) ---------- */
.stage {
  /* Everything is derived from the viewport height so the logo / portrait
     overlap stays consistent on any screen. */
  --H: max(100vh, 560px);                      /* hero height */
  --P: min(92vh, 160vw);                       /* portrait height */
  --pw: calc(var(--P) * 0.6209);               /* portrait width (aspect 1166:1878) */
  --head: .54;                                 /* where the head sits across the portrait (0–1) */
  --crop: .20;                                 /* share of the portrait that bleeds off the bottom */
  --logo-w: min(88vw, 1100px, 84vh);
  --logo-h: calc(var(--logo-w) / 3.224);       /* logo aspect 474:147 */
  --overlap: .30;                              /* how much of the logo the head covers */
  --mx: 0; --my: 0;                            /* set by JS (parallax) */

  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--H) auto;           /* row 1 = hero, row 2 = bio */
}
@supports (height: 100svh) {
  .stage {
    --H: max(100svh, 560px);
    --P: min(92svh, 160vw);
    --logo-w: min(88vw, 1100px, 84svh);
  }
}

/* Pinned portrait layer */
.stage__pin {
  grid-area: 1 / 1 / 3 / 2;                    /* spans hero + bio, so it can only stick until the bio ends */
  align-self: start;
  position: sticky;
  top: 0;
  z-index: 2;
  height: var(--H);
  overflow: hidden;
  pointer-events: none;
}
/* fade the bottom of the portrait into the black page */
.stage__pin::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 30%;
  background: linear-gradient(to top, #000 14%, rgba(0,0,0,0));
}

.portrait {
  position: absolute;
  bottom: calc(var(--P) * var(--crop) * -1);
  left: 50%;
  height: var(--P);
  aspect-ratio: 1166 / 1878;
  /* shifted so the HEAD (not the image) sits on the page's center line */
  transform: translate3d(calc(var(--head) * -100% + var(--mx) * 10px), calc(var(--my) * 5px), 0);
  will-change: transform;
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* soften the cropped left/right edges of the photo */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 9%, #000 91%, transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 9%, #000 91%, transparent 100%);
}

/* ---------- Hero ---------- */
.hero {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  height: var(--H);
  overflow: hidden;
  isolation: isolate;
}
.hero__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 55% 45% at 50% 58%, rgba(255,255,255,.09), rgba(255,255,255,0) 70%);
  pointer-events: none;
}
.hero__logo {
  position: absolute;
  left: 50%;
  top: max(
    calc(var(--nav-h) + 14px),
    calc(var(--H) - var(--P) * (1 - var(--crop)) - var(--logo-h) * (1 - var(--overlap)))
  );
  width: var(--logo-w);
  transform: translate3d(calc(-50% + var(--mx) * -14px), calc(var(--my) * -8px), 0);
  will-change: transform;
}
.hero__logo img { width: 100%; height: auto; }

.stage__memorial {
  position: absolute;
  z-index: 4;
  left: 0; right: 0;
  top: calc(var(--H) - 44px - env(safe-area-inset-bottom, 0px));
  margin: 0;
  text-align: center;
  font-size: .75rem;
  line-height: 1;
  font-weight: 500;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  pointer-events: none;
}

/* ---------- Bio ---------- */
.bio {
  grid-area: 2 / 1;
  position: relative;
  z-index: 3;                                  /* text sits above the portrait */
  min-height: var(--H);                        /* one screen tall: when it fills the screen the portrait lets go and scrolls WITH the text */
  padding: 12vh 4vw 8vh;
}
@supports (height: 100svh) { .bio { padding: 12svh 4vw 8svh; } }

.bio__grid {
  --gap: clamp(20px, 2.4vw, 40px);             /* space between text and portrait */
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "title ." "left right";
  max-width: 1800px;
  margin: 0 auto;
}
.bio__title  { grid-area: title; }
.bio__col--left  { grid-area: left; }
.bio__col--right { grid-area: right; }

/* keep each column clear of the portrait (head sits on the center line) */
.bio__title,
.bio__col--left  { padding-right: calc(var(--pw) * var(--head) + var(--gap)); }
.bio__col--right { padding-left:  calc(var(--pw) * (1 - var(--head)) + var(--gap)); }

.bio__title {
  margin: 0 0 clamp(14px, 1.6vw, 26px);
  font-size: clamp(3rem, 5.4vw, 5.6rem);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: .95;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--white);
}

.bio__col p {
  margin: 0 0 1.15em;
  font-size: clamp(.72rem, .88vw, .9rem);
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: -.005em;
  text-align: justify;
  text-justify: inter-word;
  hyphens: manual;
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 5;
  background: var(--black);
  border-top: 1px solid rgba(255,255,255,.14);
  padding: clamp(48px, 7vw, 88px) 4vw calc(clamp(36px, 5vw, 64px) + env(safe-area-inset-bottom, 0px));
  text-align: center;
}
.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px clamp(28px, 5vw, 64px);
  margin-bottom: clamp(28px, 4vw, 44px);
}
.footer__links a {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--white);
  text-decoration: none;
  padding-bottom: 6px;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .35s ease, opacity .3s ease;
}
.footer__links a:hover,
.footer__links a:focus-visible { background-size: 100% 1px; }
.footer__contact {
  margin: 0;
  font-size: .85rem;
  font-weight: 400;
  color: rgba(255,255,255,.7);
}
.footer__contact a {
  color: var(--white);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(255,255,255,.4);
  transition: text-decoration-color .3s ease;
}
.footer__contact a:hover { text-decoration-color: var(--white); }
a:focus-visible { outline: 2px solid var(--white); outline-offset: 4px; }

/* ---------- Entrance animations (only when JS is running) ---------- */
.js .hero__logo img,
.js .portrait img,
.js .stage__memorial,
.js .nav__brand { opacity: 0; }
.js .hero__logo img { transform: translateY(24px) scale(.97); }
.js .portrait img   { transform: translateY(40px); }

.js.is-loaded .nav__brand,
.js.is-loaded .hero__logo img,
.js.is-loaded .portrait img,
.js.is-loaded .stage__memorial { opacity: 1; transform: none; }

.js.is-loaded .nav__brand      { transition: opacity 1s ease .1s, transform .3s ease; }
.js.is-loaded .hero__logo img  { transition: opacity 1.4s ease .15s, transform 1.6s cubic-bezier(.2,.7,.2,1) .15s; }
.js.is-loaded .portrait img    { transition: opacity 1.4s ease .45s, transform 1.8s cubic-bezier(.2,.7,.2,1) .45s; }
.js.is-loaded .stage__memorial { transition: opacity 1.6s ease 1.3s; }

/* desktop only: "In loving memory" fades out as soon as the visitor scrolls */
@media (min-width: 961px) {
  .js.intro-done .stage__memorial { transition: opacity .35s ease; }
  .js.is-scrolled .stage__memorial { opacity: 0; transition: opacity .35s ease; }
}

/* bio paragraphs fade up as they scroll in */
.js .bio__col p { opacity: 0; transform: translateY(18px); transition: opacity .9s ease, transform .9s cubic-bezier(.2,.7,.2,1); }
.js .bio__col p.is-in { opacity: 1; transform: none; }
.js .bio__title { opacity: 0; transition: opacity 1s ease; }
.js .bio__title.is-in { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .hero__logo img, .js .portrait img, .js .stage__memorial, .js .nav__brand,
  .js .bio__col p, .js .bio__title { opacity: 1; transform: none; transition: none !important; }
  .hero__logo { transform: translate3d(-50%, 0, 0); }
  .portrait   { transform: translate3d(calc(var(--head) * -100%), 0, 0); }
}

/* ---------- Tablet & mobile: no flanking, portrait stays with the hero ---------- */
@media (max-width: 960px) {
  :root { --nav-h: 60px; }
  .nav__brand img { height: 32px; }
  .stage { --crop: .06; --overlap: .10; }

  .stage__pin { grid-area: auto; position: absolute; inset: 0 0 auto 0; }

  .bio { min-height: 0; padding: 6vh 7vw 14vh; }
  .bio__grid { grid-template-columns: 1fr; grid-template-areas: "title" "left" "right"; }
  .bio__title, .bio__col--left, .bio__col--right { padding-left: 0; padding-right: 0; }
  .bio__title { font-size: clamp(3.4rem, 16vw, 5rem); }
  .bio__col p { font-size: .9rem; line-height: 1.45; text-align: left; }

  .stage__memorial { font-size: .65rem; letter-spacing: .26em; }
}
