/* Project pages: same dark, textured stage as the home page, calm reading column */
:root {
  --font-family-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --ease-fluid: cubic-bezier(.22, 1, .36, 1);
}
.p-gallery figure:first-of-type img { view-transition-name: project-cover; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--color-text-primary);
  font-family: var(--font-family-body);
  -webkit-font-smoothing: antialiased;
}
body > :not(dialog) { position: relative; z-index: 1; }

/* ---------- Quiet grain on the background ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 256px 256px;
}

/* ---------- Background with depth: uneven tone, soft light, vignette, living grain ---------- */
body {
  background-color: var(--color-bg-page);
  background-image:
    /* edges fall off into darkness */
    radial-gradient(130% 95% at 50% 42%, transparent 45%, color-mix(in srgb, var(--ink-950) 70%, transparent) 100%),
    /* faint light pooled behind the name */
    radial-gradient(55% 45% at 50% 42%, color-mix(in srgb, var(--paper-50) 3%, transparent), transparent 70%),
    /* large, slow mottling like uneven paper or film density */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1024' height='1024'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.004' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  .9 0 0 0 -.25'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>");
  background-size: auto, auto, 1024px 1024px;
  background-attachment: fixed;
}

/* fine grain: more contrast so specks read light and dark, shifting slowly like film */
body::before {
  inset: -50%;
  opacity: .08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncR type='linear' slope='2' intercept='-.8'/><feFuncG type='linear' slope='2' intercept='-.8'/><feFuncB type='linear' slope='2' intercept='-.8'/></feComponentTransfer></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.6s steps(1) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -4%); }
  60%  { transform: translate(-4%, -1%); }
  80%  { transform: translate(3%, 3%); }
}

/* ---------- Top bar ---------- */
.p-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: var(--spacing-3);
  background: color-mix(in srgb, var(--color-bg-page) 84%, transparent);
  -webkit-backdrop-filter: blur(var(--spacing-2));
  backdrop-filter: blur(var(--spacing-2));
}
.p-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-1);
  min-height: var(--sizing-control-sm);
  padding-inline: var(--spacing-1);
  border-radius: var(--radius-full);
  color: var(--color-text-primary);
  text-decoration: none;
  font: var(--font-weight-medium) 14px/16px var(--font-family-body);
  transition: background var(--dur-fast) var(--ease-fluid);
}
.p-link:last-child { justify-self: end; }
.p-link:hover { background: color-mix(in srgb, var(--color-text-primary) 8%, transparent); }
.p-link:focus-visible, .p-logo:focus-visible, .p-next:focus-visible, .p-out:focus-visible {
  outline: var(--border-focus) solid var(--color-focus-ring);
  outline-offset: var(--spacing-half);
}
.dot {
  width: var(--spacing-1);
  height: var(--spacing-1);
  border-radius: var(--radius-full);
  background: var(--color-signal);
  animation: pulse 2s var(--ease-fluid) infinite;
}
@keyframes pulse { 50% { opacity: .4; } }
.cta-short { display: none; }
.p-logo {
  color: var(--color-text-primary);
  text-decoration: none;
  font: var(--font-weight-bold) 24px/32px "Clash Display", sans-serif;
  letter-spacing: 0;
}
.k-a { position: relative; display: inline-block; line-height: 1; margin-right: 0.02em; }
.k-a::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.03em;
  width: 0.35em;
  height: 0.1em;
  background: currentColor;
  transform: translateX(-50%);
}
.k-r { margin-right: 0.01em; }
.k-o { margin-right: 0.005em; }

/* ---------- Content column ---------- */
.p-main {
  --col: 960px;
  width: min(var(--col), calc(100% - var(--spacing-6)));
  margin: 0 auto;
  padding: var(--spacing-8) 0 var(--spacing-12);
  display: grid;
  gap: var(--spacing-8);
}
.p-wide { --col: 1200px; }

.p-head {
  display: grid;
  gap: var(--spacing-2);
  justify-items: center;
  text-align: center;
  animation: rise .9s var(--ease-fluid) both;
}
.p-kicker {
  margin: 0;
  color: var(--color-text-muted);
  font: var(--font-weight-medium) 12px/16px var(--font-family-body);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.p-title {
  margin: 0;
  font: var(--font-weight-semibold) clamp(40px, 7vw, 88px)/1 "Clash Display", sans-serif;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.p-sub { margin: 0; color: var(--color-text-muted); font: 400 18px/24px var(--font-family-body); }

.p-cover { margin: 0; animation: rise 1.1s var(--ease-fluid) .12s both; }
.p-cover img, .p-gallery img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-text-primary) 4%, transparent);
}

.p-text {
  width: min(640px, 100%);
  margin: 0 auto;
  display: grid;
  gap: var(--spacing-2);
  font: 400 18px/28px var(--font-family-body);
  animation: rise 1.1s var(--ease-fluid) .24s both;
}
.p-text p { margin: 0; }
.p-text .p-meta { color: var(--color-text-muted); font-size: 14px; line-height: 20px; }
.p-text .p-meta:first-of-type { margin-top: var(--spacing-1); }
.p-out {
  justify-self: start;
  color: var(--color-text-primary);
  font-size: 16px;
  line-height: 24px;
  text-underline-offset: var(--spacing-half);
}

.p-gallery figure { margin: 0; display: grid; gap: var(--spacing-1); }
.p-gallery figcaption { color: var(--color-text-muted); font: 400 14px/20px var(--font-family-body); }

/* ---------- Next project ---------- */
.p-next {
  display: grid;
  gap: var(--spacing-1);
  justify-items: center;
  padding: var(--spacing-8) 0 0;
  border-top: var(--border-hairline) solid color-mix(in srgb, var(--color-text-primary) 12%, transparent);
  color: var(--color-text-primary);
  text-decoration: none;
  text-align: center;
}
.p-next-title {
  font: var(--font-weight-semibold) clamp(32px, 5vw, 56px)/1.15 "Clash Display", sans-serif;
  transition: opacity var(--dur-base) var(--ease-fluid);
}
.p-next:hover .p-next-title { opacity: .7; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(var(--spacing-3)); filter: blur(var(--spacing-1)); } }
.reveal { opacity: 0; transform: translateY(var(--spacing-4)); transition: opacity 1s var(--ease-fluid), transform 1s var(--ease-fluid); }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 767.98px) {
  .p-top { padding: var(--spacing-2); }
  .p-logo { font-size: 16px; line-height: 24px; }
  .cta-long { display: none; }
  .cta-short { display: inline; }
  .p-main { width: calc(100% - var(--spacing-4)); padding-top: var(--spacing-4); gap: var(--spacing-6); }
  .p-text { font-size: 16px; line-height: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Photos: one horizontal strip, scroll or drag sideways ---------- */
html, body { overflow-x: clip; }
.p-gallery {
  --edge: max(var(--spacing-3), calc((100vw - 960px) / 2));
  width: 100vw;
  justify-self: center;
  display: flex;
  gap: var(--spacing-2);
  overflow-x: auto;
  overflow-y: hidden;
  padding-inline: var(--edge);
  scroll-padding-inline: var(--edge);
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: grab;
}
.p-gallery::-webkit-scrollbar { display: none; }
.p-gallery.dragging { cursor: grabbing; scroll-snap-type: none; }
.p-gallery.dragging .p-thumb { pointer-events: none; }
.p-gallery figure { flex: none; margin: 0; display: grid; gap: var(--spacing-1); scroll-snap-align: start; }
.p-gallery figcaption { width: 0; min-width: 100%; color: var(--color-text-muted); font: 400 14px/20px var(--font-family-body); }
.p-thumb {
  display: block;
  height: clamp(320px, 64vh, 720px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: color-mix(in srgb, var(--color-text-primary) 4%, transparent);
  cursor: zoom-in;
}
.p-gallery img {
  display: block;
  height: 100%;
  width: auto;
  border-radius: 0;
  -webkit-user-drag: none;
  user-select: none;
  transition: transform .6s var(--ease-fluid), opacity var(--dur-base) var(--ease-fluid);
}
.p-thumb:hover img { transform: scale(1.02); }
.p-thumb:focus-visible { outline: var(--border-focus) solid var(--color-focus-ring); outline-offset: calc(-1 * var(--border-focus)); }
.p-gallery img.lifted { opacity: 0; }

.p-strip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: calc(-1 * var(--spacing-5));
}
.p-count { color: var(--color-text-muted); font: 400 14px/20px var(--font-family-body); font-variant-numeric: tabular-nums; }
.p-strip-btns { display: flex; gap: var(--spacing-1); }
.s-btn {
  display: grid;
  place-items: center;
  width: var(--sizing-control-md);
  height: var(--sizing-control-md);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-text-primary) 8%, transparent);
  color: var(--color-text-primary);
  font: 400 16px/24px var(--font-family-body);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-fluid), opacity var(--dur-fast) var(--ease-fluid);
}
.s-btn:hover { background: color-mix(in srgb, var(--color-text-primary) 16%, transparent); }
.s-btn:disabled { opacity: .3; cursor: default; }
.s-btn:focus-visible { outline: var(--border-focus) solid var(--color-focus-ring); outline-offset: var(--spacing-half); }

/* the enlarged view */
.viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--spacing-8) var(--spacing-10);
  border: 0;
  background: transparent;
  color: var(--color-text-primary);
  overflow: hidden;
}
.viewer[open] { display: grid; place-items: center; }
.viewer::backdrop {
  background: color-mix(in srgb, var(--ink-950) 92%, transparent);
  -webkit-backdrop-filter: blur(var(--spacing-1));
  backdrop-filter: blur(var(--spacing-1));
}
.viewer:focus { outline: none; }
.v-fig { margin: 0; display: grid; gap: var(--spacing-2); justify-items: center; max-height: 100%; min-height: 0; }
#v-img {
  display: block;
  max-width: calc(100vw - var(--spacing-10) * 2);
  max-height: calc(100dvh - var(--spacing-16) - var(--spacing-6));
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  transform-origin: 0 0;
  cursor: default;
}
#v-cap { color: var(--color-text-muted); font: 400 14px/20px var(--font-family-body); text-align: center; min-height: var(--spacing-3); }
.v-btn {
  position: fixed;
  display: grid;
  place-items: center;
  width: var(--sizing-control-md);
  height: var(--sizing-control-md);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-text-primary) 8%, transparent);
  color: var(--color-text-primary);
  font: 400 16px/24px var(--font-family-body);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-fluid);
}
.v-btn:hover { background: color-mix(in srgb, var(--color-text-primary) 16%, transparent); }
.v-btn:focus-visible { outline: var(--border-focus) solid var(--color-focus-ring); outline-offset: var(--spacing-half); }
.v-close { top: var(--spacing-3); right: var(--spacing-3); }
.v-nav { top: 50%; transform: translateY(-50%); }
.v-prev { left: var(--spacing-3); }
.v-next { right: var(--spacing-3); }

@media (max-width: 767.98px) {
  .p-gallery { --edge: var(--spacing-2); gap: var(--spacing-1); scroll-snap-type: x mandatory; }
  .p-thumb { height: 56vh; }
  .p-strip-btns { display: none; }
  .p-strip-bar { margin-top: calc(-1 * var(--spacing-4)); }
  .viewer { padding: var(--spacing-8) var(--spacing-2); }
  #v-img { max-width: calc(100vw - var(--spacing-4)); max-height: calc(100dvh - var(--spacing-16) - var(--spacing-6)); }
  .v-nav { top: auto; bottom: var(--spacing-3); transform: none; }
  .v-prev { left: var(--spacing-2); }
  .v-next { right: var(--spacing-2); }
  .v-close { top: var(--spacing-2); right: var(--spacing-2); }
}
/* the column stays content-wide; only the photo strip runs edge to edge */
.p-main { grid-template-columns: minmax(0, 1fr); }

/* ---------- Description: the first card of the strip ---------- */
.p-intro {
  flex: none;
  height: clamp(320px, 64vh, 720px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--spacing-2);
  padding-right: var(--spacing-3);
  font: 400 16px/24px var(--font-family-body);
  scrollbar-width: none;
  cursor: auto;
}
.p-intro::-webkit-scrollbar { display: none; }
.p-intro p { margin: 0; }
.p-intro .p-meta { color: var(--color-text-muted); font-size: 14px; line-height: 20px; }
.p-intro .p-meta:first-of-type { margin-top: var(--spacing-1); }
.p-intro .p-out { align-self: flex-start; }
.p-intro-s { width: 360px; }
.p-intro-m { width: 440px; }
.p-intro-l { width: 560px; }
@media (max-width: 767.98px) {
  .p-intro { height: 56vh; width: calc(100vw - var(--spacing-6)); scroll-snap-align: start; }
}

/* ---------- Home top bar + panels on project pages ---------- */
/* styles.css locks the home page to one screen; project pages scroll */
html, body { height: auto; }
body { overflow: visible; overflow-x: clip; }
.topbar .top-logo {
  opacity: 1;
  filter: none;
  transform: translate(-50%, 0);
  pointer-events: auto;
  color: var(--color-text-primary);
  text-decoration: none;
}
.topbar .top-logo:focus-visible { outline: var(--border-focus) solid var(--color-focus-ring); outline-offset: var(--spacing-half); border-radius: var(--radius-md); }

/* photos sit on the bottom edge: the title takes the spare height, nothing follows the strip */
.p-main {
  min-height: 100dvh;
  grid-template-rows: 1fr auto;
  padding-top: calc(var(--spacing-10) + var(--spacing-8));
  padding-bottom: 0;
}
.p-head { align-content: start; }
.p-gallery { padding-bottom: 0; }
@media (max-width: 767.98px) {
  .p-main { padding-top: calc(var(--spacing-8) + var(--spacing-4)); }
}
/* content scrolls under the bar here, so it gets a soft frosted background */
.topbar {
  background: color-mix(in srgb, var(--color-bg-page) 84%, transparent);
  -webkit-backdrop-filter: blur(var(--spacing-2));
  backdrop-filter: blur(var(--spacing-2));
}

/* description reads from the top of the strip */
.p-intro { justify-content: flex-start; }
/* square photos everywhere */
.p-thumb, .p-gallery img, #v-img { border-radius: 0; }

/* ---------- One screen: no page scroll, photos scale to the height that is left ---------- */
html, body { height: 100%; }
body { overflow: hidden; }
.p-main {
  box-sizing: border-box;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--spacing-5);
  padding-bottom: var(--spacing-3);
}
.p-gallery { min-height: 0; height: 100%; }
.p-gallery figure { height: 100%; grid-template-rows: minmax(0, 1fr); }
.p-thumb, .p-intro { height: 100%; }
/* the title stays on one line; project.js shrinks it when it would not fit */
.p-title { white-space: nowrap; max-width: 100%; }
@media (max-width: 767.98px) {
  .p-main { gap: var(--spacing-3); padding-bottom: var(--spacing-2); }
  .p-thumb, .p-intro { height: 100%; }
}
/* a photo is never wider than the screen either: it shrinks as a whole, keeping its shape */
.p-gallery figure { height: auto; align-self: flex-start; }
.p-thumb { height: auto; }
.p-gallery img {
  height: var(--strip-h, 56vh);
  max-width: calc(100vw - 2 * var(--edge));
  width: auto;
  object-fit: contain;
}
