/* CGMs Photo — public styles. Plain CSS, no framework; only widely supported features. */
:root {
  --accent: #2f6f4f;
  --bg: #fbfaf7;
  --fg: #1c1c1a;
  --muted: #6b6a64;
  --line: #e4e1da;
  --card: #ffffff;
  --max: 1100px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1 0 auto; width: 100%; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.2; }

a { color: inherit; text-decoration: none; background-image: linear-gradient(currentColor, currentColor);
    background-size: 0 1px; background-position: 0 100%; background-repeat: no-repeat;
    transition: background-size .2s ease, color .2s ease; }
a:hover, a:focus-visible { color: var(--accent); background-size: 100% 1px; }
a[aria-current] { color: var(--accent); background-size: 100% 1px; }
a:has(img), .feed-link, .tl-link, .tile, .photo-zoom { background-image: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.count { color: var(--muted); font-size: .8em; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 4rem 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--bg); padding: .5rem 1rem; z-index: 2000; }
.skip:focus { left: 0; }

/* Buttons that must exist (form submits) look like clickable text */
.text-button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; border-bottom: 1px solid transparent; border-radius: 0;
}
.text-button:hover, .text-button:focus-visible { color: var(--accent); border-bottom-color: currentColor; }
.text-button.strong { font-weight: 600; color: var(--accent); }

/* Header */
.site-header {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 2rem;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); background: var(--bg);
}
.brand { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.site-title { font-family: var(--serif); font-size: 1.5rem; letter-spacing: .01em; }
.tagline { color: var(--muted); font-size: .9rem; }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; align-items: baseline; font-size: .95rem; letter-spacing: .02em; }
.site-nav .lang { color: var(--muted); font-size: .8rem; letter-spacing: .08em; }
.site-nav form.inline { display: inline; }

.site-footer {
  display: flex; justify-content: space-between; gap: 1rem; padding: 2rem clamp(1rem, 4vw, 2.5rem);
  color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 3rem;
}

.prose { max-width: 42rem; }
.prose p { margin: 0 0 1em; }
.narrow { margin: 3rem auto; padding: 0 1rem; }

/* Captions */
.caption, .tl-cap { margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .1rem .6rem; align-items: baseline; }
.cap-main { font-family: var(--serif); font-size: 1.15rem; }
.cap-species { color: var(--fg); }
.cap-sci { color: var(--muted); }
.cap-meta { color: var(--muted); font-size: .875rem; flex-basis: 100%; }

/* Scroll feed */
.feed-page { padding: 2rem clamp(.75rem, 3vw, 2rem); }
.feed { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: clamp(2.5rem, 7vw, 5rem); }
.feed-item { margin: 0; }
.feed-img { width: 100%; background: var(--line); }
.feed-more { text-align: center; display: flex; gap: 2rem; justify-content: center; margin: 3rem 0 1rem; color: var(--muted); }
.feed-more.loading::after { content: "…"; }

/* Timeline */
.timeline-page { padding: 2rem clamp(.75rem, 3vw, 2rem); }
.timeline { max-width: var(--max); margin: 0 auto; display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 2.5rem; }
.rail { position: -webkit-sticky; position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow-y: auto; }
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail-year { margin: 0 0 .35rem; font-family: var(--serif); font-size: 1.15rem; }
.rail-year.is-current > a { color: var(--accent); }
.rail-months { margin: .35rem 0 .75rem !important; padding-left: .9rem !important; border-left: 1px solid var(--line); font-family: var(--font); font-size: .9rem; }
.rail-months li { margin: .15rem 0; }
.rail-months a { text-transform: capitalize; }
.rail-months a.is-active { color: var(--accent); background-size: 100% 1px; }
.tl-year { font-size: 2.5rem; margin: 0 0 1rem; }
.tl-month { scroll-margin-top: 1rem; position: relative; padding-left: 1.5rem; border-left: 1px solid var(--line); padding-bottom: 1.5rem; }
.tl-month-title { font-size: 1.4rem; margin: 0 0 1rem; position: relative; }
.tl-month-title::before { content: ""; position: absolute; left: calc(-1.5rem - 5px); top: .45em; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.tl-items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.75rem 1.25rem; }
.tl-item { margin: 0; }
.tl-date { display: block; font-size: .8rem; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: .35rem; }
.tl-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line); }
.tl-cap { font-size: .95rem; }

/* Map */
body.full-height { height: 100vh; height: 100dvh; min-height: 0; }
.map-page { display: flex; flex-direction: column; min-height: 0; }
.map { flex: 1 1 auto; min-height: 360px; width: 100%; background: #e9eef0; }
.map-popup { display: block; width: 180px; font: 14px/1.4 var(--font); color: var(--fg); }
.map-popup img { width: 180px; height: 120px; object-fit: cover; margin-bottom: .4rem; background: var(--line); }
.map-popup .muted { font-size: .8rem; }
.leaflet-container { font-family: var(--font); }
.leaflet-container a.map-popup { color: var(--fg); background-image: none; }
.leaflet-container a.map-popup:hover strong { color: var(--accent); }
.map-reset { background: #fff; padding: .25rem .6rem; font: 13px var(--font); border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* Search */
.search-page { padding: 2rem clamp(.75rem, 3vw, 2rem); max-width: var(--max); margin: 0 auto; }
.search-form { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: flex-end; }
.search-main { flex: 1 1 20rem; }
.search-main input { width: 100%; font: inherit; font-family: var(--serif); font-size: 1.6rem; border: 0; border-bottom: 1px solid var(--fg); background: transparent; padding: .25rem 0; border-radius: 0; -webkit-appearance: none; appearance: none; color: var(--fg); }
.search-main input:focus { outline: none; border-bottom-color: var(--accent); }
.search-more { flex-basis: 100%; order: 3; }
.search-more summary { cursor: pointer; color: var(--muted); font-size: .9rem; list-style: none; display: inline-block; }
.search-more summary::-webkit-details-marker { display: none; }
.search-more summary::before { content: "+ "; }
.search-more[open] summary::before { content: "− "; }
.search-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .75rem 1.25rem; margin-top: .75rem; }
.search-fields label, .edit-form label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; letter-spacing: .02em; }
input, textarea, select { font: inherit; color: var(--fg); }
.search-fields input, .edit-form input:not([type=checkbox]):not([type=radio]):not([type=color]), .edit-form textarea, .edit-form select {
  border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: .3rem 0; border-radius: 0; font-size: 1rem; width: 100%; min-width: 0;
}
.search-fields input:focus, .edit-form input:focus, .edit-form textarea:focus, .edit-form select:focus { outline: none; border-bottom-color: var(--accent); }
.active-filters { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin: 1.5rem 0 0; font-size: .9rem; }
.search-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 2.5rem; margin-top: 2rem; }
.facet h2 { font-size: 1rem; font-family: var(--font); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 .4rem; }
.facet ul { list-style: none; margin: 0 0 1.5rem; padding: 0; font-size: .92rem; }
.facet li { margin: .15rem 0; }
.result-count { color: var(--muted); margin: 0 0 1rem; font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.25rem 1rem; }
.tile { display: block; }
.tile-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--line); transition: opacity .2s; }
.tile:hover .tile-img { opacity: .88; }
.tile-cap { display: block; font-size: .875rem; margin-top: .35rem; }
.pager { display: flex; gap: 1.5rem; justify-content: center; margin: 2.5rem 0 0; }

/* Photo detail */
.photo-page { padding: 0 0 2rem; }
.photo-figure { margin: 0; background: #111; display: flex; justify-content: center; }
.photo-zoom { display: block; cursor: zoom-in; }
.photo-img { max-height: 86vh; width: auto; max-width: 100%; object-fit: contain; }
.photo-nav { max-width: var(--max); margin: 1rem auto 0; padding: 0 1rem; display: flex; justify-content: space-between; font-size: .95rem; }
.photo-info { max-width: var(--max); margin: 1.5rem auto 0; padding: 0 1rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem 3rem; }
.photo-info header, .photo-info .prose { grid-column: 1 / -1; }
.photo-info h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; }
.photo-info .species { margin: .25rem 0 0; font-size: 1.15rem; }
.photo-info .sci { margin: .1rem 0 0; color: var(--muted); }
.meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1.25rem; margin: 0; align-content: start; }
.meta dt { color: var(--muted); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; padding-top: .15rem; }
.meta dd { margin: 0; }
.mini-map { height: 280px; background: #e9eef0; }
.lightbox { position: fixed; inset: 0; top: 0; left: 0; right: 0; bottom: 0; background: rgba(10, 10, 10, .96); z-index: 1000; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 98vw; max-height: 96vh; width: auto; height: auto; object-fit: contain; }
.lightbox-hint { position: absolute; bottom: .75rem; left: 0; right: 0; text-align: center; color: #aaa; font-size: .8rem; }
body.no-scroll { overflow: hidden; }

/* Responsive */
@media (max-width: 760px) {
  .timeline { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .rail { position: -webkit-sticky; position: sticky; top: 0; z-index: 5; background: var(--bg); max-height: none; overflow-x: auto; padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .rail-years { display: flex; gap: 1rem; white-space: nowrap; }
  .rail-year { display: flex; gap: .75rem; align-items: baseline; margin: 0; }
  .rail-months { display: flex; gap: .75rem; border-left: 0; padding-left: 0 !important; margin: 0 !important; }
  .rail-months .count, .rail-year > .count { display: none; }
  .tl-month { padding-left: 1rem; scroll-margin-top: 4rem; }
  .tl-month-title::before { left: calc(-1rem - 5px); }
  .search-layout { grid-template-columns: minmax(0, 1fr); }
  .facets { order: 2; }
  .photo-info { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
