:root {
  --cream: #f5f0e7;
  --paper: #fffdf8;
  --ink: #201d18;
  --muted: #6f685e;
  --line: #dcd3c6;
  --orange: #d94d1f;
  --orange-dark: #a63210;
  --green: #315d43;
  --soft-green: #e2ece3;
  --danger: #a43020;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(54, 42, 25, .1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(77, 64, 44, .035) 1px, transparent 1px),
    var(--cream);
  background-size: 100% 32px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

button, input { font: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 20;
  padding: .65rem 1rem;
  color: white;
  background: var(--green);
  border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

.site-header,
.site-footer,
main {
  width: min(1160px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: white;
  background: var(--orange);
  border-radius: 50% 50% 44% 56%;
  font-family: Georgia, serif;
}

.favorites-button {
  min-height: 42px;
  padding: .55rem .75rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}
.favorites-button:hover, .favorites-button[aria-pressed="true"] { border-color: var(--orange); background: #fff3ea; }
.count-badge { display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: .35rem; padding-inline: .35rem; color: white; background: var(--orange); border-radius: 999px; font-size: .72rem; }

main { padding-block: clamp(2.5rem, 7vw, 6rem); }
.hero { display: grid; grid-template-columns: 1fr minmax(370px, .85fr); gap: clamp(2rem, 7vw, 6rem); align-items: end; margin-bottom: clamp(3rem, 7vw, 6rem); }
.eyebrow { margin: 0 0 .65rem; color: var(--orange-dark); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3 { margin-top: 0; line-height: 1.08; font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin-bottom: 1rem; font-size: clamp(3rem, 7vw, 6rem); letter-spacing: -.05em; }
.hero-copy > p:last-child { max-width: 630px; margin: 0; color: var(--muted); font-size: 1.08rem; }

.search-card { padding: 1.35rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.search-card > label { display: block; margin-bottom: .6rem; font-size: .85rem; font-weight: 800; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }
input { width: 100%; min-height: 48px; padding: .7rem .9rem; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; outline: 0; }
input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217, 77, 31, .12); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: .7rem 1rem; border-radius: 10px; cursor: pointer; font-weight: 800; text-decoration: none; transition: transform .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .text-button:focus-visible, .icon-button:focus-visible, .favorites-button:focus-visible, .dialog-close:focus-visible { outline: 3px solid rgba(217, 77, 31, .3); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { color: white; background: var(--orange); border: 1px solid var(--orange); }
.button-primary:hover { background: var(--orange-dark); }
.button-secondary { color: var(--ink); background: var(--paper); border: 1px solid var(--line); }
.button-secondary:hover { background: #f5eee4; }
.quick-searches { display: flex; flex-wrap: wrap; gap: .35rem .65rem; margin-top: .8rem; color: var(--muted); font-size: .76rem; }
.text-button { padding: 0; color: var(--orange-dark); background: transparent; border: 0; cursor: pointer; text-decoration: underline; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 3.1rem); }
.result-count { margin: 0; color: var(--muted); font-size: .85rem; }
.status-message { min-height: 1.6rem; margin: .8rem 0; color: var(--muted); font-size: .88rem; }
.status-message[data-state="error"] { color: var(--danger); }
.status-message[data-state="loading"]::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: .5rem; border: 2px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.meal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.meal-card { overflow: hidden; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(64, 47, 28, .06); transition: transform .18s ease, box-shadow .18s ease; }
.meal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.meal-image-wrap { aspect-ratio: 4 / 3; overflow: hidden; background: #e6ded1; }
.meal-image-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.meal-card:hover img { transform: scale(1.025); }
.meal-body { display: flex; flex: 1; flex-direction: column; padding: 1rem; }
.meal-body h3 { margin-bottom: .7rem; font-size: 1.4rem; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tag { padding: .22rem .55rem; color: var(--green); background: var(--soft-green); border-radius: 999px; font-size: .7rem; font-weight: 800; }
.meal-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: auto; }
.meal-actions .button { flex: 1; }
.icon-button { width: 46px; height: 46px; flex: 0 0 auto; color: var(--orange-dark); background: #fff7f0; border: 1px solid #eacabb; border-radius: 10px; cursor: pointer; font-size: 1.25rem; }

.empty-state { padding: clamp(2.5rem, 8vw, 5rem); color: var(--muted); text-align: center; background: rgba(255, 253, 248, .55); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state[hidden] { display: none; }
.empty-state > span { color: var(--orange); font-size: 2.3rem; }
.empty-state h3 { margin: .5rem 0; color: var(--ink); font-size: 1.6rem; }
.empty-state p { margin: 0; }

.site-footer { padding-block: 2rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .83rem; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--orange-dark); }

.recipe-dialog { width: min(850px, calc(100% - 1rem)); max-height: calc(100vh - 2rem); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 30px 100px rgba(38, 25, 10, .34); }
.recipe-dialog::backdrop { background: rgba(34, 27, 19, .72); backdrop-filter: blur(4px); }
.dialog-close { position: sticky; z-index: 2; top: .8rem; float: right; width: 42px; height: 42px; margin: .8rem .8rem -3.5rem 0; color: var(--ink); background: rgba(255, 253, 248, .94); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; font-size: 1.5rem; }
.dialog-hero { position: relative; min-height: 280px; display: flex; align-items: end; padding: clamp(1.5rem, 5vw, 3rem); overflow: hidden; background: #3c352d; }
.dialog-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .48; }
.dialog-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 10%, rgba(25, 20, 15, .88)); }
.dialog-heading { position: relative; z-index: 1; color: white; }
.dialog-heading h2 { max-width: 680px; margin: .45rem 0 0; font-size: clamp(2rem, 6vw, 4rem); }
.dialog-body { padding: clamp(1.2rem, 5vw, 3rem); }
.dialog-topline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.dialog-grid { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr); gap: clamp(1.5rem, 5vw, 3rem); }
.dialog-section h3 { padding-bottom: .5rem; margin-bottom: .8rem; border-bottom: 1px solid var(--line); font-size: 1.25rem; }
.ingredient-list { display: grid; gap: .3rem; padding: 0; margin: 0; list-style: none; }
.ingredient-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .42rem 0; border-bottom: 1px dotted var(--line); font-size: .86rem; }
.ingredient-list li span:last-child { color: var(--muted); text-align: right; }
.instructions { margin: 0; color: #514a41; white-space: pre-line; }
.source-links { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 2rem; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .meal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .site-header, .site-footer, main { width: calc(100% - 1.25rem); }
  main { padding-top: 2rem; }
  .favorites-button { font-size: .78rem; }
  .search-row, .meal-grid, .dialog-grid { grid-template-columns: 1fr; }
  .search-row .button { width: 100%; }
  .section-heading { align-items: start; flex-direction: column; }
  .dialog-topline { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition: none !important; }
}
