:root {
  color-scheme: only light;
  --ink: #2B211B;
  --ink-strong: #241A14;
  --ink-soft: #4A3B31;
  --ink-mute: #6B5748;
  --paper: #FAF4EA;
  --rule: #E5D6C0;
  --edge: #DBC8AE;
  --accent: #A8571F;
  --accent-dark: #8F4818;
  --serif: Newsreader, Georgia, "Times New Roman", serif;
  --sans: Karla, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html {
  margin: 0; padding: 0;
  background-color: var(--paper) !important;
  scroll-behavior: smooth;
}
body {
  margin: 0; padding: 0;
  min-height: 100vh;
  background-color: var(--paper) !important;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration-color: rgba(168,87,31,.35); text-underline-offset: 3px; }
a:hover { color: #7C3D12; text-decoration-color: rgba(124,61,18,.8); }
img, video { display: block; max-width: 100%; }

section, header, footer, .hero-bg, .band { background-color: var(--paper); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 56px); }
.narrow { max-width: 720px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px); }
.mid { max-width: 1000px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 48px); }

.eyebrow {
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent-dark);
}
.label {
  font-family: var(--sans);
  font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-mute);
}

/* ---- navigation ----
   .topnav sits in normal flow and scrolls away with the hero. Once it's
   scrolled out of view (tracked in script.js via IntersectionObserver),
   .sidenav takes over: the same bar, rotated — writing-mode flips its
   layout axis and its text together, so it becomes a full-height strip
   docked on the left instead of a full-width strip docked on top. It
   slides back out once .topnav is back on screen. */
.topnav, .sidenav {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: clamp(20px, 4vw, 48px);
  background: var(--paper);
}
.topnav {
  padding: 18px clamp(20px, 5vw, 48px);
  border-bottom: 1px solid var(--rule);
}
.topnav a, .sidenav a {
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-mute); text-decoration: none; white-space: nowrap;
  transition: color 200ms ease;
}
.topnav a:hover, .sidenav a:hover { color: var(--accent); }

.sidenav {
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 500;
  align-items: center;
  padding: clamp(20px, 5vw, 48px) 18px;
  writing-mode: vertical-rl;
  border-right: 1px solid var(--rule);
  transform: translateX(-100%);
  transition: transform 320ms cubic-bezier(.2,.7,.3,1), box-shadow 320ms;
}
/* Keep the "Top" arrow pointing up inside the sideways text. */
.sidenav .to-top span { text-orientation: upright; }
/* Shadow only while shown, so it doesn't peek in from off-screen. */
.sidenav.visible { transform: translateX(0); box-shadow: 8px 0 28px rgba(64,42,25,.15); }
@media (max-width: 640px) {
  .sidenav { padding: 14px 12px; gap: clamp(14px, 4vw, 28px); }
  .sidenav a { font-size: 11px; letter-spacing: .14em; }
}

/* ---- scenes ----
   script.js adds .scenes to <html>; without it the page scrolls as one
   normal document. With it, each .scene is a full-screen layer and only
   the active one is shown. A scene taller than the screen scrolls inside
   itself; scrolling past either end fades to the neighbouring scene. The
   outgoing scene fades first, then the incoming one fades in after a delay,
   so the two never overlap. --shift (set in script.js) is the direction of
   the slight drift. */
html.scenes, html.scenes body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.scenes .hairline { display: none; }
.scenes .scene {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  overflow-y: auto; overscroll-behavior: contain;
  background-color: var(--paper);
  opacity: 0; visibility: hidden;
  transform: translateY(var(--shift, 24px));
  transition: opacity 450ms ease, transform 450ms ease, visibility 0s linear 450ms;
}
.scenes .scene.is-active {
  z-index: 2; opacity: 1; visibility: visible; transform: none;
  transition: opacity 650ms ease 380ms, transform 650ms cubic-bezier(.2,.7,.3,1) 380ms, visibility 0s;
}
.scenes .scene > * { flex: none; }
.scenes .scene > :last-child { margin-block: auto; }
.scenes .band { border-top: 0; }
/* Keep the whole slideshow (header, photo, controls) on one screen. */
.scenes #slideshow-stage { max-height: calc(100vh - 340px); min-height: 200px; }
@media (prefers-reduced-motion: reduce) {
  .scenes .scene { transform: none !important; }
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
  padding-top: clamp(28px, 6vw, 72px);
  padding-bottom: clamp(40px, 7vw, 88px);
}
.hero h1 {
  margin: clamp(14px, 2.5vw, 26px) 0 0;
  font-size: clamp(76px, 15vw, 168px);
  line-height: .82; font-weight: 300;
  letter-spacing: -.035em; color: var(--ink-strong);
}
.hero-rule { margin-top: clamp(20px, 3vw, 34px); display: flex; align-items: center; gap: 16px; }
.hero-rule span.line { height: 1px; width: clamp(36px, 8vw, 72px); background: var(--edge); }
.hero blockquote {
  margin: clamp(22px, 3.5vw, 36px) 0 0;
  font-size: clamp(21px, 2.4vw, 27px); line-height: 1.5;
  font-style: italic; font-weight: 300; color: var(--ink-soft);
  max-width: 30ch; text-wrap: pretty;
}
.frame { position: relative; width: min(100%, 300px); margin-inline: auto; }
.frame::before {
  content: ""; position: absolute;
  inset: clamp(14px,3vw,26px) calc(-1 * clamp(10px,2vw,20px)) calc(-1 * clamp(14px,3vw,26px)) clamp(10px,2vw,20px);
  border: 1px solid #E2D2BC; border-radius: 4px;
}
.frame img {
  position: relative; width: 100%;
  aspect-ratio: 499 / 934; object-fit: cover; object-position: center center;
  background-color: var(--paper); border-radius: 3px;
}

.hairline { height: 1px; background: linear-gradient(90deg, rgba(217,196,166,0) 0%, #D9C4A6 50%, rgba(217,196,166,0) 100%); }

.dedication { padding: clamp(52px, 9vw, 112px) 0; }
.dedication p:first-child {
  margin: 0; font-size: clamp(22px, 2.6vw, 29px); line-height: 1.62;
  font-weight: 300; color: #33271F; text-wrap: pretty;
}
.dedication p:first-child::first-letter {
  font-size: 3.4em; line-height: .8; float: left;
  padding: .06em .18em 0 0; color: var(--accent); font-weight: 300;
}
.dedication p + p {
  margin: clamp(26px, 4vw, 40px) 0 0;
  font-size: clamp(19px, 2.1vw, 23px); line-height: 1.72;
  font-weight: 300; color: var(--ink-soft); text-wrap: pretty;
}

.band { border-top: 1px solid var(--rule); }
.band-inner, .section { padding-top: clamp(44px, 7vw, 88px); padding-bottom: clamp(44px, 7vw, 88px); }
.head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 12px 20px;
  margin-bottom: clamp(22px, 3.5vw, 34px);
}
.head h2 {
  margin: 0; font-size: clamp(30px, 4.4vw, 46px);
  font-weight: 300; letter-spacing: -.02em; color: var(--ink-strong);
}

/* ---- slideshow (markup in index.html, behaviour in script.js) ---- */
#slideshow-stage {
  position: relative; width: 100%; aspect-ratio: 3 / 2;
  background-color: var(--paper); border: 1px solid var(--rule); border-radius: 3px;
  overflow: hidden; touch-action: pan-y;
}
#slideshow-stage img,
#slideshow-stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  opacity: 0; transition: opacity 900ms cubic-bezier(.4,0,.2,1);
}
#slideshow-stage img.is-on,
#slideshow-stage video.is-on { opacity: 1; }
/* Only the visible slide should receive clicks — otherwise a stacked,
   invisible layer underneath silently steals the click. */
#slideshow-stage img,
#slideshow-stage video { pointer-events: none; }
#slideshow-stage img.is-on,
#slideshow-stage video.is-on { pointer-events: auto; }
#slideshow-stage .ss-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 24px; text-align: center;
  font-family: var(--sans); font-size: 14px; color: var(--ink-mute);
}
.ss-controls {
  margin-top: clamp(18px, 2.6vw, 26px);
  display: flex; align-items: center; justify-content: center;
  gap: clamp(12px, 3vw, 28px);
}
.ss-arrow {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--edge); border-radius: 999px;
  background: var(--paper); color: var(--ink-mute); cursor: pointer;
  transition: background 200ms, color 200ms, border-color 200ms, transform 200ms;
}
.ss-arrow:hover { background: var(--accent); border-color: var(--accent); color: #FFF8EC; }
.ss-arrow:first-child:hover { transform: translateX(-2px); }
.ss-arrow:last-child:hover { transform: translateX(2px); }
/* Arrows stay on one row; with many slides the dots wrap between them. */
.ss-dots { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; justify-content: center; min-width: 0; }
@media (max-width: 640px) { .ss-dots { gap: 4px 6px; } }
.ss-dots button {
  width: 22px; height: 22px; padding: 0; flex: none;
  display: grid; place-items: center;
  border: none; background: none; cursor: pointer;
}
.ss-dots button i {
  display: block; width: 8px; height: 8px; border-radius: 999px;
  background: #CDB79A; transition: background 300ms, transform 300ms;
}
.ss-dots button[aria-current="true"] i { background: var(--accent); transform: scale(1.35); }
.ss-count { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mute); }
.ss-hint { margin: clamp(14px,2vw,20px) 0 0; text-align: center; font-family: var(--sans); font-size: 13px; color: var(--ink-mute); }

/* ---- video ---- */
.video-shell {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background-color: var(--paper); border: 1px solid var(--rule); border-radius: 3px; overflow: hidden;
}
.video-shell video { width: 100%; height: 100%; object-fit: contain; background-color: var(--paper); }
.video-missing {
  position: absolute; inset: 0; display: none;
  place-items: center; padding: 24px; text-align: center; background-color: var(--paper);
}
.video-shell.is-empty .video-missing { display: grid; }
.video-missing p { margin: 0; font-size: clamp(19px,2.2vw,24px); font-weight: 300; color: var(--ink-soft); }
.video-missing small {
  display: block; margin: 10px auto 0; max-width: 46ch;
  font-family: var(--sans); font-size: 14px; line-height: 1.6;
  color: var(--ink-mute);
}
.video-missing code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.caption {
  margin: clamp(16px,2.4vw,22px) 0 0;
  font-size: clamp(18px,2vw,21px); line-height: 1.7;
  font-weight: 300; font-style: italic; color: var(--ink-soft);
  max-width: 52ch; text-wrap: pretty;
}

#catch .caption { margin-inline: auto; text-align: center; }

/* ---- gallery grid (filled by script.js from the slideshow folder) ---- */
.photo-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 1.4vw, 14px);
}
.photo-grid button {
  display: block; padding: 0; aspect-ratio: 1;
  border: 1px solid var(--rule); border-radius: 3px; overflow: hidden;
  background: var(--paper); cursor: zoom-in;
}
.photo-grid img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 400ms cubic-bezier(.2,.7,.3,1);
}
.photo-grid button:hover img { transform: scale(1.04); }
.photo-grid .ss-empty {
  grid-column: 1 / -1; padding: 24px; text-align: center;
  font-family: var(--sans); font-size: 14px; color: var(--ink-mute);
}

/* ---- messages (form + approved list; backend in server/messages.js) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.message-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.message-form textarea {
  display: block; width: 100%; resize: vertical; min-height: 120px;
  padding: 14px 16px; border: 1px solid var(--edge); border-radius: 3px;
  background: #FFFDF8; color: var(--ink);
  font: 300 clamp(17px, 1.9vw, 19px)/1.6 var(--serif);
}
.message-form textarea:focus { outline: 2px solid rgba(168,87,31,.35); outline-offset: 1px; border-color: var(--accent); }
.message-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 14px; }
.message-send {
  padding: 12px 22px; border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: #FFF8EC; cursor: pointer;
  font: 600 12px var(--sans); letter-spacing: .16em; text-transform: uppercase;
  transition: background 200ms, border-color 200ms;
}
.message-send:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.message-send:disabled { opacity: .6; cursor: default; }
.message-status { margin: 0; font-family: var(--sans); font-size: 14px; color: var(--ink-mute); }
.message-list { margin-top: clamp(32px, 5vw, 48px); }
.message-list .msg { padding: 20px 0; border-top: 1px solid var(--rule); }
.message-list .msg p {
  margin: 0; white-space: pre-line; overflow-wrap: anywhere;
  font-size: clamp(18px, 2vw, 21px); line-height: 1.65; font-weight: 300; color: var(--ink-soft);
}
.message-list .msg time { display: block; margin-top: 8px; font-family: var(--sans); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }

/* ---- lightbox ----
   .lightbox always scrolls; .lightbox-viewport always centers its
   content via flex. When the image is smaller than the viewport, the
   viewport (min-width/height: 100%) matches the screen and the flex
   centering puts it in the middle. When zoomed past that, the viewport
   grows to fit the image and .lightbox scrolls to reveal it — the image
   never has to jump between "centered" and "pinned to a corner" layouts. */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20,15,10,.92);
  overflow: auto;
}
.lightbox[hidden] { display: none; }
.lightbox-viewport {
  min-width: 100%; min-height: 100%;
  box-sizing: border-box; padding: 32px;
  display: flex; align-items: center; justify-content: center;
}
.lightbox img {
  max-width: 100%; max-height: calc(100vh - 64px);
  display: block;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  border-radius: 2px;
  -webkit-user-drag: none; user-select: none;
}
.lightbox.zoomed img {
  max-width: none; max-height: none;
  height: auto;
  box-shadow: none; border-radius: 0;
  cursor: grab;
}
.lightbox.zoomed img.dragging { cursor: grabbing; }
.lightbox-close {
  position: fixed; top: 16px; right: 16px; z-index: 1001;
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid rgba(250,244,234,.35); border-radius: 999px;
  background: rgba(0,0,0,.4); color: var(--paper);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgba(0,0,0,.6); }

footer { border-top: 1px solid var(--rule); }
footer .mid { padding: clamp(40px,6vw,72px) clamp(20px,5vw,48px); text-align: center; }
footer .name { font-size: clamp(26px,3.6vw,38px); font-weight: 300; font-style: italic; color: #33271F; }
footer .eyebrow { margin-top: 14px; }

@media (max-width: 640px) {
  /* Wider side padding keeps text clear of the docked .sidenav. */
  .wrap, .narrow, .mid { padding-left: 50px; padding-right: 50px; }
  .frame img { aspect-ratio: 499 / 934; }
  .frame { width: min(100%, 260px); }
}
@media (prefers-reduced-motion: reduce) {
  #slideshow-stage img, #slideshow-stage video { transition: none; }
}

/* Re-assert the light palette if anything tries to serve a dark treatment. */
@media (prefers-color-scheme: dark) {
  html, body { background-color: var(--paper); color: #2B211B; }
  .band, footer, .hero-bg, #slideshow-stage, .video-shell, .video-missing { background-color: var(--paper); }
  .video-missing p { color: #4A3B31; }
  .video-missing small { color: #6B5748; }
  .dedication p:first-child { color: #33271F; }
  .dedication p + p, .caption, .hero blockquote { color: #4A3B31; }
  .head h2, .hero h1 { color: #241A14; }
  .label, .ss-count, .ss-hint { color: #6B5748; }
  .eyebrow { color: #8F4818; }
}
