/* 18:30 Run: a free-floating piece of the app for running - the Walk/Run
   switch (ActivityModePicker) over the run setup's sections (RunSetupSheet:
   Conditions with the heat check, Ready to run?, Intervals, Start Run and
   the note under it). Inside the card sizes are iOS points at 1 px each;
   colours follow the visitor's appearance like the app (screen tokens).
   Advice colours are AdviceStyle's: green good, amber attention, orange a
   real warning, red only for "don't". */

#stage-run { --stage-h: 392px; }
@media (max-width: 600px) { #stage-run { --stage-h: 646px; } }

#stage-run .x-run {
  position: relative;
  width: 100%;
  display: grid; justify-items: center; align-content: center; gap: 14px;
}
#stage-run .x-run-frame { width: min(100%, 584px); }
#stage-run .x-run:focus { outline: none; }

/* Hit areas of 44 px at phone width: the segmented controls grow
   vertically only (no pad reaches a neighbour), the thermometer sideways. */
#stage-run .x-run-pick button::before, #stage-run .x-run-chips button::before,
#stage-run .x-run-thermo::before { content: ""; position: absolute; }
#stage-run .x-run-pick button::before { inset: min(0px, calc(16 * var(--pt) - 22px)) 0; }
#stage-run .x-run-chips button::before { inset: min(0px, calc(15 * var(--pt) - 22px)) 0; }
#stage-run .x-run-thermo::before { inset: 0 min(0px, calc(20 * var(--pt) - 22px)); }

/* ---- The card ------------------------------------------------------------- */
#stage-run .x-run-screen {
  --pt: 1px;
  --xr-accent: #1E8A50;                 /* WalkStyle.accent */
  --xr-blue: #007AFF;                   /* the system accent (no AccentColor asset) */
  --xr-ok: var(--scr-ok); --xr-ok-ink: var(--scr-ok-ink);
  --xr-amber: #9A6700;                  /* AdviceStyle.attention */
  --xr-warn: #C85A00; --xr-warn-fill: #FF9500;
  --xr-red: var(--scr-red-ink); --xr-red-fill: var(--scr-red);
  --xr-indigo: #5856D6;
  position: relative;
  padding: 14px 16px 16px;
  border-radius: var(--r-container);
  background: linear-gradient(180deg, var(--scr-bg) 0%, var(--scr-bg-2) 100%);
  border: 1px solid var(--scr-glass-line);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  #stage-run .x-run-screen {
    --xr-accent: #52E8A0;
    --xr-blue: #0A84FF;
    --xr-amber: #FFD60A;
    --xr-warn: #FF9F0A; --xr-warn-fill: #FF9F0A;
    --xr-indigo: #7D7AFF;
  }
}
@media (max-width: 600px) {
  #stage-run .x-run-screen { --pt: 0.96px; padding: 12px 12px 14px; }
}

/* ---- Walk | Run ------------------------------------------------------------ */
#stage-run .x-run-top { position: relative; z-index: 2; display: flex; justify-content: center; }
#stage-run .x-run-pick {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: calc(2 * var(--pt));
  width: calc(232 * var(--pt)); padding: calc(3 * var(--pt));
  border-radius: var(--r-pill);
  background: var(--scr-glass); border: 1px solid var(--scr-glass-line);
  box-shadow: var(--scr-shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.6); backdrop-filter: blur(14px) saturate(1.6);
}
#stage-run .x-run-lens {
  position: absolute; z-index: 0;
  top: calc(3 * var(--pt)); bottom: calc(3 * var(--pt)); left: calc(3 * var(--pt));
  width: calc(50% - 4 * var(--pt));
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--scr-card) 92%, transparent);
  box-shadow: 0 calc(2 * var(--pt)) calc(8 * var(--pt)) rgba(0, 0, 0, 0.12), inset 0 0 0 1px var(--scr-glass-line);
  will-change: transform;
}
#stage-run .x-run-pick button {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: calc(6 * var(--pt));
  min-height: calc(32 * var(--pt)); padding: 0;
  border: 0; border-radius: var(--r-pill); background: none; cursor: pointer;
  font: 600 calc(15 * var(--pt))/1 var(--font-body); color: var(--scr-ink-2);
  transition: color 0.25s var(--ease-fade);
  -webkit-tap-highlight-color: transparent;
}
#stage-run .x-run-pick button[aria-checked="true"] { color: var(--xr-blue); }
#stage-run .x-run-pick .glyph { height: calc(18 * var(--pt)); width: calc(18 * var(--pt)); }
#stage-run .x-run-pick .g-run { width: calc(23 * var(--pt)); }

/* ---- Panes --------------------------------------------------------------------- */
#stage-run .x-run-panes { position: relative; }
#stage-run .x-run-body {
  display: grid; grid-template-columns: 1fr 1fr; column-gap: calc(14 * var(--pt));
  align-items: start;
}
#stage-run .x-run-col { min-width: 0; display: grid; align-content: start; }
@container (max-width: 520px) {
  #stage-run .x-run-body { grid-template-columns: 1fr; }
}
#stage-run .x-run-h {
  margin: calc(12 * var(--pt)) 0 calc(6 * var(--pt)) calc(12 * var(--pt));
  font-size: calc(13 * var(--pt)); color: var(--scr-ink-2);
}
#stage-run .x-run-group {
  background: var(--scr-card);
  border-radius: calc(16 * var(--pt));
  padding: calc(12 * var(--pt)) calc(14 * var(--pt));
}

/* The tier pill (TierPill): caption bold in the tint over 14 % of it. */
#stage-run .x-run-pill {
  display: inline-flex; align-items: center; gap: calc(6 * var(--pt));
  margin: 0; padding: calc(6 * var(--pt)) calc(10 * var(--pt));
  border-radius: calc(16 * var(--pt));
  background: color-mix(in srgb, var(--pf, var(--xr-ok)) 14%, transparent);
  color: var(--pt-ink, var(--xr-ok-ink));
  font: 700 calc(12.5 * var(--pt))/1.25 var(--font-body);
  transition: background-color 0.35s var(--ease-fade), color 0.35s var(--ease-fade);
}
#stage-run .x-run-pill svg { width: calc(13 * var(--pt)); height: calc(13 * var(--pt)); flex: none; color: var(--pf, var(--xr-ok)); }

/* ---- Conditions (WeatherTile) -------------------------------------------------- */
#stage-run .x-run-cond {
  display: grid; grid-template-columns: 1fr auto; column-gap: calc(10 * var(--pt)); align-items: center;
  --pf: var(--xr-ok); --pt-ink: var(--xr-ok-ink);
}
#stage-run .x-run-cond[data-tier="caution"] { --pf: var(--xr-amber); --pt-ink: var(--xr-amber); }
#stage-run .x-run-cond[data-tier="high"] { --pf: var(--xr-warn-fill); --pt-ink: var(--xr-warn); }
#stage-run .x-run-cond[data-tier="avoid"] { --pf: var(--xr-red-fill); --pt-ink: var(--xr-red); }
#stage-run .x-run-condmain {
  display: grid; gap: calc(8 * var(--pt)); justify-items: start; align-items: start; min-width: 0;
  /* Two lines held for the pill, so a longer verdict moves nothing below it. */
  grid-template-rows: auto calc(2 * 12.5 * 1.25 * var(--pt) + 12 * var(--pt));
}
#stage-run .x-run-read { display: flex; align-items: center; gap: calc(9 * var(--pt)); }
#stage-run .x-run-ticon { position: relative; width: calc(22 * var(--pt)); height: calc(22 * var(--pt)); color: var(--pf); transition: color 0.35s var(--ease-fade); }
#stage-run .x-run-ticon svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.2s var(--ease-fade); }
#stage-run .x-run-cond[data-tier="fine"] .ic-fine,
#stage-run .x-run-cond[data-tier="caution"] .ic-caution,
#stage-run .x-run-cond[data-tier="high"] .ic-high,
#stage-run .x-run-cond[data-tier="avoid"] .ic-avoid { opacity: 1; }
#stage-run .x-run-temp { font: 600 calc(20 * var(--pt))/1.1 var(--font-body); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
#stage-run .x-run-attr { grid-column: 1 / -1; margin: calc(8 * var(--pt)) 0 0; font-size: calc(11 * var(--pt)); color: var(--scr-ink-3); }

/* The thermometer: the demo's dial for the weather (drag it). */
#stage-run .x-run-thermo {
  position: relative; flex: none;
  width: calc(40 * var(--pt)); height: calc(96 * var(--pt));
  border-radius: calc(12 * var(--pt));
  cursor: ns-resize; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#stage-run .x-run-thermo:focus-visible { outline: 2px solid #8B6CFF; outline-offset: 2px; }
#stage-run .x-run-tube {
  position: absolute; left: 50%; top: calc(4 * var(--pt)); bottom: calc(18 * var(--pt));
  width: calc(10 * var(--pt)); margin-left: calc(-5 * var(--pt));
  border-radius: var(--r-pill);
  background: var(--scr-fill);
  box-shadow: inset 0 0 0 1px var(--scr-sep);
  overflow: hidden;
}
#stage-run .x-run-merc {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--lvl, 30%);
  border-radius: var(--r-pill);
  background: var(--pf);
  transition: background-color 0.35s var(--ease-fade);
}
#stage-run .x-run-bulb {
  position: absolute; left: 50%; bottom: calc(2 * var(--pt));
  width: calc(20 * var(--pt)); height: calc(20 * var(--pt)); margin-left: calc(-10 * var(--pt));
  border-radius: 50%; background: var(--pf);
  box-shadow: 0 0 0 calc(3 * var(--pt)) var(--scr-card);
  transition: background-color 0.35s var(--ease-fade);
}
#stage-run .x-run-hint {
  position: absolute; right: calc(-2 * var(--pt)); top: 38%;
  width: calc(8 * var(--pt)); height: calc(14 * var(--pt));
  color: var(--scr-ink-3);
}
#stage-run .x-run-hint svg { width: 100%; height: 100%; }

/* ---- Ready to run? (RunSuitabilityChip) --------------------------------------- */
#stage-run .x-run-dog { display: flex; align-items: center; gap: calc(12 * var(--pt)); }
#stage-run .x-run-dog .avatar, #stage-run .x-run-along .avatar {
  flex: none; width: calc(42 * var(--pt)); height: calc(42 * var(--pt));
  box-shadow: 0 0 0 calc(2 * var(--pt)) var(--scr-card);
}
#stage-run .x-run-dogcol { display: grid; gap: calc(5 * var(--pt)); justify-items: start; }
#stage-run .x-run-dogcol b { font-size: calc(15 * var(--pt)); font-weight: 600; }
#stage-run .x-run-dogcol small { font-size: calc(12 * var(--pt)); color: var(--scr-ink-2); }

/* ---- Intervals (IntervalPlanPicker) ------------------------------------------ */
#stage-run .x-run-chips {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: calc(2 * var(--pt));
  padding: calc(3 * var(--pt)); border-radius: var(--r-pill);
  background: var(--scr-fill);
}
#stage-run .x-run-chips button {
  position: relative;
  height: calc(30 * var(--pt)); padding: 0;
  border: 0; border-radius: var(--r-pill); background: transparent; cursor: pointer;
  font: 600 calc(13 * var(--pt))/1 var(--font-body); color: var(--scr-ink-2);
  transition: background-color 0.3s var(--ease-fade), color 0.3s var(--ease-fade), box-shadow 0.3s var(--ease-fade), transform 0.4s var(--spring-pop);
  -webkit-tap-highlight-color: transparent;
}
#stage-run .x-run-chips button:active { transform: scale(0.95); transition-duration: 0.12s; }
#stage-run .x-run-chips button[aria-checked="true"] {
  background: var(--scr-card); color: var(--scr-ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}
#stage-run .x-run-pick button:focus-visible, #stage-run .x-run-chips button:focus-visible { outline: 2px solid #8B6CFF; outline-offset: 1px; }

#stage-run .x-run-tl { position: relative; margin-top: calc(40 * var(--pt)); }
#stage-run .x-run-blocks { display: flex; gap: calc(2 * var(--pt)); height: calc(24 * var(--pt)); }
#stage-run .x-run-blocks i {
  position: relative; display: block; min-width: 0;
  border-radius: calc(5 * var(--pt));
  overflow: hidden;
  background: var(--scr-fill);
}
#stage-run .x-run-blocks i b { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--scr-ink) 22%, transparent); }
#stage-run .x-run-blocks i.run { background: color-mix(in srgb, var(--xr-accent) 26%, transparent); }
#stage-run .x-run-blocks i.run b { background: linear-gradient(90deg, #52E8A0, #A9E25C); }
#stage-run .x-run-blocks i.warm { background: color-mix(in srgb, var(--xr-indigo) 20%, transparent); }
#stage-run .x-run-blocks i.warm b { background: color-mix(in srgb, var(--xr-indigo) 60%, transparent); }
#stage-run .x-run-head {
  position: absolute; left: 0; top: calc(-4 * var(--pt)); bottom: calc(-4 * var(--pt));
  width: calc(2.5 * var(--pt)); margin-left: calc(-1.25 * var(--pt));
  border-radius: 2px; background: var(--scr-ink);
  will-change: transform;
}
/* The cue at each change (the haptic in the app, the notification in a
   pocket): "Run!" in the walk identity, "Walk" plain. */
#stage-run .x-run-cue {
  position: absolute; left: 0; bottom: calc(100% + 9 * var(--pt));
  will-change: transform;
}
#stage-run .x-run-cue span {
  position: relative; display: block;
  transform: translateX(-50%);
  padding: calc(5 * var(--pt)) calc(10 * var(--pt));
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, #52E8A0, #D8DE3A);
  color: #113B22; font: 750 calc(13 * var(--pt))/1 var(--font-body);
  white-space: nowrap;
  box-shadow: 0 calc(3 * var(--pt)) calc(10 * var(--pt)) rgba(30, 138, 80, 0.3);
}
#stage-run .x-run-cue span::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  width: calc(10 * var(--pt)); height: calc(6 * var(--pt)); margin-left: calc(-5 * var(--pt));
  background: inherit; clip-path: polygon(0 0, 100% 0, 50% 100%);
}
#stage-run .x-run-cue.is-walk span { background: var(--scr-card-2); color: var(--scr-ink); box-shadow: 0 calc(2 * var(--pt)) calc(8 * var(--pt)) rgba(0, 0, 0, 0.12); }
#stage-run .x-run-cue.is-warm span { background: color-mix(in srgb, var(--xr-indigo) 22%, var(--scr-card)); color: var(--scr-ink); box-shadow: none; }
#stage-run .x-run-footrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: calc(4 * var(--pt)) calc(8 * var(--pt)); margin-top: calc(10 * var(--pt)); }
#stage-run .x-run-foot { margin: 0; font-size: calc(12 * var(--pt)); color: var(--scr-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
#stage-run .x-run-legend { margin: 0; display: flex; gap: calc(9 * var(--pt)); font-size: calc(11 * var(--pt)); color: var(--scr-ink-3); white-space: nowrap; }
#stage-run .x-run-legend span { display: inline-flex; align-items: center; gap: calc(4 * var(--pt)); }
#stage-run .x-run-legend i { width: calc(8 * var(--pt)); height: calc(8 * var(--pt)); border-radius: calc(2 * var(--pt)); }
#stage-run .k-run { background: #52E8A0; }
#stage-run .k-walk { background: color-mix(in srgb, var(--scr-ink) 22%, transparent); }
#stage-run .k-warm { background: color-mix(in srgb, var(--xr-indigo) 60%, transparent); }

/* ---- Start and the note ------------------------------------------------------- */
#stage-run .x-run-start {
  margin-top: calc(14 * var(--pt));
  height: calc(48 * var(--pt));
  display: flex; align-items: center; justify-content: center; gap: calc(8 * var(--pt));
  border: 1px solid rgba(255, 255, 255, 0.6); border-radius: var(--r-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0) 58%), linear-gradient(90deg, #52E8A0, #D8DE3A);
  box-shadow: 0 calc(6 * var(--pt)) calc(18 * var(--pt)) rgba(82, 200, 120, 0.28);
  color: #113B22; font: 600 calc(17 * var(--pt))/1 var(--font-body);
}
#stage-run .x-run-start .glyph { height: calc(22 * var(--pt)); width: calc(29 * var(--pt)); }
#stage-run .x-run-startwalk .glyph { width: calc(22 * var(--pt)); }
@media (prefers-color-scheme: dark) {
  #stage-run .x-run-start { background: #52E8A0; border-color: rgba(255, 255, 255, 0.25); box-shadow: none; }
}
#stage-run .x-run-note { margin: calc(8 * var(--pt)) calc(4 * var(--pt)) 0; font-size: calc(12 * var(--pt)); line-height: 1.35; color: var(--scr-ink-2); }

/* ---- The walk side of the switch ---------------------------------------------- */
#stage-run .x-run-walk {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  width: min(100%, calc(360 * var(--pt))); margin: 0 auto;
}
#stage-run .x-run-wtitle { margin: 0 0 calc(12 * var(--pt)) calc(4 * var(--pt)); font: 700 calc(24 * var(--pt))/1.15 var(--font-body); letter-spacing: -0.02em; }
#stage-run .x-run-along { display: flex; align-items: center; gap: calc(12 * var(--pt)); }
#stage-run .x-run-along .x-run-dogcol { flex: 1; gap: calc(2 * var(--pt)); }
#stage-run .x-run-tick { width: calc(24 * var(--pt)); height: calc(24 * var(--pt)); color: var(--xr-accent); }

/* ---- Replay (outside the card: page tokens) ------------------------------------ */
#stage-run .x-run-replay {
  display: inline-flex; align-items: center; gap: 7px;
  height: 44px; padding: 0 18px 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-line);
  background: var(--glass-strong);
  color: var(--ink); font: 650 15px/1 var(--font-body);
  box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  cursor: pointer;
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s var(--ease-fade), visibility 0s 0.25s, transform 0.45s var(--spring-pop);
}
#stage-run .x-run-replay.is-shown { opacity: 1; visibility: visible; transition: opacity 0.25s var(--ease-fade), transform 0.45s var(--spring-pop); }
#stage-run .x-run-replay:hover { transform: scale(1.04); }
#stage-run .x-run-replay:active { transform: scale(0.96); }
#stage-run .x-run-replay svg { width: 18px; height: 18px; }
#stage-run .x-run-replay:focus-visible { outline: 2px solid #8B6CFF; outline-offset: 2px; }
