:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --ink: #1f1b16;
  --muted: #6b6359;
  --line: #e6dfd3;
  --accent: #c8421f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e2;
  --gold: #e0a526;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 27, 22, .06), 0 8px 24px rgba(31, 27, 22, .07);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #221e18;
    --ink: #f4eee4;
    --muted: #a99f91;
    --line: #38322a;
    --accent: #f0683f;
    --accent-ink: #1a0d07;
    --accent-soft: #3a2118;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

main, .site-header, .site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--display); font-weight: 900; font-size: 17px;
}
.brand-name { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; }

.btn {
  border: 1.5px solid var(--ink);
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 15px;
  transition: transform .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--surface); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Hero */
.hero { padding: 28px 0 26px; max-width: 760px; }
.hero h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(44px, 8vw, 84px);
  line-height: .98;
  letter-spacing: -.03em;
  margin: 0 0 16px;
}
.hero h1 em { color: var(--accent); font-style: italic; }
.hero-sub { font-size: 19px; color: var(--muted); margin: 0 0 24px; max-width: 560px; }
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
#search {
  width: 100%;
  font: inherit; font-size: 17px; color: var(--ink);
  padding: 17px 18px 17px 52px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
#search::placeholder { color: var(--muted); }
#search:focus { outline: none; border-color: var(--accent); }

/* Filters */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.chips, .toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  transition: border-color .12s ease, background .12s ease;
}
.chip:hover { border-color: var(--ink); }
.chip .n { color: var(--muted); font-weight: 400; margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.chip.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.result-line { color: var(--muted); font-size: 14px; margin: 18px 0 14px; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(31,27,22,.08), 0 16px 36px rgba(31,27,22,.14); }
.card-photo { aspect-ratio: 4 / 3; background: var(--accent-soft); overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.card:hover .card-photo img { transform: scale(1.04); }
.placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: 72px;
  background:
    radial-gradient(circle at 30% 25%, rgba(224,165,38,.35), transparent 55%),
    radial-gradient(circle at 75% 80%, rgba(200,66,31,.28), transparent 55%),
    var(--accent-soft);
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-type { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.card-title { font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
.card-blurb { color: var(--muted); font-size: 14px; margin: 0; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.card-saved {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}

.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty-big { font-family: var(--display); font-size: 28px; color: var(--ink); margin: 0 0 6px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

/* Recipe detail */
.back { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 18px; background: none; border: 0; padding: 6px 0; color: var(--muted); font-weight: 600; }
.back:hover { color: var(--ink); }
.recipe {
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.recipe-top { display: grid; grid-template-columns: 1.05fr 1fr; }
.recipe-photo { position: relative; min-height: 340px; background: var(--accent-soft); }
.recipe-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.recipe-photo .placeholder { position: absolute; inset: 0; font-size: 120px; }
.credit {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 12px 6px;
  font-size: 11px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
.credit a { color: inherit; }
.recipe-head { padding: 34px 36px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.recipe-head h1 { font-family: var(--display); font-weight: 900; font-size: clamp(32px, 4.4vw, 50px); line-height: 1.02; letter-spacing: -.025em; margin: 0; }
.recipe-blurb { font-size: 18px; color: var(--muted); margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 8px 26px; margin: 8px 0 4px; padding: 0; list-style: none; }
.stats li { display: flex; flex-direction: column; }
.stats b { font-family: var(--display); font-size: 24px; line-height: 1.1; }
.stats span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }

.recipe-body { display: grid; grid-template-columns: 1fr 1.5fr; gap: 40px; padding: 34px 36px 38px; border-top: 1px solid var(--line); }
.recipe-body h2 { font-family: var(--display); font-size: 24px; margin: 0 0 14px; letter-spacing: -.01em; }
.recipe-body h2 small { font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { border-bottom: 1px dashed var(--line); }
.ingredients label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.ingredients input { width: 19px; height: 19px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.ingredients input:checked + span { color: var(--muted); text-decoration: line-through; }
.ingredients b { font-weight: 600; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0 0 20px 54px; font-size: 17px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  font-family: var(--display); font-weight: 700; font-size: 17px;
}
.tip { margin-top: 6px; padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); border-left: 4px solid var(--accent); }
.tip b { color: var(--accent); }
.more { margin: 44px 0 0; }
.more h2 { font-family: var(--display); font-size: 26px; margin: 0 0 16px; }

.site-footer { padding-top: 48px; padding-bottom: 40px; color: var(--muted); font-size: 13.5px; }
.site-footer p { margin: 0 0 4px; }
.print-only { display: none; }

@media (max-width: 800px) {
  .recipe-top { grid-template-columns: 1fr; }
  .recipe-photo { min-height: 0; aspect-ratio: 4 / 3; }
  .recipe-head { padding: 24px 22px; }
  .recipe-body { grid-template-columns: 1fr; gap: 28px; padding: 24px 22px 28px; }
  .stats { grid-template-columns: repeat(2, auto); }
  .brand-name { font-size: 17px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .card-title { font-size: 17px; }
  .card-blurb { display: none; }
  .placeholder { font-size: 52px; }
}

/* Print: a clean recipe card on one page */
@media print {
  @page { margin: 0.5in; }
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; --accent: #000; --accent-soft: #fff; }
  body { background: #fff; color: #000; font-size: 11.5pt; }
  .site-header, .site-footer, #browse, .back, .actions, .more, .credit, .tags { display: none !important; }
  main { padding: 0; max-width: none; }
  #detail[hidden] { display: none !important; }
  .recipe { box-shadow: none; border: 2px solid #000; border-radius: 10px; }
  .recipe-top { grid-template-columns: 2.1in 1fr; align-items: center; }
  .recipe-photo { min-height: 0; height: 1.6in; width: auto; aspect-ratio: auto; margin: .2in 0 .2in .25in; border-radius: 6px; overflow: hidden; }
  .recipe-photo .placeholder { display: none; }
  .recipe.no-photo .recipe-top { grid-template-columns: 1fr; }
  .recipe.no-photo .recipe-photo { display: none; }
  .recipe-head { padding: .2in .3in; gap: 4pt; }
  .recipe-head h1 { font-size: 24pt; }
  .recipe-blurb { font-size: 11pt; }
  .card-type { color: #000; }
  .stats { grid-template-columns: repeat(4, auto); gap: 0 18pt; margin: 4pt 0 0; }
  .stats b { font-size: 14pt; }
  .stats span { font-size: 7.5pt; }
  .recipe-body { grid-template-columns: 1fr 1.6fr; gap: .3in; padding: .2in .3in .25in; border-top: 1.5px solid #000; }
  .recipe-body h2 { font-size: 14pt; margin-bottom: 6pt; }
  .ingredients label { padding: 3.5pt 0; gap: 8pt; }
  .ingredients input { appearance: none; -webkit-appearance: none; width: 10pt; height: 10pt; border: 1px solid #000; border-radius: 2px; margin-top: 3pt; }
  .ingredients input:checked + span { color: #000; text-decoration: none; }
  .steps li { font-size: 11pt; padding: 0 0 8pt 26pt; break-inside: avoid; }
  .steps li::before { width: 18pt; height: 18pt; font-size: 10pt; top: 0; background: #000; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tip { padding: 6pt 10pt; border: 1px solid #000; border-left-width: 4px; background: #fff; break-inside: avoid; }
  .tip b { color: #000; }
  .print-only { display: block; text-align: center; font-size: 8.5pt; color: #444; margin-top: 8pt; }
}
