/* The slideshow: the photo fills the screen, and the details, caption and controls
   float over it on frosted glass. The card and controls fold away (.is-bare). */
.field-slideshow {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 16px; border: 1px solid var(--rule-2);
    border-radius: var(--r); background: var(--ground-3); color: var(--ink);
    font: 600 0.8rem var(--body); cursor: pointer; box-shadow: var(--lift);
}
.field-slideshow:disabled { opacity: 0.45; cursor: default; }

/* A photo viewer stays dark whatever the site's theme. */
.collection-slideshow {
    --sv-ink: #f4ede1; --sv-ink-2: rgba(244, 237, 225, 0.72); --sv-amber: #e8b46a;
    --sv-glass: rgba(16, 12, 9, 0.52); --sv-edge: rgba(255, 255, 255, 0.12);
    position: fixed; inset: 0; width: 100%; max-width: none;
    height: 100%; max-height: none; margin: 0; padding: 0; border: 0;
    background: #0c0a08; color: var(--sv-ink); overflow: hidden;
}
.collection-slideshow::backdrop { background: #0c0a08; }
.collection-slideshow button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-width: 44px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 999px;
    background: transparent; color: var(--sv-ink); font: 0.85rem var(--body); cursor: pointer;
    transition: background 0.15s;
}
.collection-slideshow button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.collection-slideshow button:disabled { opacity: 0.35; cursor: default; }
.collection-slideshow .icon { width: 20px; height: 20px; display: block; }
.collection-slideshow :is(button, a, input):focus-visible { outline: 2px solid var(--sv-amber); outline-offset: 2px; }
.slide-glass, .slide-details, .slide-controls {
    background: var(--sv-glass); border: 1px solid var(--sv-edge);
    -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
}

.slide-stage { position: absolute; inset: 0; touch-action: pan-y; }
.slide-image { width: 100%; height: 100%; margin: 0; object-fit: contain; }
.slide-error {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 32ch;
    margin: 0; padding: 12px 16px; border-radius: 12px; background: var(--sv-glass); text-align: center;
}
.slide-error[hidden] { display: none; }

.slide-top {
    position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 6px;
    padding: 10px max(14px, env(safe-area-inset-right)) 28px max(20px, env(safe-area-inset-left));
    background: linear-gradient(rgba(0, 0, 0, 0.5), transparent); pointer-events: none;
}
.slide-top > * { pointer-events: auto; }
.slide-top h2 { margin: 0; font-size: 0.95rem; font-weight: 500; letter-spacing: 0.02em; color: var(--sv-ink-2); }
.slide-position { margin-left: auto; margin-right: 6px; font: 0.75rem var(--data); color: var(--sv-ink-2); white-space: nowrap; }

.slide-details {
    position: absolute; z-index: 1; top: 66px; right: max(16px, env(safe-area-inset-right));
    width: 250px; max-height: calc(100% - 210px); overflow-y: auto;
    padding: 16px 18px; border-radius: 16px; font-size: 0.82rem; color: var(--sv-ink-2);
}
.slide-id { margin: 0 0 6px; font: 0.68rem var(--data); letter-spacing: 0.04em; }
.slide-taxa { margin: 0 0 10px; font-size: 1.25rem; line-height: 1.2; color: var(--sv-ink); overflow-wrap: anywhere; }
.slide-taxa a { color: inherit; text-decoration: none; }
.slide-taxa a:hover { text-decoration: underline; text-underline-offset: 3px; }
.slide-age { margin: 0 0 6px; }
.slide-age:empty { display: none; }
.slide-place, .slide-link { color: var(--sv-amber); text-decoration: none; }
.slide-place:hover, .slide-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.slide-place { display: block; overflow-wrap: anywhere; }
.slide-place[hidden], .slide-views[hidden] { display: none; }
.slide-views { margin-top: 14px; }
.slide-views > p { margin: 0 0 6px; font-size: 0.72rem; }
.slide-thumbnails { display: flex; flex-wrap: wrap; gap: 6px; }
.collection-slideshow .slide-thumbnails button {
    width: 40px; height: 40px; min-width: 0; min-height: 0; padding: 0; border-radius: 8px;
    overflow: hidden; outline: 1px solid var(--sv-edge); opacity: 0.7;
}
.collection-slideshow .slide-thumbnails button[aria-pressed="true"] { outline: 2px solid var(--sv-amber); opacity: 1; }
.slide-thumbnails img { width: 100%; height: 100%; object-fit: cover; margin: 0; }
.slide-link { display: inline-block; margin-top: 14px; }

/* The caption sits on a scrim at the foot of the photo; the controls float above it. */
.slide-dock {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 48px 16px max(18px, env(safe-area-inset-bottom));
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.62)); pointer-events: none;
}
.slide-dock > * { pointer-events: auto; }
.slide-caption {
    order: 2; max-width: min(72ch, 100%); margin: 0; text-align: center;
    font-size: 0.92rem; line-height: 1.5; color: var(--sv-ink);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.slide-caption:empty { display: none; }
.slide-controls {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: 6px 18px; padding: 6px 10px; border-radius: 999px; max-height: 200px;
}
/* The labelled toggle in the top bar. */
.collection-slideshow .slide-toggle {
    min-height: 34px; padding: 0 12px 0 8px; gap: 4px;
    border: 1px solid var(--sv-edge); font-size: 0.75rem; color: var(--sv-ink-2);
}
.collection-slideshow .slide-toggle:hover { color: var(--sv-ink); }
.collection-slideshow .slide-toggle .icon { width: 16px; height: 16px; transition: transform 0.25s; }
.is-bare .slide-toggle .icon { transform: rotate(180deg); }
.slide-navigation { display: flex; align-items: center; gap: 4px; }
.collection-slideshow .slide-play {
    width: 48px; height: 48px; padding: 0; background: var(--sv-amber); color: #1a130b;
}
.collection-slideshow .slide-play:hover:not(:disabled) { background: #f0c588; }
.slide-play-icon .icon { fill: currentColor; }
.slide-pause-icon .icon { stroke-width: 3; }
.slide-play.is-playing .slide-play-icon, .slide-play:not(.is-playing) .slide-pause-icon { display: none; }
.slide-speed { display: flex; align-items: center; gap: 10px; font-size: 0.75rem; color: var(--sv-ink-2); }
/* A drawn track: filled up to the thumb, so more fill reads as faster. */
.slide-speed input {
    appearance: none; width: 120px; height: 44px; margin: 0; cursor: pointer; background:
    linear-gradient(to right, var(--sv-amber) var(--fill, 50%), rgba(255, 255, 255, 0.25) var(--fill, 50%)) center / 100% 4px no-repeat;
}
.slide-speed input::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--sv-amber); border: 3px solid #1a130b; }
.slide-speed input::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--sv-amber); border: 3px solid #1a130b; }

/* Folded away: only the photo, its caption and the top bar remain. */
.slide-chrome { transition: opacity 0.25s, transform 0.25s, visibility 0.25s, max-height 0.25s, padding 0.25s, margin 0.25s; }
.is-bare .slide-chrome { opacity: 0; visibility: hidden; }
.is-bare .slide-details { transform: translateX(12px); }
/* The controls give up their height, so the handle drops down to the caption. */
.is-bare .slide-controls { max-height: 0; padding-block: 0; margin-top: -14px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .slide-chrome, .collection-slideshow .slide-toggle .icon { transition: none; }
}

@media (max-width: 759px) {
    .field-slideshow { flex: 1; padding-inline: 8px; font-size: 0.7rem; }
    .field-tools { flex-wrap: wrap; }
    .field-tools > .field-random { flex: 1 1 100%; height: 38px; }
    .slide-top { padding: 6px 8px 24px 14px; }
    .slide-details {
        top: 58px; left: 12px; right: 12px; width: auto; max-height: 30svh;
        padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: baseline;
    }
    .slide-details > :not(.slide-taxa, .slide-id) { grid-column: 1 / -1; }
    .slide-id { grid-column: 2; grid-row: 1; margin: 0; }
    .slide-taxa { grid-row: 1; font-size: 1.1rem; margin-bottom: 6px; }
    .slide-views { margin-top: 10px; }
    .slide-link { margin-top: 10px; }
    .slide-dock { gap: 10px; padding: 40px 10px max(10px, env(safe-area-inset-bottom)); }
    .slide-caption { font-size: 0.85rem; }
    .slide-controls { gap: 4px 10px; border-radius: 22px; padding: 6px 8px; }
    .slide-speed { order: 3; flex: 1 1 100%; justify-content: center; gap: 8px; font-size: 0.7rem; }
    .slide-speed input { width: 140px; height: 32px; }
    .slide-shuffle > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .is-bare .slide-details { transform: translateY(-8px); }
}
