/* Palette taken from the paintings: chalky plaster ground, blue-black shadow,
   one red-orange note (the accents in "Road to town" and "Road between walls"). */
:root {
  --paper: #f8f5ee;
  --ink: oklch(26% 0.025 235);
  --muted: oklch(50% 0.02 235);
  --accent: oklch(58% 0.16 36);
  --cast: oklch(28% 0.04 250 / 0.38);
  --night: oklch(19% 0.015 240);
  --grain-opacity: 0.025;
  --glow: rgb(255 255 255 / 0.35);

  /* set from the visitor's local time in app.js: -1 = morning, 1 = evening */
  --sun: 0.6;
  --gutter: clamp(16px, 5vw, 72px);
  color-scheme: light;
}

/* Dusk is selected explicitly with the theme button. */
:root[data-theme="dark"] {
  --paper: oklch(21% 0.016 240);
  --ink: oklch(89% 0.012 85);
  --muted: oklch(66% 0.015 85);
  --accent: oklch(66% 0.15 38);
  --cast: oklch(6% 0.02 250 / 0.65);
  --grain-opacity: 0.05;
  --glow: oklch(60% 0.06 50 / 0.07);
  color-scheme: dark;
}

:root:not([data-theme="dark"]) body {
  /* Soften the plaster relief on the near-white wall. */
  background-image: linear-gradient(#f8f5eeb3, #f8f5eeb3), var(--wall, none);
}

body { transition: background-color 400ms ease-out, color 400ms ease-out; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--paper);
  /* plaster wall (set in app.js); scrolls with the page, so the paintings hang on it */
  background-image: var(--wall, none);
  background-size: 640px 640px;
  color: var(--ink);
  font: 400 1rem/1.65 "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  position: relative;
}

/* scumbled-plaster grain: part of the wall, so it scrolls with it
   (grain that stays put while the page moves reads as dust on the screen) */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* low light raking in from the sun's side */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(calc(90deg + (1 - var(--sun)) * 90deg), var(--glow), transparent 58%);
}

header, main, footer { position: relative; z-index: 1; }

.intro,
.label-facts,
.label-note,
.about-page .about,
.about-page .contact-details p,
.end .note { font-weight: 300; }

a { color: inherit; }

button { font: inherit; color: inherit; }

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

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

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: max(24px, env(safe-area-inset-top)) var(--gutter) 0;
}

.top[data-scroll-nav] {
  position: sticky;
  top: calc(-1 * var(--scroll-nav-height));
  z-index: 3;
  padding-bottom: clamp(12px, 2.4vh, 22px);
  transition: transform 280ms cubic-bezier(.2,.7,.2,1);
}
.top.past-opening { pointer-events: none; }
.top.past-opening :is(.kicker, .views button, .views a) { pointer-events: auto; }
.top.past-opening:is(.is-showing, :has(:focus-visible)) { transform: translateY(100%); }
.top.past-opening :is(.sep, [data-theme-toggle]) { visibility: hidden; }

.kicker {
  font-variant: all-small-caps;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0;
  text-decoration: none;
}

.views { display: flex; gap: clamp(0.65rem, 2.2vw, 1.25rem); align-items: baseline; }
.views .sep {
  width: 1px;
  height: 0.9em;
  align-self: center;
  background: color-mix(in oklch, var(--ink) 25%, transparent);
}

.views :is(button, a) {
  text-decoration: none;
  background: none;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  font-variant: all-small-caps;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition: color 160ms ease-out, border-color 160ms ease-out;
}
.views button[aria-pressed="true"], .views a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
@media (hover: hover) { .views :is(button, a):hover { color: var(--ink); } }

/* ---------- intro ---------- */

/* ---------- opening screen ---------- */

.opening {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(76px, 11vh, 112px);
  padding: clamp(66px, 13vh, 132px) var(--gutter) 0;
  margin-bottom: clamp(110px, 22vh, 240px);
}

.artist {
  margin: 0.35rem 0 0;
  color: color-mix(in oklch, var(--ink) 12%, var(--muted));
  font-weight: 500;
  font-size: clamp(1.125rem, 2vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-wrap: balance;
}

.intro {
  margin: clamp(22px, 4vh, 40px) 0 0;
  max-width: 22ch;
  font-style: italic;
  font-size: clamp(1.05rem, 1.7vw, 1.4rem);
  line-height: 1.25;
  color: var(--muted);
  text-wrap: balance;
}

.begin {
  display: inline-flex;
  gap: 0.6rem;
  align-items: baseline;
  margin-top: clamp(36px, 7vh, 72px);
  text-decoration: none;
  font-variant: all-small-caps;
  letter-spacing: 0.14em;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in oklch, var(--ink) 22%, transparent);
  transition: border-color 200ms ease-out;
}
.begin .arrow { color: var(--accent); display: inline-block; transition: transform 300ms cubic-bezier(.2,.7,.2,1); }
@media (hover: hover) {
  .begin:hover { border-bottom-color: var(--accent); }
  .begin:hover .arrow { transform: translateY(3px); }
}

.cover { display: block; text-decoration: none; cursor: zoom-in; width: min(88%, 640px); margin-inline: auto; }
.cover img { display: block; width: 100%; height: auto; }
.cover .fr {
  box-shadow: var(--fr-edges),
    calc(var(--sun) * 34px) 26px 44px -16px var(--cast),
    calc(var(--sun) * 110px) 64px 90px -50px var(--cast);
}
.cover .caption { justify-content: flex-end; }

@media (min-width: 900px) {
  .opening {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr);
    align-items: end;
    gap: 6vw;
    min-height: calc(100svh - 70px);
    padding-top: clamp(24px, 4vh, 48px);
    padding-bottom: clamp(40px, 8vh, 96px);
  }
  .opening-text { padding-bottom: 2.5rem; }
  .cover { width: min(100%, 50vw, 760px); margin-inline: 0; align-self: center; justify-self: end; }
  .cover .fr { width: fit-content; max-width: 100%; margin-inline-start: auto; }
  .cover img { width: auto; max-width: 100%; max-height: calc(76svh - 2 * var(--mould)); }
}

/* the light arrives: text rises, the cover's shadow lengthens like late afternoon */
.opening-text > * { animation: rise 900ms cubic-bezier(.2,.7,.2,1) both; }
.opening-text > :nth-child(2) { animation-delay: 120ms; }
.opening-text > :nth-child(3) { animation-delay: 320ms; }
.opening-text > :nth-child(4) { animation-delay: 520ms; }
.cover { animation: appear 1100ms 200ms ease-out both; }
.cover .fr { animation: lengthen 2600ms 400ms cubic-bezier(.3,.6,.2,1) both; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes appear { from { opacity: 0; } }
@keyframes lengthen {
  from { box-shadow: var(--fr-edges), 0 6px 12px -8px var(--cast), 0 10px 20px -16px var(--cast); }
}

/* ---------- gallery: walk ---------- */

.gallery {
  --gallery-scroll-margin: max(48px, calc(var(--scroll-nav-height, 0px) + 24px));
  list-style: none;
  margin: 0;
  padding: 0 var(--gutter);
  scroll-margin-top: var(--gallery-scroll-margin);
}
.views [data-theme-toggle] { min-width: 2.6em; text-align: right; }

.gallery-divider { margin-bottom: clamp(36px, 7vh, 72px); }
.gallery-divider h2 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 500;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.1em;
}
.gallery-divider h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in oklch, var(--ink) 16%, transparent);
}
.gallery-divider hr { margin: 0; border: 0; border-top: 1px solid color-mix(in oklch, var(--ink) 16%, transparent); }
[data-mode="index"] .gallery-divider { display: none; }

.piece { margin: 0; }

.frame {
  display: block;
  text-decoration: none;
  cursor: zoom-in;
}

.piece img { display: block; width: 100%; height: auto; }
.piece .fr {
  /* the long low shadow every tree in these paintings throws */
  box-shadow: var(--fr-edges),
    calc(var(--sun) * 26px) 20px 34px -14px var(--cast),
    calc(var(--sun) * 70px) 46px 70px -40px var(--cast);
  transition: transform 300ms cubic-bezier(.2,.7,.2,1);
}
@media (hover: hover) {
  .frame:hover .fr { transform: translateY(-3px); }
}

/* short caption (opening-screen cover) */
.caption {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  align-items: baseline;
  margin-top: 22px;
  font-size: 1rem;
}
.caption .no {
  color: var(--accent);
  font-variant-numeric: oldstyle-nums tabular-nums;
  font-size: 0.9rem;
}
.caption .title { font-style: italic; }
.caption .details {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: end;
}

/* ---------- wall label ---------- */

.label {
  margin-top: 24px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--muted);
}
.label p { margin: 0; }
/* the number hangs in the margin; everything else lines up under the title */
.label > :not(.label-head) { padding-left: 2.05rem; }

.label-head {
  display: flex;
  gap: 0.9rem;
  align-items: baseline;
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.25;
}
.label-head .no {
  flex: none;
  min-width: 1.15rem;
  white-space: nowrap;
  color: var(--accent);
  font-size: 0.85rem;
  font-variant-numeric: oldstyle-nums tabular-nums;
}
.label-head .title { font-style: italic; }
.label-year {
  display: inline-block;
  color: var(--muted);
  font-size: 0.82em;
  font-style: normal;
  white-space: nowrap;
}

.label-facts { margin-top: 0.5rem; }
.label-facts p + p { margin-top: 0.15rem; }

.label-note {
  position: relative;
  margin-top: 1.1rem !important;
  max-width: calc(30ch + 2.05rem);
  color: color-mix(in oklch, var(--ink) 80%, var(--paper));
  text-wrap: pretty;
}
.label-note::before {
  content: "";
  display: block;
  width: 26px;
  height: 1px;
  margin-bottom: 0.9rem;
  background: var(--accent);
  opacity: 0.75;
}

.label-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.9rem !important;
  font-variant: all-small-caps;
  letter-spacing: 0.12em;
}
.label-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- walk ---------- */

[data-mode="walk"] {
  --walk-span: 100cqw;
  container-type: inline-size;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: clamp(96px, 18vh, 200px) clamp(16px, 4vw, 60px);
  padding-bottom: clamp(96px, 18vh, 200px);
}
[data-mode="walk"] .piece {
  --walk-width: 0.58;
  --walk-image-width: calc(var(--walk-span) * var(--walk-width));
  flex: 0 0 100%;
  min-width: 0;
}
[data-mode="walk"] .gallery-divider { flex: 0 0 100%; margin: 0; }
[data-mode="walk"] .frame { width: var(--walk-image-width); }
[data-mode="walk"] .small-piece {
  --label-width: min(9rem, 42cqw);
  flex-basis: max(var(--label-width), var(--walk-image-width));
}
[data-mode="walk"] .small-piece .label { margin-top: 14px; }
[data-mode="walk"] .small-piece .label-head { font-size: 1rem; gap: 0.55rem; }
[data-mode="walk"] .small-piece .label > :not(.label-head) { padding-left: 0; }
[data-mode="walk"] .walk-piece[data-walk-side] {
  display: grid;
  flex-basis: 100%;
  padding-inline: 0;
}
[data-mode="walk"] [data-walk-side="right"] { justify-items: end; }
[data-mode="walk"] [data-walk-side="center"] { justify-items: center; text-align: center; }
[data-mode="walk"] [data-walk-side="center"] .label-head { justify-content: center; }
[data-mode="walk"] [data-walk-side="center"] .label > :not(.label-head) { padding-left: 0; }
[data-mode="walk"] [data-walk-side] .label { width: max(9rem, var(--walk-image-width)); }

@media (max-width: 759px) {
  [data-mode="walk"] { padding-inline: 0; }
  [data-mode="walk"] .frame { margin-inline-start: min(8px, calc((100% - var(--walk-image-width)) / 2)); }
  [data-mode="walk"] :is(.label, .gallery-divider) { padding-inline: 8px; }
  [data-mode="walk"] .small-piece {
    flex-basis: max(var(--label-width), calc(var(--walk-image-width) + 8px));
    padding-inline-start: 8px;
  }
  [data-mode="walk"] .small-piece .frame { margin-inline-start: 0; }
  [data-mode="walk"] .small-piece .label { padding-inline-start: 0; }
  [data-mode="walk"] [data-walk-side="right"] .frame {
    margin-inline: 0 min(8px, calc((100% - var(--walk-image-width)) / 2));
  }
  [data-mode="walk"] [data-walk-side="center"] .frame { margin-inline: 0; }
  [data-mode="walk"] [data-walk-side] .label { padding-inline: 8px; }
}

@media (min-width: 760px) {
  [data-mode="walk"] {
    --walk-span: 77vw;
    --walk-stagger: 12vw;
  }
  [data-mode="walk"] .piece:nth-child(3n+1 of .walk-piece:not(.small-piece, [data-walk-side])) { padding-inline-start: 4vw; }
  [data-mode="walk"] .piece:nth-child(3n+2 of .walk-piece:not(.small-piece, [data-walk-side])) { padding-inline-end: 2vw; }
  [data-mode="walk"] .piece:nth-child(3n of .walk-piece:not(.small-piece, [data-walk-side])) {
    padding-inline-start: min(var(--walk-stagger), calc(100% - var(--walk-image-width)));
  }
  [data-mode="walk"] [data-walk-side="right"][data-walk-inset] {
    padding-inline-end: min(var(--walk-stagger), calc(100% - var(--walk-image-width)));
  }
}

@media (min-width: 760px) and (max-width: 1099px) {
  [data-mode="walk"] .piece:nth-child(3n+2 of .walk-piece:not(.small-piece, [data-walk-side])) {
    display: grid;
    justify-items: end;
  }
  [data-mode="walk"] .piece:nth-child(3n+2 of .walk-piece:not(.small-piece, [data-walk-side])) .label {
    width: var(--walk-image-width);
  }
}

/* Large works leave room for a side label when the viewport permits it. */
@media (min-width: 1100px) {
  [data-mode="walk"] { --walk-span: min(79vw, 1360px); }
  [data-mode="walk"] .walk-piece:not(.small-piece, [data-walk-side="center"]) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px clamp(24px, 3vw, 56px);
  }
  [data-mode="walk"] .frame { flex: none; }
  [data-mode="walk"] .walk-piece:not(.small-piece, [data-walk-side="center"]) .label {
    flex: 0 0 13rem;
    margin: 0;
    padding-bottom: 4px;
  }
  [data-mode="walk"] [data-walk-side="right"],
  [data-mode="walk"] .piece:nth-child(3n+2 of .walk-piece:not(.small-piece, [data-walk-side])) {
    flex-direction: row-reverse;
  }
}

/* ---------- gallery: index ---------- */

/* justified rows: every row runs the full width and its paintings share one
   height. Each item grows in proportion to its aspect ratio (--ar, set in
   app.js), so widths come out as ratio × the same height. */
[data-mode="index"] {
  --row: clamp(130px, 15vw, 210px);
  display: flex;
  flex-wrap: wrap;
  gap: 44px 28px;
  align-items: flex-start;
  padding-bottom: 120px;
}
/* keeps the last row at its natural size instead of stretching it */
[data-mode="index"]::after { content: ""; flex: 999 1 0; }
[data-mode="index"] .piece {
  flex: var(--ar) 1 calc(var(--ar) * var(--row));
  min-width: 0;
}
[data-mode="index"] .piece img { width: 100%; height: auto; }
[data-mode="index"] .frame { scroll-margin-top: var(--gallery-scroll-margin); }
[data-mode="index"] .piece .fr {
  box-shadow: var(--fr-edges), calc(var(--sun) * 12px) 10px 18px -8px var(--cast);
}
@media (max-width: 759px) {
  [data-mode="index"] { --row: 110px; gap: 32px 14px; }
}
[data-mode="index"] .label { margin-top: 12px; }
[data-mode="index"] .label-head { font-size: 0.92rem; gap: 0.6rem; }
[data-mode="index"] .label-head .no { min-width: 0; }
[data-mode="index"] .label > :not(.label-head, .label-facts),
[data-mode="index"] .label-facts > :not(.label-size, .label-medium) { display: none; }
[data-mode="index"] .label-facts {
  margin-top: 0.3rem;
  padding-left: 0;
  font-size: 0.84rem;
}
[data-mode="index"] .label-size { margin: 0; }

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

.end {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem 1.5rem;
  margin: 0 var(--gutter);
  padding: 1.5rem 0 max(2.25rem, env(safe-area-inset-bottom));
  border-top: 1px solid color-mix(in oklch, var(--ink) 14%, transparent);
  color: var(--muted);
  font-size: 0.95rem;
}
.end .meta { margin: 0; }
.end .meta [data-artist] { font-variant: all-small-caps; letter-spacing: 0.12em; color: var(--ink); }
.end .note { flex-basis: 100%; margin: 0; font-style: italic; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-inline-start: auto; }
.footer-links a { text-decoration-color: transparent; text-underline-offset: 4px; }
.footer-links a:is(:hover, :focus-visible, [aria-current="page"]) {
  color: var(--ink);
  text-decoration-color: var(--accent);
}
.footer-links .instagram-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
}

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

.about-page {
  display: grid;
  grid-template-areas: "title" "painting" "bio" "contact" "framing";
  align-items: start;
  gap: 1.6rem;
  max-width: 1360px;
  margin-inline: auto;
  padding: clamp(3.5rem, 10vh, 7rem) var(--gutter) clamp(4rem, 10vh, 9rem);
  font-size: clamp(1.06rem, 1.7vw, 1.21rem);
}
.about-title {
  grid-area: title;
  margin: 0;
  color: var(--ink);
  font-size: 1em;
  font-weight: 500;
  line-height: 1.15;
}
.about-title::after {
  content: "";
  display: block;
  width: 2rem;
  height: 1px;
  margin-top: 0.55rem;
  background: var(--accent);
}
.about-paintings {
  grid-area: painting;
  min-width: 0;
}
.about-painting { min-width: 0; margin: 0; }
.about-painting-image { aspect-ratio: 4 / 3; }
.about-painting img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  box-shadow: calc(var(--sun) * 14px) 10px 20px -8px var(--cast),
    calc(var(--sun) * 30px) 20px 38px -22px var(--cast);
}
.about-painting figcaption { margin-top: 0.55rem; color: var(--muted); font-size: 0.86rem; font-style: italic; }
.about-page :is(.about, .contact-details) { font-size: clamp(1rem, 1.25vw, 1.0625rem); }
.about-page .about { grid-area: bio; max-width: 50ch; }
.about-page .about strong { font-weight: 700; }
.about-page .about p { margin: 0 0 0.75em; }
.about-page .about p:last-child { margin-bottom: 0; }
.about-page .contact-details {
  grid-area: contact;
  max-width: 50ch;
  padding-top: 1rem;
  border-top: 1px solid color-mix(in oklch, var(--ink) 16%, transparent);
}
.about-page .contact-details h2 { margin: 0 0 0.35rem; font-size: 0.94rem; font-weight: 500; letter-spacing: 0.13em; }
.about-page .contact-details p { margin: 0.2rem 0; }
.about-page .contact-details a {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}
.contact-details svg {
  flex: none;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
}
.contact-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.contact-value {
  min-width: 0;
  overflow-wrap: anywhere;
  text-decoration: underline 1px color-mix(in oklch, var(--ink) 44%, var(--paper));
  text-underline-offset: 3px;
}

.about-framing {
  grid-area: framing;
  margin: clamp(3.5rem, 7vw, 7rem) 0 0;
}
.about-framing figcaption {
  margin: 1rem auto 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  text-wrap: balance;
}
.framing-photos { display: grid; gap: clamp(1rem, 2.6vw, 2rem); }
.framing-photos img { display: block; width: 100%; height: auto; }

@media (min-width: 600px) {
  .about-page {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    grid-template-areas: ". title" "painting bio" "painting contact" "framing framing";
    column-gap: clamp(1.8rem, 6vw, 7rem);
  }
  .about-paintings { margin-top: 0.25em; }
  .framing-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
  }
}

/* ---------- viewer ---------- */

.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--night);
  color: oklch(88% 0.012 85);
}
.viewer::backdrop { background: var(--night); }
.viewer:focus { outline: none; }
html:has(.viewer[open]) { overflow: hidden; }
.viewer[open] { display: grid; place-items: center; animation: fade 220ms ease-out; }
@keyframes fade { from { opacity: 0; } }

.viewer figure {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 56px 72px 28px;
  max-height: 100dvh;
}
.viewer img {
  display: block;
  max-width: calc(100vw - 144px);
  max-height: calc(100dvh - 150px);
  width: auto;
  height: auto;
  object-fit: contain;
  /* unframed here: just the painting and its shadow */
  box-shadow: calc(var(--sun) * 30px) 26px 50px -20px oklch(0% 0 0 / 0.7);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
}
/* the viewer is always at dusk, whatever the page theme */
.viewer {
  --ink: oklch(89% 0.012 85);
  --muted: oklch(67% 0.015 85);
  --paper: var(--night);
  --accent: oklch(66% 0.15 38);
}
.viewer figcaption { width: 100%; }
.viewer .label { margin: 0; }

@media (min-width: 1100px) {
  .viewer figure {
    grid-template-columns: auto 280px;
    align-items: end;
    gap: 56px;
    padding: 56px 88px;
  }
  .viewer img { max-width: calc(100vw - 176px - 336px); max-height: calc(100dvh - 112px); }
  .viewer figcaption { padding-bottom: 6px; }
}

.viewer button {
  position: absolute;
  background: none;
  border: 0;
  cursor: pointer;
  color: oklch(80% 0.012 85);
  transition: color 160ms ease-out;
}
@media (hover: hover) { .viewer button:hover { color: oklch(97% 0.01 85); } }
.viewer .nav { top: 50%; translate: 0 -50%; font-size: 1.6rem; padding: 24px 22px; }
.viewer .prev { left: 4px; }
.viewer .next { right: 4px; }
.viewer .close {
  top: max(14px, env(safe-area-inset-top));
  right: 18px;
  padding: 10px 6px;
  font-variant: all-small-caps;
  letter-spacing: 0.14em;
}

@media (max-width: 759px) {
  .viewer figure { padding: 60px 0 20px; }
  .viewer img { max-width: 100vw; max-height: calc(100dvh - 170px); }
  .viewer .nav { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); translate: none; }
  .viewer figcaption { padding: 0 20px; }
  .viewer .label-note { display: none; }
}

/* ---------- floating frames (opt-in) ----------
   Off by default: paintings hang unframed. Add ?frames to the URL and the
   head script in index.html puts .framed on <html>, which turns on everything below.
   Oak tray frame (.fr, wrapped around each <img> in app.js) with a thin dark
   recess between moulding and canvas, so the canvas seems to float.
   Moulding: oak colour + fine grain + light from the sun's side + bevelled edges.
   Recess: the img's padding, darkened at the top where the lip shades it. */
:root {
  --oak: oklch(73% 0.06 72);
  --recess: oklch(15% 0.01 60);
  /* grain runs along each member: horizontal on top/bottom, vertical on the sides */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.008 .42' numOctaves='3' seed='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .22  0 0 0 0 .13  0 0 0 0 .05  1.5 0 0 0 -.6'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --grain-v: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.42 .008' numOctaves='3' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .22  0 0 0 0 .13  0 0 0 0 .05  1.5 0 0 0 -.6'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --fr-edges: 0 0 transparent; /* unframed: no frame edges */
}
html.framed,
.fr-on {
  /* rounded outer arris: dark outline, light catch inside it, darker inner lip */
  --fr-edges:
    inset 0 0 0 1px oklch(25% 0.03 60 / 0.55),
    inset 1px 1px 0 1px oklch(96% 0.03 85 / 0.35),
    inset -1px -1px 0 1px oklch(30% 0.04 60 / 0.25);
}
.fr { --mould: 0px; --gap: 0px; display: block; position: relative; }
.fr img { background: color-mix(in oklch, var(--ink) 12%, var(--paper)); } /* placeholder while loading */

html.framed .fr,
.fr.fr-on {
  --mould: 8px;
  --gap: 3px;
  padding: var(--mould);
  background-color: var(--oak);
  background-image:
    linear-gradient(calc(135deg - var(--sun) * 45deg),
      oklch(100% 0 0 / 0.22), transparent 42%, oklch(0% 0 0 / 0.16)),
    var(--grain-v), var(--grain-v),
    linear-gradient(var(--oak), var(--oak)), linear-gradient(var(--oak), var(--oak)),
    var(--grain);
  background-size: auto,
    var(--mould) 320px, var(--mould) 320px,
    var(--mould) 100%, var(--mould) 100%,
    320px 320px;
  background-position: 0 0, left top, right top, left top, right top, 0 0;
  background-repeat: no-repeat, repeat-y, repeat-y, no-repeat, no-repeat, repeat;
}
html.framed .fr img,
.fr.fr-on img {
  padding: var(--gap);
  background: var(--recess);
  /* inner edge of the moulding, then the recess shaded from the top */
  border: 1px solid oklch(32% 0.03 60);
  box-shadow: inset 0 2px 3px oklch(0% 0 0 / 0.9);
}
html.framed [data-mode="index"] .fr { --mould: 5px; --gap: 2px; }
@media (max-width: 759px) {
  html.framed .fr { --mould: 6px; --gap: 2px; }
}


@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
