/* Redesign, timer workstream.
   Tokens, the layout system and the type atoms live in redesign.css; this file is the
   only stylesheet the timer pages own. See docs/redesign-workstreams.md.

   Screen 01 of the hand-off: the plaster wall, one fine circle, a travelled arc and a
   point of light that goes round it once per session, the numerals inside the ring,
   and RESET / PAUSE / END as outlined circles under it.

   The clock in base_om.js writes three things into the DOM that this file styles:
   `#bar`'s stroke and dashoffset, `#circleHelper`'s stroke, and the show/hide of the
   buttons. Where an inline style would win, the override is a documented !important that
   names the line it shadows. The two presentational values the clock publishes for this
   file — `--om-progress` and `.is-final-countdown` — are read here and nowhere else. */

/* ---------- the page: full-bleed wall ---------- */

.om-timer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--rd-space-l);
  /* the banner is sticky, so it takes layout space; the wall fills what is left */
  min-height: calc(100dvh - 3rem);
  padding: var(--rd-space-xl) var(--rd-gutter) calc(var(--rd-space-2xl) + env(safe-area-inset-bottom));
  overflow: hidden;
  color: #fff;
  font-family: var(--rd-sans);
  font-weight: 300;
  text-align: center;
}
@media (min-width: 1024px) {
  .om-timer { min-height: calc(100dvh - 3.5rem); }
}
/* In the iOS wrapper the banner is native, so the webview already is the whole screen. */
.om-timer--native { min-height: 100dvh; }

.om-timer__wall {
  position: absolute;
  inset: 0;
  background-image: url("/assets/rd/photos/timer-wall-f5e63e02.webp");
  background-position: 50% 0;
  background-size: cover;
  /* the hand-off lifts the photograph so the white line and the numerals read on it */
  filter: brightness(1.1) saturate(1.05);
}

.om-timer__stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* the design puts the controls close under the ring (.t-start/.t-ctl sit 64/312ths of the
     phone width below the orbit); 48+ left a visible band of wall between them. Button
     sizes are deliberately unchanged — only this gap moves. 32 puts the measured
     ring-to-buttons gap at 80px on a 390-wide screen; the owner asked for it tighter still,
     so 24 puts it at 63px. Button sizes are unchanged. */
  gap: var(--rd-space-l);
}
/* The guided timer carries two more blocks than screen 01 draws (the recording's title
   and the note about when its fifteen minutes run), so its stage closes up. */
.om-timer--guided .om-timer__stage { gap: var(--rd-space-m); }

/* ---------- the orbit ---------- */

/* 300 x 300 is the ring's own geometry (r = 135 in a 300 viewBox); the design page
   draws it at exactly this size inside a 390-wide screen. */
.om-timer #progress-bar-container {
  position: relative;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: transparent;
  font-size: 66px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: 0.02em;
}

.om-timer #progress-bar-container svg {
  display: block;
  overflow: visible;
}

/* The track: one fine light circle. base_om.js paints this ring peach (#EAAE94) with
   an inline style — at build, on every reset (resetDisplay) and again at the two-minute
   bell (updateTimer) — so only !important reaches it. */
.om-timer #svg #circleHelper {
  stroke: rgba(255, 255, 255, 0.45) !important;
  stroke-width: 1;
}

/* The old white base ring, third from last in the markup: #circleHelper above it is now
   the only circle, so this one is no longer drawn. */
.om-timer #svg circle:first-child + circle {
  stroke: none;
}

/* The travelled arc. JS owns the dashoffset (that is the motion) and rewrites the stroke
   to #BE5325 one second after the start; the design's arc is white, so the stroke is
   taken over here and the design's glow is drawn with a drop shadow. */
.om-timer #svg #bar {
  stroke: #fff !important;
  stroke-width: 1.6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.6));
  /* the colour eases into the ochre; the arc's own motion stays timer.css's
     stroke-dashoffset 1s linear, which this rule would otherwise replace */
  transition: stroke 600ms linear, stroke-dashoffset 1s linear;
}

/* The point of light: last in the svg, turned about the ring's own centre by the
   already-computed percentage the clock writes to --om-progress (0 → 100). */
.om-timer #svg circle.om-orbit-dot {
  fill: #fff;
  stroke: none;
  transform-box: view-box;
  transform-origin: 150px 150px;
  transform: rotate(calc(var(--om-progress, 0) * 3.6deg));
  /* the design's point of light carries an SVG glow — feGaussianBlur 3.2 merged twice —
     which reads as a soft halo far wider than the 5px dot itself */
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 7px rgba(255, 255, 255, 0.7));
  transition: fill 600ms linear;
  /* The point breathes for the whole session (owner, 2026-12-05), not only in the last
     two minutes: it is the thing that says the timer is alive. The final two minutes
     keep their own cue, which is colour, not motion. */
  animation: om-orbit-pulse 1s ease-in-out infinite alternate;
}

/* ---------- the final two minutes ---------- */

/* The last two minutes are a colour change and nothing else: the arc and the point of
   light turn to the ochre and their glow with them, while the peach track the bell branch
   paints is suppressed below. The pulse runs all session (above), so this state only adds
   the warmth. `.is-final-countdown` is set by base_om.js beside the two-minute bell. */
/* The clock repaints the track peach at the bell; the new cue is the arc and the point,
   so the track is held at its resting faint white rather than removed — removing it leaves
   no ring at all in the untravelled part of the circle. */
.om-timer.is-final-countdown #svg #circleHelper {
  stroke: rgba(255, 255, 255, 0.45) !important;
}
.om-timer.is-final-countdown #svg #bar {
  stroke: var(--rd-ochre) !important;
  filter: drop-shadow(0 0 4px rgba(185, 123, 60, 0.85));
}
.om-timer.is-final-countdown #svg circle.om-orbit-dot {
  fill: var(--rd-ochre);
  filter: drop-shadow(0 0 5px rgba(185, 123, 60, 0.9));
}

@keyframes om-orbit-pulse {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

/* No pulse, no travel of its own (the rotation follows the clock). */
@media (prefers-reduced-motion: reduce) {
  .om-timer #svg circle.om-orbit-dot {
    animation: none;
  }
}

/* ---------- the numerals ---------- */

.om-timer__readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

/* #timer-control (running) and #static-time (before the first start) are two siblings in
   one grid, so each landed in its own row: the numerals sat 59px below the ring on load
   and jumped ~117px up when the clock started. They now share one box, both centred on the
   ring's centre, which is where the design puts them (.t-time top 182 of a 300 ring). */
.om-timer__readout > .timer-readout {
  position: absolute;
  inset: 0;
}

/* The readout renders one ':' and puts the two halves either side of it from
   data-minutes / data-seconds (see timer.css). Only its type is restyled here. */
.om-timer #progress-bar-container .timer-readout {
  width: 100%;
  /* The minutes and seconds are ::before/::after grid items; the colon between them is the
     element's own text, i.e. an anonymous third item. Each item is centred by its own box,
     so a shorter line box for the colon's box lifts the colon alone — the two pseudo-
     elements keep line-height 1 below and stay exactly where they were. */
  line-height: 0.68;
  font-family: var(--rd-sans);
  font-size: 66px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

/* ---------- controls ---------- */

/* 62 and 74 are the design's circle diameters and 34 the space between them; the gap
   between a circle and its label is 11. Page rhythm still comes from the tokens. */
.om-timer__controls {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 34px;
}
.om-timer__controls--aside {
  align-items: center;
  justify-content: center;
  gap: var(--rd-space-l);
  margin-top: var(--rd-space-xs);
}

/* The label hangs under its circle. It sits inside the button so that it appears and
   disappears with the button: base_om.js shows and hides buttons, never labels. */
.om-timer__control {
  padding-bottom: 29px; /* 11 gap + the 12px label's line */
}

.om-timer__button {
  position: relative;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  line-height: 0;
  vertical-align: middle;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.om-timer__button--start {
  width: 74px;
  height: 74px;
}
.om-timer__button:disabled {
  opacity: 0.5;
  cursor: default;
  /* At rest only START is drawn, as the design shows: RESET and END cannot be used yet,
     so they step out of the way instead of sitting there greyed. base_om.js enables them
     on play, and they appear. */
  visibility: hidden;
}
.om-timer__button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* Positioned rather than centred by the button's own display: jQuery's show() leaves an
   inline display on the element it reveals, so the glyph may not be a child of a grid. */
.om-timer__glyph {
  position: absolute;
  inset: 0;
  margin: auto;
}

.om-timer__button-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

.om-timer__button-label {
  position: absolute;
  top: calc(100% + 11px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  line-height: 1;
  text-transform: uppercase;
}

/* The volume test has no place in the drawing, but it is the only way to check the bell
   before an OM starts, so it stays: a quiet control on the wall, not a circle. */
.om-timer__volume {
  display: flex;
  justify-content: center;
}
.om-timer__volume-button {
  display: inline-flex;
  align-items: center;
  gap: var(--rd-space-xs);
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--rd-sans);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.om-timer__volume-button img {
  width: 20px;
  height: 20px;
  /* the asset is drawn dark for the old white buttons; the wall wants it white */
  filter: brightness(0) invert(1);
  opacity: 0.8;
}
.om-timer__volume-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.om-timer__change {
  position: relative;
  font-size: 11.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
  padding-bottom: 2px;
}
.om-timer__change:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ---------- the guided timer's own lines ---------- */

.om-timer__heading-label {
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-transform: uppercase;
}
.om-timer__heading-title {
  margin-top: var(--rd-space-2xs);
  font-family: var(--rd-serif);
  font-weight: 500;
  font-size: 24px;
  line-height: 1.1;
}
.om-timer__note {
  max-width: var(--rd-measure-body);
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.85);
}

/* the admin-only elapsed readout, if a build turns it on */
.om-timer__elapsed {
  font-size: 12px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.6);
}
