/* ==========================================================================
   25-ringzoom.css — THE LAST QUARTER LEANS IN

   "the speakers Portrait Circle timer when it reaches 75% or more, slow
    toggle zooming via a nice animation in on it to show minute progressions
    of the timer animating towards %100."

   ...and then, when four stepped bands turned out not to be it:

   "Just match/copy what you are doing with Mustard seed and it should be
    good."

   So this is Mustard Seed's, copied from CuratorPanel.swift, whose own note
   reads:

       "THE LAST QUARTER LEANS IN. Past three quarters of the speaker's time
        the portrait is drawn a little larger, and goes on growing by tenths
        of a percent all the way to the end, so the ring says how close the
        finish is before anybody reads the number. On top of that it
        breathes -- slowly, two and a half seconds each way -- which is what
        catches the eye of somebody looking at the other side of the room."

   TWO MOVEMENTS, MULTIPLIED, and they do different jobs:

     THE GROWTH   a steady slope from 1 at three quarters to 1.10 at the
                  end. It does not animate on its own -- it IS the reading.
                  Where the portrait has got to in that slope says how close
                  the speaker is, continuously, with no steps to misread.
     THE BREATH   a slow 1.05 on top, two and a half seconds each way. It
                  carries no information at all; it is only there to catch
                  an eye across the room.

   WHAT WAS HERE BEFORE was four bands with four tempos, which was this
   app's own invention rather than anything Mustard Seed does. It was worse
   in two ways: the portrait jumped a notch at each boundary, which says
   something happened at a moment when nothing did, and inside a band it was
   as still as a ring that was not moving at all.

   HOW THE GROWTH REACHES THE KEYFRAMES. js/88-ringzoom.js writes two custom
   properties on each ring, --pr-grow and --pr-grow-big (the same times
   1.05), and the keyframes below breathe between them. Two properties
   rather than one and a calc() because a calc() inside a keyframe is a
   thing to find out about on an old iPad in a booth, and two custom
   properties are not.

   WHY TRANSFORM, AND WHY ON THE OUTER SPAN.

   04-components.css records what happened the last time something in this
   ring was animated with anything else: Safari repaints a filtered or
   resized SVG element by its filter region rather than its geometry, and an
   animated stroke-width under a drop-shadow left an orange smear sitting an
   inch below the portrait. A transform on the outer HTML span is composited
   whole -- the browser moves one finished layer and has nothing to
   re-rasterise, so there is nothing to leave behind.

   It also costs no layout. The span's box never changes size, so a swelling
   portrait cannot push the text beside it around or reflow a card; it grows
   over its own margins. .xp-pring is already position:relative, so raising
   it while it is swollen is enough to keep it over its neighbours rather
   than under them.
   ========================================================================== */

.xp-pring.is-closing {
  transform-origin: 50% 50%;
  /* Over its neighbours while it is swollen, not under them. */
  z-index: 3;
  /* The growth, with no breath, is what a ring is the moment it crosses
     three quarters -- and what it stays if anything below turns the
     animation off. */
  transform: scale(var(--pr-grow, 1));
  animation: xpRingBreath 5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   NEARLY TIME TO GO ON

   The other side of the start, and deliberately a different movement from
   the sermon's: this one holds ONE size and fades slowly in and out, where
   the sermon grows steadily and breathes. Two moments, two signals -- a
   producer glancing up can tell "they are nearly on" from "they are nearly
   out of time" without reading anything.

   Four seconds each way, which is slower than the sermon's breath on
   purpose. Waiting should look like waiting.
   -------------------------------------------------------------------------- */
.xp-pring.is-nearly {
  transform-origin: 50% 50%;
  z-index: 3;
  transform: scale(var(--pr-grow, 1));
  animation: xpRingNearly 8s ease-in-out infinite;
}

@keyframes xpRingNearly {
  0%, 100% { opacity: 1;   transform: scale(var(--pr-grow, 1)); }
  50%      { opacity: .45; transform: scale(var(--pr-grow, 1)); }
}

@keyframes xpRingBreath {
  0%, 100% { transform: scale(var(--pr-grow, 1)); }
  50%      { transform: scale(var(--pr-grow-big, 1)); }
}

/* --------------------------------------------------------------------------
   WHERE IT DOES NOT HAPPEN

   Three places, for three different reasons, and all of them are decided
   here rather than in js/88-ringzoom.js: the JavaScript knows what the
   countdown says, and the stylesheet knows where the ring is standing. A
   pass that had to know about calendar pills and archive rows would be a
   pass that breaks the next time one of them moves.
   -------------------------------------------------------------------------- */

/* A SMALL RING HAS NO ROOM. Calendar pills draw at 44px and the gutters
   around them are a few pixels; a 14% swell there pushes the face into the
   pill's own edge. Matched the same way 04-components.css shrinks the
   figure on the small sizes -- by the inline width the draw writes. */
.xp-pring[style*="width:48px"].is-closing,
.xp-pring[style*="width:44px"].is-closing,
.xp-pring[style*="width:40px"].is-closing,
.cal-pill-face .xp-pring.is-closing,
.xp-pring[style*="width:48px"].is-nearly,
.xp-pring[style*="width:44px"].is-nearly,
.xp-pring[style*="width:40px"].is-nearly,
.cal-pill-face .xp-pring.is-nearly {
  animation: none !important;
  transform: none !important;
}

/* NO RING MEANS NO ZOOM. Archive rows and archived roster cards hide the
   ring and the figure (03-chrome.css, 04-components.css), so all that is
   left to swell is the photograph -- a portrait that grows and shrinks for
   no stated reason is a fault, not an indicator. */
.ar-person .xp-pring.is-closing,
.roster-card.archive-card .xp-pring.is-closing,
.ar-person .xp-pring.is-nearly,
.roster-card.archive-card .xp-pring.is-nearly {
  animation: none !important;
  transform: none !important;
}

/* --------------------------------------------------------------------------
   PAPER, EXPORTS AND REDUCED MOTION

   On paper there is no motion, so a scaled portrait would simply print
   bigger than its neighbours, and on the frame it would be mid-swell at
   whatever moment the print was taken.
   -------------------------------------------------------------------------- */
@media print {
  .xp-pring.is-closing,
  .xp-pring.is-nearly { animation: none !important; transform: none !important;
                        opacity: 1 !important; }
}
.pdf-exp .xp-pring.is-closing,
.pdf-exp .xp-pring.is-nearly { animation: none !important; transform: none !important;
                               opacity: 1 !important; }

/* Somebody who has asked their machine for less movement gets the standing
   emphasis without the movement: the near rings still sit a little larger
   than the far ones, so the information survives, and nothing on the screen
   moves. The band still decides how much, because that is the part worth
   keeping. */
/* Mustard Seed's rule, word for word: "A Mac set to reduce motion gets the
   growth and no breath." The growth is the reading, so it stays; the breath
   is decoration, so it goes. Nothing on the screen moves, and the near ring
   still sits larger than the far one. */
@media (prefers-reduced-motion: reduce) {
  .xp-pring.is-closing,
  .xp-pring.is-nearly {
    animation: none !important;
    transform: scale(var(--pr-grow, 1));
    opacity: 1;
  }
}
