/* Team Building Activities Widget - Auto-scroll with popup cards */

:root {
  /* Layer tokens keep header/footer on top while letting the widget sit above content */
  --vu-tb-layer-header: var(--vu-layer-header, 1000);
  --vu-tb-layer-footer: var(--vu-layer-footer, 1000);
  --vu-tb-layer-overlay: 300;
  --vu-tb-layer-card: 360;
  --vu-tb-layer-widget: 340;
}

/* Sidebar context: lift the widget above center content without beating header/footer */
aside:has(.vu-tb-widget),
.widget-area:has(.vu-tb-widget) {
  position: relative;
  z-index: var(--vu-tb-layer-widget);
}

/* === Widget Container (Glass Effect) === */
.vu-tb-widget {
  --tb-surface: var(--grad-surface-1, linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(245, 248, 255, 0.9)));
  --tb-text: var(--vu-ink, #1f2c57);
  --tb-outline: rgba(12, 24, 48, 0.12);
  --tb-shadow: var(--vu-shadow-soft, 0 16px 28px rgba(5, 7, 19, 0.12));
  --tb-radius: 18px;
  --tb-pad: clamp(7px, 1.5vw, 9px);
  --tb-gold: var(--vu-gold, #ffd900);

  /* Card popup width */
  --card-w: clamp(280px, 35cqi, 400px);
  --card-offset: 12px;

  position: relative;
  z-index: var(--vu-tb-layer-widget);
  /* Higher than center column but under header/footer */
  padding: var(--tb-pad);
  background: transparent;
  color: var(--tb-text);
  overflow: visible;
}

/* Spotlight Mode: When card is open, lift entire widget above Header (1M) */
.vu-tb-widget.is-focused {
  z-index: calc(var(--vu-tb-layer-widget) + 20);
}

/* Outer glow layer */
.vu-tb-widget::before {
  content: "";
  position: absolute;
  inset: -6px;
  z-index: -2;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.1));
  border-radius: 22px;
  pointer-events: none;
}

/* Inner surface layer */
.vu-tb-widget::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: -1;
  background: var(--tb-surface);
  border: 1px solid var(--tb-outline);
  border-radius: var(--tb-radius);
  box-shadow: var(--tb-shadow);
  pointer-events: none;
}

/* === Title === */
.vu-tb-header {
  margin-bottom: 12px;
}

.vu-tb-title {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  line-height: 1.1;
}

.vu-tb-line1 {
  font-size: clamp(14px, 2vw, 16px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tb-text);
  opacity: 0.7;
}

.vu-tb-line2 {
  font-size: clamp(22px, 3.2vw, 28px);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--tb-text);
}

/* === Scroll Container === */
.vu-tb-scroll-wrap {
  position: relative;
  z-index: 1;
  /* Above backdrop so it remains clickable */
  max-height: 480px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: auto;
  scrollbar-color: var(--tb-gold, #ffd900) rgba(255, 217, 0, 0.15);
  /* Balance scrollbar width for visual centering */
  padding-left: 5px;
}

.vu-tb-scroll-wrap::-webkit-scrollbar {
  width: 10px;
}

.vu-tb-scroll-wrap::-webkit-scrollbar-track {
  background: rgba(255, 217, 0, 0.12);
  border-radius: 5px;
  margin: 4px 0;
}

.vu-tb-scroll-wrap::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #ffc600, #ffd900);
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.vu-tb-scroll-wrap::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #ffcc00, #ffe033);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* === Activity List === */
.vu-tb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* === Activity Item === */
.vu-tb-item {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.vu-tb-item.is-exiting {
  opacity: 0;
  transform: translateY(-8px);
}

.vu-tb-item.is-entering {
  animation: tbSlideIn 0.4s ease forwards;
}

@keyframes tbSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Trigger Button === */
.vu-tb-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  min-height: 48px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(12, 24, 48, 0.08);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--tb-text);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.vu-tb-trigger:hover,
.vu-tb-trigger:focus-visible {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 217, 0, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateX(4px);
}

.vu-tb-trigger.is-highlighting {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 217, 0, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.vu-tb-trigger:focus-visible {
  outline: 2px solid var(--tb-gold);
  outline-offset: 2px;
}

.vu-tb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Progress Bar (Auto-scroll timer) === */
.vu-tb-progress {
  position: relative;
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.vu-tb-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(135deg, #ffc600, #ffd900);
  border-radius: inherit;
  transition: width 120ms linear;
}

/* Removed .is-expanded state - no longer using expand button */

/* === Expand Button (Hidden - scrollbar indicates scroll) === */
.vu-tb-expand {
  display: none;
}

/* === Backdrop Overlay === */
body.vu-tb-locked {
  overflow: hidden;
}

/* Overlay shell appended to <body> so it escapes sidebar stacking contexts */
.vu-tb-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--vu-tb-layer-overlay);
  display: block;
  pointer-events: none;
}

/* === Backdrop Overlay === */
.vu-tb-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--vu-tb-layer-overlay);
  background: rgba(15, 24, 52, 0.25);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: auto;
}

.vu-tb-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

.vu-tb-backdrop[hidden] {
  display: none;
}

/* === Popup Card === */
/* Container context for intrinsic responsive design */
.vu-tb-card {
  /* Design tokens */
  --card-bg: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(248, 250, 255, 0.95) 50%,
    rgba(240, 245, 255, 0.92) 100%
  );
  --card-border: rgba(255, 255, 255, 0.6);
  --card-shadow:
    0 4px 6px rgba(0, 0, 0, 0.02),
    0 12px 24px rgba(15, 25, 50, 0.08),
    0 32px 64px rgba(15, 25, 50, 0.12),
    0 64px 120px rgba(15, 25, 50, 0.16);
  --card-radius: 28px;
  --card-padding: clamp(20px, 4cqi, 32px);
  --card-gap: clamp(16px, 3cqi, 28px);

  /* Animation timing */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-enter: 0.7s;
  --duration-exit: 0.45s;

  /* Container query context */
  container-type: inline-size;
  container-name: tb-card;

  position: absolute;
  z-index: var(--vu-tb-layer-card);
  top: 0;
  left: 0;

  /* Larger default size */
  width: min(720px, 85vw);
  min-height: 240px;
  max-height: min(480px, 80vh);

  display: grid;
  grid-template-columns: minmax(260px, 0.48fr) minmax(0, 1fr);
  gap: var(--card-gap);
  padding: var(--card-padding);

  background: var(--card-bg);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  border: 1.5px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);

  /* Initial hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px) scale(0.92);
  transform-origin: left center;

  /* Exit transition */
  transition:
    opacity var(--duration-exit) ease-in,
    transform var(--duration-exit) ease-in,
    visibility var(--duration-exit);

  overflow: hidden;
}

/* Entrance animation */
.vu-tb-card.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0) scale(1);

  transition:
    opacity var(--duration-enter) var(--ease-out-expo),
    transform var(--duration-enter) var(--ease-spring),
    visibility 0s;
}

/* Staggered children entrance */
.vu-tb-card.is-visible .vu-tb-card-figure {
  animation: cardFigureIn var(--duration-enter) var(--ease-out-expo) forwards;
}

.vu-tb-card.is-visible .vu-tb-card-body {
  animation: cardBodyIn var(--duration-enter) var(--ease-out-expo) 0.05s forwards;
}

.vu-tb-card.is-visible .vu-tb-card-title {
  animation: cardContentIn 0.35s var(--ease-out-expo) 0.08s both;
}

.vu-tb-card.is-visible .vu-tb-card-excerpt {
  animation: cardContentIn 0.35s var(--ease-out-expo) 0.12s both;
}

.vu-tb-card.is-visible .vu-tb-card-link {
  animation: cardLinkIn 0.4s var(--ease-spring) 0.18s both;
}

@keyframes cardFigureIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateX(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

@keyframes cardBodyIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes cardLinkIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Quick swap between items */
.vu-tb-card.is-switching {
  transition: opacity 0.12s ease, transform 0.12s ease;
  opacity: 0.85;
  transform: translateX(0) scale(0.98);
}

.vu-tb-card[hidden] {
  display: none;
}

/* === Card Close Button === */
.vu-tb-card-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ffd000, #ffdc00);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  color: #1a1f35;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 6px 16px rgba(255, 190, 79, 0.35);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease;
}

.vu-tb-card-close:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(255, 190, 79, 0.45);
}

.vu-tb-card-close:focus-visible {
  outline: 2px solid var(--tb-gold);
  outline-offset: 3px;
}

/* === Card Figure === */
.vu-tb-card-figure {
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(15, 24, 52, 0.06), rgba(15, 24, 52, 0.12));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.3),
    0 8px 24px rgba(5, 7, 19, 0.12),
    0 24px 48px rgba(5, 7, 19, 0.08);
}

.vu-tb-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease-out-expo);
}

.vu-tb-card:hover .vu-tb-card-image {
  transform: scale(1.03);
}

/* === Card Body === */
.vu-tb-card-body {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2cqi, 18px);
  padding: 8px 4px 4px 0;
  min-width: 0; /* Prevent flex overflow */
}

.vu-tb-card-title {
  margin: 0;
  font-size: clamp(1.5rem, 5cqi, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--tb-text, #1f2c57);
  text-wrap: balance;
}

.vu-tb-card-excerpt {
  margin: 0;
  font-size: clamp(0.95rem, 3cqi, 1.1rem);
  line-height: 1.65;
  color: rgba(31, 44, 87, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}

.vu-tb-card-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: auto;
  padding: 1rem 1.75rem;
  background: linear-gradient(145deg, #ffd500, #ffe44d);
  color: #0f1834;
  text-decoration: none;
  border-radius: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: clamp(0.85rem, 2.5cqi, 0.95rem);
  align-self: flex-start;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 8px 20px rgba(255, 200, 0, 0.3);
  transition:
    transform 0.25s var(--ease-spring),
    box-shadow 0.25s ease,
    background 0.2s ease;
}

.vu-tb-card-link::after {
  content: "\2192"; /* Right arrow */
  font-size: 1.1em;
  transition: transform 0.25s var(--ease-spring);
}

.vu-tb-card-link:hover,
.vu-tb-card-link:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.06),
    0 12px 28px rgba(255, 190, 0, 0.4);
  background: linear-gradient(145deg, #ffe033, #fff066);
  outline: none;
}

.vu-tb-card-link:hover::after {
  transform: translateX(4px);
}

.vu-tb-card-link:active {
  transform: translateY(0);
}

/* === Container Query Breakpoints === */
/* Compact layout for narrow containers */
@container tb-card (max-width: 500px) {
  .vu-tb-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    max-height: min(600px, 85vh);
  }

  .vu-tb-card-figure {
    aspect-ratio: 16 / 9;
    max-height: 200px;
  }

  .vu-tb-card-body {
    padding: 4px 0 0;
  }

  .vu-tb-card-excerpt {
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  .vu-tb-card-link {
    align-self: stretch;
    justify-content: center;
  }
}

/* Medium layout tweaks */
@container tb-card (min-width: 501px) and (max-width: 650px) {
  .vu-tb-card {
    grid-template-columns: minmax(200px, 0.42fr) minmax(0, 1fr);
  }

  .vu-tb-card-excerpt {
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}

/* Large layout enhancements */
@container tb-card (min-width: 651px) {
  .vu-tb-card-body {
    justify-content: center;
  }

  .vu-tb-card-excerpt {
    -webkit-line-clamp: 5;
    line-clamp: 5;
  }
}

/* === Empty State === */
.vu-tb-empty {
  margin: 0;
  padding: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: rgba(31, 44, 87, 0.6);
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  .vu-tb-item,
  .vu-tb-trigger,
  .vu-tb-expand,
  .vu-tb-backdrop,
  .vu-tb-card,
  .vu-tb-card-figure,
  .vu-tb-card-body,
  .vu-tb-card-title,
  .vu-tb-card-excerpt,
  .vu-tb-card-link,
  .vu-tb-card-image,
  .vu-tb-card-close {
    transition: none !important;
    animation: none !important;
  }

  .vu-tb-card {
    --duration-enter: 0s;
    --duration-exit: 0s;
  }
}

/* === Mobile Adjustments === */
@media (max-width: 600px) {
  .vu-tb-trigger {
    padding: 10px 12px;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .vu-tb-expand {
    padding: 12px 16px;
  }

  /* On mobile, center the card as a modal */
  .vu-tb-card {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: min(92vw, 480px);
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
    padding: clamp(18px, 5vw, 24px);
    transform: translate(-50%, -50%) scale(0.92);
    transform-origin: center center;
    overflow-y: auto;
  }

  .vu-tb-card.is-visible {
    transform: translate(-50%, -50%) scale(1);
  }

  .vu-tb-card-close {
    position: sticky;
    top: 0;
    float: right;
    margin: -4px -4px 8px 8px;
  }
}
