/* Author:Kevin
   Date:01/01/2018
   Description: A click game, hopefully this game will change the internet for the better, enjoy it you.
*/

/* === VARIABLES === */
:root{
  --bg-900: #0f1220; /* page background base */
  --bg-overlay: rgba(6,10,22,0.45);
  --panel-bg: rgba(24,28,44,0.48);
  --panel-accent: rgba(120,160,255,0.08);
  --accent-1: #6ea0ff; /* primary accent */
  --accent-2: #9b7cff; /* secondary accent */
  --button-start: #5a74ff;
  --button-end: #4258d9;
  --muted: rgba(236,239,255,0.9);
  --glass-blur: 8px;
  --toast-bg: rgba(8,12,28,0.92);
  --orb-glow-1: rgba(120,160,255,0.95);
  --orb-glow-2: rgba(140,190,255,0.55);
  --ring: 0 6px 28px rgba(90,120,200,0.16);
}

/* === Base styles === */
body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg-900);
  color: var(--muted);
  text-align: center;
  margin: 0;
  padding: 0;
  /* keep original image but add a soft radial overlay for depth */
  background-image: radial-gradient(circle at 10% 10%, rgba(110,140,220,0.06), transparent 12%), radial-gradient(circle at 90% 80%, rgba(150,110,220,0.03), transparent 18%), url('Pics/Backgrounds/galacticbg.jpg');
  background-size: cover;
  background-position: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h2 {
  color: #e0e4ff;
  text-shadow: 0 4px 12px rgba(80,120,220,0.14);

}

/* === Layout === */
.game-container {
  display: grid;
  grid-template-columns: 1fr 0.65fr; /* left and right panels */
  grid-template-rows: auto auto;     /* first row: panels, second row: buff bar */
  gap: 10px;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

#reset-game {
  position: absolute;
  right: 18px;
  /* compacted: smaller footprint but still visible */
  padding: 6px 10px;
  font-size: 13px;
  background: linear-gradient(180deg,var(--button-start),var(--button-end));
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 6px 18px rgba(80,110,220,0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
} 

#reset-game:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(80,110,220,0.14);
} 

#support-btn {
    position: fixed;
    bottom: 18px; /* or top: 18px if you prefer */
    right: 18px;
    padding: 4px 12px;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(180deg, #6ea0ff, #4258d9);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 2000;
    box-shadow: 0 0 12px rgba(110,160,255,0.6);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#support-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 18px rgba(155,124,255,0.8);
}

.left-panel, .right-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  padding: 5px; /* Reduced padding slightly to save space */
  border-radius: 14px;
  background-color: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: 0 8px 30px rgba(8,12,28,0.6);
  
  /* NEW: Prevent these from growing forever */
  max-height: 60vh; 
  display: flex;
  flex-direction: column;
}

.left-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 500px;
  grid-column: 1;
  grid-row: 1;
}

.right-panel {
  position: relative;
  min-height: 500px;
  grid-column: 2;
  grid-row: 1;
}

.buff-panel {
  grid-column: 2;
  grid-row: 2;
  background-color: rgba(26,30,50,0.6);
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 10px;
  box-shadow: 0 -6px 20px rgba(10,14,30,0.6);
  border: 1px solid rgba(130,150,255,0.04);
}

.buff-slot {
  width: 40px;
  height: 32px;
  background: linear-gradient(180deg, rgba(80,100,180,0.14), rgba(40,50,90,0.12));
  color: var(--muted);
  border: 1px solid rgba(120,150,255,0.06);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

.buff-slot:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 18px rgba(80,120,220,0.12);
}

#mana-display {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 30px;
  line-height: 1;
  color: #f8fbff;
  text-shadow: 0 6px 18px rgba(80,120,220,0.12);
}

#mana-rate {
  margin-bottom: 45px;
  font-size: 20px;
  color: rgba(240,240,255,0.9);
}

button {
  padding: 10px 18px;
  margin: 2px 0;
  font-size: 15px;
  background: linear-gradient(180deg,var(--button-start),var(--button-end));
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(60,80,170,0.14);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover { transform: translateY(-3px); }

/* === Shop & Upgrades (buttons + icon) === */
.right-panel .upgrade button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* tightened gap so icons and text sit closer */
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  /* compacted: keep 60px icons but reduce extra vertical space */
  min-height: 64px;
  padding: 4px 12px;
  margin-bottom: 8px;
  position: relative; /* so .production-label positions correctly */
} 

.shop-icon {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex: 0 0 60px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.shop-icon:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 26px rgba(80,110,200,0.1);
} 

.shop-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0; /* allow truncation */
}

.shop-title {
  display: block;
  font-size: 1em;
  line-height: 1.1;
}

.shop-meta {
  font-size: 0.85em;
  color: rgba(240,240,255,0.85);
  margin-top: 4px;
}

/* Click power badge (top-left of left panel) */
.click-power {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(20,20,30,0.6);
  color: #f6f6ff;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.orb-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* === Mana Orb (interactive) === */
.mana-orb {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background-image: url('Pics/orb.png');
  background-size: cover;
  background-position: center;
  background-color: #111426;
  box-shadow: 0 0 30px var(--orb-glow-1), 0 0 80px var(--orb-glow-2), inset 0 0 18px rgba(255,255,255,0.03);
  cursor: pointer;
  position: relative;
  transition: transform 0.18s cubic-bezier(.2,.8,.2,1), box-shadow 0.2s ease;
  border: 2px solid rgba(120,160,255,0.06);

  /* Prevent accidental selection/dragging during click-drag gestures */
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.mana-orb:active { 
  transform: scale(0.96); 
  box-shadow: 0 0 100px rgba(160,200,255,0.98); 
}
.mana-orb:hover {
  transform: scale(1.06); 
  box-shadow: 0 0 60px var(--orb-glow-1), 0 0 120px var(--orb-glow-2); }

.mana-orb::before,
.mana-orb::after {
  content: "";
  position: absolute;
  width: 60%;
  height: 60%;
  left: 20%;
  top: 20%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.85) 0%, transparent 65%);
  filter: blur(6px);
  mix-blend-mode: screen;
  pointer-events: none;
  transform-origin: center center;
  animation: sparkle 2.6s infinite ease-in-out;
  will-change: transform, opacity;
}

.mana-orb::after { 
  animation-delay: 1.2s; 
}

@keyframes sparkle {
  0% { transform: scale(1) rotate(0deg); opacity: 0.75; }
  45% { transform: scale(1.18) rotate(180deg); opacity: 0.18; }
  100% { transform: scale(1) rotate(360deg); opacity: 0.75; }
}

@keyframes pulse-animation {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  30% {
    transform: scale(1.06);
    opacity: 0.92;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.pulse {
  /* Slightly longer and subtler pulse so rapid clicks don't look sped-up */
  animation: pulse-animation 300ms cubic-bezier(.2,.8,.2,1) forwards;
}

/* Floating click feedback (e.g. "+1") */
.click-fx {
  position: fixed;
  pointer-events: none;
  color: #01fec3;
  font-weight: 800;
  font-size: 18px;
  -webkit-text-stroke: 0.6px rgba(0,0,0,0.95);
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 6px 18px rgba(30,40,80,0.45);
  transform-origin: center center;
  will-change: transform, opacity;
  z-index: 1300;
  animation: click-fx 700ms cubic-bezier(.2,.9,.2,1) forwards;
}

@keyframes click-fx {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  60% { opacity: 1; transform: translateY(-26px) scale(1.06); }
  100% { opacity: 0; transform: translateY(-54px) scale(1.08); }
}

/* CSS-only floating feedback container that uses a ::after pseudo-element */
#click-fx {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 2400;
}

#click-fx::after {
  content: attr(data-text);
  position: fixed;
  left: var(--fx-x, 50%);
  top: var(--fx-y, 50%);
  transform: translate(-50%, -50%);
  color: #01fec3;
  font-weight: 800;
  font-size: 18px;
  -webkit-text-stroke: 0.6px rgba(0,0,0,0.95);
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 6px 18px rgba(30,40,80,0.45);
  will-change: transform, opacity;
  opacity: 0;
}

#click-fx.show::after {
  animation: click-fx 700ms cubic-bezier(.2,.9,.2,1) forwards;
}

/* Accessibility & responsiveness */
@media (max-width: 700px) {
  h1{
    margin-top: 50px;
  }

  .game-container {
    display: block;
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 20px;
  }

  .mana-orb {
    width: min(280px, 70vw);
    height: min(280px, 70vw);
    margin: 0 auto;
  }

  #mana-display {
    font-size: 20px;
    margin-bottom: 18px;
  }

  #watermark { left: 10px; bottom: 10px; font-size: 13px; position: static !important; }

  /* Slightly reduce icon sizes on small screens to keep layout stable */
  .right-panel .upgrade button { min-height: 60px; padding: 4px 8px; }
  .shop-icon { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 10px; }
}

/* Visually hidden but accessible element for screen readers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .mana-orb:not(.pulse) { animation: none !important; }  /* allow pulse */
  .mana-orb { transition: none !important; }
  .mana-orb::before,
  .mana-orb::after { animation: none !important; }
}

#watermark {
  position: fixed;
  left: 12px;
  bottom: 8px;
  font-size: 12px;
  color: rgba(220, 230, 255, 0.7);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(10,12,22,0.14));
  padding: 6px 8px;
  border-radius: 8px;
  backdrop-filter: blur(4px) saturate(120%);
  pointer-events: none;
  user-select: none;
  box-shadow: 0 6px 20px rgba(6,8,18,0.6);
  border: 1px solid rgba(130,150,255,0.04);
}

/* Achievements button (fixed top-left) */
#open-achievements {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 10px 16px;
  font-size: 14px;
  background-color: #5a9ad1;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  z-index: 1000;
}
#open-achievements:hover { background-color: #4a86b8; }

/* === Achievements Panel === */
.achievements-panel {
  position: fixed;
  top: 56px;
  left: 12px;
  width: 360px;
  max-width: calc(100% - 24px);
  max-height: 70vh;
  background: linear-gradient(180deg, rgba(12,14,28,0.9), rgba(22,24,44,0.88));
  padding: 12px;
  border-radius: 12px;
  overflow: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,0.65);
  display: none;
  z-index: 1500;
  border: 1px solid rgba(120,150,255,0.04);
}
/*ask a professionaal what this code is & if it is efficient */
.achievements-panel.open { display: block; }
.achievements-panel h3 { margin: 6px 0 8px 0; font-size: 16px; }
.achievements-panel ul { list-style: none; padding: 0; margin: 0; }
.achievements-panel li { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 14px; }
.ach-item.unlocked { color: #bfe7a9; }
.ach-item.locked { color: #d0d0ff; opacity: 0.7; }
.ach-unlocked { font-style: italic; color: #9fd88a; margin-left: 8px; }
.ach-locked { font-style: italic; color: #b0b0ff; margin-left: 8px; }

/* Small close button in the panel */
.ach-close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: transparent;
  border: none;
  color: #ddd;
  font-size: 18px;
  cursor: pointer;
}

/* === Toasts / Notifications === */
#toast-container {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 2200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--toast-bg);
  color: #f7f9ff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(10,14,30,0.6);
  transform: translateY(-10px);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(.2,.9,.2,1), opacity 0.2s ease;
  pointer-events: auto;
  border-left: 3px solid var(--accent-1);
}
.toast.visible { transform: translateY(0); opacity: 1; }

/* Shop Button Hotfix: Absolute Positioning */
#shop-container button {
    position: relative; /* This allows the label to 'stick' to the button */
    padding-right: 60px; /* Makes room so text doesn't overlap the label */
    min-height: 50px;    /* Matches your original 'ideal' size */
    font-size: 0.9em;    
}

#shop-container {
  overflow-y: auto;       /* Enable vertical scrolling */
  overflow-x: hidden;     /* Prevent horizontal scroll */
  flex-grow: 1;           /* Take up remaining space in the panel */
  padding-right: 8px;     /* Space for the scrollbar */
  margin-top: 10px;
}

/* Optional: Make the scrollbar look nicer and fit the theme */
#shop-container::-webkit-scrollbar {
  width: 6px;
}
#shop-container::-webkit-scrollbar-thumb {
  background: var(--accent-1);
  border-radius: 10px;
}

.production-label {
    position: absolute;
    top: 5px;
    right: 10px;
    background: rgba(155, 124, 255, 0.652); /* Subtle purple glow */
    color: #000000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    pointer-events: none; /* Clicking the label still clicks the button */
}

/* Multi-Buy Toggle Styling */
.buy-toggle-container {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
  justify-content: center;
}

.buy-toggle {
  background: var(--panel-bg);
  border: 1px solid var(--accent-1);
  color: white;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s;
}

.buy-toggle.active {
  background: var(--accent-1);
  color: var(--bg-900);
  font-weight: bold;
  box-shadow: 0 0 10px var(--accent-1);

}


