/* ==========================================================================
   MICLCA motion layer  —  08.08.26
   Pairs with miclca-motion.js. No dependencies.
   Only transform and opacity are animated. Nothing here changes layout, so
   if the JS fails to load the pages render exactly as they do without it.
   ========================================================================== */

:root {
  --mo-marker-dur: 420ms;
  --mo-marker-step: 9ms;    /* delay between markers inside a type group */
  --mo-group-gap: 300ms;    /* pause between institution-type groups */
  --mo-flip-dur: 340ms;
  --mo-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ------------------------------------------------------------ 1. THE MAP */

/* .mo-map-armed is added by JS, so markers are never hidden unless the
   script is present and able to bring them back. */
.mo-map-armed .mo-marker {
  opacity: 0;
  transform: scale(0.35);
  transform-origin: center;
  transform-box: fill-box;
}
.mo-map-armed.mo-map-run .mo-marker {
  animation: mo-marker-in var(--mo-marker-dur) var(--mo-ease) both;
  animation-delay: var(--mo-delay, 0ms);
}
@keyframes mo-marker-in {
  0%   { opacity: 0; transform: scale(0.35); }
  60%  { opacity: 1; transform: scale(1.35); }
  100% { opacity: 1; transform: scale(1); }
}

/* Legend rows dim, then light up as their wave of markers lands. */
.mo-legend-item {
  transition: opacity 260ms var(--mo-ease);
}
.mo-legend-item.mo-legend-dim  { opacity: 0.3; }
.mo-legend-item.mo-legend-live { opacity: 1; }

/* Markers link into the directory. */
.mo-marker-link { cursor: pointer; }
.mo-marker-link .mo-marker { transition: transform 150ms var(--mo-ease); }
.mo-marker-link:hover .mo-marker,
.mo-marker-link:focus-visible .mo-marker { transform: scale(1.7); }
.mo-marker-link:focus-visible {
  outline: 2px solid var(--navy, #1a2744);
  outline-offset: 1px;
}

/* Instant tooltip, replacing the browser's ~1s <title> delay. */
.mo-tip {
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  max-width: 15rem;
  padding: 0.34rem 0.6rem;
  border-radius: 5px;
  background: var(--navy, #1a2744);
  color: #fff;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.mo-tip.mo-tip-on { opacity: 1; visibility: visible; }

/* -------------------------------------------------------- 2. STAT NUMBERS */

.mo-counting { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- 3. DIRECTORY FLIP */

.mo-flip-invert {
  transform: translate(var(--mo-dx, 0px), var(--mo-dy, 0px));
  transition: none;
}
.mo-flip-play {
  transform: none;
  transition: transform var(--mo-flip-dur) var(--mo-ease);
}
.mo-flip-enter { animation: mo-fade-up 320ms var(--mo-ease) both; }

@keyframes mo-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------- 4. FOUNDING TIMELINE */

.mo-timeline-wrap { position: relative; }

.mo-timeline {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  --mo-tl-cols: 6;   /* keep in sync with the column count above */
  gap: 0;
  position: relative;
  padding-top: 2.75rem;
  margin: 0;
}

/* the unfilled track */
.mo-timeline::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  left: calc(50% / var(--mo-tl-cols));
  right: calc(50% / var(--mo-tl-cols));
  height: 2px;
  background: var(--gray-200, #d4d4da);
}
/* the drawn line, scaled by scroll progress */
.mo-timeline::after {
  content: "";
  position: absolute;
  top: 0.5rem;
  left: calc(50% / var(--mo-tl-cols));
  right: calc(50% / var(--mo-tl-cols));
  height: 2px;
  background: var(--teal, #207670);
  transform: scaleX(var(--mo-progress, 0));
  transform-origin: left center;
}

.mo-tl-item {
  position: relative;
  padding: 0 0.9rem;
  text-align: center;
}
.mo-tl-item::before {           /* the node */
  content: "";
  position: absolute;
  top: -2.25rem;
  left: 50%;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: var(--white, #fff);
  border: 2px solid var(--gray-200, #d4d4da);
  transform: scale(0.6);
  opacity: 0;
  transition: opacity 280ms var(--mo-ease), transform 280ms var(--mo-ease),
              background-color 280ms var(--mo-ease), border-color 280ms var(--mo-ease);
}
.mo-tl-item.mo-node-lit::before {
  opacity: 1;
  transform: scale(1);
  background: var(--teal, #207670);
  border-color: var(--teal, #207670);
}
.mo-tl-item > * {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 300ms var(--mo-ease) 90ms, transform 300ms var(--mo-ease) 90ms;
}
.mo-tl-item.mo-node-lit > * { opacity: 1; transform: none; }

.mo-tl-date {
  display: block;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gold, #c7973e);
  margin-bottom: 0.35rem;
}
.mo-tl-text {
  display: block;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-secondary, #5c5c6e);
}
.mo-tl-item.mo-tl-future .mo-tl-text { font-style: italic; }

/* Vertical on narrow screens. The line runs down the left instead. */
@media (max-width: 720px) {
  .mo-timeline {
    grid-template-columns: 1fr;
    padding-top: 0;
    padding-left: 1.85rem;
    gap: 1.6rem;
  }
  .mo-timeline::before,
  .mo-timeline::after {
    top: 0.45rem;
    bottom: 0.45rem;
    left: 5px;
    right: auto;
    width: 2px;
    height: auto;
  }
  .mo-timeline::after {
    transform: scaleY(var(--mo-progress, 0));
    transform-origin: center top;
  }
  .mo-tl-item { padding: 0; text-align: left; }
  .mo-tl-item::before { top: 0.2rem; left: -1.85rem; margin-left: 0; }
}

/* --------------------------------------------------------- 5. REDUCED MOTION
   Every module resolves to its finished state with no movement. The JS checks
   the same query and short-circuits; this is the second line of defence.     */

@media (prefers-reduced-motion: reduce) {
  .mo-map-armed .mo-marker,
  .mo-map-armed.mo-map-run .mo-marker {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
  .mo-legend-item,
  .mo-legend-item.mo-legend-dim { opacity: 1 !important; }
  .mo-marker-link:hover .mo-marker,
  .mo-marker-link:focus-visible .mo-marker { transform: none !important; }
  .mo-flip-invert, .mo-flip-play { transform: none !important; transition: none !important; }
  .mo-flip-enter { animation: none !important; opacity: 1 !important; }
  .mo-timeline::after { transform: scaleX(1) !important; }
  .mo-tl-item::before { opacity: 1 !important; transform: scale(1) !important;
                        background: var(--teal, #207670) !important;
                        border-color: var(--teal, #207670) !important; }
  .mo-tl-item > * { opacity: 1 !important; transform: none !important; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 720px) {
  .mo-timeline::after { transform: scaleY(1) !important; }
}
