/* Element Fusion - Game Styles
 * simpleboardgames.com
 * Vanilla CSS with glass-morphism design
 * MOBILE-FIRST REDESIGN
 */

/* ============================
   1. CSS Custom Properties
   ============================ */
:root {
  /* Game brand colors */
  --ef-hue: 32;
  --ef-primary: hsl(var(--ef-hue), 90%, 55%);
  --ef-primary-light: hsl(var(--ef-hue), 95%, 70%);
  --ef-primary-dark: hsl(var(--ef-hue), 85%, 45%);
  --ef-primary-glow: hsla(var(--ef-hue), 90%, 55%, 0.3);

  /* Category colors */
  --ef-nature: hsl(120, 60%, 50%);
  --ef-animals: hsl(30, 90%, 55%);
  --ef-plants: hsl(90, 60%, 50%);
  --ef-weather: hsl(200, 80%, 55%);
  --ef-civilization: hsl(280, 60%, 55%);
  --ef-technology: hsl(210, 40%, 55%);
  --ef-space: hsl(240, 70%, 60%);
  --ef-fantasy: hsl(330, 80%, 60%);

  /* Layout */
  --ef-sidebar-width: 280px;
  --ef-crafting-min-height: 400px;
  --ef-element-size: 60px;
  --ef-drop-zone-size: 100px;

  /* Glass effect */
  --ef-glass: rgba(30, 41, 59, 0.6);
  --ef-glass-border: rgba(255, 255, 255, 0.08);
  --ef-glass-blur: 16px;
}

/* ============================
   2. Game Container
   ============================ */
.game-container {
  background: var(--ef-glass);
  backdrop-filter: blur(var(--ef-glass-blur));
  border: 1px solid var(--ef-glass-border);
  border-radius: 32px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ============================
   3. Game Header
   ============================ */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.game-header h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  background: linear-gradient(135deg, var(--ef-primary), var(--ef-primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-icon {
  font-size: 2.5rem;
  margin-right: 12px;
  filter: drop-shadow(0 0 8px var(--ef-primary-glow));
}

/* ============================
   4. Progress Section
   ============================ */
.progress-section {
  margin-bottom: 24px;
}

.progress-bar-container {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-full);
  height: 12px;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ef-primary), var(--ef-primary-light));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

.progress-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.hint-points {
  background: var(--ef-glass);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* ============================
   5. Game Layout — MOBILE FIRST
   ============================ */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================
   6. Crafting Board — TOP on mobile
   ============================ */
.crafting-board {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  order: -1;
}

.crafting-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

.drop-zone {
  width: 110px;
  height: 110px;
  min-width: 110px;
  min-height: 110px;
  background: rgba(0, 0, 0, 0.3);
  border: 3px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}

.drop-zone.drag-over {
  border-color: var(--ef-primary);
  background: hsla(var(--ef-hue), 90%, 55%, 0.15);
  box-shadow: 0 0 24px var(--ef-primary-glow);
  transform: scale(1.05);
}

.drop-zone.filled {
  border-style: solid;
  border-color: var(--ef-primary);
  background: var(--ef-glass);
}

.drop-zone .emoji {
  font-size: 2.8rem;
}

.drop-placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.3;
}

.combine-indicator {
  font-size: 2.5rem;
  color: var(--ef-primary-light);
  font-weight: 700;
  text-shadow: 0 0 12px var(--ef-primary-glow);
}

.result-area {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================
   7. Result Element
   ============================ */
.result-element {
  text-align: center;
  animation: resultAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-element .emoji {
  font-size: 4rem;
  display: block;
  filter: drop-shadow(0 0 16px var(--ef-primary-glow));
}

.result-element .name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ef-primary-light);
  margin-top: 8px;
}

.result-element.new-discovery .emoji {
  animation: discoveryPulse 0.8s ease-in-out;
}

/* ============================
   8. Hint Button
   ============================ */
.hint-btn {
  background: var(--ef-glass);
  border: 1px solid var(--ef-glass-border);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  min-height: 48px;
}

.hint-btn:hover:not(:disabled) {
  background: var(--ef-primary-glow);
  border-color: var(--ef-primary);
  color: var(--text-primary);
}

.hint-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================
   9. Element Sidebar — BOTTOM on mobile
   ============================ */
.element-sidebar {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: none;
}

.search-box input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--ef-glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  min-height: 48px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--ef-primary);
  box-shadow: 0 0 0 3px var(--ef-primary-glow);
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-btn {
  padding: 8px 14px;
  min-height: 44px;
  min-width: 44px;
  background: var(--ef-glass);
  border: 1px solid var(--ef-glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-btn:hover {
  background: var(--ef-primary-glow);
  border-color: var(--ef-primary);
}

.cat-btn.active {
  background: var(--ef-primary);
  color: #000;
  font-weight: 600;
}

.element-list {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px;
  padding-right: 4px;
  max-height: 320px;
}

.element-list::-webkit-scrollbar {
  width: 6px;
}

.element-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.element-list::-webkit-scrollbar-thumb {
  background: var(--ef-primary-dark);
  border-radius: 3px;
}

/* ============================
   10. Element Cards — BIGGER for touch
   ============================ */
.element-card {
  width: 100%;
  aspect-ratio: 1;
  background: var(--ef-glass);
  border: 2px solid var(--ef-glass-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: var(--transition-bounce);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  gap: 2px;
}

.element-card:hover {
  transform: scale(1.08);
  border-color: var(--ef-primary);
  box-shadow: 0 0 16px var(--ef-primary-glow);
}

.element-card:active {
  cursor: grabbing;
  transform: scale(0.95);
}

.element-card.selected {
  border-color: var(--ef-primary);
  box-shadow: 0 0 20px var(--ef-primary-glow);
  background: hsla(var(--ef-hue), 90%, 55%, 0.2);
}

.element-card .emoji {
  font-size: 2rem;
  line-height: 1;
}

.element-card .name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  padding: 0 2px;
}

/* Category border colors */
.element-card[data-category="nature"] { border-left: 3px solid var(--ef-nature); }
.element-card[data-category="animals"] { border-left: 3px solid var(--ef-animals); }
.element-card[data-category="plants"] { border-left: 3px solid var(--ef-plants); }
.element-card[data-category="weather"] { border-left: 3px solid var(--ef-weather); }
.element-card[data-category="civilization"] { border-left: 3px solid var(--ef-civilization); }
.element-card[data-category="technology"] { border-left: 3px solid var(--ef-technology); }
.element-card[data-category="space"] { border-left: 3px solid var(--ef-space); }
.element-card[data-category="fantasy"] { border-left: 3px solid var(--ef-fantasy); }

/* ============================
   11. Discovery Feed
   ============================ */
.discovery-feed {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.discovery-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  animation: feedSlideIn 0.3s ease-out;
}

.discovery-item .emoji {
  font-size: 1.4rem;
}

/* ============================
   12. Discovery Popup (overlay)
   ============================ */
.discovery-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--bg-surface);
  border: 2px solid var(--ef-primary);
  border-radius: var(--radius-xl);
  padding: 32px 48px;
  text-align: center;
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  box-shadow: 0 0 60px var(--ef-primary-glow);
}

.discovery-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.discovery-popup .discovery-icon {
  font-size: 5rem;
  margin-bottom: 12px;
}

.discovery-popup .discovery-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.discovery-popup .discovery-category {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============================
   13. Milestone Modal
   ============================ */
.milestone-content {
  text-align: center;
}

.milestone-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: bounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ============================
   14. Drag Ghost (follows cursor during drag)
   ============================ */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  width: 70px;
  height: 70px;
  background: var(--ef-glass);
  border: 2px solid var(--ef-primary);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 24px var(--ef-primary-glow);
  transform: scale(1.1);
  opacity: 0.9;
}

.drag-ghost .emoji {
  font-size: 2rem;
}

.drag-ghost .name {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ============================
   15. Animations
   ============================ */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes resultAppear {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes discoveryPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes feedSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes confetti {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) rotate(720deg);
  }
}

/* ============================
   16. Failure Animation
   ============================ */
.combination-failed .drop-zone {
  animation: shake 0.4s ease-in-out;
  border-color: var(--coral);
  background: hsla(0, 75%, 55%, 0.1);
}

.combination-failed .combine-indicator {
  color: var(--coral);
}

/* ============================
   17. Light Mode Override
   ============================ */
@media (prefers-color-scheme: light) {
  .game-container {
    --ef-glass: rgba(255, 255, 255, 0.8);
    --ef-glass-border: rgba(0, 0, 0, 0.1);
    background: var(--ef-glass);
    color: #1a1a2e;
  }

  .element-sidebar {
    background: rgba(0, 0, 0, 0.05);
  }

  .element-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
  }

  .drop-zone {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
  }

  .search-box input {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
  }

  .cat-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #555;
  }

  .progress-bar-container {
    background: rgba(0, 0, 0, 0.1);
  }

  .stats-row {
    color: #555;
  }

  .hint-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #555;
  }

  .discovery-feed .discovery-item {
    background: rgba(0, 0, 0, 0.05);
  }

  .discovery-popup {
    background: #fff;
    color: #1a1a2e;
  }
}

/* ============================
   18. DESKTOP — ≥768px
   ============================ */
@media (min-width: 769px) {
  .game-layout {
    display: grid;
    grid-template-columns: var(--ef-sidebar-width) 1fr;
    gap: 24px;
    min-height: var(--ef-crafting-min-height);
  }

  .crafting-board {
    order: 0;
  }

  .element-sidebar {
    max-height: 600px;
  }

  .element-list {
    grid-template-columns: repeat(auto-fill, minmax(var(--ef-element-size), 1fr));
    max-height: none;
  }

  .element-card .emoji {
    font-size: 1.8rem;
  }

  .element-card .name {
    font-size: 0.75rem;
  }

  .drop-zone {
    width: var(--ef-drop-zone-size);
    height: var(--ef-drop-zone-size);
    min-width: var(--ef-drop-zone-size);
    min-height: var(--ef-drop-zone-size);
  }

  .drop-zone .emoji {
    font-size: 2.5rem;
  }
}

/* ============================
   19. TABLET — 481px–768px
   ============================ */
@media (min-width: 481px) and (max-width: 768px) {
  .game-container {
    padding: 20px;
    border-radius: 28px;
  }

  .game-header h1 {
    font-size: 1.6rem;
  }

  .drop-zone {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
  }

  .drop-zone .emoji {
    font-size: 3rem;
  }

  .element-list {
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    max-height: 400px;
  }

  .element-card .emoji {
    font-size: 2.2rem;
  }
}

/* ============================
   20. SMALL MOBILE — ≤480px
   ============================ */
@media (max-width: 480px) {
  .game-container {
    padding: 12px;
    border-radius: 16px;
    border-radius: 20px;
  }

  .game-header {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    margin-bottom: 12px;
  }

  .game-header h1 {
    font-size: 1.4rem;
  }

  .game-icon {
    font-size: 1.8rem;
    margin-right: 8px;
  }

  .progress-section {
    margin-bottom: 12px;
  }

  .crafting-board {
    padding: 16px 12px;
    gap: 12px;
  }

  .crafting-area {
    gap: 12px;
  }

  .drop-zone {
    width: 90px;
    height: 90px;
    min-width: 90px;
    min-height: 90px;
  }

  .drop-zone .emoji {
    font-size: 2.2rem;
  }

  .drop-placeholder {
    font-size: 0.75rem;
  }

  .combine-indicator {
    font-size: 2rem;
  }

  .result-element .emoji {
    font-size: 3rem;
  }

  .result-element .name {
    font-size: 1rem;
  }

  .element-list {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    max-height: 260px;
  }

  .element-card .emoji {
    font-size: 1.6rem;
  }

  .element-card .name {
    font-size: 0.75rem;
  }

  .category-filters {
    gap: 6px;
  }

  .cat-btn {
    padding: 6px 10px;
    min-height: 40px;
    font-size: 0.8rem;
  }

  .hint-btn {
    padding: 10px 18px;
    font-size: 0.85rem;
  }

  .discovery-popup {
    padding: 20px 24px;
    width: calc(100% - 32px);
  }

  .discovery-popup .discovery-icon {
    font-size: 3.5rem;
  }

  .discovery-popup .discovery-name {
    font-size: 1.2rem;
  }
}

/* ============================
   21. Hidden Class
   ============================ */
.hidden {
  display: none !important;
}

/* ============================
   22. Reduced Motion
   ============================ */
@media (prefers-reduced-motion: reduce) {
  .game-container,
  .result-element,
  .discovery-popup,
  .discovery-item,
  .milestone-icon,
  .element-card {
    animation: none !important;
    transition: none !important;
  }
}
