/*
 * The Situated Image — base stylesheet.
 * Per-visitor variables are injected at the edge as a <style> block
 * in <head>; everything here consumes those variables with safe fallbacks.
 */

/* Optician Sans — a typeface built from historical eye-chart optotypes.
 * SIL Open Font License. Used as a fixed design constant for titles,
 * regardless of the per-visitor body face. */
@font-face {
  font-family: "Optician Sans";
  src: url("/fonts/Optician-Sans.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Snellen — a classic eye-chart optotype (self-hosted, full A–Z/a–z).
 * Currently applied to the hero title only. */
@font-face {
  font-family: "Snellen";
  src: url("/fonts/Snellen.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Title face is constant; --display-serif is the fallback if the
   * optotype webfont fails to load. */
  --title-face: "Optician Sans", var(--display-serif);
  --body-serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --display-serif: "Playfair Display", "Source Serif 4", Georgia, serif;
  --color-ink: #ecede9;
  --color-paper: #20201e;  /* matches the cowboy reveal JPEGs' flat margin: JPEG's
                              YCbCr round-trip can't hold #20211e's green (33→32), so
                              the page is set to the value the frames actually render. */
  --color-accent: #93a8b5;
  --body-size: 17px;
  --body-leading: 1.6;
  --column-max: 36rem;
  --section-gap: clamp(96px, 14vw, 220px);
}

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

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--body-serif);
  font-size: var(--body-size);
  line-height: var(--body-leading);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--title-face);
  font-weight: 400;
  letter-spacing: 0.005em;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.5px;
}

a:hover { text-decoration-color: var(--color-ink); }

p { margin: 0 0 1.1em; }

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

/* ── Hero ──────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  background: #0a0a0a;
}

.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  padding: clamp(28px, 7vh, 84px) clamp(20px, 5vw, 56px) 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.hero-title {
  margin: 0;
  color: #fafafa;
  font-family: var(--title-face);
  font-size: clamp(42px, 12vw, 144px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  /* White ink through difference blend: reads white over dark areas of the
   * video and inverts to dark over light areas — never a flat overlay. */
  mix-blend-mode: difference;
}

/* Scroll cue pinned to the bottom of the hero. */
.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 3vh, 36px);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  pointer-events: auto;
  text-decoration: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
  animation: scroll-bounce 2.1s ease-in-out infinite;
}

.scroll-hint-arrow {
  display: block;
  width: 15px;
  height: 15px;
  border-right: 2px solid #fafafa;
  border-bottom: 2px solid #fafafa;
  transform: rotate(45deg);
}

@keyframes scroll-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(8px); }
}

/* ── Sections ──────────────────────────────────────────────────────── */

section {
  padding: var(--section-gap) clamp(20px, 5vw, 48px);
  max-width: 100%;
}

.statement,
.bio {
  max-width: var(--column-max);
  margin: 0 auto;
}

.statement p {
  font-size: 1.05em;
  line-height: calc(var(--body-leading) + 0.05);
}

.statement-heading {
  font-family: var(--title-face);
  text-align: center;
  font-size: 2em;
  letter-spacing: 0.02em;
  margin-bottom: 1em;
}

.statement-lede {
  font-size: 1.32em;
  line-height: 1.4;
  margin-bottom: 1.3em;
}

.statement-title {
  font-family: var(--display-serif);
  font-style: italic;
  text-align: center;
  font-size: 1.25em;
  margin: 2.5em 0;
}

.section-header {
  font-size: 2em;
  text-align: center;
  margin: 0 0 calc(var(--section-gap) / 2);
  letter-spacing: 0.04em;
}

/* ── Works ─────────────────────────────────────────────────────────── */

.works {
  max-width: 1100px;
  margin: 0 auto;
}

.work {
  margin: 0 0 calc(var(--section-gap) * 0.9);
}

.work:last-child { margin-bottom: 0; }

.work-image {
  width: 100%;
  display: block;
  margin-bottom: 1.4em;
  text-align: center;
}

/* Show the whole artwork — never crop. Tall pieces are capped to the
 * viewport height and centered. */
.work-image img {
  max-width: 100%;
  max-height: 88vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  display: block;
}

.placeholder {
  background:
    linear-gradient(135deg, rgba(0,0,0,0.04), rgba(0,0,0,0.02)),
    var(--color-paper);
  border: 1px solid rgba(0,0,0,0.08);
  display: grid;
  place-items: center;
  color: rgba(0,0,0,0.35);
  font-style: italic;
  font-size: 0.95em;
}

.placeholder-label {
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.work figcaption {
  max-width: var(--column-max);
  margin: 0 auto;
  text-align: center;
}

.work-title {
  font-family: var(--title-face);
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 1.05em;
  margin: 0 0 0.5em;
}

.work-desc {
  font-size: 0.95em;
  text-align: left;
  margin: 0 0 1.3em;
}

.work-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 1.5vw, 16px);
  margin: 0 0 0.7em;
  align-items: start; /* don't let grid stretch the squares vertically */
}

.work-details img {
  width: 100%;
  height: auto;
  display: block;
}

/* Two zoomed details share the top row as true squares. */
.work-details .detail-sq {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* The trial-frame photo spans the full width below, in its natural ratio. */
.work-details .detail-wide {
  grid-column: 1 / -1;
}

/* Snellen-style green bar dividing works — echoes the reference bars on a
 * standard eye chart. */
.snellen-bar {
  border: none;
  height: 6px;
  width: min(420px, 65vw);
  margin: 0 auto;
  background: #4a7c59;
  border-radius: 1px;
}

.snellen-bar.is-red {
  background: #8c3a3a;
}

.snellen-bar.is-inset {
  margin-top: calc(var(--section-gap) * 0.4);
  margin-bottom: calc(var(--section-gap) * 0.4);
}

.work-detail-cap {
  margin: 0;
  font-size: 0.78em;
  font-style: italic;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--color-ink) 55%, var(--color-paper));
}

/* ── Bio ───────────────────────────────────────────────────────────── */

.bio-quote {
  margin: 0;
  padding: 0;
  border: none;
  text-align: center;
}

.bio-quote p {
  font-family: var(--display-serif);
  font-style: italic;
  font-size: clamp(1.15em, 2.4vw, 1.55em);
  line-height: 1.55;
  margin: 0 0 1.4em;
}

.bio-sig {
  font-family: var(--display-serif);
  font-style: italic;
  font-size: 1.1em;
  letter-spacing: 0.03em;
  color: color-mix(in srgb, var(--color-ink) 70%, var(--color-paper));
}

.bio-dash {
  margin-right: 0.15em;
}

/* ── Footer ────────────────────────────────────────────────────────── */

.footer {
  padding: clamp(80px, 12vw, 160px) 24px 60px;
  text-align: center;
  font-size: 0.82em;
  color: color-mix(in srgb, var(--color-ink) 55%, var(--color-paper));
}

.footer a {
  text-decoration: none;
  transition: color 0.2s;
}

.footer a:hover { color: var(--color-ink); }

.footer-links {
  font-family: var(--title-face);
  font-size: 1.05em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 2em;
}

.footer-links .sep {
  margin: 0 0.6em;
  opacity: 0.35;
}

.footer-links .icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
}

.mailing-list {
  display: flex;
  justify-content: center;
  border-bottom: 1px solid color-mix(in srgb, var(--color-ink) 25%, var(--color-paper));
  max-width: 18rem;
  margin: 0 auto 2.5em;
  transition: border-color 0.2s;
}

.mailing-list:focus-within {
  border-color: var(--color-accent);
}

.mailing-list input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0.5em 0;
  outline: none;
}

.mailing-list input::placeholder {
  color: color-mix(in srgb, var(--color-ink) 35%, var(--color-paper));
  font-style: italic;
  letter-spacing: 0.02em;
}

.mailing-list button {
  border: 0;
  background: transparent;
  font: inherit;
  color: color-mix(in srgb, var(--color-ink) 40%, var(--color-paper));
  padding: 0.5em 0.4em;
  cursor: pointer;
  transition: color 0.2s;
}

.mailing-list button:hover { color: var(--color-ink); }

.footer-copy {
  margin: 0;
}

/* ── Interactive optics ────────────────────────────────────────────── */

/* Phoropter focus-pull: a button scrubs the clip between its two planes of
 * focus, playing the frames in between. No blur filter — the footage
 * carries its own focus. */
.interlude {
  display: flex;
  justify-content: center;
}

.focuspull {
  margin: 0;
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1em;
  text-align: center;
}

.focuspull-video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  border: 5px solid #c2c3c2;
}

.focuspull-toggle {
  --pull: 0;            /* 0 = far, 1 = near; driven from the video's currentTime */
  --track-w: 64px;
  --knob: 22px;
  --pad: 3px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  cursor: pointer;
  padding: 0.4em 0;
  font-family: var(--title-face);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.8em;
}

.focuspull-label {
  color: var(--color-ink);
  margin-right: 0.3em;
}

.focuspull-side {
  color: color-mix(in srgb, var(--color-ink) 45%, var(--color-paper));
  transition: color 0.25s, opacity 0.25s;
}
/* The side nearest the current plane of focus lights up as the knob arrives. */
.focuspull-side.is-far  { opacity: calc(1 - var(--pull) * 0.65); color: color-mix(in srgb, var(--color-ink) calc((100 - var(--pull) * 55) * 1%), var(--color-paper)); }
.focuspull-side.is-near { opacity: calc(0.35 + var(--pull) * 0.65); color: color-mix(in srgb, var(--color-ink) calc((45 + var(--pull) * 55) * 1%), var(--color-paper)); }

.focuspull-track {
  position: relative;
  width: var(--track-w);
  height: calc(var(--knob) + var(--pad) * 2);
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-ink) 12%, var(--color-paper));
  border: 1px solid var(--color-accent);
  transition: border-color 0.2s, background 0.2s;
}

.focuspull-knob {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  width: var(--knob);
  height: var(--knob);
  border-radius: 50%;
  background: var(--color-accent);
  /* near sits on the LEFT, far on the right: knob rests left at near (--pull 1),
   * slides right toward far as --pull -> 0. */
  transform: translateX(calc((1 - var(--pull)) * (var(--track-w) - var(--knob) - var(--pad) * 2)));
}

.focuspull-toggle:hover .focuspull-track { border-color: var(--color-ink); }
.focuspull-toggle:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; border-radius: 4px; }
.focuspull-toggle[disabled] { cursor: progress; }

.lens-cap {
  margin: 0;
  font-style: italic;
  font-size: 0.85em;
  line-height: 1.45;
  color: color-mix(in srgb, var(--color-ink) 62%, var(--color-paper));
}

/* Self-portrait reveal: a slider swaps between pre-rendered frames blurred
 * with the artwork's true optical PSF (soft pupil), not a CSS gaussian.
 * The wrapper shrink-wraps the frame and is centred by the parent's
 * text-align; sizing comes from the shared `.work-image img` rules. */
.lens-reveal {
  position: relative;
  display: inline-block;
  /* Cap the shrink-to-fit width: an inline-block sizes to its content's
   * intrinsic width (here a 1024px frame) and the child img's max-width:100%
   * is ignored during that intrinsic sizing — so without this the frame blows
   * past the viewport on phones and forces horizontal overflow. */
  max-width: 100%;
  line-height: 0;
}

/* Defocus stack: every frame is a preloaded layer; the slider reveals one by
 * fading in its opacity rather than swapping the <img> src — so the element is
 * never momentarily empty (no black blink). The base .reveal-frame stays put
 * underneath, so an undecoded layer falls back to frame 0, never to background. */
.lens-reveal .reveal-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}

.lens-reveal .reveal-layer.is-active { opacity: 1; }

.lens-control {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6em;
  margin: 1.3em auto 0;
}

.lens-side {
  font-family: var(--title-face);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.8em;
  color: color-mix(in srgb, var(--color-ink) 45%, var(--color-paper));
  transition: color 0.25s, opacity 0.25s;
}

.lens-side.is-sharp { opacity: calc(1 - var(--blur, 0) * 0.55); }
.lens-side.is-blur  { opacity: calc(0.45 + var(--blur, 0) * 0.55); }

.lens-slider {
  -webkit-appearance: none;
  appearance: none;
  width: min(280px, 70vw);
  height: 2px;
  background: color-mix(in srgb, var(--color-ink) 32%, var(--color-paper));
  outline: none;
  cursor: pointer;
}

.lens-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-paper);
  cursor: pointer;
}

.lens-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-paper);
  cursor: pointer;
}

.lens-hint {
  flex-basis: 100%;
  font-size: 0.78em;
  font-style: italic;
  letter-spacing: 0.02em;
  text-align: center;
  color: color-mix(in srgb, var(--color-ink) 55%, var(--color-paper));
}

/* ── Small screens ─────────────────────────────────────────────────── */

@media (max-width: 640px) {
  :root { --section-gap: clamp(72px, 18vw, 140px); }
  .hero { height: 88vh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-video { display: none; }
  .hero { background: #111; }
  .scroll-hint { animation: none; }
}
