/*! pull-refresh.css 2.0.0 | DJ2000-UK/app-workbench */
/* Pull to refresh (refresh/pull-refresh.js): the glass pill under the header.
   While a finger pulls it is a round bead in the gap, with a thin ring that fills.
   Let go past the point of no return and it widens to "Syncing…" beside the
   turning ring, and stays put over the page as the page goes back up and as it
   scrolls. Then the ring becomes a tick, the pill says how the sync went, and it
   lifts away. Every colour is one of the app's own tokens (--accent or
   --accent-rgb, --muted-bright, --ink, --panel, --void, --positive, --amber,
   --muted, and --warning where the app has it), which Kaizen, Shinpo, Hokyu and
   djcns.css all define, so it follows the palette.
   The pill sits below the header, never in the top few px iOS reads for the
   status bar's colour, and is far narrower than the 90% of the width iOS looks
   for, so its blur leaves the status bar alone (docs/IPHONE.md). */

/* Chrome on Android has its own pull to refresh, in a tab and in an installed
   app alike, and it reloads the page. pull-refresh.js claims a pull only after
   the finger has moved a little, so without this Chrome can take the first
   movement. contain turns Chrome's off and keeps each browser's own bounce or
   stretch at the edges. :where() leaves an app free to override it. */
:where(html, body) { overscroll-behavior-y: contain; }

/* The layer's top is the header's foot. The pill hangs from it, moved by
   pull-refresh.js with transform only, so nothing is laid out again while the
   finger moves: only the pill's transform and the ring's dash change. Above the
   page, below the tab bar (90) and sheets. */
.pull-refresh {
  position: fixed;
  z-index: var(--pull-refresh-z, 85);
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  overflow: visible;
  pointer-events: none;
}
.pull-refresh[hidden] { display: none; }

/* The glass: the page shows through, blurred, under a tint of the app's panel
   colour, with a faint rim and a soft shadow, as the tab bar's glass. Its width
   is set by pull-refresh.js to fit the words; with none it is round. */
.pull-refresh-pill {
  --pull-refresh-accent: var(--accent, rgb(var(--accent-rgb)));
  --pill-tone: var(--positive);
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  box-sizing: border-box;
  width: 36px;
  max-width: calc(100vw - 32px);
  height: 36px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 74%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--ink) 13%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ink) 14%, transparent),
    0 10px 26px color-mix(in srgb, var(--void) 42%, transparent),
    0 2px 6px color-mix(in srgb, var(--void) 24%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  color: var(--ink);
  transform: translate(-50%, -18px) scale(0);
  transform-origin: 50% 50%;
}
.pull-refresh.is-leaving .pull-refresh-pill { opacity: 0; }
.pull-refresh-pill__row {
  display: flex;
  box-sizing: border-box;
  width: max-content;
  height: 100%;
  padding: 0 15px 0 7px;
  gap: 8px;
  align-items: center;
}
.pull-refresh-pill__icon { position: relative; display: block; flex: none; width: 22px; height: 22px; }
.pull-refresh-pill__text {
  display: block;
  flex: none;
  max-width: calc(100vw - 32px - 52px);
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .01em;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

/* Today's Apple look: a thin ring with rounded ends in the app's accent, on a
   faint track. pull-refresh.js fills it as the gap opens; armed, it pops and
   turns as an arc a third of the way round. */
.pull-refresh__wheel {
  position: absolute;
  top: -1px;
  left: -1px;
  display: block;
  width: 24px;
  height: 24px;
  overflow: visible;
  transform-origin: 50% 50%;
  transition: opacity 200ms ease;
}
.pull-refresh__track,
.pull-refresh__arc { fill: none; stroke-width: 2.8; }
.pull-refresh__track { stroke: color-mix(in srgb, var(--muted-bright) 22%, transparent); }
.pull-refresh__arc { stroke: var(--pull-refresh-accent); stroke-linecap: round; }

/* Armed and syncing: one smooth turn every .85 s, on the compositor, so it keeps
   turning while the app is busy redrawing the screen, and a small pop as the ring
   closes. The pop is the `scale` property, so it adds to the turn. */
.pull-refresh.is-spinning .pull-refresh__wheel {
  animation: pull-refresh-turn .85s linear infinite, pull-refresh-pop .34s cubic-bezier(.3, .7, .3, 1);
}
@keyframes pull-refresh-turn { to { transform: rotate(360deg); } }
@keyframes pull-refresh-pop {
  0% { scale: 1; }
  40% { scale: 1.14; }
  100% { scale: 1; }
}

/* How it went: the ring closes and fades as the result's mark pops in over it,
   a tick on a green disc, or the tone of what still waits. */
.pull-refresh-pill__mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--pill-tone);
  color: var(--void);
  opacity: 0;
  scale: .4;
  transition: opacity 160ms ease 80ms, scale 420ms cubic-bezier(.3, 1.4, .5, 1) 80ms;
}
.pull-refresh-pill__mark svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pull-refresh:is([data-state="result"], [data-state="leaving"]) .pull-refresh__wheel { opacity: 0; }
.pull-refresh:is([data-state="result"], [data-state="leaving"]) .pull-refresh-pill__mark { opacity: 1; scale: 1; }
.pull-refresh-pill[data-tone="signin"] { --pill-tone: var(--warning, var(--amber)); }
.pull-refresh-pill[data-tone="waiting"] { --pill-tone: var(--amber); }
.pull-refresh-pill[data-tone="offline"] { --pill-tone: var(--muted); }

/* The sentence a screen reader hears; the pill itself is only drawn. */
.pull-refresh-status {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  /* No turning and no pop: the ring stays whole and breathes. The pill fades in
     and out where it sits, and its mark shows without growing. */
  .pull-refresh.is-spinning .pull-refresh__wheel { animation: pull-refresh-breathe 1.4s ease-in-out infinite alternate; }
  @keyframes pull-refresh-breathe { from { opacity: 1; } to { opacity: .45; } }
  .pull-refresh:is([data-state="result"], [data-state="leaving"]) .pull-refresh__wheel { animation: none; }
  .pull-refresh-pill__mark { scale: 1; transition: opacity 160ms ease; }
}
