/* ==========================================================================
   ryan.bibby.photography
   CSP note: the host's policy is style-src 'self' — no <style> blocks and no
   style="" attributes in the HTML. Per-photo aspect ratios are classes from
   gallery.css; anything dynamic is set from site.js.
   ========================================================================== */

@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Inter Tight";
  src: url("../fonts/inter-tight-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --ink: #0f0e0d;
  --ink-2: #161513;
  --ink-3: #221f1c;
  --line: rgba(236, 230, 220, 0.14);
  --paper: #ece6dc;
  --paper-2: #d3ccc1;
  --paper-dim: #a39b8f;
  --paper-faint: #6f685f;
  --safelight: #e2553f;

  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --max: 1480px;
  --header-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);

  color-scheme: dark;
}

/* ---- base --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
html.is-locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
p { margin: 0; }
::selection { background: var(--safelight); color: var(--ink); }
:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -80px;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.skip:focus { top: 12px; }

.eyebrow {
  margin-bottom: 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.eyebrow__dot {
  display: inline-block;
  position: relative;
  top: -1px;
  margin-right: 0.65em;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--safelight);
  box-shadow: 0 0 14px 1px rgba(226, 85, 63, 0.7);
}

/* ---- header ------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 14, 13, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem 2rem;
  height: var(--header-h);
}
.wordmark {
  margin-right: auto;
  font-family: var(--serif);
  font-size: 1.625rem;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav { display: flex; gap: clamp(1rem, 2.6vw, 2.25rem); font-size: 0.9375rem; }
.site-nav a { color: var(--paper-dim); text-decoration: none; transition: color 0.2s ease; }
.site-nav a:hover { color: var(--paper); }

.family-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--paper-dim);
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.family-link svg { width: 14px; height: 14px; }
.family-link:hover { color: var(--paper); border-color: var(--paper-faint); }
@media (max-width: 700px) { .family-link { display: none; } }

/* ---- hero --------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2.5rem, 6vw, 6.5rem);
  padding-block: clamp(3rem, 7vw, 6.5rem) clamp(4rem, 8vw, 7.5rem);
}
.hero__title {
  margin: 0 0 1.75rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 6.3vw, 6.4rem);
  line-height: 0.98;
  letter-spacing: -0.018em;
  text-wrap: balance;
}
.hero__title em { font-style: italic; color: var(--safelight); }
.hero__lede {
  max-width: 34rem;
  margin-bottom: 2.25rem;
  font-size: clamp(1.0625rem, 1.25vw, 1.1875rem);
  color: var(--paper-dim);
  text-wrap: pretty;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  height: 48px;
  padding: 0 1.4rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.btn svg { width: 16px; height: 16px; transition: transform 0.35s var(--ease); }
.btn--solid { background: var(--paper); color: var(--ink); }
.btn--solid:hover { background: #fff; }
.btn--solid:hover svg { transform: translateY(2px); }
.btn--ghost { border: 1px solid var(--line); }
.btn--ghost:hover { border-color: var(--paper-dim); }

.hero__prints {
  display: grid;
  grid-template-columns: 4fr 3fr;
  gap: clamp(8px, 1vw, 14px);
}
.print {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: 2px;
  background: var(--ink-3);
}
/* The squares set the row heights; the tall print spans both rows and its
   image is taken out of flow so its own intrinsic height can't stretch them. */
.print--tall { grid-row: span 2; }
.print--square { aspect-ratio: 1; }
.print img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

@media (prefers-reduced-motion: no-preference) {
  .hero__text > *, .print {
    animation: rise 0.9s var(--ease) both;
  }
  .hero__text > :nth-child(2) { animation-delay: 0.06s; }
  .hero__text > :nth-child(3) { animation-delay: 0.12s; }
  .hero__text > :nth-child(4) { animation-delay: 0.18s; }
  .print:nth-child(1) { animation-delay: 0.15s; }
  .print:nth-child(2) { animation-delay: 0.27s; }
  .print:nth-child(3) { animation-delay: 0.39s; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.hero--text-only { grid-template-columns: minmax(0, 52rem); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-bottom: 1rem; }
}

/* ---- sections ----------------------------------------------------------- */

.section { padding-block: clamp(3.5rem, 8vw, 7rem); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem 2rem;
  margin-bottom: clamp(1.75rem, 3vw, 2.75rem);
  padding-top: clamp(1.5rem, 3vw, 2.5rem);
  border-top: 1px solid var(--line);
}
.section-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.75rem, 5.5vw, 4.75rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

/* ---- filters ------------------------------------------------------------ */

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--paper-dim);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.chip:hover { color: var(--paper); border-color: var(--paper-faint); }
.chip[aria-pressed="true"] { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.chip__n { font-family: var(--mono); font-size: 0.6875rem; opacity: 0.7; }

/* ---- justified gallery ---------------------------------------------------
   Each item's flex-basis and flex-grow are both proportional to its aspect
   ratio (--ar, from the ar-NNN class in gallery.css), so every item in a row shares one height
   and rows fill the width exactly. The ::after spacer soaks up the leftover
   space on the last row so it keeps the natural height instead of blowing up.
   ------------------------------------------------------------------------- */

.gallery {
  --row: clamp(140px, 23vw, 340px);
  --gap: clamp(6px, 0.8vw, 12px);
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
.gallery::after { content: ""; flex-grow: 999999; }

.ph {
  --ar: 1;
  position: relative;
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row));
  min-width: 0;
}
.ph__link {
  position: relative;
  display: block;
  aspect-ratio: var(--ar);
  overflow: hidden;
  border-radius: 2px;
  background: var(--ink-3);
  cursor: zoom-in;
}
.ph__link picture, .ph__link img { width: 100%; height: 100%; }
.ph__link img {
  object-fit: cover;
  transition: transform 1.1s var(--ease), opacity 0.7s ease;
}
.js .ph__link img { opacity: 0; }
.js .ph__link img.is-loaded { opacity: 1; }

.ph__meta {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.5rem 0.75rem 0.6rem;
  overflow: hidden;
  background: linear-gradient(to bottom, transparent, rgba(10, 9, 8, 0.72));
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.6875rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s var(--ease);
  pointer-events: none;
}
@media (hover: hover) {
  .ph__link:hover img { transform: scale(1.035); }
  .ph__link:hover .ph__meta { opacity: 1; transform: none; }
}
.ph__link:focus-visible { outline-offset: 2px; }
.ph__link:focus-visible .ph__meta { opacity: 1; transform: none; }

@media (max-width: 700px) {
  .ph__meta { display: none; }
}

/* ---- about -------------------------------------------------------------- */

.about {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: start;
  gap: clamp(2.5rem, 6vw, 7rem);
}
.about__portrait {
  position: sticky;
  top: calc(var(--header-h) + 32px);
  margin: 0;
}
.about__portrait img {
  width: 100%;
  height: auto;
  border-radius: 2px;
  background: var(--ink-3);
}
.about__portrait figcaption {
  margin-top: 0.85rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--paper-dim);
}
.about__portrait figcaption a {
  color: var(--paper);
  text-decoration-color: var(--paper-faint);
  text-underline-offset: 3px;
}
.about__portrait figcaption a:hover { text-decoration-color: var(--paper); }

.about__body .section-title { margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
.about__body { padding-top: clamp(0rem, 2vw, 2rem); }

.prose { max-width: 40rem; }
.prose p { margin-bottom: 1.2em; color: var(--paper-2); text-wrap: pretty; }
.prose p:first-child {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.3vw, 2rem);
  line-height: 1.28;
  color: var(--paper);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2rem;
  max-width: 40rem;
  margin: 2.5rem 0 0;
  border-top: 1px solid var(--line);
}
.facts > div { padding-block: 1.05rem; border-bottom: 1px solid var(--line); }
.facts dt {
  margin-bottom: 0.3rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.facts dd { margin: 0; font-size: 0.9375rem; }

@media (max-width: 860px) {
  .about { grid-template-columns: 1fr; }
  .about__portrait { position: static; max-width: 440px; }
}
@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; }
}

/* ---- contact ------------------------------------------------------------ */

.contact__inner { padding-top: clamp(1.5rem, 3vw, 2.5rem); border-top: 1px solid var(--line); }
.contact__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.5rem, 10vw, 9rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
}
.contact__mail {
  display: inline-block;
  margin-top: 0.4rem;
  padding-bottom: 0.1em;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(2.1rem, 6vw, 5.25rem);
  line-height: 1.1;
  color: var(--safelight);
  text-decoration: none;
  overflow-wrap: anywhere;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat;
  transition: background-size 0.6s var(--ease);
}
.contact__mail:hover, .contact__mail:focus-visible { background-size: 100% 2px; }
.contact__note { margin-top: 1.5rem; max-width: 30rem; color: var(--paper-dim); }

/* ---- footer ------------------------------------------------------------- */

.site-footer {
  padding-block: 1.75rem 2.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--paper-dim);
}
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }
.site-footer a { color: var(--paper); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- reveal on scroll (only when JS is running) ------------------------- */

@media screen and (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.9s ease, transform 0.9s var(--ease); }
  .js .reveal.is-in { opacity: 1; transform: none; }
}

/* ---- lightbox ----------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(9, 8, 7, 0.97);
  color: var(--paper);
  overflow: hidden;
}
.lightbox::backdrop { background: transparent; }
.lightbox[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] { animation: fade-in 0.3s ease; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* One definite grid cell, so the image's max-width/max-height of 100% resolve
   against the space between the top edge and the bar. */
.lightbox__stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  padding: clamp(12px, 3vw, 40px) clamp(12px, 4vw, 72px) 8px;
  touch-action: pan-y pinch-zoom;
}
.lightbox__stage picture { display: contents; }
.lightbox__img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.28s ease;
}
.lightbox__stage.is-loading .lightbox__img { opacity: 0.25; }
.lightbox__stage.is-loading::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 28px; height: 28px;
  margin: -14px 0 0 -14px;
  border: 2px solid var(--line);
  border-top-color: var(--paper);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox__bar {
  display: grid;
  grid-template-columns: minmax(4.5rem, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 14px clamp(12px, 3vw, 32px) max(14px, env(safe-area-inset-bottom));
}
.lightbox__count, .lightbox__caption {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--paper-dim);
}
.lightbox__caption {
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lightbox__controls { display: flex; gap: 0.4rem; }
.lb-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.lb-btn:hover { background: rgba(236, 230, 220, 0.08); border-color: var(--paper-faint); }
.lb-btn svg { width: 18px; height: 18px; }

@media (max-width: 560px) {
  .lightbox__bar { grid-template-columns: auto auto; }
  .lightbox__caption { grid-column: 1 / -1; grid-row: 1; white-space: normal; }
  .lightbox__controls { justify-self: end; }
}

/* ---- 404 ----------------------------------------------------------------- */

.notfound {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: clamp(2.5rem, 6vw, 6rem);
  min-height: calc(100vh - var(--header-h) - 88px);
  min-height: calc(100svh - var(--header-h) - 88px);
  padding-block: clamp(2rem, 4vw, 3.5rem);
}
.notfound--text-only { grid-template-columns: minmax(0, 52rem); }
.notfound__title {
  margin: 0 0 1.75rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.5rem, 8vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.notfound__title em { font-style: italic; color: var(--safelight); }

/* Sized by the viewport height too, so header, photo and footer fit one screen. */
.notfound__print { justify-self: end; width: min(100%, 28rem, 48vh); margin: 0; }
.notfound__frame {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 2px;
  background: var(--ink-3);
}
.notfound__frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}
.notfound__print figcaption {
  margin-top: 0.85rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--paper-dim);
}

/* The photo starts out of focus and racks in, hunting once like autofocus. */
@media (prefers-reduced-motion: no-preference) {
  .notfound__text > * { animation: rise 0.9s var(--ease) both; }
  .notfound__text > :nth-child(2) { animation-delay: 0.06s; }
  .notfound__text > :nth-child(3) { animation-delay: 0.12s; }
  .notfound__text > :nth-child(4) { animation-delay: 0.18s; }
  .notfound__frame img { animation: rack-focus 3.2s cubic-bezier(0.25, 0.6, 0.2, 1) 0.35s both; }
}
@keyframes rack-focus {
  0%   { filter: blur(24px) brightness(0.9); transform: scale(1.1); }
  45%  { filter: blur(2px); transform: scale(1.02); }
  60%  { filter: blur(7px); }
  80%  { filter: blur(0.5px); }
  100% { filter: blur(0); transform: none; }
}

@media (max-width: 860px) {
  .notfound { grid-template-columns: 1fr; min-height: 0; }
  .notfound__print { justify-self: start; width: min(100%, 22rem); }
}

/* ---- "Show more" ---------------------------------------------------------
   A checkbox and its <label> under the gallery; :has() lets the ticked box
   reveal the .ph--more photos above it. No JavaScript needed, nothing reflows
   on load, and the checkbox sits right under its button so ticking it never
   scrolls the page. While a filter is active (.is-filtered, set by site.js)
   every matching photo shows, featured or not. */

.work:not(:has(.more-toggle:checked)) .gallery:not(.is-filtered) .ph--more { display: none; }

.more {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: clamp(1.75rem, 3vw, 2.75rem);
}
.more:has(.more-toggle:checked),
.gallery.is-filtered ~ .more { display: none; }

/* A fade over the bottom of the last row hints that the gallery carries on. */
.more::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + clamp(1.75rem, 3vw, 2.75rem));
  height: min(140px, 30vw);
  background: linear-gradient(to bottom, rgba(15, 14, 13, 0), var(--ink));
  pointer-events: none;
}

.more-toggle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.more__button { cursor: pointer; user-select: none; padding-inline: 1.6rem; }
.more__button:hover svg { transform: rotate(90deg); }
.more-toggle:focus-visible + .more__button { outline: 2px solid var(--paper); outline-offset: 3px; }
