/* ═══════════════════════════════════════════
   BookVibe — Styles
   Warm, bookish, premium aesthetic
   ═══════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────── */
:root {
  /* Warm parchment palette */
  --color-bg: #1a1410;
  --color-bg-warm: #231e18;
  --color-surface: #2d261e;
  --color-surface-hover: #3a3128;
  --color-border: #4a3f33;
  --color-border-light: #5c4f3f;

  /* Text */
  --color-text: #f0e6d6;
  --color-text-muted: #b8a990;
  --color-text-dim: #8a7b6a;

  /* Accent — amber / warm gold */
  --color-accent: #d4a647;
  --color-accent-light: #e8c56a;
  --color-accent-glow: rgba(212, 166, 71, 0.25);

  /* Feedback */
  --color-error: #e85d5d;
  --color-error-bg: rgba(232, 93, 93, 0.12);

  /* Fonts */
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

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

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 30px var(--color-accent-glow);

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Subtle background texture */
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(212, 166, 71, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(212, 166, 71, 0.03) 0%, transparent 50%);
}

/* ─── HEADER ─────────────────────────────── */
.header {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(180deg, var(--color-bg-warm) 0%, var(--color-bg) 100%);
}

.header__inner {
  max-width: 600px;
  margin: 0 auto;
}

.header__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.header__icon {
  width: 32px;
  height: 32px;
  color: var(--color-accent);
  filter: drop-shadow(0 0 6px var(--color-accent-glow));
}

.header__title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header__tagline {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--color-text-muted);
  font-style: italic;
  letter-spacing: 0.02em;
}

/* API Key Badge (header) */
.api-key-badge {
  margin-top: var(--space-sm);
  padding: 4px 12px;
  border: 1px solid rgba(212, 166, 71, 0.3);
  border-radius: var(--radius-pill);
  background: rgba(212, 166, 71, 0.08);
  color: var(--color-accent);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
}

.api-key-badge:hover {
  background: rgba(212, 166, 71, 0.15);
  border-color: var(--color-accent);
}

/* ─── API KEY SECTION ────────────────────── */
.api-key-section {
  max-width: 520px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}

.api-key-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  animation: results-in 0.5s var(--ease-out);
}

.api-key-card__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.api-key-card__desc {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: var(--space-lg);
}

.api-key-card__desc a {
  color: var(--color-accent);
  text-decoration: none;
}

.api-key-card__desc a:hover {
  text-decoration: underline;
}

.api-key-card__steps {
  text-align: left;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin: 0 auto var(--space-lg);
  max-width: 360px;
  padding-left: var(--space-lg);
  line-height: 1.8;
}

.api-key-card__steps a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.api-key-card__steps a:hover {
  text-decoration: underline;
}

/* Key Input */
.api-key-input-wrapper {
  position: relative;
  max-width: 420px;
  margin: 0 auto var(--space-lg);
}

.api-key-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  padding-right: 48px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-warm);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}

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

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

.api-key-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.api-key-toggle:hover {
  opacity: 1;
}

.api-key-card__note {
  margin-top: var(--space-md);
  font-size: 0.75rem;
  color: var(--color-text-dim);
  font-style: italic;
}

/* ─── MAIN ───────────────────────────────── */
.main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}

/* ─── MOOD SECTION ───────────────────────── */
.mood-section {
  text-align: center;
}

.mood-section__heading {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.mood-section__subtext {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-bottom: var(--space-xl);
}

/* Textarea */
.mood-input-wrapper {
  position: relative;
  max-width: 600px;
  margin: 0 auto var(--space-lg);
}

.mood-input {
  width: 100%;
  padding: var(--space-lg);
  padding-bottom: var(--space-xl);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}

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

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

.mood-input__counter {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 0.75rem;
  color: var(--color-text-dim);
  pointer-events: none;
}

/* Mood Chips */
.mood-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.mood-chip {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  white-space: nowrap;
}

.mood-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-light);
  background: rgba(212, 166, 71, 0.08);
  transform: translateY(-2px);
}

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

/* CTA Button */
.cta-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-accent) 0%, #c4922e 100%);
  color: #1a1410;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  box-shadow: 0 4px 20px rgba(212, 166, 71, 0.3);
  letter-spacing: 0.01em;
}

.cta-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(212, 166, 71, 0.45);
}

.cta-button:active {
  transform: translateY(-1px);
}

.cta-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.cta-button__sparkle {
  font-size: 1.2rem;
  display: inline-block;
  animation: sparkle-pulse 2s ease-in-out infinite;
}

@keyframes sparkle-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2) rotate(10deg);
  }
}

/* Error Message */
.error-message {
  max-width: 500px;
  margin: var(--space-lg) auto 0;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--color-error-bg);
  border: 1px solid rgba(232, 93, 93, 0.25);
  color: var(--color-error);
  font-size: 0.95rem;
  text-align: center;
  animation: shake 0.4s ease-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  15% {
    transform: translateX(-6px);
  }

  30% {
    transform: translateX(5px);
  }

  45% {
    transform: translateX(-4px);
  }

  60% {
    transform: translateX(3px);
  }

  75% {
    transform: translateX(-1px);
  }
}

/* ─── LOADING SECTION ────────────────────── */
.loading-section {
  text-align: center;
  padding: var(--space-xl) 0;
}

.loading-text {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--color-accent);
  margin-bottom: var(--space-xl);
  min-height: 1.8em;
  animation: text-fade 0.5s ease-in-out;
}

@keyframes text-fade {
  0% {
    opacity: 0;
    transform: translateY(4px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Skeleton Grid */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-lg);
}

.skeleton-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
}

.skeleton-cover {
  width: 100%;
  height: 200px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  background: linear-gradient(90deg,
      var(--color-surface) 0%,
      var(--color-surface-hover) 40%,
      var(--color-surface) 80%);
  background-size: 400% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  margin-bottom: var(--space-sm);
  background: linear-gradient(90deg,
      var(--color-surface) 0%,
      var(--color-surface-hover) 40%,
      var(--color-surface) 80%);
  background-size: 400% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skeleton-line.wide {
  width: 85%;
}

.skeleton-line.medium {
  width: 60%;
}

.skeleton-line.short {
  width: 40%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ─── RESULTS SECTION ────────────────────── */
.results-section {
  text-align: center;
  animation: results-in 0.6s var(--ease-out);
}

@keyframes results-in {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-section__heading {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: var(--space-xl);
  color: var(--color-text);
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

/* Book Card */
.book-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: left;
  transition: all 0.35s var(--ease-out);
  cursor: default;
  display: flex;
  flex-direction: column;
  animation: card-in 0.5s var(--ease-out) backwards;
}

/* Staggered card animation */
.book-card:nth-child(1) {
  animation-delay: 0.05s;
}

.book-card:nth-child(2) {
  animation-delay: 0.12s;
}

.book-card:nth-child(3) {
  animation-delay: 0.19s;
}

.book-card:nth-child(4) {
  animation-delay: 0.26s;
}

.book-card:nth-child(5) {
  animation-delay: 0.33s;
}

@keyframes card-in {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.book-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-border-light);
}

/* Cover Image */
.book-card__cover-wrapper {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-md);
  background: var(--color-bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease-out);
}

.book-card:hover .book-card__cover {
  transform: scale(1.04);
}

/* Placeholder cover */
.book-card__cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--color-text-dim);
  font-size: 0.8rem;
  gap: var(--space-sm);
  background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-bg-warm) 100%);
}

.book-card__cover-placeholder svg {
  width: 40px;
  height: 40px;
  opacity: 0.4;
}

/* Card Text */
.book-card__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  line-height: 1.3;
}

.book-card__author {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.book-card__year {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  margin-bottom: var(--space-sm);
}

/* Genre Badge */
.book-card__genre {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-accent-glow);
  color: var(--color-accent-light);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-md);
  align-self: flex-start;
}

/* Mood Match Quote */
.book-card__mood-match {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Reset Button */
.reset-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.reset-button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-light);
  background: rgba(212, 166, 71, 0.06);
  transform: translateY(-2px);
}

/* ─── FOOTER ─────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-dim);
  font-size: 0.85rem;
}

.footer strong {
  color: var(--color-text-muted);
  font-weight: 600;
}

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

  .mood-section__heading {
    font-size: 1.4rem;
  }

  .results-grid,
  .skeleton-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
  }

  .book-card__cover-wrapper {
    height: 180px;
  }
}

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

  .header__title {
    font-size: 1.7rem;
  }

  .mood-chips {
    gap: var(--space-xs);
  }

  .mood-chip {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  .results-grid,
  .skeleton-grid {
    grid-template-columns: 1fr;
  }
}