/* First run: the welcome walk-through (#onboarding.fr-host > .fr) and the tour of the camera
   screen (.tour-root). Both follow the phone's light/dark setting through app.css's tokens, and
   keep clear of the notch and home bar. */

:root {
  --tour-safe-t: var(--safe-t, env(safe-area-inset-top, 0px));
  --tour-safe-b: var(--safe-b, env(safe-area-inset-bottom, 0px));
  --tour-safe-l: var(--safe-l, env(safe-area-inset-left, 0px));
  --tour-safe-r: var(--safe-r, env(safe-area-inset-right, 0px));
}

/* ------------------------------------------------------------- the walk-through */
/* (z-index under the sheets, so "Invite" and the Snapchat steps can open theirs on top) */
#onboarding.fr-host {
  position: fixed; inset: 0; z-index: 56; display: block; padding: 0; overflow: hidden;
  background: var(--bg, #fff); color: var(--fg, #121214);
}
.fr {
  position: absolute; inset: 0; margin: 0 auto; max-width: 520px;
  display: flex; flex-direction: column;
  padding: calc(var(--tour-safe-t) + 8px) calc(var(--tour-safe-r) + 20px) calc(var(--tour-safe-b) + 16px) calc(var(--tour-safe-l) + 20px);
}
.fr.has-pointer { padding-bottom: calc(var(--tour-safe-b) + 76px); }
.fr-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; flex: none; }
.fr-dots { display: flex; gap: 6px; align-items: center; }
.fr-dots i { display: block; width: 8px; height: 8px; border-radius: 4px; background: var(--line, #ececf0); transition: width .25s ease, background .25s ease; }
.fr-dots i.done { background: var(--muted, #6e6e76); }
.fr-dots i.on { width: 24px; background: var(--fg, #121214); }
.fr-skip {
  margin-left: auto; border: 0; background: none; color: var(--muted, #6e6e76); font-weight: 700; font-size: 15px;
  min-height: 44px; padding: 0 2px 0 12px;
}
.fr-skip:disabled { opacity: .4; }

.fr-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; padding: 12px 0 18px;
  animation: fr-in .32s cubic-bezier(.2,.8,.2,1);
  /* a soft edge where a long step scrolls under the buttons */
  -webkit-mask-image: linear-gradient(#000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 18px), transparent);
}
/* centered when it fits, scrolls from the top when it doesn't */
.fr-body::before, .fr-body::after { content: ""; flex: 1 1 0; max-height: 14vh; }
.fr-art {
  flex: none; width: 76px; height: 76px; border-radius: 24px; background: var(--accent, #ffcf24); color: #121214;
  display: grid; place-items: center; margin: 0 0 22px;
}
.fr-art svg { width: 40px; height: 40px; display: block; }
.fr-count { margin: 0 0 6px; font-size: 12.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted, #6e6e76); }
.fr h1 { margin: 0 0 10px; font-size: 28px; line-height: 1.12; font-weight: 800; letter-spacing: -.02em; }
/* the title takes focus so screen readers start there; it isn't something to press, so no ring */
.fr h1:focus, .fr h1:focus-visible { outline: none; }
.fr-text { margin: 0 0 16px; font-size: 16.5px; line-height: 1.45; color: var(--muted, #6e6e76); }
.fr-promise { margin: 0 0 16px; padding: 13px 15px; border-radius: 16px; background: var(--chip, #f2f2f5); font-size: 15px; line-height: 1.45; }
.fr-promise b { font-weight: 800; }
.fr-code { letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.fr-fine { margin: 0 0 12px; font-size: 13.5px; line-height: 1.45; color: var(--muted, #6e6e76); }
.fr-fields { margin: 4px 0 6px; }
.fr .field input { background: var(--bg, #fff); color: var(--fg, #121214); }
.fr .steps { margin: 0 0 14px; }
.fr .setup-help { margin: 10px 0 4px; font-size: 14.5px; }
.fr-details { margin: 0 0 14px; padding: 12px 15px; border-radius: 16px; background: var(--chip, #f2f2f5); }
.fr-details summary { font-weight: 800; cursor: pointer; min-height: 24px; }
.fr-details summary:focus-visible { outline: 3px solid var(--send, #0eadff); outline-offset: 4px; border-radius: 6px; }
.fr-msg { margin: 4px 0 0; min-height: 1.45em; font-size: 14.5px; font-weight: 700; color: var(--fg, #121214); }
.fr-msg:empty { min-height: 0; }
.fr-msg.bad { color: var(--heart, #ff375f); }
.fr-msg.good { color: var(--ok, #1fbf6a); }
.fr-actions { flex: none; display: grid; gap: 8px; padding-top: 12px; }
.fr-actions .btn { margin: 0; min-height: 52px; height: auto; padding: 12px 16px; }
.fr-actions .btn + .btn { margin-top: 0; }
.fr-actions .btn:focus-visible, .fr-skip:focus-visible, .tour-root button:focus-visible {
  outline: 3px solid var(--send, #0eadff); outline-offset: 2px;
}
@keyframes fr-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* iPhone Safari: an arrow at Safari's own Share button (bottom of the screen; top right on iPad) */
.fr-pointer {
  position: absolute; left: 50%; bottom: calc(var(--tour-safe-b) + 6px); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none;
  color: var(--fg, #121214); font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.fr-pointer i { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--accent, #ffcf24); color: #121214; padding: 6px; animation: fr-bob 1.1s ease-in-out infinite; }
.fr-pointer i svg { width: 100%; height: 100%; display: block; }
.fr-pointer.top { top: calc(var(--tour-safe-t) + 4px); bottom: auto; left: auto; right: calc(var(--tour-safe-r) + 18px); transform: none; flex-direction: column-reverse; }
.fr-pointer.top i { transform: rotate(180deg); animation-name: fr-bob-up; }
@keyframes fr-bob { 50% { transform: translateY(6px); } }
@keyframes fr-bob-up { from, to { transform: rotate(180deg); } 50% { transform: rotate(180deg) translateY(6px); } }

/* a short screen (a small phone, or the keyboard open): tighter */
@media (max-height: 760px) {
  .fr-body:has(.fr-fields) .fr-art { display: none; }
  .fr-art { width: 60px; height: 60px; border-radius: 19px; margin-bottom: 14px; }
  .fr-art svg { width: 32px; height: 32px; }
  .fr h1 { font-size: 25px; }
  .fr-text { font-size: 15.5px; margin-bottom: 12px; }
  .fr-body::before, .fr-body::after { max-height: 6vh; }
}

/* ------------------------------------------------------------- the tour of the camera screen */
.tour-root {
  position: fixed; inset: 0; z-index: 58; cursor: pointer; touch-action: none;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
.tour-spot {
  position: fixed; pointer-events: none; border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent, #ffcf24), 0 0 0 9999px rgba(0, 0, 0, .68);
  transition: left .32s cubic-bezier(.2,.8,.2,1), top .32s cubic-bezier(.2,.8,.2,1), width .32s cubic-bezier(.2,.8,.2,1), height .32s cubic-bezier(.2,.8,.2,1), border-radius .32s;
}
.tour-spot::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 3px solid var(--accent, #ffcf24);
  animation: tour-pulse 1.6s ease-out infinite;
}
@keyframes tour-pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(1.35); opacity: 0; } }
.tour-tip {
  position: fixed; width: min(340px, calc(100vw - 32px)); cursor: default;
  background: var(--bg, #fff); color: var(--fg, #121214); border-radius: 18px; padding: 14px 16px 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .38), 0 0 0 1px color-mix(in srgb, var(--fg, #121214) 12%, transparent);
  transition: left .32s cubic-bezier(.2,.8,.2,1), top .32s cubic-bezier(.2,.8,.2,1);
}
.tour-root.no-anim .tour-spot, .tour-root.no-anim .tour-tip { transition: none; }
.tour-arrow { position: absolute; bottom: -7px; width: 16px; height: 16px; background: inherit; transform: rotate(45deg); border-radius: 3px; }
.tour-tip.below .tour-arrow { top: -7px; bottom: auto; }
.tour-tip h2 { margin: 0 0 4px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.tour-tip p { margin: 0; font-size: 15px; line-height: 1.42; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.tour-count { font-size: 13px; font-weight: 700; color: var(--muted, #6e6e76); font-variant-numeric: tabular-nums; }
.tour-btns { display: flex; gap: 6px; align-items: center; }
.tour-skip { border: 0; background: none; color: var(--muted, #6e6e76); font-weight: 700; font-size: 14.5px; min-height: 44px; padding: 0 10px; }
.tour-next {
  border: 0; border-radius: 999px; min-height: 44px; padding: 0 20px; font-weight: 800; font-size: 15px;
  background: var(--accent, #ffcf24); color: var(--accent-fg, #121214);
}
.tour-tip .tour-hint { margin-top: 6px; font-size: 12px; color: var(--muted, #6e6e76); text-align: center; }
.tour-live, .tour-safe-probe {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.tour-safe-probe {
  position: fixed; visibility: hidden; pointer-events: none; box-sizing: content-box;
  padding: var(--tour-safe-t) var(--tour-safe-r) var(--tour-safe-b) var(--tour-safe-l);
}

@media (prefers-reduced-motion: reduce) {
  .fr-body, .fr-pointer i, .tour-spot::after { animation: none !important; }
  .tour-spot, .tour-tip, .fr-dots i { transition: none !important; }
}
