:root {
  --bg: #f7f2e8;
  --bg-2: #f0e3d2;
  --ink: #1f1a16;
  --muted: #6f6158;
  --card: #fff8f0;
  --border: #ead8c6;
  --accent: #e56b45;
  --accent-2: #1f8a70;
  --accent-3: #f2b544;
  --shadow: 0 20px 45px rgba(35, 25, 18, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, rgba(242, 181, 68, 0.25), transparent 55%),
    radial-gradient(circle at 80% 10%, rgba(229, 107, 69, 0.18), transparent 45%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 138, 112, 0.25), transparent 70%);
  filter: blur(0.5px);
  z-index: -1;
}

.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: inline-block;
  padding: 12px 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  color: white;
  background: #2f6f5f;
  border: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.back-button:hover {
  background: #25594c;
}

body::before {
  top: -140px;
  left: -80px;
}

body::after {
  bottom: -160px;
  right: -120px;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(31, 138, 112, 0.35);
  outline-offset: 3px;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 32px;
  animation: fadeUp 0.8s ease both;
}

.hero-text {
  max-width: 620px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 0 0 12px;
}

h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: clamp(2.4rem, 3vw + 1.6rem, 3.6rem);
  margin: 0 0 12px;
}

.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 18px;
  line-height: 1.6;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-tags span {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(31, 138, 112, 0.12);
  color: var(--accent-2);
  font-size: 0.85rem;
  font-weight: 600;
}

.hero-plate {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff3e1, #f6c8a9 60%, #e5855d 100%);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero-plate::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 2px dashed rgba(31, 138, 112, 0.35);
}

.hero-plate-inner {
  width: 86px;
  height: 86px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent-2), #2bbf99);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.25);
  transform: rotate(18deg);
}

main {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.panel {
  background: rgba(255, 248, 240, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: fadeUp 0.8s ease 0.15s both;
}

form {
  display: grid;
  gap: 18px;
}

.form-row {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.form-group label {
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
  color: #3a2f28;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid #594a41;
  border-bottom: 2px solid #594a41;
  transform: translateY(-60%) rotate(45deg);
  pointer-events: none;
}

select {
  width: 100%;
  padding: 12px 40px 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fffdf9;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(31, 138, 112, 0.2);
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  flex: 1 1 200px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-tertiary {
  flex: 0 0 auto;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid rgba(31, 138, 112, 0.35);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  color: #2f6b5c;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary {
  color: #fff8f2;
  background: linear-gradient(120deg, var(--accent), #f08a5d);
  box-shadow: 0 12px 25px rgba(229, 107, 69, 0.3);
}

.btn-secondary {
  color: #f8fffd;
  background: linear-gradient(120deg, var(--accent-2), #2bbf99);
  box-shadow: 0 12px 25px rgba(31, 138, 112, 0.25);
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-tertiary:hover {
  transform: translateY(-2px);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-tertiary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.results {
  animation: fadeUp 0.8s ease 0.25s both;
}

.results-head h2 {
  font-family: "Fraunces", "Times New Roman", serif;
  margin: 0 0 8px;
  font-size: 1.9rem;
}

.results-head p {
  margin: 0 0 18px;
  color: var(--muted);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.recipe-card {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 12px 25px rgba(38, 28, 20, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.recipe-card.reveal {
  animation: floatIn 0.55s ease forwards;
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 35px rgba(38, 28, 20, 0.16);
}

.card-media img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 14px;
}

.image-fallback {
  height: 200px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(31, 138, 112, 0.2), rgba(229, 107, 69, 0.25));
  display: grid;
  place-items: center;
  color: #3e2f27;
  font-weight: 600;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-header h3 {
  margin: 0;
  font-size: 1.2rem;
  flex: 1;
}

.pill {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(229, 107, 69, 0.15);
  color: #b94d2f;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.card-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 14px 0 6px;
}

.card-section {
  display: grid;
  gap: 6px;
}

.card-text {
  color: #2a231f;
  font-size: 0.95rem;
  line-height: 1.5;
}

.card-text ul,
.card-text ol {
  padding-left: 18px;
  margin: 8px 0 0;
}

.card-link {
  margin-top: auto;
  text-decoration: none;
  font-weight: 600;
  color: var(--accent-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-link:hover {
  text-decoration: underline;
}

.card-link svg {
  width: 16px;
  height: 16px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 40px 24px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  text-align: center;
  grid-column: 1 / -1;
}

.empty-state p {
  margin: 0;
}

/* Loading State */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 24px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: var(--muted);
  font-weight: 500;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pagination Styles */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 32px;
  padding: 20px;
  background: rgba(255, 248, 240, 0.7);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.pagination.hidden {
  display: none;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent-2);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 138, 112, 0.25);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn svg {
  flex-shrink: 0;
}

.pagination-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#pageInfo {
  font-weight: 600;
  color: var(--ink);
  font-size: 1rem;
}

.total-results {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Page dots */
.page-dots {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.page-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-dot.active {
  background: var(--accent-2);
  transform: scale(1.2);
}

.page-dot:hover:not(.active) {
  background: rgba(31, 138, 112, 0.4);
}

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

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 860px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-plate {
    align-self: center;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 24px 16px 50px;
  }

  .hero-plate {
    width: 180px;
    height: 180px;
  }

  .button-row {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

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

  .pagination {
    flex-direction: column;
    gap: 16px;
  }

  .pagination-btn {
    width: 100%;
    justify-content: center;
  }
}
