/*
 * MTG Card Alternatives - Fantasy Theme
 * Dark, mystical design inspired by Magic: The Gathering
 */

/* === ROOT VARIABLES === */
:root {
  --color-bg: #0a0a0f;
  --color-bg-secondary: #1a1a2e;
  --color-bg-card: #16213e;
  --color-accent: #c9a961;
  --color-accent-bright: #e6c87e;
  --color-text: #e8e8e8;
  --color-text-dim: #a8a8b8;
  --color-border: #2d3748;
  --color-success: #48bb78;
  --color-error: #f56565;

  --font-display: 'Cinzel', serif;
  --font-body: 'Roboto', sans-serif;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(201, 169, 97, 0.3);
}

/* === RESET & BASE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

/* === FANTASY BACKGROUND === */
.fantasy-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(88, 50, 120, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(120, 50, 88, 0.15) 0%, transparent 50%),
    linear-gradient(180deg, #0a0a0f 0%, #1a1a2e 100%);
  z-index: -1;
}

/* === TYPOGRAPHY === */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-accent-bright);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-accent-bright);
}

/* === LAYOUT === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* === HEADER === */
.site-header {
  background: rgba(26, 26, 46, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.site-header h1 {
  font-size: 1.75rem;
  margin: 0;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo {
  display: inline-block;
}

/* === MAIN CONTENT === */
.main-content {
  min-height: calc(100vh - 200px);
  padding: 2rem 0;
}

/* === HERO SECTION === */
.hero-section {
  text-align: center;
  padding: 4rem 0;
}

.hero-title {
  font-size: 3rem;
  margin-bottom: 1rem;
  text-shadow: var(--shadow-glow);
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--color-text-dim);
  margin-bottom: 3rem;
}

/* === SEARCH === */
.search-container {
  max-width: 600px;
  margin: 0 auto 2rem;
  position: relative;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 1rem 3.5rem 1rem 1.5rem;
  font-size: 1.125rem;
  font-family: var(--font-body);
  background: var(--color-bg-card);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}

.search-input::placeholder {
  color: var(--color-text-dim);
}

.search-icon {
  position: absolute;
  right: 1.25rem;
  font-size: 1.5rem;
  opacity: 0.7;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.search-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* === AUTOCOMPLETE === */
.autocomplete-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border: 2px solid var(--color-accent);
  border-radius: 12px;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: none;
}

.autocomplete-results.active {
  display: block;
}

.autocomplete-item {
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: rgba(201, 169, 97, 0.15);
}

.autocomplete-item-name {
  font-weight: 500;
  color: var(--color-text);
}

.autocomplete-loading,
.autocomplete-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-dim);
}

/* === SEARCH TIPS === */
.search-tips {
  margin-top: 1.5rem;
  color: var(--color-text-dim);
  font-size: 0.95rem;
}

/* === FEATURES SECTION === */
.features-section {
  padding: 4rem 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.feature-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--color-text-dim);
}

/* === CARD PAGE === */
.card-page {
  padding: 2rem 0;
}

.breadcrumb {
  margin-bottom: 2rem;
}

.back-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.back-link:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.card-header {
  text-align: center;
  margin-bottom: 3rem;
}

.card-name {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.alternatives-count {
  font-size: 1.125rem;
  color: var(--color-text-dim);
}

/* === CARDS GRID === */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}

.card-item {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

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

.card-image-wrapper {
  position: relative;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  background: var(--color-bg-secondary);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card-item:hover .card-image {
  transform: scale(1.05);
}

.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-dim);
  font-style: italic;
}

.price-badge {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  background: rgba(72, 187, 120, 0.95);
  color: var(--color-bg);
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.card-info {
  padding: 1.25rem;
}

.card-title {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
  color: var(--color-accent-bright);
}

.scryfall-link {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--color-accent);
  transition: color 0.2s ease;
}

.scryfall-link:hover {
  color: var(--color-accent-bright);
}

/* === ERROR PAGES === */
.error-page {
  text-align: center;
  padding: 4rem 0;
}

.error-page h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.error-page p {
  font-size: 1.125rem;
  color: var(--color-text-dim);
  margin-bottom: 2rem;
}

.no-results {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-dim);
  font-size: 1.125rem;
}

/* === FOOTER === */
.site-footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  text-align: center;
  margin-top: 4rem;
}

.site-footer p {
  color: var(--color-text-dim);
  font-size: 0.95rem;
}

.site-footer a {
  color: var(--color-accent);
}

/* === LEGAL PAGES === */
.legal-page {
  padding: 2rem 0;
}

.legal-page h1 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.legal-page h2 {
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--color-accent-bright);
}

.legal-content {
  max-width: 800px;
  margin: 0 auto 3rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2rem;
  line-height: 1.8;
}

.legal-content p {
  margin-bottom: 1rem;
}

.legal-content a {
  color: var(--color-accent);
  text-decoration: underline;
}

.legal-content a:hover {
  color: var(--color-accent-bright);
}

.legal-page .back-link {
  display: inline-block;
  margin: 0 auto;
  text-align: center;
}

/* === CARDS LIST (INDEX PAGE) === */
.cards-list {
  max-width: 800px;
  margin: 0 auto 3rem;
}

.letter-divider {
  font-size: 2rem;
  color: var(--color-accent-bright);
  border-bottom: 2px solid var(--color-accent);
  padding: 1rem 0 0.5rem;
  margin: 2rem 0 1rem;
  font-family: var(--font-display);
}

.card-list-item {
  padding: 0.75rem 1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}

.card-list-item:hover {
  border-color: var(--color-accent);
  background: rgba(201, 169, 97, 0.05);
  transform: translateX(4px);
}

.card-link {
  display: block;
  color: var(--color-text);
  font-size: 1.125rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.card-link:hover {
  color: var(--color-accent-bright);
}

/* === PAGINATION === */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin: 3rem 0;
}

.pagination {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  list-style: none;
  padding: 0;
}

.pagination a,
.pagination span {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  transition: all 0.2s ease;
  min-width: 40px;
  text-align: center;
}

.pagination a:hover {
  border-color: var(--color-accent);
  background: rgba(201, 169, 97, 0.1);
  color: var(--color-accent-bright);
}

.pagination .current {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
  font-weight: 700;
}

.pagination .disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination .prev,
.pagination .next {
  font-weight: 600;
}

.pagination .first,
.pagination .last {
  font-weight: 600;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
  }

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

  .card-name {
    font-size: 2rem;
  }

  .legal-content {
    padding: 1.5rem;
  }

  .legal-page h1 {
    font-size: 2rem;
  }
}
