/* Companion and Sitter Services: the signature section, "An afternoon together".

   Six ways a visit can go, as a deck of playing cards on the table: the hero photograph is a
   game of cards over tea, and this is the same table. Each card carries one activity: its
   number in the corners like a card's index, an animated icon, the heading and the words.

   The still version is the HTML as written: six cards laid out side by side. pages/companion.js
   turns it into the live deck (.noon--live): the top card is read, two more lie fanned beneath
   it, and the visitor moves through them with Next and Previous, with a swipe of the top card
   (it is tossed aside and tucked under the deck), with the arrow keys, or on wide screens by
   picking a name from the list beside the deck. Nothing moves on its own.

   The script sets each card's place in the deck as an inline transform (translate, rotate,
   scale: the same three functions everywhere, so they interpolate cleanly); the transitions
   below carry the cards between places. The tossed card's flight is a Web Animation. Only
   transform and opacity move. With reduced motion the cards change places without moving. */

.noon { z-index: 2; }
.noon__box { margin-top: clamp(2.75rem, 5vw, 4.5rem); }

/* ---------- a card ---------- */
.noon__cards { margin: 0; padding: 0; list-style: none; }
.noon__card { position: relative; display: flex; flex-direction: column; min-height: 30rem; padding: 2.1rem 2.5rem 4rem; border-radius: 1.5rem; background: #FFFBF4; color: var(--ink); box-shadow: 0 34px 50px -30px rgba(18, 5, 22, .95), 0 2px 0 rgba(200, 144, 48, .25); }
/* the printed frame of a playing card */
.noon__card::before { content: ""; position: absolute; inset: .7rem; border: 1px solid rgba(200, 144, 48, .55); border-radius: 1.05rem; pointer-events: none; }
.noon__pip { position: absolute; left: 1.7rem; top: 1.65rem; display: flex; flex-direction: column; align-items: center; gap: .35rem; font-family: var(--sans); font-size: 2rem; font-weight: 300; line-height: .9; letter-spacing: -.035em; font-variant-numeric: lining-nums; color: var(--gold-deep); }
.noon__pip::after { content: ""; width: 1.55rem; height: 1.6rem; background: url("../flowers/sunflower-head.webp") center / contain no-repeat; }
.noon__pip--end { left: auto; top: auto; right: 1.7rem; bottom: 1.65rem; transform: rotate(180deg); }
.noon__icon { align-self: flex-end; width: 5.5rem; height: 5.5rem; margin: 0 -.6rem 0 0; }
.no-js .noon__icon { visibility: hidden; }
.noon__card h3 { margin-top: 1.1rem; padding-left: .1rem; font-size: clamp(2rem, 2.6vw, 2.5rem); color: var(--purple); }
.noon__card p { margin-top: .8rem; font-size: clamp(1.1875rem, .3vw + 1.12rem, 1.25rem); line-height: 1.6; color: var(--ink); }

/* the still version: six cards laid out side by side */
.noon__cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(1.25rem, 2.6vw, 2.25rem); }

/* ---------- the live deck ---------- */
.noon--live { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: clamp(2.5rem, 6vw, 7rem); align-items: center; }
.noon__stage { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.noon--live .noon__cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; width: min(100%, 27rem); touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.noon--live .noon__card { grid-area: 1 / 1; transform-origin: 50% 90%; transition: transform 560ms var(--ease-out), opacity 360ms ease; will-change: transform; }
.noon--live .noon__card.is-drag, .noon--live .noon__card.is-fly { transition: none; }
.noon--live .noon__card[data-p="0"] { cursor: grab; }
.noon--live .noon__card.is-drag { cursor: grabbing; }
/* the cards beneath show only their card stock; the words come up as a card reaches the top */
.noon--live .noon__card > * { transition: opacity 340ms ease 140ms; }
.noon--live .noon__card:not([data-p="0"]):not(.is-fly) > * { opacity: 0; transition: opacity 180ms ease; }

/* Previous, where you are, Next */
.noon__nav { display: flex; align-items: center; justify-content: center; gap: clamp(.75rem, 2vw, 1.5rem); margin-top: clamp(2rem, 3.5vw, 2.75rem); }
.noon__btn { display: inline-flex; align-items: center; gap: .55rem; min-height: 3.5rem; padding: 0 1.5rem; border: 1px solid rgba(232, 181, 82, .7); border-radius: 999px; background: transparent; color: var(--cream); font-family: var(--sans); font-size: 1.0625rem; font-weight: 600; cursor: pointer; transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease, transform 160ms var(--ease-out); -webkit-tap-highlight-color: transparent; }
.noon__btn svg { width: 1.25rem; height: 1.25rem; flex: none; }
.noon__btn--next { background: var(--gold-light); border-color: var(--gold-light); color: #1D0A21; }
.noon__btn:active { transform: scale(.97); }
.noon__btn:focus-visible, .noon__to:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 3px; }
.noon__count { min-width: 4.5rem; text-align: center; font-size: 1.0625rem; font-weight: 500; color: var(--on-dark); font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) {
  .noon__btn:hover { border-color: var(--gold-light); background: rgba(251, 244, 234, .08); }
  .noon__btn--next:hover { background: #F0C46A; }
}

/* the six names beside the deck (wide screens) */
.noon__index { margin: 0; padding: 0; list-style: none; counter-reset: none; border-top: 1px solid var(--line-gold); }
.noon__index li { border-bottom: 1px solid var(--line-gold); }
.noon__to { display: flex; align-items: center; gap: 1.25rem; width: 100%; min-height: 4.25rem; padding: .55rem .25rem; border: 0; background: none; color: rgba(251, 244, 234, .78); font-family: var(--serif); font-size: clamp(1.4375rem, 1.8vw, 1.75rem); font-weight: 400; line-height: 1.15; text-align: left; cursor: pointer; transition: color 200ms ease; -webkit-tap-highlight-color: transparent; }
.noon__to b { display: grid; place-items: center; flex: none; width: 2.75rem; height: 2.75rem; border: 1px solid rgba(232, 181, 82, .7); border-radius: 50%; font-family: var(--sans); font-size: 1.125rem; font-weight: 500; color: var(--cream); transition: background-color 220ms ease, color 220ms ease, transform 160ms var(--ease-out); }
.noon__to span { flex: 1 1 auto; }
.noon__to::after { content: ""; flex: none; width: 2.1rem; height: 2.2rem; background: url("../flowers/sunflower-head.webp") center / contain no-repeat; opacity: 0; transform: scale(.7) rotate(-20deg); transition: opacity 260ms ease, transform 520ms var(--ease-spring); }
.noon__to[aria-current="true"] { color: var(--cream); }
.noon__to[aria-current="true"] b { background: var(--gold-light); border-color: var(--gold-light); color: #1D0A21; }
.noon__to[aria-current="true"]::after { opacity: 1; transform: none; }
.noon__to:active b { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) {
  .noon__to:hover { color: var(--cream); }
  .noon__to:not([aria-current="true"]):hover b { background: #5C2567; }
}

/* ---------- the entrance: the deck is dealt onto the table (the script adds .noon--anim, then .is-in) ---------- */
.noon--anim:not(.is-in) .noon__card { opacity: 0 !important; transform: translate(0%, 14%) rotate(0deg) scale(.96) !important; }
.noon--anim:not(.is-in) .noon__nav, .noon--anim:not(.is-in) .noon__index { opacity: 0; transform: translateY(18px); }
.noon--anim .noon__nav, .noon--anim .noon__index { transition: opacity 600ms var(--ease-out) 420ms, transform 800ms var(--ease-out) 420ms; }
.noon--anim.is-in:not(.is-dealt) .noon__card { transition: transform 900ms var(--ease-out), opacity 500ms ease; }
.noon--anim.is-in:not(.is-dealt) .noon__card[data-p="1"] { transition-delay: 110ms; }
.noon--anim.is-in:not(.is-dealt) .noon__card[data-p="0"] { transition-delay: 220ms; }

/* ---------- the closing button of "Companion care starts in four steps" ---------- */
.noon-go { margin-top: 1.5rem; }

/* ---------- this page's photograph in "Who it helps": the caregiver and his sunflower ---------- */
#who-it-helps .arch > img { object-position: 50% 30%; }

/* ---------- tablets: the deck alone, the list of names folds away ---------- */
@media (max-width: 1023px) {
  .noon__cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .noon--live { grid-template-columns: minmax(0, 1fr); }
  .noon__index { display: none; }
}
@media (max-width: 639px) {
  .noon__cards { grid-template-columns: minmax(0, 1fr); }
  .noon--live .noon__cards { width: min(88%, 22rem); }
  .noon__card { min-height: 0; padding: 1.75rem 1.6rem 3.5rem; }
  .noon__icon { width: 4.5rem; height: 4.5rem; }
  .noon__card h3 { margin-top: .6rem; font-size: 1.875rem; }
  .noon__card p { font-size: 1.125rem; }
  .noon__pip { left: 1.4rem; top: 1.4rem; font-size: 1.75rem; }
  .noon__pip--end { left: auto; top: auto; right: 1.4rem; bottom: 1.4rem; }
  .noon__btn { padding: 0 1.15rem; }
  .noon__nav { gap: .5rem; }
  .noon__count { min-width: 3.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .noon--live .noon__card { transition: opacity 200ms ease; }
  .noon--live .noon__card > *, .noon--live .noon__card:not([data-p="0"]):not(.is-fly) > * { transition: opacity 160ms ease; }
  .noon__btn, .noon__to, .noon__to b, .noon__to::after { transition: none; }
}
