/**
 * Gamified Site Tour — styles (Notes.md #4, Component D)
 * Design: docs/design/notes-backlog-ux-spec.md §D
 * Implementation: Yuuji Itadori
 * Date: 2026-09-22
 *
 * Reuse-first: extends frontend/styles/passport-form.css's stamp grammar
 * (--passport-yellow / --passport-green / --passport-transition) with a
 * jwh-tour- prefix, and the Island Glass jwh-modal shell (confirm-modal.css)
 * for the welcome prompt / finale. The spotlight callout is intentionally
 * NOT wrapped in .jwh-modal-overlay — the ring's own giant box-shadow is the
 * dim layer, so the page stays interactive underneath (per spec).
 */

:root {
  --jwh-tour-yellow: var(--passport-yellow, #ffee00);
  --jwh-tour-green: var(--passport-green, #28a745);
}

/* ============================================================
   SPOTLIGHT RING
   ============================================================ */
.jwh-tour-ring {
  position: absolute;
  border: 2px solid var(--ig-gold, #fed100);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78);
  pointer-events: none;
  z-index: 10006; /* above jwh-modal's 10005 */
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .jwh-tour-ring {
    transition: none;
  }
}

/* TASK 2 fixed-ancestor placement: the floating icons (.floating-icons-wrapper)
   are position:fixed, so their rect is viewport-relative and doesn't move
   with scroll. site-tour.js zeroes scrollX/scrollY in its placement math for
   these targets AND toggles this class so the ring itself stops scrolling
   with the document too — otherwise the two would drift apart on scroll. */
.jwh-tour-ring--fixed {
  position: fixed;
}

/* TASK 3: hides the ring/callout (state preserved, not torn down) while
   #loginModal is open — the tour's own z-index (10006/10007) sits ABOVE
   jwh-modal's 10005 and would otherwise cover the login dialog. */
.jwh-tour-ui--hidden {
  display: none !important;
}

/* ============================================================
   CALLOUT (non-modal — page stays interactive underneath)
   ============================================================ */
.jwh-tour-callout {
  position: absolute;
  z-index: 10007;
  width: min(340px, calc(100vw - 32px));
  background: rgba(15, 15, 15, 0.94);
  border: 1px solid rgba(254, 209, 0, 0.35);
  border-radius: 14px;
  padding: 16px 18px 14px;
  color: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  font-family: inherit;
  animation: jwh-tour-callout-in 220ms ease-out;
}

/* Fixed-bottom fallback (desktop) for targets taller than the viewport —
   ring-clamping alone can't place a "below/above the target" callout when
   both rect.top and rect.bottom are off-screen (Nobara review, fix 4).
   Overrides the entrance keyframe's translateY with a centered translateX
   so the two transforms don't fight during the 220ms entrance. */
.jwh-tour-callout--fixed-bottom {
  position: fixed;
  top: auto;
  left: 50%;
  right: auto;
  bottom: 24px;
  transform: translateX(-50%);
  animation: jwh-tour-callout-in-fixed-bottom 220ms ease-out;
}

/* TASK 2 fixed-ancestor placement companion to .jwh-tour-ring--fixed above —
   same reasoning, applied to the callout when its spotlighted target sits
   inside a position:fixed ancestor (e.g. .floating-icons-wrapper). Distinct
   from --fixed-bottom (which anchors bottom-center regardless of target
   position for viewport-taller-than-target cases): this one still uses the
   computed top/left from site-tour.js, just interpreted as viewport-fixed
   coordinates instead of document-absolute ones. */
.jwh-tour-callout--target-fixed {
  position: fixed;
}

@keyframes jwh-tour-callout-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes jwh-tour-callout-in-fixed-bottom {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.jwh-tour-callout__progress {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 4px;
}

.jwh-tour-callout__title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  transition: opacity 130ms ease;
}

.jwh-tour-callout__body {
  margin: 0 0 10px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.85);
  transition: opacity 130ms ease;
}

/* Short cross-fade of title/body content on each showStop() (Nobara review,
   fix 2) — toggled by site-tour.js immediately before swapping the text. */
.jwh-tour-callout--content-fading .jwh-tour-callout__title,
.jwh-tour-callout--content-fading .jwh-tour-callout__body {
  opacity: 0;
}

.jwh-tour-callout__levelbar {
  margin-bottom: 10px;
}

.jwh-tour-callout__levelbar-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--jwh-tour-yellow);
  margin-bottom: 4px;
}

.jwh-tour-callout__levelbar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.jwh-tour-callout__levelbar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--jwh-tour-green), var(--jwh-tour-yellow));
  transition: width 400ms ease-in-out;
}

.jwh-tour-callout__levelbar--levelup .jwh-tour-callout__levelbar-track {
  animation: jwh-tour-levelup-burst 600ms ease-out;
}

@keyframes jwh-tour-levelup-burst {
  0% { box-shadow: 0 0 0 0 rgba(254, 209, 0, 0.6); }
  100% { box-shadow: 0 0 0 10px rgba(254, 209, 0, 0); }
}

.jwh-tour-callout__xp {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #000;
  background: var(--jwh-tour-yellow);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 10px;
}

/* TASK 3: "Show me" — logged-out profile-hub stop only. Its own full-width
   row above .jwh-tour-callout__actions rather than crowding into the
   Skip/Back/Next row. */
.jwh-tour-callout__showme-btn {
  display: block;
  width: 100%;
  margin: 0 0 10px;
}

/* One-row equal-width Skip/Back/Next (USER redesign 2026-09-22 — supersedes
   the earlier "Skip full row, Back+Next half row" layout drafted earlier in
   this same task; see dev-notes.md for the full sequence). All three
   buttons are equal-width flex children (flex: 1 1 0) at every viewport, so
   when Back is hidden on stop 1 (backBtn.hidden — site-tour.js ~line 1645,
   [hidden] is forced to display:none by the rule below) Skip and Next
   automatically split the row 50/50 instead of leaving an empty slot — pure
   flexbox, no [hidden]-target selector needed. Applied unscoped by media
   query so desktop gets the same even row as mobile (USER: "apply the same
   one-row treatment on desktop if it currently looks uneven there too" —
   it did: Skip was ghost/left-pushed while Back+Next were right-aligned). */
.jwh-tour-callout__actions {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 8px;
}

.jwh-tour-callout__actions .jwh-modal__btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px; /* WCAG 2.5.8 / Apple HIG minimum tap target */
  padding: 10px 10px;
  font-size: 0.82rem;
  letter-spacing: 0;
  white-space: nowrap;
}

/* Jamaica flag colour-coding (USER decision 2026-09-22). Contrast ratios
   (WCAG relative-luminance formula, hand-verified — see dev-notes.md for
   the full calculation):
     NEXT  #FED100 bg / #000 text -> ~13.9:1
     BACK  #009B3A bg / #000 text -> ~5.7:1 (white text on this green is
                                              only ~3.65:1 and fails AA at
                                              this text size — black used
                                              instead, per USER instruction)
     SKIP  #000000 bg / #fff text -> 21:1 (max), plus a 2px gold border so
                                            the button doesn't vanish against
                                            the callout's own near-black
                                            glass background
                                            (rgba(15, 15, 15, 0.94))
   Scoped to .jwh-tour-callout__actions only. The welcome prompt footer, the
   navigator CTA (.jwh-tour-nav-cta), the finale footer, and the pause/
   confirm dialogs elsewhere on the site all reuse the same shared
   .jwh-modal__btn--confirm/--cancel base classes, but none of them are
   descendants of .jwh-tour-callout__actions, so these overrides do not
   reach them. */
.jwh-tour-callout__actions [data-tour-action="next"] {
  background: #fed100;
  color: #000;
  /* Transparent 2px border matches Skip's gold border so flex: 1 1 0
     yields truly equal thirds (a border sits outside the flex share). */
  border: 2px solid transparent;
}

.jwh-tour-callout__actions [data-tour-action="next"]:hover {
  background: #ffdc3d;
  box-shadow: 0 4px 14px rgba(254, 209, 0, 0.45);
}

/* The shared .jwh-modal__btn--confirm focus ring is gold (#ffee00) — nearly
   invisible against this button's own gold fill. Swapped to white so the
   ring reads as a distinct shape (offset outline), not just a colour
   change, per USER instruction. */
.jwh-tour-callout__actions [data-tour-action="next"]:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.jwh-tour-callout__actions [data-tour-action="back"] {
  background: #009b3a;
  color: #000;
  border: 2px solid transparent; /* equal thirds — see Next above */
}

.jwh-tour-callout__actions [data-tour-action="back"]:hover {
  background: #00b043;
}

/* Back/Skip both use the shared .jwh-modal__btn--cancel base, whose default
   focus-visible ring (#ffee00 gold, confirm-modal.css) already contrasts
   well against both the green Back fill and the black Skip fill below, so
   neither needs a per-button override the way Next does above. */
.jwh-tour-callout__actions [data-tour-action="skip"] {
  background: #000;
  color: #fff;
  border: 2px solid #fed100;
}

.jwh-tour-callout__actions [data-tour-action="skip"]:hover {
  background: #1a1a1a;
  color: #fff;
}

.jwh-tour-callout [hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .jwh-tour-callout,
  .jwh-tour-callout--fixed-bottom {
    animation: none;
  }
  .jwh-tour-callout__title,
  .jwh-tour-callout__body {
    transition: none;
  }
  .jwh-tour-callout__levelbar-fill {
    transition: none;
  }
  .jwh-tour-callout__levelbar--levelup .jwh-tour-callout__levelbar-track {
    animation: none;
  }
}

/* ============================================================
   MOBILE — bottom sheet callout (<=640px per brief)
   ============================================================ */
@media (max-width: 640px) {
  .jwh-tour-callout {
    position: fixed;
    top: auto !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  /* DEFECT B (TS-20260922_172702) and the interim "Skip full row, Back+Next
     half row" layout that followed it are both superseded by the single
     equal-width Skip/Back/Next row defined above (USER redesign
     2026-09-22) — that rule applies unscoped by media query now, so
     nothing phone-specific is needed for .jwh-tour-callout__actions here
     any more; see the comment above .jwh-tour-callout__actions for why. */
}

/* ============================================================
   WELCOME PROMPT / FINALE extras (jwh-modal shell is reused as-is)
   ============================================================ */
.jwh-tour-skip-link {
  display: block;
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 10px 0 4px;
  min-height: 32px;
}

.jwh-tour-skip-link:hover,
.jwh-tour-skip-link:focus-visible {
  color: #fff;
}

.jwh-tour-skip-link:focus-visible {
  outline: 2px solid #ffee00;
  outline-offset: 2px;
}

/* ============================================================
   PASSPORT-STYLE BADGE BOOK — extends passport-form.css grammar
   ============================================================ */
.jwh-tour-stampbook {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.jwh-tour-stamp {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.3);
  transition: all var(--passport-transition, 300ms ease-in-out);
  margin: 0 auto;
}

.jwh-tour-stamp i {
  font-size: 18px;
}

.jwh-tour-stamp.earned {
  border-color: var(--jwh-tour-green);
  color: var(--jwh-tour-green);
  animation: jwh-tour-stamp-in 400ms ease-out;
}

@keyframes jwh-tour-stamp-in {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .jwh-tour-stamp,
  .jwh-tour-stamp.earned {
    transition: none;
    animation: none;
  }
}

/* ============================================================
   FINALE — level line + CTA row spacing (shell reused from jwh-modal)
   ============================================================ */
.jwh-tour-finale-level {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  margin: 0 0 4px;
}

/* ============================================================
   CONFETTI CANVAS — self-hosted, fixed full-viewport, decorative only
   ============================================================ */
.jwh-tour-confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10010;
}

/* ============================================================
   REPLAY FLOATING ICON — mirrors the pill + circle pattern
   (support-container.css .floating-gear-icon treatment, new class
   name only per spec D.6 — no shared-file edits required)
   ============================================================ */
.tour-replay-container {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 15px;
  height: 50px;
  max-height: 50px;
  min-height: 50px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.tour-replay-icon {
  position: relative; /* anchors .tour-hub-badge's position: absolute (§1.1) */
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  box-sizing: border-box;
  border: 2px solid var(--jwh-tour-yellow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--jwh-tour-yellow);
  box-shadow:
    0 4px 12px rgba(255, 238, 0, 0.4),
    0 0 20px rgba(255, 238, 0, 0.6),
    0 0 40px rgba(255, 238, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0;
  padding: 0;
}

/* ============================================================
   TOUR HUB PROGRESS BADGE (docs/design/tour-navigator-redesign.md §1.1) —
   the merged icon's own progress indicator, replacing the separate green
   .tour-progress-icon (removed below). Hidden entirely at 0 badges
   (site-tour.js refreshTourHubUI()) so a first-time visitor sees a clean
   compass, not a "0" that reads like an error state.
   ============================================================ */
.tour-hub-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(15, 15, 15, 0.94);
  border: 2px solid var(--jwh-tour-green);
  color: var(--jwh-tour-green);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tour-hub-badge--complete {
  background: var(--jwh-tour-green);
  color: #000;
}

.tour-hub-badge--complete i {
  font-size: 0.6rem;
}

.tour-replay-icon i {
  font-size: 24px;
  color: #000;
}

.tour-replay-icon:hover {
  background: #fff700;
  transform: scale(1.1) rotate(-12deg);
  box-shadow:
    0 6px 20px rgba(255, 238, 0, 0.6),
    0 0 30px rgba(255, 238, 0, 0.8),
    0 0 60px rgba(255, 238, 0, 0.5);
}

.tour-replay-icon:focus-visible {
  outline: 3px solid #ffee00;
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .tour-replay-icon {
    width: 45px;
    height: 45px;
    min-width: 45px;
    min-height: 45px;
  }

  .tour-replay-icon i {
    font-size: 20px;
  }

  .tour-replay-container .pill-btn {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-replay-icon {
    transition: none;
  }
  .tour-replay-icon:hover {
    transform: none;
  }
}

/* Conditional "View my badges" link inside the welcome prompt, shown only
   when the user already has some progress (fix 1). Reuses the skip-link's
   quiet text-link treatment. */
.jwh-tour-progress-link {
  display: block;
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--jwh-tour-green);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
  min-height: 32px;
}

.jwh-tour-progress-link:hover,
.jwh-tour-progress-link:focus-visible {
  color: #fff;
}

.jwh-tour-progress-link:focus-visible {
  outline: 2px solid #ffee00;
  outline-offset: 2px;
}

/* ============================================================
   NAVIGATOR — interactive page list inside showProgressModal()
   (docs/design/tour-navigator-redesign.md §2.2). Each row is a full-width
   link (not a bare icon), so its accessible name is real, readable text
   (WCAG 2.4.6) rather than a hover-only title.
   ============================================================ */
.jwh-tour-nav-cta {
  display: block;
  width: 100%;
  margin: 0 0 14px;
}

.jwh-tour-navlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.jwh-tour-navlist__item {
  display: flex;
  align-items: stretch;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.jwh-tour-navlist__item:last-child {
  border-bottom: none;
}

.jwh-tour-navitem {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
}

.jwh-tour-navitem:hover {
  background: rgba(255, 255, 255, 0.06);
}

.jwh-tour-navitem:focus-visible {
  outline: 2px solid #ffee00;
  outline-offset: -2px;
}

.jwh-tour-navitem__stamp {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.3);
}

.jwh-tour-navitem__stamp.earned {
  border-color: var(--jwh-tour-green);
  color: var(--jwh-tour-green);
}

.jwh-tour-navitem__stamp i {
  font-size: 14px;
}

.jwh-tour-navitem__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.jwh-tour-navitem__label {
  font-size: 0.9rem;
  font-weight: 700;
}

.jwh-tour-navitem__status {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.6);
}

.jwh-tour-navitem--done .jwh-tour-navitem__status {
  color: var(--jwh-tour-green);
}

.jwh-tour-navitem__chevron {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.35);
}

/* Secondary "replay this page's tour" icon button on collected rows only
   (USER decision, TS-20260922_172702) — own tap target, distinct accessible
   name, keyboard reachable via normal DOM tab order (it's a sibling <a>,
   not nested inside the primary row link). */
.jwh-tour-navitem__replay {
  flex: 0 0 auto;
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--jwh-tour-green);
  border-radius: 8px;
  text-decoration: none;
}

.jwh-tour-navitem__replay:hover {
  background: rgba(40, 167, 69, 0.15);
}

.jwh-tour-navitem__replay:focus-visible {
  outline: 2px solid #ffee00;
  outline-offset: -2px;
}

/* F1 fix (TS-20260922_172702): the height cap used to live ONLY on
   .jwh-tour-navlist inside the <=640px mobile media query below, so at
   wider viewports (e.g. 1366x768) nothing capped the modal at all — header
   + level bar + CTA + 15 navlist rows + footer could add up to far more
   than the viewport height, pushing #tourProgressModal's `top: 50%`
   centering math into negative territory (observed: 1172px tall, top:
   -202px) and making the title and Close button unreachable. Fixed at the
   MODAL level, at every width, instead of just the list: flex-column
   layout keeps the header and footer always visible (flex: 0 0 auto), and
   only the body (level bar/CTA/navlist) scrolls internally once it exceeds
   90vh. `vh` is used rather than a fixed px value because it's
   viewport-relative and unaffected by the sitewide `body { zoom: 0.8 }`
   (unlike the JS-computed ring/callout pixel math elsewhere in this file,
   which DOES need the explicit /zoom correction — see BUG-TOUR-ZOOM-001). */
#tourProgressModal {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

#tourProgressModal .jwh-modal__header,
#tourProgressModal .jwh-modal__footer {
  flex: 0 0 auto;
}

#tourProgressModal .jwh-modal__body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 640px) {
  .jwh-tour-navitem__stamp {
    width: 32px;
    height: 32px;
  }
}
