/* ═══ Anchor HQ — RPG Game Layer ═══ */
/* Stardew Valley-themed RPG UI: skill trees, achievements, quests, overlays, toasts */


/* ────────────────────────────────────────────
   1. SKILL TREE
   ──────────────────────────────────────────── */

.rpg-skill-tree {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 4px 0;
}

.rpg-skill-item {
  flex: 1;
  min-width: 130px;
  max-width: 180px;
  text-align: center;
  padding: 16px 12px;
  background: var(--panel-soft);
  border: 2px solid var(--wood);
  border-radius: var(--radius);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.rpg-skill-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(218, 165, 32, 0.2),
              0 0 8px rgba(218, 165, 32, 0.1);
}

.rpg-skill-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
  display: block;
  line-height: 1;
}

.rpg-skill-name {
  font-family: var(--font-pixel);
  font-size: 0.42rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  line-height: 1.5;
}

.rpg-skill-level {
  font-family: var(--font-pixel);
  font-size: 0.38rem;
  color: var(--gold);
  margin-bottom: 8px;
  line-height: 1.4;
}

.rpg-skill-pips {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-bottom: 8px;
}

.rpg-skill-pip {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.rpg-skill-pip.filled {
  background: var(--pip-color, var(--gold));
  border-color: var(--pip-color, var(--gold));
  box-shadow: 0 0 6px var(--pip-color, rgba(218, 165, 32, 0.5));
}

.rpg-skill-xp-bar {
  height: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.rpg-skill-xp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
  background: var(--pip-color, var(--gold));
}

/* Skill color variants via custom property */
.rpg-skill-item[data-skill-color="green"]  { --pip-color: var(--green); }
.rpg-skill-item[data-skill-color="blue"]   { --pip-color: var(--blue); }
.rpg-skill-item[data-skill-color="purple"] { --pip-color: var(--purple); }
.rpg-skill-item[data-skill-color="orange"] { --pip-color: var(--orange); }
.rpg-skill-item[data-skill-color="gold"]   { --pip-color: var(--gold); }


/* ────────────────────────────────────────────
   2. ACHIEVEMENT GRID
   ──────────────────────────────────────────── */

.rpg-achievements-card {
  position: relative;
}

.rpg-achievements-card .card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rpg-achievement-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.rpg-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--panel-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  transition: all 0.3s ease;
  min-height: 80px;
  cursor: default;
  position: relative;
}

.rpg-badge.locked {
  opacity: 0.4;
  -webkit-filter: grayscale(0.8);
          filter: grayscale(0.8);
  border-color: var(--border);
}

.rpg-badge.unlocked {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(218, 165, 32, 0.3);
  background: linear-gradient(
    135deg,
    var(--panel-soft),
    rgba(218, 165, 32, 0.08)
  );
}

.rpg-badge.unlocked:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(218, 165, 32, 0.5);
}

.rpg-badge-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
  line-height: 1;
}

.rpg-badge-name {
  font-family: var(--font-pixel);
  font-size: 0.35rem;
  color: var(--text);
  line-height: 1.4;
}

.rpg-badge.locked .rpg-badge-name {
  color: var(--muted);
}

.rpg-badge-desc {
  display: none;
}

/* Tooltip on hover via title attribute */
.rpg-badge[title] {
  overflow: visible;
}

.rpg-badge[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  margin-bottom: 4px;
}

/* Small arrow under tooltip */
.rpg-badge[title]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% - 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--gold);
  z-index: 11;
  pointer-events: none;
}

/* Unlocked badge shimmer on initial reveal */
.rpg-badge.unlocked.rpg-badge-new {
  animation: rpg-badge-shimmer 1.5s ease forwards;
}

@keyframes rpg-badge-shimmer {
  0%   { box-shadow: 0 0 8px rgba(218, 165, 32, 0.3); }
  50%  { box-shadow: 0 0 24px rgba(218, 165, 32, 0.7); }
  100% { box-shadow: 0 0 8px rgba(218, 165, 32, 0.3); }
}


/* ────────────────────────────────────────────
   3. DAILY QUEST BOARD
   ──────────────────────────────────────────── */

.rpg-quest-board-card {
  position: relative;
}

.rpg-quest-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(139, 111, 71, 0.05) 0px,
      rgba(139, 111, 71, 0.05) 2px,
      transparent 2px,
      transparent 8px
    );
  border-radius: 4px;
}

.rpg-quest-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--parchment, #f5e6c8);
  border: 1px solid rgba(139, 111, 71, 0.3);
  border-radius: 4px;
  position: relative;
  transition: all 0.3s ease;
}

/* Push-pin decoration */
.rpg-quest-card::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 14px;
  width: 8px;
  height: 8px;
  background: #c0392b;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.rpg-quest-card:hover {
  transform: translateX(2px);
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

.rpg-quest-card.completed {
  opacity: 0.6;
  border-color: var(--green, #5ba84c);
}

.rpg-quest-card.completed .rpg-quest-title {
  text-decoration: line-through;
  color: var(--green);
}

.rpg-quest-card.completed::before {
  background: var(--green, #5ba84c);
}

.rpg-quest-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
}

.rpg-quest-title {
  flex: 1;
  font-size: 0.82rem;
  color: #3d2b1a;
  line-height: 1.4;
}

.rpg-quest-reward {
  font-family: var(--font-pixel);
  font-size: 0.4rem;
  color: #b8860b;
  background: rgba(218, 165, 32, 0.15);
  padding: 2px 8px;
  border-radius: 2px;
  white-space: nowrap;
  line-height: 1.5;
}

.rpg-quest-empty {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 20px;
  font-size: 0.85rem;
}


/* ────────────────────────────────────────────
   4. LEVEL-UP OVERLAY
   ──────────────────────────────────────────── */

.rpg-level-up-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: rpg-overlay-fade-in 0.3s ease;
}

.rpg-level-up-overlay.active {
  display: flex;
}

.rpg-level-up-content {
  text-align: center;
  animation: rpg-level-up-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 40px;
  max-width: 400px;
}

.rpg-level-up-stars {
  font-size: 2.5rem;
  animation: pixelPulse 1s ease infinite;
  margin-bottom: 12px;
  line-height: 1;
}

.rpg-level-up-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), var(--gold-bright, #f0c040));
  color: var(--wood-dark, #3a2415);
  font-size: 1.2rem;
  padding: 10px 24px;
  border-radius: 4px;
  border: 3px solid var(--gold-bright, #f0c040);
  box-shadow: 0 0 30px rgba(218, 165, 32, 0.6),
              0 0 60px rgba(218, 165, 32, 0.2);
  margin-bottom: 8px;
  font-weight: 700;
}

.rpg-level-up-label {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(218, 165, 32, 0.5);
  margin-bottom: 6px;
  letter-spacing: 0.1em;
  line-height: 1.6;
}

.rpg-level-up-title {
  font-size: 1.1rem;
  color: var(--text-bright, #fff);
  margin-bottom: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.rpg-level-up-coins {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.rpg-level-up-coins span {
  animation: rpg-coin-bounce 0.6s ease infinite;
  display: inline-block;
}

.rpg-level-up-coins span:nth-child(1) { animation-delay: 0s; }
.rpg-level-up-coins span:nth-child(2) { animation-delay: 0.1s; }
.rpg-level-up-coins span:nth-child(3) { animation-delay: 0.2s; }
.rpg-level-up-coins span:nth-child(4) { animation-delay: 0.3s; }
.rpg-level-up-coins span:nth-child(5) { animation-delay: 0.4s; }

.rpg-level-up-dismiss {
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold);
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.5;
}

.rpg-level-up-dismiss:hover {
  background: rgba(218, 165, 32, 0.15);
  box-shadow: 0 0 12px rgba(218, 165, 32, 0.3);
}

.rpg-level-up-dismiss:active {
  transform: scale(0.96);
}

/* Level-Up Keyframes */
@keyframes rpg-overlay-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rpg-level-up-bounce {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes rpg-coin-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}


/* ────────────────────────────────────────────
   5. XP TOAST
   ──────────────────────────────────────────── */

.rpg-xp-toast {
  position: absolute;
  right: 80px;
  top: -4px;
  pointer-events: none;
  z-index: 10;
  animation: rpg-xp-float 1.8s ease forwards;
}

.rpg-xp-toast-text {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--gold-bright, #f0c040);
  text-shadow:
    0 0 8px rgba(218, 165, 32, 0.7),
    1px 1px 0 var(--wood-dark, #3a2415);
  font-weight: bold;
  white-space: nowrap;
  line-height: 1;
}

@keyframes rpg-xp-float {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}


/* ────────────────────────────────────────────
   6. STREAK FIRE ENHANCEMENT
   ──────────────────────────────────────────── */

/* 7-day streak */
.rpg-streak.rpg-streak-fire.s7 {
  position: relative;
}

.rpg-streak.rpg-streak-fire.s7 .rpg-streak-flame {
  transform: scale(1.15);
  animation: rpg-flame-flicker 0.8s ease infinite;
  display: inline-block;
}

/* 30-day streak */
.rpg-streak.rpg-streak-fire.s30 {
  position: relative;
}

.rpg-streak.rpg-streak-fire.s30 .rpg-streak-flame {
  transform: scale(1.3);
  animation: rpg-flame-flicker 0.65s ease infinite;
}

.rpg-streak.rpg-streak-fire.s30::after {
  content: '\1F525';
  position: absolute;
  right: -6px;
  top: -4px;
  font-size: 0.5rem;
  opacity: 0.7;
  pointer-events: none;
}

/* 100-day streak */
.rpg-streak.rpg-streak-fire.s100 {
  box-shadow: 0 0 12px rgba(218, 165, 32, 0.5);
  position: relative;
}

.rpg-streak.rpg-streak-fire.s100 .rpg-streak-flame {
  transform: scale(1.4);
  animation: rpg-flame-flicker 0.5s ease infinite;
}

.rpg-streak.rpg-streak-fire.s100::after {
  content: '\1F525';
  position: absolute;
  right: -8px;
  top: -6px;
  font-size: 0.6rem;
  opacity: 0.85;
  pointer-events: none;
}

@keyframes rpg-flame-flicker {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.1) rotate(-3deg);
  }
  75% {
    transform: scale(0.95) rotate(3deg);
  }
}


/* ────────────────────────────────────────────
   7. SIDEBAR RPG STATS
   ──────────────────────────────────────────── */

.rpg-sidebar-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 0 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.rpg-sidebar-level {
  font-family: var(--font-pixel);
  font-size: 0.4rem;
  background: linear-gradient(135deg, var(--gold), var(--gold-bright, #f0c040));
  color: var(--wood-dark, #3a2415);
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--gold-bright, #f0c040);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.rpg-sidebar-gold {
  font-size: 0.72rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}

.rpg-sidebar-gold span:first-child {
  font-size: 0.85rem;
}

.rpg-sidebar-trophies {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  line-height: 1;
}

.rpg-sidebar-trophies span:first-child {
  font-size: 0.85rem;
}

/* Sidebar mini XP bar */
.rpg-sidebar-xp-bar {
  flex: 1;
  height: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  min-width: 40px;
}

.rpg-sidebar-xp-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.6s ease;
}


/* ────────────────────────────────────────────
   8. RESPONSIVE BREAKPOINTS
   ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .rpg-skill-tree {
    gap: 8px;
  }

  .rpg-skill-item {
    min-width: 110px;
    padding: 12px 8px;
  }

  .rpg-achievement-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .rpg-quest-card {
    padding: 10px 12px;
  }

  .rpg-level-up-content {
    padding: 28px 20px;
  }

  .rpg-level-up-badge {
    font-size: 1rem;
    padding: 8px 18px;
  }
}

@media (max-width: 640px) {
  .rpg-skill-tree {
    flex-direction: column;
    align-items: stretch;
  }

  .rpg-skill-item {
    max-width: 100%;
    flex-direction: row;
    display: flex;
    gap: 12px;
    text-align: left;
    padding: 10px 14px;
  }

  .rpg-skill-pips {
    justify-content: flex-start;
  }

  .rpg-achievement-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .rpg-badge {
    padding: 8px 4px;
    min-height: 60px;
  }

  .rpg-badge-icon {
    font-size: 1.2rem;
  }

  .rpg-badge-name {
    font-size: 0.3rem;
  }

  .rpg-quest-card {
    padding: 8px 10px;
  }

  .rpg-quest-reward {
    font-size: 0.36rem;
    padding: 2px 6px;
  }

  .rpg-sidebar-stats {
    margin: 0 8px;
    padding: 8px 12px;
  }

  .rpg-level-up-content {
    padding: 24px 16px;
  }

  .rpg-level-up-stars {
    font-size: 2rem;
  }

  .rpg-level-up-badge {
    font-size: 0.9rem;
    padding: 8px 16px;
  }
}

@media (max-width: 420px) {
  .rpg-achievement-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rpg-quest-card::before {
    width: 6px;
    height: 6px;
    left: 10px;
  }

  .rpg-level-up-coins {
    gap: 8px;
    font-size: 1.2rem;
  }

  .rpg-sidebar-stats {
    gap: 6px;
    padding: 6px 10px;
  }

  .rpg-sidebar-level {
    font-size: 0.35rem;
    padding: 2px 6px;
  }
}


/* ────────────────────────────────────────────
   9. REDUCED MOTION
   ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .rpg-xp-toast {
    animation: none;
    opacity: 0;
  }

  .rpg-level-up-overlay {
    animation: none;
  }

  .rpg-level-up-content {
    animation: none;
  }

  .rpg-level-up-coins span {
    animation: none;
  }

  .rpg-skill-pip.filled {
    transition: none;
  }

  .rpg-skill-xp-fill {
    transition: none;
  }

  .rpg-level-up-stars {
    animation: none;
  }

  .rpg-streak.rpg-streak-fire .rpg-streak-flame {
    animation: none;
  }

  .rpg-badge.unlocked.rpg-badge-new {
    animation: none;
  }

  .rpg-skill-item {
    transition: none;
  }

  .rpg-badge {
    transition: none;
  }

  .rpg-quest-card {
    transition: none;
  }
}


/* ────────────────────────────────────────────
   10. LIGHT THEME OVERRIDES
   ──────────────────────────────────────────── */

[data-theme="light"] .rpg-quest-card {
  background: #faf0dc;
  border-color: rgba(139, 111, 71, 0.4);
}

[data-theme="light"] .rpg-quest-card::before {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .rpg-quest-title {
  color: #2a1a08;
}

[data-theme="light"] .rpg-quest-reward {
  color: #8b6914;
  background: rgba(218, 165, 32, 0.2);
}

[data-theme="light"] .rpg-badge.unlocked {
  box-shadow: 0 0 10px rgba(218, 165, 32, 0.4);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9),
    rgba(218, 165, 32, 0.12)
  );
}

[data-theme="light"] .rpg-skill-item {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--wood);
}

[data-theme="light"] .rpg-skill-item:hover {
  box-shadow: 0 4px 16px rgba(218, 165, 32, 0.25);
}

[data-theme="light"] .rpg-sidebar-stats {
  border-color: rgba(139, 111, 71, 0.2);
}

[data-theme="light"] .rpg-level-up-overlay {
  background: rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .rpg-level-up-title {
  color: #2a1a08;
}

[data-theme="light"] .rpg-level-up-dismiss {
  color: var(--wood-dark, #3a2415);
  border-color: var(--wood);
}

[data-theme="light"] .rpg-level-up-dismiss:hover {
  background: rgba(139, 111, 71, 0.1);
}

[data-theme="light"] .rpg-xp-toast-text {
  color: var(--gold);
  text-shadow:
    0 0 6px rgba(218, 165, 32, 0.5),
    1px 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .rpg-quest-board {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(139, 111, 71, 0.08) 0px,
      rgba(139, 111, 71, 0.08) 2px,
      transparent 2px,
      transparent 8px
    );
}

[data-theme="light"] .rpg-badge[title]:hover::after {
  background: #fff;
  border-color: var(--wood);
  color: #2a1a08;
}
