/* ==========================================================================
   Mini Manchester: UI feature (search pill, pin, loading states, share, zoom)
   ========================================================================== */

/* Design tokens. The glass material itself is .lg (features/glass/glass.css + glass.js:
   real refraction in Chromium, frosted fallback elsewhere). These tokens remain for
   features that style their own panels. */
:root {
  --glass-bg: rgba(255, 255, 255, .18);
  --glass-bg-strong: rgba(255, 255, 255, .42);   /* panels with lots of text */
  --glass-bg-hover: rgba(255, 255, 255, .36);
  --glass-border: rgba(255, 255, 255, .45);
  --glass-blur: blur(20px) saturate(180%);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, .6);
  --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, .38) 0%, rgba(255, 255, 255, .10) 32%, rgba(255, 255, 255, 0) 58%);
  --glass-shadow: 0 10px 30px rgba(29, 36, 51, .16), 0 2px 6px rgba(29, 36, 51, .10);
  --glass-ink: #1d2433;
  --glass-ink-muted: rgba(29, 36, 51, .62);
  --glass-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --glass-radius: 999px;
  --glass-radius-panel: 22px;
  --glass-ease: cubic-bezier(.2, .8, .2, 1);

  --tm-paper: #efe6d3;
  --tm-paper-ink: #2b2620;
  --tm-gap: 16px;
  --tm-safe-t: max(var(--tm-gap), calc(env(safe-area-inset-top) + 10px));
  --tm-safe-r: max(var(--tm-gap), calc(env(safe-area-inset-right) + 10px));
  --tm-safe-b: max(var(--tm-gap), calc(env(safe-area-inset-bottom) + 6px));
  --tm-safe-l: max(var(--tm-gap), calc(env(safe-area-inset-left) + 10px));
}

.tm-glass { color: var(--glass-ink); font-family: var(--glass-font); }
/* inside liquid glass, ink follows the glass tone (light map / dark map / night) */
.lg { --glass-ink: var(--lg-ink); --glass-ink-muted: var(--lg-ink-muted); color: var(--glass-ink); }

#layer-ui { font-family: var(--glass-font); color: var(--glass-ink); }
#layer-ui button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- loading
   No splash screen: a starry sky (styles.css) until the first tiles land, the city under
   cloud, then a glide down while the clouds part (features/ui/loader.js). */
.tm-clouds {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none;
  opacity: 1; transform-origin: 50% 50%;
  animation: tm-cloud-drift 6s ease-in-out infinite alternate;
  transition: opacity 1.9s cubic-bezier(.5, 0, .3, 1), transform 2.4s cubic-bezier(.35, 0, .25, 1);
}
.tm-clouds.tm-clouds-part { animation: none; transform: scale(3.2); opacity: 0; }
.tm-clouds.tm-clouds-gone { animation: none; opacity: 0; transition-duration: .35s; }
@keyframes tm-cloud-drift { from { transform: scale(1.06) translate3d(-1%, 0, 0); } to { transform: scale(1.1) translate3d(1%, -.5%, 0); } }

.tm-status {
  position: absolute; z-index: 25;
  left: var(--tm-safe-l); bottom: calc(var(--tm-safe-b) + 64px);
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 10px; border-radius: 999px;
  font: 500 13.5px/1 var(--glass-font); letter-spacing: -.01em; white-space: nowrap;
  pointer-events: none !important;
  animation: tm-fade-in .5s ease both;
  transition: opacity .6s ease, translate .6s var(--glass-ease);
}
.tm-status-out { opacity: 0; translate: 0 6px; }
.tm-status .tm-bee { width: 26px; height: 18px; flex: none; overflow: visible; }
.tm-status-done .tm-bee-bob { animation-duration: 2s; }

.tm-bee { stroke: #2b2620; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.tm-bee-bob { animation: tm-bee-bob .9s ease-in-out infinite; }
.tm-bee-body { fill: #f2b632; }
.tm-bee-stripe { fill: none; stroke-width: 2.4; }
.tm-bee-head { fill: #2b2620; stroke: none; }
.tm-bee-ant { fill: none; }
.tm-wing { fill: rgba(255, 255, 255, .9); stroke-width: 1.2; transform-box: fill-box; transform-origin: 50% 100%; animation: tm-wing .11s ease-in-out infinite alternate; }
.tm-wing-b { animation-delay: -.055s; }
@keyframes tm-wing { from { scale: 1 1; } to { scale: 1 .35; } }
@keyframes tm-bee-bob { 50% { translate: 0 -1.6px; } }

/* ---------------------------------------------------------------- search pill */
.tm-search {
  position: absolute; z-index: 20;
  left: var(--tm-safe-l);
  bottom: calc(var(--tm-safe-b) + var(--tm-kb, 0px));
  width: min(352px, calc(100vw - var(--tm-safe-l) - var(--tm-safe-r) - 60px));
  transition: width .42s var(--glass-ease), bottom .25s ease;
}
.tm-search.tm-focus { width: min(460px, calc(100vw - var(--tm-safe-l) - var(--tm-safe-r))); }

.tm-pill {
  position: relative; display: flex; align-items: center; gap: 4px;
  height: 50px; padding: 0 6px 0 15px; box-sizing: border-box;
  border-radius: var(--glass-radius);
  --lg-press: .985;
}
/* focused: the lens deepens a little and lifts (width morphs via .tm-search) */
.tm-focus .tm-pill { --lg-tint: rgba(255, 255, 255, .40); --lg-drop: 0 14px 34px -8px rgba(18, 24, 40, .36), 0 2px 6px -1px rgba(18, 24, 40, .16); }
.tm-focus .tm-pill[data-lg-tone-now="dark"] { --lg-tint: rgba(14, 18, 34, .48); }
.tm-pill-icon { display: flex; flex: none; color: var(--glass-ink); opacity: .8; margin-right: 4px; }
.tm-pill-icon svg { width: 19px; height: 19px; }
.tm-input {
  flex: 1; min-width: 0; height: 100%; padding: 0; margin: 0;
  border: 0; outline: 0; background: transparent;
  font: 500 16px/1 var(--glass-font); color: var(--glass-ink); letter-spacing: -.01em;
  text-overflow: ellipsis;
}
.tm-input::placeholder { color: var(--glass-ink-muted); opacity: 1; }
.tm-kbd {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-right: 4px;
  border-radius: 7px; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); background: rgba(255, 255, 255, .14);
  font: 600 12px/1 var(--glass-font); color: var(--glass-ink-muted);
}
.tm-focus .tm-kbd, .tm-has-value .tm-kbd { display: none; }
@media (pointer: coarse) { .tm-kbd { display: none; } }

.tm-btn {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  color: var(--glass-ink); -webkit-tap-highlight-color: transparent;
  transition: scale .5s cubic-bezier(.3, 1.7, .45, 1), background-color .25s ease, box-shadow .25s ease, opacity .2s ease;
}
.tm-btn:focus-visible { outline: 2px solid color-mix(in srgb, currentColor 60%, transparent); outline-offset: -2px; }
.tm-clear { display: none; width: 32px; height: 32px; }
.tm-clear svg { width: 16px; height: 16px; }
.tm-has-value .tm-clear { display: grid; }
.tm-sep { flex: none; width: 1px; height: 22px; margin: 0 2px; background: currentColor; opacity: .16; }

/* ---------------------------------------------------------------- results panel */
.tm-results {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 10px);
  box-sizing: border-box; padding: 6px;
  max-height: min(56vh, 456px, var(--tm-avail, 100vh)); overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--glass-radius-panel);
  opacity: 0; visibility: hidden; transform: translateY(8px) scale(.985); transform-origin: 50% 100%;
  transition: opacity .22s ease, transform .3s var(--glass-ease), visibility 0s linear .3s;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, currentColor 28%, transparent) transparent;
  -webkit-overflow-scrolling: touch; touch-action: pan-y;
}
.tm-open .tm-results { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.tm-res-head {
  padding: 8px 12px 6px; font: 600 12.5px/1 var(--glass-font);
  color: var(--glass-ink-muted);
}
.tm-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 15px;
  cursor: pointer; transition: background-color .15s ease;
}
.tm-row.tm-active { /* a raised drop of glass under the highlighted row */
  background: linear-gradient(180deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, .36));
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .7), inset 1px 1.4px .5px -.5px #fff,
    inset -1px -1px .5px -.5px rgba(255, 255, 255, .6), 0 3px 10px -3px rgba(18, 24, 40, .22);
}
[data-lg-tone-now="dark"] .tm-row.tm-active {
  background: linear-gradient(180deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, .09));
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .22), inset 1px 1.4px .5px -.5px rgba(255, 255, 255, .5), 0 3px 10px -3px rgba(0, 0, 0, .35);
}
.tm-row.tm-off { cursor: default; opacity: .48; filter: grayscale(1); }
.tm-row-icon {
  --c: #5c6680;
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, rgba(255, 255, 255, .55));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 18%, transparent);
}
.tm-row-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tm-row-name, .tm-row-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-row-name { font: 500 15px/1.2 var(--glass-font); letter-spacing: -.01em; }
.tm-row-name mark { background: none; color: inherit; font-weight: 700; }
.tm-row-type { font: 400 12.5px/1.2 var(--glass-font); color: var(--glass-ink-muted); }
.tm-res-status {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  font: 450 13.5px/1.3 var(--glass-font); color: var(--glass-ink-muted);
}

/* category tints */
.tm-cat-neighbourhood { --c: #7a5a32; }
.tm-cat-station, .tm-cat-tram, .tm-cat-bus { --c: #2d64c8; }
.tm-cat-landmark, .tm-cat-museum, .tm-cat-venue { --c: #7d4bbd; }
.tm-cat-park, .tm-cat-sport { --c: #2c7d47; }
.tm-cat-shopping { --c: #c0561c; }
.tm-cat-education { --c: #9a3a8a; }
.tm-cat-health { --c: #c93838; }
.tm-cat-pub, .tm-cat-bar, .tm-cat-restaurant, .tm-cat-cafe { --c: #c27a17; }
.tm-cat-hotel { --c: #3f63a8; }
.tm-cat-water { --c: #1f86a8; }
.tm-cat-street { --c: #5b6473; }
.tm-cat-postcode { --c: #c2362f; }
.tm-cat-address { --c: #9a5b2e; }
.tm-cat-busstop, .tm-cat-bike { --c: #2d64c8; }
.tm-cat-club { --c: #7d4bbd; }
.tm-cat-shop { --c: #c0561c; }
.tm-cat-fastfood { --c: #c27a17; }
.tm-cat-office, .tm-cat-coworking { --c: #3f5f8a; }
.tm-cat-parking { --c: #3a6fb0; }
.tm-cat-amenity, .tm-cat-building { --c: #5c6680; }
/* featured places: warm gradient chip with a white star */
.tm-row-icon.tm-cat-featured {
  color: #fff; background: linear-gradient(135deg, #ff9a3d 0%, #ff5f6d 50%, #8b5cf6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 2px 6px rgba(255, 95, 109, .35);
}
.tm-badge {
  flex: none; margin-left: auto; padding: 4px 8px; border-radius: 999px;
  font: 600 11.5px/1 var(--glass-font); color: #b4471f;
  background: rgba(255, 154, 61, .16); box-shadow: inset 0 0 0 1px rgba(255, 120, 61, .28);
}

/* ---------------------------------------------------------------- spinners */
.tm-spin {
  display: inline-block; flex: none; width: 18px; height: 18px; box-sizing: border-box;
  border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 18%, transparent); border-top-color: currentColor;
  animation: tm-rot .8s linear infinite;
}
.tm-spin-sm { width: 15px; height: 15px; }
.tm-busy {
  position: absolute; top: var(--tm-safe-t); right: var(--tm-safe-r); z-index: 15;
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  pointer-events: none !important;
  opacity: 0; transform: scale(.8); transition: opacity .3s ease, transform .3s var(--glass-ease);
}
.tm-busy.tm-on { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- zoom buttons */
.tm-zoom {
  position: absolute; z-index: 20; right: var(--tm-safe-r); bottom: var(--tm-safe-b);
  display: flex; flex-direction: column; align-items: center; padding: 3px;
  border-radius: 24px; --lg-press: .97;
  transition: opacity .25s ease, transform .25s ease, scale .55s cubic-bezier(.3, 1.6, .45, 1), --lg-glow .35s ease;
}
.tm-zoom .tm-btn { width: 42px; height: 42px; }
.tm-zoom-sep { width: 20px; height: 1px; background: currentColor; opacity: .16; }
/* Phones: pinch to zoom, so the buttons go and the pill takes the full width. */
@media (max-width: 600px) and (pointer: coarse) {
  .tm-zoom { display: none; }
  .tm-search, .tm-search.tm-focus { width: calc(100vw - var(--tm-safe-l) - var(--tm-safe-r)); }
}
@media (max-width: 600px) {
  .tm-search.tm-focus ~ .tm-zoom { opacity: 0; transform: translateY(8px); pointer-events: none; }
}

/* ---------------------------------------------------------------- toast */
.tm-toast {
  position: absolute; z-index: 30; left: 50%; bottom: calc(var(--tm-safe-b) + 6px);
  display: flex; align-items: center; gap: 8px; padding: 10px 18px 10px 14px;
  border-radius: var(--glass-radius);
  font: 600 14px/1 var(--glass-font); white-space: nowrap;
  pointer-events: none !important;
  opacity: 0; transform: translate(-50%, 10px) scale(.96);
  transition: opacity .25s ease, transform .35s var(--glass-ease);
}
.tm-toast svg { color: #1f8a4c; }
.tm-toast[data-lg-tone-now="dark"] svg { color: #4cd17e; }
.tm-toast.tm-on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 600px) { .tm-toast { bottom: calc(var(--tm-safe-b) + 64px); } }

/* ---------------------------------------------------------------- pin + card (OSD overlay) */
.tm-pin-anchor { width: 0; height: 0; pointer-events: none; }
.tm-pin-layer { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none !important; }
.tm-pin { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.tm-pin-inner {
  position: absolute; left: 0; bottom: 0; translate: -50% 0; /* tip of the drop = anchor */
  display: flex; flex-direction: column; align-items: center;
  transition: opacity .2s ease, transform .2s ease;
}
.tm-pin-out .tm-pin-inner { opacity: 0; transform: translateY(-10px) scale(.9); }

/* the drop: falls, squashes on impact, two small bounces, settles (~0.8 s) */
.tm-pin-fall { position: relative; z-index: 1; transform-origin: 50% 100%; animation: tm-pin-fall .82s both; }
.tm-pin-drop { display: block; pointer-events: auto; cursor: pointer; filter: drop-shadow(0 4px 5px rgba(15, 20, 31, .35)); }
.tm-pin-featured .tm-pin-dot { fill: #ffb347; }
.tm-pin-shadow {
  position: absolute; left: 50%; bottom: -4px; width: 22px; height: 8px; margin-left: -11px;
  border-radius: 50%; background: radial-gradient(closest-side, rgba(15, 20, 31, .5), rgba(15, 20, 31, 0));
  animation: tm-pin-shadow .82s both;
}
.tm-pin-pulse {
  position: absolute; left: 50%; bottom: -14px; width: 56px; height: 28px; margin-left: -28px;
  box-sizing: border-box; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .95);
  box-shadow: 0 0 0 1px rgba(29, 36, 51, .25);
  opacity: 0; animation: tm-pulse 1.6s ease-out .36s 2;
}

/* glass card above the pin */
.tm-card {
  position: relative; z-index: 2; pointer-events: auto;
  display: flex; align-items: center; gap: 10px; margin-bottom: 9px;
  max-width: min(320px, calc(100vw - 40px)); box-sizing: border-box; padding: 8px 6px 8px 8px;
  border-radius: 18px; font-family: var(--glass-font);
  --lg-tint: rgba(255, 255, 255, .50); --lg-press: .97;
  transform-origin: 50% 100%;
  animation: tm-card-in .42s cubic-bezier(.2, 1.3, .4, 1) .5s both;
  transition: opacity .2s ease, transform .25s var(--glass-ease), visibility 0s linear 0s, scale .55s cubic-bezier(.3, 1.6, .45, 1), --lg-glow .35s ease;
}
.tm-card[data-lg-tone-now="dark"] { --lg-tint: rgba(14, 18, 34, .56); }
.tm-card::after { /* little glass bead between card and pin */
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 6px; height: 6px; margin-left: -3px;
  border-radius: 50%; background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .8), inset .8px 1px .4px -.3px #fff, 0 1px 3px rgba(18, 24, 40, .3);
}
.tm-card .tm-row-icon { width: 32px; height: 32px; border-radius: 10px; }
.tm-card-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.tm-card-name, .tm-card-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-card-name { font: 650 14.5px/1.2 var(--glass-font); letter-spacing: -.01em; }
.tm-card-sub { font: 400 12.5px/1.25 var(--glass-font); color: var(--glass-ink-muted); }
.tm-card-close { width: 26px; height: 26px; align-self: flex-start; color: var(--glass-ink-muted); }
.tm-card-close svg { width: 14px; height: 14px; }
.tm-card-hidden .tm-card {
  animation: none; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(6px) scale(.92);
  transition: opacity .18s ease, transform .2s ease, visibility 0s linear .2s;
}

/* ---------------------------------------------------------------- keyframes */
@keyframes tm-rot { to { transform: rotate(360deg); } }
@keyframes tm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tm-fade-out { to { opacity: 0; visibility: hidden; } }
@keyframes tm-draw { to { stroke-dashoffset: 0; } }
@keyframes tm-float { 50% { transform: translateY(-3px); } }
@keyframes tm-pin-fall {
  0% { opacity: 0; transform: translateY(-90px); animation-timing-function: cubic-bezier(.5, 0, 1, .5); }
  12% { opacity: 1; }
  42% { transform: translateY(0) scale(1, 1); animation-timing-function: ease-out; }
  50% { transform: translateY(0) scale(1.16, .8); animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  64% { transform: translateY(-16px) scale(.96, 1.05); animation-timing-function: cubic-bezier(.6, 0, 1, .6); }
  76% { transform: translateY(0) scale(1.06, .92); animation-timing-function: ease-out; }
  86% { transform: translateY(-4px) scale(.99, 1.01); animation-timing-function: ease-in; }
  100% { opacity: 1; transform: none; }
}
@keyframes tm-pin-shadow {
  0% { opacity: 0; transform: scale(.3); }
  42%, 76% { opacity: 1; transform: scale(1.15, 1); }
  64% { opacity: .6; transform: scale(.75); }
  100% { opacity: 1; transform: none; }
}
@keyframes tm-card-in {
  from { opacity: 0; transform: translateY(8px) scale(.9); }
  to { opacity: 1; transform: none; }
}
@keyframes tm-pulse {
  0% { opacity: .95; transform: scale(.25); }
  100% { opacity: 0; transform: scale(1.5); }
}

@media (prefers-reduced-motion: reduce) {
  .tm-wing, .tm-bee-bob, .tm-clouds, .tm-pin-fall, .tm-pin-shadow, .tm-pin-pulse, .tm-card { animation: none !important; }
  .tm-search, .tm-results, .tm-toast { transition-duration: .01s !important; }
}
