/* ==========================================================================
   Wilson McMillan — site styles
   Tokens → base → header/footer → pages (home, video, photo, about) → lightbox
   ========================================================================== */

@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Screening-room palette: the UI stays quiet so footage and photos carry the colour. */
  --stage: #15232a;
  --raise: #1e2e36;
  --line: #314149;
  --text: #ece9e3;
  --muted: #9faaad;
  --tungsten: #e3b167; /* focus rings and required stars — nothing else */

  --sans: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gutter: clamp(1rem, 4vw, 2.5rem);
  --pad: max(var(--gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --max: 1240px;
  --radius: 6px;

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(5rem + env(safe-area-inset-top, 0px));
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--stage);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
body:has(dialog[open]) { overflow: hidden; }

main { flex: 1 0 auto; }

img, video, iframe { max-width: 100%; }
a { color: inherit; }
::selection { background: color-mix(in srgb, var(--tungsten) 40%, transparent); }

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

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

/* ---------- cross-page fade ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.28s; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--stage) 34%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  view-transition-name: site-header;
}
.site-header .bar {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--pad);
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-right: 0.75rem;
  color: #dcdbe1;
  text-decoration: none;
}
.wm {
  display: block;
  height: 1.15rem;
  width: auto;
  overflow: visible;
  opacity: 0.8;
  filter: blur(0.25px)
          drop-shadow(0.5px 0 0 rgb(255 70 90 / 0.3))
          drop-shadow(-0.5px 0 0 rgb(70 210 255 / 0.3))
          drop-shadow(0 0 4px rgb(220 219 225 / 0.3));
  transition: opacity 0.2s;
}
.wordmark:hover .wm,
.wordmark:focus-visible .wm { opacity: 1; }
.nav {
  display: flex;
  margin-left: auto;
  margin-right: -0.75rem; /* optical: link padding aligns text to the gutter */
}
.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: clamp(0.5rem, 2.4vw, 0.9rem);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color 0.2s;
}
.nav a:hover,
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"] { font-weight: 500; }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: clamp(0.5rem, 2.4vw, 0.9rem);
  right: clamp(0.5rem, 2.4vw, 0.9rem);
  bottom: 7px;
  height: 1px;
  background: currentColor;
}


/* ---------- footer ---------- */
.site-footer {
  flex-shrink: 0;
  margin-top: clamp(3.5rem, 9vw, 6.5rem);
  border-top: 1px solid var(--line);
}
.site-footer .bar {
  max-width: var(--max);
  margin-inline: auto;
  padding: 0.75rem var(--pad) calc(0.75rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 0.25rem;
}
.social {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--muted);
  transition: color 0.2s;
}
.social:hover { color: var(--text); }
.social svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- shared: headings + buttons ---------- */
.section-title {
  margin: 0 0 1rem;
  font-size: clamp(1.25rem, 2.8vw, 1.65rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

/* ---------- home ---------- */
.home .wordmark { display: none; }

/* header floats transparently over the hero, then picks up its blur once you scroll past it */
.home .site-header {
  position: fixed;
  inset: 0 0 auto 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: background-color 0.3s, backdrop-filter 0.3s;
}
.home .site-header.is-scrolled {
  background: color-mix(in srgb, var(--stage) 34%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.home main { display: flex; }

.hero {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 26rem;
  overflow: hidden;
  background: #0b1317 url("../hero/header-poster.jpg") center / cover no-repeat;
  isolation: isolate;
}
.hero__media {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* darkens the footage for legibility and melts the bottom edge into the page */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgb(21 35 42 / 0.5) 0%, rgb(21 35 42 / 0.2) 38%, rgb(21 35 42 / 0.34) 70%, var(--stage) 100%);
}
.hero__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.15rem, 1vh, 0.6rem);
  padding: 0 var(--pad);
}
.hero-name {
  display: flex;
  justify-content: center;
  margin: 0;
  font-size: clamp(1.2rem, 5.6vw, 2rem); /* the glyph height: small and quiet, one line */
}
/* VHS on-screen-display lettering: faded phosphor grey, soft glow, a hint of red/cyan tracking fringe */
.osd {
  display: block;
  height: 1em;
  width: auto;
  overflow: visible;
  color: #dcdbe1;
  opacity: 0.65;
  filter: blur(0.3px)
          drop-shadow(0.03em 0 0 rgb(255 70 90 / 0.3))
          drop-shadow(-0.03em 0 0 rgb(70 210 255 / 0.3))
          drop-shadow(0 0 0.28em rgb(220 219 225 / 0.3))
          drop-shadow(0 0 0.45em rgb(6 14 18 / 0.75));   /* soft dark halo so it stays readable over bright footage */
}

/* the running clock from the VHS footage: black-backed, so it screens straight into the picture */
.clock {
  position: absolute;
  right: max(var(--pad), 1rem);
  bottom: clamp(1rem, 4vh, 2rem);
  z-index: 1;
  width: clamp(86px, 10.5vw, 138px);
  aspect-ratio: 236 / 48;
  height: auto;
  object-fit: contain;
  mix-blend-mode: screen;
  opacity: 0.65;
  filter: blur(0.3px);
  pointer-events: none;
}

/* ---------- VHS play button: the on-screen "PLAY ▶" of an old VCR ---------- */
.vhs {
  display: inline-flex;
  align-items: center;
  min-height: 56px;
  padding: 0.5rem 1.25rem;
  color: #d6d5dc;
  text-decoration: none;
}
.vhs__text {
  display: block;
  height: clamp(0.95rem, 3.6vw, 1.4rem);
  width: auto;
  overflow: visible;
  opacity: 0.65;
  /* phosphor glow + the faint red/cyan fringe of a tracking-worn tape */
  filter: blur(0.3px)
          drop-shadow(0.6px 0 0 rgb(255 70 90 / 0.3))
          drop-shadow(-0.6px 0 0 rgb(70 210 255 / 0.3))
          drop-shadow(0 0 4px rgb(220 219 225 / 0.3))
          drop-shadow(0 0 7px rgb(6 14 18 / 0.75));
  transition: filter 0.2s, opacity 0.2s;
}
.vhs:hover .vhs__text,
.vhs:focus-visible .vhs__text {
  opacity: 0.95;
  filter: blur(0.25px)
          drop-shadow(1.2px 0 0 rgb(255 70 90 / 0.5))
          drop-shadow(-1.2px 0 0 rgb(70 210 255 / 0.5))
          drop-shadow(0 0 8px rgb(233 232 238 / 0.6))
          drop-shadow(0 0 7px rgb(6 14 18 / 0.75));
}
@media (prefers-reduced-motion: no-preference) {
  .vhs:hover .vhs__text,
  .vhs:focus-visible .vhs__text { animation: vhs-jitter 0.32s steps(2, end) 1; }
}
@keyframes vhs-jitter {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-2px) skewX(-4deg); }
  50%  { transform: translateX(2px); }
  75%  { transform: translateX(-1px) skewX(3deg); }
  100% { transform: translateX(0); }
}

/* reel viewer (reuses the lightbox shell) */
.viewer__frame {
  position: relative;
  width: min(100%, 1280px, calc((100dvh - 7rem) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08), 0 30px 90px -30px rgb(0 0 0 / 0.8);
}
.viewer__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.viewer__frame video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- video ---------- */
.group + .group { margin-top: clamp(2.75rem, 6.5vw, 4.5rem); }

.pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.75rem, 3.4vw, 2.5rem);
}
@media (min-width: 760px) {
  .pair { grid-template-columns: 1fr 1fr; }
}

.clip { margin: 0; }
/* each tile is a button: hover to preview (muted), click to open the player */
.frame {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  aspect-ratio: 16 / 9;
  background: #0d171c;
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  pointer-events: none;
}
/* a chosen still shown until the preview is actually playing (and again when you move away) */
.frame__poster {
  position: absolute;
  inset: 0;
  z-index: 1;                 /* above the video, so the chosen still wins until the preview plays */
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s;
  pointer-events: none;
}
.frame.is-playing .frame__poster { opacity: 0; }
/* If an MP4 isn't present yet, the tile keeps its still (or a plain placeholder). */
.frame.is-missing video { display: none; }
.clip figcaption {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 1.4;
  opacity: 0;                      /* hidden until the video starts playing (space is kept, so nothing jumps) */
  transition: opacity 0.6s ease;
}
.clip.has-played figcaption { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .clip figcaption { transition: none; } }
@media (max-width: 639px) {
  .frame { width: calc(100% + 2 * var(--pad)); margin-inline: calc(-1 * var(--pad)); border-radius: 0; }
}

/* ---------- photo ---------- */
.shoot + .shoot { margin-top: clamp(2.75rem, 6.5vw, 4.5rem); }

/* Fallback (no JavaScript): justified rows. */
.wall {
  --row: 210px;
  --gap: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wall li {
  --ar: calc(var(--w) / var(--h));
  position: relative;
  flex-grow: calc(var(--ar) * 100);
  flex-shrink: 1;
  flex-basis: calc(var(--ar) * var(--row));
  background: var(--raise);
  overflow: hidden;
}
.wall li::before { content: ""; display: block; padding-top: calc(100% / var(--ar)); }
.wall a { position: absolute; inset: 0; display: block; cursor: zoom-in; }
.wall img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 600px)  { .wall { --row: 260px; --gap: 8px; } }
@media (min-width: 1000px) { .wall { --row: 270px; --gap: 10px; } }

/* With JavaScript: every row is the same height and exactly fills the width. */
.wall.is-even li {
  flex: var(--ar) 1 0%;
  min-width: 0;
  height: var(--rowh);
}
.wall.is-even li::before { display: none; }
.wall.is-even .brk {
  flex: 0 0 100%;
  height: 0;
  margin-block: calc(var(--gap) * -0.5);
  background: none;
}

/* ---------- inner pages ---------- */
.page-wrap { padding-top: clamp(1.25rem, 4vw, 2.5rem); }

/* ---------- about: picture left, contact right ---------- */
.duo {
  display: grid;
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: center;
}
@media (min-width: 900px) {
  .duo { grid-template-columns: 5fr 7fr; }
  .duo .contact { order: 1; }
  .duo .duo__photo { order: 2; }
}
.duo__photo { margin: 0; }
.duo__photo img { display: block; width: 100%; height: auto; border-radius: var(--radius); }

.contact { text-align: center; }
.contact__title {
  margin: 0 0 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.contact__line { margin: 0 0 0.55rem; font-size: 0.875rem; line-height: 1.5; }
.contact__label { color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
.contact__line a {
  font-weight: 300;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  transition: text-decoration-color 0.2s;
}
.contact__line a:hover { text-decoration-color: var(--tungsten); }

/* ---------- grainy VHS backdrop on the inner pages ---------- */
/* a faint, soft film-grain texture drifting slowly beneath everything, with a gentle flicker */
.grainfx {
  position: fixed;
  inset: -256px;
  z-index: -1;
  background: url("../grain/tile.png") 0 0 / 256px 256px;
  opacity: 0.2;
  pointer-events: none;
  will-change: transform, opacity;
  animation: grain-drift 26s linear infinite, grain-flicker 6.5s ease-in-out infinite;
}
@keyframes grain-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(-256px, -256px); } /* exactly one tile, so the loop is seamless */
}
@keyframes grain-flicker {
  0%, 100% { opacity: 0.17; }
  18%      { opacity: 0.26; }
  41%      { opacity: 0.14; }
  66%      { opacity: 0.24; }
  83%      { opacity: 0.16; }
}
@media (prefers-reduced-motion: reduce) {
  .grainfx { animation: none; opacity: 0.2; }
}

/* the slowed, softened VHS footage under it all */
.bgfx {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.2;
  pointer-events: none;
}

/* ---------- lightbox ---------- */
.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
}
.lightbox::backdrop { background: rgb(8 14 17 / 0.95); }
.lightbox[open] { animation: lb-in 0.22s ease-out; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lightbox[open] { animation: none; } }

.lightbox__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px))
           max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  touch-action: pan-y pinch-zoom;
}
.lightbox__stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 2px;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(21 35 42 / 0.7);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s;
}
.lb-btn:hover { background: rgb(49 65 73 / 0.9); }
.lb-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lb-close { top: max(0.75rem, env(safe-area-inset-top, 0px)); right: max(0.75rem, env(safe-area-inset-right, 0px)); }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: max(0.75rem, env(safe-area-inset-left, 0px)); }
.lb-next { right: max(0.75rem, env(safe-area-inset-right, 0px)); }
/* On phones, swiping is the gesture; keep the arrows from covering the photo. */
@media (max-width: 639px) and (pointer: coarse) {
  .lb-prev, .lb-next { display: none; }
}
