/* Time Machine — owner: ui-lab. */

.tl-root {
  --tl-early: #f5b544;
  --tl-warn: var(--warn, #f5b544);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 4px 14px 4px;
  box-sizing: border-box;
  color: var(--text, #e7edf8);
  font-size: var(--fs-xs, 11.5px);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- controls row */
.tl-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 28px;
  flex-shrink: 0;
}
.tl-transport { display: flex; align-items: center; gap: 4px; }
.tl-play {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--accent, #6c8cff);
  color: var(--on-accent, #050814);
  cursor: pointer;
  box-shadow: 0 0 0 0 var(--accent-glow);
  transition: transform var(--dur-1, 120ms), box-shadow var(--dur-2, 220ms);
}
.tl-play svg { width: 12px; height: 12px; fill: currentColor; }
.tl-play:hover { transform: scale(1.06); }
.tl-play.playing { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 18px var(--accent-glow); animation: tl-breathe 1.6s ease-in-out infinite; }
@keyframes tl-breathe {
  50% { box-shadow: 0 0 0 6px var(--accent-soft), 0 0 26px var(--accent-glow); }
}
.tl-btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--r-sm, 6px);
  border: 1px solid var(--border, rgba(150, 172, 230, 0.11));
  background: var(--panel-2, rgba(22, 32, 58, 0.72));
  color: var(--text-2, #b9c4da);
  cursor: pointer;
}
.tl-btn:hover:not([disabled]) { color: var(--text); border-color: var(--border-strong); }
.tl-btn[disabled] { opacity: 0.4; cursor: default; }
.tl-btn.icon { width: 24px; padding: 0; justify-content: center; font-size: 16px; line-height: 1; }
.tl-btn kbd { font-size: 9px; }
.tl-play:focus-visible,
.tl-btn:focus-visible,
.tl-speed-btn:focus-visible,
.tl-track:focus-visible { outline: none; box-shadow: var(--ring); }

.tl-speed {
  display: inline-flex;
  margin-left: 4px;
  padding: 2px;
  border-radius: var(--r-pill, 999px);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}
.tl-speed-btn {
  font: inherit;
  font-family: var(--font-mono, ui-monospace);
  font-size: 10px;
  padding: 1px 7px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tl-speed-btn.on { background: var(--accent-soft); color: var(--accent-strong); }

.tl-now {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.tl-date {
  font-family: var(--font-mono, ui-monospace);
  font-size: var(--fs-md, 13.5px);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.tl-root.time-travel .tl-date { color: var(--tl-warn); text-shadow: 0 0 12px color-mix(in srgb, var(--tl-warn) 50%, transparent); }
.tl-wd { color: var(--muted); }
.tl-stats { color: var(--muted); overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.tl-legend {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: var(--fs-2xs, 10.5px);
  white-space: nowrap;
}
.tl-legend > span { display: inline-flex; align-items: center; gap: 4px; }
.tl-legend > span::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }
.lg-bo::before { background: var(--up, #ff4d5e); }
.lg-early::before { background: var(--tl-early); }
.lg-idx::before { height: 2px !important; background: var(--accent); }
.tl-latest[disabled] { display: none; }
.tl-root.time-travel .tl-latest {
  color: var(--on-accent, #050814);
  background: var(--tl-warn);
  border-color: var(--tl-warn);
  font-weight: 600;
}

/* ---------- track */
.tl-track {
  position: relative;
  flex: 1;
  min-height: 40px;
  cursor: ew-resize;
  touch-action: none;
  outline: none;
  border-radius: var(--r-sm, 6px);
}
.tl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tl-root.tl-loading .tl-canvas { opacity: 0.75; transition: opacity 200ms; }
.tl-track.dragging { cursor: grabbing; }
.tl-tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--panel-solid, #0d1427);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  pointer-events: none;
  font-size: var(--fs-2xs);
  color: var(--text-2);
  z-index: 5;
}
.tl-tip strong { font-family: var(--font-mono); color: var(--text); }
.tt-bo { color: var(--up); }
.tt-early { color: var(--tl-early); }

/* ---------- time-travel banner (floats above the dock) */
.tl-banner {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 7px 8px 7px 14px;
  border-radius: var(--r-pill, 999px);
  background: color-mix(in srgb, var(--panel-solid, #0d1427) 88%, var(--tl-warn));
  border: 1px solid var(--tl-warn);
  color: var(--text);
  box-shadow: 0 0 0 4px var(--warn-soft, rgba(245, 181, 68, 0.14)), 0 12px 40px -10px rgba(0, 0, 0, 0.7), 0 0 40px -8px color-mix(in srgb, var(--tl-warn) 60%, transparent);
  font-size: var(--fs-sm, 12.5px);
  white-space: nowrap;
  z-index: 20;
  animation: tl-banner-in 380ms var(--ease-spring, ease-out);
  backdrop-filter: blur(12px);
}
.tl-banner[hidden] { display: none; }
@keyframes tl-banner-in {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.96); }
}
.tl-banner-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--tl-warn);
  color: #1a1204;
  font-weight: 800;
  animation: tl-spin 600ms ease-out 1 reverse; /* spin once on enter, then rest */
}
@keyframes tl-spin {
  to { transform: rotate(360deg); }
}
.tl-banner-text { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.tl-banner-ago { color: var(--tl-warn); font-family: var(--font-mono); font-size: var(--fs-xs); }
.tl-latest-inline {
  border-radius: var(--r-pill);
  background: var(--tl-warn);
  color: #1a1204;
  border-color: var(--tl-warn);
  font-weight: 700;
}

/* Whole-app amber frame while time travelling — impossible to mistake history for today. */
body.tm-active::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--warn, #f5b544) 70%, transparent), inset 0 0 60px -20px var(--warn, #f5b544);
  animation: tl-frame-in 300ms ease-out;
}
@keyframes tl-frame-in {
  from { opacity: 0; }
}

@media (max-width: 760px) {
  .tl-legend > span,
  .tl-stats { display: none; }
  .tl-banner { white-space: normal; border-radius: var(--r-lg); }
  .tl-banner-ago { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tl-play.playing,
  .tl-banner,
  .tl-banner-icon,
  body.tm-active::after { animation: none; }
}

/* Keep the banner centred on the visible stage (between the lab and an open drawer) — desktop only;
   below 901px the lab is a bottom sheet, not a column. */
@media (min-width: 901px) {
  .app:not(.lab-collapsed) .tl-banner { left: calc(var(--lab-w) + (100% - var(--lab-w)) / 2); }
  .app.drawer-open .tl-banner { left: calc(var(--lab-w) + (100% - var(--lab-w) - var(--drawer-w)) / 2); max-width: calc(100% - var(--lab-w) - var(--drawer-w) - 24px); }
  .app.drawer-open.lab-collapsed .tl-banner { left: calc((100% - var(--drawer-w)) / 2); max-width: calc(100% - var(--drawer-w) - 24px); }
  .app.drawer-open .tl-banner-ago { display: none; }
}
@media (max-width: 900px) {
  .app .tl-banner,
  .app.drawer-open .tl-banner { left: 50%; max-width: calc(100% - 24px); }
}
.tl-banner-short { display: none; }
@media (max-width: 760px) {
  .app .tl-banner,
  .app.drawer-open .tl-banner {
    left: 12px;
    right: 12px;
    transform: none;
    max-width: none;
    justify-content: space-between;
    border-radius: var(--r-lg, 14px);
    white-space: nowrap;
    animation-name: tl-banner-in-m;
  }
  .tl-banner-long { display: none; }
  .tl-banner-short { display: inline; }
}
@keyframes tl-banner-in-m {
  from { opacity: 0; transform: translateY(10px); }
}
