/* ──────────────────────────────────────────────────────────────────
   First-visit guided tour + plain-English glossary tooltips.
   Loaded on every hub page (not the audience portal, which has its
   own base template). All selectors are namespaced `guide-`/`gloss-`.
   ────────────────────────────────────────────────────────────────── */

:root {
  --guide-ease: cubic-bezier(.25, 1, .35, 1);
  --guide-dim: rgba(17, 17, 37, .55);
}

/* ── Tour layer ─────────────────────────────────────────────────── */

.guide-layer {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: none;
}
.guide-layer.is-on {
  display: block;
  animation: guide-fade .28s ease-out both;
}

/* The spotlight: a transparent rounded window whose giant box-shadow
   dims the rest of the page. It glides between targets. */
.guide-spot {
  position: fixed;
  pointer-events: none;
  border: 2px solid rgba(255, 207, 0, .95);
  border-radius: 14px;
  box-shadow: 0 0 0 200vmax var(--guide-dim);
  transition:
    top .5s var(--guide-ease), left .5s var(--guide-ease),
    width .5s var(--guide-ease), height .5s var(--guide-ease),
    border-radius .35s ease, border-color .3s ease;
}
.guide-spot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  animation: guide-pulse 2s ease-out infinite;
}
.guide-layer.no-anim .guide-spot { transition: none; }
.guide-layer.is-center .guide-spot { border-color: transparent; }
.guide-layer.is-center .guide-spot::after { display: none; }

/* ── The speech bubble ──────────────────────────────────────────── */

.guide-pop {
  position: fixed;
  width: min(340px, calc(100vw - 24px));
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(17, 17, 37, .05);
  padding: .95rem 1.05rem .8rem;
  font-family: var(--font);
}
.guide-pop.pop-in { animation: guide-pop .42s cubic-bezier(.2, .9, .3, 1.35) both; }
.guide-pop.is-center {
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 24px));
  padding: 1.25rem 1.3rem 1rem;
  text-align: left;
}
.guide-pop.is-center.pop-in { animation: guide-pop-center .42s cubic-bezier(.2, .9, .3, 1.35) both; }

.guide-arrow {
  position: absolute;
  width: 13px;
  height: 13px;
  background: var(--card);
  transform: rotate(45deg);
}

.guide-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .5rem;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.guide-count {
  background: var(--yellow);
  color: var(--ink);
  padding: .12rem .5rem;
  border-radius: var(--r-full);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
}

.guide-title {
  margin: 0 0 .35rem;
  font-size: .99rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}
.guide-pop.is-center .guide-title { font-size: 1.12rem; }
.guide-body {
  margin: 0;
  font-size: .845rem;
  line-height: 1.58;
  color: var(--text-soft);
}

.guide-foot {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .9rem;
}
.guide-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-right: auto;
}
.guide-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: var(--r-full);
  background: var(--border-strong);
  cursor: pointer;
  transition: width .25s ease, background .25s ease;
}
.guide-dot.is-here {
  width: 16px;
  background: var(--yellow);
}
.guide-dot:hover { background: var(--muted-soft); }
.guide-dot.is-here:hover { background: var(--yellow); }

.guide-btn {
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  border-radius: 8px;
  padding: .42rem .85rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease,
              color .15s ease, transform .15s ease;
}
.guide-btn.primary { background: var(--yellow); color: var(--ink); }
.guide-btn.primary:hover { background: var(--yellow-hover); transform: translateY(-1px); }
.guide-btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-soft);
}
.guide-btn.ghost:hover { border-color: var(--ink); color: var(--ink); }
.guide-skip {
  background: none;
  border: none;
  padding: .3rem .15rem;
  font: inherit;
  font-size: .73rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  white-space: nowrap;
}
.guide-skip:hover { color: var(--ink); }

/* ── "Show me around" floating button ───────────────────────────── */

.guide-beacon {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem .5rem .55rem;
  border: none;
  border-radius: var(--r-full);
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.guide-beacon:hover {
  background: var(--yellow-hover);
  transform: translateY(-2px);
  box-shadow: 0 20px 44px -8px rgba(17, 17, 37, .28), 0 8px 16px -8px rgba(17, 17, 37, .12);
}
.guide-beacon:active { transform: scale(.97); }
.guide-beacon-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--yellow);
  font-size: .8rem;
  font-weight: 800;
}
.guide-beacon-label { white-space: nowrap; }
body.guide-open .guide-beacon { display: none; }

/* ── "Guide" button in the top bar ──────────────────────────────── */

.guide-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .32rem .8rem .32rem .42rem;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: var(--r-full);
  color: #fff;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.guide-topbar-btn:hover {
  border-color: var(--yellow);
  color: var(--yellow);
  background: rgba(255, 207, 0, .08);
}
.guide-topbar-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-size: .68rem;
  font-weight: 800;
}

/* ── Glossary: "?" badges, dotted terms and the shared tooltip ──── */

.gloss-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: .35rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-family: var(--font);
  font-size: .62rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.gloss-btn:hover,
.gloss-btn:focus-visible {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--ink);
}

.gloss-term {
  border-bottom: 1px dotted var(--muted-soft);
  cursor: help;
}

.gloss-tip {
  position: fixed;
  z-index: 260;
  max-width: 272px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font);
  font-size: .775rem;
  font-weight: 500;
  line-height: 1.52;
  padding: .55rem .75rem .6rem;
  border-radius: 9px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(4px) scale(.97);
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
}
.gloss-tip.is-on { opacity: 1; transform: none; }
.gloss-tip strong {
  display: block;
  margin-bottom: .18rem;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--yellow);
}
.gloss-tip-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--ink);
  transform: rotate(45deg);
}

.gloss-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Animations ─────────────────────────────────────────────────── */

@keyframes guide-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes guide-pop {
  from { opacity: 0; transform: translateY(9px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
@keyframes guide-pop-center {
  from { opacity: 0; transform: translate(-50%, -47%) scale(.94); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes guide-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 207, 0, .5); }
  70%  { box-shadow: 0 0 0 15px rgba(255, 207, 0, 0); }
  100% { box-shadow: 0 0 0 15px rgba(255, 207, 0, 0); }
}

@media (max-width: 640px) {
  /* Collapse the pill back to a compact circle on small screens. */
  .guide-beacon {
    right: 13px;
    bottom: 13px;
    gap: 0;
    padding: 0;
    width: 42px;
    height: 42px;
    justify-content: center;
  }
  .guide-beacon-label { display: none; }
  .guide-beacon-mark {
    width: auto;
    height: auto;
    background: transparent;
    color: var(--ink);
    font-size: 1.1rem;
  }
  .guide-topbar-btn span:not(.guide-topbar-mark) { display: none; }
  .guide-topbar-btn { padding: .32rem .42rem; }
  .guide-pop { padding: .85rem .9rem .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .guide-layer.is-on,
  .guide-pop.pop-in,
  .guide-pop.is-center.pop-in { animation: none; }
  .guide-spot { transition: none; }
  .guide-spot::after { animation: none; box-shadow: none; }
  .guide-beacon,
  .guide-topbar-btn,
  .guide-btn,
  .guide-dot,
  .gloss-tip { transition: none; }
}
