/* Recipes — warm editorial grid. Anti-slop: tinted warm palette (no pure
   black/gray), Fraunces display serif (not Inter/system default), terracotta
   accent (no purple→blue gradient), flat cards (no cards-in-cards), smooth
   easing (no bounce). */

:root {
  /* Warm paper + ink — everything tinted, nothing pure gray */
  --paper: #f6f1e9;
  --paper-2: #efe7da;
  --card: #fffdf9;
  --ink: #2a2017;
  --ink-soft: #6f6253;
  --ink-faint: #9a8b76;
  --line: #e6dccb;

  /* Terracotta accent + appetizing supporting tints */
  --accent: #c2562a;
  --accent-deep: #a8451f;
  --accent-wash: #f6e2d2;
  --veg: #5f7d4f;
  --veg-wash: #e9f0e0;
  --amber: #b97e1f;
  --amber-wash: #f6ead0;

  --shadow-1: 0 1px 2px rgba(74, 52, 30, 0.06), 0 4px 14px rgba(74, 52, 30, 0.08);
  --shadow-2: 0 6px 16px rgba(74, 52, 30, 0.12), 0 18px 40px rgba(74, 52, 30, 0.16);

  --r-card: 16px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --sans: "Hanken Grotesk", -apple-system, "Segoe UI", system-ui, sans-serif;
  --display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--paper-2), transparent 60%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Masthead ---------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 22px clamp(18px, 4vw, 56px) 14px;
}

.masthead__inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.masthead__title h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0;
}

.masthead__count {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.01em;
}

/* ---------- Search ---------- */
.search {
  position: relative;
  flex: 1 1 320px;
  max-width: 460px;
}

.search__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--ink-faint);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search input {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  padding: 13px 16px 13px 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  box-shadow: var(--shadow-1);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
}

/* ---------- Filter chips ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  text-transform: capitalize;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-1);
}
.chip--group-label {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 7px 4px 7px 8px;
  border: none;
  background: none;
  cursor: default;
  align-self: center;
}
.chip--diet[aria-pressed="true"] { background: var(--veg); border-color: var(--veg); }

/* ---------- Board + grid ---------- */
.board {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) clamp(18px, 4vw, 56px) 64px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 30%, 320px), 1fr));
  gap: clamp(16px, 2vw, 28px);
}
/* The explicit display:grid outranks the UA [hidden] rule, so JS setting
   `hidden` (0 search results) won't hide the grid without this guard. */
.grid[hidden] { display: none; }

/* ---------- Card ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform 0.28s var(--ease), box-shadow 0.28s var(--ease);
}
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-2);
}
.card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: linear-gradient(135deg, var(--paper-2), var(--accent-wash));
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease);
}
.card:hover .card__img { transform: scale(1.05); }

/* Placeholder for image-less recipes — keeps the grid uniform */
.card__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 600;
  font-size: 64px;
  color: color-mix(in srgb, var(--accent) 55%, var(--paper));
  background:
    radial-gradient(120% 120% at 30% 20%, var(--card), transparent 70%),
    repeating-linear-gradient(45deg, var(--paper-2) 0 14px, var(--paper) 14px 28px);
}

.card__diet {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  backdrop-filter: blur(4px);
}
.tag--veg { background: color-mix(in srgb, var(--veg) 88%, transparent); color: #fff; }
.tag--status {
  background: color-mix(in srgb, var(--amber) 88%, transparent);
  color: #fff;
}

.card__body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0;
}
.card__meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.card__meta .dot { color: var(--ink-faint); }
.card__cuisine { text-transform: capitalize; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-soft);
}
.empty__mark {
  font-family: var(--display);
  font-size: 56px;
  color: var(--ink-faint);
  margin: 0 0 8px;
}
.empty__text { font-size: 16px; margin: 0 0 18px; }
.empty__reset {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--r-pill);
  padding: 10px 22px;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}
.empty__reset:hover { background: var(--accent-deep); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(42, 32, 23, 0.5);
  backdrop-filter: blur(3px);
  animation: fade 0.25s var(--ease);
}
.modal__card {
  position: relative;
  z-index: 1;
  width: min(880px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
  animation: rise 0.3s var(--ease);
}
.modal__close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-1);
  transition: background 0.18s var(--ease);
}
.modal__close:hover { background: var(--accent); color: #fff; }
.modal__media {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--paper-2), var(--accent-wash));
  overflow: hidden;
}
.modal__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal__media .modal__ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--display); font-size: 88px;
  color: color-mix(in srgb, var(--accent) 55%, var(--paper));
}
.modal__body { padding: clamp(20px, 3vw, 34px); }
.modal__head h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.1;
  margin: 0;
}
.modal__meta { color: var(--ink-soft); font-size: 14px; margin: 8px 0 0; text-transform: capitalize; }
.modal__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.modal__chips .tag { backdrop-filter: none; }
.modal__chips .tag--cuisine { background: var(--amber-wash); color: var(--amber); }
.modal__chips .tag--veg { background: var(--veg-wash); color: var(--veg); }

.modal__cols {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: clamp(20px, 4vw, 40px);
  margin-top: 26px;
}
.modal__cols h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-wash);
}
.modal__ings ul { list-style: none; margin: 0; padding: 0; }
.modal__ings li {
  font-size: 14.5px;
  line-height: 1.5;
  padding: 6px 0 6px 20px;
  position: relative;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.modal__ings li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.modal__steps ol { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.modal__steps li {
  counter-increment: step;
  position: relative;
  padding: 4px 0 18px 42px;
  font-size: 14.5px;
  line-height: 1.6;
}
.modal__steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
}
.modal__notes {
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--amber-wash);
  color: var(--amber);
  border-radius: 12px;
  font-size: 13.5px;
}
.modal__source {
  display: inline-block;
  margin-top: 22px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-deep);
  text-decoration: none;
}
/* The explicit display above outranks the UA [hidden] rule, so JS setting
   `hidden` won't hide the link without this guard (matches .modal[hidden]). */
.modal__source[hidden] { display: none; }
.modal__source:hover { text-decoration: underline; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (max-width: 620px) {
  .modal__cols { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
