/* A quiet, shared archive control; leave room for map zoom and attribution. */
.time-machine {
    position: fixed;
    z-index: 10;
    right: 64px;
    bottom: max(28px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    width: 300px;
    max-width: calc(100vw - 88px);
    padding: 12px 16px 10px;
    color: #53666c;
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(67, 91, 97, .12);
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(28, 48, 53, .07);
    backdrop-filter: blur(12px);
    font: 12px/1.4 system-ui, sans-serif;
    transition: box-shadow .2s, background .2s;
}
.time-machine[hidden] { display: none; }
.time-machine:hover, .time-machine:focus-within {
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 4px 18px rgba(28, 48, 53, .11);
}
.time-machine-heading { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.time-machine-caption { display: flex; align-items: center; gap: 5px; color: #77858a; font-size: 11px; }
.time-machine-caption a { color: inherit; text-decoration: none; }
.time-machine-caption a:hover { color: #297b78; text-decoration: underline; }
.time-machine svg { stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
#archive-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: auto; font-size: 11px; font-weight: 600; color: #39555a; font-variant-numeric: tabular-nums; }
.time-machine .time-machine-catalog { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: 0 0 44px; margin: -6px -8px -6px 0; color: #859397; border-radius: 5px; }
.time-machine .time-machine-catalog:hover { color: #297b78; background: #eef4f3; }
.archive-timeline { position: relative; height: 52px; margin: 5px -6px 0; }
.archive-timeline::before { content: ''; position: absolute; left: 18px; right: 18px; top: 16px; height: 1px; background: #cdd8d8; }
.time-machine .archive-year { position: absolute; left: calc((100% - 36px) * var(--archive-year-position)); top: 0; width: 36px; height: 52px; display: flex; flex-direction: column; align-items: center; padding: 12px 0 0; border: 0; border-radius: 6px; background: transparent; color: #77858a; font: 11px/1.4 system-ui, sans-serif; cursor: pointer; box-shadow: none; }
.archive-year::before { content: ''; width: 8px; height: 8px; margin-bottom: 8px; border-radius: 50%; background: #9aadaf; box-shadow: 0 0 0 3px #fff; }
.archive-year[aria-current="date"] { color: #297b78; font-weight: 600; }
.archive-year[aria-current="date"]::before, .archive-year[aria-expanded="true"]::before { background: #39847f; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #39847f25; }
.archive-year:hover { color: #297b78; }
.archive-year:focus-visible { outline: 2px solid #39847f; outline-offset: 1px; }
.archive-year-popover { position: absolute; z-index: 2; bottom: calc(100% + 8px); left: -1px; right: -1px; padding: 12px 14px 10px; border: 1px solid #dce3e3; border-radius: 12px; background: #fff; box-shadow: 0 4px 20px #1c30351c; }
.archive-year-popover[hidden] { display: none; }
/* Bridge the small visual gap so moving from a year to its points keeps it open. */
.archive-year-popover::after { content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px; }
.archive-detail-heading { display: flex; justify-content: space-between; align-items: center; color: #39555a; font-size: 12px; }
.archive-detail-heading span { color: #8b989c; font-size: 10px; }
.archive-detail-scroller { overflow-x: auto; scrollbar-width: thin; }
.archive-detail-track { position: relative; display: flex; justify-content: space-between; width: max-content; min-width: 100%; isolation: isolate; }
.archive-detail-track::before { content: ''; position: absolute; z-index: -1; left: 16px; right: 16px; top: 22px; height: 1px; background: #cdd8d8; }
.time-machine .archive-point { position: relative; display: flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; box-shadow: none; }
.time-machine .archive-point[hidden] { display: none; }
.archive-detail-date { min-height: 32px; font-size: 11px; line-height: 16px; color: #53666c; }
.archive-point::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #9aadaf; box-shadow: 0 0 0 3px #fff; transition: background .15s, box-shadow .15s, transform .15s; }
.archive-point[aria-pressed="true"]::before { width: 9px; height: 9px; background: #39847f; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #39847f25; }
.archive-point:hover::before { background: #39847f; transform: scale(1.2); }
.time-machine :is(.archive-point, .time-machine-catalog):focus-visible { outline: 2px solid #39847f; outline-offset: 1px; }
.time-machine .archive-point:focus-visible { outline-offset: -2px; }
.archive-point-tooltip, .archive-years { display: none; }
.time-machine .time-machine-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }
.time-machine[data-state="error"] .time-machine-status { position: static; width: auto; height: auto; clip-path: none; white-space: normal; font-size: 11px; margin-top: 6px; }
@media (max-width: 600px) { .time-machine { right: 56px; bottom: max(24px, env(safe-area-inset-bottom)); width: 300px; padding: 10px 14px 8px; } }
@media (prefers-reduced-motion: reduce) { .time-machine, .archive-point::before, .archive-point-tooltip { transition: none; } }

/* The catalogue has no map controls to avoid; keep its archive in the flow. */
.catalog-main .time-machine { position: relative; right: auto; bottom: auto; width: 300px; max-width: 100%; margin: 24px 0; box-shadow: none; }

.catalog-main .archive-year-popover { top: calc(100% + 8px); bottom: auto; }
.catalog-main .archive-year-popover::after { top: -10px; bottom: auto; }

/* The current date stays selected until the next snapshot is ready. */
.time-machine[data-state="loading"] { border-color: #39847f55; }
.archive-point[data-pending]::after {
    content: '';
    position: absolute;
    width: 19px;
    height: 19px;
    border: 1.5px solid #39847f30;
    border-top-color: #39847f;
    border-radius: 50%;
    animation: archive-orbit .85s linear infinite;
}
@keyframes archive-orbit { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .archive-point[data-pending]::after { animation: none; border-color: #39847f; }
}

/* Brief confirmation after the replacement snapshot has been committed. */
.archive-date-flash { position: fixed; z-index: 25; top: max(24px, env(safe-area-inset-top)); right: max(28px, env(safe-area-inset-right)); max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; user-select: none; color: #fff; text-shadow: 0 2px 16px #233b4b66, 0 1px 3px #233b4b99; font: 300 clamp(30px, 4vw, 60px)/1.1 system-ui, sans-serif; letter-spacing: .035em; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .archive-date-flash { top: max(112px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); } }
