/* React Bits-inspired micro interactions, expressed in the atlas's native
 * motion grammar. No new gesture handlers or animation runtime. */

/* Rubber Segment: a small elastic settle on the existing measured carriage.
 * Keep geometry, labels, focus, and selection under their existing owners. */
@supports (transition-timing-function: linear(0, 1)) {
  @media (prefers-reduced-motion: no-preference) {
    html[data-material-prototype="relief"] body.is-map-active
      [data-segmented-indicator]:is([data-segmented-indicator="mode"], [data-segmented-indicator="surface"]).has-sliding-indicator {
      --segmented-indicator-duration: var(--motion-duration-slow);
      --segmented-indicator-ease: linear(0, 0.4 15%, 0.76 30%, 0.96 48%, 1.012 65%, 1.004 82%, 1);
    }
  }
}

/* Wake Slider: nearby ticks lift toward the thumb only while manipulating
 * the instrument. The printed labels and native thumb geometry stay still. */
html body .reach-time-instrument .reach-time-scale i::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  transform-origin: center bottom;
  transform: scaleY(1);
  transition: transform var(--motion-duration-fast) var(--motion-ease-standard),
    color var(--motion-duration-fast) var(--motion-ease-standard);
}

html body .reach-time-instrument:has(input[type="range"]:not(:disabled):is(:active, :focus-visible))
  .reach-time-scale i::before {
  transform: scaleY(var(--reach-tick-wake, 1));
  color: var(--accent);
}

html body :is(#maxTimeRange, #mobileMapMaxTimeRange, #mobileSheetMaxTimeRange)::-webkit-slider-thumb {
  transition: transform var(--motion-duration-fast) var(--motion-ease-standard);
}
html body :is(#maxTimeRange, #mobileMapMaxTimeRange, #mobileSheetMaxTimeRange)::-moz-range-thumb {
  transition: transform var(--motion-duration-fast) var(--motion-ease-standard);
}
html body :is(#maxTimeRange, #mobileMapMaxTimeRange, #mobileSheetMaxTimeRange):not(:disabled):is(:active, :focus-visible)::-webkit-slider-thumb {
  transform: scale(1.08);
}
html body :is(#maxTimeRange, #mobileMapMaxTimeRange, #mobileSheetMaxTimeRange):not(:disabled):is(:active, :focus-visible)::-moz-range-thumb {
  transform: scale(1.08);
}

/* Spring Check: saved-state confirmation uses an empty decorative shape,
 * leaving the translated label and aria-pressed as the accessible meaning. */
html body button[data-shortlist-toggle]::before {
  content: "";
  display: inline-block;
  box-sizing: border-box;
  width: 11px;
  height: 11px;
  margin-inline-end: 7px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  vertical-align: -1px;
  opacity: 0.55;
}
html body button[data-shortlist-toggle][aria-pressed="true"]::before {
  border: 0;
  border-radius: 0;
  opacity: 1;
  background: currentColor;
  clip-path: polygon(4% 48%, 18% 34%, 40% 56%, 82% 8%, 98% 22%, 41% 88%);
  animation: atlas-save-check var(--motion-duration-base) var(--motion-ease-enter) both;
}
@keyframes atlas-save-check {
  0% { transform: scale(0.65); }
  65% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  html body .reach-time-instrument .reach-time-scale i::before {
    transition: none;
    transform: none !important;
  }
  html body :is(#maxTimeRange, #mobileMapMaxTimeRange, #mobileSheetMaxTimeRange)::-webkit-slider-thumb {
    transition: none;
    transform: none !important;
  }
  html body :is(#maxTimeRange, #mobileMapMaxTimeRange, #mobileSheetMaxTimeRange)::-moz-range-thumb {
    transition: none;
    transform: none !important;
  }
  html body button[data-shortlist-toggle][aria-pressed="true"]::before { animation: none; }
}

@media (forced-colors: active) {
  html body button[data-shortlist-toggle]::before { forced-color-adjust: none; color: ButtonText; }
}

/* Place previews connect a paper card to its geographic marker. */
.destination-title strong { display: inline-block; }
.destination-cards article {
  transition: border-color var(--motion-duration-fast) var(--motion-ease-standard),
    box-shadow var(--motion-duration-fast) var(--motion-ease-standard),
    background-color var(--motion-duration-fast) var(--motion-ease-standard);
}
.destination-cards article.is-hovered {
  background-color: #edf2e9;
}

/* Metric copies are decorative and out of flow; the real value stays exact. */
.reach-station-count, #mobileCollapsedFocal { position: relative; }
html body .micro-metric-previous {
  position: absolute !important;
  pointer-events: none;
  margin: 0;
  white-space: nowrap;
}
.reach-station-count > b:not(.micro-metric-previous), #mobileCollapsedFocalValue { display: inline-block; }
#mobileCollapsedProgress::-webkit-progress-value {
  transition: width var(--motion-duration-base) var(--motion-ease-standard);
}
#mobileCollapsedProgress::-moz-progress-bar {
  transition: width var(--motion-duration-base) var(--motion-ease-standard);
}

/* Native details keep their keyboard and disclosure semantics. Older
 * browsers retain instant opening; supporting browsers also ease closed. */
.home-finder-edit-label::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-inline-end: 7px;
  border-block-start: 1.5px solid currentColor;
  border-inline-end: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--motion-duration-fast) var(--motion-ease-standard);
}
.home-finder-place-editor[open] .home-finder-edit-label::before { transform: rotate(135deg); }
@supports (interpolate-size: allow-keywords) and (transition-behavior: allow-discrete) {
  :is(.home-finder-place-editor, .home-finder-baseline, .plan-stop-choices) {
    interpolate-size: allow-keywords;
  }
  [data-micro-disclosure]::details-content {
    block-size: 0;
    opacity: 0;
    overflow: clip;
    transition: block-size var(--motion-duration-base) var(--motion-ease-standard),
      opacity var(--motion-duration-fast) var(--motion-ease-standard),
      content-visibility var(--motion-duration-base) allow-discrete;
  }
  [data-micro-disclosure][open]::details-content {
    block-size: auto;
    opacity: 1;
  }
}

/* Stateful icons describe real actions, without another click handler. */
html body :is(#fullscreenButton, #zoomInButton, #zoomOutButton) svg {
  transition: transform var(--motion-duration-fast) var(--motion-ease-standard);
}
html body #fullscreenButton[aria-pressed="true"] svg { transform: scale(0.85); }
html body :is(#fullscreenButton, #zoomInButton, #zoomOutButton):not(:disabled):active svg { transform: scale(0.88); }
html body .map-locate-button[data-locate-state="success"] svg {
  animation: atlas-save-check var(--motion-duration-base) var(--motion-ease-enter);
}

/* Journey state comes directly from the request owner; no simulated progress. */
.discovery-route[data-journey-state]:not([data-journey-state="idle"]) > :first-child::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-inline-end: 7px;
  box-sizing: border-box;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  vertical-align: -1px;
}
.discovery-route[data-journey-state="loading"] > :first-child::before {
  border-inline-end-color: transparent;
  animation: atlas-journey-working 900ms linear infinite;
}
.discovery-route[data-journey-state="ready"] > :first-child::before {
  border: none;
  border-radius: 0;
  background: currentColor;
  clip-path: polygon(4% 48%, 18% 34%, 40% 56%, 82% 8%, 98% 22%, 41% 88%);
  animation: atlas-save-check var(--motion-duration-base) var(--motion-ease-enter);
}
.discovery-route[data-journey-state="error"] > :first-child::before {
  border-radius: 2px;
  background: linear-gradient(currentColor, currentColor) center 2px / 2px 4px no-repeat,
    linear-gradient(currentColor, currentColor) center 7px / 2px 2px no-repeat;
}
@keyframes atlas-journey-working { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .home-finder-edit-label::before { transition: none; }
  .destination-cards article,
  html body :is(#fullscreenButton, #zoomInButton, #zoomOutButton) svg { transition: none; }
  #mobileCollapsedProgress::-webkit-progress-value { transition: none; }
  #mobileCollapsedProgress::-moz-progress-bar { transition: none; }
  [data-micro-disclosure]::details-content { transition: none; }
  .discovery-route[data-journey-state] > :first-child::before,
  html body .map-locate-button[data-locate-state="success"] svg { animation: none; }
}
