/* Hendershott Collection: a private register of ethnographic art.
   Dark slate gallery wall, softly lit mats under every photograph, trade-cloth blue for interaction,
   yellow ochre reserved for price changes. */

:root {
  --wall: #1e2329;
  --wall-deep: #2a3038;
  --field: #262c33;
  --mat: #eceeef;
  --ink: #e7e9eb;
  --ink-soft: #9ea6ae;
  --rule: #3b434c;
  --indigo: #9db4ec;
  --indigo-dark: #c3d2f5;
  --on-accent: #16202f;
  --ochre: #d9a441;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: 2.75rem;

  --gutter: clamp(1rem, 3vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--wall); color: var(--ink); color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--indigo); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--indigo-dark); text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }

h1, h2 { font-weight: 500; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip { position: absolute; left: -999px; top: 0; background: var(--field); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }

button, select, input { font: inherit; color: inherit; }

/* ---- Masthead ---------------------------------------------------------- */

.masthead {
  display: grid;
  grid-template-columns: auto minmax(12rem, 32rem) auto;
  align-items: center;
  gap: 1rem 2rem;
  padding: 1.25rem var(--gutter);
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-size: var(--step-2);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  line-height: 1;
}
.wordmark span { font-weight: 400; font-style: italic; color: var(--ink-soft); }

.search { display: flex; font-family: var(--sans); }
.search input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--rule);
  border-right: 0;
  background: var(--field);
  border-radius: 3px 0 0 3px;
}
.search button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--indigo);
  background: var(--indigo);
  color: var(--on-accent);
  font-weight: 600;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
}
.search button:hover { background: var(--indigo-dark); }

.primary { display: flex; gap: 1.5rem; font-family: var(--sans); justify-self: end; }
.primary a { color: var(--ink); text-decoration: none; padding-block: 0.25rem; border-bottom: 2px solid transparent; }
.primary a:hover, .primary a[aria-current] { border-bottom-color: var(--indigo); }

/* ---- Browse layout ------------------------------------------------------- */

.browse {
  display: grid;
  grid-template-columns: 15.5rem 1fr;
  gap: var(--gutter);
  padding: 2rem var(--gutter) 4rem;
}

.index {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  font-family: var(--sans);
  font-size: var(--step--1);
  padding-right: 0.5rem;
}
.index a {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
}
.index a span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.index a:hover { background: var(--wall-deep); }
.index a[aria-current] { background: var(--ink); color: var(--wall); }
.index a[aria-current] span { color: var(--wall-deep); }
.index-all { font-weight: 600; margin-bottom: 0.75rem; }

.region { border-top: 1px solid var(--rule); padding-block: 0.5rem; }
.region summary { list-style: none; cursor: pointer; }
.region summary::-webkit-details-marker { display: none; }
.region summary a { font-family: var(--serif); font-size: var(--step-1); font-weight: 500; }
.region ul { list-style: none; margin: 0.25rem 0 0; padding: 0 0 0 0.75rem; }

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--ink);
}
.count { margin: 0.35rem 0 0; font-family: var(--sans); color: var(--ink-soft); font-size: var(--step--1); }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; font-family: var(--sans); font-size: var(--step--1); }
.filters label { display: grid; gap: 0.2rem; color: var(--ink-soft); }
.filters select { padding: 0.4rem 0.5rem; border: 1px solid var(--rule); background: var(--field); border-radius: 3px; max-width: 14rem; }
.filters button, .empty a {
  padding: 0.45rem 0.9rem; border: 1px solid var(--ink); background: transparent; border-radius: 3px; cursor: pointer;
}
.filters button:hover { background: var(--ink); color: var(--wall); }

.active-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-family: var(--sans); font-size: var(--step--1); margin: 1rem 0 0; }

.group-heading {
  font-size: var(--step-1);
  margin: 2.5rem 0 1rem;
  color: var(--ink-soft);
  font-style: italic;
  font-weight: 400;
}

/* ---- Object plates: the photograph on a white mat, a museum label beneath ---- */

.plates {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 2.25rem 1.5rem;
}
.group-heading + .plates { margin-top: 0; }

.plate a { display: grid; gap: 0.7rem; color: var(--ink); text-decoration: none; }
.mat {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--mat);
  display: grid;
  place-items: center;
  box-shadow: 0 1px 0 var(--rule);
  overflow: hidden;
}
.mat img { position: absolute; inset: 0.9rem; width: calc(100% - 1.8rem); height: calc(100% - 1.8rem); object-fit: contain; }
.plate a:hover .mat { outline: 2px solid var(--indigo); outline-offset: -2px; }
.plate a:hover .label-title { text-decoration: underline; text-underline-offset: 0.18em; }
.no-photo { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); text-align: center; padding: 1rem; }

.label { display: grid; gap: 0.15rem; }
.label-title { font-size: var(--step-1); line-height: 1.25; }
.label-meta { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.label-price { font-family: var(--sans); font-size: var(--step--1); font-weight: 600; font-variant-numeric: tabular-nums; }

.plates-small { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }

.pager { display: flex; justify-content: center; gap: 2rem; margin-top: 3rem; font-family: var(--sans); }

.empty { padding: 3rem 0; font-size: var(--step-1); }
.empty a { display: inline-block; color: var(--ink); text-decoration: none; font-family: var(--sans); font-size: var(--step--1); }

/* ---- Object page ------------------------------------------------------- */

.object { padding: 1.5rem var(--gutter) 4rem; max-width: 84rem; margin-inline: auto; }

.crumbs { font-family: var(--sans); font-size: var(--step--1); display: flex; gap: 0.5rem; color: var(--ink-soft); margin-bottom: 1.5rem; }

.object-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}

.gallery { position: sticky; top: 1rem; }
.gallery-main {
  display: grid; place-items: center; width: 100%;
  background: var(--mat); border: 0; padding: clamp(1rem, 3vw, 2.5rem);
  cursor: zoom-in; min-height: 20rem;
}
.gallery-main img { max-height: 72vh; width: auto; height: auto; object-fit: contain; }
.gallery-thumbs { list-style: none; padding: 0; margin: 0.75rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gallery-thumbs button { width: 4.5rem; height: 4.5rem; padding: 0.25rem; background: var(--mat); border: 2px solid transparent; cursor: pointer; }
.gallery-thumbs button[aria-current] { border: 2px solid var(--indigo); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: contain; }
.gallery-empty { background: var(--wall-deep); padding: 4rem 2rem; text-align: center; color: var(--ink-soft); font-style: italic; }

.object-text h1 { font-size: clamp(2rem, 3.5vw, var(--step-4)); max-width: 22ch; }
.flag { font-family: var(--sans); font-size: var(--step--1); color: var(--ochre);
        border: 1px solid var(--ochre); border-radius: 3px; padding: 0.4rem 0.7rem; display: inline-block; }
.subtitle { font-size: var(--step-1); font-style: italic; color: var(--ink-soft); margin: 0.5rem 0 0; }

.price { font-family: var(--sans); font-size: var(--step-3); font-weight: 500; margin: 1.5rem 0 0; font-variant-numeric: tabular-nums; }
.price-note { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin: 0.2rem 0 0; }

.facts {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.6rem 1rem;
  margin: 1.75rem 0; padding: 1.25rem 0; border-block: 1px solid var(--rule);
}
.facts dt { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); padding-top: 0.15rem; }
.facts dd { margin: 0; white-space: pre-line; }

.prose { max-width: 38rem; }
.prose p { margin: 0 0 1em; line-height: 1.65; }

/* Price history: the one sequence on the page, drawn as a dated line. */
.history { margin-top: 4rem; }
.history h2 { margin-bottom: 1.5rem; }
.timeline {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(12rem, 1fr);
  overflow-x: auto; position: relative;
}
.timeline li { position: relative; padding: 1.75rem 1.5rem 0 0; display: grid; gap: 0.2rem; align-content: start; }
.timeline li::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0.45rem; height: 2px; background: var(--ink);
}
.timeline li::after {
  content: ""; position: absolute; left: 0; top: 0; width: 1rem; height: 1rem;
  border-radius: 50%; background: var(--wall); border: 2px solid var(--ink);
}
.timeline li:last-child::before { right: auto; width: 1rem; }
.timeline li.up::after, .timeline li.down::after { background: var(--ochre); border-color: var(--ochre); }
.timeline time { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.t-price { font-family: var(--sans); font-size: var(--step-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.up .t-price, .down .t-price { color: var(--ochre); }
.t-catalog { font-size: var(--step-0); }
.t-ref { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }

.related { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--rule); }

/* ---- Catalogs and reading ----------------------------------------------- */

.page-wide { padding: 2rem var(--gutter) 4rem; max-width: 84rem; margin-inline: auto; }
.page-narrow { padding: 2rem var(--gutter) 4rem; max-width: 46rem; margin-inline: auto; }
.lede { font-size: var(--step-1); color: var(--ink-soft); max-width: 40rem; margin: 0.75rem 0 2rem; }

.catalog-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 2.5rem 1.75rem; }
.catalog-list a { display: grid; gap: 0.4rem; color: var(--ink); text-decoration: none; }
.cover { position: relative; background: var(--mat); aspect-ratio: 4 / 3; overflow: hidden; }
.cover img { position: absolute; inset: 0.75rem; width: calc(100% - 1.5rem); height: calc(100% - 1.5rem); object-fit: contain; }
.catalog-title { font-size: var(--step-1); }
.catalog-list a:hover .catalog-title { text-decoration: underline; }
.catalog-meta { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }

.viewer { margin: 1rem 0 2.5rem; scroll-margin-top: 1rem; }
.viewer-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  font-family: var(--sans); font-size: var(--step--1); padding: 0.75rem 0;
}
.viewer-bar a[rel="next"] { justify-self: end; }
.viewer-bar form { display: flex; gap: 0.4rem; align-items: center; }
.viewer-bar select { padding: 0.25rem; border: 1px solid var(--rule); background: var(--field); }
.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1.5rem; align-items: start; }
.page-scan { width: 100%; background: var(--mat); }
.on-page h2 { font-size: var(--step-1); margin-bottom: 0.5rem; }
.on-page ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.on-page li span { display: block; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.on-page p { color: var(--ink-soft); font-style: italic; margin: 0; }

.catalog-articles { margin-bottom: 2.5rem; }

.contents { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.contents th { font-family: var(--sans); font-size: var(--step--1); font-weight: 500; color: var(--ink-soft); text-align: left; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--ink); }
.contents td { padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.contents td:first-child, .contents td:nth-child(2) { font-family: var(--sans); font-size: var(--step--1); white-space: nowrap; }
.contents .num { text-align: right; font-family: var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; }

.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li { border-top: 1px solid var(--rule); }
.article-list a {
  display: grid; grid-template-columns: 1fr 6rem; grid-template-areas: "title img" "source img" "excerpt img";
  gap: 0.2rem 1.5rem; padding: 1.25rem 0; color: var(--ink); text-decoration: none;
}
.article-list img { grid-area: img; width: 6rem; height: 6rem; object-fit: cover; }
.article-title { grid-area: title; font-size: var(--step-2); }
.article-list a:hover .article-title { text-decoration: underline; text-underline-offset: 0.15em; }
.article-source { grid-area: source; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.article-excerpt { grid-area: excerpt; color: var(--ink-soft); }

.essay h1 { font-size: clamp(2rem, 4vw, var(--step-4)); }
.essay .article-source { display: block; margin: 0.5rem 0 2rem; }
.essay .prose { font-size: var(--step-1); }
.essay-images { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.75rem; }
.essay-images button { width: 100%; aspect-ratio: 1; padding: 0.4rem; background: var(--mat); border: 0; cursor: zoom-in; }
.essay-images img { width: 100%; height: 100%; object-fit: contain; }

.colophon { border-top: 1px solid var(--rule); padding: 1.5rem var(--gutter) 2.5rem; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.colophon p { margin: 0; }

/* ---- Lightbox ------------------------------------------------------------ */

.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; padding: 0;
  background: rgba(12, 14, 17, 0.97); color: var(--ink);
  grid-template-columns: 5rem 1fr 5rem; align-items: center;
}
.lightbox[open] { display: grid; }
.lightbox::backdrop { background: transparent; }
/* Fixed placements: a hidden Previous button must not let the photo fall into the narrow arrow column. */
.lightbox figure { grid-column: 2; grid-row: 1; margin: 0; display: grid; justify-items: center; align-content: center; gap: 0.75rem; min-width: 0; height: 100%; }
.lightbox img { width: auto; height: auto; max-width: 100%; max-height: 88vh; object-fit: contain; cursor: zoom-out; }
.lb-prev { grid-column: 1; grid-row: 1; }
.lb-next { grid-column: 3; grid-row: 1; }
.lightbox figcaption { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.lightbox button { background: none; border: 0; color: var(--ink); font-family: var(--sans); cursor: pointer; padding: 1rem; }
.lightbox button:hover { text-decoration: underline; }
.lb-close { position: absolute; top: 0.5rem; right: 0.75rem; }

/* ---- Small screens ------------------------------------------------------ */

@media (max-width: 900px) {
  .masthead { grid-template-columns: minmax(0, 1fr) auto; }
  .search { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .browse { grid-template-columns: 1fr; }
  .index { position: static; max-height: none; border-bottom: 1px solid var(--ink); padding-bottom: 1rem; }
  .region:not([open]) ul { display: none; }
  .object-layout { grid-template-columns: 1fr; }
  .gallery { position: static; }
  .viewer-body { grid-template-columns: 1fr; }
  .lightbox { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; }
  .lightbox figure { grid-column: 1 / -1; grid-row: 1; }
  .lb-prev { grid-column: 1; grid-row: 2; justify-self: start; }
  .lb-next { grid-column: 2; grid-row: 2; justify-self: end; }
}

@media (max-width: 520px) {
  h1 { font-size: var(--step-3); }
  .masthead { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .wordmark { font-size: var(--step-1); }
  .primary { gap: 1.25rem; justify-self: start; grid-row: 2; }
  .search { grid-row: 3; }
  .plates { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem 1rem; }
  .facts { grid-template-columns: 1fr; }
  .contents td:nth-child(2), .contents th:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

body.centred { display: grid; place-items: center; min-height: 100vh; }
.card { background: var(--field); padding: 2.5rem; border-radius: 4px; width: min(26rem, 90vw); }
.card h1 { font-size: var(--step-2); margin-bottom: 0.5rem; }
.card h1 span { font-style: italic; color: var(--ink-soft); }
.card form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.card label { display: grid; gap: 0.3rem; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.card input { padding: 0.55rem 0.7rem; border: 1px solid var(--rule); background: var(--wall); border-radius: 3px; }
.card button { padding: 0.6rem; border: 0; border-radius: 3px; background: var(--indigo); color: var(--on-accent);
               font-family: var(--sans); font-weight: 600; cursor: pointer; }
.error { color: var(--ochre); font-family: var(--sans); font-size: var(--step--1); }
.signed-in { display: flex; align-items: center; gap: 0.5rem; font-family: var(--sans); font-size: var(--step--1); }
.signed-in button { background: none; border: 0; color: var(--indigo); cursor: pointer; text-decoration: underline; }

.admin-form form { display: grid; gap: 1.25rem; margin-top: 2rem; }
.admin-form label { display: grid; gap: 0.3rem; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.admin-form input, .admin-form select, .admin-form textarea {
  padding: 0.5rem 0.7rem; border: 1px solid var(--rule); background: var(--field); border-radius: 3px;
  font-family: var(--serif); font-size: var(--step-0); color: var(--ink); }
.admin-form label.check { display: flex; align-items: center; gap: 0.5rem; }
.admin-form button[type="submit"] { justify-self: start; padding: 0.6rem 1.4rem; border: 0; border-radius: 3px;
  background: var(--indigo); color: var(--on-accent); font-family: var(--sans); font-weight: 600; cursor: pointer; }
.reverted { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin: -0.75rem 0 0; }
.reverted button { background: none; border: 0; color: var(--indigo); text-decoration: underline; cursor: pointer; }
.photo-edit { list-style: none; padding: 0; display: grid; gap: 1rem; }
.photo-edit li { display: grid; grid-template-columns: 5rem repeat(3, auto) 1fr; gap: 1rem; align-items: center; }
.photo-edit img { width: 5rem; height: 5rem; object-fit: contain; background: var(--mat); }
.hidden-form { display: none; }
.notice { font-family: var(--sans); color: var(--indigo); }
.admin-link { font-family: var(--sans); font-size: var(--step--1); margin: 0.5rem 0 0; }

.stat-row { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 2.5rem; margin: 1.5rem 0;
            font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.stat-row strong { display: block; font-family: var(--serif); font-size: var(--step-3); color: var(--ink); font-weight: 500; }
form.inline { display: inline; }
.account-help, .account-meta { color: var(--ink-soft); font-family: var(--sans); font-size: var(--step--1); }
.account-list { list-style: none; margin: 1rem 0 3rem; padding: 0; display: grid; gap: 1rem; }
.account-card { border: 1px solid var(--rule); border-radius: 4px; padding: 1rem 1.25rem; }
.account-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.account-heading h2 { font-size: var(--step-1); }
.account-meta { margin: 0.5rem 0; }
.account-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; }
.account-controls form { display: flex; align-items: end; gap: 0.75rem; margin: 0; }
.account-controls button, .account-password button { padding: 0.45rem 0.8rem; border: 1px solid var(--rule); border-radius: 3px; background: var(--field); cursor: pointer; }
.account-password { margin-top: 0.75rem; font-family: var(--sans); font-size: var(--step--1); }
.account-password summary { cursor: pointer; color: var(--indigo); }
.account-password form { max-width: 24rem; }
.admin-item-search { margin: 1rem 0; max-width: 40rem; }
.admin-item-search label { display: block; margin-bottom: 0.35rem; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.admin-item-search div { display: flex; gap: 0.5rem; align-items: center; }
.admin-item-search input { flex: 1; min-width: 0; padding: 0.5rem 0.7rem; border: 1px solid var(--rule); background: var(--field); border-radius: 3px; }
.admin-item-search button { padding: 0.5rem 0.9rem; border: 0; border-radius: 3px; background: var(--indigo); color: var(--on-accent); cursor: pointer; }
.admin-items td:first-child { white-space: normal; }
