/* ============================================================
   Gabe Williams — portfolio (v4)
   Two visual identities that share a neutral cover.
   Marketing = daylight (light, bright, editorial).
   Animation = darkness (near-black, quiet, exact).
   The switch flips the whole page light<->dark over ~600ms.
   ============================================================ */

:root {
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --page-pad: clamp(1.25rem, 7vw, 8rem);
}

/* identity palettes ---------------------------------------- */
body[data-view="cover"]     { --ground: #C7C7C4; --ink: #161616; --muted: #4e4e4c; --line: #a7a7a3; }
body[data-view="marketing"] { --ground: #F7F7F5; --ink: #141414; --muted: #5c5c5a; --line: #e2e2de; }
body[data-view="animation"] { --ground: #0B0B0C; --ink: #EDEDEA; --muted: #8c8c88; --line: #26262a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--ground);
  color: var(--ink);
  font-size: clamp(14px, 1.05vw, 16px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.6s ease, color 0.6s ease;
}
img { max-width: 100%; display: block; }
figure { margin: 0; }

/* ---------------- View / crossfade ---------------- */
.stage { transition: opacity 0.6s ease; }
.stage.is-fading { opacity: 0; }
.view { display: none; }
.view.is-active { display: block; }

/* ---------------- Cover (neutral grey) ---------------- */
.cover { position: relative; overflow: hidden; min-height: 100vh; min-height: 100svh; flex-direction: column; padding: clamp(3rem, 9vh, 7rem) var(--page-pad) 0; }
.cover.is-active { display: flex; }

/* identity preview split — left ~4% lighter, right ~4% darker than the base grey.
   Sits behind everything; the two panels ease toward each section's ground on hover. */
.cover-preview { position: absolute; inset: 0; z-index: 0; display: grid; grid-template-columns: 1fr 1fr; pointer-events: none; }
.cp-l { background: #CFCFCC; transition: background-color 0.6s ease; }
.cp-r { background: #BFBFBC; transition: background-color 0.6s ease; }
body[data-view="cover"][data-hover="m"] .cp-l { background: #E7E7E3; }
body[data-view="cover"][data-hover="m"] .cp-r { background: #C1C1BE; }
body[data-view="cover"][data-hover="a"] .cp-r { background: #8e8e8c; }
body[data-view="cover"][data-hover="a"] .cp-l { background: #C1C1BE; }

.cover-head { position: relative; z-index: 2; text-align: center; }
.name { text-transform: uppercase; font-weight: 600; letter-spacing: 0.2em; margin: 0 0 0 0.2em; font-size: clamp(1.6rem, 5.4vw, 3.4rem); line-height: 1.1; }
.tagline { margin: clamp(1rem, 3vh, 1.6rem) 0 0; color: var(--muted); font-size: clamp(0.95rem, 1.9vw, 1.2rem); font-weight: 400; }
.proof { margin: 0.5rem 0 0; color: var(--muted); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; font-size: clamp(0.68rem, 1.1vw, 0.8rem); }

.doors { position: relative; z-index: 2; flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr; min-height: 56vh; margin-top: clamp(2.5rem, 7vh, 6rem); }
.door { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; color: var(--ink); padding: clamp(2rem, 6vh, 5rem) 1.5rem; }
@media (min-width: 720px) { .door + .door { border-left: 1px solid var(--line); } }

/* crossfading still stack behind each door's type. The stack sets the idle/hover
   LEVEL (0.6s); individual images crossfade against each other (1.2s). */
.door-stack { position: absolute; inset: 0; z-index: 1; overflow: hidden; opacity: 0.18; filter: saturate(0.55); transform: scale(1.04); transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s ease; }
.door-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.2s ease; }
.door-img.is-shown { opacity: 1; }

/* hovered side rises; opposite side sinks. Driven by JS (body[data-hover]) with a
   pure-CSS :hover fallback so imagery still responds without script. */
@media (hover: hover) {
  .door:hover .door-stack { opacity: 0.55; filter: saturate(1); transform: scale(1); }
  .doors:hover .door:not(:hover) .door-stack { opacity: 0.08; filter: saturate(0.4) brightness(0.6); }
}
body[data-view="cover"][data-hover="m"] .door-m .door-stack,
body[data-view="cover"][data-hover="a"] .door-a .door-stack { opacity: 0.55; filter: saturate(1); transform: scale(1); }
body[data-view="cover"][data-hover="m"] .door-a .door-stack,
body[data-view="cover"][data-hover="a"] .door-m .door-stack { opacity: 0.08; filter: saturate(0.4) brightness(0.6); }

/* type + legibility scrim (keeps dark ink AA-legible over bright OR dark stills) */
.door-inner { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 0.85rem; padding: 0.5em 1.4em; }
.door-inner::before { content: ""; position: absolute; inset: -0.6em -1.4em; z-index: -1; border-radius: 3px; background: radial-gradient(120% 120% at 50% 50%, rgba(199, 199, 196, 0.62), rgba(199, 199, 196, 0) 72%); opacity: 0; transition: opacity 0.6s ease; }
@media (hover: hover) { .door:hover .door-inner::before { opacity: 1; } }
body[data-view="cover"][data-hover="m"] .door-m .door-inner::before,
body[data-view="cover"][data-hover="a"] .door-a .door-inner::before { opacity: 1; }
.door-k { font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; font-size: clamp(1.5rem, 3.6vw, 2.8rem); text-shadow: 0 1px 12px rgba(199, 199, 196, 0.45); }
.door-sub { font-weight: 500; font-size: clamp(1rem, 1.9vw, 1.35rem); text-shadow: 0 1px 10px rgba(199, 199, 196, 0.4); }
.door-meta { color: var(--muted); font-size: clamp(0.85rem, 1.4vw, 1rem); letter-spacing: 0.02em; text-shadow: 0 1px 10px rgba(199, 199, 196, 0.4); }

/* mobile: no hover — both stacks sit at ~30% and keep crossfading, faint scrim on */
@media (hover: none) {
  .door-stack { opacity: 0.30; }
  .door-inner::before { opacity: 0.55; }
}

@media (max-width: 719px) {
  .doors { grid-template-columns: 1fr; min-height: 0; }
  .door { min-height: 42vh; }
  .door + .door { border-top: 1px solid var(--line); }
}

/* animated film grain — cover only. Stepped background-position on a tiled noise
   PNG: no canvas loop, no smooth pan, just cheap repaints. */
.cover-grain { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0.035; background: url(img/noise.png) repeat; background-size: 128px 128px; animation: grainShift 0.8s steps(1) infinite; }
@keyframes grainShift {
  0%   { background-position: 0 0; }
  12%  { background-position: -32px 12px; }
  24%  { background-position: 22px -26px; }
  36%  { background-position: -14px 22px; }
  48%  { background-position: 26px 16px; }
  60%  { background-position: -26px -12px; }
  72%  { background-position: 12px 26px; }
  84%  { background-position: -20px -22px; }
  100% { background-position: 0 0; }
}

/* first-load entrance — added by JS once per session, skipped under reduced motion */
.cover.intro .name    { animation: nameIn 0.9s ease both; }
.cover.intro .tagline { animation: coverFade 0.6s ease 0.4s both; }
.cover.intro .proof   { animation: coverFade 0.6s ease 0.55s both; }
.cover.intro .doors   { animation: coverRise 0.8s ease 0.7s both; }
@keyframes nameIn   { from { opacity: 0; letter-spacing: 0.35em; } to { opacity: 1; letter-spacing: 0.2em; } }
@keyframes coverFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes coverRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------------- Persistent switch + home ---------------- */
.switch { position: fixed; top: clamp(0.9rem, 3vh, 1.5rem); right: clamp(1rem, 4vw, 2.5rem); z-index: 50; display: none; align-items: baseline; gap: 0.7rem; }
.switch .sw { text-transform: uppercase; letter-spacing: 0.14em; text-decoration: none; color: var(--ink); font-size: clamp(0.66rem, 1.05vw, 0.78rem); font-weight: 500; transition: opacity 0.6s ease, color 0.6s ease; }
.switch .sw-div { color: var(--muted); }
.home { position: fixed; top: clamp(0.9rem, 3vh, 1.5rem); left: clamp(1rem, 4vw, 2.5rem); z-index: 50; display: none; text-decoration: none; color: var(--ink); text-transform: uppercase; letter-spacing: 0.18em; font-weight: 700; font-size: clamp(0.78rem, 1.3vw, 0.95rem); transition: color 0.6s ease; }
body[data-view="marketing"] .switch, body[data-view="animation"] .switch { display: flex; }
body[data-view="marketing"] .home,   body[data-view="animation"] .home   { display: block; }
body[data-view="marketing"] .sw-a { opacity: 0.4; }
body[data-view="animation"] .sw-m { opacity: 0.4; }

/* ---------------- Section scaffolding ---------------- */
.half { padding: clamp(4rem, 11vh, 9rem) var(--page-pad) clamp(4rem, 10vh, 8rem); }
.sec-title { font-weight: 600; letter-spacing: -0.02em; font-size: clamp(2rem, 6vw, 4.4rem); margin: 0; line-height: 1.02; }
.sec-lead { color: var(--muted); font-size: clamp(1rem, 1.9vw, 1.3rem); margin: 0.8rem 0 0; max-width: 40em; }
.cap-label { text-transform: uppercase; font-weight: 500; letter-spacing: 0.18em; font-size: clamp(0.72rem, 1.15vw, 0.82rem); color: var(--muted); }

/* ---------------- Slots & placeholders ---------------- */
.slot { display: block; position: relative; aspect-ratio: var(--ar, 3 / 2); background: transparent; overflow: hidden; }
.slot > img, .slot > picture, .slot > picture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { position: absolute; inset: 0; border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5em; text-align: center; padding: 1.5rem; color: var(--muted); }
.ph-id { text-transform: uppercase; letter-spacing: 0.18em; font-size: clamp(0.72rem, 1.2vw, 0.9rem); font-weight: 500; }
.ph-desc { font-size: clamp(0.85rem, 1.4vw, 1rem); max-width: 24em; }
.ph-ar { font-size: 0.78rem; letter-spacing: 0.06em; opacity: 0.8; }

/* ================= MARKETING (light, editorial) ================= */
.m-lead { max-width: 48em; margin: clamp(1rem, 2.5vh, 1.6rem) 0 clamp(3rem, 8vh, 6rem); }
.m-lead p { margin: 0.5em 0 0; color: var(--muted); font-size: clamp(0.95rem, 1.5vw, 1.15rem); line-height: 1.55; }
.m-lead .lead-strong { color: var(--ink); font-weight: 500; }

.film-role { margin: 0.5rem 0 0; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; font-size: clamp(0.82rem, 1.25vw, 0.95rem); }

.photo-credit { text-transform: uppercase; letter-spacing: 0.14em; font-weight: 500; font-size: clamp(0.72rem, 1.1vw, 0.82rem); color: var(--muted); margin: 0 0 clamp(1.4rem, 3.5vh, 2.2rem); }

.subhead-note { margin: 0 0 clamp(1.6rem, 4vh, 2.6rem); color: var(--muted); font-size: clamp(0.9rem, 1.4vw, 1.05rem); }

/* One contact block, both halves. `.marketing-contact` is the original class and
   is left in place so the signed-off marketing markup is not touched; the
   animation half uses `.site-contact`. Every colour is a theme variable, so the
   same rules render light on marketing and dark on animation with no override. */
.marketing-contact, .site-contact { display: block; font-style: normal; margin-top: clamp(4rem, 11vh, 9rem); border-top: 1px solid var(--line); padding-top: clamp(1.6rem, 4vh, 2.6rem); }
.marketing-contact .mc-name, .site-contact .mc-name { display: block; font-weight: 600; font-size: clamp(1.15rem, 2.2vw, 1.6rem); letter-spacing: -0.01em; }
.marketing-contact .mc-lines, .site-contact .mc-lines { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; align-items: baseline; margin-top: 0.7rem; font-size: clamp(0.95rem, 1.5vw, 1.1rem); }
.marketing-contact a, .site-contact a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; transition: border-color 0.3s ease; }
.marketing-contact a:hover, .site-contact a:hover { border-color: var(--ink); }
.marketing-contact .mc-sep, .site-contact .mc-sep { color: var(--muted); }

/* films — centred column, never wider than a 720p poster wants to be */
.filmrow { max-width: 1100px; margin: 0 auto clamp(4rem, 11vh, 9rem); }
.filmrow:last-of-type { margin-bottom: 0; }
.filmrow .film { width: 100%; }
.film-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-top: clamp(0.9rem, 2vh, 1.4rem); }
.film-title { font-weight: 600; font-size: clamp(1.2rem, 2.6vw, 2rem); letter-spacing: -0.01em; margin: 0; }
.film-index { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; letter-spacing: 0.05em; }

/* constrained grids: finished homes, crew, detail */
.subsection { margin-top: clamp(4rem, 11vh, 9rem); }
.subhead { border-top: 1px solid var(--line); padding-top: clamp(1rem, 2.5vh, 1.6rem); margin: 0 0 0.5rem; font-weight: 600; font-size: clamp(1.2rem, 2.4vw, 1.8rem); letter-spacing: -0.01em; }
.grid { display: grid; gap: clamp(1rem, 2vw, 1.8rem); }
.grid-band { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-band .slot { aspect-ratio: 3 / 2; max-height: 70vh; }
.grid-50 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-50 .slot { aspect-ratio: 3 / 2; max-height: 50vh; }
/* interview frames are 16:9 with a burned-in lower third — show the whole frame, no crop */
.grid-16 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-16 .slot { aspect-ratio: 16 / 9; max-height: 50vh; }
.grid-cap { margin-top: 0.8rem; }

/* ================= ANIMATION (dark, exact) ================= */
.animation { padding-top: clamp(5rem, 14vh, 11rem); }
.animation .sec-title { font-size: clamp(1.6rem, 4.4vw, 3rem); letter-spacing: -0.01em; }
.animation .sec-lead { font-family: var(--mono); font-size: clamp(0.8rem, 1.4vw, 0.95rem); letter-spacing: 0; }
.animation .ph-id, .animation .ph-ar { font-family: var(--mono); letter-spacing: 0.05em; }

/* Intro — mirrors .m-lead so the two halves read as siblings. */
.a-lead { max-width: 48em; margin: clamp(1rem, 2.5vh, 1.6rem) 0 clamp(3rem, 8vh, 6rem); }
.a-lead p { margin: 0.5em 0 0; color: var(--muted); font-size: clamp(0.95rem, 1.5vw, 1.15rem); line-height: 1.55; }

/* Nine renders want an explicit 3-across, not auto-fit.
   The marketing grids each hold exactly 3 items, so `repeat(auto-fit,
   minmax(260px,1fr))` happens to give them a tidy single row. With 9 items the
   same rule packs 4 columns at 1440px and strands the ninth image alone on a
   third row. Fixed tracks give a true 3x3 and keep the same rhythm as the
   marketing grids; it still steps down to 2-up and 1-up on narrow screens. */
.grid-renders { grid-template-columns: 1fr; }
@media (min-width: 620px)  { .grid-renders { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid-renders { grid-template-columns: repeat(3, 1fr); } }

/* Dark-grid separation.
   MEASURED, not guessed (scripts/edgecheck.mjs): 8 of the 9 renders have an outer
   edge within 15 luma of the #0B0B0C ground — six sit at luma ~0, i.e. pure black
   on near-black. Without a boundary those cells have no visible edge.
   A lighter CELL BACKGROUND cannot fix this: every render is fully opaque
   (minAlpha 255, 0% non-opaque pixels) and object-fit:cover fills the box, so the
   cell background is never visible behind the image. The rule is the only option
   that actually renders — it sits ON the image edge rather than behind it.
   inset instead of a border so the 1px never changes layout or aspect ratio. */
.grid-dark .slot { position: relative; }
.grid-dark .slot::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.anim-block { margin-top: clamp(5rem, 14vh, 11rem); }
.anim-block:first-of-type { margin-top: clamp(3rem, 8vh, 6rem); }
.anim-films { display: grid; grid-template-columns: 1fr; gap: clamp(2rem, 5vw, 4rem); max-width: 62rem; margin: 0 auto; }
@media (min-width: 820px) { .anim-films { grid-template-columns: 1fr 1fr; } }
.anim-plate { max-width: 62rem; margin: 0 auto; }
.anim-meta { font-family: var(--mono); font-size: clamp(0.72rem, 1.2vw, 0.82rem); color: var(--muted); margin-top: 0.9rem; letter-spacing: 0.04em; }

/* ---------------- Film player (pausable) ---------------- */
.player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.poster { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; display: block; }
.poster .slot { position: absolute; inset: 0; aspect-ratio: auto; }
.poster::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0.10); transition: background 0.4s ease; }
.poster:hover::after, .poster:focus-visible::after { background: rgba(0,0,0,0.02); }
.play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: clamp(56px, 6vw, 82px); height: clamp(56px, 6vw, 82px); border: 1.5px solid #fff; border-radius: 50%; z-index: 2; background: rgba(0,0,0,0.28); transition: transform 0.5s ease, background 0.4s ease; pointer-events: none; }
.play::before { content: ""; position: absolute; top: 50%; left: 55%; transform: translate(-50%, -50%); width: 0; height: 0; border-top: clamp(10px,1.4vw,14px) solid transparent; border-bottom: clamp(10px,1.4vw,14px) solid transparent; border-left: clamp(16px,2.1vw,23px) solid #fff; }
.poster:hover .play { transform: translate(-50%, -50%) scale(1.05); background: rgba(0,0,0,0.4); }
.player > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------------- Motion ---------------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 1s ease, transform 1s ease; will-change: opacity, transform; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .stage, body { transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .play, .poster::after, .door { transition: none; }
  /* cover: kill the grain, the crossfade transitions, and the entrance */
  .cover-grain { display: none; }
  .door-img, .door-stack, .cp-l, .cp-r, .door-inner::before { transition: none; }
  .cover.intro .name, .cover.intro .tagline, .cover.intro .proof, .cover.intro .doors { animation: none; }
}
