/* Respite Care for Family Caregivers: the signature section, "How much time do you need?".

   Three choices of time, and for the chosen one, what it looks like for the family caregiver
   (left) and for the loved one (right), side by side. Between them stands a flower clock: a
   twelve-hour dial with a peony at its centre and two rings of petals. The outer ring is the
   day, the inner ring the night. A few hours lights three petals at the top of the day; a full
   day lights the whole day ring; longer, or around the clock, lights the night ring too. Each
   new petal opens in turn, spreading from twelve o'clock down both sides.

   The still version is the HTML as written: the three choices side by side, each with its own
   heading, its two sides and a small dial drawn beside the heading. pages/respite.js turns it
   into the live version (.rest--live): it builds the three choice buttons from the headings,
   keeps the headings for screen readers, and shows one choice at a time. With reduced motion
   the live version works the same, without movement: petals and panels only fade.

   Only transform, opacity and clip-path move. The dial's entrance is a clip-path circle that
   opens from the centre, started by an IntersectionObserver, never by a timer. */

.rest { z-index: 2; }
.rest__box { --gap: clamp(1.5rem, 3.4vw, 3.5rem); --clock: clamp(21rem, 30vw, 28rem); margin-top: clamp(2.5rem, 4.5vw, 4rem); }

/* ---------- the still version: three choices side by side ---------- */
.rest__clock { display: none; }
.rest__panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.rest__panel { padding-top: 1.6rem; border-top: 1px solid var(--line-gold); }
.rest__h { display: flex; align-items: center; gap: 1rem; font-size: clamp(1.625rem, 2.2vw, 2.125rem); line-height: 1.12; color: var(--cream); text-wrap: balance; }
.rest__pair { margin: 0; padding: 0; list-style: none; }
.rest__side { margin-top: 1.6rem; }
.rest__side .sv-t { font-size: clamp(1.4375rem, 1.8vw, 1.75rem); }
.rest__side > span { display: block; margin-top: .6rem; font-size: clamp(1.1875rem, .3vw + 1.12rem, 1.25rem); line-height: 1.65; color: var(--on-dark); }
.rest__after { max-width: 46rem; }

/* the small dial: outer ring the day, inner ring the night */
.rest__mini { flex: none; width: 3rem; height: 3rem; color: var(--gold-light); overflow: visible; }
.rest__mini circle { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke 240ms ease, opacity 240ms ease; }
.rest__mini-track { stroke: currentColor; opacity: .32; }
.rest__mini-day { stroke: var(--gold-light); }
.rest__mini-night { stroke: var(--cream); }

/* ---------- the live version: three buttons, one choice at a time ---------- */
.rest__tabs { --tg: .85rem; position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--tg); margin-bottom: clamp(2.75rem, 5vw, 4.5rem); }
/* the cream pill that sits behind the chosen button and slides to the next one */
.rest__thumb { position: absolute; left: 0; top: 0; z-index: 0; width: calc((100% - 2 * var(--tg)) / 3); height: 100%; border-radius: 999px; background: var(--cream); box-shadow: 0 22px 34px -20px rgba(18, 5, 22, .95); transition: transform 380ms var(--ease-out); }
.rest__tabs[data-pick="1"] .rest__thumb { transform: translateX(calc(100% + var(--tg))); }
.rest__tabs[data-pick="2"] .rest__thumb { transform: translateX(calc(200% + 2 * var(--tg))); }
.rest__tab { position: relative; z-index: 1; display: flex; align-items: center; gap: 1rem; min-height: 5.25rem; padding: .8rem 1.75rem .8rem 1.05rem; border: 1px solid rgba(232, 181, 82, .55); border-radius: 999px; background: transparent; color: var(--cream); font-family: var(--serif); font-size: clamp(1.3125rem, 1.6vw, 1.5625rem); font-weight: 400; line-height: 1.15; text-align: left; text-wrap: balance; cursor: pointer; transition: color 240ms ease, border-color 240ms ease, transform 160ms var(--ease-out); -webkit-tap-highlight-color: transparent; }
.rest__tab .rest__mini { width: 3.25rem; height: 3.25rem; }
.rest__tab[aria-selected="true"] { color: var(--purple); border-color: transparent; }
.rest__tab[aria-selected="true"] .rest__mini-track { stroke: var(--purple); opacity: .22; }
.rest__tab[aria-selected="true"] .rest__mini-day { stroke: var(--gold-deep); }
.rest__tab[aria-selected="true"] .rest__mini-night { stroke: var(--purple-soft); }
.rest__tab:active { transform: scale(.98); }
.rest__tab:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) {
  .rest__tab[aria-selected="false"]:hover { border-color: var(--gold-light); background: rgba(251, 244, 234, .06); }
}

.rest--live .rest__panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.rest--live .rest__panel { position: relative; grid-area: 1 / 1; padding: 0; border: 0; border-radius: 1.25rem; visibility: hidden; opacity: 0; transition: opacity 200ms var(--ease-out), visibility 0s linear 200ms; }
.rest--live .rest__panel.is-on { visibility: visible; opacity: 1; transition: opacity 460ms var(--ease-out) 90ms, visibility 0s linear 0s; }
.rest--live .rest__panel:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 10px; }
/* the heading stays for screen readers; the chosen button shows the same words */
.rest--live .rest__h { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rest--live .rest__side { margin: 0; transition: transform 700ms var(--ease-out) 90ms; }
.rest--live .rest__panel.is-on .rest__side + .rest__side { transition-delay: 170ms; }
.rest--live .rest__panel:not(.is-on) .rest__side { transform: translateY(14px); transition: transform 0s linear 200ms; }
.rest--live .rest__side::before { content: ""; display: block; width: 3.25rem; height: 1px; margin-bottom: 1.25rem; background: var(--gold-light); }

/* wide screens: you on the left, your loved one on the right, the clock between */
.rest--live .rest__stage { display: grid; grid-template-columns: minmax(0, 1fr) var(--clock) minmax(0, 1fr); column-gap: var(--gap); align-items: center; }
.rest--live .rest__clock { display: block; grid-column: 2; grid-row: 1; }
.rest--live .rest__panels { grid-column: 1 / -1; grid-row: 1; }
.rest--live .rest__pair { display: grid; grid-template-columns: minmax(0, 1fr) var(--clock) minmax(0, 1fr); column-gap: var(--gap); align-items: start; }
.rest--live .rest__side { width: min(100%, 25rem); }
.rest--live .rest__side:first-child { grid-column: 1; justify-self: start; }
.rest--live .rest__side:last-child { grid-column: 3; justify-self: start; }

/* ---------- the flower clock ---------- */
.rest__clock { position: relative; }
.rest__glow { position: absolute; left: -16%; right: -16%; top: -16%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, rgba(232, 181, 82, .3), rgba(232, 181, 82, 0)); opacity: .45; transition: opacity 900ms ease; pointer-events: none; }
.rest__box[data-pick="1"] .rest__glow { opacity: .75; }
.rest__box[data-pick="2"] .rest__glow { opacity: 1; }
.rest__dial { position: relative; aspect-ratio: 1; }
.rest__svg { display: block; width: 100%; height: 100%; overflow: visible; }
.rest__ring { fill: none; stroke: var(--gold-light); }
.rest__ring--b { stroke-opacity: .55; stroke-width: 1.2; }
.rest__ring--c { stroke-opacity: .22; stroke-width: 1; }
.rest__face { fill: url(#rest-face); stroke: rgba(232, 181, 82, .85); stroke-width: 1.4; }
.rest__nums text { font-family: var(--sans); font-size: 26px; font-weight: 300; fill: rgba(251, 244, 234, .78); text-anchor: middle; dominant-baseline: central; }
.rest__po { fill: rgba(232, 181, 82, .07); stroke: rgba(232, 181, 82, .45); stroke-width: 1.2; }
.rest__petals--night .rest__po { fill: rgba(251, 244, 234, .04); stroke: rgba(251, 244, 234, .3); }
.rest__pf { fill: url(#rest-sun); opacity: 0; transform: scale(.42); transform-box: fill-box; transform-origin: 50% 100%; transition: opacity 180ms ease var(--d, 0ms), transform 220ms var(--ease-out) var(--d, 0ms); }
.rest__petals--night .rest__pf { fill: url(#rest-moon); }
.rest__pf.is-lit { opacity: 1; transform: none; transition: opacity 380ms var(--ease-out) var(--d, 0ms), transform 680ms var(--ease-spring) var(--d, 0ms); }
/* the peony opens a little fuller with every step of time, and turns a touch, like a hand */
.rest__peony { position: absolute; left: 50%; top: 50%; width: 27%; height: auto; transform: translate(-50%, -52%) scale(.9); filter: drop-shadow(0 14px 16px rgba(18, 5, 22, .55)); transition: transform 1200ms var(--ease-in-out); }
.rest__box[data-pick="1"] .rest__peony { transform: translate(-50%, -52%) rotate(5deg); }
.rest__box[data-pick="2"] .rest__peony { transform: translate(-50%, -52%) rotate(10deg) scale(1.1); }
/* a two-word key under the dial */
.rest__key { display: flex; justify-content: center; gap: 1.75rem; margin-top: 1.1rem; font-size: 1rem; font-weight: 500; letter-spacing: .02em; color: var(--on-dark); }
.rest__key span { display: inline-flex; align-items: center; gap: .55rem; }
.rest__key span::before { content: ""; width: .8rem; height: 1.15rem; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; }
.rest__key-day::before { background: linear-gradient(0deg, #C89030, #FBE3A4); }
.rest__key-night::before { background: linear-gradient(0deg, #D9B4C4, #FBF4EA); }

/* ---------- the entrance (the script adds .rest--anim, then .is-in when the box is in view) ---------- */
.rest--anim .rest__tabs, .rest--anim .rest__panels { opacity: 0; transform: translateY(18px); }
.rest--anim .rest__dial { clip-path: circle(0% at 50% 50%); }
.rest--anim .rest__key { opacity: 0; }
.rest--anim:not(.is-in) .rest__glow { opacity: 0; }
.rest--anim.is-in .rest__tabs { opacity: 1; transform: none; transition: opacity 520ms var(--ease-out), transform 820ms var(--ease-out); }
.rest--anim.is-in .rest__dial { clip-path: circle(72% at 50% 50%); transition: clip-path 1200ms var(--rv-ease-soft) 140ms; }
.rest--anim.is-in .rest__panels { opacity: 1; transform: none; transition: opacity 620ms var(--ease-out) 320ms, transform 900ms var(--ease-out) 320ms; }
.rest--anim.is-in .rest__key { opacity: 1; transition: opacity 600ms ease 1000ms; }

/* ---------- the closing button of "How respite care starts" ---------- */
.rest-go { margin-top: 1.5rem; }

/* ---------- shared-component workaround: service.css lays seven reasons out 2+2+3 with a
   selector stronger than the homepage's one-column rule for phones, so on a phone the first
   four reasons stood in half-width columns. One column under 900px, as on the homepage. ---------- */
@media (max-width: 899px) {
  #why-flowers .why__item { grid-column: span 6; }
}

/* ---------- tablets: the clock above, the two sides below it ---------- */
@media (max-width: 1023px) {
  .rest__panels { grid-template-columns: minmax(0, 1fr); }
  .rest--live .rest__stage { grid-template-columns: minmax(0, 1fr); row-gap: clamp(2.25rem, 5vw, 3rem); }
  .rest--live .rest__clock { grid-column: 1; grid-row: 1; justify-self: center; width: min(100%, 22rem); }
  .rest--live .rest__panels { grid-column: 1; grid-row: 2; }
  .rest--live .rest__pair { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .rest--live .rest__side { width: auto; }
  .rest--live .rest__side:first-child, .rest--live .rest__side:last-child { justify-self: stretch; }
  .rest--live .rest__side:last-child { grid-column: 2; }
}
/* phones: the three buttons in a column */
@media (max-width: 899px) {
  .rest__tabs { --tg: .65rem; grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; }
  .rest__thumb { width: 100%; height: calc((100% - 2 * var(--tg)) / 3); }
  .rest__tabs[data-pick="1"] .rest__thumb { transform: translateY(calc(100% + var(--tg))); }
  .rest__tabs[data-pick="2"] .rest__thumb { transform: translateY(calc(200% + 2 * var(--tg))); }
  .rest__tab { min-height: 4.5rem; padding: .7rem 1.5rem .7rem .8rem; }
  .rest__tab .rest__mini { width: 2.9rem; height: 2.9rem; }
}
@media (max-width: 639px) {
  .rest--live .rest__pair { grid-template-columns: minmax(0, 1fr); row-gap: 2rem; }
  .rest--live .rest__side:last-child { grid-column: 1; }
  .rest--live .rest__clock { width: min(92%, 20rem); }
  .rest__nums text { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .rest__thumb, .rest__peony, .rest__tab, .rest__mini circle { transition: none; }
  .rest__pf, .rest__pf.is-lit { transform: none; transition: opacity 220ms ease; }
  .rest--live .rest__side, .rest--live .rest__panel:not(.is-on) .rest__side { transform: none; transition: none; }
  .rest__peony, .rest__box[data-pick="1"] .rest__peony, .rest__box[data-pick="2"] .rest__peony { transform: translate(-50%, -52%); }
}
