/* ========================================
   Dice Throne Reference App - Styles
   ======================================== */

/* === CSS Custom Properties === */
:root {
  /* Colors - Rich, vibrant palette */
  --color-bg-primary: hsl(220, 20%, 8%);
  --color-bg-secondary: hsl(220, 18%, 12%);
  --color-bg-card: hsl(220, 16%, 14%);
  --color-bg-hover: hsl(220, 16%, 18%);

  --color-accent-primary: hsl(280, 85%, 60%);
  --color-accent-secondary: hsl(200, 90%, 55%);
  --color-accent-gradient: linear-gradient(135deg, hsl(280, 85%, 60%), hsl(200, 90%, 55%));

  --color-text-primary: hsl(0, 0%, 95%);
  --color-text-secondary: hsl(0, 0%, 70%);
  --color-text-muted: hsl(0, 0%, 50%);

  /* Hero colors */
  --hero-scarlet-witch: hsl(350, 85%, 55%);
  --hero-thor: hsl(210, 80%, 55%);
  --hero-loki: hsl(120, 65%, 45%);
  --hero-spider-man: hsl(355, 85%, 50%);

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 3rem;

  /* Border radius */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(130, 80, 255, 0.3);
}

/* === Google Fonts Import === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* === Base Styles === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(20, 23, 33, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--space-md) var(--space-lg);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: var(--font-size-xl);
  font-weight: 800;
  background: var(--color-accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.back-btn {
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: all var(--transition-base);
  font-size: var(--font-size-sm);
}

.back-btn:hover {
  background: var(--color-bg-hover);
  transform: translateX(-4px);
}

/* === Container === */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* === Home View === */
.home-view {
  display: block;
}

.home-view.hidden {
  display: none;
}

.page-title {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  text-align: center;
  margin-bottom: var(--space-2xl);
  letter-spacing: -1px;
}

.page-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  text-align: center;
  margin-top: calc(var(--space-md) * -1);
  margin-bottom: var(--space-xl);
}

/* === Hero Grid === */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.hero-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--hero-color);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.hero-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--hero-color);
}

.hero-card:hover::before {
  opacity: 1;
}

.hero-card[data-hero="scarlet-witch"] {
  --hero-color: var(--hero-scarlet-witch);
}

.hero-card[data-hero="thor"] {
  --hero-color: var(--hero-thor);
}

.hero-card[data-hero="loki"] {
  --hero-color: var(--hero-loki);
}

.hero-card[data-hero="spider-man"] {
  --hero-color: var(--hero-spider-man);
}

.hero-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
  border-radius: 50%;
  background: var(--color-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  border: 3px solid var(--hero-color);
  box-shadow: 0 0 20px rgba(var(--hero-color-rgb), 0.3);
}

.hero-name {
  font-size: var(--font-size-xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-xs);
}

.hero-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  text-align: center;
}

/* === Hero Detail View === */
.hero-detail-view {
  display: none;
}

.hero-detail-view.active {
  display: block;
}

.hero-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.hero-title {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  margin-bottom: var(--space-sm);
  letter-spacing: -1px;
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
}

.tab-btn {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: all var(--transition-base);
  white-space: nowrap;
  font-size: var(--font-size-base);
  border: 2px solid transparent;
}

.tab-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.tab-btn.active {
  background: var(--color-accent-primary);
  color: white;
  border-color: var(--color-accent-primary);
  box-shadow: var(--shadow-glow);
}

/* === Tab Content === */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn var(--transition-base);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Board Viewer === */
.board-container {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
}

.board-image {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* === Cards Gallery === */
.cards-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
}

.card-item {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-base);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-sm);
  aspect-ratio: 63 / 88;
}

.card-item:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(130, 80, 255, 0.3);
}

.card-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* === Dice Display === */
.dice-container {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-md);
}

.dice-image {
  max-width: 600px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* === Leaflets Display === */
.leaflets-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-lg);
}

.leaflet-item {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-md);
}

.leaflet-item img {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* === Lightbox === */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  overflow: auto;
}

.lightbox.active {
  display: flex;
  animation: fadeIn var(--transition-base);
}

.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  position: relative;
  touch-action: pinch-zoom;
  overflow: auto;
}

.lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  touch-action: pinch-zoom;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: var(--color-accent-primary);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: 700;
  transition: all var(--transition-base);
}

.lightbox-close:hover {
  background: var(--color-accent-secondary);
  transform: rotate(90deg);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: 700;
  transition: all var(--transition-base);
}

.lightbox-nav:hover {
  background: var(--color-accent-primary);
}

.lightbox-prev {
  left: -70px;
}

.lightbox-next {
  right: -70px;
}

/* === Utility Classes === */
.hidden {
  display: none !important;
}

/* === Responsive Design === */
@media (max-width: 768px) {
  :root {
    --font-size-3xl: 2rem;
    --font-size-2xl: 1.5rem;
    --space-xl: 2rem;
  }

  .container {
    padding: var(--space-lg) var(--space-md);
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .cards-gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-sm);
  }

  .leaflets-container {
    grid-template-columns: 1fr;
  }

  .lightbox-nav {
    display: none;
  }

  .board-container,
  .dice-container,
  .leaflet-item {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  .header {
    padding: var(--space-sm) var(--space-md);
  }

  .logo {
    font-size: var(--font-size-lg);
  }

  .cards-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}