/* ============================================================
   THE PAIRING ROOM — Design System & Styles
   ============================================================ */

/* --- Design Tokens --- */
:root {
  /* Colors */
  --bg-primary: #0d0a0f;
  --bg-secondary: #15111a;
  --bg-card: rgba(13, 10, 15, 0.55);
  --bg-card-hover: rgba(13, 10, 15, 0.65);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --bg-glass-border: rgba(255, 255, 255, 0.1);

  --wine-red: #8B2252;
  --wine-red-glow: rgba(139, 34, 82, 0.4);
  --wine-burgundy: #722F37;
  --wine-light: #c75b8e;

  --gold: #C9A96E;
  --gold-light: #e0c98f;
  --gold-glow: rgba(201, 169, 110, 0.3);

  --text-primary: #F2EDE8;
  --text-secondary: rgba(242, 237, 232, 0.6);
  --text-muted: rgba(242, 237, 232, 0.35);

  --accent-blue: #5B8FC9;
  --accent-green: #6EAA7C;
  --accent-amber: #D4A853;

  /* Typography */
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

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

  /* Borders & Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 200ms;
  --duration-normal: 350ms;
  --duration-slow: 600ms;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: radial-gradient(circle at center, #15111a 0%, #0d0a0f 100%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}

/* --- Ambient Background --- */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  transform: translateZ(0);
  will-change: transform;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.35;
  animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: var(--wine-red);
  top: -10%;
  left: -5%;
  animation-delay: 0s;
  opacity: 0.45;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--gold);
  top: 50%;
  right: -8%;
  animation-delay: -7s;
  opacity: 0.3;
}

.orb-3 {
  width: 450px;
  height: 450px;
  background: var(--wine-burgundy);
  bottom: -5%;
  left: 30%;
  animation-delay: -14s;
  opacity: 0.35;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Hero --- */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-3xl) var(--space-xl) var(--space-xl);
}

.hero-content {
  max-width: 700px;
  margin: 0 auto;
}

.hero-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-md);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.2s forwards;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  padding-bottom: 0.05em;
  background: linear-gradient(135deg, var(--text-primary) 0%, #e8d6b3 25%, var(--gold) 50%, #b37a90 75%, var(--wine-light) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  image-rendering: auto;
  animation: fadeInUp 0.8s var(--ease-out) 0.4s forwards, shimmer 8s ease-in-out infinite;
  opacity: 0;
}

.hero-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-secondary);
  margin-top: var(--space-md);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.6s forwards;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Main Container --- */
.main-container {
  position: relative;
  z-index: 10;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-xl) var(--space-3xl);
}

/* --- Mode Toggle --- */
.mode-toggle-wrapper {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-2xl);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.8s forwards;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.mode-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--wine-red) 0%, #7e2844 50%, var(--wine-burgundy) 100%);
  color: var(--text-primary);
  border-color: var(--wine-light);
  box-shadow: 0 4px 20px var(--wine-red-glow);
  image-rendering: auto;
}

.mode-icon {
  font-size: 1.2rem;
}

.mode-label {
  pointer-events: none;
}

/* --- Search Section --- */
.search-section {
  position: relative;
  z-index: 50;
  margin-bottom: var(--space-xl);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 1s forwards;
}

.search-container {
  position: relative;
}

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

.search-icon {
  position: absolute;
  left: var(--space-lg);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: color var(--duration-fast) ease;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-lg) var(--space-lg) var(--space-lg) 3.25rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all var(--duration-normal) var(--ease-out);
}

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

.search-input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow), 0 8px 32px rgba(0, 0, 0, 0.3);
}

.search-input:focus ~ .search-icon,
.search-input:focus + .search-icon {
  color: var(--gold);
}

.search-input-wrapper:focus-within .search-icon {
  color: var(--gold);
}

.clear-btn {
  position: absolute;
  right: var(--space-md);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.clear-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.15);
}

.search-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* --- Autocomplete Dropdown --- */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(20, 16, 28, 1);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  max-height: calc(100vh - 300px);
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  animation: dropdownOpen var(--duration-fast) var(--ease-out);
}

@keyframes dropdownOpen {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: background var(--duration-fast) ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.autocomplete-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.autocomplete-item.highlighted {
  background: var(--gold);
}

.autocomplete-item.highlighted .autocomplete-item-name,
.autocomplete-item.highlighted .autocomplete-item-detail {
  color: var(--bg-dark);
}

.autocomplete-item.highlighted mark {
  color: #000 !important;
}

.autocomplete-item-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.autocomplete-item-info {
  flex: 1;
  min-width: 0;
}

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

.autocomplete-item-name mark,
.autocomplete-item-detail mark {
  background: none;
  color: var(--gold);
  font-weight: 600;
}

.autocomplete-item-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Quick Picks --- */
.quick-picks {
  text-align: center;
  margin-bottom: var(--space-2xl);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 1.2s forwards;
}

.quick-picks-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.quick-picks-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
}

.quick-tag {
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
}

.quick-tag:hover {
  color: var(--gold-light);
  border-color: var(--gold);
  background: rgba(201, 169, 110, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--gold-glow);
}

/* --- Results Section --- */
.results-section {
  animation: fadeInUp var(--duration-slow) var(--ease-out);
}

.results-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.results-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.results-profile {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.results-profile .region-tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gold);
  background: rgba(201, 169, 110, 0.12);
  border: 1px solid rgba(201, 169, 110, 0.2);
  border-radius: var(--radius-full);
  margin-left: var(--space-sm);
  vertical-align: middle;
}

.results-profile .type-tag {
  display: inline;
  font-size: 0.78rem;
  font-weight: 400;
  font-style: italic;
  margin-left: var(--space-xs);
  border: none !important;
  background: none !important;
  padding: 0;
}

/* Type colors — text-only, no pill backgrounds */
.type-tag.red { color: #e87070; }
.type-tag.white { color: #e0d48a; }
.type-tag.rosé { color: #e8a0b0; }
.type-tag.sparkling { color: #a0d4e8; }
.type-tag.dessert { color: #d4a0e8; }
.type-tag.fortified { color: #c4a070; }
.type-tag.hard { color: #d4a853; }
.type-tag.soft { color: #f0e0c0; }
.type-tag.semi-soft { color: #e0c898; }
.type-tag.semi-hard { color: #c8b080; }
.type-tag.blue { color: #8090d0; }
.type-tag.fresh { color: #90d890; }
.type-tag.cured { color: #d48a7a; }
.type-tag.smoked { color: #c89870; }
.type-tag.roasted { color: #d4a070; }
.type-tag.grilled { color: #e09060; }
.type-tag.raw { color: #e0a0a0; }
.type-tag.charcuterie { color: #c87878; }
.type-tag.poultry { color: #d4b888; }
.type-tag.game { color: #a08870; }
.type-tag.seafood { color: #88b8d0; }
.type-tag.pâté { color: #b89888; }

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 1.1s forwards;
}

.filter-bar-label {
  width: 100%;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.filter-chip {
  padding: 3px 12px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
}

.filter-chip:hover {
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

.filter-chip.active {
  color: var(--gold-light);
  border-color: var(--gold);
  background: rgba(201, 169, 110, 0.12);
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* --- Pairing Card --- */
.pairing-card {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: all var(--duration-normal) var(--ease-out);
  opacity: 0;
  transform: translateY(16px);
  animation: cardReveal var(--duration-slow) var(--ease-out) forwards;
}

.pairing-card:nth-child(1) { animation-delay: 0.05s; }
.pairing-card:nth-child(2) { animation-delay: 0.15s; }
.pairing-card:nth-child(3) { animation-delay: 0.25s; }
.pairing-card:nth-child(4) { animation-delay: 0.35s; }
.pairing-card:nth-child(5) { animation-delay: 0.45s; }

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

.pairing-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.card-title-section {
  flex: 1;
}

.card-emoji {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.card-origin {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-type-badge {
  display: inline;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
  border: none;
  background: none;
  margin-top: 2px;
}

.card-section {
  margin-bottom: var(--space-lg);
}

.card-section:last-child {
  margin-bottom: 0;
}

.card-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.card-explanation {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.card-profile {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.6;
  padding-left: var(--space-md);
  border-left: 2px solid rgba(201, 169, 110, 0.3);
}

/* --- Appetizer Tags --- */
.appetizer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.appetizer-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) ease;
}

.appetizer-tag:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

/* --- Match Score Bar --- */
.match-bar-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.match-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.match-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.match-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--wine-red) 0%, #a6655c 50%, var(--gold) 100%);
  image-rendering: auto;
  transition: width 1s var(--ease-out);
  width: 0;
}

.match-score {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  min-width: 28px;
  text-align: right;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  animation: fadeInUp var(--duration-slow) var(--ease-out);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.empty-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .main-container {
    padding: 0 var(--space-md) var(--space-2xl);
  }

  .hero {
    padding: var(--space-xl) var(--space-md) var(--space-sm);
  }

  .hero-title {
    font-size: 2.2rem;
  }

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

  .mode-toggle-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: var(--space-lg);
  }

  .mode-btn {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.75rem;
    gap: 4px;
  }

  .mode-icon {
    font-size: 0.9rem;
  }

  .search-input {
    padding: var(--space-md) var(--space-md) var(--space-md) 2.75rem;
    font-size: 16px;
  }

  .hero {
    padding: var(--space-xl) var(--space-md) var(--space-md);
  }

  .main-container {
    padding: 0 var(--space-md) var(--space-xl);
  }

  .results-grid {
    gap: var(--space-xl);
  }

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

  .card-header {
    flex-direction: column;
  }

  .card-emoji {
    order: -1;
  }

  .quick-picks-tags {
    gap: var(--space-xs);
  }
}

/* --- Loading Overlay --- */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-dark);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.loading-text {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  animation: pulseLoading 1.5s infinite ease-in-out;
}

@keyframes pulseLoading {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
