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

body {
  font-family: 'Nunito', sans-serif;
  background: #1a1a2e;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
}

/* ── Layout ── */
.container {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Hero responsive ── */
.hero {
  text-align: center;
  padding: 20px 0;
}

.hero h1 {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(1.8rem, 6vw, 3rem);
  color: #ff6b35;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero .subtitle {
  color: #b8b8d0;
  font-size: 1.1rem;
  margin-top: 6px;
}

/* ── Card ── */
.card {
  background: #16213e;
  border-radius: 20px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* ── Input Group ── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-weight: 700;
  color: #e0e0f0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  padding: 14px 16px;
  font-size: 1rem;
  font-family: 'Nunito', sans-serif;
  background: #0f3460;
  border: 2px solid transparent;
  border-radius: 12px;
  color: #ffffff;
  transition: border-color 0.2s ease;
  outline: none;
}

input::placeholder {
  color: #5a6a8a;
}

input:focus, select:focus {
  border-color: #ff6b35;
}

.input-hint {
  font-size: 0.8rem;
  color: #7a8aa0;
  margin-top: 2px;
}

select option {
  background: #0f3460;
}

/* ── Button ── */
button {
  padding: 16px;
  font-size: 1.1rem;
  font-family: 'Fredoka One', cursive;
  font-weight: 400;
  letter-spacing: 1px;
  background: #ff6b35;
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  margin-top: 4px;
}

button:hover {
  background: #e55a25;
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0px);
}

button.spinning {
  animation: pulse 0.6s ease infinite alternate;
  pointer-events: none;
}

@keyframes pulse {
  from { transform: scale(1); background: #ff6b35; }
  to   { transform: scale(1.03); background: #e55a25; }
}

/* ── Result Card ── */
.result-card {
  background: #16213e;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  animation: slideUp 0.4s ease;
}

.result-card.hidden {
  display: none;
}

.result-card .result-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ff6b35;
  font-weight: 700;
  margin-bottom: 10px;
}

.result-card h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: #ffffff;
  margin-bottom: 10px;
}

.result-card .description {
  color: #b8b8d0;
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ── Meta pills fix ── */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta span, .result-card .meta span {
  background: #0f3460;
  color: #e0e0f0;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  flex: 1 1 auto;
  text-align: center;
  min-width: 0;
}

/* ── Meta Icons ── */
.meta-time::before { 
  content: "⏱ "; 
}

.meta-ingredients::before {
   content: "🧄 "; 
}

.meta-match::before {
   content: "✅ "; 
}

.meta-vibe::before {
   content: "🎭 ";
}

.no-match {
  color: #a0a0c0;
  font-size: 1rem;
  text-align: center;
  padding: 10px 0;
}

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

.result-img {
  width: 100%;
  border-radius: 12px;
  margin: 12px 0;
  object-fit: cover;
  max-height: 220px;
}

/* ── Favorites Section ── */
.favorites-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.favorites-title {
  font-family: 'Fredoka One', cursive;
  color: #ff6b35;
  font-size: 1.8rem;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Favorite Card ── */
.fav-card {
  background: #16213e;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  position: relative;
}

.fav-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}

.fav-img {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.fav-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.fav-info h3 {
  font-family: 'Fredoka One', cursive;
  color: #ffffff;
  font-size: 1.2rem;
}

.fav-info p {
  color: #b8b8d0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.hidden {
  display: none;
}

/* ── Save Button ── */
.save-btn {
  margin-top: 16px;
  background: transparent;
  border: 2px solid #ff6b35;
  color: #ff6b35;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.save-btn:hover {
  background: #ff6b35;
  color: white;
  transform: translateY(-2px);
}

.save-btn.saved {
  border-color: #4caf50;
  color: #4caf50;
  cursor: default;
}

.save-btn.saved:hover {
  background: transparent;
  transform: none;
}

/* ── Remove Button ── */
.remove-btn {
  background: transparent;
  border: none;
  color: #5a6a8a;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.remove-btn:hover {
  color: #ff6b35;
  background: transparent;
  transform: none;
}

.remove-btn svg {
  pointer-events: none;
}

.reset-btn {
  background: transparent;
  border: 2px solid #5a6a8a;
  color: #5a6a8a;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  font-size: 0.9rem;
}

.reset-btn:hover {
  border-color: #a0a0c0;
  color: #a0a0c0;
  transform: translateY(-2px);
  background: transparent;
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: #ff6b35;
  color: white;
  padding: 10px 20px;
  border-radius: 0 0 8px 0;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  text-decoration: none;
  z-index: 999;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* ── Modal Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

/* ── Modal Card ── */
.modal-card {
  background: #16213e;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  border-radius: 24px 24px 0 0;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s ease;
}

/* ── Modal Close Button ── */
.modal-image-wrap {
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 52, 96, 0.9);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ffffff;
  transition: background 0.2s ease;
  z-index: 10;
}

.modal-close-btn:hover {
  background: #ff6b35;
  transform: none;
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-right: 0;
}

/* ── Modal Image ── */
.modal-img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
}

.modal-img.hidden {
  display: none;
}

/* ── Modal Content ── */
.modal-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-category {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ff6b35;
  font-weight: 700;
}

.modal-title {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: #ffffff;
  line-height: 1.2;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-meta span {
  background: #0f3460;
  color: #e0e0f0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Modal Sections ── */
.modal-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-section h3 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  color: #ff6b35;
}

/* ── Ingredients List ── */
.modal-ingredients-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal-ingredients-list li {
  color: #e0e0f0;
  font-size: 0.85rem;
  padding: 6px 10px;
  background: #0f3460;
  border-radius: 8px;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-ingredients-list li::before {
  content: "•";
  color: #ff6b35;
  font-size: 1.2rem;
  flex-shrink: 0;
}

@media (max-width: 400px) {
  .modal-ingredients-list {
    grid-template-columns: 1fr;
  }
}

/* ── Steps List ── */
.modal-steps-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-left: 0;
  list-style: none;
  counter-reset: steps-counter;
}

.modal-steps-list li {
  color: #b8b8d0;
  font-size: 0.95rem;
  line-height: 1.7;
  padding: 16px;
  background: #0f3460;
  border-radius: 12px;
  position: relative;
  padding-left: 52px;
  counter-increment: steps-counter;
}

.modal-steps-list li::before {
  content: counter(steps-counter);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: #ff6b35;
  color: white;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── View Recipe Button ── */
.view-recipe-btn {
  margin-top: 8px;
  background: #0f3460;
  border: 2px solid #0f3460;
  color: #e0e0f0;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.view-recipe-btn:hover {
  background: transparent;
  border-color: #e0e0f0;
  transform: translateY(-2px);
}

/* ── Favorites view button ── */
.fav-actions {
  margin-top: 8px;
}

.fav-view-btn {
  font-size: 0.85rem;
  padding: 8px 14px;
}

/* ── Body scroll lock ── */
body.modal-open {
  overflow: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Modal responsive ── */
@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }

  .modal-card {
    border-radius: 24px;
    max-height: 85vh;
  }
}

/* SVG icon alignment */
h1 svg, h2 svg {
  vertical-align: middle;
  margin-right: 8px;
  color: #ff6b35;
}

button svg {
  vertical-align: middle;
  margin-right: 6px;
}

.save-btn svg {
  color: currentColor;
}

/* ── Responsive breakpoints ── */

/* Tablet and below */
@media (max-width: 600px) {
  body {
    padding: 20px 12px;
  }

  .card {
    padding: 24px 16px;
  }

  .result-card {
    padding: 24px 16px;
  }

  .hero {
    padding: 10px 0;
  }

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

  button {
    font-size: 1rem;
    padding: 14px;
  }

  input, select {
    font-size: 1rem;
    padding: 12px 14px;
  }

  .result-card h2 {
    font-size: 1.6rem;
  }

  .fav-card {
    padding: 16px;
    gap: 12px;
  }

  .fav-img {
    width: 70px;
    height: 70px;
  }
}

/* Small phones - 320px to 400px */
@media (max-width: 400px) {
  .card {
    padding: 20px 12px;
  }

  .result-card h2 {
    font-size: 1.4rem;
  }

  .meta span {
    font-size: 0.75rem;
    padding: 5px 8px;
  }

  .fav-info h3 {
    font-size: 1rem;
  }

  .fav-img {
    width: 60px;
    height: 60px;
  }

  .favorites-title {
    font-size: 1.5rem;
  }
}

/* Legacy - iPhone 4 at 320px */
@media (max-width: 320px) {
  .meta {
    gap: 6px;
  }

  .meta span {
    font-size: 0.7rem;
    padding: 4px 6px;
  }

  .result-card h2 {
    font-size: 1.2rem;
  }
}

/* Favorites card stacked layout for very small screens */
@media (max-width: 320px) {
  .fav-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .fav-img {
    width: 100%;
    height: 140px;
    border-radius: 10px;
  }

  .fav-info {
    width: 100%;
  }

  .remove-btn {
    position: absolute;
    top: 12px;
    right: 12px;
  }
}

/* Favorites card targeted fixes */
.fav-card {
  position: relative;
}

.fav-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.fav-info p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fav-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fav-actions .view-recipe-btn {
  flex: 1;
  margin-top: 0;
  font-size: 0.85rem;
  padding: 8px 14px;
}

.fav-actions .remove-btn {
  flex-shrink: 0;
  position: static;
}