/* ==========================================================================
   Theme
   Switch between dark and light in src/_data/site.json ("theme": "dark" |
   "light" | "auto"). To fine-tune the colours, edit the variables below.
   ========================================================================== */

:root {
  --bg: #0d0d0c;
  --fg: #e9e6e0;
  --muted: #8f8b84;        /* 5.9:1 on --bg */
  --line: #262522;
  --frame: #171715;        /* shown behind images while they load */

  --font: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --fs-small: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-title: clamp(1.625rem, 1.2rem + 1.6vw, 2.5rem);

  --gutter: clamp(1.25rem, 4vw, 4rem);
  --max: 1760px;
  --space: clamp(3rem, 7vw, 7rem);

  /* Shape of the key stills on the Selected Works page.
     16 / 9, 2.39 / 1, 1.85 / 1 ... or "auto" to show each at its own ratio. */
  --index-ratio: 16 / 9;

  --fade: 700ms;
}

:root[data-theme="light"] {
  --bg: #f3f1ec;
  --fg: #171614;
  --muted: #64605a;        /* 5.7:1 on --bg */
  --line: #dcd8d0;
  --frame: #e6e2da;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f3f1ec;
    --fg: #171614;
    --muted: #64605a;
    --line: #dcd8d0;
    --frame: #e6e2da;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, dl, dd, figure, ul { margin: 0; }
ul { padding: 0; list-style: none; }
img, picture { display: block; max-width: 100%; }
img { height: auto; }

a {
  color: inherit;
  text-decoration: none;
  transition: color 200ms ease, opacity 200ms ease;
}

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

::selection { background: var(--fg); color: var(--bg); }

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

.page { flex: 1; }

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 0.5rem 0.75rem;
  background: var(--fg);
  color: var(--bg);
  font-size: var(--fs-small);
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* Subtle fade-in for images (only when JS is running). */
.js img.fade { opacity: 0; transition: opacity var(--fade) ease; }
.js img.fade.is-loaded { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js img.fade { opacity: 1; }
}

/* ==========================================================================
   Header + footer
   ========================================================================== */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding-block: clamp(1.25rem, 3vw, 2.25rem);
  font-size: var(--fs-small);
}

.site-id { display: flex; flex-wrap: wrap; column-gap: 0.75rem; }
.site-name { font-weight: 500; }
.site-role { color: var(--muted); }

.site-nav { display: flex; gap: clamp(1rem, 2.5vw, 2rem); }
.site-nav a { color: var(--muted); }
.site-nav a:hover,
.site-nav a[aria-current] { color: var(--fg); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  margin-top: var(--space);
  padding-block: 2rem clamp(1.5rem, 3vw, 2.5rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-small);
}

.footer-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.footer-links a:hover { color: var(--fg); }

.section-label {
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--muted);
  margin-block: clamp(2rem, 6vw, 5rem) clamp(1.25rem, 2.5vw, 2rem);
}

/* ==========================================================================
   Selected Works
   ========================================================================== */

.works {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 3vw, 2.5rem);
}

@media (min-width: 760px) {
  .works { grid-template-columns: 1fr 1fr; }
}

.work a { display: block; }

.work-frame {
  aspect-ratio: var(--index-ratio);
  overflow: hidden;
  background: var(--frame);
}

.work-frame picture,
.work-frame img {
  width: 100%;
  height: 100%;
}

.work-frame img {
  object-fit: cover;
  transition: opacity var(--fade) ease, filter 400ms ease;
}

/* "thumbnailCrop": false in projects.json: show the whole still at its own
   aspect ratio instead of filling the shared frame. */
.work-frame--whole { aspect-ratio: auto; }
.work-frame--whole picture,
.work-frame--whole img { height: auto; }

.work a:hover .work-frame img.is-loaded,
.work a:focus-visible .work-frame img.is-loaded { opacity: 0.82; }

.work-caption {
  padding-top: 0.9rem;
  font-size: var(--fs-small);
}

.work-title { font-size: var(--fs-base); font-weight: 500; }
.work-meta { color: var(--muted); }

/* ==========================================================================
   Project page
   ========================================================================== */

.project-head {
  display: grid;
  gap: 1.75rem;
  margin-block: clamp(2rem, 6vw, 5rem) clamp(2rem, 4vw, 3.5rem);
}

@media (min-width: 900px) {
  .project-head {
    grid-template-columns: 1fr minmax(20rem, 28rem);
    align-items: end;
  }
}

.project-title {
  font-size: var(--fs-title);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.credits {
  display: grid;
  gap: 0.3rem;
  font-size: var(--fs-small);
}

.credits > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
}

.credits dt { color: var(--muted); }
.credits dd span { display: block; }

/* Video: shows a poster first, loads the player on click. */
.video {
  position: relative;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.video-facade,
.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-facade { display: block; cursor: pointer; }
/* "contain": a poster wider than the player (e.g. a 2.39 still in a 16:9
   player) is shown whole, letterboxed on black like the film, never cropped. */
.video-facade picture,
.video-facade img { width: 100%; height: 100%; object-fit: contain; }

.video-play {
  position: absolute;
  left: clamp(1rem, 2.5vw, 2rem);
  bottom: clamp(1rem, 2.5vw, 2rem);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-size: var(--fs-small);
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  transition: opacity 250ms ease;
}

.video-play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.4rem 0 0.4rem 0.65rem;
  border-color: transparent transparent transparent currentColor;
}

.video-facade::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent 40%);
  transition: opacity 250ms ease;
}

.video-facade:hover::after,
.video-facade:focus-visible::after { opacity: 0.5; }
.video-facade:focus-visible { outline-offset: -3px; outline-color: #fff; }

/* Stills: centred stack (default) or two-column grid ("layout": "grid").
   On big screens the stack stops at --still-max so frames aren't blown up
   past their real resolution; on laptops and phones it still fills the width. */
.stills {
  --still-max: 1080px;
  display: grid;
  gap: clamp(1.5rem, 5vw, 5rem);
  margin-top: clamp(1.5rem, 5vw, 5rem);
}

.stills:not(.stills--grid) {
  max-width: var(--still-max);
  margin-inline: auto;
}

@media (min-width: 900px) {
  .stills--grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.still-link {
  display: block;
  background: var(--frame);
  cursor: zoom-in;
}

.still-link img { width: 100%; }

.still figcaption {
  padding-top: 0.6rem;
  color: var(--muted);
  font-size: var(--fs-small);
}

.next-project {
  margin-top: var(--space);
}

.next-project a {
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
}

.next-label { color: var(--muted); font-size: var(--fs-small); }
.next-title { font-size: var(--fs-title); line-height: 1.1; letter-spacing: -0.01em; }
.next-project a:hover .next-title { color: var(--muted); }

/* ==========================================================================
   Lightbox
   ========================================================================== */

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

.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #e9e6e0;
}

.lightbox::backdrop { background: #000; }
.lightbox:focus { outline: none; }

.lightbox[open] { animation: lb-fade 300ms ease; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }

.lb-stage {
  position: absolute;
  inset: 3.5rem clamp(0rem, 4vw, 4.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-stage picture { display: contents; }

.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  animation: lb-fade 300ms ease;
}

.lb-btn {
  position: absolute;
  padding: 1rem 1.25rem;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-size: var(--fs-small);
  opacity: 0.65;
  cursor: pointer;
}

.lb-btn:hover,
.lb-btn:focus-visible { opacity: 1; }
.lb-btn:focus-visible { outline: 1px solid currentColor; outline-offset: -6px; }

.lb-close { top: 0; right: 0; }
.lb-prev { left: 0; bottom: 0; }
.lb-next { right: 0; bottom: 0; }

.lb-count {
  position: absolute;
  top: 0;
  left: 0;
  padding: 1rem 1.25rem;
  font-size: var(--fs-small);
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 900px) {
  .lb-prev, .lb-next { top: 50%; bottom: auto; transform: translateY(-50%); }
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact { max-width: 44rem; }

.contact-list {
  display: grid;
  gap: 0.6rem;
}

.contact-list > div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
}

@media (max-width: 480px) {
  .contact-list > div { grid-template-columns: 1fr; gap: 0.1rem; }
  .contact-list > div + div { margin-top: 0.6rem; }
}

.contact-list dt { color: var(--muted); }
.contact-list dd span { display: block; }

.contact a,
.lead a {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.25em;
}

.contact a:hover,
.lead a:hover { text-decoration-color: currentColor; }

.lead { font-size: var(--fs-base); }

.contact-form {
  display: grid;
  gap: 1.1rem;
  margin-top: 1rem;
}

.contact-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: var(--fs-small);
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.7rem 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-base);
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-bottom-color: var(--fg);
}

.contact-form button {
  justify-self: start;
  padding: 0.7rem 1.4rem;
  background: var(--fg);
  color: var(--bg);
  border: 0;
  font: inherit;
  font-size: var(--fs-small);
  cursor: pointer;
}

.contact-form button:hover { opacity: 0.85; }
