/* Time Machine map layer: pins, clusters, name sign, hover tooltip, labels, key, line layer, shoreline card.
   Light theme only. Class hues are muted and reach 3:1 against the Esri light grey base; yellow is only ever the selected place. */
.tm-page {
  --c-war: #9e2f45; --c-religion: #74468a; --c-trade: #7d5826; --c-transport: #2a6296; --c-kampong: #b1522b;
  --c-civic: #1f7673; --c-leisure: #a73d79; --c-nature: #3f7a33; --c-architecture: #536070; --c-rest: #8a919b;
  --tm-ink: #121316;
}
.tm-pin[data-c="war"], .tm-key-dot[data-c="war"] { --c: var(--c-war); }
.tm-pin[data-c="religion"], .tm-key-dot[data-c="religion"] { --c: var(--c-religion); }
.tm-pin[data-c="trade"], .tm-key-dot[data-c="trade"] { --c: var(--c-trade); }
.tm-pin[data-c="transport"], .tm-key-dot[data-c="transport"] { --c: var(--c-transport); }
.tm-pin[data-c="kampong"], .tm-key-dot[data-c="kampong"] { --c: var(--c-kampong); }
.tm-pin[data-c="civic"], .tm-key-dot[data-c="civic"] { --c: var(--c-civic); }
.tm-pin[data-c="leisure"], .tm-key-dot[data-c="leisure"] { --c: var(--c-leisure); }
.tm-pin[data-c="nature"], .tm-key-dot[data-c="nature"] { --c: var(--c-nature); }
.tm-pin[data-c="architecture"], .tm-key-dot[data-c="architecture"] { --c: var(--c-architecture); }

/* Pins. Leaflet owns each marker root's transform, so all motion lives on the inner element. The tip of the pin sits on the point.
   Standing: solid class colour, ink ring. Changed (demolished, reused, moved): pale tint, dashed ring, "ghost". Marked site only: dotted ring and a small stone square. */
.tm-marker { background: none; border: 0; }
.tm-pin { position: absolute; left: 5px; top: 0; width: 34px; height: 40px; --c: var(--c-architecture); animation: tm-pop .26s var(--nv-ease) both; transform-origin: 50% 100%; transition: transform .16s var(--nv-ease), opacity .3s var(--nv-ease); }
.tm-plaque { position: absolute; left: 0; top: 0; width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid var(--tm-ink); border-radius: 50%; background: var(--c); color: #fff; box-shadow: 0 0 0 2px #fff, 0 3px 7px rgba(18,19,22,.38); }
.tm-plaque::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; margin-left: -5px; background: var(--tm-ink); transform: rotate(45deg); border-radius: 0 0 2px 0; z-index: -1; box-shadow: 2px 2px 0 1.5px #fff; }
.tm-plaque svg { width: 18px; height: 18px; }
.tm-echo { display: none; }
.tm-pin.is-ghost .tm-plaque { background: color-mix(in srgb, var(--c) 13%, #fff); color: var(--c); border-style: dashed; }
.tm-pin.is-ghost .tm-plaque::after { background: color-mix(in srgb, var(--c) 13%, #fff); border-right: 2px dashed var(--tm-ink); border-bottom: 2px dashed var(--tm-ink); }
.tm-pin.is-ghost[data-s="marked-site-only"] .tm-plaque { border-style: dotted; border-width: 2.5px; }
.tm-pin.is-ghost[data-s="marked-site-only"] .tm-plaque::before { content: ""; position: absolute; left: -4px; bottom: -3px; width: 9px; height: 9px; background: var(--tm-ink); box-shadow: 0 0 0 1.5px #fff; border-radius: 1px; }
.tm-pin.is-ghost .tm-echo { display: block; position: absolute; left: -5px; top: -5px; width: 44px; height: 44px; border-radius: 50%; border: 1.5px dashed var(--c); animation: tm-echo 2.8s var(--nv-ease) infinite; }
.tm-hero-tab { position: absolute; right: -6px; top: -6px; z-index: 2; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--tm-ink); color: #fff; box-shadow: 0 0 0 2px #fff; }
.tm-hero-tab svg { width: 10px; height: 10px; }
.tm-moved { position: absolute; left: -5px; top: -5px; z-index: 2; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px var(--tm-ink); font-size: 11px; font-weight: 700; line-height: 15px; text-align: center; color: var(--tm-ink); }
.tm-pin-year { position: absolute; left: 50%; top: 44px; transform: translate(-50%, -3px); padding: 1px 6px; border: 1px solid var(--nv-line); border-radius: 9px; background: #fff; font: 600 11px/14px var(--nv-font); font-style: normal; font-variant-numeric: tabular-nums; color: var(--tm-ink); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--nv-ease); white-space: nowrap; }
.tm-pin-year.is-on { opacity: 1; transform: translate(-50%, 0); }
.tm-pin.is-dim { opacity: .25; pointer-events: none; animation: none; filter: grayscale(1); }
.tm-linefocus .tm-pin:not(.is-station):not(.is-selected):not(.is-dim) { opacity: .45; }
.tm-pin.is-station .tm-plaque { transform: scale(1.12); }
.tm-pin.is-station { z-index: 5; }

/* Selected: the one yellow pin. Ink ring, class colour as an inner ring so its class is still readable. */
.tm-pin.is-selected { left: 0; width: 44px; height: 48px; animation: tm-drop .5s cubic-bezier(.34, 1.45, .5, 1) both; z-index: 10; }
.tm-pin.is-selected .tm-plaque { width: 44px; height: 44px; border-width: 3px; background: var(--nv-accent); color: var(--nv-accent-ink); box-shadow: inset 0 0 0 3px var(--c), 0 0 0 2px #fff, 0 5px 12px rgba(18,19,22,.42); }
.tm-pin.is-selected .tm-plaque::after { bottom: -8px; width: 12px; height: 12px; margin-left: -6px; }
.tm-pin.is-selected .tm-plaque svg { width: 24px; height: 24px; }
.tm-pin.is-selected .tm-hero-tab { right: -8px; top: -8px; }

/* Name sign for the selected pin: wraps, never overflows, arrow always points at the pin. --dx is set by map.js to keep it on the map. */
.tm-pin-sign { --dx: 0px; position: absolute; left: 50%; top: 60px; transform: translateX(calc(-50% + var(--dx))); display: flex; flex-direction: column; align-items: center; gap: 2px; width: max-content; max-width: min(240px, calc(100vw - 24px)); padding: 6px 11px 7px; border-radius: 8px; background: var(--tm-ink); color: #fff; font-size: 12px; font-weight: 600; line-height: 1.3; text-align: center; overflow-wrap: anywhere; white-space: normal; box-shadow: 0 0 0 1.5px #fff, 0 4px 12px rgba(18,19,22,.3); pointer-events: none; }
.tm-pin-sign::before { content: ""; position: absolute; left: calc(50% - var(--dx)); top: -5px; width: 10px; height: 10px; margin-left: -5px; background: var(--tm-ink); transform: rotate(45deg); border-radius: 2px 0 0 0; }
.tm-pin-sign.is-above { top: auto; bottom: 58px; }
.tm-pin-sign.is-above::before { top: auto; bottom: -5px; border-radius: 0 0 2px 0; }
.tm-pin-sign small { position: static; display: block; width: auto; height: auto; font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.8); }

/* Labels from zoom 15. The class colour is the left edge. */
.tm-label { position: absolute; left: 40px; top: 8px; max-width: 170px; padding: 0 7px 0 6px; border: 1px solid var(--nv-line); border-left: 3px solid var(--c); border-radius: 9px; background: #fff; font: 600 10px/16px var(--nv-font); font-style: normal; color: var(--tm-ink); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s; }
.tm-z17 .tm-label { font-size: 11px; }
.tm-label.is-on, .leaflet-marker-icon:hover .tm-label, .leaflet-marker-icon:focus .tm-label { opacity: 1; }
.leaflet-marker-icon:hover, .leaflet-marker-icon:focus { z-index: 900 !important; }

/* Clusters: donut ring is the class mix, ink outline, count in the white core. */
.tm-cluster { position: absolute; left: 50%; top: 50%; width: var(--d); height: var(--d); margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2); display: grid; place-items: center; border-radius: 50%; background: var(--mix, var(--c-rest)); box-shadow: 0 0 0 2px var(--tm-ink), 0 0 0 4px #fff, 0 3px 8px rgba(18,19,22,.35); animation: tm-spring .38s cubic-bezier(.34, 1.4, .5, 1) both; transition: transform .16s var(--nv-ease); }
.tm-cluster.is-sm { --d: 42px; --ring: 8px; --fs: 13px; } .tm-cluster.is-md { --d: 50px; --ring: 9px; --fs: 15px; } .tm-cluster.is-lg { --d: 60px; --ring: 10px; --fs: 17px; }
.tm-cluster-core { position: absolute; inset: var(--ring); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border-radius: 50%; background: #fff; color: var(--tm-ink); box-shadow: 0 0 0 1.5px var(--tm-ink); }
.tm-cluster-core b { font-size: var(--fs); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tm-cluster-glyph svg { display: block; width: 11px; height: 11px; margin-bottom: 1px; color: var(--cg, var(--nv-muted)); }
.is-lg .tm-cluster-glyph svg { width: 13px; height: 13px; }
.leaflet-marker-icon:hover .tm-pin:not(.is-selected):not(.is-dim), .leaflet-marker-icon:hover .tm-cluster { transform: scale(1.1); }
.leaflet-marker-icon:active .tm-pin, .leaflet-marker-icon:active .tm-cluster { transform: scale(.95); }
.leaflet-marker-icon:focus-visible { outline: none; }
.leaflet-marker-icon:focus-visible .tm-plaque, .leaflet-marker-icon:focus-visible .tm-cluster { outline: 3px solid var(--tm-ink); outline-offset: 5px; }

.leaflet-tooltip.tm-area-label { padding: 1px 4px; border: 0; background: none; box-shadow: none; color: var(--tm-ink); font: 600 11px/1.25 var(--nv-font); text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff, 0 0 2px #fff; white-space: normal; text-align: center; }
.leaflet-tooltip.tm-area-label span { display: block; font-weight: 400; font-style: italic; }
.leaflet-tooltip.tm-area-label.is-hover { padding: 4px 8px; border: 1px solid var(--nv-line); border-radius: var(--nv-r); background: #fff; text-shadow: none; box-shadow: var(--nv-shadow); }
.leaflet-tooltip.tm-area-label::before { display: none; }

/* Hover tooltip: dark, wraps up to 280px, arrow points at the pin (--ax from tip.js). */
.tm-tip { --ax: 24px; position: absolute; left: 0; top: 0; z-index: 1200; width: max-content; max-width: min(280px, calc(100% - 16px)); padding: 10px 12px; border-radius: 8px; background: var(--tm-ink); color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.55), 0 6px 18px rgba(18,19,22,.35); overflow-wrap: anywhere; white-space: normal; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .15s var(--nv-ease), visibility 0s .15s; will-change: transform; }
.tm-tip.is-on { opacity: 1; visibility: visible; transition: opacity .15s var(--nv-ease); }
.tm-tip::after { content: ""; position: absolute; left: var(--ax); width: 10px; height: 10px; margin-left: -5px; background: var(--tm-ink); transform: rotate(45deg); bottom: -5px; border-radius: 0 0 2px 0; }
.tm-tip[data-side="below"]::after { bottom: auto; top: -5px; border-radius: 2px 0 0 0; }
.tm-tip-row { display: flex; gap: 10px; align-items: flex-start; }
.tm-tip-thumb { flex: none; }
.tm-tip-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12px; line-height: 1.35; }
.tm-tip-text strong { font-size: 14px; line-height: 1.25; color: #fff; }
.tm-tip-former, .tm-tip-theme, .tm-tip .tm-years { color: rgba(255,255,255,.78); }
.tm-tip-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.tm-tip .tm-badge { border-color: rgba(255,255,255,.75); background: transparent; color: #fff; }
.tm-tip .tm-badge-standing { background: #fff; color: var(--tm-ink); border-color: #fff; }
.tm-tip-hint { margin: 8px 0 0; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.3); font-size: 12px; font-weight: 600; color: #fff; }
.tm-tip-list { margin: 2px 0 0; padding-left: 16px; font-size: 12px; color: rgba(255,255,255,.9); }

/* Key */
.tm-key { margin: 0 0 12px 12px !important; }
.tm-key-toggle { min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--nv-line); border-radius: var(--nv-r); background: #fff; font: 600 13px var(--nv-font); color: var(--tm-ink); cursor: pointer; box-shadow: 0 2px 6px rgba(18,19,22,.15); }
.tm-key-toggle[aria-expanded="true"] { border-color: var(--tm-ink); }
.tm-key-panel { position: absolute; left: 0; bottom: 48px; width: 286px; max-width: calc(100vw - 24px); max-height: min(70dvh, 460px); overflow-y: auto; padding: 10px 12px 6px; border: 1px solid var(--tm-ink); border-radius: var(--nv-r); background: #fff; box-shadow: var(--nv-shadow); animation: tm-fade .2s var(--nv-ease) both; }
.tm-key-panel h4 { margin: 4px 0 2px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--nv-muted); }
.tm-key-panel ul { margin: 0; padding: 0; list-style: none; }
.tm-key-panel li { position: relative; display: flex; align-items: center; min-height: 30px; padding-left: 34px; font-size: 12px; line-height: 1.3; }
.tm-key-dot { position: absolute; left: 4px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border: 2px solid var(--tm-ink); border-radius: 50%; background: var(--c); }
.tm-key-panel .tm-pin, .tm-key-panel .tm-cluster, .tm-key-area, .tm-key-line { position: absolute; left: 4px; top: 50%; animation: none; }
.tm-key-panel .tm-pin { width: 34px; height: 34px; margin-top: -19px; transform: scale(.6); transform-origin: 0 50%; }
.tm-key-panel .tm-cluster { margin: -21px 0 0 -1px; transform: scale(.7); transform-origin: 0 50%; }
.tm-key-area { width: 24px; height: 16px; margin-top: -8px; border: 1.5px dashed #3a3122; background: rgba(251,230,160,.35); }
.tm-key-line { width: 26px; height: 8px; margin-top: -4px; border-top: 2px solid var(--tm-ink); border-bottom: 2px solid var(--tm-ink); background: repeating-linear-gradient(90deg, var(--tm-ink) 0 2px, #fff 2px 6px); }
@media (min-width: 768px) { .tm-key { margin-left: 384px !important; } }
@media (max-width: 767px) { .tm-page .leaflet-bottom { margin-bottom: var(--tm-sheet-h, 0px) !important; } .tm-key { margin-bottom: 8px !important; } }

/* Shoreline card */
.tm-feature-panel.tm-shoreline { width: min(300px, calc(100vw - 24px)); padding: 10px 12px; overflow: hidden; overflow-wrap: anywhere; }
.tm-shore-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.tm-shore-title { font-size: .9375rem; font-weight: 650; letter-spacing: -.01em; }
.tm-shore-toggle { position: relative; min-height: 28px; padding: 0 10px; border: 1px solid var(--nv-line); border-radius: 14px; background: #fff; color: var(--tm-ink); font: 600 .75rem/1 var(--nv-font); cursor: pointer; transition: background-color .2s, transform .18s var(--nv-ease); }
.tm-shore-toggle::after { content: ""; position: absolute; inset: -8px -4px; }
.tm-shore-toggle:hover { background: var(--nv-surface); } .tm-shore-toggle:active { transform: scale(.96); }
.tm-shore-body { display: grid; gap: 2px; padding-top: 2px; animation: tm-feature-in .2s var(--nv-ease) both; }
.tm-shore-body[hidden] { display: none; }
.tm-feature-panel.tm-shoreline { --thumb: 28px; }
.tm-shore-slider { position: relative; padding: 0; }
.tm-shore-slider input[type=range] { display: block; width: 100%; height: 44px; margin: 0; padding: 0; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: pan-y; }
.tm-shore-slider input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--nv-line); }
.tm-shore-slider input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--nv-line); }
.tm-shore-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: -12px; border: 3px solid var(--tm-ink); border-radius: 50%; background: var(--nv-accent); box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(18,19,22,.3); transition: transform .15s var(--nv-ease); }
.tm-shore-slider input[type=range]::-moz-range-thumb { width: calc(var(--thumb) - 6px); height: calc(var(--thumb) - 6px); border: 3px solid var(--tm-ink); border-radius: 50%; background: var(--nv-accent); box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(18,19,22,.3); }
.tm-shore-slider input[type=range]:active::-webkit-slider-thumb { transform: scale(1.1); }
.tm-shore-ticks { position: relative; height: 34px; margin: -8px 0 4px; list-style: none; padding: 0; }
.tm-shore-ticks li { position: absolute; top: 0; left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--p)); display: flex; flex-direction: column; align-items: center; gap: 3px; width: 40px; margin-left: -20px; font: 500 .6875rem/1 var(--nv-mono); font-variant-numeric: tabular-nums; color: var(--nv-muted); pointer-events: none; }
.tm-shore-ticks li::before { content: ""; width: 1.5px; height: 6px; background: var(--nv-muted); }
.tm-shore-ticks li.is-on { color: var(--tm-ink); font-weight: 700; }
.tm-shore-ticks li.is-on::before { background: var(--tm-ink); }
.tm-shore-note { margin: 0; font-size: .75rem; line-height: 1.4; color: var(--nv-muted); }
.tm-shore-source { border-top: 1px solid var(--nv-line); margin-top: 6px; }
.tm-shore-source summary { display: flex; align-items: center; min-height: 40px; font-size: .8125rem; font-weight: 600; cursor: pointer; }
.tm-shore-source p { margin: 0 0 6px; font-size: .75rem; line-height: 1.45; color: var(--nv-muted); overflow-wrap: anywhere; word-break: break-word; }
.tm-shore-source a { display: inline-flex; align-items: center; min-height: 40px; font-size: .8125rem; font-weight: 600; color: var(--tm-ink); text-underline-offset: 3px; }

@keyframes tm-echo { 0% { opacity: .9; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes tm-drop { from { opacity: 0; transform: translateY(-26px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes tm-spring { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes tm-pop { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tm-pin, .tm-cluster, .tm-echo, .tm-pin-year, .tm-key-panel, .tm-shore-body, .tm-tip, .tm-label, .tm-shore-toggle { animation: none !important; transition: none !important; }
}
.tm-shore-text { max-height: 96px; overflow-y: auto; }
