@import 'variables.css';
@import 'themes.css';
@import 'intro.css';

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-core);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Utilities */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-gradient {
  background: linear-gradient(135deg, var(--accent-diamond), var(--accent-emerald));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Glassmorphism Card */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: var(--space-md);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(80, 227, 194, 0.1);
  border-color: rgba(80, 227, 194, 0.2);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent-diamond);
  color: var(--bg-core);
}

.btn-primary:hover {
  background: #3fd1b3;
  box-shadow: 0 0 15px rgba(80, 227, 194, 0.4);
}

/* Search Dropdown */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.search-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
  text-decoration: none;
  color: var(--text-primary);
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover,
.search-item:active {
  background: rgba(255,255,255,0.05);
}

.search-item-cat {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}


/* Crafting Table Slots */
.craft-slot {
  width: 50px;
  height: 50px;
  background: #3a3a3a;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: bold;
  transition: all 0.2s;
}

.craft-slot:hover {
  background: #4a4a4a;
  border-color: rgba(255,255,255,0.3);
}

.craft-slot.filled {
  background: #4a4a4a;
  border-color: var(--accent-diamond);
}

/* Fun Fact Bar */
.fun-fact-bar {
  margin-top: 30px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(80, 227, 194, 0.08), rgba(139, 92, 246, 0.08));
  border: 1px solid transparent;
  border-radius: 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.fun-fact-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(135deg, var(--accent-diamond), var(--accent-emerald), #8b5cf6);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.fun-fact-icon {
  font-size: 1.8rem;
  animation: pulse-glow 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-glow {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(80, 227, 194, 0.3));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(80, 227, 194, 0.6));
    transform: scale(1.1);
  }
}

.fun-fact-content {
  flex: 1;
}

.fun-fact-content p {
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0;
}

/* Filter Chips */
.filter-chip:hover,
.filter-chip:active {
  background: rgba(80, 227, 194, 0.1) !important;
  border-color: var(--accent-diamond) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.filter-chip:active {
  transform: translateY(0);
}


/* 3D Block Viewer */
.item-3d-container {
    perspective: 1000px;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cube {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-30deg) rotateY(45deg);
    animation: rotate-cube 10s infinite linear;
    transition: transform 0.5s ease;
}

.cube:hover {
    animation-play-state: paused;
}

.face {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 1px solid rgba(0,0,0,0.2);
    background-size: cover;
    image-rendering: pixelated;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--accent-diamond);
    background-color: rgba(255,255,255,0.05);
}

.front  { transform: rotateY(  0deg) translateZ(60px); }
.right  { transform: rotateY( 90deg) translateZ(60px); }
.back   { transform: rotateY(180deg) translateZ(60px); }
.left   { transform: rotateY(-90deg) translateZ(60px); }
.top    { transform: rotateX( 90deg) translateZ(60px); }
.bottom { transform: rotateX(-90deg) translateZ(60px); }


/* Layout Classes */
.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 40px;
}

.hero-search-container {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

/* ============================================
   MOBILE STYLES — Single clean @media block
   ============================================ */
@media (max-width: 768px) {

  /* --- Layout --- */
  .container {
    padding: 0 16px;
  }

  /* --- Typography --- */
  /* Hero h1 on index page */
  header h1 {
    font-size: 2.2rem !important;
  }

  /* Detail page h1 */
  #item-title {
    font-size: 2rem !important;
  }

  h2 {
    font-size: 1.3rem;
  }

  /* --- Smaller search input font to prevent iOS auto-zoom --- */
  input[type="text"] {
    font-size: 16px !important; /* 16px prevents iOS zoom-on-focus */
  }

  /* --- Navigation --- */
  .nav-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }

  .nav-links {
    justify-content: center;
    gap: 8px;
  }

  /* Remove all the margin-left values baked into inline styles */
  .nav-links a {
    margin-left: 0 !important;
    font-size: 0.9rem;
  }

  .nav-links button {
    margin-right: 0 !important;
  }

  /* Theme switcher in nav */
  .theme-switcher {
    margin-left: 0 !important;
    margin-top: 4px;
  }

  /* --- Hero Section --- */
  header {
    padding: 32px 0 !important;
  }

  header p {
    font-size: 1rem !important;
    padding: 0 8px;
  }

  /* Hero buttons stack */
  .hero-buttons {
    flex-direction: column !important;
    align-items: center !important;
  }

  .hero-buttons .btn-primary,
  .hero-buttons .filter-chip {
    width: 100%;
    max-width: 320px;
  }

  /* Filter chips row wraps nicely */
  .hero-search-container > div:last-child {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* --- Search Dropdown --- */
  /* On mobile, keep it absolute within its container (not fixed) */
  .search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 50vh;
    width: 100%;
  }

  /* --- Category Cards (Index) --- */
  section .glass-card {
    margin-bottom: 16px;
  }

  /* --- Detail Page Grid: stack to single column --- */
  .content-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Reorder: on mobile show sidebar (image) FIRST */
  .content-grid > div:last-child {
    order: -1;
  }

  /* --- 3D Container / Item Image --- */
  .item-3d-container {
    width: 100% !important;
    height: 240px !important;
    margin: 0 auto !important;
  }

  /* Detail: glass card padding */
  .glass-card {
    padding: 16px !important;
  }

  /* Detail page main glass card title */
  .glass-card h1 {
    font-size: 1.8rem !important;
  }

  /* --- Crafting Table: pull out of fixed, make inline --- */
  #crafting-table {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    margin-top: 24px !important;
    box-shadow: none !important;
    z-index: 1 !important;
  }

  /* --- Fun Fact bar --- */
  .fun-fact-bar {
    padding: 14px 16px;
    gap: 10px;
  }

  .fun-fact-icon {
    font-size: 1.4rem;
  }

  /* --- Breadcrumb --- */
  #item-category,
  #item-name-crumb {
    font-size: 0.85rem;
  }

  /* --- Action Buttons on detail page --- */
  .btn {
    font-size: 0.95rem;
    padding: 0.75rem 1.2rem;
    touch-action: manipulation;
  }

  /* Prevent double-tap zoom on buttons and links */
  a, button, .filter-chip, .search-item, .glass-card {
    touch-action: manipulation;
  }
}

/* Extra small screens */
@media (max-width: 400px) {
  header h1 {
    font-size: 1.8rem !important;
  }

  .intro-logo {
    font-size: 2.4rem !important;
  }
}
