/* ==========================================================================
   TabGuide — Spotlight Tour Engine
   Design language: Neobrutalist
   Palette: --ink #0d0d0d, --paper #f5f0e8, --cream #fffdf7,
            --yellow #fef9c3, --muted #78716c, --stone #e7e0d3
   ========================================================================== */

:root {
  --ink: #0d0d0d;
  --paper: #f5f0e8;
  --cream: #fffdf7;
  --yellow: #fef9c3;
  --muted: #78716c;
  --stone: #e7e0d3;
  --success: #16a34a;
  --error: #dc2626;
}

/* --------------------------------------------------------------------------
   1. Overlay Backdrop
   -------------------------------------------------------------------------- */
.tg-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.tg-overlay svg {
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------------------------
   2. SVG Spotlight Mask
   -------------------------------------------------------------------------- */
.tg-mask-fill {
  fill: rgba(0, 0, 0, 0.55);
}

.tg-mask-hole {
  fill: black;
  rx: 0;
  ry: 0;
}

/* --------------------------------------------------------------------------
   3. Tooltip Card
   -------------------------------------------------------------------------- */
.tg-tooltip {
  position: fixed;
  z-index: 10001;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--cream);
  border-radius: 0;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 20px;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  pointer-events: auto;
}

.tg-tooltip.tg-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   4. Tooltip Arrow (::before)
   -------------------------------------------------------------------------- */
.tg-tooltip::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--cream);
  transform: rotate(45deg);
  border: 2px solid var(--ink);
}

/* Arrow on top — tooltip sits below the target */
.tg-tooltip[data-pos="top"]::before {
  top: -7px;
  left: 50%;
  margin-left: -6px;
  border-bottom: none;
  border-right: none;
}

/* Arrow on bottom — tooltip sits above the target */
.tg-tooltip[data-pos="bottom"]::before {
  bottom: -7px;
  left: 50%;
  margin-left: -6px;
  border-top: none;
  border-left: none;
}

/* Arrow on left — tooltip sits to the right of the target */
.tg-tooltip[data-pos="left"]::before {
  left: -7px;
  top: 50%;
  margin-top: -6px;
  border-top: none;
  border-right: none;
}

/* Arrow on right — tooltip sits to the left of the target */
.tg-tooltip[data-pos="right"]::before {
  right: -7px;
  top: 50%;
  margin-top: -6px;
  border-bottom: none;
  border-left: none;
}

/* --------------------------------------------------------------------------
   5. Step Badge
   -------------------------------------------------------------------------- */
.tg-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 0;
  border: 2px solid var(--ink);
  margin-bottom: 10px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   6. Title
   -------------------------------------------------------------------------- */
.tg-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 6px;
  line-height: 1.35;
}

/* --------------------------------------------------------------------------
   7. Description
   -------------------------------------------------------------------------- */
.tg-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 16px;
}

/* --------------------------------------------------------------------------
   8. Footer & Buttons
   -------------------------------------------------------------------------- */
.tg-footer {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Base button */
.tg-btn {
  border: 2px solid var(--ink);
  outline: none;
  border-radius: 0;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 16px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
  line-height: 1;
  font-family: inherit;
}

.tg-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* Skip button */
.tg-btn-skip {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.tg-btn-skip:hover {
  color: var(--ink);
  background: var(--stone);
  border-color: var(--ink);
}

/* Previous button */
.tg-btn-prev {
  background: var(--cream);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.tg-btn-prev:hover {
  background: var(--stone);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

/* Next / primary button */
.tg-btn-next {
  background: var(--ink);
  color: var(--yellow);
  box-shadow: 3px 3px 0 var(--muted);
}

.tg-btn-next:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--muted);
}

/* --------------------------------------------------------------------------
   9. Progress Dots
   -------------------------------------------------------------------------- */
.tg-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 14px;
}

.tg-dot {
  width: 6px;
  height: 6px;
  border-radius: 0;
  border: 2px solid var(--ink);
  background: var(--stone);
  transition:
    width 0.3s ease,
    background 0.3s ease;
}

.tg-dot.tg-active {
  width: 16px;
  border-radius: 0;
  background: var(--yellow);
}

.tg-dot.tg-done {
  background: var(--ink);
}

/* --------------------------------------------------------------------------
   10. Welcome Stage — Full-screen editorial takeover
   -------------------------------------------------------------------------- */
.tg-welcome {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  text-align: left;
  overflow: hidden;
  opacity: 0;
  pointer-events: auto;
  transform: scale(1.04);
  transition: opacity 320ms ease, transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tg-welcome.tg-visible {
  opacity: 1;
  transform: scale(1);
}

/* Quando NON è la welcome attiva, lo strato full-screen (z-index 10002, opacity 0)
   deve essere trasparente ai click: altrimenti copre il tooltip spotlight (z 10001)
   e ne mangia i bottoni Avanti/Salta sugli step targettizzati. */
.tg-welcome:not(.tg-visible) {
  pointer-events: none;
}

/* Drifting multi-radial gradient backdrop for a "morning light" feel */
.tg-welcome::before {
  content: "";
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(circle at 22% 28%, rgba(254, 249, 195, 0.85) 0%, transparent 38%),
    radial-gradient(circle at 78% 72%, rgba(219, 234, 254, 0.6) 0%, transparent 40%),
    radial-gradient(circle at 50% 92%, rgba(254, 215, 170, 0.45) 0%, transparent 36%);
  animation: tg-bg-drift 22s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes tg-bg-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(2%, -2%) scale(1.04); }
  100% { transform: translate(-2%, 1.5%) scale(1.06); }
}

/* Decorative neo-brutalist corners */
.tg-fs-corner {
  position: absolute;
  width: 110px;
  height: 110px;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
}

.tg-fs-corner svg { width: 100%; height: 100%; display: block; color: var(--ink); }

.tg-fs-corner-tl { top: 28px;    left: 28px;    transform: rotate(-8deg); }
.tg-fs-corner-tr { top: 28px;    right: 28px;   transform: rotate(8deg); }
.tg-fs-corner-bl { bottom: 28px; left: 28px;    transform: rotate(8deg); }
.tg-fs-corner-br { bottom: 28px; right: 28px;   transform: rotate(-8deg); }

.tg-welcome.tg-visible .tg-fs-corner-tl { animation: tg-corner-in 700ms cubic-bezier(0.16, 1, 0.3, 1) 100ms forwards; }
.tg-welcome.tg-visible .tg-fs-corner-tr { animation: tg-corner-in 700ms cubic-bezier(0.16, 1, 0.3, 1) 180ms forwards; }
.tg-welcome.tg-visible .tg-fs-corner-bl { animation: tg-corner-in 700ms cubic-bezier(0.16, 1, 0.3, 1) 260ms forwards; }
.tg-welcome.tg-visible .tg-fs-corner-br { animation: tg-corner-in 700ms cubic-bezier(0.16, 1, 0.3, 1) 340ms forwards; }

@keyframes tg-corner-in {
  0%   { opacity: 0; transform: var(--tg-base-rot, rotate(0)) translate(8px, 8px); }
  100% { opacity: 0.18; }
}

/* Top bar */
.tg-welcome .tg-fs-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 26px 40px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.tg-welcome .tg-fs-top .tg-step-badge {
  margin-bottom: 0;
  font-size: 11px;
  padding: 5px 10px;
}

.tg-welcome .tg-fs-top .tg-btn-skip {
  font-size: 12px;
  padding: 8px 16px;
  border: 2px solid rgba(13, 13, 13, 0.2);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(6px);
}

.tg-welcome .tg-fs-top .tg-btn-skip:hover {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}

/* Center stage */
.tg-welcome .tg-fs-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0 max(48px, 8vw);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 2;
}

/* Big icon plate */
.tg-welcome .tg-welcome-icon {
  width: 96px;
  height: 96px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 32px;
  font-size: 44px;
  box-shadow: 6px 6px 0 var(--ink);
  opacity: 0;
  transform: rotate(-14deg) scale(0.6);
}

.tg-welcome.tg-visible .tg-welcome-icon {
  animation: tg-icon-pop 700ms cubic-bezier(0.34, 1.56, 0.64, 1) 200ms forwards;
}

@keyframes tg-icon-pop {
  0%   { opacity: 0; transform: rotate(-14deg) scale(0.6); }
  60%  { opacity: 1; transform: rotate(6deg) scale(1.1); }
  100% { opacity: 1; transform: rotate(-3deg) scale(1); }
}

/* Editorial display title — stages overrides over the base .tg-title */
.tg-welcome .tg-title {
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 28px;
  color: var(--ink);
  max-width: 18ch;
}

.tg-welcome .tg-title .tg-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(40px);
  will-change: transform, opacity;
}

.tg-welcome.tg-visible .tg-title .tg-word {
  animation: tg-word-in 600ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tg-word-in {
  to { opacity: 1; transform: translateY(0); }
}

/* Description */
.tg-welcome .tg-desc {
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.55;
  color: rgba(13, 13, 13, 0.7);
  font-weight: 500;
  max-width: 60ch;
  margin: 0;
  opacity: 0;
  transform: translateY(20px);
  white-space: pre-line;
}

.tg-welcome.tg-visible .tg-desc {
  animation: tg-fade-up 600ms cubic-bezier(0.16, 1, 0.3, 1) 700ms forwards;
}

@keyframes tg-fade-up {
  to { opacity: 1; transform: translateY(0); }
}

/* Bottom strip */
.tg-welcome .tg-fs-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px max(48px, 8vw) 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(20px);
}

.tg-welcome.tg-visible .tg-fs-bottom {
  animation: tg-fade-up 500ms cubic-bezier(0.16, 1, 0.3, 1) 900ms forwards;
}

.tg-welcome .tg-fs-bottom .tg-dots {
  margin-top: 0;
  flex: 1;
  justify-content: center;
}

.tg-welcome .tg-fs-bottom .tg-dot {
  width: 8px;
  height: 8px;
}

.tg-welcome .tg-fs-bottom .tg-dot.tg-active {
  width: 28px;
}

.tg-welcome .tg-fs-bottom .tg-btn {
  font-size: 14px;
  padding: 12px 24px;
  min-width: 140px;
  text-align: center;
}

.tg-welcome .tg-fs-bottom .tg-btn-prev {
  background: transparent;
  border-color: rgba(13, 13, 13, 0.25);
  color: rgba(13, 13, 13, 0.7);
  box-shadow: none;
}

.tg-welcome .tg-fs-bottom .tg-btn-prev:hover {
  background: rgba(13, 13, 13, 0.06);
  border-color: var(--ink);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.tg-welcome .tg-fs-bottom .tg-spacer {
  display: inline-block;
  min-width: 140px;
}

/* Keyboard hints */
.tg-welcome .tg-keyhints {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(13, 13, 13, 0.45);
  z-index: 3;
  opacity: 0;
}

.tg-welcome.tg-visible .tg-keyhints {
  animation: tg-fade-up 500ms ease 1100ms forwards;
}

.tg-welcome .tg-keyhints span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tg-welcome .tg-key {
  border: 1px solid rgba(13, 13, 13, 0.3);
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.55);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0;
  text-transform: none;
  font-size: 10px;
}

/* Help Trigger Button — removed */

/* --------------------------------------------------------------------------
   12. Mobile Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .tg-tooltip {
    width: 290px;
    padding: 16px;
  }

  .tg-title {
    font-size: 14px;
  }

  .tg-desc {
    font-size: 12px;
  }

  .tg-welcome .tg-welcome-icon {
    width: 72px;
    height: 72px;
    font-size: 32px;
    margin-bottom: 22px;
    box-shadow: 4px 4px 0 var(--ink);
  }

  .tg-welcome .tg-title {
    font-size: clamp(2rem, 9vw, 3.25rem);
    margin-bottom: 20px;
  }

  .tg-welcome .tg-desc {
    font-size: 0.95rem;
  }

  .tg-welcome .tg-fs-top {
    padding: 18px 22px;
  }

  .tg-welcome .tg-fs-bottom {
    padding: 18px 22px 26px;
    flex-wrap: wrap;
  }

  .tg-welcome .tg-fs-bottom .tg-btn {
    font-size: 13px;
    padding: 10px 18px;
    min-width: 110px;
  }

  .tg-welcome .tg-fs-bottom .tg-spacer {
    min-width: 110px;
  }

  .tg-welcome .tg-fs-main {
    padding: 0 22px;
  }

  .tg-fs-corner {
    width: 70px;
    height: 70px;
  }

  .tg-fs-corner-tl, .tg-fs-corner-tr { top: 16px; }
  .tg-fs-corner-bl, .tg-fs-corner-br { bottom: 16px; }
  .tg-fs-corner-tl, .tg-fs-corner-bl { left: 16px; }
  .tg-fs-corner-tr, .tg-fs-corner-br { right: 16px; }

  .tg-welcome .tg-keyhints {
    display: none;
  }

  .tg-welcome .tg-fs-top .tg-step-badge {
    font-size: 10px;
    padding: 4px 8px;
  }
}
