/* ==========================================================================
   MoodQuote - Stylesheet (Neutral Default State)
   ========================================================================== */

/* Registered so the atmospheric background can transition between mood colors.
   Initial value matches the default --accent-color (--border-light). */
@property --glow {
  syntax: "<color>";
  inherits: true;
  initial-value: #e2e8f0;
}

/* --------------------------------------------------------------------------
   1. Design Tokens & CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Neutral Color Palette */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-glass: rgba(255, 255, 255, 0.85);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-light: #e2e8f0;
  --border-subtle: #f1f5f9;
  
  /* Neutral Theme Accents (Before Mood Selection) */
  --theme-accent: #64748b;
  --theme-accent-soft: rgba(100, 116, 139, 0.08);
  --theme-border: #cbd5e1;
  --accent-color: var(--border-light);
  
  /* Mood Button Default State */
  --btn-bg: #ffffff;
  --btn-border: #e2e8f0;
  --btn-text: #334155;
  --btn-hover-bg: #f1f5f9;
  
  /* Disabled State Tokens */
  --btn-disabled-bg: #e2e8f0;
  --btn-disabled-text: #94a3b8;
  --btn-disabled-border: #cbd5e1;
  
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  
  /* Shadows & Elevation */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 20px 40px -15px rgba(15, 23, 42, 0.08);
  
  /* Border Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   2. Reset & Global Styles
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
  background-color: transparent;
}

/* Atmospheric mood-reactive background layer.
   html holds the solid light base; this fixed pseudo-element paints the
   gradients behind all content without affecting layout or input. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg-main);
  --glow: var(--accent-color);
  transition: --glow 0.6s ease;
  background-image:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--glow) 14%, white) 0%, transparent 55%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--glow) 14%, white) 0%, transparent 55%);
}

/* Static abstract contour line art. Same asset for every mood.
   Paints above the mood gradients (::after follows ::before at the same
   z-index) and below all content. Decorative only. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("contours.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   3. Main Layout Container
   -------------------------------------------------------------------------- */
.app-container {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   4. Header Component
   -------------------------------------------------------------------------- */
.app-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo-badge {
  width: 48px;
  height: 48px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

.app-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.app-tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   5. Mood Selector Component
   -------------------------------------------------------------------------- */
.mood-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Mood question is slightly more prominent than other section titles */
.mood-section .section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.mood-buttons-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 520px) {
  .mood-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mood-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  min-height: 44px;
  background-color: var(--btn-bg);
  border: 1.5px solid var(--btn-border);
  border-radius: var(--radius-md);
  color: var(--btn-text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  user-select: none;
}

/* Hover: each button responds with its own mood color (single reusable rule) */
.mood-btn:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--mood-color, var(--theme-accent)) 12%, var(--btn-bg));
  border-color: var(--mood-color, var(--theme-accent));
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Selected (persistent): strongest indicator, wins over hover */
.mood-btn.is-selected {
  background-color: color-mix(in srgb, var(--mood-color, var(--theme-accent)) 22%, var(--btn-bg));
  border-color: var(--mood-color, var(--theme-accent));
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
}

/* Selected + hover: keep the selected look so hover never fades it */
.mood-btn.is-selected:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--mood-color, var(--theme-accent)) 26%, var(--btn-bg));
  border-color: var(--mood-color, var(--theme-accent));
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.mood-btn:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.mood-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   6. Quote Display Container & Welcome State
   -------------------------------------------------------------------------- */
.quote-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.quote-card {
  width: 100%;
  min-height: 240px;
  background-color: var(--bg-card);
  border: 1.5px solid var(--accent-color);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
}

/* Mood-derived tint on the card while a mood is selected.
   --accent-color holds the selected mood's primary color, so the tint
   always comes from moodData without duplicating colors. */
.has-mood .quote-card {
  background-color: color-mix(in srgb, var(--accent-color) 12%, var(--bg-card));
}

/* Neutral Welcome State (First Load) */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 16px 0;
}

.welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background-color: var(--theme-accent-soft);
  color: var(--theme-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 1px dashed var(--theme-border);
}

.welcome-message {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  overflow-wrap: break-word;
  word-break: break-word;
}

.quote-author {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* --------------------------------------------------------------------------
   7. Action Controls (New Quote Button - Visually Disabled)
   -------------------------------------------------------------------------- */
.controls-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.btn-new-quote {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
}

.btn-new-quote:not(:disabled) {
  background-color: var(--accent-color);
  color: var(--text-primary);
  border-color: var(--accent-color);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

/* Hover feedback while enabled */
.btn-new-quote:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  filter: brightness(1.06);
}

/* Pressed feedback while enabled */
.btn-new-quote:not(:disabled):active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-sm);
  filter: brightness(0.95);
}

.btn-new-quote:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

/* Disabled/Inactive State Style */
.btn-new-quote:disabled,
.btn-new-quote[disabled] {
  background-color: var(--btn-disabled-bg);
  color: var(--btn-disabled-text);
  border-color: var(--btn-disabled-border);
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
  transform: none;
}

.btn-icon {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   7b. Favorite Button
   -------------------------------------------------------------------------- */
.btn-favorite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
}

.btn-favorite:not(:disabled) {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-light);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-favorite:not(:disabled):hover {
  border-color: var(--theme-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Saved/favorited state: filled heart in a rose tone */
.btn-favorite.is-favorite:not(:disabled) {
  color: #e11d48;
  border-color: rgba(225, 29, 72, 0.35);
}

.btn-favorite.is-favorite:not(:disabled) .heart-icon {
  fill: currentColor;
}

.btn-favorite:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.btn-favorite:disabled,
.btn-favorite[disabled] {
  background-color: var(--btn-disabled-bg);
  color: var(--btn-disabled-text);
  border-color: var(--btn-disabled-border);
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
  transform: none;
}

/* --------------------------------------------------------------------------
   7c. Saved Quotes Section
   -------------------------------------------------------------------------- */
.saved-quotes-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.saved-quotes-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-quotes-empty {
  width: 100%;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  background-color: var(--bg-card);
  border: 1.5px dashed var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px 16px;
}

.saved-quote-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-left: 4px solid var(--item-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.saved-quote-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.saved-quote-mood {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--item-color);
}

.saved-quote-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: break-word;
}

.saved-quote-author {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 2px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.saved-quote-remove {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  background-color: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.saved-quote-remove:hover {
  border-color: var(--theme-accent);
  color: var(--text-primary);
}

.saved-quote-remove:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   8. Responsive Media Queries (<480px & <360px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .quote-card {
    padding: 32px 20px;
    min-height: 200px;
  }
}

@media (max-width: 360px) {
  .mood-buttons-grid {
    gap: 8px;
  }

  .mood-btn {
    padding: 10px 8px;
    font-size: 0.875rem;
  }

  .app-container {
    gap: 24px;
  }

  .btn-favorite {
    padding: 10px 14px;
  }
}

/* --------------------------------------------------------------------------
   9. Footer Component
   -------------------------------------------------------------------------- */
.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 8px;
}
