/* The compass button: a deep ink pill on a white page, with a liquid compass in its round left end. The compass, its
   card, its needle, its bubble and its glass are drawn by script.js on a canvas (their colours come from here); the
   pill, the words and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #1b2836;          /* the pill, at its top */
  --pill-deep: #0e1720;     /* the pill, at its foot */
  --ink: #f4efe4;           /* the words */
  --muted: #9fabb6;         /* the small words, and the words while it searches */
  --chip: rgba(244, 239, 228, 0.1);   /* the little Change pill */
  --brass-light: #f7e2a6;   /* the bezel of the compass, where the light falls */
  --brass: #c79a48;         /* the bezel */
  --brass-dark: #6f4f1c;    /* the bezel, in its shadow */
  --card: #f4eddc;          /* the printed card under the needle */
  --card-edge: #ddcfae;     /* the card at its edge, under the lip of the bezel */
  --print: #2a2621;         /* the ticks and the letters printed on the card */
  --rose: #d8cbb0;          /* the faint star printed in the middle of the card */
  --north: #d33a2c;         /* the N, and the north half of the needle */
  --steel: #e9edf0;         /* the south half of the needle */
  --steel-dark: #8f9aa4;    /* the south half, on its dark facet */
  --focus: #1b2836;         /* the ring of the keyboard's focus */
}

* {
  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(--pill);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 72px 16px;
}

.locate {
  display: grid;
  justify-items: center;
}

/* ---------------------------------------------------------------- the pill */
.locate__btn {
  position: relative;
  display: block;
  /* the script sets the width from the words; this is the width before it does */
  width: 252px;
  max-width: calc(100vw - 32px);
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.locate__btn[aria-disabled='true'] {
  cursor: progress;
}

/* the fill is a layer of its own, so it can swell past the pill with a bounce without moving anything */
.locate__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(90% 140% at 18% 0%, rgba(255, 255, 255, 0.07), transparent 62%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(14, 23, 32, 0.22),
    0 14px 28px -14px rgba(14, 23, 32, 0.6);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

.locate__btn:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 5px;
}

html[data-using='pointer'] .locate__btn:focus-visible {
  outline: none;
}

/* the compass sits in the round left end of the pill, a little inside its edge */
.locate__compass {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 60px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
/* three faces on top of each other, right of the compass: at rest, while it searches, and the place found */
.locate__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 62px;
  right: 0;
  pointer-events: none;
}

.locate__face {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  /* as wide as the words, not as the pill is now: the script measures it to size the pill */
  width: max-content;
  display: flex;
  align-items: center;
  text-align: left;
  white-space: nowrap;
}

.locate__face--busy,
.locate__face--found {
  opacity: 0;
  visibility: hidden;
}

/* the words at rest widen on the typeface's width axis under the pointer; the wide copy, invisible and zero high,
   holds their room, so the pill never changes size */
.locate__word {
  display: inline-grid;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.008em;
  line-height: 1;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.9, 0.45, 1), font-weight 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.locate__word::before {
  content: attr(data-wide);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 116%;
  font-weight: 680;
}

/* while it searches: the words in a quieter tone, with a sheen running through them */
.locate__shine {
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 560;
  letter-spacing: -0.004em;
  line-height: 1;
  color: var(--muted);
  background: linear-gradient(100deg, var(--muted) 0%, var(--muted) 38%, var(--ink) 50%, var(--muted) 62%, var(--muted) 100%);
  background-size: 260% 100%;
  background-position: var(--sheen, 100%) 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* the place found: a small line over the name, and the little Change pill at the right end */
.locate__face--found {
  gap: 14px;
}

.locate__place {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.locate__lead {
  font-size: 11.5px;
  font-weight: 520;
  letter-spacing: 0.012em;
  line-height: 1;
  color: var(--muted);
}

.locate__spot {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.locate__pin {
  flex: none;
  width: 14px;
  height: 14px;
  margin-left: -1px;
  fill: none;
  stroke: var(--north);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.locate__name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.008em;
  line-height: 1.05;
}

.locate__change {
  flex: none;
  display: grid;
  place-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px rgba(244, 239, 228, 0.12);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .locate__btn:not([aria-disabled='true']):hover .locate__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.11),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 1px 2px rgba(14, 23, 32, 0.22),
      0 18px 32px -14px rgba(14, 23, 32, 0.66);
  }

  .locate__btn:not([aria-disabled='true']):hover .locate__word {
    font-stretch: 116%;
    font-weight: 680;
  }

  .locate__btn:not([aria-disabled='true']):hover .locate__change {
    background: rgba(244, 239, 228, 0.18);
    box-shadow: inset 0 0 0 1px rgba(244, 239, 228, 0.22);
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .locate__btn:focus-visible .locate__word {
  font-stretch: 116%;
  font-weight: 680;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no widening */
@media (prefers-reduced-motion: reduce) {
  .locate__fill,
  .locate__word {
    transition: box-shadow 0.3s ease, filter 0.3s ease;
  }

  html[data-using='keys'] .locate__btn:focus-visible .locate__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .locate__btn:not([aria-disabled='true']):hover .locate__fill {
    inset: 0;
    filter: brightness(1.22);
  }

  .locate__btn:not([aria-disabled='true']):hover .locate__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}
