/**
 * 1. THEME VARIABLES & CORE RESET
 */
:root {
  --bg-page: #f0f4f8;
  --bg-card: #ffffff;
  --bg-footer: #e2e8f0;
  --text-main: #1a202c;
  --text-muted: #4a5568;
  --border-color: #cbd5e0;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-rgb: 37, 99, 235;
  --danger: #dc2626;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.dark {
  --bg-page: #05070a;
  --bg-card: #0f172a;
  --bg-footer: #020617;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --accent: #38bdf8;
  --accent-light: rgba(56, 189, 248, 0.1);
  --danger: #f87171;
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

html, body {
  overflow-x: clip;
  min-height: 100%;
  background-color: var(--bg-page);
  color: var(--text-main);
  transition: background-color 0.4s ease, color 0.4s ease;
  scroll-behavior: smooth;
}



/**
 * 2. USER CARDS - DYNAMIC & STATIC
 */
/**
 * DYNAMIC COLORING (NO ANIMATION)
 */
.user-card h2,
.profile-link,
.user-card a {
  color: var(--accent) !important;
  font-weight: 800;
  text-decoration: none;
  /* Animate ONLY the color property when theme changes */
  transition: color 0.4s ease, opacity 0.2s ease;
}

/* Static Hover: No movement */
.user-card:hover h2 {
  filter: brightness(1.2);
}

.profile-link:hover,
.user-card a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* Button to trigger Screenshot Mode in the Dev Panel */
.screenshot-btn {
    border-color: var(--text-muted) !important;
    color: var(--text-muted) !important;
    font-size: 0.6rem !important;
    margin-top: 10px;
}

/* If your links look like tags/pills */
.link-pill {
  background-color: var(--accent-light) !important;
  color: var(--accent) !important;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  border: 1px solid transparent;
}

.link-pill:hover {
  border-color: var(--accent);
}



/* If you have a specific button-style profile link */
.profile-btn {
  background-color: var(--accent-light) !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 800;
  transition: all 0.3s ease;
}

.profile-btn:hover {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 15px var(--accent-light);
}

.skill-item {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background-color: var(--accent-light) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  line-height: 1;
  isolation: isolate;
}

.skill-item:hover {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
}

/**
 * 3. BUTTONS & SHIMMER EFFECTS
 */
.surprise-btn {
  background-color: #2563eb !important;
  color: #ffffff !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.5rem;
  border-radius: 9999px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.dark .surprise-btn { background-color: var(--accent) !important; }

.surprise-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
  filter: brightness(1.1);
}

.surprise-btn::after, .skill-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  transition: 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.surprise-btn:hover::after, .skill-item:hover::after { left: 150%; }

/**
 * 4. DEVELOPER TOOLS - INDESTRUCTIBLE VIEWPORT PANEL
 */
#dev-tools {
  position: fixed !important;
  top: 1rem;
  right: 1rem;
  width: 280px;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--accent);
  padding: 1.25rem;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  z-index: 2147483647 !important;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: translateZ(0); /* Force layer isolation */
}

/* NUCLEAR LOCK: Forces stability during page-wide glitches */
#dev-tools[data-lock="true"],
html body #dev-tools[data-lock="true"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 1rem !important;
    right: 1rem !important;
    transform: none !important;
    animation: none !important;
    border-left-color: #ef4444 !important;
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.6) !important;
}

#dev-tools button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  color: #e2e8f0;
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

#dev-tools button:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 15px currentColor;
  transform: translateX(-4px);
}

/* Console Neon Overrides */
#dev-tools button[onclick*="matrix"] { color: #00ff41 !important; }
#dev-tools button[onclick*="konami"] { color: #ffcc00 !important; }
#dev-tools button[onclick*="gravity"] { color: #ff3333 !important; }
#dev-tools button[onclick*="badge_click"] { color: #bc13fe !important; }

/**
 * 5. SELF DESTRUCT & REPAIR
 */
#destruct-bar-container {
    width: 100%; height: 14px; background: #000;
    border: 2px solid #333; margin-top: 15px; border-radius: 4px;
}

#destruct-bar-progress {
    height: 100%; width: 0%; background: #22c55e;
    transition: width 1s linear, background-color 0.3s;
}

#repair-btn {
  background-color: #2563eb !important; /* Restore to Blue */
  color: #fff !important;
  border: 4px solid #fff;
  border-radius: 9999px;
  padding: 1.5rem 3rem;
  font-weight: 900;
  box-shadow: 0 0 60px rgba(37, 99, 235, 0.6);
  z-index: 10001;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/**
 * 6. ANIMATIONS
 */
@keyframes shake-anim {
  0% { transform: translate(0, 0); }
  25% { transform: translate(3px, -3px); }
  50% { transform: translate(-3px, 3px); }
  100% { transform: translate(0, 0); }
}

.glitch-shake { animation: shake-anim 0.1s infinite; overflow: hidden; }

@keyframes konami-barrel-roll {
    0% { transform: rotate(0deg) scale(1); filter: hue-rotate(0deg); }
    50% { transform: rotate(180deg) scale(0.8); filter: hue-rotate(180deg); }
    100% { transform: rotate(360deg) scale(1); filter: hue-rotate(360deg); }
}

.konami-roll { animation: konami-barrel-roll 2s cubic-bezier(0.45, 0.05, 0.55, 0.95); }

/**
 * FANCY USER SELECTION EFFECT
 */
@keyframes fancy-ping {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(var(--accent-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
    }
}
/* Ensure the card can show the trace glow */
.user-card.selected-fancy {
    z-index: 50;
    overflow: visible !important;
    transform: scale(1.02);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.border-trace {
    position: absolute;
    inset: -2px; /* Slightly outside the card border */
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    pointer-events: none;
    fill: none;
}

.border-trace rect {
    stroke-width: 4px;
    stroke-linecap: round;
    /* Perimeter length - 2500px is a safe bet for these cards */
    stroke-dasharray: 2500;
    stroke-dashoffset: 2500;
    animation: retrace-sequence 7.5s linear forwards;
}

@keyframes retrace-sequence {
    0% {
        stroke-dashoffset: 2500;
        stroke: var(--accent);
        filter: drop-shadow(0 0 8px var(--accent));
    }
    100% {
        stroke-dashoffset: 0;
        /* Cycle through colors while drawing */
        stroke: var(--accent);
        filter: drop-shadow(0 0 12px var(--accent)) hue-rotate(360deg);
    }
}
/* Visual feedback when hovering a skill to gain XP */
.mining-xp {
    filter: brightness(1.5);
    box-shadow: 0 0 15px var(--accent);
    transition: all 0.2s ease;
}

/* Special styling for those who have reached Level 5 (Data Miner) */
body[data-level="5"] .skill-item {
    border-color: #06b6d4 !important; /* Data Miner Cyan */
    background: rgba(6, 182, 212, 0.1) !important;
    position: relative;
    overflow: hidden;
}

/* Add a gem-like sparkle to skills at Level 5 */
body[data-level="5"] .skill-item::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(45deg);
    animation: gem-shimmer 3s infinite;
}

@keyframes gem-shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}
@keyframes float-up {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -50px); opacity: 0; }
}

/* Level 5 Specific Visual Perk */
.level-architect .skill-item,
body[data-level="5"] .skill-item {
    border-color: #06b6d4 !important;
    background: rgba(6, 182, 212, 0.1) !important;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.skill-item {
    cursor: crosshair; /* Makes it feel like you are "mining" */
}
/* Level 6 Visuals */
body[data-level="6"] .user-card {
    border-color: rgba(236, 72, 153, 0.3);
}

body[data-level="6"]::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.1) 50%
    );
    background-size: 100% 4px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.2; /* Very subtle scanlines */
}
#total-xp-display {
    display: inline-block;
    transition: transform 0.1s ease;
}

/* Added via JS when XP increases */
.xp-pulse {
    transform: scale(1.3);
    color: white !important;
}
