:root {
    --font-body: "Instrument Sans", system-ui, -apple-system, sans-serif;

    --color-bg: #faf8f4;
    --color-ink: #211f1c;
    --color-accent: #bd5b39;
    --color-wordmark-rule: rgba(33, 31, 28, 0.22);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-padding-top: 4.5rem;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-ink);
    margin: 0;
    padding: 0;
}

h1 {
    letter-spacing: 0;
}

.site-nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 40px;
    border-bottom: 1px solid rgba(33, 31, 28, 0.08);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 70;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-ink);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-ink);
    font-size: 1.3rem;
    text-decoration: none;
    white-space: nowrap;
}

.nav-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-accent);
    flex: none;
}

.nav-wordmark-name {
    font-weight: 700;
}

.nav-wordmark-rule {
    width: 1px;
    height: 1.05em;
    margin: 0 0.375rem;
    background: var(--color-wordmark-rule);
    flex: none;
}

.nav-wordmark-suffix {
    font-weight: 400;
    color: var(--color-accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    color: var(--color-ink);
    font-family: inherit;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
}

.nav-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.nav-link.active {
    color: var(--color-accent);
    font-weight: 600;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown.open .nav-dropdown-trigger {
    color: var(--color-accent);
}

.nav-caret {
    transition: transform 0.2s ease;
}

.nav-dropdown.open .nav-caret {
    transform: rotate(180deg);
}

.nav-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: #ffffff;
    border: 1px solid rgba(33, 31, 28, 0.12);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(33, 31, 28, 0.1);
    z-index: 50;
}

.nav-dropdown-panel[hidden] {
    display: none;
}

.nav-subject-link {
    padding: 8px 12px;
    border-radius: 4px;
    color: var(--color-ink);
    opacity: 0.6;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
}

.nav-subject-link:hover {
    background: rgba(33, 31, 28, 0.05);
    opacity: 0.85;
}

.nav-subject-link.active {
    color: var(--color-accent);
    opacity: 1;
    font-weight: 600;
}

.nav-subject-link--separated {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid rgba(33, 31, 28, 0.12);
}

.page-content {
    padding: 30px 40px 40px;
}

.filter-control {
    position: relative;
}

.chip-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: #5a6b5a;
    cursor: pointer;
}

.chip-icon-btn:hover {
    background-color: rgba(33, 31, 28, 0.08);
    color: var(--color-ink);
}

#clearTagsBtn[hidden] {
    display: none;
}

.filter-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    padding: 10px;
    background: #ffffff;
    border: 1px solid rgba(33, 31, 28, 0.12);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(33, 31, 28, 0.1);
    z-index: 50;
}

.filter-popover--tagFilter {
    min-width: 220px;
}

.preset-days {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.preset-day-btn {
    padding: 0.3rem 0.6rem;
    font: inherit;
    font-size: 0.8rem;
    color: var(--color-ink);
    background: white;
    border: 1px solid #ccc;
    border-radius: 1rem;
    cursor: pointer;
}

.preset-day-btn:hover {
    background-color: #f2f4f2;
}

.preset-day-btn.active {
    color: white;
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

#tagSearch,
#placeSearch {
    position: relative;
    display: block;
}

#tagSuggestions,
#placeSuggestions {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    text-align: left;
}

#tagSuggestions:empty,
#placeSuggestions:empty {
    display: none;
}

#tagSuggestions div,
#placeSuggestions div {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    cursor: pointer;
}

#tagSuggestions div:hover,
#placeSuggestions div:hover {
    background-color: #eee;
}

#tagSuggestions div.selected,
#placeSuggestions div.selected {
    background-color: #ddd;
}

#tagInput,
#placeInput {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid #ccc;
    border-radius: 6px;
}

#galleryBarSentinel {
    height: 1px;
    margin-bottom: -1px;
    pointer-events: none;
}

#galleryControls {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem 1rem;
    margin: 0 -40px calc(1rem + var(--pin-shrink, 0px));
    padding: 0.5rem 40px;
    background: var(--color-bg);
}

#galleryControls.is-pinned {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(33, 31, 28, 0.08);
    box-shadow: 0 4px 12px rgba(33, 31, 28, 0.06);
}

#galleryControls.is-pinned #photoCount {
    display: none;
}

#galleryControls.is-pinned {
    align-items: center;
}

#galleryControls.is-pinned .collection-title {
    font-size: 1.2rem;
}

#galleryControls.is-pinned .collection-intro {
    display: none;
}

.controls-main {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.6rem;
    margin-left: auto;
}

.filters-toggle {
    display: none;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.75rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a6b5a;
    background-color: #f2f4f2;
    border: 1px solid #e0e5e0;
    border-radius: 1rem;
    cursor: pointer;
}

.filters-toggle:hover,
.filters-toggle:focus-visible,
.filters-toggle[aria-expanded="true"] {
    color: var(--color-ink);
    background-color: #e0e5e0;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.sort-control {
    font-size: 0.85rem;
    color: #5a6b5a;
    font-weight: 600;
}

#sortSelect {
    padding: 0.3rem 0.5rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: normal;
    color: var(--color-ink);
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: white;
}

.shuffle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    color: #5a6b5a;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.shuffle-btn[hidden] {
    display: none;
}

.shuffle-btn:hover,
.shuffle-btn:focus-visible {
    color: var(--color-ink);
    background-color: #e0e5e0;
}

.sort-order-btn[data-order="asc"] svg {
    transform: rotate(180deg);
}

.slideshow-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.75rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a6b5a;
    background-color: #f2f4f2;
    border: 1px solid #e0e5e0;
    border-radius: 1rem;
    cursor: pointer;
}

.slideshow-btn-icon {
    height: 0.75em;
    width: auto;
}

.slideshow-btn:hover:not(:disabled),
.slideshow-btn:focus-visible {
    color: var(--color-ink);
    background-color: #e0e5e0;
}

.slideshow-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

#photoCount {
    font-size: 0.85rem;
    color: #5a6b5a;
}

.chip-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem 0.3rem 0.75rem;
    background-color: #f2f4f2;
    border: 1px solid #e0e5e0;
    border-radius: 1rem;
}

.chip-group-label {
    font-size: 0.85rem;
    color: #5a6b5a;
    font-weight: 600;
    margin-right: 0.1rem;
    cursor: default;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    background-color: #e8f0e8;
    border-radius: 1rem;
    font-size: 0.9rem;
    cursor: default;
    user-select: none;
}

.chip strong {
    margin-left: 0.35rem;
    font-weight: normal;
}

.tag-chip {
    cursor: pointer;
}

.tag-chip:hover {
    background-color: #d8e5d8;
}

.date-filter-chip {
    background-color: #e6ecf7;
}

.date-filter-chip strong {
    cursor: pointer;
}

.date-filter-chip strong:hover {
    opacity: 0.7;
}

.date-filter-icon {
    margin-right: 0.35rem;
    color: #5a6b8c;
    flex-shrink: 0;
}

.place-filter-chip {
    background-color: #f3ede2;
}

.place-filter-chip strong {
    cursor: pointer;
}

.place-filter-chip strong:hover {
    opacity: 0.7;
}

.place-filter-icon {
    margin-right: 0.35rem;
    color: #8c6f4a;
    flex-shrink: 0;
}

.about-content {
    max-width: 800px;
    margin: 2rem auto 0;
    line-height: 1.6;
}

.about-content h1 {
    margin-bottom: 1rem;
}

.places-content {
    margin: 2rem 0 0;
    line-height: 1.6;
}

.places-content h1 {
    margin-bottom: 1rem;
}

.not-found-content {
    max-width: 800px;
    margin: 2rem auto 0;
    line-height: 1.6;
}

.not-found-content h1 {
    margin-bottom: 1rem;
}

.home-view[hidden] {
    display: none;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.home-tile {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 10px;
    aspect-ratio: 3 / 2;
    background: var(--color-ink);
    color: white;
    text-decoration: none;
}

.home-tile--wide {
    aspect-ratio: 3 / 1;
    margin-bottom: 16px;
}

.home-grid > .home-tile:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    aspect-ratio: 3 / 1;
}

.home-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.home-tile-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 1.5rem 1.25rem 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
    text-align: left;
}

.home-tile-title {
    font-size: 22px;
    font-weight: 600;
}

.home-tile--wide .home-tile-title {
    font-size: 26px;
}

.home-tile-subtitle {
    font-size: 0.9rem;
    opacity: 0.85;
}

.home-tile:hover .home-tile-title {
    text-decoration: underline;
}

.home-tile:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: -3px;
}

.home-all {
    margin: 16px 0 0;
    text-align: right;
}

.home-all a {
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}

.home-all a:hover {
    text-decoration: underline;
}

.places-state h2 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.5rem;
}

.places-list {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 4 280px;
    column-gap: 2.5rem;
}

.places-list > li {
    break-inside: avoid;
    padding: 0.15rem 0;
}

.place-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.place-areas {
    list-style: none;
    margin: 0.15rem 0 0.35rem;
    padding: 0 0 0 1.25rem;
    border-left: 2px solid rgba(90, 107, 140, 0.2);
    margin-left: 0.4rem;
}

.place-areas li {
    padding: 0.1rem 0;
    font-size: 0.95rem;
}

.place-areas .place-pin svg {
    width: 18px;
    height: 18px;
}

.place-expander {
    display: inline-flex;
    padding: 0.1rem;
    border: none;
    border-radius: 4px;
    background: none;
    color: #5a6b8c;
    cursor: pointer;
}

.place-expander:hover {
    background: rgba(90, 107, 140, 0.15);
}

.place-expander svg {
    transition: transform 0.15s ease;
}

.place-expander[aria-expanded="true"] svg {
    transform: rotate(90deg);
}

.place-count {
    min-width: 1.6rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: rgba(90, 107, 140, 0.15);
    color: #5a6b8c;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.place-count:hover,
.place-count:focus-visible {
    background: #5a6b8c;
    color: #fff;
}

.place-pin {
    display: inline-flex;
    color: #5a6b8c;
}

.places-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.places-content .places-header h1 {
    margin: 0;
}

#placesMap {
    isolation: isolate;
    height: min(75vh, 860px);
    min-height: 320px;
    border: 1px solid rgba(33, 31, 28, 0.12);
    border-radius: 8px;
    background: #e8ebe6;
    font-family: var(--font-body);
}

#placesMap .leaflet-control-layers {
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

#placesMap .leaflet-control-layers label {
    cursor: pointer;
}

#placesMap .leaflet-control-layers input {
    accent-color: var(--color-accent);
    margin: 0 0.3rem 0 0;
    vertical-align: -1px;
}

.places-map-note {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    opacity: 0.6;
}

.map-pin {
    background: none;
    border: none;
    color: var(--color-accent);
}

.map-pin svg {
    display: block;
    filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

.map-pin:hover,
.map-pin:focus-visible {
    color: #5a6b8c;
}

.map-popup {
    min-width: 160px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.map-popup-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.map-popup a {
    color: #5a6b8c;
    text-decoration: none;
}

.map-popup a:hover {
    text-decoration: underline;
}

.map-popup-photos {
    font-weight: 600;
}

.map-popup-areas {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0 0 0 0.6rem;
    border-left: 2px solid rgba(90, 107, 140, 0.2);
}

.map-popup-count {
    margin-left: 0.35rem;
    font-size: 0.8rem;
    opacity: 0.75;
}

.map-popup .map-popup-external {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.8rem;
}

.collection-heading {
    flex: 1 1 20rem;
    max-width: 44rem;
}

.collection-title {
    margin: 0;
}

.collection-intro {
    margin: 0.4rem 0 0;
    line-height: 1.5;
    opacity: 0.75;
}

.equipment dt {
    margin-top: 10px;
}

.site-footer {
    padding: 22px 40px;
    border-top: 1px solid rgba(33, 31, 28, 0.08);
    text-align: center;
}

.site-footer p {
    margin: 0;
    color: var(--color-ink);
    opacity: 0.6;
    font-size: 0.9rem;
}

.site-footer a {
    color: inherit;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, max-content));
    gap: 3px;
}

.view-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background-color: #f2f4f2;
    border: 1px solid #e0e5e0;
    border-radius: 1rem;
}

.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    padding: 0;
    color: #5a6b5a;
    background: none;
    border: none;
    border-radius: 1rem;
    cursor: pointer;
}

.view-toggle-btn:hover,
.view-toggle-btn:focus-visible {
    color: var(--color-ink);
    background-color: #e0e5e0;
}

.view-toggle-btn[aria-pressed="true"] {
    color: var(--color-ink);
    background-color: #ffffff;
    box-shadow: 0 0 0 1px #e0e5e0;
}

.svg-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.photo-list {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.photo-list th {
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a6b5a;
    border-bottom: 1px solid rgba(33, 31, 28, 0.12);
    white-space: nowrap;
}

.photo-list td {
    padding: 0.4rem 0.6rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(33, 31, 28, 0.08);
}

.photo-list tbody tr:hover {
    background-color: rgba(33, 31, 28, 0.03);
}

.photo-list-sort,
.photo-list-open,
.photo-list-place-btn,
.photo-list-area-btn {
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
}

.photo-list-sort {
    display: inline-flex;
    gap: 0.3rem;
    font-weight: 600;
}

.photo-list-sort:hover,
.photo-list th[aria-sort] .photo-list-sort {
    color: var(--color-ink);
}

.photo-list-sort-arrow {
    min-width: 0.7em;
}

.photo-list .photo-list-thumb {
    width: calc(56px + 0.6rem);
    padding-left: 0;
}

.photo-list-thumb .photo-list-open {
    display: block;
}

.photo-list-thumb img {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: cover;
    background-color: #f2f4f2;
}

.photo-list-title .photo-list-open {
    font-weight: 600;
}

.photo-list-title .photo-list-open:hover,
.photo-list-species a:hover,
.photo-list-place-btn:hover,
.photo-list-area-btn:hover {
    color: var(--color-accent);
}

.photo-list-species a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
    text-decoration: none;
}

.photo-list-sci {
    display: block;
    padding-left: calc(14px + 0.35rem);
    font-size: 0.8em;
    color: rgba(33, 31, 28, 0.6);
}

.photo-list-taxon-icon {
    width: 14px;
    height: 14px;
    fill: #74ac00;
    flex-shrink: 0;
}

.photo-list-place-btn,
.photo-list-area-btn {
    display: block;
}

.photo-list-area-btn {
    font-size: 0.85rem;
    color: #5a6b5a;
}

.photo-list-date {
    white-space: nowrap;
    color: #5a6b5a;
}

.photo-list-tag {
    margin: 2px 4px 2px 0;
    padding: 0.15rem 0.55rem;
    font: inherit;
    font-size: 0.8rem;
    color: var(--color-ink);
    border: none;
    cursor: pointer;
}

.photo-list-tag:hover {
    background-color: #d8e5d8;
}

@media (max-width: 760px) {
    .photo-list,
    .photo-list tbody,
    .photo-list tr,
    .photo-list td {
        display: block;
    }

    .photo-list thead,
    .photo-list .photo-list-tags {
        display: none;
    }

    .photo-list tr {
        position: relative;
        min-height: calc(64px + 1rem);
        padding: 0.5rem 0 0.5rem calc(64px + 0.75rem);
        border-bottom: 1px solid rgba(33, 31, 28, 0.08);
    }

    .photo-list td {
        padding: 0;
        border: none;
    }

    .photo-list .photo-list-thumb {
        position: absolute;
        top: 0.5rem;
        left: 0;
        width: auto;
    }

    .photo-list-thumb img {
        width: 64px;
        height: 64px;
    }

    .photo-list-species,
    .photo-list-place,
    .photo-list-date {
        font-size: 0.85rem;
    }

    .photo-list .photo-list-place,
    .photo-list .photo-list-date,
    .photo-list-place-btn {
        display: inline;
    }

    .photo-list-place {
        color: #5a6b5a;
    }

    .photo-list-area-btn {
        display: none;
    }

    .photo-list-place:not(:empty) + .photo-list-date:not(:empty)::before {
        content: " · ";
    }
}

.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 1rem auto 3rem auto;
    text-align: center;
}

.gallery-empty[hidden] {
    display: none;
}

.gallery-empty img {
    max-width: 350px;
    width: 100%;
    height: auto;
}

.gallery-empty p {
    margin: 0;
    color: var(--color-ink);
    opacity: 0.6;
    font-size: 1.2rem;
}

.gallery-item {
    position: relative;
    display: block;
    overflow: hidden;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: linear-gradient(
        transparent,
        rgba(0,0,0,0.8)
    );
    color: white;
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item:hover .caption {
    opacity: 1;
}

.gallery-item:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: -3px;
}

.gallery-item:focus-within .caption {
    opacity: 1;
}

.slideshow {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #000;
}

.slideshow:focus {
    outline: none;
}

.slideshow--idle {
    cursor: none;
}

.slideshow--idle .slideshow-close {
    opacity: 0;
    pointer-events: none;
}

.slideshow--idle .slideshow-close:focus-visible {
    opacity: 1;
}

.slideshow-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 1500ms ease;
}

.slideshow-layer--visible {
    opacity: 1;
}

.slideshow-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding: 4rem clamp(16px, 3vw, 40px) clamp(16px, 2.5vw, 32px);
    color: #fff;
    text-align: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--slideshow-caption-fade, 800ms) ease;
}

.slideshow--caption-shown .slideshow-caption {
    opacity: 1;
}

.slideshow-caption-title {
    font-size: clamp(1rem, 1.6vw, 1.5rem);
    font-weight: 600;
}

.slideshow-caption-meta {
    margin-top: 0.2rem;
    font-size: clamp(0.85rem, 1.1vw, 1.05rem);
    color: rgba(255, 255, 255, 0.8);
}

.slideshow-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 300ms ease;
}

.slideshow-close:hover,
.slideshow-close:focus-visible {
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
}

body.slideshow-open {
    overflow: hidden;
}

.photo-content {
    max-width: 1200px;
    margin: 0.5rem auto 0;
}

.photo-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.photo-back,
.photo-pager-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.photo-back:hover,
.photo-pager-link:hover {
    text-decoration: underline;
}

.photo-pager {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
}

.photo-position {
    color: rgba(33, 31, 28, 0.6);
    font-variant-numeric: tabular-nums;
}

.photo-header {
    margin-bottom: 1.25rem;
}

.photo-header h1 {
    margin: 0.2rem 0 0.3rem;
    font-size: 2rem;
    line-height: 1.2;
}

.photo-kicker {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(33, 31, 28, 0.6);
}

.photo-place {
    margin: 0;
    font-size: 1.05rem;
}

.photo-place a {
    color: inherit;
}

.photo-place a:hover {
    color: var(--color-accent);
}

.photo-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 1.5rem;
    align-items: start;
}

.photo-stage {
    position: relative;
    aspect-ratio: 4 / 3;
    max-height: min(78vh, 820px);
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #1a1917;
    touch-action: pan-y;
}

.photo-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.photo-stage.is-loading .photo-image {
    opacity: 0.6;
}

.photo-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: photo-spin 800ms linear infinite;
    pointer-events: none;
}

.photo-spinner[hidden] {
    display: none;
}

@keyframes photo-spin {
    to {
        transform: rotate(360deg);
    }
}

.photo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
}

.photo-action {
    padding: 0;
    font: inherit;
    color: rgba(33, 31, 28, 0.6);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
}

.photo-action:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.photo-card {
    margin: 0;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid rgba(33, 31, 28, 0.1);
    border-radius: 10px;
}

.photo-card + .photo-card {
    margin-top: 1rem;
}

.photo-card[hidden] {
    display: none;
}

.photo-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}

.photo-detail--wide {
    grid-column: 1 / -1;
}

.photo-detail dt,
.photo-tags-card h2 {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: rgba(33, 31, 28, 0.6);
}

.photo-detail dd {
    margin: 0.15rem 0 0;
    font-size: 1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.photo-species {
    color: inherit;
    text-decoration: none;
}

.photo-species:hover {
    color: var(--color-accent);
}

.photo-link-out {
    width: 0.8em;
    height: 0.8em;
    margin-left: 0.25rem;
    vertical-align: -0.05em;
}

.photo-species-sci {
    display: block;
    font-size: 0.9rem;
    font-weight: 400;
}

.photo-species-sci[hidden] {
    display: none;
}

.photo-species-sci.is-italic,
.photo-list-sci.is-italic,
#photoSpeciesName.is-italic {
    font-style: italic;
}

.photo-detail-note {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(33, 31, 28, 0.6);
}

.photo-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.photo-tag {
    color: var(--color-ink);
    text-decoration: none;
    cursor: pointer;
}

.photo-tag:hover {
    background-color: #d8e5d8;
}

.photo-description {
    max-width: 760px;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(33, 31, 28, 0.12);
    line-height: 1.6;
}

.photo-description p {
    margin: 0 0 1rem;
}

.photo-video {
    margin: 0 0 1rem;
    aspect-ratio: 16 / 9;
}

.photo-video-short {
    max-width: 320px;
    aspect-ratio: 9 / 16;
}

.photo-video iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 6px;
}

@media (hover: none) {
    .caption {
        opacity: 1;
        background: linear-gradient(
            transparent,
            rgba(0, 0, 0, 0.75) 60%
        );
    }
}

@media (hover: none) and (max-width: 760px) {
    .caption,
    .gallery-item:focus-within .caption {
        display: none;
    }
}

@media (max-width: 760px) {
    .site-nav {
        padding: 16px 20px;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 20px 16px;
        background: var(--color-bg);
        border-bottom: 1px solid rgba(33, 31, 28, 0.08);
        box-shadow: 0 8px 24px rgba(33, 31, 28, 0.1);
        z-index: 60;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: 12px 0;
        border-top: 1px solid rgba(33, 31, 28, 0.08);
    }

    .nav-links > .nav-link:first-child,
    .nav-links > .nav-dropdown:first-child .nav-dropdown-trigger {
        border-top: none;
    }

    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-trigger {
        width: 100%;
        justify-content: space-between;
        border-top: 1px solid rgba(33, 31, 28, 0.08);
    }

    .nav-dropdown-panel {
        position: static;
        width: 100%;
        margin: 4px 0 8px;
        padding: 4px;
        box-shadow: none;
        border-radius: 4px;
    }

    .filter-popover {
        position: static;
        width: min(280px, calc(100vw - 40px));
        margin: 0.5rem 0 0;
        box-shadow: none;
    }

    .page-content {
        padding: 20px 20px 30px;
    }

    #galleryControls {
        margin-left: -20px;
        margin-right: -20px;
        padding-left: 20px;
        padding-right: 20px;
    }

    #galleryControls.is-pinned .collection-heading {
        display: none;
    }

    .controls-main {
        align-items: flex-start;
        margin-left: 0;
    }

    #galleryControls.is-pinned .controls-main {
        flex: 1 1 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    #galleryControls.is-pinned .filters-toggle {
        display: inline-flex;
    }

    #galleryControls.is-pinned #photoCount {
        display: block;
    }

    #galleryControls.is-pinned .controls-row {
        display: none;
        flex-basis: 100%;
    }

    #galleryControls.is-pinned.is-open .controls-row {
        display: flex;
        max-height: calc(100vh - 4.5rem);
        max-height: calc(100dvh - 4.5rem);
        overflow-y: auto;
    }

    .controls-row {
        justify-content: flex-start;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 2px;
    }

    .photo-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .photo-stage {
        max-height: 75vh;
    }

    .photo-header h1 {
        font-size: 1.6rem;
    }

    .site-footer {
        padding: 16px 20px;
    }

    .home-grid {
        gap: 12px;
    }

    .home-tile {
        aspect-ratio: 1 / 1;
    }

    .home-tile--wide,
    .home-grid > .home-tile:last-child:nth-child(odd) {
        aspect-ratio: 7 / 4;
    }

    .home-tile--wide {
        margin-bottom: 12px;
    }

    .home-tile-caption {
        padding: 1rem 0.75rem 0.65rem;
    }

    .home-tile-title {
        font-size: 15px;
    }

    .home-tile--wide .home-tile-title {
        font-size: 20px;
    }

    .home-tile-subtitle {
        font-size: 0.8rem;
    }

    .home-all {
        margin-top: 12px;
    }
}

@media (max-width: 480px) {
    .places-content,
    .not-found-content {
        margin-top: 1rem;
    }

    .about-content {
        margin-top: 1rem;
        line-height: 1.55;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

}
