/*
 * The ? button, top right on both pages, and its pop-up: what Trip Reveal is, and the way to the privacy policy
 * and credits (/privacy). The button is Begin's glass as a circle; the pop-up the intro menus' dark glass, a
 * native popover grown from the button (help.js closes it when a click lands in the globe's frame).
 */

:root {
  /* set in from the corner, on a margin that grows with the window */
  --help-top: max(clamp(24px, 4.5vh, 44px), env(safe-area-inset-top));
  --help-right: max(clamp(24px, 3.2vw, 52px), env(safe-area-inset-right));
  --help-ease: cubic-bezier(0.25, 1, 0.5, 1);
  --help-snap: cubic-bezier(0.23, 1, 0.32, 1);
}

/* Orbit inside the reveal's frame shows only the globe */
.embedded .help,
.embedded .about {
  display: none;
}

/* the reveal: it waits, hidden, until Begin is ready, then arrives; it leaves with the intro */
.intro:has(#start:disabled) .help {
  visibility: hidden;
  animation: none;
}

/* ---------- the help button: Begin's glass as a circle, top right ---------- */
.help {
  position: fixed;
  top: var(--help-top);
  right: var(--help-right);
  z-index: 40;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #f3efe6;
  cursor: pointer;
  background:
    radial-gradient(120% 150% at 50% 0%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -10px 18px -12px rgba(110, 160, 230, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 16px 40px -18px rgba(90, 140, 230, 0.6);
  /* arrives a beat after the page, out of a soft blur (on the reveal, once Begin is ready) */
  animation: help-in 1.2s var(--help-ease) 0.6s backwards; /* released once in, so hover moves it */
  transition: transform 0.4s var(--help-ease), box-shadow 0.4s var(--help-ease);
  -webkit-tap-highlight-color: transparent;
}
/* the hit area stays where the button rests, so at its edge the lift can't slip out from under the
   pointer and bounce (it moves down as the button moves up) */
.help::after { content: ''; position: absolute; inset: -3px; border-radius: 50%;
  transition: transform 0.4s var(--help-ease); }
@media (hover: hover) { .help:hover::after { transform: translateY(2px); } }
@keyframes help-in {
  from { opacity: 0; filter: blur(6px); transform: translateY(-6px) scale(0.92); }
}
/* the two glyphs share one place: ? at rest, × while the pop-up is open */
.help svg { grid-area: 1 / 1; width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.45s var(--help-snap), opacity 0.25s ease; }
.help .help-x { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.help:has(+ .about:popover-open) .help-q { opacity: 0; transform: rotate(90deg) scale(0.6); }
.help:has(+ .about:popover-open) .help-x { opacity: 1; transform: none; }

@media (hover: hover) {
  /* anticipation: it lifts and the ? leans in, as if about to answer */
  .help:hover {
    transform: translateY(-2px);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.4),
      inset 0 -10px 18px -10px rgba(110, 160, 230, 0.7),
      0 0 0 1px rgba(255, 255, 255, 0.2),
      0 20px 46px -16px rgba(90, 140, 230, 0.8);
  }
  .help:hover .help-q { transform: rotate(-8deg) scale(1.04); transition: transform 0.4s var(--help-ease); }
}
/* the press: it gives under the finger, quick */
.help:active { transform: scale(0.92); transition-duration: 0.15s; }
.help:focus-visible { outline: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36),
  0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 0 3px #06080c, 0 0 0 5px rgba(170, 200, 255, 0.75); }

/* ---------- the pop-up: the intro menus' dark glass, grown from the button ---------- */
.about {
  position: fixed;
  box-sizing: border-box;
  inset: auto;
  top: calc(var(--help-top) + 56px);
  right: var(--help-right);
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 120px);
  margin: 0;
  padding: 28px 28px 22px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  color: rgba(243, 239, 230, 0.8);
  font: 400 15px/1.65 'Manrope', system-ui, sans-serif;
  text-align: left;
  background: rgba(20, 24, 32, 0.62);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 40px 90px -30px rgba(0, 0, 0, 0.8);
  transform-origin: calc(100% - 22px) -34px; /* the button's centre */
  opacity: 0;
  transform: translateY(-6px) scale(0.94);
  filter: blur(4px);
  transition: opacity 0.2s ease, transform 0.25s var(--help-snap), filter 0.2s ease,
    overlay 0.25s allow-discrete, display 0.25s allow-discrete;
}
.about:popover-open { opacity: 1; transform: none; filter: none;
  transition: opacity 0.3s ease, transform 0.5s var(--help-snap), filter 0.3s ease,
    overlay 0.5s allow-discrete, display 0.5s allow-discrete; }
@starting-style { .about:popover-open { opacity: 0; transform: translateY(-6px) scale(0.94); filter: blur(4px); } }
/* its contents settle a beat after the panel */
.about > * { transition: opacity 0.4s ease 0.08s, transform 0.5s var(--help-ease) 0.08s; }
@starting-style { .about:popover-open > * { opacity: 0; transform: translateY(4px); } }

.about h2 { margin: 0 0 10px; color: #f3efe6; font: italic 400 30px/1.1 'Instrument Serif', Georgia, serif; }
.about p { margin: 0 0 12px; }
.about footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.about footer small { color: rgba(243, 239, 230, 0.45); font-size: 13px; }
.about a { display: inline-flex; align-items: center; gap: 6px; color: #f3efe6; font-weight: 600;
  text-decoration: none; }
.about a svg { width: 13px; height: 13px; transition: transform 0.4s var(--help-ease); }
@media (hover: hover) { .about a:hover svg { transform: translateX(3px); } }
.about a:focus-visible { outline: 2px solid rgba(170, 200, 255, 0.75); outline-offset: 4px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  .help, .help svg, .about, .about > * { animation: none; transition-duration: 0.01s; }
  .help:hover .help-q { transform: none; }
}
@media (orientation: landscape) and (max-height: 500px), (orientation: portrait) and (max-width: 500px) {
  :root { --help-top: max(14px, env(safe-area-inset-top)); --help-right: max(16px, env(safe-area-inset-right)); }
  /* a phone: a panel clearly smaller than the window, room around it on every side */
  .about { width: min(320px, calc(100vw - 64px)); max-height: calc(100dvh - 96px); padding: 18px 18px 14px;
    border-radius: 20px; font-size: 14px; line-height: 1.55; }
  .about h2 { font-size: 25px; margin-bottom: 8px; }
  .about footer { margin-top: 12px; padding-top: 12px; }
}
