/* ============================================================
   Guided Tour — Spotlight, Tooltips & Contribute Nudge
   ============================================================ */

/* --- Overlay & Spotlight --- */

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.tour-overlay--hidden {
  opacity: 0;
  pointer-events: none;
}

.tour-spotlight {
  position: fixed;
  z-index: 10001;
  border-radius: var(--radius-md);
  box-shadow:
    0 0 0 9999px rgba(15, 23, 42, 0.58),
    0 0 0 2px rgba(99, 102, 241, 0.9),
    0 10px 36px rgba(15, 23, 42, 0.18);
  transition:
    top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* --- Tour Tooltip (Nuvoletta) --- */

.tour-tooltip {
  position: fixed;
  z-index: 10002;
  width: min(340px, calc(100vw - 24px));
  max-width: 340px;
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow:
    0 24px 64px rgba(15, 23, 42, 0.2),
    0 4px 14px rgba(15, 23, 42, 0.08);
  color: #172033;
  font-size: 13px;
  line-height: 1.48;
  pointer-events: auto;
  animation: tourTooltipIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes tourTooltipIn {
  from {
    opacity: 0;
    transform: scale(0.82) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.tour-tooltip__step-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #4f46e5;
  margin-bottom: 6px;
}

.tour-tooltip__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.3;
}

.tour-tooltip__body {
  margin: 0 0 14px;
  opacity: 0.92;
  color: #536176;
}

/* --- Tooltip Arrow --- */

.tour-tooltip__arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.97);
  transform: rotate(45deg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: -1;
}

.tour-tooltip--above .tour-tooltip__arrow {
  bottom: -7px;
  left: 50%;
  margin-left: -7px;
  border-top: none;
  border-left: none;
}

.tour-tooltip--below .tour-tooltip__arrow {
  top: -7px;
  left: 50%;
  margin-left: -7px;
  border-bottom: none;
  border-right: none;
}

.tour-tooltip--left .tour-tooltip__arrow {
  right: -7px;
  top: 50%;
  margin-top: -7px;
  border-bottom: none;
  border-left: none;
}

/* --- Tooltip Actions --- */

.tour-tooltip__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-tooltip__btn {
  flex: 1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tour-tooltip__btn--next {
  background: #4f46e5;
  color: #fff;
  border: 1px solid #4f46e5;
}

.tour-tooltip__btn--next:hover {
  background: #4338ca;
}

.tour-tooltip__btn--prev {
  background: transparent;
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.tour-tooltip__btn--prev:hover {
  color: #334155;
  background: #f1f5f9;
}

.tour-tooltip__btn--skip {
  flex: 0;
  padding: 8px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.tour-tooltip__btn--skip:hover {
  color: #334155;
}

.tour-tooltip__btn--finish {
  background: #4f46e5;
  color: #fff;
}

.tour-tooltip__btn--finish:hover {
  background: #4338ca;
  transform: translateY(-1px);
}

.tour-tooltip__btn .material-symbols-outlined {
  font-size: 18px;
}

/* --- Progress dots --- */

.tour-tooltip__progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.tour-tooltip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dbe1ea;
  transition: all 0.3s ease;
}

.tour-tooltip__dot--active {
  background: #4f46e5;
  transform: scale(1.3);
}

.tour-tooltip__dot--done {
  background: #a5b4fc;
}

/* --- Contribute Nudge (floating bubble) --- */

.guided-tour-contrib-target {
  display: flow-root;
}

.contribute-nudge {
  position: fixed;
  top: 150px;
  left: 24px;
  z-index: 9005; /* Above the dark overlay */
  width: min(286px, calc(100vw - 32px));
  max-width: 286px;
  box-sizing: border-box;
  padding: 12px 14px;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.98),
      rgba(248, 250, 252, 0.96)
    ),
    #fff;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  box-shadow:
    0 26px 60px rgba(15, 23, 42, 0.22),
    0 10px 22px rgba(79, 70, 229, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  color: #172033;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  isolation: isolate;
  animation: nudgeSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.contribute-nudge--avatar-anchored {
  position: absolute;
  z-index: 10020;
}

.contribute-nudge:hover {
  transform: translateY(-2px);
  box-shadow:
    0 30px 70px rgba(15, 23, 42, 0.25),
    0 12px 26px rgba(79, 70, 229, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.contribute-nudge:focus-visible {
  outline: 3px solid rgba(251, 191, 36, 0.5);
  outline-offset: 3px;
}

.contribute-nudge::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.98),
    rgba(248, 250, 252, 0.96)
  );
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: -5px 5px 10px rgba(15, 23, 42, 0.08);
  transform: rotate(45deg);
  z-index: -1;
}

.contribute-nudge::after {
  content: none;
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(251, 191, 36, 0.45);
  box-shadow: 0 0 0 8px rgba(251, 191, 36, 0.11);
  opacity: 0.95;
  pointer-events: none;
}

.contribute-nudge--from-avatar-right::before {
  left: -9px;
  top: calc(var(--nudge-tail-offset, 50%) - 12px);
  border-top: none;
  border-right: none;
}

.contribute-nudge--from-avatar-right::after {
  left: -70px;
  top: 23px;
}

.contribute-nudge--from-avatar-left::before {
  right: -9px;
  top: calc(var(--nudge-tail-offset, 50%) - 12px);
  border-bottom: none;
  border-left: none;
  box-shadow: 5px -5px 10px rgba(15, 23, 42, 0.08);
}

.contribute-nudge--from-avatar-left::after {
  right: -70px;
  top: 23px;
}

.contribute-nudge--from-avatar-below::before {
  left: var(--nudge-tail-offset, 50%);
  top: -9px;
  margin-left: -12px;
  border-bottom: none;
  border-right: none;
  box-shadow: -5px -5px 10px rgba(15, 23, 42, 0.06);
}

.contribute-nudge--from-avatar-below::after {
  left: 50%;
  top: -78px;
  margin-left: -26px;
}

@keyframes nudgeSlideIn {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.contribute-nudge--leaving {
  animation: nudgeFadeOut 0.35s ease forwards;
}

@keyframes nudgeFadeOut {
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
}

.contribute-nudge__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  color: #7c5600;
  background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
  box-shadow: 0 8px 16px rgba(217, 119, 6, 0.22);
}

.contribute-nudge__text {
  font-size: 12px;
  line-height: 1.42;
  flex: 1;
  color: #475569;
}

.contribute-nudge__text strong {
  display: block;
  font-size: 12.5px;
  line-height: 1.2;
  color: #111827;
  margin-bottom: 4px;
}

.contribute-nudge__close {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: rgba(100, 116, 139, 0.72);
  cursor: pointer;
  padding: 3px;
  line-height: 1;
  font-size: 16px;
  transition: color 0.2s;
}

.contribute-nudge__close:hover {
  color: #0f172a;
}

.contribute-nudge__close .material-symbols-outlined {
  font-size: 16px;
}

/* Pointing state when attached to the contribute form */
.contribute-nudge--pointing {
  animation: none !important;
  transition: all 0.3s ease;
  transform: translateY(0) !important;
}

.contribute-nudge--pointing::before {
  content: none;
}

.contribute-nudge--pointing::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 14px;
  height: 14px;
  background: inherit;
  transform: rotate(45deg);
  z-index: -1;
  border-radius: 0;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-top: none;
  border-left: none;
  box-shadow: none;
  opacity: 1;
}

/* --- Help Tour Button Tooltip --- */

#help-tour-btn {
  position: relative;
  overflow: visible;
}

#help-tour-btn::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(251, 191, 36, 0.86);
  box-shadow:
    0 0 0 0 rgba(251, 191, 36, 0.36),
    0 0 18px rgba(251, 191, 36, 0.24);
  pointer-events: none;
  animation: helpButtonPulse 2.2s ease-in-out infinite;
}

#help-tour-btn .help-tooltip-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: rgba(17, 24, 39, 0.88);
  color: rgba(255, 255, 255, 0.85);
  padding: 5px 8px;
  border-radius: 7px;
  border: none;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.86;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  animation: floatTooltipSide 2.5s ease-in-out infinite;
  letter-spacing: 0.2px;
  font-family: inherit;
  z-index: 9010;
}

.help-tooltip-label::before {
  display: none;
}

.help-tooltip-label::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -5px;
  transform: translateY(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent rgba(17, 24, 39, 0.95) transparent transparent;
  pointer-events: none;
}

@keyframes helpButtonPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 0 rgba(251, 191, 36, 0.34),
      0 0 18px rgba(251, 191, 36, 0.24);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(251, 191, 36, 0),
      0 0 22px rgba(251, 191, 36, 0.34);
  }
}

@keyframes floatTooltipSide {
  0%,
  100% {
    transform: translate(0, -50%);
  }
  50% {
    transform: translate(4px, -50%);
  }
}

/* Premium contribution invitation and guided flow */
.contribute-nudge {
  display: block;
  width: min(350px, calc(100vw - 28px));
  max-width: 350px;
  padding: 18px;
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 24px;
  background:
    radial-gradient(
      circle at 100% 0%,
      rgba(250, 204, 21, 0.2),
      transparent 34%
    ),
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.99),
      rgba(246, 252, 248, 0.98)
    );
  box-shadow:
    0 30px 80px rgba(15, 23, 42, 0.28),
    0 10px 30px rgba(22, 101, 52, 0.17),
    inset 0 1px 0 #fff;
}

.contribute-nudge__topline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 22px;
  color: #a16207;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.105em;
}

.contribute-nudge__spark {
  color: #d6a514;
  font-size: 17px;
}

.contribute-nudge__main {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 13px;
}

.contribute-nudge .contribute-nudge__icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #238a52, #14532d);
  box-shadow: 0 10px 24px rgba(22, 101, 52, 0.27);
  font-size: 24px;
}

.contribute-nudge .contribute-nudge__text {
  font-size: 0.78rem;
  line-height: 1.42;
}

.contribute-nudge .contribute-nudge__text strong {
  margin-bottom: 3px;
  color: #12271c;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.16rem;
}

.contribute-nudge__text > span {
  color: #5d6f65;
}

.contribute-nudge__reward {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 7px;
  margin-top: 15px;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 13px;
  color: #854d0e;
  background: linear-gradient(90deg, #fffbeb, #fefce8);
  font-size: 0.72rem;
}

.contribute-nudge__reward .material-symbols-outlined {
  color: #d6a514;
  font-size: 19px;
}

.contribute-nudge__reward strong {
  color: #166534;
}

.contribute-nudge__cta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  margin-top: 11px;
  color: #166534;
  font-size: 0.71rem;
  font-weight: 850;
}

.contribute-nudge__cta .material-symbols-outlined {
  font-size: 17px;
  transition: transform 180ms ease;
}

.contribute-nudge:hover .contribute-nudge__cta .material-symbols-outlined {
  transform: translateX(3px);
}

.tour-tooltip {
  width: min(350px, calc(100vw - 20px));
  max-width: 350px;
  padding: 21px;
  border: 1px solid rgba(250, 204, 21, 0.32);
  border-radius: 22px;
  background:
    radial-gradient(
      circle at 100% 0%,
      rgba(250, 204, 21, 0.14),
      transparent 34%
    ),
    rgba(255, 255, 255, 0.985);
  box-shadow:
    0 26px 70px rgba(15, 23, 42, 0.27),
    0 8px 22px rgba(22, 101, 52, 0.12);
}

.tour-tooltip__step-badge {
  color: #166534;
  background: #e8f5ed;
  border: 1px solid #c9e8d5;
}

.tour-tooltip__title {
  color: #12271c;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.22rem;
}

.tour-tooltip__body {
  color: #5f6f66;
  line-height: 1.55;
}
.tour-tooltip__dot--active {
  background: #166534;
  box-shadow: 0 0 0 4px rgba(22, 101, 52, 0.12);
}
.tour-tooltip__dot--done {
  background: #d6a514;
}
.tour-tooltip__btn--next,
.tour-tooltip__btn--finish {
  background: linear-gradient(135deg, #1d7a46, #14532d);
  box-shadow: 0 7px 18px rgba(22, 101, 52, 0.2);
}

@media (max-width: 600px) {
  .contribute-nudge {
    width: min(300px, calc(100vw - 32px));
    max-width: 300px;
    padding: 14px;
  }
  .contribute-nudge__topline {
    font-size: 0.56rem;
  }
  .contribute-nudge .contribute-nudge__text strong {
    font-size: 1.03rem;
  }
  .tour-tooltip {
    width: calc(100vw - 16px);
    max-width: none;
    padding: 17px;
  }
}

/* --- Dark overlay for Nudge --- */

.nudge-dark-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(
    circle at var(--nudge-focus-x, 36%) var(--nudge-focus-y, 24%),
    rgba(15, 23, 42, 0.24),
    rgba(15, 23, 42, 0.62) 42%,
    rgba(15, 23, 42, 0.7) 100%
  );
  z-index: 9001; /* Above profile content, below nudge */
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none; /* Let clicks pass through */
}

/* --- Scroll highlight pulse on contribute section --- */

.tour-highlight-pulse {
  animation: highlightPulse 1.5s ease-out;
}

@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.5);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(79, 70, 229, 0.15);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
  }
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .tour-tooltip {
    width: calc(100vw - 24px);
    max-width: 320px;
    min-width: 200px;
    font-size: 12px;
    padding: 13px;
    line-height: 1.45;
  }

  .tour-tooltip__title {
    font-size: 13.5px;
    margin-bottom: 4px;
  }

  .tour-tooltip__body {
    font-size: 12px;
    margin-bottom: 10px;
  }

  .tour-tooltip__step-badge {
    font-size: 10px;
    margin-bottom: 4px;
  }

  .tour-tooltip__progress {
    gap: 5px;
    margin-bottom: 8px;
  }

  .tour-tooltip__dot {
    width: 6px;
    height: 6px;
  }

  .tour-tooltip__actions {
    gap: 6px;
  }

  .tour-tooltip__btn {
    padding: 6px 10px;
    font-size: 11.5px;
  }

  .contribute-nudge {
    width: min(300px, calc(100vw - 32px));
    max-width: 300px;
    padding: 14px;
  }

  .contribute-nudge__icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .contribute-nudge__text {
    font-size: 11px;
    line-height: 1.35;
  }

  .contribute-nudge__text strong {
    font-size: 11.5px;
    margin-bottom: 2px;
  }

  @keyframes nudgeSlideIn {
    from {
      opacity: 0;
      transform: translateY(30px) scale(0.92);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .contribute-nudge:hover {
    transform: translateY(-2px);
  }

  .contribute-nudge--leaving {
    animation: nudgeFadeOutMobile 0.35s ease forwards;
  }

  @keyframes nudgeFadeOutMobile {
    to {
      opacity: 0;
      transform: translateX(-50%) translateY(20px) scale(0.92);
    }
  }

  .contribute-nudge--pointing {
    left: auto !important;
    transform: none;
  }

  .contribute-nudge--pointing:hover {
    transform: translateY(-2px);
  }

  #help-tour-btn .help-tooltip-label {
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
    white-space: nowrap;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 6px;
    gap: 0;
    max-width: none;
    background: rgba(17, 24, 39, 0.88);
    color: rgba(255, 255, 255, 0.85);
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  }

  .help-tooltip-label::before {
    display: none;
  }

  .help-tooltip-label::after {
    display: none;
  }

  @keyframes floatTooltipSide {
    0%,
    100% {
      transform: translate(0, -50%);
    }
    50% {
      transform: translate(3px, -50%);
    }
  }

  #help-tour-btn::after {
    inset: -3px;
    border-width: 1.5px;
  }
}

@media (max-width: 768px) {
  .contribute-nudge {
    width: min(300px, calc(100vw - 32px));
    max-width: 300px;
    padding: 14px;
  }

  .contribute-nudge .contribute-nudge__icon {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }

  .contribute-nudge .contribute-nudge__text {
    font-size: 0.74rem;
  }
  .contribute-nudge .contribute-nudge__text strong {
    font-size: 1.02rem;
  }
  .tour-tooltip {
    width: calc(100vw - 16px);
    max-width: 350px;
    padding: 17px;
  }
  .tour-tooltip__title {
    font-size: 1.06rem;
  }
  .tour-tooltip__body {
    font-size: 0.76rem;
  }
}
