/* Technology: the numbers in a band across the page, each large under a hairline; screens side by side, on
   phones a row that scrolls sideways. */
@layer views {
  .stats-band {
    padding-block: var(--space-24) 0;
  }
  .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-8);
  }
  .stats div {
    padding-top: var(--space-7);
    border-top: 1px solid var(--color-line);
  }
  .stats b {
    display: block;
    font-size: var(--figure-xl);
    font-weight: var(--weight-light);
    line-height: var(--leading-none);
    letter-spacing: var(--tracking-figure);
  }
  .stats span {
    display: block;
    margin-top: var(--space-4);
    font-size: var(--text-lg);
    color: var(--color-text-muted);
  }
  .phone-row {
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-18);
  }
  .phone-row:has(> :nth-child(3)) {
    --n: 3;
  }
  .phone-row:has(> :nth-child(5)) {
    --n: 5;
  }
  .phone-row figure {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: var(--space-6);
    text-align: center;
  }
  .phone-row .phone {
    --w: min(260px, calc((min(100vw, var(--shell)) - var(--gutter) * 2) / var(--n) - var(--space-6)));
  }
  .phone-row figcaption {
    max-width: 24ch;
    font-size: var(--text-md);
    color: var(--color-text-muted);
  }
  .phone-row strong {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--color-text);
    font-size: var(--heading-sm);
    font-weight: var(--weight-regular);
    letter-spacing: var(--tracking-title);
  }

  @media (max-width: 760px) {
    .stats-band {
      padding-block: var(--space-16) var(--space-22);
    }
    .stats {
      gap: var(--space-4);
    }
    .stats div {
      padding-top: var(--space-5);
    }
    .stats span {
      margin-top: var(--space-3);
      font-size: var(--text-sm);
    }
    .phone-row {
      display: flex;
      gap: var(--space-5);
      width: auto;
      margin-top: var(--space-12);
      padding: 0 var(--gutter) var(--space-2);
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      scroll-padding-inline: var(--gutter);
    }
    .phone-row figure {
      flex: none;
      scroll-snap-align: start;
    }
    .phone-row .phone {
      --w: 230px;
    }
  }
}
/* Technology opens on the film of how a way is found: the scheme on the right, the heading, the caption of
   the part on screen and the buttons on the left. The film keeps its whole width and fades into the page's
   black above and below; a phone gets the tall film, filling the screen. */
@layer widgets {
  .route-hero > video {
    position: absolute;
    z-index: var(--z-media);
    inset-inline-start: 0;
    top: 50%;
    width: 100%;
    height: auto;
    translate: 0 -50%;
    mask-image: var(--mask-film);
  }
  .route-hero .notes {
    grid-auto-flow: row;
    grid-template-columns: minmax(0, 340px);
    margin-top: var(--space-9);
  }
  .route-hero .notes > div {
    grid-area: 1 / 1;
  }
  .route-hero:not(.playing) .notes > div:not(:last-child),
  .route-hero.playing .notes > div:not(.on) {
    opacity: 0;
  }
  /* On a landscape screen the caption's line is the signal going into the device: it lies at the device's
     height (the middle of the hero, where the film centres it) and ends at the device's left edge (37.2% of
     the film's width), just where the ways fan out on its other side; it fills as the part plays. */
  @media (min-width: 761px) and (min-aspect-ratio: 1/1) {
    /* On a very wide screen the film moves right so the words keep at least 330px before the device. The
       heading ends before the device: its longest line is about 7.1 em. */
    .route-hero {
      --left: max(var(--gutter), (100vw - var(--shell)) / 2);
      --shift: max(0px, calc(var(--left) + 330px - 37.2vw));
      --fit: clamp(40px, calc((37.2vw + var(--shift) - var(--left) - 28px) / 7.1), 64px);
    }
    .route-hero > video {
      translate: var(--shift) -50%;
    }
    .route-hero .copy {
      display: grid;
      grid-template: 50% auto 1fr / minmax(0, 1fr);
      justify-content: stretch;
      align-items: start;
      padding-block: 0;
    }
    .route-hero h1 {
      align-self: end;
      margin-bottom: var(--space-9);
      font-size: var(--fit);
    }
    .route-hero .notes {
      grid-template-columns: calc(37.2vw + var(--shift) - var(--left));
      margin-top: 0;
    }
    .route-hero .notes p {
      max-width: 30ch;
    }
  }

  @media (max-width: 760px) {
    /* The whole scheme stands between the header and the words. */
    .route-hero > video {
      top: 56px;
      height: 68%;
      translate: none;
      object-fit: cover;
      object-position: 50% 0;
      mask-image: var(--mask-fade-bottom);
    }
  }
}
/* The app's map in the page's colours: its land as dots (tools/world-map.mjs), its route and places. Edge to
   edge and never narrower than 1000px: a narrow screen sees the route, centred, and the world runs off both
   sides. A pulse runs along the route every four seconds, as in the app. The map is a picture with physical
   places in it: it is never mirrored. */
@layer widgets {
  .world {
    --beat: 4s;
    --pulse-at: 2.4s;
    --draw-at: 1.2s;
    --second-at: 2s;
    --second-pulse-at: 3.6s;
    --stop-at: 0.6s;
    --gateway-at: 1.4s;

    direction: ltr;
    margin-top: var(--space-10);
    overflow: hidden;
    mask-image: var(--mask-world);
    mask-composite: intersect;
  }
  .world-layer {
    --layer: max(100%, 1000px);
    --centre: min(0px, calc(50% - var(--layer) * 0.392));

    position: relative;
    width: var(--layer);
    margin-inline-start: var(--centre);
  }
  .world svg {
    width: 100%;
    height: auto;
  }
  .land {
    opacity: 0.17;
  }
  .land.near {
    opacity: 0.55;
  }
  .route,
  .pulse {
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
  }
  .route {
    stroke: var(--color-accent);
    filter: var(--glow-route);
  }
  .pulse {
    stroke: var(--color-white);
    stroke-dasharray: 0.16 1.2;
    stroke-dashoffset: 0.16;
    filter: var(--glow-pulse);
    animation: pulse var(--beat) var(--ease-loop) var(--pulse-at) infinite;
  }
  @keyframes pulse {
    45%,
    100% {
      stroke-dashoffset: -1;
    }
  }
  /* Three stories on the map, one at a time: what stands in the way shows first, then the way ARXUM takes
     draws itself through its gateway (a second leg after the first) and a pulse runs along it. A story
     that comes on starts over; with reduced motion each simply stands drawn. */
  .story {
    display: none;
  }
  .story.on {
    display: inline;
  }
  .story .route {
    stroke-dasharray: 1;
    animation: draw var(--duration-slower) var(--ease) var(--draw-at) both;
  }
  .story .second {
    animation-delay: var(--second-at);
  }
  .story .pulse.second {
    animation-delay: var(--second-pulse-at);
  }
  .story :is(.wall, .blocked, .stop, .gateway) {
    animation: appear var(--duration-slow) var(--ease) both;
  }
  .story .stop {
    animation-delay: var(--stop-at);
  }
  .story .gateway {
    animation-delay: var(--gateway-at);
  }
  @keyframes draw {
    from {
      stroke-dashoffset: 1;
    }
    to {
      stroke-dashoffset: 0;
    }
  }
  @keyframes appear {
    from {
      opacity: 0;
    }
  }
  .wall {
    fill: var(--color-map-wall-fill);
    stroke: var(--color-map-wall);
    stroke-width: 1.2;
    stroke-dasharray: 3 4;
  }
  .blocked {
    fill: none;
    stroke: var(--color-map-blocked);
    stroke-width: 1.6;
    stroke-dasharray: 2 4;
  }
  /* A route path is measured in its own length (pathLength 1). */
  use.blocked {
    stroke-dasharray: 0.006 0.012;
  }
  .stop {
    fill: none;
    stroke: var(--color-light);
    stroke-width: 1.8;
    stroke-linecap: round;
  }
  .gateway {
    fill: var(--color-gateway);
    stroke: var(--color-light);
    stroke-width: 1.4;
  }
  /* The stories' captions as text tabs: the one on the map is lit, its line fills while it plays. */
  .stories {
    --story: 7s;

    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-8);
    margin-top: var(--space-2);
  }
  .stories button {
    position: relative;
    display: grid;
    gap: var(--space-2);
    padding: var(--space-5) 0 0;
    border: 0;
    border-top: 1px solid var(--color-line);
    background: none;
    color: var(--color-text-muted);
    font-size: var(--text-md);
    line-height: var(--leading-body);
    text-align: start;
    opacity: 0.55;
    transition: opacity var(--duration-base) var(--ease);
  }
  .stories b {
    color: var(--color-text);
    font-size: var(--heading-xs);
    font-weight: var(--weight-regular);
    letter-spacing: var(--tracking-title);
  }
  .stories [aria-selected="true"] {
    opacity: 1;
  }
  .stories [aria-selected="true"]::before {
    content: "";
    position: absolute;
    top: -1px;
    inset-inline-start: 0;
    width: 100%;
    height: 2px;
    background: var(--color-light);
    transform-origin: left;
    animation: fill var(--story) var(--ease-linear) both;
  }
  .stories [aria-selected="true"]:dir(rtl)::before {
    transform-origin: right;
  }
  @keyframes fill {
    from {
      transform: scaleX(0);
    }
  }
  /* A place: its mark on the point, its name in a label under it. Where each stands is in percent of the
     map's view (tools/world-map.mjs). */
  .place {
    --dot: 12px;

    position: absolute;
    inset-inline-start: var(--x);
    top: var(--y);
    transform: translate(-50%, 18px);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--color-label);
    box-shadow: var(--shadow-edge);
    color: var(--color-light);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-label);
    letter-spacing: var(--tracking-title);
    white-space: nowrap;
  }
  .place[data-place="you"] {
    --x: 27.30%;
    --y: 42.89%;
  }
  .place[data-place="exit"] {
    --x: 51.06%;
    --y: 33.03%;
  }
  .place::before,
  .place::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -18px;
    width: var(--dot);
    height: var(--dot);
    margin-block-start: calc(var(--dot) / -2);
    margin-inline-start: calc(var(--dot) / -2);
    border-radius: var(--radius-round);
  }
  .place::before {
    background: var(--color-light);
    box-shadow: var(--ring-place);
  }
  .place::after {
    border: 1.5px solid var(--color-light);
    opacity: 0;
    animation: breathe var(--beat) var(--ease-out) infinite;
  }
  .place.exit {
    --dot: 22px;

    transform: translate(-50%, 22px);
    background: var(--color-light);
    box-shadow: none;
    color: var(--color-dark);
  }
  .place.exit::before,
  .place.exit::after {
    top: -22px;
  }
  .place.exit::before {
    background: var(--gradient-place-exit);
  }
  .place.exit::after {
    animation-name: arrive;
  }
  @keyframes breathe {
    0% {
      opacity: 0.6;
      transform: scale(1);
    }
    40%,
    100% {
      opacity: 0;
      transform: scale(3.4);
    }
  }
  @keyframes arrive {
    0%,
    42% {
      opacity: 0;
      transform: scale(1);
    }
    46% {
      opacity: 0.7;
    }
    75%,
    100% {
      opacity: 0;
      transform: scale(2.6);
    }
  }

  @media (max-width: 760px) {
    .stories {
      grid-template-columns: 1fr;
      gap: 0;
    }
    .stories button {
      padding-bottom: var(--space-5);
    }
    .stories button:not([aria-selected="true"]) span {
      display: none;
    }
  }
}
