/* The admin Timeline tab (Backoffice::TimelineController, timeline_controller.js) */

/* The tab itself: on the far right of the bar, in the primary colour */
.backoffice nav.tabs a.timeline-tab {
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: auto;
  color: var(--ink-900); font-weight: 700;
}
.backoffice nav.tabs a.timeline-tab:hover,
.backoffice nav.tabs a.timeline-tab[aria-current="page"] { color: var(--ink-900); }
.backoffice .timeline-tab .spark {
  position: relative; width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--aura);
}
.backoffice .timeline-tab .spark::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--primary);
  animation: timeline-ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
}

.backoffice main.wide { max-width: 1180px; }

/* Hero. High contrast over the glow: the heading's gradient is the aura's, deeper on light and
   nearly white on dark, and the rest of the text is a step stronger than elsewhere */
.backoffice .timeline-hero {
  --timeline-heading: linear-gradient(135deg, #E0475C 0%, #D63A7A 46%, #5B4CE0 100%);
  --hero-text: var(--ink-900); --hero-muted: var(--ink-700); --hero-accent: var(--primary-hover);
  --hero-glow: calc(var(--glow-opacity) * 2.2);
}
[data-theme="dark"] .backoffice .timeline-hero {
  --timeline-heading: linear-gradient(135deg, #FFFFFF 0%, #FFF1F5 50%, #F1EEFF 100%);
  --hero-text: #FFFFFF; --hero-muted: #ECE8F1; --hero-accent: #D2CCFF;
  --hero-glow: calc(var(--glow-opacity) * 1.4);
}
.backoffice .timeline-hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px 32px;
  padding: 36px 32px 32px; margin-bottom: 24px;
  background: var(--canvas);
  border: 1px solid var(--border); border-radius: var(--r-lg);
}
.backoffice .timeline-hero::before,
.backoffice .timeline-hero::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%;
  filter: blur(48px); opacity: var(--hero-glow);
  animation: timeline-drift 14s ease-in-out infinite alternate;
}
.backoffice .timeline-hero::before { width: 360px; height: 260px; top: -140px; left: -80px; background: #FF8A80; }
.backoffice .timeline-hero::after {
  width: 420px; height: 300px; bottom: -200px; right: -60px; background: var(--primary);
  animation-duration: 18s; animation-direction: alternate-reverse;
}
.backoffice .timeline-hero .eyebrow {
  margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--hero-accent);
}
.backoffice .timeline-hero h1 {
  font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -.035em; line-height: 1.1; margin: 0;
  background: var(--timeline-heading); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: timeline-sheen 8s ease-in-out infinite alternate;
}
.backoffice .timeline-hero .subtle { max-width: 440px; margin-top: 10px; color: var(--hero-muted); }
.backoffice .timeline-hero .subtle a { color: var(--hero-accent); }
.backoffice .hero-text { flex: 1 1 320px; min-width: 0; }
.backoffice .hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 16px; }

.backoffice dl.hero-stats { display: flex; gap: 28px; margin: 0; }
.backoffice dl.hero-stats dt {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--hero-muted);
}
.backoffice dl.hero-stats dd {
  margin: 2px 0 0; color: var(--hero-text); font-size: 30px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}

.backoffice .sync { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 14px; }
.backoffice .sync form { margin: 0; }
.backoffice .sync-status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--hero-muted); }
.backoffice .timeline-hero .secondary-button { color: var(--hero-text); border-color: color-mix(in srgb, var(--hero-text) 35%, transparent); }
.backoffice .timeline-hero .secondary-button:hover { border-color: var(--hero-text); }
.backoffice .live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.backoffice .live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: inherit;
  animation: timeline-ping 2s cubic-bezier(0, 0, .2, 1) infinite;
}
.backoffice .sync-status.failing .live-dot { background: var(--danger); }
.backoffice .sync-error { margin-bottom: 16px; }

/* The two timelines */
.backoffice .project-switch { display: none; }
.backoffice .timelines {
  position: relative;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start;
}

/* Joins pull requests that go together, lined up across the two timelines (timeline_controller.js) */
.backoffice .timelines .bridge {
  position: absolute; z-index: 1; height: 2px; pointer-events: none;
  background: var(--primary);
  transform-origin: left;
  animation: timeline-bridge .8s cubic-bezier(.65, 0, .35, 1) .9s both;
}
.backoffice .timelines .bridge::before {
  content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
}
.backoffice li.lined-up .shipment-card { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }

.backoffice .timeline {
  --accent: var(--primary);
  background: var(--canvas);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px 22px 10px;
}
.backoffice .timeline.grooplo { --badge: var(--aura); }
.backoffice .timeline.grooplo-ios { --badge: linear-gradient(135deg, #8B7FF8 0%, #6D5EF5 55%, #4A3FD1 100%); }

.backoffice .timeline-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px;
  padding-bottom: 18px; margin-bottom: 8px; border-bottom: 1px solid var(--border);
}
.backoffice .timeline-header h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.backoffice .timeline-header .repo { font-size: 13px; font-weight: 500; color: var(--ink-500); }
.backoffice .timeline-header .repo:hover { color: var(--primary); }
.backoffice .project-badge {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  color: #fff; background: var(--badge); border-radius: var(--r-md);
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--primary) 60%, transparent);
}
.backoffice .project-badge svg { width: 22px; height: 22px; }
.backoffice dl.project-stats { display: flex; gap: 18px; margin: 0 0 0 auto; text-align: right; }
.backoffice dl.project-stats dt {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500);
}
.backoffice dl.project-stats dd { margin: 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* The track: a line down the left with a node for each shipment */
/* flow-root, so space timeline_controller.js adds above the first entry doesn't merge with the margin above */
.backoffice ol.track {
  --rail: 30px; position: relative; display: flow-root; list-style: none; margin: 0; padding: 0 0 0 var(--rail);
}
.backoffice ol.track::before {
  content: ""; position: absolute; top: 8px; bottom: 16px; left: 9px; width: 2px; border-radius: 2px;
  background: var(--primary);
  transform-origin: top; animation: timeline-grow 1.4s cubic-bezier(.65, 0, .35, 1) both;
}
/* A glint that runs down the line */
.backoffice ol.track::after {
  content: ""; position: absolute; top: 0; left: 7px; width: 6px; height: 90px; border-radius: 6px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, #fff 85%, var(--primary)), transparent);
  filter: blur(1px); opacity: 0;
  animation: timeline-glint 5s ease-in-out 1.6s infinite;
}

.backoffice li.day {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: baseline; gap: 10px;
  margin-left: calc(var(--rail) * -1); padding: 14px 0 8px;
  background: var(--canvas);
}
/* Fades the entries out under the day as they scroll past it */
.backoffice li.day::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; pointer-events: none;
  background: linear-gradient(to bottom, var(--canvas), transparent);
}
.backoffice li.day h3 {
  margin: 0; padding: 3px 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--info); background: var(--primary-soft); border-radius: var(--r-pill);
}
.backoffice li.day span { font-size: 12px; color: var(--ink-500); }

.backoffice li.shipment { position: relative; padding: 6px 0 12px; }

.backoffice .node {
  position: absolute; z-index: 1; top: 22px; left: calc(var(--rail) * -1 + 3px);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--canvas); border: 3px solid var(--primary);
  animation: timeline-pop .5s cubic-bezier(.34, 1.56, .64, 1) both;
  animation-delay: calc(var(--i) * 70ms + 300ms);
}
/* Pushes are diamonds, in coral */
.backoffice li.push .node { border-color: var(--coral); border-radius: 3px; rotate: 45deg; width: 13px; height: 13px; }
.backoffice li.latest .node { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.backoffice li.latest .node::after {
  content: ""; position: absolute; inset: -6px; border-radius: inherit; border: 2px solid var(--primary);
  animation: timeline-ring 2.2s cubic-bezier(0, 0, .2, 1) 1.2s infinite;
}

.backoffice .shipment-card {
  padding: 13px 16px 12px;
  background: var(--canvas);
  border: 1px solid var(--border); border-radius: var(--r-md);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  animation: timeline-rise .7s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i) * 70ms + 250ms);
}
.backoffice .shipment-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  box-shadow: 0 10px 28px -14px color-mix(in srgb, var(--primary) 55%, transparent);
}
.backoffice li.push .shipment-card {
  border-style: dashed; border-color: color-mix(in srgb, var(--coral) 45%, var(--border));
  background: color-mix(in srgb, var(--coral-soft) 45%, var(--canvas));
}
.backoffice li.latest .shipment-card { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }

.backoffice .shipment-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  font-size: 12px; color: var(--ink-500); margin-bottom: 4px;
}
.backoffice .shipment-meta .kind {
  font-weight: 700; color: var(--info); background: var(--primary-soft);
  border-radius: var(--r-pill); padding: 1px 8px;
}
.backoffice .shipment-meta .kind.push { color: var(--danger); background: var(--coral-soft); }
.backoffice .shipment-meta .kind code { font-size: 11px; padding: 0; background: none; color: inherit; }
.backoffice .shipment-meta time { font-variant-numeric: tabular-nums; }
.backoffice .shipment-meta .newest {
  margin-left: auto; font-weight: 700; color: #fff; background: var(--aura);
  border-radius: var(--r-pill); padding: 1px 9px;
}

.backoffice .shipment-card h4 { margin: 0; font-size: 15px; line-height: 1.35; letter-spacing: -.005em; }
.backoffice .shipment-card h4 a { color: var(--ink-900); }
.backoffice .shipment-card h4 a:hover { color: var(--primary); }

.backoffice .shipment-card .summary { margin: 6px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-700); }

.backoffice .shipment-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.backoffice .churn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.backoffice .churn .added { color: var(--success); }
.backoffice .churn .removed { color: var(--danger); }
.backoffice .churn-bar {
  width: 64px; height: 6px; border-radius: var(--r-pill); background-color: var(--surface-2);
  background-image: linear-gradient(to right, var(--success) 0 var(--added), var(--danger) var(--added) 100%);
  background-size: var(--size) 100%; background-repeat: no-repeat;
  animation: timeline-bar 1s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms + 550ms);
}

.backoffice a.pair {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--info);
  background: var(--primary-soft); border-radius: var(--r-pill); padding: 2px 10px 2px 8px;
  transition: transform .15s ease;
}
.backoffice a.pair:hover { color: var(--info); transform: translateX(2px); }
.backoffice a.pair svg { width: 13px; height: 13px; }

/* New since the page opened, and jumped to from the other project. On the entry rather than its
   card, so a refresh dropping the class doesn't replay the card's own animation. */
.backoffice li.arrived { animation: timeline-arrive 1.8s cubic-bezier(.2, .8, .2, 1) both; }
.backoffice li.spotlight { animation: timeline-spotlight 1.6s ease-out; }

/* Further down, entries rise as they scroll into view, where the browser can tie that to scrolling */
@supports (animation-timeline: view()) {
  .backoffice li.later .shipment-card,
  .backoffice li.later .node {
    animation-delay: 0s;
    animation-timeline: view();
    animation-range: entry 0% entry 70%;
  }
}

@keyframes timeline-rise {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
}
@keyframes timeline-pop {
  from { opacity: 0; scale: .2; }
}
@keyframes timeline-bridge {
  from { transform: scaleX(0); }
}
@keyframes timeline-grow {
  from { transform: scaleY(0); }
}
@keyframes timeline-bar {
  from { background-size: 0 100%; }
}
@keyframes timeline-glint {
  0% { top: 0; opacity: 0; }
  15% { opacity: .9; }
  85% { opacity: .9; }
  100% { top: calc(100% - 90px); opacity: 0; }
}
@keyframes timeline-ping {
  75%, 100% { transform: scale(2.6); opacity: 0; }
}
@keyframes timeline-ring {
  0% { transform: scale(.7); opacity: .9; }
  80%, 100% { transform: scale(1.5); opacity: 0; }
}
@keyframes timeline-drift {
  to { transform: translate(60px, 30px) scale(1.15); }
}
@keyframes timeline-sheen {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}
@keyframes timeline-arrive {
  0% { transform: translateX(-24px); filter: drop-shadow(0 0 0 transparent); }
  35% { transform: none; filter: drop-shadow(0 0 14px color-mix(in srgb, var(--primary) 70%, transparent)); }
  100% { filter: drop-shadow(0 0 0 transparent); }
}
@keyframes timeline-spotlight {
  0%, 35% { filter: drop-shadow(0 0 10px var(--primary)); }
  100% { filter: drop-shadow(0 0 0 transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .backoffice .timeline-page *,
  .backoffice .timeline-page *::before,
  .backoffice .timeline-page *::after,
  .backoffice .timeline-tab .spark::after { animation: none !important; transition: none !important; }
}

/* Narrower screens: one project at a time, picked with a switch */
@media (max-width: 820px) {
  .backoffice .timelines { grid-template-columns: minmax(0, 1fr); }

  .backoffice .project-switch {
    display: flex; gap: 4px; padding: 4px; margin: 0 0 16px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill);
  }
  .backoffice .project-switch input { position: absolute; opacity: 0; pointer-events: none; }
  .backoffice .project-switch label {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 12px; border-radius: var(--r-pill); cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--ink-500);
    transition: background .2s ease, color .2s ease;
  }
  .backoffice .project-switch label svg { width: 16px; height: 16px; }
  .backoffice .project-switch input:checked + label { color: #fff; background: var(--primary); }
  .backoffice .project-switch input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }

  .backoffice .timeline-page:has(#project-grooplo:checked) .timeline:not(.grooplo),
  .backoffice .timeline-page:has(#project-grooplo-ios:checked) .timeline:not(.grooplo-ios) { display: none; }
}

@media (max-width: 640px) {
  .backoffice .timeline-hero { padding: 26px 20px 22px; }
  .backoffice .hero-side { align-items: stretch; width: 100%; }
  .backoffice dl.hero-stats { justify-content: space-between; gap: 12px; }
  .backoffice dl.hero-stats dd { font-size: 24px; }
  .backoffice .sync { justify-content: space-between; }

  .backoffice .timeline { padding: 18px 14px 6px; }
  .backoffice dl.project-stats { margin-left: 0; text-align: left; flex-basis: 100%; }
  .backoffice ol.track { --rail: 26px; }
  .backoffice ol.track::before { left: 7px; }
  .backoffice ol.track::after { left: 5px; }
  .backoffice .shipment-card { padding: 12px 13px 11px; }
  .backoffice .shipment-meta .newest { margin-left: 0; }
}
