/* 10X Vital Intelligence: closed-loop widget (light). Every selector is scoped to the mount or #loop-steps.
   The mount sits directly on the page; the canvas draws its own white dial plate with a soft shadow. */
[data-widget="loop"] {
  position: relative;
  display: block;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1;
  margin-left: auto;
  margin-right: auto;
  overflow: visible;
  -webkit-user-select: none;
  user-select: none;
}
@supports not (aspect-ratio: 1 / 1) {
  [data-widget="loop"] { height: 0; padding-bottom: 100%; }
}
[data-widget="loop"] .lp-stage { position: absolute; inset: 0; }
[data-widget="loop"] .lp-canvas { position: absolute; left: 0; top: 0; display: block; width: 100%; height: 100%; }

[data-widget="loop"] .lp-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 4px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
}
[data-widget="loop"] .lp-pos-top { transform: translate(-50%, -100%); align-items: center; text-align: center; }
[data-widget="loop"] .lp-pos-bottom { transform: translate(-50%, 0); align-items: center; text-align: center; }
[data-widget="loop"] .lp-pos-right { transform: translate(0, -50%); align-items: flex-start; text-align: left; }
[data-widget="loop"] .lp-pos-left { transform: translate(-100%, -50%); align-items: flex-end; text-align: right; }

[data-widget="loop"] .lp-num {
  font-family: var(--mono, "JetBrains Mono", ui-monospace, Menlo, monospace);
  font-size: 0.6875rem;               /* 11px at the default text size; follows the reader's setting */
  font-weight: 500;
  letter-spacing: .14em;
  margin-right: -.14em;               /* trailing tracking out of the box, so the number centres optically */
  color: var(--muted, #64748b);
  transition: color var(--dur-3, 400ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
[data-widget="loop"] .lp-name {
  font-family: var(--display, "Space Grotesk", system-ui, sans-serif);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.15;
  color: var(--text, #475569);
  transition: color var(--dur-3, 400ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
[data-widget="loop"] .lp-label.is-active .lp-num { color: var(--lp-ink, var(--orange-ink, #c2410c)); }
[data-widget="loop"] .lp-label.is-active .lp-name { color: var(--head, #0f172a); }

/* phones: numbers only, the list beside carries the names */
[data-widget="loop"].lp-compact .lp-name,
[data-widget="loop"].lp-inner .lp-name { display: none; }
[data-widget="loop"].lp-compact .lp-num { font-size: 0.75rem; }
/* numbers inside the track (the short pinned ring): a touch smaller so they sit clear of the model well */
[data-widget="loop"].lp-inner .lp-num { font-size: 0.6875rem; }

[data-widget="loop"] .lp-core {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, Menlo, monospace);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}
[data-widget="loop"] .lp-core span { white-space: nowrap; margin-right: -.14em; }
[data-widget="loop"].lp-bare .lp-core { display: none; }
[data-widget="loop"].lp-pointing { cursor: default; }

/* the step list, kept in sync with the ring; each step takes its place on the brand ramp, orange to amber
   to sky (set by the script as --lp-c, with a text-safe twin --lp-ink for the small step numbers) */
#loop-steps li[data-step="1"] .num { color: var(--lp-ink, var(--orange-ink, #c2410c)); }
#loop-steps li[data-step="2"] .num { color: var(--lp-ink, var(--orange-ink, #c2410c)); }
#loop-steps li[data-step="3"] .num { color: var(--lp-ink, var(--amber-ink, #b45309)); }
#loop-steps li[data-step="4"] .num { color: var(--lp-ink, var(--sky-ink, #0369a1)); }
#loop-steps li[data-step="5"] .num { color: var(--lp-ink, var(--sky-ink, #0369a1)); }
#loop-steps li[data-step="6"] .num { color: var(--lp-ink, var(--sky-ink, #0369a1)); }
/* one state timing for the whole step change (number, title, card, bar), in step with the ring's labels;
   the background sweep is the one longer gesture */
#loop-steps li .num,
#loop-steps li h3 { transition: color var(--dur-3, 400ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)); }
#loop-steps li {
  background-color: rgba(255, 255, 255, 0);
  background-image: linear-gradient(90deg, var(--lp-soft, rgba(249, 115, 22, .07)), var(--lp-soft-0, rgba(249, 115, 22, 0)) 75%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  box-shadow: 0 0 0 1px rgba(226, 232, 240, 0), 0 1px 2px rgba(15, 23, 42, 0), 0 8px 24px -12px rgba(15, 23, 42, 0);
  transition: background-size .6s var(--ease-out, cubic-bezier(.2, .7, .2, 1)),
    background-color var(--dur-3, 400ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)),
    box-shadow var(--dur-3, 400ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
#loop-steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 2px;
  border-radius: 2px;
  background: var(--lp-c, var(--orange, #f97316));
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform var(--dur-3, 400ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
  pointer-events: none;
}
#loop-steps li.is-active {
  background-color: var(--bg, #fff);
  background-size: 100% 100%;
  /* the shared plate depth, with the hairline as a ring */
  box-shadow: 0 0 0 1px var(--line, #e2e8f0), var(--shadow-plate, 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12));
}
#loop-steps li.is-active::before { transform: scaleY(1); }
#loop-steps li.is-active h3 { color: var(--head, #0f172a); }

/* phones and portrait tablets: the ring pins under the nav while the steps scroll beneath it, and the
   step nearest the ring lights up (the script drives this from scroll position under the same query).
   An opaque band in the section tint, full bleed, hides the passing steps; only a short feather shows. */
@media (max-width: 960px) and (min-height: 600px) {
  .loop > .widget[data-widget="loop"] {
    position: sticky;
    top: var(--sticky-top, 76px);   /* follows the nav if it slides away while reading */
    z-index: 1;
    width: clamp(220px, min(62vw, 30vh), 320px);
    width: clamp(220px, min(62vw, 30svh), 320px);   /* svh: no resize while a phone's toolbar slides */
    /* the pin releases 150px early, so the ring leaves together with Learn instead of covering it;
       the list's matching negative margin keeps the layout exactly where it was */
    margin-bottom: 150px;
  }
  #loop-steps { margin-top: -150px; }
  [data-widget="loop"]::before {
    content: "";
    position: absolute;
    left: 50%;
    width: 100vw;
    margin-left: -50vw;
    top: -16px;
    bottom: -18px;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(to bottom, var(--bg-alt, #f8fafc) 0, var(--bg-alt, #f8fafc) calc(100% - 16px), rgba(248, 250, 252, 0) 100%);
  }
}
/* the pinned ring glides with the nav when it slides away (--sticky-top); the page's reveal fade is
   repeated here so this rule does not cancel it (not while the page's own pause control is on) */
@media (max-width: 960px) and (min-height: 600px) and (prefers-reduced-motion: no-preference) {
  html:not(.motion-paused).js .loop > .widget.reveal.in:not(.skip-reveal)[data-widget="loop"],
  html:not(.motion-paused) .loop > .widget:not(.reveal)[data-widget="loop"] {
    transition: top .3s var(--ease-out, cubic-bezier(.2, .7, .2, 1)),
      opacity var(--dur-4, 700ms) var(--ease-out, cubic-bezier(.2, .7, .2, 1)),
      transform calc(var(--dur-4, 700ms) + 120ms) var(--ease-out, cubic-bezier(.2, .7, .2, 1));
  }
}
/* phones: a short, full-width dial (numbers inside the track) so the pinned block stays near 30% of the
   screen and the steps keep the full column */
@media (max-width: 560px) and (min-height: 600px) {
  .loop > .widget[data-widget="loop"] {
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    height: clamp(150px, 20vh, 184px);
    height: clamp(150px, 20svh, 184px);
    padding-bottom: 0;
  }
}
/* phones: the step number becomes a small kicker above the title, so the text gets the full measure */
@media (max-width: 560px) {
  #loop-steps li { grid-template-columns: 1fr; row-gap: 2px; padding: 12px 14px 14px 18px; }
  #loop-steps li .num { padding-top: 0; }
  #loop-steps li p { grid-column: 1; }
  #loop-steps li::before { top: 14px; bottom: 14px; }
}

/* forced colours (Windows contrast themes): the canvas redraws itself in system colours (see loop.js);
   the labels keep no backplate over it, and the active step is marked by an outline, a Highlight bar and
   Highlight text, since its tint, card shadow and colour bar are all background paint that gets stripped */
@media (forced-colors: active) {
  [data-widget="loop"] .lp-label,
  [data-widget="loop"] .lp-core {
    forced-color-adjust: none;
    background: transparent;
    color: CanvasText;
  }
  [data-widget="loop"] .lp-num,
  [data-widget="loop"] .lp-name,
  [data-widget="loop"] .lp-core { color: CanvasText; }
  [data-widget="loop"] .lp-label.is-active .lp-num,
  [data-widget="loop"] .lp-label.is-active .lp-name { color: Highlight; }
  #loop-steps li.is-active {
    outline: 2px solid Highlight;
    outline-offset: 0;
  }
  #loop-steps li::before {
    forced-color-adjust: none;
    background: Highlight;
  }
  #loop-steps li.is-active h3,
  #loop-steps li.is-active .num { color: Highlight; }
}
/* the pinned ring's band is a gradient, which forced colours drops: make it a plain Canvas band so the
   steps still pass out of sight behind the ring */
@media (forced-colors: active) and (max-width: 960px) and (min-height: 600px) {
  [data-widget="loop"]::before {
    forced-color-adjust: none;
    background: Canvas;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-widget="loop"] .lp-num,
  [data-widget="loop"] .lp-name,
  #loop-steps li, #loop-steps li::before, #loop-steps li .num, #loop-steps li h3 { transition: none; }
}
/* the page's "Pause animations" control mirrors reduced motion */
html.motion-paused [data-widget="loop"] .lp-num,
html.motion-paused [data-widget="loop"] .lp-name,
html.motion-paused #loop-steps li,
html.motion-paused #loop-steps li::before,
html.motion-paused #loop-steps li .num,
html.motion-paused #loop-steps li h3 { transition: none; }
