/* RealmStatus and Timeline (scripts/lib/components/milestones.mjs), from the home page's
   realm panel and road to launch. The Open pip is the page's one steady pulse; the route
   line draws in on scroll where the browser supports scroll timelines, with the final state
   as the fallback. The host sets the panel frame; these rules draw what is inside it. */

/* ---------- Realm status ---------- */

.wfg-realm { width: 100%; border-collapse: collapse; font-size: .88rem; }
.wfg-realm caption { padding-bottom: .5rem; font: 400 .8rem/1.3 var(--font-ui); color: var(--ink-3); text-align: left; }
.wfg-realm th, .wfg-realm td { padding: .5rem .35rem; text-align: left; vertical-align: middle; }
.wfg-realm thead th {
  padding-top: 0;
  white-space: nowrap;
  border-bottom: 1px solid var(--edge-inner);
  font-family: var(--font-ui);
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.wfg-realm tbody tr + tr > * { border-top: 1px solid color-mix(in srgb, var(--ink) 5%, transparent); }
.wfg-realm tbody th { font-weight: 600; line-height: 1.25; overflow-wrap: normal; color: var(--ink); }
.wfg-realm tbody th a { display: inline-flex; align-items: center; min-height: 1.75rem; color: inherit; text-decoration: none; }
.wfg-realm tbody th a:hover { text-decoration: underline; text-underline-offset: .18em; }
.wfg-realm td:nth-child(2) { font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
.wfg-realm td:last-child { text-align: right; }
.wfg-realm tr.is-launch th { color: var(--accent-text); }
.wfg-realm-conflict { display: block; font-size: .74rem; white-space: normal; color: var(--ink-3); }
.wfg-realm td .wfg-evidence { margin-left: .35rem; }

.wfg-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .12rem .5rem;
  border-radius: var(--r-ctl);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  font-family: var(--font-ui);
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .04em;
  white-space: nowrap;
  color: var(--ink-2);
}
.wfg-status::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.wfg-status[data-state="open"] { color: var(--new); background: color-mix(in srgb, var(--new) 12%, transparent); }
.wfg-status[data-state="soon"] { color: var(--accent-text); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.wfg-status[data-state="done"] { color: var(--ink-3); }
.wfg-status[data-state="unclear"] { color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-control); }
/* An undated stop (the level-cap raise, the Server Slam): an empty ring, never a live pip. */
.wfg-status[data-state="undated"] { color: var(--ink-3); background: transparent; box-shadow: inset 0 0 0 1px var(--edge-inner); }
.wfg-status[data-state="undated"]::before { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
/* The Open pip's pulse: a ring over the dot that grows and fades (transform and opacity). */
.wfg-status[data-state="open"]::after {
  content: "";
  position: absolute;
  left: .5rem;
  top: 50%;
  width: .45rem;
  height: .45rem;
  margin-top: -.225rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--new);
  opacity: 0;
  animation: wfg-pip 2.2s ease-out infinite;
}
@keyframes wfg-pip {
  0% { transform: scale(1); opacity: .7; }
  70%, 100% { transform: scale(3); opacity: 0; }
}
.wfg-asof { margin: .6rem 0 0; font: 400 .78rem/1.4 var(--font-ui); color: var(--ink-3); }

/* ---------- Journey bar and local time ---------- */

.wfg-journey { margin-top: 1rem; }
.wfg-journey[hidden] { display: none; }
.wfg-journey-track { position: relative; height: 6px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.wfg-journey-fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 45%, transparent), var(--accent)); transform: scaleX(var(--p, 0)); transform-origin: left; transition: transform 1.2s cubic-bezier(.2, .8, .2, 1); }
.wfg-journey-label { display: flex; justify-content: space-between; gap: .5rem; margin: .45rem 0 0; font-size: .72rem; color: var(--ink-3); }
.wfg-journey-label b { font-weight: 600; color: var(--accent-text); }
.wfg-local { margin: .85rem 0 0; font-size: .82rem; color: var(--ink-3); }
.wfg-local b { font-weight: 600; color: var(--ink); }

/* ---------- Timeline ---------- */

.wfg-stops {
  --wfg-node: .95rem;
  --wfg-stop-ground: var(--bg);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3rem 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wfg-stop { position: relative; padding: 1.9rem 1.5rem 0 0; }
.wfg-stop::before, .wfg-stop::after { content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 2px; }
/* The route: dashed where it has not been traveled, solid accent where it has. */
.wfg-stop::before { background: repeating-linear-gradient(90deg, var(--edge-inner) 0 7px, transparent 7px 13px); }
.wfg-stop::after { background: var(--accent); transform: scaleX(0); transform-origin: left; }
.wfg-stop[data-state="past"]::after, .wfg-stop[data-state="now"]::after { transform: scaleX(1); }
.wfg-stop-node {
  position: absolute;
  top: calc(var(--wfg-node) / -2);
  left: 0;
  z-index: 1;
  width: var(--wfg-node);
  height: var(--wfg-node);
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--wfg-stop-ground);
}
.wfg-stop.is-launch .wfg-stop-node { --wfg-node: 1.3rem; top: -.65rem; background: var(--accent); box-shadow: 0 0 0 2px var(--wfg-stop-ground), 0 0 0 3px var(--accent); }
.wfg-stop[data-state="past"] .wfg-stop-node { background: var(--accent); }
.wfg-stop[data-state="now"] .wfg-stop-node { background: var(--accent); box-shadow: 0 0 0 2px var(--wfg-stop-ground), 0 0 0 3px var(--accent); }
.wfg-stops:not(.is-vertical) .wfg-stop:nth-child(4n)::before { right: auto; width: 3rem; background: linear-gradient(90deg, var(--edge-inner), transparent); }
.wfg-stops:not(.is-vertical) .wfg-stop:nth-child(4n)::after { display: none; }
.wfg-stop:last-child::before { display: none; }
.wfg-stop-when { display: block; font-family: var(--font-display); font-size: 1.35rem; font-weight: 400; line-height: 1.2; color: var(--ink); }
.wfg-stop-when small { font-family: var(--font-ui); font-size: .78rem; font-weight: 400; letter-spacing: .06em; color: var(--ink-3); }
.wfg-stops .wfg-stop :is(h2, h3, h4) { margin: .45rem 0 0; font-family: var(--font-ui); font-size: 1rem; font-weight: 400; letter-spacing: 0; }
.wfg-stop :is(h2, h3, h4) a { color: var(--accent-text); text-decoration: none; }
.wfg-stop :is(h2, h3, h4) a:hover { text-decoration: underline; text-underline-offset: .2em; }
.wfg-stop p { margin: .35rem 0 0; font-size: .92rem; line-height: 1.5; color: var(--ink-2); }
.wfg-stop-tag {
  position: absolute;
  z-index: 1;
  top: -.75rem;
  left: 1.6rem;
  padding: .1rem .55rem;
  border-radius: var(--r-ctl);
  background: var(--accent);
  font-family: var(--font-ui);
  font-size: .66rem;
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--on-accent);
}
.wfg-stop-tag[hidden] { display: none; }
.wfg-stop[data-state="past"] .wfg-stop-when, .wfg-stop[data-state="past"] p { color: var(--ink-3); }

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .wfg-stops:not(.is-vertical) .wfg-stop[data-state="past"]::after, .wfg-stops:not(.is-vertical) .wfg-stop[data-state="now"]::after { animation: wfg-draw linear both; animation-timeline: view(); animation-range: entry 20% entry 100%; }
  }
}
@keyframes wfg-draw {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@media (max-width: 60rem) {
  .wfg-stops { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wfg-stops:not(.is-vertical) .wfg-stop:nth-child(4n)::before { right: 0; width: auto; background: repeating-linear-gradient(90deg, var(--edge-inner) 0 7px, transparent 7px 13px); }
  .wfg-stops:not(.is-vertical) .wfg-stop:nth-child(2n)::before { right: auto; width: 3rem; background: linear-gradient(90deg, var(--edge-inner), transparent); }
  .wfg-stops:not(.is-vertical) .wfg-stop:nth-child(2n)::after { display: none; }
  .wfg-stop:last-child::before { display: none; }
}

/* The vertical road: always on /roadmap, and the row layout's phone form. */
.wfg-stops.is-vertical { grid-template-columns: minmax(0, 1fr); gap: 0; padding-left: .5rem; }
.wfg-stops.is-vertical .wfg-stop { padding: 0 0 1.75rem 1.75rem; }
.wfg-stops.is-vertical .wfg-stop::before, .wfg-stops.is-vertical .wfg-stop::after { top: 0; bottom: 0; left: -1px; right: auto; width: 2px; height: auto; }
.wfg-stops.is-vertical .wfg-stop::before { background: repeating-linear-gradient(180deg, var(--edge-inner) 0 7px, transparent 7px 13px); }
.wfg-stops.is-vertical .wfg-stop::after { transform: scaleY(0); transform-origin: top; }
.wfg-stops.is-vertical .wfg-stop[data-state="past"]::after, .wfg-stops.is-vertical .wfg-stop[data-state="now"]::after { transform: scaleY(1); animation: none; }
.wfg-stops.is-vertical .wfg-stop:last-child::before, .wfg-stops.is-vertical .wfg-stop:last-child::after { display: none; }
.wfg-stops.is-vertical .wfg-stop-node { top: .35rem; left: calc(var(--wfg-node) / -2); }
.wfg-stops.is-vertical .wfg-stop.is-launch .wfg-stop-node { top: .2rem; left: -.65rem; }
.wfg-stops.is-vertical .wfg-stop-tag { position: static; display: inline-block; margin-top: .4rem; }
.wfg-stops.is-vertical .wfg-stop-tag[hidden] { display: none; }

@media (max-width: 40rem) {
  .wfg-stops { grid-template-columns: minmax(0, 1fr); gap: 0; padding-left: .5rem; }
  .wfg-stop { padding: 0 0 1.75rem 1.75rem; }
  .wfg-stop::before, .wfg-stop::after { top: 0; bottom: 0; left: -1px; right: auto; width: 2px; height: auto; }
  .wfg-stop::before { background: repeating-linear-gradient(180deg, var(--edge-inner) 0 7px, transparent 7px 13px); }
  .wfg-stop::after { transform: scaleY(0); transform-origin: top; }
  .wfg-stops:not(.is-vertical) .wfg-stop[data-state="past"]::after, .wfg-stops:not(.is-vertical) .wfg-stop[data-state="now"]::after { transform: scaleY(1); animation: none; }
  .wfg-stops:not(.is-vertical) .wfg-stop:nth-child(n)::before { right: auto; width: 2px; background: repeating-linear-gradient(180deg, var(--edge-inner) 0 7px, transparent 7px 13px); }
  .wfg-stops:not(.is-vertical) .wfg-stop:nth-child(n)::after { display: block; }
  .wfg-stops:not(.is-vertical) .wfg-stop:last-child::before, .wfg-stops:not(.is-vertical) .wfg-stop:last-child::after { display: none; }
  .wfg-stop-node { top: .35rem; left: calc(var(--wfg-node) / -2); }
  .wfg-stop.is-launch .wfg-stop-node { top: .2rem; left: -.65rem; }
  .wfg-stop-tag { position: static; display: inline-block; margin-top: .4rem; }
  .wfg-realm { font-size: .84rem; }
  .wfg-realm td:nth-child(2) { font-size: .76rem; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .wfg-status::after, .wfg-stop::after { animation: none !important; }
  .wfg-status[data-state="open"]::after { display: none; }
  .wfg-journey-fill { transition: none; }
}
