/* Tomatoro page: the cycle stage, one state per phase in the colour of its phase.
   Depends on tomatoro.css for the stage colours (--stage-*, --on-stage) and the leaf shapes. */

/* Static by default: three full-colour bands, one per phase, each with its length, its name and its
   copy; stacked on narrow screens, a triptych from 900px. That is what a reader gets without
   JavaScript and under reduced motion. app.js adds .live to the track when motion is allowed; only
   then the stage pins, the three states share one grid cell (so the digits and the steps keep their
   place whatever the copy's length), .on marks the phase the scroll position picks, and the ring
   that fills with the phase appears. */
.cycle { margin-top: clamp(24px, 4vw, 56px); }
.cycle-stage { position: relative; isolation: isolate; color: var(--on-stage); }
.cycle-states { list-style: none; margin: 0; padding: 0; }
.cycle-state { position: relative; overflow: hidden; padding: clamp(56px, 8vw, 96px) 0; background: var(--stage); }
.cycle-state[data-stage="work"] { --stage: var(--stage-work); }
.cycle-state[data-stage="short"] { --stage: var(--stage-short); }
.cycle-state[data-stage="long"] { --stage: var(--stage-long); }
/* The label opens the first band only; a pinned stage shows it in every state. */
.cycle-state + .cycle-state .eyebrow { display: none; }
.cycle-bg, .cycle-foot { display: none; }
.cycle-inner { position: relative; z-index: 1; }
.cycle-stage .eyebrow { color: var(--on-stage); }
/* The app's countdown: light system digits of one width. */
.cycle-time { font: 300 clamp(5.5rem, 22vw, 16.5rem)/0.9 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-left: -0.04em; }
.cycle-phase { font-size: clamp(1.6rem, 1rem + 2vw, 2.6rem); margin: 0.4rem 0 0; color: var(--on-stage); }
.cycle-copy { max-width: 46ch; font-size: clamp(1rem, 0.95rem + 0.4vw, 1.2rem); color: var(--on-stage); margin: 1rem 0 0; }
.cycle-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 24px; flex-wrap: wrap; }
.cycle-steps li { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 2px solid rgba(255, 255, 255, 0.35); min-width: 120px; font-size: 0.9rem; color: var(--on-stage); }
.cycle-steps li b { font-weight: 600; }
.cycle-steps li.now { border-top-color: var(--on-stage); }

/* The app's ring (box 124x154, centre 70,90, band radius 56.5) with its leaves, in the stage's text
   colour. It shows elapsed time, so only a pinned stage draws it. */
.cycle-ring { --leaf: var(--on-stage); --leaf-rib: transparent; --leaf-stem: var(--on-stage); display: none; position: absolute; right: -6vw; top: 50%; height: min(74vh, 58vw); width: auto; max-width: none; aspect-ratio: 124 / 154; transform: translateY(-50%); overflow: visible; }
.c-track { fill: none; stroke: var(--on-stage); stroke-opacity: 0.18; stroke-width: 10; }
.c-arc { fill: none; stroke: var(--on-stage); stroke-opacity: 0.92; stroke-width: 10; stroke-linecap: round; }
.c-arc.zero { stroke-opacity: 0; }

.cycle-track.live { height: 320vh; view-timeline: --cycle block; }
.live .cycle-stage { position: sticky; top: 0; display: flex; flex-direction: column; justify-content: center; height: 100vh; min-height: 560px; overflow: hidden; }
.live .cycle-bg { display: block; position: absolute; inset: 0; z-index: -1; background: var(--stage-work); }
.live .cycle-states { display: grid; grid-template-columns: minmax(0, 1fr); }
.live .cycle-state { grid-area: 1 / 1; position: static; overflow: visible; padding: 0; background: none; visibility: hidden; }
.live .cycle-state.on { visibility: visible; }
.live .cycle-state + .cycle-state .eyebrow { display: block; }
.live .cycle-ring { display: block; }
.live .cycle-foot { display: block; position: relative; z-index: 1; margin-top: 2rem; }

/* Static, wide: the triptych. The three bands stand on the page's column lines (a third of the text
   width each) and the outer two run to the window's edges, so the first band's text starts on the
   page's left line and the last ends on its right line. The hidden labels keep the digits level. */
@media (min-width: 900px) {
  .cycle-track:not(.live) .cycle-stage {
    container-type: inline-size;
    --third: calc((min(var(--w-page), 100cqi) - 2 * var(--gutter)) / 3);
    --side: calc((100cqi - min(var(--w-page), 100cqi)) / 2 + var(--gutter));
    --inset: 32px;
  }
  .cycle-track:not(.live) .cycle-states { display: grid; grid-template-columns: minmax(0, 1fr) var(--third) minmax(0, 1fr); }
  .cycle-track:not(.live) .cycle-state { padding: clamp(56px, 6vw, 88px) 0; }
  .cycle-track:not(.live) .cycle-inner { max-width: none; margin: 0; padding: 0 var(--inset); }
  .cycle-track:not(.live) .cycle-state:first-child .cycle-inner { padding-left: var(--side); }
  .cycle-track:not(.live) .cycle-state:last-child .cycle-inner { padding-right: var(--side); }
  .cycle-track:not(.live) .cycle-state + .cycle-state .eyebrow { display: block; visibility: hidden; }
  .cycle-track:not(.live) .cycle-time { font-size: min(7vw, 6.5rem); }
  .cycle-track:not(.live) .cycle-phase { font-size: clamp(1.6rem, 1rem + 1vw, 2rem); margin-top: 0.8rem; }
  .cycle-track:not(.live) .cycle-copy { font-size: 1.05rem; }
}

@media (max-width: 720px) {
  .cycle-state { padding: 44px 0; }
  .cycle-time { font-size: clamp(5rem, 28vw, 12rem); }
  .cycle-track.live { height: 260vh; }
  .cycle-steps { gap: 12px; flex-wrap: nowrap; }
  .cycle-steps li { flex: 1; min-width: 0; font-size: 0.8rem; }
  /* Phones: a pinned stage centres the copy above a ring that stands on the bottom edge and shows its
     leaves and the top of its band; a stage too short for both goes without the ring. */
  .live .cycle-stage { padding-bottom: 30vw; }
  .live .cycle-ring { right: -12vw; top: auto; bottom: -54vw; height: 86vw; transform: none; opacity: 0.7; }
}
@media (max-width: 720px) and (max-height: 700px) {
  .live .cycle-stage { padding-bottom: 0; }
  .live .cycle-ring { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  /* The stage colour follows the phase as the track scrolls. */
  @keyframes stage { 0%, 44% { background: var(--stage-work); } 48%, 70% { background: var(--stage-short); } 74%, 100% { background: var(--stage-long); } }
  @supports (animation-timeline: view()) {
    .live .cycle-bg { animation: stage linear both; animation-timeline: --cycle; animation-range: contain 0% contain 100%; }
  }
  .cycle-bg.js { transition: background 0.25s linear; }
  .cycle-steps li { transition: border-color 0.3s; }
}
