/* =========================================================
   1. TOKENS
   Colours live only here. Light is the default; dark follows the
   system (prefers-color-scheme). There is no theme toggle.
   ========================================================= */
:root {
  color-scheme: light;

  --paper: #F3EFE7;          /* page */
  --surface: #F8F5EF;        /* raised: inputs, bars */
  --ink: #2A2723;            /* all reading text */
  --muted: #6F685F;          /* secondary text */
  --hairline: #DCD4C7;       /* separators (decorative, not text) */
  --line-strong: #8A8174;    /* control borders (UI, >= 3:1) */
  --accent: #8C4F33;         /* clay: links, buttons, focus. Nothing else. */
  --accent-hover: #6F3C26;
  --accent-ink: #F8F5EF;     /* text on an accent fill */
  --placeholder: #E7E0D3;    /* tile background while the photo loads */

  /* paper grain: ink-coloured specks, almost invisible */
  --grain-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .17 0 0 0 0 .15 0 0 0 0 .13 0 0 0 2.2 -.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain-opacity: .05;

  /* type */
  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --fs-xs: .75rem;                                     /* 12  labels, notes */
  --fs-s: .875rem;                                     /* 14  meta, buttons */
  --fs-m: 1rem;                                        /* 16  body */
  --fs-l: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem);    /* list titles */
  --fs-xl: clamp(2.25rem, 1.4rem + 3.4vw, 3.75rem);    /* page titles */

  /* space and layout */
  --gutter-l: clamp(16px, 5vw, 72px);
  --gutter-r: clamp(16px, 9vw, 140px);                 /* wider on the right: the page leans left */
  --label-w: 10rem;
  --col-gap: 2rem;
  --grid-gap: 8px;                                     /* read by layoutGrid() */
}
@media (max-width: 759px) { :root { --gutter-r: var(--gutter-l); } }   /* phones: symmetrical gutters */
@media (min-width: 760px) { :root { --grid-gap: 12px; } }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #1C1A17;
    --surface: #24211D;
    --ink: #ECE6DC;
    --muted: #A69D91;
    --hairline: #3A352F;
    --line-strong: #7B7266;
    --accent: #D08C68;
    --accent-hover: #E0A07D;
    --accent-ink: #1C1A17;
    --placeholder: #2B2723;
    --grain-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .93 0 0 0 0 .9 0 0 0 0 .86 0 0 0 2.2 -.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --grain-opacity: .045;
  }
}

/* =========================================================
   2. BASE / TYPOGRAPHY
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--fs-m)/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
/* Grain sits behind all content (z-index -1), so it never touches photos. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--grain-image);
  background-size: 240px 240px;
  opacity: var(--grain-opacity);
}
h1, h2, p, ul, figure { margin: 0; padding: 0; }
ul { list-style: none; }
img { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.label {
  font: 500 var(--fs-xs)/1.4 var(--font-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* =========================================================
   3. LAYOUT
   One left-leaning column: [label | main]. The page is not centred.
   ========================================================= */
.wrap {
  max-width: 1360px;
  padding-inline: var(--gutter-l) var(--gutter-r);
}
.site-header { padding-block: 1.5rem 0; }
.site-name {
  font: 400 var(--fs-m)/1.2 var(--font-serif);   /* Newsreader is only self-hosted at 400 */
  color: var(--ink);
  text-decoration: none;
}
.site-name span { font-style: italic; color: var(--muted); }
.site-name:hover { color: var(--accent); }

.screen { padding-block: clamp(3rem, 8vw, 6.5rem) clamp(3rem, 8vw, 6rem); }

.split { display: grid; row-gap: 1rem; }
@media (min-width: 760px) {
  .split { grid-template-columns: var(--label-w) minmax(0, 1fr); column-gap: var(--col-gap); row-gap: 0; }
}
.split__main { max-width: 40rem; min-width: 0; }

.site-footer { padding-block: 0 2.5rem; }
.site-footer p { font-size: var(--fs-xs); color: var(--muted); max-width: 40rem; }

/* =========================================================
   4. COMPONENTS
   ========================================================= */

/* --- buttons and quiet links --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .6em 1.25em;
  border: 0; border-radius: 2px;
  background: var(--accent); color: var(--accent-ink);
  font: 500 var(--fs-s)/1.2 var(--font-ui);
  cursor: pointer;
  transition: background-color .15s ease;
}
.btn:hover { background: var(--accent-hover); }
/* .btn is also used on links: keep the label colour and no underline */
a.btn, a.btn:hover { color: var(--accent-ink); text-decoration: none; }
.back {
  display: inline-block;
  font: 500 var(--fs-s)/1.4 var(--font-ui);
  text-decoration: none;
}
.back:hover { text-decoration: underline; }

/* --- event list --- */
.intro-line {
  font: italic 400 var(--fs-m)/1.5 var(--font-serif);
  font-size: 1.25rem;
  max-width: 28rem;
}
.event-list { max-width: 66rem; margin-top: clamp(2.5rem, 6vw, 4.5rem); border-bottom: 1px solid var(--hairline); }
.event-list li { border-top: 1px solid var(--hairline); }
.event-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title open" "meta meta";
  column-gap: 1rem; row-gap: .5rem;
  padding-block: 1.25rem 1.375rem;
  color: var(--ink);
  text-decoration: none;
}
.event-row__title { grid-area: title; font: 400 var(--fs-l)/1.15 var(--font-serif); letter-spacing: -.01em; }
.event-row__meta { grid-area: meta; display: flex; gap: 1.25rem; font-size: var(--fs-s); line-height: 1.4; }
.event-row__meta .count { color: var(--muted); }
.event-row__open { grid-area: open; align-self: start; padding-top: .5rem; font-size: var(--fs-s); color: var(--muted); white-space: nowrap; }
.event-row__open span { display: inline-block; transition: transform .2s ease; }
.event-row:hover .event-row__title,
.event-row:hover .event-row__open { color: var(--accent); }
.event-row:hover .event-row__open span { transform: translateX(3px); }
.event-row:focus-visible { outline-offset: -2px; }
@media (min-width: 760px) {
  .event-row {
    grid-template-columns: var(--label-w) minmax(0, 1fr) auto;
    grid-template-areas: "meta title open";
    column-gap: var(--col-gap);
    align-items: baseline;
    padding-block: 1.5rem 1.625rem;
  }
  .event-row__meta { flex-direction: column; gap: .125rem; }
  .event-row__open { align-self: baseline; padding-top: 0; }
}

/* --- password gate --- */
.gate-title, .gallery-title {
  font: 400 var(--fs-xl)/1.05 var(--font-serif);
  letter-spacing: -.015em;
}
.gate-meta, .gallery-meta { margin-top: 1rem; font-size: var(--fs-s); color: var(--muted); }
.gate-form { margin-top: 2.5rem; max-width: 22rem; }
.gate-form label { display: block; margin-bottom: .5rem; font: 500 var(--fs-s)/1.3 var(--font-ui); }
.field { position: relative; }
.field input {
  width: 100%; min-height: 48px;
  padding: .5rem 4.5rem .5rem .875rem;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--surface); color: var(--ink);
  font: 400 var(--fs-m)/1.4 var(--font-ui);
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field input[aria-invalid="true"] { border-color: var(--accent); outline: 1px solid var(--accent); outline-offset: -2px; }
.field input[aria-invalid="true"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field__toggle {
  position: absolute; top: 0; right: 0; bottom: 0;
  min-width: 4rem; padding: 0 .875rem;
  border: 0; background: none;
  font-size: var(--fs-s); font-weight: 500; color: var(--accent);
  cursor: pointer;
}
.field__toggle:hover { color: var(--accent-hover); }
.field__toggle:focus-visible { outline-offset: -4px; }
.gate-error { min-height: 1.55em; margin-top: .625rem; font-size: var(--fs-s); color: var(--ink); }
.gate-form .btn { margin-top: .75rem; }

/* --- gallery head --- */
.gallery-head .btn { margin-top: 2rem; }

/* --- empty list (real site only) --- */
.empty { margin-top: clamp(2.5rem, 6vw, 4.5rem); color: var(--muted); }

/* --- masonry grid (positions are set by layoutGrid(); CSS only sets the stage) --- */
.grid { position: relative; margin-top: clamp(2.5rem, 6vw, 4rem); }
.grid__item { position: absolute; top: 0; left: 0; margin: 0; }
.grid__link { display: block; width: 100%; height: 100%; background: var(--placeholder); }
.grid__img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s ease; }
.grid__img.is-loaded { opacity: 1; }
.grid__link:hover .grid__img.is-loaded { opacity: .9; }
.grid__link:focus-visible { outline-offset: 2px; }

/* --- lightbox: overrides on top of vendor/lightbox3.css (linked first). The backdrop stays dark in both themes. --- */
.lightbox3-overlay {
  --lb-backdrop-color: rgba(22, 20, 17, .96);
  --lb-chrome-bg: rgba(30, 28, 25, .94);
  --lb-chrome-text: #ECE6DC;
  --lb-chrome-font-size: 14px;
  --lb-chrome-border-radius: 3px;
  --lb-image-border-radius: 0;
  --lb-link: #E0A07D;
  font-family: var(--font-ui);
}
.lightbox3-chrome {
  -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: none;
  font-weight: 400; letter-spacing: 0;
}
.lightbox3-counter { color: #B5ACA0; font-variant-numeric: tabular-nums; }
.lightbox3-caption { color: #ECE6DC; }
.lightbox3-caption .lb-name { font-variant-numeric: tabular-nums; white-space: nowrap; }
.lightbox3-caption .lb-name { margin-right: .875em; }   /* gap sits after the name so a wrapped second line is not indented */
.lightbox3-caption .lb-dl { color: var(--lb-link); text-underline-offset: .2em; white-space: nowrap; }
@media (max-width: 600px) { .lightbox3-caption .lb-name { margin-right: .5em; } }
.lightbox3-caption .lb-dl:hover { color: #F0B896; }
.lightbox3-caption .lb-dl:focus-visible { outline: 2px solid var(--lb-link); outline-offset: 3px; }
.lightbox3-close, .lightbox3-arrow {
  border-radius: 3px; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.lightbox3-arrow { background: rgba(30, 28, 25, .8); }
.lightbox3-arrow:hover { background: rgba(30, 28, 25, .96); }
.lightbox3-close:focus-visible, .lightbox3-arrow:focus-visible { outline-color: var(--lb-link); }

/* --- lightbox: photo details behind the small "i" button (lives in the caption HTML, see html.ts) --- */
.lightbox3-caption .lb-actions { white-space: nowrap; }
.lightbox3-caption .lb-info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin: 0 0 0 .5em; padding: 0; vertical-align: middle;
  border: 1px solid rgba(236, 230, 220, .4); border-radius: 3px; background: none;
  font: italic 400 16px/1 var(--font-serif); color: #B5ACA0; cursor: pointer;
}
.lightbox3-caption .lb-info-btn:hover { color: #ECE6DC; border-color: #ECE6DC; }
.lightbox3-caption .lb-info-btn[aria-expanded="true"] { color: #ECE6DC; border-color: #ECE6DC; background: rgba(236, 230, 220, .12); }
.lightbox3-caption .lb-info-btn:focus-visible { outline: 2px solid var(--lb-link); outline-offset: 2px; }
.lightbox3-caption .lb-info { display: none; margin-top: .75em; font-size: 13px; line-height: 1.45; color: #B5ACA0; font-variant-numeric: tabular-nums; }
.lb-info-open .lightbox3-caption .lb-info { display: block; }
.lightbox3-caption .lb-info__line { display: block; }
