/* PeptideScope: #timeline (plain-text timeline, js/timeline.js) and #active-effects (js/effects.js).
   v4 look: one calm card, a big round play button, the time in words in Nunito, a thick rounded
   track with the four milestones on it, the milestones as four soft tiles, then the cited text.
   No graphs, no level or percentage readout (the timeline never shows one). Colours come only from
   tokens.css; amber and red are used only for "notable" and "serious" side effects. */

/* ------------------------------------------------------------------ shared */
.tl-sr, .fx-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.tl, .fx {
  position: relative;
  min-width: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: var(--leading);
}
.tl *, .tl *::before, .tl *::after,
.fx *, .fx *::before, .fx *::after { box-sizing: border-box; }
.tl p, .fx p { margin: 0; }

.tl-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
  line-height: 1.5;
  white-space: nowrap;
}
.tl-chip-unv { background: var(--warn-bg); color: var(--warn-ink); }
.tl-chip[hidden] { display: none; }

.tl-cites { white-space: nowrap; }
.tl-cites .tl-src { white-space: normal; }
.tl .cite, .fx .cite { font-size: 0.72em; line-height: 0; margin-left: 1px; }
.tl .cite a, .fx .cite a { font-weight: var(--weight-bold); color: var(--primary); text-decoration: none; padding: 0 2px; }
.tl .cite a:hover, .fx .cite a:hover { text-decoration: underline; }
.tl-src { display: inline; color: var(--muted); font-size: var(--step--2); }
.tl-src-k { font-weight: var(--weight-bold); }
.tl-src a { color: var(--primary); }

.tl :focus-visible, .fx :focus-visible { outline: 2.5px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-xs); }

/* ------------------------------------------------------------------ timeline card */
.tl {
  display: grid;
  gap: var(--space-m);
  padding: var(--space-m);
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.tl-head { display: grid; gap: var(--space-m); }
.tl-lead { display: flex; align-items: center; gap: 16px; min-width: 0; }
.tl-play {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  transition: background-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.tl-play:hover:not(:disabled) { background: var(--primary-hover); }
.tl-play:active:not(:disabled) { transform: scale(0.96); }
.tl-play:disabled { opacity: 0.4; cursor: not-allowed; }
.tl-ico { width: 24px; height: 24px; fill: currentColor; }
.tl-ico-play { transform: translateX(1.5px); }
.tl-ico-pause { display: none; }
.tl.is-playing .tl-ico-play { display: none; }
.tl.is-playing .tl-ico-pause { display: block; }
/* after the injection animation: one soft ring around Play says "press me next" */
.tl-play::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  pointer-events: none;
}
.tl.is-cued .tl-play::after { animation: tl-cue 2.2s var(--ease) infinite; }
@keyframes tl-cue {
  0% { opacity: 0.7; transform: scale(0.92); }
  70%, 100% { opacity: 0; transform: scale(1.18); }
}

.tl-readout { display: grid; gap: 2px; min-width: 0; }
.tl-eyebrow { color: var(--muted); font-size: var(--step--1); font-weight: var(--weight-medium); }
.tl-time { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; line-height: 1.15; }
.tl-time-main {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--step-2);
  letter-spacing: var(--tracking-display);
  color: var(--text);
}
.tl-time-sub { color: var(--muted); font-size: var(--step--1); }
.tl-time-sub[hidden] { display: none; }
.tl-state { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 2px; }
.tl-state-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.tl.is-disabled .tl-state-dot { background: var(--muted); }
.tl-state-label { font-weight: var(--weight-bold); color: var(--primary); }
.tl.is-disabled .tl-state-label { color: var(--muted); font-weight: var(--weight-medium); }

/* track: a thick rounded groove with the milestones on it; the native range sits on top */
.tl-track { position: relative; min-width: 0; }
.tl-scrub { --thumb: 28px; position: relative; height: var(--thumb); }
.tl-groove {
  position: absolute;
  left: calc(var(--thumb) / 2);
  right: calc(var(--thumb) / 2);
  top: 50%;
  height: 10px;
  margin-top: -5px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tl-groove-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--tl-f, 0) * 100%);
  border-radius: inherit;
  background: var(--primary);
}
.tl-pins { position: absolute; inset: 0; }
.tl-pin {
  position: absolute;
  top: 50%;
  left: calc(var(--p, 0) * 100%);
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  background: var(--surface);
  transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.tl-pin.is-past { border-color: var(--primary); background: var(--primary); }
.tl-pin.is-active { box-shadow: 0 0 0 5px var(--primary-soft); }

.tl-range {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: var(--thumb);
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}
.tl-range:disabled { cursor: not-allowed; opacity: 0.4; }
.tl-range:focus { outline: none; }
.tl-range::-webkit-slider-runnable-track { height: var(--thumb); background: transparent; border: 0; }
.tl-range::-moz-range-track { height: var(--thumb); background: transparent; border: 0; }
.tl-range::-moz-range-progress { background: transparent; }
.tl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-1) var(--ease);
}
.tl-range::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.tl-range:active::-webkit-slider-thumb { transform: scale(1.08); }
.tl-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6.5px var(--focus); }
.tl-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6.5px var(--focus); }

.tl-scrub-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}
.tl-end { color: var(--muted); font-size: var(--step--2); white-space: nowrap; }
.tl-end-stop { text-align: right; }
.tl-range-label { color: var(--text-2); font-size: var(--step--2); font-weight: var(--weight-bold); text-align: center; }
/* the key hint appears only while the scrubber has keyboard focus, floating, so nothing moves */
.tl-keys {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  z-index: 2;
  translate: -50% 0;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-size: var(--step--2);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-1) var(--ease);
}
.tl-track:has(.tl-range:focus-visible) .tl-keys { opacity: 1; }
@media (hover: none) { .tl-keys { display: none; } }
.tl.is-disabled .tl-track { display: none; }

.tl-cue {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-m);
  background: var(--primary-soft);
  color: var(--text);
  font-size: var(--step--1);
  font-weight: var(--weight-medium);
}
.tl-cue[hidden] { display: none; }
.tl-cue-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* milestones: four soft tiles (2 × 2 in narrow columns) */
.tl-miles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tl-miles[hidden] { display: none; }
@container tl (min-width: 620px) { .tl-miles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tl { container: tl / inline-size; }
.tl-mile-item { margin: 0; padding: 0; min-width: 0; display: grid; }
.tl-mile {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 4px;
  width: 100%;
  min-height: 76px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
@media (hover: hover) and (pointer: fine) { .tl-mile:hover { border-color: var(--primary-line); } }
.tl-mile-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  background: var(--surface);
}
.tl-mile-name { font-weight: var(--weight-bold); font-size: 0.9375rem; line-height: 1.25; }
.tl-mile-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; color: var(--muted); font-size: var(--step--2); line-height: 1.35; }
.tl-mile-term, .tl-detail-term { color: var(--muted); }
.tl-mile-fig { color: var(--text-2); font-weight: var(--weight-medium); }
.tl-mile.is-past .tl-mile-dot { border-color: var(--primary); background: var(--primary); }
.tl-mile.is-active { border-color: var(--primary); background: var(--primary-soft); }
.tl-mile.is-active .tl-mile-name { color: var(--primary); }

/* the cited text of the current milestone */
.tl-detail { display: grid; gap: 6px; }
.tl-detail:empty { display: none; }
.tl-detail-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.tl-detail-label { font-family: var(--font-display); font-weight: 800; font-size: var(--step-1); line-height: 1.2; }
.tl-detail-fig {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--step--1);
  font-weight: var(--weight-medium);
}
.tl-detail-text { max-width: var(--measure); color: var(--text-2); line-height: var(--leading); }

/* "with weekly shots": cited text only, folded away */
.tl-weekly { border-top: 1px solid var(--line); padding-top: 12px; }
.tl-weekly[hidden] { display: none; }
.tl-weekly-sum {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}
.tl-weekly-sum::-webkit-details-marker { display: none; }
.tl-weekly-sum::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: rotate(-45deg);
  transition: transform var(--dur-2) var(--ease);
}
.tl-weekly[open] > .tl-weekly-sum::before { transform: rotate(45deg); }
.tl-weekly-label { font-weight: var(--weight-bold); }
.tl-weekly-text { max-width: var(--measure); color: var(--text-2); margin-top: 4px; }

.tl-caption { color: var(--muted); font-size: var(--step--2); line-height: 1.5; }

@media (max-width: 519.98px) {
  .tl { padding: 20px 16px; }
  .tl-play { width: 52px; height: 52px; }
  .tl-mile { min-height: 70px; padding: 10px 12px; }
}

/* ------------------------------------------------------------------ side effects */
.fx { display: grid; gap: var(--space-s); }
/* the section heading already says "Side effects at this point"; the timeline shows the time */
.fx-head { display: flex; align-items: center; justify-content: flex-end; min-height: 0; }
.fx-eyebrow, .fx-when {
  position: absolute !important;
  width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.fx-count {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
}
.fx-count:empty { display: none; }
.fx-head:has(.fx-count:empty) { display: none; }

.fx-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.fx-list:focus { outline: none; }
.fx-list:empty { display: none; }
.fx-card {
  --sev: var(--muted);
  --sev-soft: var(--surface-2);
  --sev-ink: var(--text-2);
  display: grid;
  gap: 6px;
  padding: 16px 18px 10px;
  border-radius: var(--radius-l);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.fx-card-notable { --sev: var(--warn); --sev-soft: var(--warn-bg); --sev-ink: var(--warn-ink); }
.fx-card-serious { --sev: var(--danger); --sev-soft: var(--danger-bg); --sev-ink: var(--danger-ink); border-color: var(--danger-line); }
.fx-card.is-entering { opacity: 0; transform: translateY(6px); }
.fx-card.is-leaving { opacity: 0; transform: translateY(-4px); }
.fx-card[hidden] { display: none; }
.fx-rm .fx-card { transition: opacity var(--dur-fade, 100ms) linear; }
.fx-rm .fx-card.is-entering, .fx-rm .fx-card.is-leaving { transform: none; }

.fx-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.fx-sev {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--sev-soft);
  color: var(--sev-ink);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
}
.fx-organ { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--step--1); font-weight: var(--weight-medium); }
.fx-organ-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.fx-also { color: var(--muted); font-weight: 400; }
.fx-locate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-left: auto;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--primary);
  font-size: var(--step--1);
  font-weight: var(--weight-bold);
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
@media (hover: hover) and (pointer: fine) { .fx-locate:hover { background: var(--primary-soft); border-color: var(--primary-line); } }
.fx-locate-ico { position: relative; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; }
.fx-locate-ico::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: currentColor; }
.fx-name { margin: 2px 0 0; font-family: var(--font-display); font-size: var(--step-1); font-weight: 800; line-height: 1.25; color: var(--text); }
/* one plain line under the name: when it tends to show */
.fx-line { color: var(--text-2); font-size: var(--step--1); line-height: 1.5; max-width: 60ch; }
/* labels stacked above full-width text (no hanging indent) */
.fx-more-body { display: grid; gap: 12px; padding: 4px 0 12px; }
.fx-kv { display: grid; gap: 2px; }
.fx-more .fx-k { padding: 0; color: var(--muted); font-weight: var(--weight-bold); font-size: var(--step--2); letter-spacing: 0.01em; }
.fx-v { min-width: 0; margin: 0; padding: 0 !important; color: var(--text-2); font-size: var(--step--1); line-height: var(--leading); }
.fx-more { border-top: 0; }
.fx-more summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  font-weight: var(--weight-bold);
  font-size: var(--step--1);
  color: var(--text);
}
.fx-more summary::-webkit-details-marker { display: none; }
.fx-more summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--dur-2) var(--ease);
}
.fx-more[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
@media (hover: hover) and (pointer: fine) { .fx-more summary:hover { color: var(--primary); } }
.fx-more summary { color: var(--primary); }
.fx-more p { padding: 0 0 12px; color: var(--text-2); font-size: var(--step--1); line-height: var(--leading); }

.fx-toggle {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line-strong);
  color: var(--text);
  font-weight: var(--weight-bold);
  font-size: var(--step--1);
}
@media (hover: hover) and (pointer: fine) { .fx-toggle:hover { border-color: var(--primary); color: var(--primary); } }
.fx-toggle[hidden] { display: none; }
.fx-empty {
  padding: 18px 20px;
  border-radius: var(--radius-l);
  border: 1.5px dashed var(--line-strong);
  color: var(--muted);
}
.fx-empty[hidden] { display: none; }
.fx-note { color: var(--muted); font-size: var(--step--2); line-height: 1.55; }

/* ------------------------------------------------------------------ reduced motion */
.tl-rm .tl-play::after, .tl-rm.is-cued .tl-play::after { animation: none; }
.tl-rm.is-cued .tl-play::after { opacity: 0.6; transform: scale(1.1); }
.tl-rm .tl-pin, .tl-rm .tl-mile, .tl-rm .tl-keys { transition: none; }
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) .tl-play::after { animation: none !important; }
  html:not([data-motion="full"]) .fx-card { transition: opacity 100ms linear; transform: none !important; }
}
@media (forced-colors: active) {
  .tl-groove-fill, .tl-pin.is-past, .tl-mile.is-past .tl-mile-dot { background: Highlight; }
  .tl-mile.is-active { border-color: Highlight; }
  .fx-card { border: 1px solid CanvasText; }
}
