/* The waxing moon steps: a white card on a white page, a night drawing at its top and the steps under it. The colours
   of the night are the drawing's; the card keeps to ink and a deep indigo. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --card-edge: #e4e7f1;     /* its hairline edge */
  --ink: #11173a;           /* titles and choices */
  --ink-soft: #3a4166;      /* the names of the steps done */
  --muted: #5b6282;         /* the line under a title */
  --dim: #6b7190;           /* the names of the steps still to come */
  --accent: #2d3a9a;        /* the current step, a choice made, the focus ring */
  --accent-soft: #eef0fb;   /* a step done or a recap pointed at */
  --chip-edge: #d6dae8;     /* the edge of a choice not made */
  --recap: #f0f2f9;         /* the recap of the choices, on the last step */
  --go: #161d4a;            /* Continue */
  --go-ink: #ffffff;        /* its words */
  --off: #e3e6f0;           /* Continue when there is nothing chosen to go on with */
  --off-ink: #7d839c;       /* its words then */

  /* the night: one sky for each place to watch from */
  --night-city-top: #181c42;
  --night-city-low: #3a355f;
  --night-suburbs-top: #0d1336;
  --night-suburbs-low: #222c5c;
  --night-country-top: #060a20;
  --night-country-low: #1b2552;
  --glow: #f39a5c;          /* the street lights over the horizon */
  --milky: #c9cfff;         /* the Milky Way, from the countryside */
  --star: #fff4d6;          /* the stars */
  --star-deep: #ffd98e;
  --land: #0e1434;          /* the skyline, the houses, the hills */
  --windows: #f6c66d;       /* their lit windows */
  --ridge: #070a1e;         /* the ground in front */

  /* the moon */
  --moon-lit: #f4e6c2;
  --moon-crater: #e0cd9e;
  --moon-dark: #222c5a;     /* the side lit only by the earth */
  --moon-dark-crater: #283364;

  /* Saturn, the comet, the telescope */
  --saturn-hi: #f3d597;
  --saturn-lo: #c08a4a;
  --saturn-band: #b98448;
  --ring-hi: #f7e8c2;
  --ring-lo: #c6a46a;
  --ion: #8fb6ff;
  --comet-head: #f6fbff;
  --comet-tail: #a8dcf6;
  --comet-core: #ffffff;
  --tripod-hi: #93a0cc;
  --tripod-lo: #5a6592;
  --mount: #dfe3f2;
  --mount-lo: #97a1c6;
  --tube-hi: #fdfaf2;
  --tube-lo: #c7bea6;
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- the card */
.tour {
  width: min(384px, 100%);
  padding: 8px;
  border-radius: 28px;
  background: var(--card);
  box-shadow:
    0 0 0 1px var(--card-edge),
    0 2px 6px rgba(17, 23, 58, 0.05),
    0 24px 48px -24px rgba(17, 23, 58, 0.32);
}

/* ---------------------------------------------------------------- the night drawing */
.scene {
  position: relative;
  aspect-ratio: 360 / 216;
  border-radius: 20px;
  overflow: hidden;
  background: var(--night-suburbs-top);
  /* the corners stay round while the drawing moves inside */
  isolation: isolate;
}

.scene__svg {
  display: block;
  width: 100%;
  height: 100%;
}

.glow-stop {
  stop-color: var(--glow);
}

.milky {
  fill: var(--milky);
  opacity: 0;
}

.milky__haze {
  opacity: 0.5;
}

.milky__core {
  opacity: 0.75;
}

.stars {
  fill: var(--star);
}

.moon__dark {
  fill: var(--moon-dark);
}

.moon__dark-craters {
  fill: var(--moon-dark-crater);
}

.moon__lit {
  fill: var(--moon-lit);
}

.moon__craters {
  fill: var(--moon-crater);
}

.land {
  fill: var(--land);
}

.windows {
  fill: var(--windows);
  opacity: 0;
}

.ridge {
  fill: var(--ridge);
}

.shapes {
  display: none;
}

/* Skip, over the sky */
.skip {
  position: absolute;
  top: 10px;
  right: 10px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font: 600 14px/1 'Bricolage Grotesque Variable', system-ui, sans-serif;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.25s ease, visibility 0.25s, transform 0.14s ease-out;
  -webkit-tap-highlight-color: transparent;
}

/* the finger gets 44 pixels, the eye sees 32 */
.skip::after {
  content: '';
  position: absolute;
  inset: -6px -4px;
}

@media (hover: hover) and (pointer: fine) {
  .skip:hover {
    background: rgba(255, 255, 255, 0.24);
  }
}

.skip:active {
  transform: scale(0.95);
}

.skip:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.skip.is-gone {
  opacity: 0;
  visibility: hidden;
}

/* ---------------------------------------------------------------- the sheet under the drawing */
.sheet {
  padding: 18px 16px 16px;
}

/* the names of the steps: the progress is the moon in the drawing and these names, never a count */
.trail {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin: 0 0 12px -8px;
  padding: 0;
  list-style: none;
}

.trail__name {
  position: relative;
  display: inline-grid;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--dim);
  font: 500 13.5px/30px 'Bricolage Grotesque Variable', system-ui, sans-serif;
  letter-spacing: 0.005em;
  cursor: default;
  transition: color 0.3s ease, background-color 0.2s ease, font-weight 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

/* the name at its boldest, hidden and flat: it keeps the place, so a name getting bolder never pushes the others */
.trail__name::before {
  content: attr(data-name);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 680;
}

.trail__name::after {
  content: '';
  position: absolute;
  inset: -7px 0;
}

.trail__step.is-current .trail__name {
  color: var(--accent);
  font-weight: 680;
}

.trail__step.is-done .trail__name {
  color: var(--ink-soft);
  font-weight: 560;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .trail__step.is-done .trail__name:hover {
    color: var(--accent);
    background: var(--accent-soft);
  }
}

.trail__step.is-done .trail__name:active {
  background: var(--accent-soft);
}

.trail__name:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* the steps lie one on the other: the card is as tall as the tallest, and nothing under them jumps */
.panels {
  display: grid;
}

.panel {
  grid-area: 1 / 1;
  min-width: 0;
}

.panel.is-away {
  visibility: hidden;
}

.panel__title {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 660;
  line-height: 28px;
  letter-spacing: -0.018em;
  color: var(--ink);
  text-wrap: balance;
  outline: none;
}

.panel__line {
  min-height: 44px;
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 420;
  line-height: 22px;
  color: var(--muted);
  text-wrap: balance;
}

/* ---------------------------------------------------------------- the choices */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.chip {
  position: relative;
  display: inline-grid;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.16s ease-out;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.chip__face,
.chip__lit {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 18px;
  border-radius: inherit;
  font-size: 15px;
  font-weight: 560;
  white-space: nowrap;
}

.chip__face {
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--chip-edge);
  transition: box-shadow 0.2s ease;
}

/* the choice made: the indigo comes over the chip with a curved edge, the way the light comes over the moon. The
   script moves the edge */
.chip__lit {
  background: var(--accent);
  color: #ffffff;
  clip-path: ellipse(0% 0% at 100% 50%);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover .chip__face {
    box-shadow: inset 0 0 0 1.5px var(--muted);
  }
}

.chip:active {
  transform: scale(0.96);
}

.chip:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ---------------------------------------------------------------- the recap, on the last step */
.recap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recap__item {
  position: relative;
  height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  background: var(--recap);
  color: var(--ink-soft);
  font: 560 14px/36px 'Bricolage Grotesque Variable', system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.16s ease-out;
  -webkit-tap-highlight-color: transparent;
}

.recap__item::after {
  content: '';
  position: absolute;
  inset: -4px 0;
}

@media (hover: hover) and (pointer: fine) {
  .recap__item:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }
}

.recap__item:active {
  transform: scale(0.96);
}

.recap__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- Back and Continue */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

/* the site's elastic pill: the background swells with a bounce, the words widen on the font's width axis */
.pill {
  position: relative;
  display: inline-grid;
  place-items: center;
  height: 48px;
  padding: 0 22px;
  border: 0;
  background: none;
  font: 620 15px/1 'Bricolage Grotesque Variable', system-ui, sans-serif;
  letter-spacing: 0.005em;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.pill > :not(.pill__bg) {
  grid-area: 1 / 1;
}

.pill__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  transition: inset 0.6s cubic-bezier(0.3, 1.8, 0.4, 1), transform 0.14s ease-out, background-color 0.25s ease, box-shadow 0.2s ease;
}

.pill__text {
  display: block;
  font-stretch: 88%;
  white-space: nowrap;
  transition: font-stretch 0.55s cubic-bezier(0.3, 1.6, 0.4, 1), color 0.25s ease;
}

/* the words of Continue roll when they change: cut above and below, free at the sides to widen */
.pill__clip {
  display: grid;
  justify-items: center;
  padding: 3px 0;
  clip-path: inset(0 -40px);
}

.pill--go {
  color: var(--go-ink);
}

.pill--go .pill__bg {
  background: var(--go);
}

.pill--quiet {
  color: var(--ink);
}

.pill--quiet .pill__bg {
  box-shadow: inset 0 0 0 1.5px var(--chip-edge);
}

@media (hover: hover) and (pointer: fine) {
  .pill:not([aria-disabled='true']):hover .pill__bg {
    inset: -2px -7px;
  }

  .pill:not([aria-disabled='true']):hover .pill__text {
    font-stretch: 100%;
  }

  .pill--quiet:hover .pill__bg {
    box-shadow: inset 0 0 0 1.5px var(--muted);
  }
}

.pill:not([aria-disabled='true']):active .pill__bg {
  transform: scale(1.03, 0.88);
}

.pill:focus-visible {
  outline: none;
}

.pill:focus-visible .pill__bg {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent);
}

.pill--quiet:focus-visible .pill__bg {
  box-shadow: inset 0 0 0 1.5px var(--chip-edge), 0 0 0 2px var(--card), 0 0 0 4px var(--accent);
}

/* nothing to go on with: Continue fades to grey and only says why */
.pill--go[aria-disabled='true'] {
  color: var(--off-ink);
  cursor: not-allowed;
}

.pill--go[aria-disabled='true'] .pill__bg {
  background: var(--off);
}

/* on the first step there is nothing to go back to */
.pill--quiet {
  transition: opacity 0.25s ease, visibility 0.25s;
}

.pill--quiet.is-gone {
  opacity: 0;
  visibility: hidden;
}

/* ---------------------------------------------------------------- without movement */
@media (prefers-reduced-motion: reduce) {
  .pill__bg,
  .pill__text {
    transition: background-color 0.25s ease, box-shadow 0.2s ease, color 0.25s ease;
  }

  @media (hover: hover) {
    .pill:not([aria-disabled='true']):hover .pill__bg {
      inset: 0;
    }
  }

  @media (hover: hover) {
    .pill:not([aria-disabled='true']):hover .pill__text {
      font-stretch: 88%;
    }
  }

  .pill:not([aria-disabled='true']):active .pill__bg,
  .chip:active,
  .recap__item:active,
  .skip:active {
    transform: none;
  }
}

/* ---------------------------------------------------------------- a phone */
@media (max-width: 440px) {
  .sheet {
    padding: 16px 14px 14px;
  }

  .panel__title {
    font-size: 22px;
    line-height: 27px;
  }

  .chip__face,
  .chip__lit {
    padding: 0 16px;
  }

  .recap__item {
    padding: 0 12px;
  }
}
