/* BiteMe - Main Styles */

/* CSS Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

:root {
  /* Color Palette - Balanced Elegance */
  --primary-color: #6B9080;
  --primary-dark: #4F7A67;
  --accent-color: #A4C3B2;
  --accent-light: #EAF4F4;
  --background: #FAFAFA;
  --surface: #FFFFFF;
  --text-primary: #2C3E50;
  --text-secondary: #7F8C8D;
  --border: #E8EDED;
  --shadow: rgba(107, 144, 128, 0.1);
  --tag-background: #F8F9FA;
  --tag-text: #6B9080;

  /* Semi-transparent variants */
  --primary-alpha-20: rgba(107, 144, 128, 0.2);
  --accent-light-alpha-30: rgba(234, 244, 244, 0.3);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-size-base: 16px;
  --line-height: 1.6;

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

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text-primary);
  background-color: var(--background);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: linear-gradient(to bottom, var(--accent-light) 0%, var(--surface) 100%);
  color: var(--text-primary);
  padding: var(--spacing-lg) var(--spacing-sm);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

/* Header layouts (shared between main-header and recipe-nav) */
.main-header,
.recipe-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
}

header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--primary-color);
  flex: 1;
  text-align: center;
}

.logo {
  background: linear-gradient(135deg, var(--primary-dark), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-accent {
  font-weight: 500;
  font-style: italic;
}

/* Icon buttons (shared styles for back-button and shopping-cart-link) */
.back-button,
.shopping-cart-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--primary-color);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.back-button:hover,
.shopping-cart-link:hover {
  background-color: var(--accent-light);
}

.back-button:active,
.shopping-cart-link:active {
  transform: scale(0.9);
}

.shopping-cart-link {
  position: relative;
}

.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--primary-color);
  color: var(--surface);
  font-size: 0.7rem;
  font-weight: 500;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}

/* Main Content */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: var(--spacing-md) var(--spacing-sm);
}

/* Search */
.search-container {
  margin-bottom: var(--spacing-md);
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

#search-input {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.95rem;
  font-weight: 300;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  transition: border-color 0.2s;
  letter-spacing: 0.01em;
}

#search-input:focus {
  outline: none;
  border-color: var(--text-secondary);
}

#search-input::placeholder {
  color: var(--text-secondary);
  font-weight: 300;
}

.favorites-filter {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.favorites-filter:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--primary-color);
}

.favorites-filter:active {
  transform: scale(0.95);
}

.favorites-filter.active {
  background-color: var(--accent-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.favorites-filter.active svg {
  fill: var(--primary-color);
}

.favorites-filter svg {
  flex-shrink: 0;
}

/* Recipe Grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.recipe-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.recipe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.recipe-card:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(to right, var(--primary-color), var(--accent-color));
  transition: height 0.2s ease;
}

.recipe-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-2px);
}

.recipe-card:hover:before {
  height: 4px;
}

.recipe-card:active {
  transform: translateY(0);
}

.recipe-title {
  font-size: 1.25rem;
  font-weight: 400;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  flex: 1;
}

.favorite-button-small {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.2s;
  flex-shrink: 0;
}

.favorite-button-small:hover {
  background-color: var(--accent-light);
  color: var(--primary-color);
  transform: scale(1.1);
}

.favorite-button-small:active {
  transform: scale(0.95);
}

.favorite-button-small.favorited {
  color: var(--primary-color);
}

.favorite-button-small.favorited svg {
  fill: var(--primary-color);
}

.recipe-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: var(--spacing-sm);
}

/* Card Cooking Stats */
.card-cooking-stats {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 300;
  margin-top: var(--spacing-sm);
  margin-bottom: 0;
}

/* Tags */
.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: var(--accent-light);
  color: var(--primary-color);
  border: 1px solid var(--accent-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* Buttons */
.button {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 0.95rem;
  font-weight: 300;
  letter-spacing: 0.03em;
  text-align: center;
  text-decoration: none;
  color: var(--surface);
  background-color: var(--primary-color);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
}

.button:hover {
  background-color: var(--primary-dark);
}

.button:active {
  transform: scale(0.98);
}

.button-primary {
  background-color: var(--primary-color);
  font-size: 1rem;
  padding: var(--spacing-md) var(--spacing-xl);
}

/* No Results */
.no-results {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--spacing-xl);
  font-size: 1.1rem;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 200px;
  margin: 0 auto var(--spacing-lg);
}

.empty-state-icon img {
  width: 100%;
  height: auto;
  display: block;
}

.empty-state p {
  margin-bottom: var(--spacing-sm);
  font-size: 1.1rem;
}

.empty-subtitle {
  font-size: 0.95rem;
  margin-bottom: var(--spacing-lg);
}

.empty-state .button {
  margin-top: var(--spacing-md);
}

/* Error State */
.error {
  text-align: center;
  padding: var(--spacing-xl);
}

.error p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  font-size: 1.1rem;
}

/* Footer */
footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--spacing-md);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

footer a:hover {
  border-color: var(--primary-color);
}

/* Update Toast */

/* Placeholder (for Phase 2 pages) */
.placeholder {
  text-align: center;
  padding: var(--spacing-xl);
}

.placeholder h1 {
  margin-bottom: var(--spacing-md);
}

.placeholder p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

/* Responsive Design */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.75rem;
  }

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

/* iPhone Specific Optimizations */
@media (max-width: 480px) {
  :root {
    --spacing-sm: 0.875rem;
    --spacing-md: 1.25rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .recipe-card {
    padding: var(--spacing-sm);
  }

  .button {
    width: 100%;
  }
}

/* Install Banner */
.install-banner {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  background: var(--surface);
  color: var(--text-primary);
  padding: 0.875rem 1rem;
  border-radius: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(calc(100% + 1rem));
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.install-banner-content {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.install-banner-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  flex-shrink: 0;
}

.install-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
  min-width: 0;
}

.install-banner-text strong {
  font-size: 0.875rem;
  font-weight: 600;
}

.install-banner-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.install-banner-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-shrink: 0;
}

.install-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 2rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.install-btn:hover {
  background: var(--primary-dark);
}

.install-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.install-close:hover {
  background: var(--accent-light);
}

/* Install Modal */
.install-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

.install-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
}

.install-modal-content {
  position: relative;
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
  animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.install-modal-content h2 {
  margin: 0 0 1.25rem 0;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.install-step {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.step-number {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--accent-light);
  color: var(--primary-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.install-step p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-close-btn:hover {
  background: var(--primary-dark);
}

/* What's New Button */
.whats-new-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: none;
  border: none;
  color: var(--primary-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
  position: relative;
}

.whats-new-button:hover {
  background-color: var(--accent-light);
}

.whats-new-button:active {
  transform: scale(0.9);
}

.whats-new-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background-color: #e74c3c;
  border-radius: 50%;
}

/* What's New Sheet */
.whats-new-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

.whats-new-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
}

.whats-new-content {
  position: relative;
  background: var(--surface);
  border-radius: 1rem;
  max-width: 400px;
  width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
  animation: modalSlideUp 0.3s ease-out;
}

.whats-new-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0.75rem;
  flex-shrink: 0;
}

.whats-new-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.whats-new-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  line-height: 1;
}

.whats-new-close-btn:hover {
  background: var(--accent-light);
}

.whats-new-list {
  overflow-y: auto;
  padding: 0 1.5rem;
  flex: 1;
  min-height: 0;
}

.whats-new-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.whats-new-entry:last-child {
  border-bottom: none;
}

.whats-new-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.whats-new-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.whats-new-footer {
  padding: 0.75rem 1.5rem 1.25rem;
  text-align: center;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.whats-new-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}

.whats-new-footer a:hover {
  text-decoration: underline;
}
