/* =====================================================================
   OSE · Page map · styles/components/page-map.css
   ---------------------------------------------------------------------
   Where you are in the home page, on the right edge (desktop, from
   --bp-lg): a hairline with a small dot per stop and a bead that slides
   along it as you scroll. The current stop's dot is bigger and its name
   shows to the left, on a small pill. A slim clear-glass capsule (a 24 %
   navy tint, a frosted backdrop, a sheen and a hairline edge, like
   Apple's glass; the dots keep a soft dark halo). The name's pill is
   flat: a deeper see-through fill, no edge, no sheen
   wraps just the line and the dots, so the map reads over anything (the
   cream planet included). It takes no room and only its dots take the
   pointer, so it never blocks the content.
   Component tokens only: --page-map-*.

   Markup
     <nav class="page-map" data-js="page-map" data-surface="night" aria-label="Bản đồ trang">
       <span class="page-map__bead" aria-hidden="true"></span>
       <ol class="page-map__list" role="list">
         <li><a class="page-map__point" href="#main" data-target="xuat-phat" aria-current="true">
           <span class="page-map__name">Xuất phát</span></a></li>
         …Trạm 01–04 (#vi-sao-chon-ose … #phuong-phap) · Khai giảng (#len-tau)…
       </ol>
     </nav>
   Box      fixed, vertically centred, --page-map-inset from the right
            (inside the cockpit's window), --page-map-height tall, no
            width: the capsule, the line, the dots and the names hang off
            it. Stops spread evenly; each dot sits in a full
            tap target (--page-map-tap), the only part that takes the pointer.
   Links    a stop links to its chapter; data-target names the chapter it
            tracks when the link goes elsewhere (Xuất phát links to #main,
            the very top, because the hero itself is pinned mid-flight).
   Script   js/components/page-map.js: aria-current on the stop whose
            chapter has reached the landing line (under the nav, where a
            link lands it) and the bead's position (transform), so after a
            click the bead sits on that dot. Always data-surface="night"
            (the capsule is dark). Without JS it stays as written (Xuất
            phát current, bead at the top).
   States   current: bigger dot, name shown · hover / focus-visible: name
            shown · focus ring from base.css.
   .page-map--static: in the flow (styleguide demos).
   ===================================================================== */

@layer components {
  .page-map {
    display: none;
  }

  @media (min-width: 64em) {
    .page-map {
      display: block;
      position: fixed;
      inset-inline-end: var(--page-map-inset);
      inset-block-start: 50%;
      translate: 0 -50%;
      block-size: var(--page-map-height);
      z-index: var(--page-map-z);
      pointer-events: none;
    }
  }

  .page-map--static {
    display: block;
    position: relative;
    inset: auto;
    translate: none;
    margin-inline: auto;
    inline-size: 0;
    block-size: var(--page-map-height);
    pointer-events: none;
  }

  /* The capsule: just around the line and the dots, dark and see-through. */
  .page-map::before {
    content: "";
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 0;
    inline-size: calc(var(--page-map-dot-on) + var(--page-map-capsule-pad) * 2);
    block-size: calc(100% + var(--page-map-dot-on) + var(--page-map-capsule-pad) * 2);
    translate: -50% -50%;
    border-radius: var(--page-map-capsule-radius);
    background-color: var(--page-map-capsule);
    background-image: linear-gradient(var(--page-map-capsule-sheen), var(--page-map-capsule-clear));
    box-shadow: inset 0 0 0 var(--page-map-capsule-edge-width) var(--page-map-capsule-edge);
    -webkit-backdrop-filter: blur(var(--page-map-capsule-blur)) saturate(var(--page-map-capsule-saturate));
    backdrop-filter: blur(var(--page-map-capsule-blur)) saturate(var(--page-map-capsule-saturate));
  }

  /* Light mode (html.perf-light): no backdrop blur. */
  .perf-light .page-map::before,
  .perf-light .page-map__name {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .page-map__list {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    block-size: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* The hairline. */
  .page-map__list::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    border-inline-start: var(--page-map-line-width) solid var(--page-map-line);
  }

  .page-map__list > li {
    position: relative;
    block-size: 0;
  }

  /* A dot in a full tap target, centred on the line. */
  .page-map__point {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    display: grid;
    place-items: center;
    inline-size: var(--page-map-tap);
    block-size: var(--page-map-tap);
    translate: -50% -50%;
    color: var(--page-map-name);
    text-decoration: none;
    pointer-events: auto;
  }

  .page-map__point::before {
    content: "";
    inline-size: var(--page-map-dot);
    block-size: var(--page-map-dot);
    border-radius: var(--page-map-dot-radius);
    background-color: var(--page-map-dot-color);
    box-shadow: 0 0 0 var(--page-map-dot-halo-width) var(--page-map-dot-halo);
    transition: background-color var(--page-map-fade);
  }

  .page-map__point[aria-current="true"]::before {
    inline-size: var(--page-map-dot-on);
    block-size: var(--page-map-dot-on);
    background-color: var(--page-map-dot-color-on);
  }

  /* The name, to the left of its dot. */
  .page-map__name {
    position: absolute;
    inset-inline-end: 100%;
    margin-inline-end: var(--page-map-gap);
    padding: var(--page-map-name-pad-block) var(--page-map-name-pad-inline);
    border-radius: var(--page-map-capsule-radius);
    /* Flat (John): a soft see-through fill behind the text only, no edge,
       no sheen, so it never reads as a button. */
    background-color: var(--page-map-name-glass);
    -webkit-backdrop-filter: blur(var(--page-map-capsule-blur));
    backdrop-filter: blur(var(--page-map-capsule-blur));
    font: var(--page-map-font);
    line-height: var(--page-map-name-leading);
    letter-spacing: var(--page-map-tracking);
    text-transform: uppercase;
    white-space: nowrap;
    opacity: var(--page-map-name-hidden);
    transition: opacity var(--page-map-fade);
    pointer-events: none;
  }

  .page-map__point[aria-current="true"] .page-map__name,
  .page-map__point:hover .page-map__name,
  .page-map__point:focus-visible .page-map__name,
  .page-map__point.is-hover .page-map__name,
  .page-map__point.is-focus-visible .page-map__name {
    opacity: var(--page-map-name-shown);
  }

  /* The bead: page-map.js moves it along the line (transform). */
  .page-map__bead {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    z-index: var(--page-map-z);
    inline-size: var(--page-map-dot);
    block-size: var(--page-map-dot);
    border-radius: var(--page-map-dot-radius);
    background-color: var(--page-map-bead);
    box-shadow: 0 0 0 var(--page-map-dot-halo-width) var(--page-map-dot-halo);
    translate: -50% -50%;
    pointer-events: none;
  }

  @media (prefers-reduced-motion: reduce) {
    .page-map__point::before,
    .page-map__name {
      transition: none;
    }
  }
}
