/* Brand: "Herb garden". Rosemary green, warm white, mustard. See brand.html for the reference sheet.
   Every text pairing meets WCAG AA in both themes; --control (input and button borders) meets 3:1. */
:root {
  --bg: #fbfaf5;
  --surface: #ffffff;
  --text: #1e2a23;
  --muted: #56635a;
  --line: #dfe4d8;
  --control: #86938a;
  --accent: #2f5d46;
  --accent-ink: #ffffff;
  --accent-soft: #e4ede5;
  --brand-mustard: #d9a42b;
  --ok: #2e6b45;
  --star: #b07c12;
  --radius: 14px;
  --tap: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131b16;
    --surface: #1c2620;
    --text: #eef2ea;
    --muted: #a8b4aa;
    --line: #33433a;
    --control: #66786d;
    --accent: #8fc7a0;
    --accent-ink: #10180f;
    --accent-soft: #26392d;
    --brand-mustard: #e5b54a;
    --ok: #8fc7a0;
    --star: #e5b54a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 19px/1.5 var(--font);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
@media (min-width: 768px) { body { font-size: 20px; } }

a { color: var(--accent); }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0.4em 0 0.5em; }
h2 { font-size: 1.25rem; margin: 1.2em 0 0.5em; }
h3 { font-size: 1.05rem; margin: 1em 0 0.3em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card h2:first-child { margin-top: 0; }
p { margin: 0.5em 0; }
.lead { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 3px solid var(--brand-mustard);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--accent); text-decoration: none; }
.brand img { width: 30px; height: 30px; }
main {
  max-width: 820px; margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}
/* main is focused after each navigation (for screen readers); never draw the focus ring around the whole page */
main:focus, main:focus-visible { outline: none; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap, .row.gap { gap: 10px; }
.row.between { gap: 8px 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.notice { background: var(--accent-soft); border-color: transparent; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; text-align: center;
  padding: 16px 4px; min-height: 60px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.tabs a[aria-current] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px;
  border: 1.5px solid var(--control); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.big { min-height: 56px; font-size: 1.05rem; padding: 0 28px; }
.btn.small { min-height: 42px; padding: 0 14px; font-size: 0.9rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--control); border-radius: 10px;
  min-height: var(--tap); padding: 8px 12px;
}
input[type="search"], textarea, .row > input:not([type]) { width: 100%; flex: 1; }
input[type="checkbox"] { min-height: 0; width: 26px; height: 26px; accent-color: var(--accent); flex: none; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.field input, .field select { font-weight: 400; max-width: 16rem; }
.toggle { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); }
.small-select { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.small-select select { min-height: 42px; padding: 4px 8px; font-size: 0.9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 42px; padding: 0 14px;
  border: 1.5px solid var(--control); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.tag {
  display: inline-block; font-size: 0.75rem; padding: 1px 8px; margin-left: 6px;
  border-radius: 999px; background: var(--accent-soft); color: var(--text); vertical-align: middle;
}

.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; }
.stars .dim { color: var(--line); }
.stars.small { font-size: 0.85em; margin-left: 6px; }
.stars.rate button {
  border: 0; background: none; padding: 0 2px; cursor: pointer;
  font-size: 2rem; line-height: 1; color: var(--line); min-width: 44px; min-height: var(--tap);
}
.stars.rate button.on { color: var(--star); }

/* plan */
.days { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
@media (min-width: 900px) { main:has(.days) { max-width: 1100px; } .days { grid-template-columns: 1fr 1fr; } }
.day { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.day-date { color: var(--muted); }
.day-date strong { color: var(--text); }
.day-title { font-size: 1.3rem; font-weight: 700; line-height: 1.25; text-decoration: none; color: var(--text); }
.day-title:hover { text-decoration: underline; }
.day.locked { border-color: var(--accent); }
.day.cooked .day-title { color: var(--ok); }
.day.skip { background: transparent; border-style: dashed; }
.day .controls { margin-top: 6px; }

/* recipe list */
.search { margin-bottom: 8px; }
.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list a {
  display: flex; flex-direction: column; padding: 12px 4px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.recipe-list .title { font-weight: 600; font-size: 1.05rem; }
.recipe-list .muted { font-size: 0.9rem; }
.match-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.match-list li a { border-bottom: 0; flex: 1; }
.recipe-list .missing { font-size: 0.9rem; color: var(--text); }
.already .shop li { padding: 6px 0; gap: 12px; }
.already summary { font-weight: 600; }
.plan-history { list-style: none; padding: 0; margin: 0; }
.plan-history > li.current { border-color: var(--accent); }
.plan-history h2 { margin: 0; }
.plan-days { list-style: none; padding: 0; margin: 10px 0 14px; display: grid; gap: 4px; }
.plan-days li { display: grid; grid-template-columns: 3.2em 1fr; gap: 8px; }
.cooked-mark { color: var(--ok); font-size: 0.9rem; }
.repeat input[type="date"] { min-height: 42px; padding: 4px 8px; font-size: 0.9rem; }

/* recipe */
.recipe .meta { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.ingredients ul, .steps ol { padding-left: 1.4em; margin: 0.3em 0; }
.ingredients li, .steps li { margin: 0.45em 0; padding: 2px 4px; border-radius: 8px; }
.ingredients li.optional { color: var(--muted); }
.steps li { margin: 0.8em 0; }
.planner-box .toggle { font-weight: 400; }
details { margin: 1em 0; }
summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }

/* cooking mode: bigger type, no chrome, tap to track progress */
.exit-cook { display: none; }
body.cooking { font-size: 24px; padding-bottom: 0; }
body.cooking .tabs, body.cooking .topbar, body.cooking .card, body.cooking details,
body.cooking [data-action="favorite"], body.cooking .rating-slot, body.cooking [data-action="cook"]:not(.exit-cook) { display: none; }
body.cooking .exit-cook { display: inline-flex; position: sticky; top: 8px; z-index: 5; }
body.cooking main { max-width: 1000px; }
@media (min-width: 900px) {
  body.cooking .recipe { display: grid; grid-template-columns: 2fr 3fr; gap: 0 40px; }
  body.cooking .recipe > header, body.cooking .recipe > section:not(.ingredients):not(.steps) { grid-column: 1 / -1; }
}
body.cooking .ingredients li, body.cooking .steps li { cursor: pointer; }
body.cooking .ingredients li.done { text-decoration: line-through; color: var(--muted); }
body.cooking .steps li.current { background: var(--accent-soft); outline: 2px solid var(--accent); }

/* shopping */
.aisle h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.shop { list-style: none; margin: 0; padding: 0; }
.shop li { display: flex; align-items: center; justify-content: space-between; }
.shop label { display: flex; align-items: flex-start; gap: 14px; padding: 10px 0; flex: 1; cursor: pointer; }
.shop label input { margin-top: 3px; }
.shop .item-name { font-weight: 600; }
.shop .qty { margin-left: 8px; }
.shop .raw, .shop .from { display: block; font-size: 0.85rem; color: var(--muted); }
.shop .raw { font-style: italic; }
.shop li.done .item-name, .shop li.done .qty { text-decoration: line-through; color: var(--muted); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--text); color: var(--bg);
  padding: 12px 22px; border-radius: 999px; font-weight: 600;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
#toast button {
  margin-left: 10px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--bg); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}

.print-only { display: none; }

/* Paper: black on white whatever the screen theme; no controls, no planning box, no ticked-off items. */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #bbb; --control: #666; --accent: #000; --star: #000; }
  @page { margin: 1.5cm; }
  html { font-size: 11pt; } /* rem sizes are relative to this on paper */
  .tabs, .topbar, .btn, .chips, form, textarea, #toast, .no-print, .save-state, .notes.empty,
  .shop li.done, .aisle:not(:has(li:not(.done))) { display: none !important; }
  body, body.cooking { font-size: 11pt; padding: 0; background: #fff; color: #000; }
  main, body.cooking main { max-width: none; padding: 0; }
  body.cooking .recipe { display: block; }
  body.cooking .card { display: block; }
  h1 { font-size: 20pt; margin-top: 0; }
  h2 { font-size: 13pt; margin: 1em 0 0.3em; break-after: avoid; }
  h3 { break-after: avoid; }
  li, .shop li { break-inside: avoid; }
  .card { border: 0; padding: 0; margin: 1em 0; background: none; }
  .print-only { display: block; white-space: pre-wrap; }
  a { color: inherit; text-decoration: none; }
  summary { min-height: 0; }
  .ingredients li, .steps li { margin: 0.25em 0; }
  .aisles { display: flex; gap: 2em; align-items: flex-start; }
  .aisles > .col { flex: 1; min-width: 0; }
  .aisle h2 { margin-top: 0.6em; }
  .shop label { padding: 2pt 0; gap: 6pt; }
  .shop input[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 10pt; height: 10pt; min-height: 0; padding: 0; margin-top: 2pt; border: 1pt solid #000; border-radius: 2pt; }
  .shop .from { font-size: 7.5pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
