/* Family photo library.
   Type steps, spacing tokens, radius values and the motion curve come from the landing design system.
   Motion level: Light (hover/press, view fade, the slider). Only transform and opacity move,
   plus clip-path on the slider's black-and-white layer. */

:root {
  /* spacing tokens (landing B2) */
  --s-25: 2px;  --s-50: 4px;  --s-75: 8px;  --s-100: 12px; --s-200: 16px; --s-300: 24px;
  --s-400: 32px; --s-500: 40px; --s-600: 48px; --s-700: 64px; --s-800: 80px; --s-900: 96px;

  /* motion (landing B7) */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-move: 500ms;
  --t-fade: 300ms;

  /* light: album paper */
  --bg: #F7F4EE;
  --mat: #E9E4D8;
  --ink: #1B1915;
  --muted: #645E52;
  --line: #DAD3C4;
  --accent: #8A4F1D;
  --btn-bg: #1B1915;
  --btn-bg-hover: #3A342B;
  --btn-ink: #F7F4EE;
  --head-from: #000000;
  --head-to: #666666;

  --gutter: var(--s-200);
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131209;
    --mat: #1F1F1F;
    --ink: #EDE9E0;
    --muted: #A8A294;
    --line: #313131;
    --accent: #DBA862;
    --btn-bg: #EDE9E0;
    --btn-bg-hover: #FFFFFF;
    --btn-ink: #131209;
    --head-from: #FFFFFF;
    --head-to: #9B9B9B;
  }
}

@media (min-width: 640px)  { :root { --gutter: var(--s-300); } }
@media (min-width: 1024px) { :root { --gutter: var(--s-500); } }

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 400;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
h1, h2, p, figure, ul { margin: 0; }
h1, h2 { text-wrap: balance; }
p, figcaption { text-wrap: pretty; }
img { max-width: 100%; }
a { color: inherit; }
main:focus, h1:focus { outline: none; }

/* ---------- named text styles (landing B1) ---------- */
.heading-2 { font-size: 3rem;     line-height: 1;       font-weight: 600; letter-spacing: -0.02em; }
.heading-3 { font-size: 2.25rem;  line-height: 2.5rem;  font-weight: 600; letter-spacing: -0.02em; }
.heading-4 { font-size: 1.875rem; line-height: 2.25rem; font-weight: 600; letter-spacing: -0.015em; }
.title-3   { font-size: 1rem;     line-height: 1.5rem;  font-weight: 500; }
.title-4   { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; }
.body-3    { font-size: 1rem;     line-height: 1.5rem;  font-weight: 400; }
.button-lg { font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; }
.button-sm { font-size: 0.875rem; line-height: 1.25rem; font-weight: 600; }
.caption-1 { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; }
.caption-2 { font-size: 0.875rem; line-height: 1.25rem; font-weight: 400; }
.caption-3 { font-size: 0.75rem;  line-height: 1rem;    font-weight: 600; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.sprite { position: absolute; }
.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---------- shared bits ---------- */
.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.skip {
  position: absolute; left: var(--s-200); top: var(--s-200); z-index: 10;
  padding: var(--s-75) var(--s-100); border-radius: 8px;
  background: var(--btn-bg); color: var(--btn-ink); text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-75);
  min-height: 48px; padding: var(--s-75) var(--s-200);
  border-radius: 8px; border: 0;
  background: var(--btn-bg); color: var(--btn-ink);
  text-decoration: none; cursor: pointer;
  transition: background-color var(--t-fade) var(--ease), transform var(--t-fade) var(--ease);
}
.btn:active { transform: scale(0.98); }
@media (hover: hover) { .btn:hover { background: var(--btn-bg-hover); } }

.notice {
  margin-top: var(--s-400); padding: var(--s-200); border-radius: 8px;
  border: 1px solid var(--line); background: var(--mat); max-width: 680px;
}

/* view change: a plain fade. Visible by default, so nothing depends on it firing. */
@keyframes view-in { from { opacity: 0; } to { opacity: 1; } }
.view-enter { animation: view-in var(--t-fade) var(--ease) both; }

/* ---------- 1. library ---------- */
.masthead { padding-block: var(--s-600) var(--s-400); }
.masthead-title {
  max-width: 680px;
  color: var(--head-from);
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .masthead-title {
    width: fit-content;
    background: linear-gradient(90deg, var(--head-from), var(--head-to));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
  }
}
@media (forced-colors: active) {
  .masthead-title { background: none; -webkit-text-fill-color: currentColor; color: CanvasText; }
}
.masthead-lede { max-width: 680px; margin-top: var(--s-200); }
.masthead-note { max-width: 680px; margin-top: var(--s-100); color: var(--muted); }

/* Justified rows: every photo keeps its own shape, each row lines up edge to edge.
   --r is the picture's width / height, set per item. */
.grid {
  --row-h: 96px;
  display: flex; flex-wrap: wrap;
  gap: var(--s-300) var(--s-100);
  list-style: none; padding: 0;
  padding-bottom: var(--s-700);
}
.grid > li {
  flex: var(--r) 1 calc(var(--r) * var(--row-h));
  min-width: 0; max-width: 100%;
}
.grid::after { content: ""; flex: 1000 1 0px; }

@media (min-width: 640px)  { .grid { --row-h: 150px; gap: var(--s-400) var(--s-200); } }
@media (min-width: 1024px) { .grid { --row-h: 190px; gap: var(--s-500) var(--s-300); } }
@media (min-width: 1280px) { .grid { --row-h: 220px; } }

.card { display: block; text-decoration: none; border-radius: 4px; }
.frame {
  display: block; position: relative; overflow: hidden;
  aspect-ratio: var(--r);
  background: var(--mat); border-radius: 4px;
  transition: transform var(--t-fade) var(--ease);
}
.frame img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
  transition: opacity var(--t-fade) var(--ease), transform var(--t-move) var(--ease);
}
.frame img.is-loaded { opacity: 1; }
.card-cap { display: block; margin-top: var(--s-75); }
.card-title { display: block; transition: color var(--t-fade) var(--ease); text-wrap: balance; }
.card-year { display: block; color: var(--muted); }
.card:active .frame { transform: scale(0.98); }
@media (hover: hover) {
  .card:hover .card-title { color: var(--accent); }
  .card:hover .frame img.is-loaded { transform: scale(1.03); }
}
@media (min-width: 1024px) {
  .card-title { font-size: 1rem; line-height: 1.5rem; }  /* Title 3 */
  .card-cap { margin-top: var(--s-100); }
}

/* ---------- 2. one photo ---------- */
.photo-top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-200);
  padding-top: var(--s-200); min-height: 44px;
}
.back {
  display: inline-flex; align-items: center; gap: var(--s-75);
  min-height: 44px; padding-right: var(--s-75);
  text-decoration: none; border-radius: 8px;
  transition: color var(--t-fade) var(--ease);
}
.back .icon { transition: transform var(--t-fade) var(--ease); }
@media (hover: hover) {
  .back:hover { color: var(--accent); }
  .back:hover .icon { transform: translateX(-2px); }
}
.pager { display: inline-flex; align-items: center; gap: var(--s-50); }
.pager-count { color: var(--muted); min-width: 4.5em; text-align: center; font-variant-numeric: tabular-nums; }
.pager-btn {
  display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 8px; border: 1px solid var(--line);
  text-decoration: none; cursor: pointer;
  transition: background-color var(--t-fade) var(--ease), color var(--t-fade) var(--ease),
              opacity var(--t-fade) var(--ease), transform var(--t-fade) var(--ease);
}
.pager-btn:active { transform: scale(0.96); }
@media (hover: hover) { .pager-btn[href]:hover { background: var(--mat); color: var(--accent); } }
.pager-btn[aria-disabled="true"] { opacity: 0.35; cursor: default; pointer-events: none; }

.photo-head { padding-block: var(--s-300); text-align: center; }
.photo-title { margin-inline: auto; max-width: 680px; }
.photo-year { color: var(--muted); margin-top: var(--s-50); }

/* A picture box that never jumps: shape comes from --ratio (width / height), set per photo.
   --room is how much of the screen height a picture may take. */
.shot {
  position: relative; display: block; overflow: hidden;
  width: min(100%, max(240px, calc(var(--room, 80svh) * var(--ratio))));
  aspect-ratio: var(--ratio);
  background: var(--mat); border-radius: 4px;
}
.shot img {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  opacity: 0; transition: opacity var(--t-fade) var(--ease);
}
.shot img.is-loaded { opacity: 1; }

.stage { --room: calc(100svh - 264px); }
.stage .shot { margin-inline: auto; }

/* (a) compare slider. --pos is 0 to 100: how far across the divider sits.
   Black and white is the top layer, clipped on its right side; nothing is ever resized. */
.compare {
  --pos: 50;
  touch-action: pan-y;          /* up/down swipes still scroll the page; sideways drags move the divider */
  cursor: ew-resize;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.compare img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; pointer-events: none; }
.compare .compare-bw { clip-path: inset(0 calc(100% - var(--pos) * 1%) 0 0); }
.compare-range {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; pointer-events: none; cursor: inherit;
}
/* A full-size layer that slides sideways; its right edge is the divider. Transform only. */
.compare-line {
  position: absolute; inset: 0; pointer-events: none;
  transform: translate3d(calc((var(--pos) - 100) * 1%), 0, 0);
  opacity: 0; transition: opacity var(--t-fade) var(--ease);
}
.compare.is-ready .compare-line { opacity: 1; }
.compare-line::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: -1px; width: 2px;
  background: #FFFFFF; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
}
.compare-handle {
  position: absolute; top: 50%; right: 0; width: 48px; height: 48px;
  margin: -24px -24px 0 0;
  display: grid; grid-auto-flow: column; place-items: center; place-content: center;
  border-radius: 9999px; background: #FFFFFF; color: #1B1915;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.28);
  transition: transform var(--t-fade) var(--ease);
}
.compare-handle .icon { width: 16px; height: 16px; margin-inline: -1px; }
.compare.is-dragging .compare-handle { transform: scale(0.94); }
.compare-range:focus-visible ~ .compare-line .compare-handle { outline: 3px solid var(--accent); outline-offset: 3px; }
.compare:has(.compare-range:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }
/* A tap or click glides the divider to that spot; a drag follows the finger with no lag. */
.compare.is-gliding .compare-bw { transition: clip-path var(--t-fade) var(--ease), opacity var(--t-fade) var(--ease); }
.compare.is-gliding .compare-line { transition: transform var(--t-fade) var(--ease), opacity var(--t-fade) var(--ease); }

.compare-legend {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; gap: var(--s-200);
  width: min(100%, max(240px, calc(var(--room) * var(--ratio))));
  margin: var(--s-75) auto 0; color: var(--ink);
  container-type: inline-size; white-space: nowrap;
}
.compare-legend > :last-child { text-align: right; grid-column: 3; }
.compare-hint { color: var(--muted); text-align: center; display: none; }
@container (min-width: 520px) { .compare-hint { display: block; } }   /* only where the picture is wide enough */

/* (b) and (c) */
.pair { display: grid; gap: var(--s-500); margin-top: var(--s-600); }
.solo { min-width: 0; --room: 80svh; }
.solo-label { margin-bottom: var(--s-75); }
@media (min-width: 900px) {
  .pair { grid-template-columns: 1fr 1fr; gap: var(--s-400); margin-top: var(--s-700); align-items: start; }
}
.download { margin-top: var(--s-200); }
.download-note { margin-top: var(--s-100); color: var(--muted); max-width: 44ch; }

/* previous / next at the bottom */
.neighbours {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-200);
  margin-top: var(--s-700); padding-top: var(--s-400);
  border-top: 1px solid var(--line);
}
.neighbour { display: block; text-decoration: none; max-width: 260px; border-radius: 4px; }
.neighbour.is-next { grid-column: 2; justify-self: end; text-align: right; }
.neighbour-label { display: block; color: var(--muted); margin-bottom: var(--s-75); text-transform: uppercase; letter-spacing: 0.06em; }
.neighbour .frame { aspect-ratio: 3 / 2; }
.neighbour:active .frame { transform: scale(0.98); }
.neighbour .card-title { margin-top: var(--s-75); }
@media (hover: hover) {
  .neighbour:hover .card-title { color: var(--accent); }
  .neighbour:hover .frame img.is-loaded { transform: scale(1.03); }
}

/* not found */
.missing { padding-block: var(--s-800); }
.missing p { margin-top: var(--s-200); }
.missing p + p { margin-top: var(--s-300); }

/* footer: the honest line. The library already says it at the top, so it only shows on the other views. */
.site-footer { padding-block: var(--s-600) var(--s-700); color: var(--muted); }
.site-footer p { max-width: 680px; }
body[data-view="library"] .site-footer { display: none; }

@media (min-width: 768px) {
  .masthead { padding-block: var(--s-800) var(--s-600); }
  .masthead-title { font-size: 3rem; line-height: 1; }                /* Heading 2 */
  .photo-title { font-size: 2.25rem; line-height: 2.5rem; }           /* Heading 3 */
  .photo-top { padding-top: var(--s-300); }
}

/* ---------- reduced motion: nothing moves, short fades stay ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .view-enter { animation-duration: 150ms !important; }
  .frame img, .shot img, .compare-line,
  .card-title, .btn, .pager-btn, .back { transition-duration: 150ms !important; transition-property: opacity, color, background-color !important; }
  .card:hover .frame img.is-loaded, .neighbour:hover .frame img.is-loaded,
  .card:active .frame, .neighbour:active .frame, .btn:active, .pager-btn:active,
  .back:hover .icon, .compare.is-dragging .compare-handle { transform: none !important; }
  .compare.is-gliding .compare-bw, .compare.is-gliding .compare-line { transition: none !important; }
}
