/* chrisbernier.com public site.
   Type: one grotesque sans + its mono (A24 approach). Fonts live in exactly two
   variables; to switch to PP Neue Montreal, drop the two licensed .woff2 files in
   /fonts and change the two @font-face blocks below. */

@font-face {
  font-family: "Site Sans";
  src: url("/fonts/InterTight-Variable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Site Mono";
  src: url("/fonts/GeistMono-Variable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched fallbacks: keep line breaks stable while the web fonts load. */
@font-face {
  font-family: "Site Sans Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  size-adjust: 94%;
  ascent-override: 102%;
  descent-override: 26%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Site Mono Fallback";
  src: local("Menlo"), local("Consolas"), local("Courier New");
  size-adjust: 100%;
  ascent-override: 98%;
  descent-override: 24%;
  line-gap-override: 0%;
}

:root {
  --font-sans: "Site Sans", "Site Sans Fallback", system-ui, sans-serif;
  --font-mono: "Site Mono", "Site Mono Fallback", ui-monospace, monospace;

  --bg: #0b0b0c;
  --fg: #f2f2f0;
  --fg-2: #a3a3a0;
  --rule: rgba(242, 242, 240, 0.16);
  --accent: #e0a868;
  --card-bg: #1a1a1c;

  --pad: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(0.22, 0.7, 0.2, 1);
  --slide: 600ms;

  --fs-display: clamp(3rem, 8.4vw, 8.5rem);
  --fs-title-xl: clamp(2.25rem, 5.4vw, 5.5rem);
  --fs-title-l: clamp(1.75rem, 3.6vw, 3.5rem);
  --fs-row: clamp(1.5rem, 3.4vw, 3.25rem);
  --fs-body: 1.125rem;
  --fs-label: 0.6875rem;
}

:root[data-theme="light"] {
  --bg: #e9e7e2;
  --fg: #151514;
  --fg-2: #5c5b57;
  --rule: rgba(21, 21, 20, 0.18);
  --accent: #9a4f12;
  --card-bg: #d9d6cf;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 420;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { list-style: none; padding: 0; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: var(--pad); top: -100px; z-index: 100;
  background: var(--fg); color: var(--bg); padding: 10px 14px; font-family: var(--font-mono);
  font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em;
}
.skip:focus { top: 10px; }

.wrap { padding-inline: var(--pad); }

/* ---------- Type roles ---------- */
.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 450;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.4;
}
.display {
  font-size: var(--fs-display);
  font-weight: 480;
  letter-spacing: -0.035em;
  line-height: 0.95;
}
.title-xl {
  font-size: var(--fs-title-xl);
  font-weight: 470;
  letter-spacing: -0.03em;
  line-height: 1;
}
.title-l {
  font-size: var(--fs-title-l);
  font-weight: 470;
  letter-spacing: -0.025em;
  line-height: 1.02;
}
.secondary, .spot { color: var(--fg-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 12px 18px; border: 1px solid var(--fg); border-radius: 999px;
  transition: background-color 200ms, color 200ms;
}
.btn::before {
  content: ""; width: 0; height: 0;
  border-left: 7px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent;
}
.btn:hover { background: var(--fg); color: var(--bg); }
.btn-text { padding: 8px 2px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; }
.btn-text:hover { text-decoration-color: currentColor; }
.link-arrow { text-decoration: none; display: inline-flex; gap: 8px; padding: 8px 0; }
.link-arrow::after { content: "\2192"; font-family: var(--font-sans); }
.link-arrow:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Header (A24 layout: nav left, name centered, contact right) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 60px; padding: 10px var(--pad);
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
.nav { display: flex; gap: clamp(14px, 2vw, 28px); align-items: center; }
.nav a { text-decoration: none; padding: 8px 0; }
.nav a:hover, .nav a[aria-current="true"] { text-decoration: underline; text-underline-offset: 4px; }
.nav-right { justify-content: flex-end; }
.brand {
  text-decoration: none; justify-self: center;
  font-size: clamp(1.25rem, 1.9vw, 1.625rem); font-weight: 520; letter-spacing: -0.02em; line-height: 1;
  padding: 6px 0;
}
.brand img { height: 34px; width: auto; }
.menu-toggle { display: none; padding: 8px 0; }
.mobile-menu {
  grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; padding: 16px 0 8px;
}
.mobile-menu[hidden] { display: none; }
.mobile-menu a { text-decoration: none; font-size: 2rem; font-weight: 470; letter-spacing: -0.02em; padding: 4px 0; }

@media (max-width: 760px) {
  .site-header { grid-template-columns: 1fr auto; }
  .nav-left { display: none; }
  .brand { justify-self: start; grid-column: 1; grid-row: 1; }
  .nav-right { grid-column: 2; grid-row: 1; }
  .nav-right a { display: none; }
  .menu-toggle { display: block; }
}

/* ---------- Sections ---------- */
.section { padding-block: clamp(56px, 9vw, 140px) 0; position: relative; }
.section-selected { padding-top: clamp(20px, 3vw, 40px); }
.section-head { margin-bottom: clamp(20px, 3vw, 40px); }
.section-kicker { margin-bottom: 16px; }
.intro { max-width: 46ch; margin-top: 20px; color: var(--fg-2); }
.below-carousel { margin-top: 8px; }

/* ---------- Carousel ---------- */
/* Space reserved before the content arrives, so nothing below shifts:
   stage (27% of width) + caption (roles, two title lines, button). */
.carousel { position: relative; outline: none; min-height: calc(27.2vw + 18px + var(--fs-title-xl) * 2 + 104px); }
@media (max-width: 699px) { .carousel { min-height: calc(44vw + 18px + 54px + var(--fs-title-xl) * 2 + 104px); } }
.carousel-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.27;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
@media (max-width: 699px) { .carousel-stage { aspect-ratio: 1 / 0.4388; } }

.c-card {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 100%;
  transition: transform var(--slide) var(--ease), opacity var(--slide) var(--ease);
  will-change: transform, opacity;
  background: var(--card-bg);
  overflow: hidden;
}
.c-card .media { position: absolute; inset: 0; overflow: hidden; }
.c-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.c-card .gray { filter: grayscale(1); }
.c-card .color { opacity: 0; transition: opacity var(--slide) var(--ease); }
.c-card.is-active .color { opacity: 1; }
.c-card.is-hidden { visibility: hidden; transition: transform var(--slide) var(--ease), opacity var(--slide) var(--ease), visibility 0s linear var(--slide); }

/* Slow zoom on the active still (transform only). */
@keyframes slowzoom { from { transform: scale(1); } to { transform: scale(1.08); } }
.zoom-on .zoomable { animation: slowzoom 18s linear infinite alternate; }

.preview-host { position: absolute; inset: 0; pointer-events: none; }
.preview-frame {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
  opacity: 0; transition: opacity 700ms var(--ease);
}
.preview-frame.is-playing { opacity: 1; }

.carousel-caption {
  position: relative;
  margin-top: 18px;
  padding-left: var(--c-left, var(--pad));
  padding-right: var(--pad);
  display: grid;
  grid-template-columns: minmax(0, var(--c-width, 1fr)) 1fr;
  gap: 16px 32px;
  align-items: start;
}
.caption-text { transition: opacity 220ms var(--ease); min-height: calc(var(--fs-title-xl) * 2 + 104px); }
.caption-text.is-fading { opacity: 0; }
.caption-roles { color: var(--fg-2); margin-bottom: 10px; }
.caption-title { margin-bottom: 20px; }
.carousel-controls { display: flex; gap: 20px; align-items: center; justify-content: flex-end; padding-top: 2px; }
.carousel-count { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.carousel-controls button { padding: 10px 0; }
.carousel-controls button:hover { text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 699px) {
  .carousel-caption { grid-template-columns: 1fr; }
  .carousel-controls { justify-content: flex-start; order: -1; }
}

/* ---------- Reel ---------- */
/* Same width and left edge as the Selected Work carousel's active card (carousel.js
   LAYOUT: 8.5% / 50% of the stage, 6% / 78% when the stage is under 700px). The
   section is a size container so the breakpoint follows its width, as the carousel's does.
   2.39:1 with cover, so letterbox bars in a 16:9 poster or video never show. */
.section-reel { container-type: inline-size; }
.reel { margin-left: 8.5%; width: 50%; max-width: var(--poster-w, none); }
@container (max-width: 699px) { .reel { margin-left: 6%; width: 78%; } }
.reel-frame {
  display: block; position: relative; width: 100%; aspect-ratio: 2.39 / 1; overflow: hidden;
  background: var(--card-bg); cursor: pointer;
}
.reel-frame img { width: 100%; height: 100%; object-fit: cover; }
/* The preview is 16:9: size it to the frame's width and center it, so the frame
   crops the video's own letterbox bars. */
.reel-frame .preview-frame {
  inset: auto; left: 50%; top: 50%; width: calc(100% * var(--reel-scale, 1)); height: auto; aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
}
.reel-meta { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; margin-top: 20px; }

/* ---------- Work index (A24 rows, role filters) ---------- */
.work-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: clamp(24px, 3.5vw, 48px); }
.filter {
  min-height: 44px; padding: 10px 16px; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--fg-2); transition: color 200ms, border-color 200ms, background-color 200ms;
}
.filter .count { margin-left: 4px; opacity: 0.75; font-variant-numeric: tabular-nums; }
.filter:hover { color: var(--fg); border-color: var(--fg-2); }
.filter[aria-pressed="true"] { color: var(--bg); background: var(--fg); border-color: var(--fg); }
.work-index { margin-top: clamp(20px, 3vw, 40px); }
/* Reserve space until the list renders, so Contact does not start in view and jump. */
.work-index:empty { min-height: 100vh; }

/* Stacking for the hover still: other rows (1) < still (2) < hovered row (3).
   overflow: clip keeps the still inside the Work section. */
.work-list { position: relative; isolation: isolate; overflow: clip; border-top: 1px solid var(--rule); }
.rows li { position: relative; }
.row {
  position: relative; z-index: 1;
  display: grid; width: 100%; text-align: left;
  grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 26rem);
  gap: 8px 24px; align-items: baseline;
  padding: clamp(10px, 1.4vw, 18px) 0;
  border-bottom: 1px solid var(--rule);
}
.row.is-hot { z-index: 3; }
.row-year { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.row-title { font-size: var(--fs-row); font-weight: 460; letter-spacing: -0.025em; line-height: 1.04; }
.row-title .client { color: var(--fg); }
.row-title .spot { color: var(--fg-2); transition: color 200ms; }
.row-roles { color: var(--fg-2); text-align: right; }
.row-thumb { display: none; }
.work-index.no-years .row { grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); }
.work-index.no-years .row-year { display: none; }
.row:hover .spot, .row:focus-visible .spot, .row.is-hot .spot { color: var(--fg); }
.rows { transition: opacity 160ms var(--ease); }
.rows.is-fading { opacity: 0; }
.row.is-hot .row-title, .row.is-hot .row-roles { text-shadow: 0 0 2px var(--bg), 0 0 18px var(--bg), 0 0 36px var(--bg); }
.row.is-hot .row-roles { color: var(--fg); }

.work-peek {
  position: absolute; z-index: 2; top: 0; left: 36%; width: min(50%, 760px);
  aspect-ratio: 16 / 9; pointer-events: none;
}
.work-peek img {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 320ms var(--ease), transform 320ms var(--ease);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.work-peek img.no-move { transition: opacity 320ms var(--ease); }
.work-peek img.is-shown { opacity: 1; }

@media (max-width: 760px) {
  .row, .work-index.no-years .row { grid-template-columns: 3.25rem minmax(0, 1fr); }
  .work-index.no-years .row { grid-template-columns: minmax(0, 1fr); }
  .row-roles { grid-column: 2; text-align: left; }
  .work-index.no-years .row-roles { grid-column: 1; }
  .work-peek { left: 30%; width: 66%; }
}
/* Touch screens: no hover, so each row shows a small thumbnail instead (no peek). */
@media (hover: none) {
  .row, .work-index.no-years .row { grid-template-columns: 96px minmax(0, 1fr); align-items: center; }
  .row-year { display: none; }
  .row-thumb { display: block; grid-row: span 2; width: 96px; aspect-ratio: 16 / 9; height: auto; object-fit: cover; background: var(--card-bg); }
  .row-title { font-size: clamp(1.25rem, 5.4vw, 2rem); }
  .row-roles, .work-index.no-years .row-roles { grid-column: 2; text-align: left; }
  .work-peek { display: none; }
  .work-filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad); scrollbar-width: none; }
  .filter { flex: none; }
}

/* ---------- Contact / footer ---------- */
.section-contact .about { max-width: 34ch; margin-top: 28px; font-size: clamp(1.25rem, 2.2vw, 1.75rem); letter-spacing: -0.01em; line-height: 1.3; }
.section-contact .email { margin-top: 24px; }
.section-contact .email a {
  font-size: var(--fs-title-l); font-weight: 470; letter-spacing: -0.025em; line-height: 1.1;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.12em; word-break: break-word;
}
.site-footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: clamp(64px, 9vw, 140px); padding-block: 24px 32px; border-top: 1px solid var(--rule); color: var(--fg-2);
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.noscript { padding-block: 40px; }

/* ---------- Player (simple pop-up) ---------- */
/* Always dark, whatever the site theme: it is a screening room over the page. */
html.player-open { overflow: hidden; }
.player {
  --arrow: 56px; --gap: clamp(12px, 2vw, 28px); --meta: 76px;
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: transparent; color: #f2f2f0;
}
.player::backdrop { background: rgba(5, 5, 6, 0.88); }
.player[open] { display: block; }
.player-body {
  height: 100%; display: grid; grid-template-columns: var(--arrow) auto var(--arrow);
  justify-content: center; align-items: center; gap: var(--gap); padding: 64px var(--pad);
}
.player-frame {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  width: min(calc(100vw - 2 * var(--pad) - 2 * var(--arrow) - 2 * var(--gap)), calc((100dvh - 128px - var(--meta)) * 16 / 9));
}
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-frame .player-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #a3a3a0; padding: 24px; text-align: center; }
.player-meta { min-height: var(--meta); padding-top: 14px; }
.player-title { font-size: clamp(1.0625rem, 1.5vw, 1.375rem); font-weight: 470; letter-spacing: -0.01em; line-height: 1.2; }
.player-roles { margin-top: 6px; color: #a3a3a0; }

.player-close, .parrow {
  display: grid; place-items: center; width: var(--arrow); height: var(--arrow); border-radius: 50%;
  color: #f2f2f0; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(242, 242, 240, 0.35);
  font-size: 1.375rem; line-height: 1; transition: background-color 150ms, color 150ms, border-color 150ms;
}
.player-close:hover, .parrow:hover { background: #f2f2f0; color: #0b0b0c; border-color: #f2f2f0; }
.player-close:focus-visible, .parrow:focus-visible { outline: 2px solid #f2f2f0; outline-offset: 3px; }
.player-close { position: fixed; top: 12px; right: 12px; z-index: 2; width: 48px; height: 48px; font-size: 1.125rem; }
.parrow[hidden] { display: grid; visibility: hidden; }
.player.is-single .player-body { grid-template-columns: auto; }
.player.is-single .parrow { display: none; }
.player.is-single .player-frame { width: min(calc(100vw - 2 * var(--pad)), calc((100dvh - 128px - var(--meta)) * 16 / 9)); }

/* Phones: video full width, arrows below it. */
@media (max-width: 760px) {
  .player { --arrow: 52px; }
  .player::backdrop { background: rgba(5, 5, 6, 0.96); }
  .player-body {
    grid-template-columns: 1fr 1fr; grid-template-areas: "stage stage" "prev next";
    align-content: center; gap: 16px 12px; padding: 72px 0 24px;
  }
  .player-stage { grid-area: stage; }
  .parrow-prev { grid-area: prev; justify-self: end; }
  .parrow-next { grid-area: next; justify-self: start; }
  .player-frame, .player.is-single .player-frame { width: 100vw; }
  .player-meta { padding: 12px var(--pad) 0; min-height: 0; }
  .player.is-single .player-body { grid-template-columns: 1fr; grid-template-areas: "stage"; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .player-meta { display: none; }
  .player-body { padding-block: 12px; }
  .player-frame { width: min(calc(100vw - 2 * var(--pad) - 2 * var(--arrow) - 2 * var(--gap)), calc((100dvh - 24px) * 16 / 9)); }
}

/* ---------- Route layouts (data-route is set on <html> before first paint) ---------- */
main { display: flex; flex-direction: column; }
[data-route="director"] .section-selected,
[data-route="director"] .section-reel { display: none; }
[data-route="director"] .section-director { padding-top: clamp(28px, 4vw, 56px); }
[data-route="reel"] .section-reel { order: -1; padding-top: clamp(20px, 3vw, 40px); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .rows, .work-peek img { transition: none; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}
