/* The run processing loader (js/run-processing-loader.js): the Relay logo (static/relay-loader.css
   turns .proc-logo-spinner-wrap into the Relay art; the ripple rings are dead on purpose), the
   title, "N activities analysed", the level-line bar and the runs going by. One copy for every
   source that processes runs: Garmin and Apple Health (garmin-profile.html) and Stryd
   (stryd-profile.html). The page sets --ra-results-min-h (the results' height) on a parent.
   Phases on the root: proc-phase-init (hidden; the page's skeleton stands for it),
   proc-phase-analysing, + proc-phase-finalising. */

/* Processing runs (or waiting for the source to send them) is this loader (owner 2026-10-19:
   "we had this progress bar, with the pulsating logo above it, with all the runs that were
   being processed"); the page's skeleton steps aside meanwhile. */
[data-run-processing-loader].proc-phase-init { display: none !important; }
body:has([data-run-processing-loader]:is(.proc-phase-analysing, .proc-phase-finalising)) :is(#procPrePlaceholder, [data-run-processing-skeleton]) { display: none !important; }
/* A first sync shows only the processing card (owner 2026-10-19: "until done with processing,
   no other card is shown; this is for EVERY TYPE"): the source card (figures, connection,
   Sync) comes back with the results. js/run-processing-loader.js isFirstRunSync(). */
html[data-first-runs] body:has([data-run-processing-loader]:is(.proc-phase-analysing, .proc-phase-finalising)) :is(#garminProfileControls, #stravaProfileControls, #appleHealthProfileControls, #strydRunOverview, [data-run-processing-source-card]) { display: none !important; }

/* -- Data Processing Section - Logo Spinner -- */
.proc-logo-spinner-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  overflow: visible;
}
.proc-logo-spinner-wrap img {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  height: 32px;
  z-index: 10;
  filter: drop-shadow(0 0 16px rgba(46, 209, 244, 0.5));
}
.proc-logo-spinner-wrap .proc-logo-glow {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80px; height: 80px;
  background: radial-gradient(circle, rgba(46, 209, 244, 0.18) 0%, transparent 70%);
  border-radius: 50%;
}
.proc-logo-spinner-wrap svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform: rotate(-90deg);
  z-index: 2;
}
/* Magic UI Ripple - two rings behind the logo */
@keyframes procRipplePulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.96); opacity: 0.5; }
  50%       { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}
@keyframes procRippleGlow {
  0%, 100% { box-shadow: 0 0  4px 0px rgba(46, 209, 244, 0.10), inset 0 0 2px rgba(46, 209, 244, 0.03); }
  50%       { box-shadow: 0 0 14px 4px rgba(46, 209, 244, 0.45), inset 0 0 8px rgba(46, 209, 244, 0.10); }
}
.proc-ripple-ring {
  position: absolute;
  top: 50%; left: 50%;
  /* translate is here in the base so rings stay centred during any animation delay */
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid rgba(46, 209, 244, 0.70);
  background: transparent;
  animation: procRipplePulse 4s ease-in-out infinite, procRippleGlow 4s ease-in-out infinite;
  animation-fill-mode: backwards;
  pointer-events: none;
  z-index: 0;
}
/* inner ring: child 2; outer ring: child 3 */
.proc-ripple-ring:nth-child(2) { width: 104px; height: 104px; animation-delay: 0s; }
.proc-ripple-ring:nth-child(3) { width: 136px; height: 136px; animation-delay: 0.6s; border-color: rgba(46, 209, 244, 0.40); }


@keyframes procEnterFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

[data-run-processing-loader] { padding: 32px 0; display: none; flex-direction: column; align-items: center; min-height: var(--ra-results-min-h, 220px); justify-content: center; }
/* Fading out while the results fade in: out of the flow, over the results. */
[data-run-processing-loader].proc-overlay { position: absolute; right: 0; left: 0; z-index: 2; pointer-events: none; }
/* Container fades in as one unit - no per-child stagger (avoids position glitches) */
[data-run-processing-loader].proc-entering {
  animation: procEnterFade 0.45s ease both;
}

/* -- Phase system: init → analysing → done -- */
/* Init phase: just spinner + text, no progress/feed */
[data-run-processing-loader].proc-phase-init .proc-progress-track,
[data-run-processing-loader].proc-phase-init .proc-feed,
[data-run-processing-loader].proc-phase-init .proc-counter { display: none !important; }
[data-run-processing-loader].proc-phase-init .proc-spinner { width: 28px; height: 28px; border-width: 3px; }
/* Analysing phase: full animation visible */
[data-run-processing-loader].proc-phase-analysing .proc-progress-track,
[data-run-processing-loader].proc-phase-analysing .proc-feed,
[data-run-processing-loader].proc-phase-analysing .proc-counter { display: inherit; }
[data-run-processing-loader].proc-phase-analysing .proc-spinner { width: 36px; height: 36px; border-width: 3px; }
[data-run-processing-loader].proc-phase-finalising {
  min-height: var(--ra-results-min-h, 220px);
  padding: 20px 0 12px;
}
[data-run-processing-loader].proc-phase-finalising .proc-feed,
[data-run-processing-loader].proc-phase-finalising .proc-patience-note {
  display: none !important;
}

/* -- Centered spinner -- */
.proc-spinner-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 18px; position: relative; z-index: 20; overflow: visible; }
.proc-spinner { border: 3px solid rgba(46, 209, 244,.15); border-top-color: #2ED1F4; border-radius: 50%; animation: proc-spin 1s linear infinite; filter: drop-shadow(0 0 6px rgba(46, 209, 244,.35)); transition: width .4s ease, height .4s ease; }
@keyframes proc-spin { to { transform: rotate(360deg); } }
.proc-title { display: inline-block; min-height: 1.35em; color: #fff; font-weight: 600; font-size: var(--ri-text-subtitle); letter-spacing: 0; line-height: var(--ri-leading-subtitle); max-width: min(92vw, 420px); text-align: center; transition: opacity .35s ease; contain: paint; -webkit-font-smoothing: antialiased; }
.proc-title.text-fading { opacity: 0; }
.proc-patience-note {
  color: rgba(186, 230, 253, 0.72);
  font-size: var(--ri-text-caption);
  line-height: var(--ri-leading-caption);
  text-align: center;
  max-width: 280px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transform: translateY(-4px);
  transition: opacity .38s ease, transform .38s ease, max-height .38s ease, margin .38s ease;
  margin: -8px auto 0;
}
.proc-patience-note.visible {
  max-height: 42px;
  opacity: 1;
  overflow: visible;
  transform: translateY(0);
  margin: -3px auto 2px;
  z-index: 300;
}
.proc-patience-note .section-tooltip-trigger {
  position: relative;
  flex: 0 0 auto;
  z-index: 350;
}
.proc-patience-note .section-tooltip-btn {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  transform-origin: center;
}
.proc-patience-note .section-tooltip-btn svg {
  width: 15px !important;
  height: 15px !important;
  min-width: 15px !important;
  min-height: 15px !important;
  flex-basis: 15px !important;
}
.proc-patience-note .section-tooltip {
  left: 50%;
  min-width: min(420px, calc(100vw - 40px)) !important;
  max-width: min(460px, calc(100vw - 40px)) !important;
  padding: 16px 18px !important;
  transform: translate(-50%, 10px);
  z-index: 2147483647 !important;
}
.proc-patience-note .section-tooltip p {
  margin: 0;
  line-height: 1.55;
}
.proc-patience-note .section-tooltip::after {
  left: calc(50% - 6px);
}
@media (min-width: 640px) {
  .proc-patience-note .section-tooltip-trigger:hover .section-tooltip,
  .proc-patience-note .section-tooltip-trigger.tooltip-active .section-tooltip,
  .proc-patience-note .section-tooltip.tooltip-open {
    transform: translate(-50%, 0);
  }
}
[data-run-processing-loader].proc-phase-init .proc-patience-note { display: none; }
.proc-counter { color: rgba(255,255,255,.5); font-size: var(--ri-text-caption); margin-bottom: 4px; text-align: center; display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.proc-counter-main { display: inline-flex; align-items: center; transition: transform .32s ease; }
.proc-counter.has-valid .proc-counter-main { transform: translateX(-7px); }
.proc-counter .proc-num { color: #2ED1F4; font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 4px; display: inline-block; }
.proc-valid-inline {
  display: inline-flex;
  align-items: center;
  color: rgba(255,255,255,.5);
  font-size: var(--ri-text-caption);
  opacity: 0;
  margin-left: 0;
  max-width: 0;
  overflow: hidden;
  transform: translateX(-4px);
  transition: opacity .32s ease, max-width .32s ease, margin-left .32s ease, transform .32s ease;
}
.proc-valid-inline.visible {
  opacity: 1;
  max-width: 170px;
  margin-left: 10px;
  transform: translateX(0);
}
.proc-valid-inline .proc-valid-num { color: #34d399; font-weight: 600; margin-right: 4px; }

/* -- Progress bar: the level line (owner 2026-10-07; ui-components.css
   .ri-level-track / .ri-level-fill). Cyan while it runs, green when done. -- */
.proc-progress-track { width: 100%; max-width: 300px; height: 8px; border-radius: 5px; margin-bottom: 22px; position: relative; }
.proc-progress-fill { --bar-rgb: 46, 209, 244; height: 100%; width: 0%; border-radius: 5px; transition: width .4s cubic-bezier(.4,0,.2,1), background .45s ease, box-shadow .45s ease; position: relative; }
.proc-progress-fill.proc-progress-complete { --bar-rgb: 34, 197, 94; }

/* -- Run feed -- */
.proc-feed { position: relative; width: 100%; max-width: 340px; height: 110px; overflow: visible; margin: 0 auto; }
.proc-feed-inner { display: flex; flex-direction: column; gap: 5px; height: 100%; width: 100%; align-items: stretch; overflow: visible; }

/* Mobile-only compact processing layout */
@media (max-width: 640px) {
  [data-run-processing-loader] { padding: 20px 0 14px; }
  .proc-spinner-wrap { gap: 10px; margin-bottom: 10px; }
  .proc-progress-track { max-width: 240px; margin-bottom: 12px; }
  .proc-patience-note {
    max-width: 232px;
    line-height: 1.3;
  }
  .proc-counter {
    max-width: 240px;
    width: 100%;
    margin: 0 auto 4px;
  }
  .proc-counter .proc-num {
    line-height: 1;
  }
  .proc-valid-inline .proc-valid-num {
    line-height: 1;
  }
  .proc-feed { max-width: 272px; height: 92px; }
  .proc-feed-inner { gap: 4px; }
  .proc-run { min-height: 24px; padding: 4px 8px; gap: 6px; }
}

/* -- Individual run row - compact queue item -- */
/* Rows are app tiles (owner 2026-10-19: "in line with our CURRENT styling"): the tile
   surface, and a run type lights its row from the inside only (the inner-glow rule:
   nothing drawn outside a tile). */
.proc-run { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: var(--ri-radius-sm, 8px); background: var(--ri-surface-tile, rgba(255,255,255,.04)); border: 1px solid rgba(255,255,255,.08); animation: proc-enter .5s cubic-bezier(.25,.1,.25,1) forwards; min-height: 28px; flex-shrink: 0; width: 100%; box-sizing: border-box; transition: box-shadow .5s ease, border-color .5s ease; }
.proc-run[class*="proc-glow-"] { --proc-run-rgb: var(--ri-cyan-rgb, 46, 209, 244); box-shadow: inset 0 0 14px rgba(var(--proc-run-rgb), .16); border-color: rgba(var(--proc-run-rgb), .32); }
.proc-run.proc-glow-daily { --proc-run-rgb: var(--ri-run-daily-rgb, 59, 130, 246); }
.proc-run.proc-glow-tempo { --proc-run-rgb: var(--ri-run-tempo-rgb, 249, 115, 22); }
.proc-run.proc-glow-race { --proc-run-rgb: var(--ri-run-race-rgb, 239, 68, 68); }
.proc-run.proc-glow-interval { --proc-run-rgb: 234, 179, 8; }
@keyframes proc-enter { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Top run highlight - the one currently being "processed" */
.proc-run.proc-active { border-color: rgba(255,255,255,.08); }

/* Type-specific glow on classification */

/* Exit animations */
.proc-run.proc-exit-left { animation: proc-slide-left .35s ease forwards !important; }
.proc-run.proc-exit-right { animation: proc-slide-right .35s ease forwards !important; }
@keyframes proc-slide-left { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-60px); } }
@keyframes proc-slide-right { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(60px); } }

/* Discarded styling - only applied when classified */
.proc-run.proc-classified-discard { filter: opacity(.45); }
.proc-run.proc-classified-discard .proc-run-details { text-decoration: line-through; text-decoration-color: rgba(255,255,255,.18); }

.proc-run-details { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: var(--ri-text-label); color: rgba(255,255,255,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .22s ease, transform .22s ease; }
.proc-run-details.proc-details-fade-out { opacity: 0; transform: translateY(-3px); }
.proc-run-details.proc-details-fade-in { animation: proc-details-fade-in .32s ease forwards; }
@keyframes proc-details-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.proc-run-detail { display: inline-flex; align-items: center; min-width: 0; }
.proc-run-detail-date { color: rgba(255,255,255,.58); font-size: var(--ri-text-label); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

/* -- Classification pill -- */
/* The classification is the shared tag (.ri-tag); a skipped run is dimmed,
   a pending one shows three dots. */
.proc-pill { flex-shrink: 0; transition: opacity .3s ease; }
.proc-pill-discard { opacity: .6; }
.proc-pill-pending { align-items: flex-end; justify-content: center; gap: 4px; min-width: 44px; padding-bottom: 7px; }
.proc-pill-pending .proc-pending-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .22; }
.proc-feed-inner > .proc-run:first-child .proc-pill-pending .proc-pending-dot,
.proc-run.proc-active .proc-pill-pending .proc-pending-dot { opacity: .35; animation: proc-pending-bounce 1.05s ease-in-out infinite; }
.proc-feed-inner > .proc-run:first-child .proc-pill-pending .proc-pending-dot:nth-child(2),
.proc-run.proc-active .proc-pill-pending .proc-pending-dot:nth-child(2) { animation-delay: .14s; }
.proc-feed-inner > .proc-run:first-child .proc-pill-pending .proc-pending-dot:nth-child(3),
.proc-run.proc-active .proc-pill-pending .proc-pending-dot:nth-child(3) { animation-delay: .28s; }
@keyframes proc-pending-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-3px); opacity: 1; }
}

[data-run-processing-loader].proc-finishing { transition: opacity 160ms ease; }
[data-run-processing-loader].proc-finishing.proc-fade-out { opacity: 0; }

/* -- Done: the logo turns into the check (owner 2026-10-20) --
   Any finalising (the page still loading the results behind it) reads as done: green check
   in the logo's place, the bar full in the complete green. relay-loader.css paints the logo
   as the wrap's background and hides its children, so the check is the wrap's ::before/::after. */
@keyframes procDoneRing { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes procDoneCheck { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
[data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap { background-image: none !important; }
[data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap::before,
[data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
[data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap::before {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 1.5px solid rgba(34, 197, 94, .7);
  background: radial-gradient(circle, rgba(34, 197, 94, .16) 0%, rgba(34, 197, 94, .04) 70%);
  box-shadow: 0 0 18px 2px rgba(34, 197, 94, .35), inset 0 0 8px rgba(34, 197, 94, .12);
  animation: procDoneRing .35s ease-out both;
}
[data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap::after {
  width: 32px; height: 32px;
  background: #22c55e;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.29289 12.70711L9 19.41421L21.70711 6.70711L20.29289 5.29289L9 16.58579L3.70711 11.29289Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.29289 12.70711L9 19.41421L21.70711 6.70711L20.29289 5.29289L9 16.58579L3.70711 11.29289Z'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 0 8px rgba(34, 197, 94, .55));
  animation: procDoneCheck .45s .12s cubic-bezier(.2, .9, .3, 1.2) both;
}
[data-run-processing-loader].proc-phase-finalising .proc-progress-fill { width: 100% !important; --bar-rgb: 34, 197, 94; }
@media (prefers-reduced-motion: reduce) {
  [data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap::before,
  [data-run-processing-loader].proc-phase-finalising .proc-logo-spinner-wrap::after { animation: none; }
}
