/* Cooking With: mobile-first styles. No framework. */

:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f4ece1;
  --text: #2a211c;
  --muted: #6b5d52;
  --border: #e6dbcd;
  --accent: #b5432a;
  --accent-strong: #963520;
  --accent-ink: #ffffff;
  --accent-soft: #f8e3db;
  --green: #4b6a37;
  --green-soft: #e5eedb;
  --gold-soft: #f7ecd2;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 6px 20px rgb(60 40 20 / 8%);
  --radius: 14px;
  --radius-sm: 8px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Fraunces", Georgia, "Times New Roman", serif;
  --header-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1613;
    --surface: #251f1b;
    --surface-2: #2e2621;
    --text: #f3ebe2;
    --muted: #bba999;
    --border: #3e342d;
    --accent: #ec8064;
    --accent-strong: #f39a82;
    --accent-ink: #1b1613;
    --accent-soft: #3d2620;
    --green: #a3c487;
    --green-soft: #26301f;
    --gold-soft: #352c1c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.25rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 640px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lede { font-size: clamp(1.05rem, 2.5vw, 1.25rem); color: var(--muted); max-width: 60ch; }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin: 0 0 0.4em; }
.kicker--accent { color: var(--accent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 16px; top: -48px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 8px; }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.15em; }

/* ---------- Buttons & chips ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 44px; padding: 0 1.25em; border: 2px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 600 1rem/1 var(--font-body);
  text-decoration: none; cursor: pointer; transition: background 0.15s, transform 0.15s;
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.button:active { transform: translateY(1px); }
.button--ghost { background: transparent; color: var(--accent); }
.button--ghost:hover { background: var(--accent-soft); color: var(--accent-strong); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 1rem; }
.chip {
  display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: 0.875rem; font-weight: 500;
  background: var(--surface-2); color: var(--text); text-decoration: none; border: 1px solid var(--border);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip--diet { background: var(--green-soft); color: var(--green); border-color: transparent; }
.chip--cuisine { background: var(--gold-soft); border-color: transparent; }
.chip--occasion { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "brand search" "nav nav";
  align-items: center; gap: 8px 12px; padding-top: 10px; padding-bottom: 4px;
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text);
  font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; line-height: 1; }
.brand em { font-style: normal; color: var(--accent); }
.brand img { width: 30px; height: 30px; }
.brand--small { font-size: 1.1rem; margin-bottom: 0.5rem; }

.header-search { grid-area: search; display: flex; min-width: 0; }
.header-search input, .big-search input, .filters input, .filters select {
  width: 100%; min-width: 0; min-height: 44px; padding: 0 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.header-search input { border-radius: 999px 0 0 999px; border-right: 0; font-size: 0.95rem; }
.header-search button {
  flex: none; width: 46px; border: 1px solid var(--border); border-left: 0; border-radius: 0 999px 999px 0;
  background: var(--surface); color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.header-search button:hover { color: var(--accent); }
.header-search input:focus, .big-search input:focus, .filters input:focus, .filters select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.site-nav {
  grid-area: nav; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 12px 6px; -webkit-overflow-scrolling: touch;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  flex: none; padding: 8px 12px; border-radius: 999px; color: var(--text); text-decoration: none;
  font-weight: 500; font-size: 0.95rem;
}
.site-nav a:hover { background: var(--surface-2); color: var(--accent); }

@media (min-width: 900px) {
  :root { --header-h: 72px; }
  .container { padding: 0 24px; }
  .header-inner { grid-template-columns: auto 1fr minmax(240px, 340px); grid-template-areas: "brand nav search";
    padding-top: 0; padding-bottom: 0; min-height: var(--header-h); gap: 24px; }
  .site-nav { margin: 0; padding: 0; overflow: visible; }
}

/* ---------- Hero (soup of the day) ---------- */
.hero { padding: 24px 0 32px; }
.hero-inner { display: grid; gap: 20px; }
.hero-media { display: block; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); }
.hero-media img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; transition: transform 0.4s; }
.hero-media:hover img { transform: scale(1.03); }
.hero-text h1 a { color: inherit; text-decoration: none; }
.hero-text h1 a:hover { color: var(--accent); }
.hero--plain { text-align: center; padding: 48px 0; }
.hero--plain .lede { margin-inline: auto; }

@media (min-width: 800px) {
  .hero { padding: 48px 0 56px; }
  .hero-inner { grid-template-columns: 1.15fr 1fr; align-items: center; gap: 48px; }
}

/* ---------- Meta lists ---------- */
.meta { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 0; color: var(--muted); font-size: 0.85rem; }
.meta li { display: inline-flex; align-items: center; gap: 5px; }
.meta--large { font-size: 0.95rem; margin-bottom: 1.5rem; }

/* Spice level chillies */
.spice { display: inline-flex; align-items: center; gap: 1px; color: #c4351e; }
.spice .icon { width: 1.2em; height: 1.2em; }
.chilli--off { color: var(--muted); opacity: 0.45; }
.spice-fact { display: flex; align-items: center; gap: 6px; }
@media (prefers-color-scheme: dark) { .spice { color: #f0674d; } }

/* ---------- Finder ---------- */
.finder { padding: 28px 0 8px; border-top: 1px solid var(--border); }
.finder-title { font-size: clamp(1.3rem, 3vw, 1.6rem); }
.big-search { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; max-width: 640px; }
.big-search input { min-height: 52px; font-size: 1.05rem; padding: 0 20px; }
.big-search .button { min-height: 52px; }
@media (min-width: 560px) {
  .big-search { flex-direction: row; }
  .big-search .button { flex: none; }
}

/* ---------- Sections & cards ---------- */
.section { padding: 32px 0; }
.section--tight { padding-top: 16px; }
.section--tint { background: var(--surface-2); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; width: 100%; }
.more { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--border); transition: transform 0.2s, box-shadow 0.2s; }
.card:hover { transform: translateY(-3px); }
.card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.card-media { position: relative; background: var(--surface-2); }
.card-media img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card-title { font-size: 1.2rem; margin-bottom: 0.35em; }
.card-link:hover .card-title { color: var(--accent); }
.card-blurb { color: var(--muted); font-size: 0.925rem; margin-bottom: 0.9em; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { position: absolute; left: 12px; top: 12px; background: var(--accent); color: var(--accent-ink);
  padding: 4px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600;
  max-width: calc(100% - 66px); line-height: 1.35; }
.fav { position: absolute; right: 10px; top: 10px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

@media (min-width: 900px) {
  .section { padding: 48px 0; }
  .grid { gap: 24px; }
}

/* ---------- Search page ---------- */
.page-head { padding: 28px 0 8px; }
.page-head--centre { text-align: center; padding: 64px 0; }
.page-head--centre .big-search { margin: 24px auto; }
.page-head--centre .lede { margin-inline: auto; }
.filters { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 16px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.field--grow, .field--actions { grid-column: 1 / -1; }
.field--actions { flex-direction: row; align-items: center; gap: 16px; }
.filters select { border-radius: var(--radius-sm); appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.filters input { border-radius: var(--radius-sm); }
.clear { font-weight: 500; }
.result-count { color: var(--muted); font-weight: 500; }
.empty { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 32px; flex-wrap: wrap; }
.pagination a { font-weight: 600; text-decoration: none; padding: 8px 4px; }

@media (min-width: 900px) {
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
  .field--grow, .field--actions { grid-column: auto; }
}

/* ---------- Recipe page ---------- */
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.recipe-header { padding: 20px 0 8px; }
.recipe-header-inner { display: grid; gap: 20px; }
.recipe-media { margin: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); }
.recipe-media img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 20px 0;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.facts div { background: var(--surface); padding: 10px 12px; }
.facts div:last-child:nth-child(3n + 1) { grid-column: 1 / -1; }   /* a lone last fact fills its row */
.facts div:last-child:nth-child(3n + 2) { grid-column: span 2; }
.facts dt { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: 0.95rem; }
.facts small { font-weight: 400; color: var(--muted); }
.print-button { margin-top: 4px; }

.recipe-body { padding-bottom: 48px; }
.recipe-description { max-width: 70ch; font-size: 1.05rem; margin: 16px 0 8px; }
.recipe-columns { display: grid; gap: 28px; margin-top: 16px; }

.ingredients { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; align-self: start; }
.ingredients h3 { font-family: var(--font-body); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 6px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { position: relative; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist input { position: absolute; opacity: 0; width: 22px; height: 22px; left: 0; top: 12px; margin: 0; }
.checklist label { display: block; padding: 10px 0 10px 34px; cursor: pointer; line-height: 1.45; }
.checklist label::before {
  content: ""; position: absolute; left: 0; top: 12px; width: 20px; height: 20px;
  border: 2px solid var(--border); border-radius: 6px; background: var(--bg); transition: all 0.15s;
}
.checklist input:checked + label { color: var(--muted); text-decoration: line-through; }
.checklist input:checked + label::before {
  background: var(--green); border-color: var(--green);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E");
  background-size: 14px; background-position: center; background-repeat: no-repeat;
}
.checklist input:focus-visible + label::before { outline: 3px solid var(--accent); outline-offset: 2px; }
.prep { color: var(--muted); }
.optional { color: var(--muted); font-size: 0.875em; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 24px; }
.steps li { counter-increment: step; position: relative; padding: 0 0 22px 52px; }
.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(--accent-soft); color: var(--accent-strong);
  font: 700 1.05rem/1 var(--font-head);
}
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 17px; top: 40px; bottom: 6px; width: 2px; background: var(--border); }
.steps p { margin: 0 0 6px; font-size: 1.05rem; }
.step-time { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 999px; }

.note { border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.note h2 { font-size: 1.2rem; }
.note p:last-child { margin-bottom: 0; }
.note--serve { background: var(--green-soft); }
.note--tip { background: var(--gold-soft); }

@media (min-width: 900px) {
  .recipe-header { padding: 40px 0 16px; }
  .recipe-header-inner { grid-template-columns: 1fr 1fr; align-items: center; gap: 48px; }
  .recipe-columns { grid-template-columns: minmax(300px, 380px) 1fr; gap: 48px; }
  .ingredients { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; margin-top: 24px; color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0 0 0.5rem; }
.debug { text-align: left; white-space: pre-wrap; overflow: auto; max-height: 50vh; background: var(--surface-2); padding: 16px; border-radius: var(--radius-sm); font-size: 0.8rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Print ---------- */
/* Admin preview banner (only on /<admin>/recipe/{id}/preview) */
.preview-banner { background: var(--gold-soft); border-bottom: 2px solid var(--accent); }
.preview-banner-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding-top: 12px; padding-bottom: 12px; }
.preview-banner-title { margin: 0; }
.preview-banner-title strong { display: inline-block; margin-right: 6px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.preview-banner-warnings { margin: 6px 0 0; padding-left: 20px; font-size: 0.9rem; }
.preview-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-banner-actions form { margin: 0; }
.preview-banner .button--small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --border: #ccc; --shadow: none; }
  .site-header, .site-footer, .skip-link, .preview-banner, .print-button, .chips, .crumbs, .recipe-media { display: none !important; }
  body { font-size: 11pt; }
  .container { max-width: none; padding: 0; }
  .recipe-header-inner, .recipe-columns { display: block; }
  .facts { grid-template-columns: repeat(4, auto); }
  .facts div:last-child:nth-child(n) { grid-column: auto; }
  .spice, .chilli--off { color: #000; }
  .ingredients { position: static; max-height: none; border: 1px solid #ccc; margin-bottom: 16px; break-inside: avoid; }
  .checklist label::before { display: none; }
  .checklist label { padding-left: 0; text-decoration: none !important; color: #000 !important; }
  .steps li { break-inside: avoid; }
  .note { border: 1px solid #ccc; background: none !important; }
  a { color: #000; text-decoration: none; }
}
