/* Errands and Transportation: the signature section, "A week of trips".

   A small night map of one neighbourhood, folded open beside the five stops of the week. A
   faint dotted line shows the whole loop planned for the week: from the house to the doctor,
   the pharmacy, the grocery store, church, and back to the same house. As the reader moves
   down the stops, the gold route is drawn over the plan, leg by leg, and a little car drives
   it. While a stop is being read, the car waits at that stop and its pin is lit.

   The pins are plain links to the five stops, so the map works by tap and keyboard, and
   without the script (the gold route is then drawn in full and the car waits in the drive).
   pages/errands.js writes the drawing (stroke-dashoffset of the five legs) and moves the car
   (a transform on one SVG group); nothing else is animated by it. The map's own entrance is
   a clip-path: it opens from its centre fold, then the pins settle onto it.

   From 1024px the map stays beside the stops (sticky, offset by var(--header-h)). Below that
   it sits above the stops and draws its loop as it passes up through the window. */

.trip { z-index: 2; }
.trip__grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: clamp(2rem, 5.5vw, 6rem); align-items: start; }
.trip__side { grid-column: 2; grid-row: 1; position: sticky; top: calc(var(--header-h) + 1.5rem); }
.trip__stops { grid-column: 1; grid-row: 1; margin: 0; padding: 0; list-style: none; }

/* ---------- the map ---------- */
.trip__map { --disc: 4rem; --r: 1.75rem; position: relative; width: min(100%, calc((100vh - var(--header-h) - 3.5rem) * 1.4)); margin-left: auto; aspect-ratio: 7 / 5; border-radius: var(--r); overflow: hidden; isolation: isolate; background: radial-gradient(120% 95% at 42% 40%, #46184F 0%, var(--aub-2) 50%, var(--aub) 100%); box-shadow: 0 46px 60px -42px rgba(43, 16, 48, .75); color: var(--cream); }
/* a map's double frame: a gold edge and a finer line just inside it */
.trip__map::before, .trip__map::after { content: ""; position: absolute; z-index: 4; pointer-events: none; border-radius: inherit; }
.trip__map::before { inset: 0; box-shadow: inset 0 0 0 1px rgba(232, 181, 82, .75); }
.trip__map::after { inset: .6rem; border: 1px solid rgba(232, 181, 82, .28); border-radius: calc(var(--r) - .6rem); }
.trip__art { position: absolute; inset: 0; width: 100%; height: 100%; }
.trip__streets { fill: none; stroke: rgba(251, 244, 234, .04); stroke-width: 8; }
.trip__avenues { fill: none; stroke: rgba(251, 244, 234, .065); stroke-width: 13; }
.trip__creek { fill: none; stroke: rgba(112, 56, 112, .55); stroke-width: 17; stroke-linecap: round; }
.trip__creek-hi { fill: none; stroke: rgba(232, 181, 82, .22); stroke-width: 1.5; stroke-dasharray: 18 14; }
.trip__park { fill: rgba(156, 104, 153, .11); }
.trip__trees circle { fill: rgba(251, 244, 234, .07); }
.trip__compass circle { fill: none; stroke: rgba(232, 181, 82, .45); stroke-width: 1.2; }
.trip__needle { fill: var(--gold-light); }
.trip__needle-x { fill: rgba(232, 181, 82, .45); }
.trip__compass text { font-family: var(--sans); font-size: 13px; font-weight: 600; fill: var(--gold-light); text-anchor: middle; }
/* the week as planned, and the week as driven */
.trip__plan { fill: none; stroke: rgba(251, 244, 234, .4); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1 11; }
.trip__route { filter: drop-shadow(0 0 5px rgba(232, 181, 82, .45)); }
.trip__seg { fill: none; stroke: var(--gold-light); stroke-width: 6; stroke-linecap: round; }
.trip__car-shadow { fill: rgba(10, 2, 12, .45); }
.trip__car-body { fill: var(--cream); stroke: var(--gold-light); stroke-width: 1.5; }
.trip__car-glass { fill: var(--purple); }
.trip__car-lamp { fill: var(--gold-light); }
/* the service's flower, laid on the corner of the map */
.trip__bud { position: absolute; right: 2.6%; bottom: 3.6%; z-index: 3; width: 9.5%; height: auto; transform: rotate(14deg); filter: drop-shadow(0 10px 12px rgba(10, 2, 12, .55)); pointer-events: none; }

/* ---------- the pins: five links, each to its stop ---------- */
.trip__pins ol { position: absolute; inset: 0; z-index: 6; margin: 0; padding: 0; list-style: none; }
.trip__pin { position: absolute; left: var(--x); top: var(--y); }
.trip__go { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; min-width: 5rem; padding-bottom: .1rem; transform: translate(-50%, calc(var(--disc) / -2)); border-radius: 1rem; color: var(--cream); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.trip__go b { position: relative; display: grid; place-items: center; width: var(--disc); height: var(--disc); border: 1.5px solid rgba(232, 181, 82, .85); border-radius: 50%; background: var(--aub-2); box-shadow: 0 12px 18px -8px rgba(10, 2, 12, .85); font-family: var(--sans); font-size: 1.3125rem; font-weight: 500; line-height: 1; color: var(--cream); transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease, transform 160ms var(--ease-out); }
.trip__go b svg { width: 50%; height: 50%; }
.trip__go span { padding: .22rem .7rem .28rem; border-radius: 999px; background: rgba(28, 9, 32, .84); font-size: 1rem; font-weight: 500; line-height: 1.2; white-space: nowrap; color: rgba(251, 244, 234, .94); transition: color 220ms ease; }
.trip__pin--home b { border-width: 2px; background: #5C2567; }
.trip__go.is-past b { background: #5C2567; border-color: var(--gold-light); }
.trip__go[aria-current] b { background: var(--gold-light); border-color: var(--gold-light); color: #1D0A21; }
.trip__go[aria-current] span { color: var(--gold-light); }
.trip__go[aria-current] b::after { content: ""; position: absolute; inset: -2px; border: 2px solid var(--gold-light); border-radius: 50%; animation: trip-ping 2.6s var(--ease-out) infinite; }
@keyframes trip-ping { from { transform: scale(1); opacity: .8; } to { transform: scale(1.75); opacity: 0; } }
.trip__go:active b { transform: scale(.94); }
.trip__go:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .trip__go:not([aria-current]):hover b { border-color: var(--gold-light); background: #5C2567; }
  .trip__go:hover span { color: var(--cream); }
}

/* ---------- the five stops ---------- */
.trip__stop { --pad: clamp(2.5rem, 6.5vh, 4.25rem); position: relative; display: grid; grid-template-columns: 5.25rem minmax(0, 1fr); column-gap: clamp(1.25rem, 2.2vw, 2rem); align-content: start; padding: var(--pt, var(--pad)) 0 var(--pad); scroll-margin-top: calc(var(--header-h) + 1rem); }
.trip__stop:first-child { --pt: .35rem; }
/* the stops are joined by the same dotted road as the map */
.trip__stop:not(:last-child)::after { content: ""; position: absolute; left: calc(2.625rem - 1px); top: calc(var(--pt, var(--pad)) + 6.1rem); bottom: calc(.85rem - var(--pad)); border-left: 2px dashed rgba(143, 98, 18, .42); }
.trip__pt { grid-row: 1 / span 2; position: relative; width: 5.25rem; height: 5.25rem; }
.trip__mark { display: block; width: 100%; height: 100%; padding: 1.05rem; border-radius: 50%; background: radial-gradient(circle at 50% 34%, #5C2567 0%, var(--aub-2) 72%); box-shadow: 0 0 0 1px rgba(232, 181, 82, .8), 0 18px 24px -12px rgba(43, 16, 48, .55); }
.trip__pt::after { content: ""; position: absolute; inset: -.5rem; border: 1.5px solid var(--gold); border-radius: 50%; opacity: 0; transform: scale(.86); transition: opacity 240ms ease, transform 420ms var(--ease-out); pointer-events: none; }
.trip__stop.is-on .trip__pt::after { opacity: 1; transform: none; }
.trip__no { position: absolute; right: -.45rem; top: -.4rem; z-index: 2; display: grid; place-items: center; width: 2.125rem; height: 2.125rem; border-radius: 50%; background: var(--gold-light); box-shadow: 0 0 0 3px var(--cream); font-family: var(--sans); font-size: 1.0625rem; font-weight: 600; line-height: 1; color: #1D0A21; }
.trip__no svg { width: 58%; height: 58%; }
.trip__stop h3 { grid-column: 2; padding-top: .55rem; font-size: clamp(1.75rem, 2.6vw, 2.375rem); border-radius: 4px; }
.trip__stop h3:focus { outline: none; }
.trip__stop h3:focus-visible { outline: 3px solid var(--purple); outline-offset: 6px; }
.trip__stop p { grid-column: 2; max-width: 33rem; margin-top: .8rem; font-size: clamp(1.1875rem, .3vw + 1.12rem, 1.25rem); line-height: 1.65; }
/* the last stop is given room, so the map is still whole beside it when the car gets home */
@media (min-width: 1024px) { .trip__stop:last-child { min-height: calc(var(--trip-map-h, 31rem) + var(--header-h) + 6.5rem - 34vh); } }

/* ---------- the map's entrance (the script adds .trip--live, then .is-in on the map) ---------- */
.trip__pin:nth-child(2) { --i: 1; }
.trip__pin:nth-child(3) { --i: 2; }
.trip__pin:nth-child(4) { --i: 3; }
.trip__pin:nth-child(5) { --i: 4; }
.trip--live .trip__seg { opacity: 0; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.trip--live .trip__map { clip-path: inset(0 50% 0 50% round var(--r)); }
.trip--live .trip__map.is-in { clip-path: inset(0 0 0 0 round var(--r)); transition: clip-path 1100ms var(--rv-ease-soft); }
.trip--live .trip__pin { opacity: 0; transform: translateY(.75rem); }
.trip--live .is-in .trip__pin { opacity: 1; transform: none; transition: opacity 320ms ease calc(620ms + var(--i, 0) * 80ms), transform 620ms var(--rv-ease-settle) calc(620ms + var(--i, 0) * 80ms); }
.trip--live .trip__car { opacity: 0; }
.trip--live .is-in .trip__car { opacity: 1; transition: opacity 420ms ease 1050ms; }

/* ---------- tablets and phones: the map sits above the stops ---------- */
@media (max-width: 1023px) {
  .trip__grid { display: block; }
  .trip__side { position: relative; top: auto; justify-self: stretch; margin-bottom: clamp(1.25rem, 4vw, 2.25rem); }
  .trip__map { --disc: clamp(3.25rem, 7vw, 4rem); --r: 1.25rem; width: 100%; margin: 0; }
  .trip__stop { --pad: 1.75rem; grid-template-columns: 4.25rem minmax(0, 1fr); column-gap: 1rem; }
  .trip__stop:first-child { --pt: 1rem; }
  .trip__stop:not(:last-child)::after { left: calc(2.125rem - 1px); top: calc(var(--pt, var(--pad)) + 5rem); }
  .trip__pt { width: 4.25rem; height: 4.25rem; }
  .trip__mark { padding: .85rem; }
  .trip__no { width: 1.875rem; height: 1.875rem; font-size: 1rem; }
  .trip__stop h3 { padding-top: .3rem; }
}
@media (max-width: 639px) {
  /* the map runs edge to edge on a phone, so the pins and their names have room */
  .trip__map { --r: 0px; width: auto; margin: 0 calc(-1 * var(--gutter)); box-shadow: none; }
  .trip__map::after { border-radius: .6rem; }
  .trip__go { gap: .25rem; min-width: 3.5rem; }
  .trip__go b { font-size: 1.125rem; }
  .trip__go span { padding: .14rem .5rem .2rem; font-size: .9375rem; }
}
@media (max-width: 479px) {
  /* a smaller icon beside each stop leaves the words a longer line */
  .trip__stop { grid-template-columns: 3.5rem minmax(0, 1fr); column-gap: .9rem; }
  .trip__stop:not(:last-child)::after { left: calc(1.75rem - 1px); top: calc(var(--pt, var(--pad)) + 4.25rem); }
  .trip__pt { width: 3.5rem; height: 3.5rem; }
  .trip__mark { padding: .7rem; }
  .trip__no { right: -.55rem; top: -.5rem; width: 1.75rem; height: 1.75rem; font-size: .9375rem; }
  .trip__stop h3 { padding-top: .1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .trip__go b, .trip__go span, .trip__pt::after { transition: none; }
  .trip__go[aria-current] b::after { animation: none; opacity: 0; }
}

/* ---------- this page's photograph in "What it is": the two faces under the curve of the arch ---------- */
#what-it-is .arch > img { object-position: 50% 30%; }
/* the stem across the foot of "What is included" lies a little lower here, so its head clears the last line of the left column */
#included .sv-stem--bl { bottom: -22.5rem; }
