/* ============================================
   Theme Journey Design System
   Progresso visual, cards premium e trilha
   de aprendizado para páginas de tema/lição
   ============================================ */

:root {
  --tj-glass-surface: rgba(255,255,255,0.65);
  --tj-glass-border: rgba(255,255,255,0.4);
  --tj-glass-shadow: 0 8px 32px rgba(0,0,0,0.08);
  --tj-glass-blur: saturate(160%) blur(14px);
  --tj-radius-sm: 10px;
  --tj-radius: 14px;
  --tj-radius-lg: 18px;
  --tj-radius-xl: 24px;
  --tj-transition: all 0.3s cubic-bezier(0.22,1,0.36,1);
}

[data-theme="dark"] {
  --tj-glass-surface: rgba(30,41,59,0.55);
  --tj-glass-border: rgba(255,255,255,0.08);
  --tj-glass-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes tj-fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tj-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--tj-accent-rgb), 0.35); }
  50%      { box-shadow: 0 0 0 8px rgba(var(--tj-accent-rgb), 0); }
}
@keyframes tj-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.tj-animate {
  opacity: 0;
  animation: tj-fadeInUp 0.5s cubic-bezier(0.22,1,0.36,1) forwards;
}
.tj-delay-1 { animation-delay: 0.05s; }
.tj-delay-2 { animation-delay: 0.1s; }
.tj-delay-3 { animation-delay: 0.15s; }
.tj-delay-4 { animation-delay: 0.2s; }
.tj-delay-5 { animation-delay: 0.25s; }

/* ============================================
   GLASSMORPHISM BASE
   ============================================ */
.tj-glass {
  background: var(--tj-glass-surface);
  backdrop-filter: var(--tj-glass-blur);
  -webkit-backdrop-filter: var(--tj-glass-blur);
  border: 1px solid var(--tj-glass-border);
  border-radius: var(--tj-radius-lg);
  box-shadow: var(--tj-glass-shadow);
}

/* ============================================
   THEME CARDS PREMIUM (level.ejs)
   ============================================ */
.themes-grid-premium {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.theme-card-premium {
  position: relative;
  background: #fff;
  border-radius: var(--tj-radius-lg);
  border: 1px solid #e2e8f0;
  padding: 1.5rem;
  transition: var(--tj-transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.theme-card-premium::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--level-color, #059669);
  opacity: 0.8;
  transition: height 0.25s ease;
}

.theme-card-premium:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.12);
  border-color: var(--level-color, #059669);
}

.theme-card-premium:hover::before {
  height: 5px;
}

.theme-card-premium.completed {
  border-color: var(--level-color, #059669);
  background: linear-gradient(180deg, rgba(var(--tj-accent-rgb), 0.03) 0%, #fff 40%);
}

.theme-card-premium.completed::before {
  height: 5px;
  opacity: 1;
}

/* Header do card */
.tj-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.375rem;
  padding-top: 0.25rem;
}

.tj-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  margin: 0;
}

.tj-card-subtitle {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.tj-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 1rem;
}

/* Badges no card */
.tj-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tj-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.tj-badge-success {
  background: #dcfce7;
  color: #166534;
}

.tj-badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.tj-badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.tj-badge-completed {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}

/* Progress bar de 4 etapas */
.tj-progress-track {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.tj-progress-segment {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  transition: background 0.4s ease, transform 0.3s ease;
  position: relative;
}

.tj-progress-segment.done {
  background: var(--level-color, #059669);
}

.tj-progress-segment.active {
  background: linear-gradient(90deg, var(--level-color, #059669), #86efac);
  background-size: 200% 100%;
  animation: tj-shimmer 2s infinite linear;
}

.tj-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* Actions do card */
.tj-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
}

.tj-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--tj-radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--tj-transition);
  flex: 1;
}

.tj-btn-primary {
  background: var(--level-color, #059669);
  color: #fff;
}

.tj-btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.tj-btn-secondary {
  background: #f1f5f9;
  color: #475569;
}

.tj-btn-secondary:hover {
  background: #e2e8f0;
}

.tj-btn-ghost {
  background: transparent;
  color: var(--level-color, #059669);
  border: 1.5px solid var(--level-color, #059669);
  padding: 0.5rem 1rem;
}

.tj-btn-ghost:hover {
  background: rgba(var(--tj-accent-rgb), 0.08);
}

/* ============================================
   JOURNEY TRACKER VERTICAL (content.ejs sidebar)
   ============================================ */
.journey-tracker {
  position: relative;
  padding-left: 1.75rem;
}

.journey-tracker::before {
  content: '';
  position: absolute;
  left: 0.6875rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: #e2e8f0;
  border-radius: 999px;
}

.journey-step {
  position: relative;
  padding-bottom: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}

.journey-step:last-child {
  padding-bottom: 0;
}

.journey-step-dot {
  position: absolute;
  left: -1.75rem;
  top: 0.125rem;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  z-index: 1;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #94a3b8;
  transition: var(--tj-transition);
}

.journey-step.completed .journey-step-dot {
  background: var(--level-color, #059669);
  border-color: var(--level-color, #059669);
  color: #fff;
}

.journey-step.active .journey-step-dot {
  background: #fff;
  border-color: var(--level-color, #059669);
  color: var(--level-color, #059669);
  animation: tj-pulse-glow 2s infinite;
}

.journey-step-body {
  flex: 1;
}

.journey-step-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.journey-step.completed .journey-step-title {
  color: var(--level-color, #059669);
}

.journey-step-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.4;
}

.journey-step-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--level-color, #059669);
  text-decoration: none;
  transition: gap 0.2s ease;
}

.journey-step-link:hover {
  gap: 0.4rem;
  text-decoration: underline;
}

/* ============================================
   STORY CARD PREMIUM (content.ejs)
   ============================================ */
.story-card-premium {
  position: relative;
  background: linear-gradient(135deg, rgba(var(--tj-accent-rgb), 0.06) 0%, #fff 60%);
  border: 1px solid rgba(var(--tj-accent-rgb), 0.15);
  border-radius: var(--tj-radius-lg);
  padding: 1.75rem;
  overflow: hidden;
  transition: var(--tj-transition);
}

.story-card-premium:hover {
  border-color: rgba(var(--tj-accent-rgb), 0.3);
  box-shadow: 0 12px 32px -8px rgba(var(--tj-accent-rgb), 0.12);
  transform: translateY(-2px);
}

.story-card-premium .story-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--tj-radius);
  background: rgba(var(--tj-accent-rgb), 0.1);
  color: var(--level-color, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.story-card-premium .story-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.story-card-premium .story-preview {
  font-size: 1rem;
  line-height: 1.7;
  color: #475569;
  margin-bottom: 1.25rem;
}

.story-card-premium .story-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 1rem;
}

.story-card-premium .story-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: var(--level-color, #059669);
  color: #fff;
  border-radius: var(--tj-radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: var(--tj-transition);
}

.story-card-premium .story-cta:hover {
  filter: brightness(1.08);
  transform: translateX(3px);
}

.story-card-premium .story-status {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.story-status-unread {
  background: #f1f5f9;
  color: #64748b;
}

.story-status-read {
  background: #dcfce7;
  color: #166534;
}

/* ============================================
   GAMES HUB IN LESSON (content.ejs)
   ============================================ */
.games-hub-header {
  margin-bottom: 1.25rem;
}

.games-hub-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.games-hub-header p {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0;
}

.games-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.875rem;
}

.game-hub-card {
  position: relative;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--tj-radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: var(--tj-transition);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.game-hub-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -8px rgba(0,0,0,0.1);
  border-color: var(--level-color, #059669);
}

.game-hub-card.recommended {
  border-color: var(--level-color, #059669);
  background: linear-gradient(180deg, rgba(var(--tj-accent-rgb), 0.04) 0%, #fff 50%);
}

.game-hub-card.recommended::after {
  content: 'Próximo';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.15rem 0.5rem;
  background: var(--level-color, #059669);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
}

.game-hub-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.game-hub-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.game-hub-skill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--level-color, #059669);
  background: rgba(var(--tj-accent-rgb), 0.08);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.game-hub-score {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.game-hub-score-bar {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: auto;
}

.game-hub-score-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--level-color, #059669), #86efac);
  transition: width 0.8s cubic-bezier(0.22,1,0.36,1);
}

.game-hub-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--level-color, #059669);
}

/* ============================================
   CTA SECTION — QUIZ FINAL
   ============================================ */
.cta-journey-card {
  position: relative;
  background: linear-gradient(135deg, rgba(var(--tj-accent-rgb), 0.08) 0%, #fff 50%);
  border: 2px solid rgba(var(--tj-accent-rgb), 0.15);
  border-radius: var(--tj-radius-lg);
  padding: 2rem;
  text-align: center;
  overflow: hidden;
}

.cta-journey-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(var(--tj-accent-rgb), 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(var(--tj-accent-rgb), 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.cta-journey-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(var(--tj-accent-rgb), 0.1);
  color: var(--level-color, #059669);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.cta-journey-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.5rem;
  position: relative;
}

.cta-journey-desc {
  font-size: 0.95rem;
  color: #475569;
  max-width: 480px;
  margin: 0 auto 1.25rem;
  position: relative;
  line-height: 1.6;
}

.cta-journey-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: rgba(var(--tj-accent-rgb), 0.06);
  border: 1px dashed rgba(var(--tj-accent-rgb), 0.25);
  border-radius: var(--tj-radius-sm);
  font-size: 0.8rem;
  color: var(--level-color, #059669);
  margin-bottom: 1.25rem;
  position: relative;
}

.cta-journey-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  background: var(--level-color, #059669);
  color: #fff;
  border-radius: var(--tj-radius);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: var(--tj-transition);
  position: relative;
  box-shadow: 0 4px 16px rgba(var(--tj-accent-rgb), 0.25);
}

.cta-journey-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--tj-accent-rgb), 0.35);
}

/* ============================================
   GAMES PAGE PREMIUM (games.ejs)
   ============================================ */
.games-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 0;
}

.game-page-card {
  position: relative;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--tj-radius-lg);
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  transition: var(--tj-transition);
  display: flex;
  flex-direction: column;
}

.game-page-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px -8px rgba(0,0,0,0.1);
  border-color: var(--level-color, #059669);
}

.game-page-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.game-page-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--tj-radius);
  background: rgba(var(--tj-accent-rgb), 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
}

.game-page-title-wrap {
  flex: 1;
}

.game-page-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.15rem;
}

.game-page-skill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--level-color, #059669);
  background: rgba(var(--tj-accent-rgb), 0.08);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.game-page-desc {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 1rem;
  flex: 1;
}

.game-page-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.875rem;
  border-top: 1px solid #f1f5f9;
}

.game-page-best {
  font-size: 0.8rem;
  color: #64748b;
}

.game-page-best strong {
  color: #0f172a;
}

.game-page-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: var(--tj-transition);
}

.game-page-card:hover .game-page-arrow {
  background: var(--level-color, #059669);
  color: #fff;
  transform: translateX(3px);
}

/* Journey banner em games.ejs */
.journey-banner {
  background: linear-gradient(135deg, rgba(var(--tj-accent-rgb), 0.06) 0%, #fff 100%);
  border: 1px solid rgba(var(--tj-accent-rgb), 0.12);
  border-radius: var(--tj-radius-lg);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.journey-banner-text {
  font-size: 0.9rem;
  color: #475569;
}

.journey-banner-text strong {
  color: #0f172a;
}

.journey-banner-dots {
  display: flex;
  gap: 0.35rem;
}

.journey-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e2e8f0;
}

.journey-banner-dot.done {
  background: var(--level-color, #059669);
}

.journey-banner-dot.active {
  background: var(--level-color, #059669);
  box-shadow: 0 0 0 3px rgba(var(--tj-accent-rgb), 0.2);
}

/* ============================================
   STORY PAGE IMPROVEMENTS (story.ejs)
   ============================================ */
.story-text-premium {
  font-size: 1.1rem;
  line-height: 1.85;
  color: #1e293b;
  padding: 1.75rem;
  background: #fdfcfa;
  border-radius: var(--tj-radius-lg);
  border-left: 4px solid var(--level-color, #059669);
  margin-bottom: 1rem;
}

.story-audio-sticky {
  position: sticky;
  top: 80px;
  z-index: 10;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--tj-radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.story-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--level-color, #059669);
  z-index: 1000;
  transition: width 0.1s linear;
}

.story-cta-post {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .themes-grid-premium {
    grid-template-columns: 1fr;
  }
  .games-hub-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .games-page-grid {
    grid-template-columns: 1fr;
    padding: 1rem 0;
  }
  .journey-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .story-text-premium {
    font-size: 1rem;
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  .games-hub-grid {
    grid-template-columns: 1fr;
  }
  .tj-card-actions {
    flex-direction: column;
  }
  .cta-journey-card {
    padding: 1.5rem 1rem;
  }
}
