/* Smart Kitchen: a calm, editorial recipe app.
   White page, serif headings, system sans for everything you read quickly,
   one tomato-red accent for links and the selected state. Lists are divided by rules, not boxed. */
:root {
  --bg: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6a65;
  --rule: #e6e4df;
  --rule-strong: #cfccc4;
  --accent: #a3271f;
  --accent-tint: #fbf1ef;
  --warn-bg: #fbf2cf;
  --warn-ink: #5b4500;
  --serif: "Iowan Old Style", "Charter", "Source Serif 4", "Georgia", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --ink: #ecebe7; --muted: #a3a19a; --rule: #2c2b29; --rule-strong: #43413d;
    --accent: #e7776c; --accent-tint: #2a1b19; --warn-bg: #3a3214; --warn-ink: #f3dc8a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-underline-offset: 2px; }
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  background: var(--bg); border-bottom: 1px solid var(--rule);
}
.brand { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.link-btn { background: none; border: 0; padding: 8px 0; color: var(--muted); cursor: pointer; font-size: .875rem; }
.link-btn:hover { color: var(--ink); }

main { max-width: 760px; margin: 0 auto; padding: 24px 20px 32px; outline: none; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 2.125rem; line-height: 1.12; letter-spacing: -.015em; margin: 4px 0 8px; text-wrap: balance; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; line-height: 1.3; margin: 36px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { color: var(--muted); font-size: .875rem; margin: -4px 0 10px; }
.loading { color: var(--muted); }

.btn { border: 0; border-radius: 3px; padding: 12px 18px; font-weight: 600; cursor: pointer; min-height: 46px; transition: opacity .15s; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--ink); color: var(--bg); width: 100%; }
.btn-secondary { background: var(--ink); color: var(--bg); }
.btn-ghost { background: none; color: var(--ink); border: 1px solid var(--rule-strong); width: 100%; }

/* ---------- sign in ---------- */
.login-card { max-width: 420px; margin: 8vh 0 0; display: grid; gap: 10px; }
.login-card h1 { margin-bottom: 0; }
.login-card > p:first-of-type { margin: 0 0 12px; color: var(--muted); }
.login-card label { font-weight: 600; font-size: .9375rem; }
input[type=email], input[type=search], textarea {
  width: 100%; border: 1px solid var(--rule-strong); background: var(--bg); border-radius: 3px; padding: 11px 12px;
  font-size: 16px; /* stops iOS zoom */
}
input:focus, textarea:focus { border-color: var(--ink); outline: none; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-msg { min-height: 1.5em; margin: 0; color: var(--muted); }

/* ---------- goals: quiet checkboxes ---------- */
.goals { border: 0; padding: 0; margin: 0 0 20px; }
.goals legend { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; padding: 0; margin-bottom: 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 0;
  background: none; border: 0; cursor: pointer; font-size: .9375rem; color: var(--ink);
}
.chip::before {
  content: ""; flex: none; width: 16px; height: 16px; border: 1.5px solid var(--rule-strong); border-radius: 2px;
  background: var(--bg) center / 11px no-repeat; transition: background-color .12s, border-color .12s;
}
.chip[aria-pressed="true"]::before {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.2 4.8 9 10 3' fill='none' stroke='white' stroke-width='1.8'/%3E%3C/svg%3E");
}

/* ---------- chapter tabs: text with an underline ---------- */
.tabs { display: flex; gap: 22px; overflow-x: auto; margin: 0 -20px 16px; padding: 0 20px; border-bottom: 1px solid var(--rule); scrollbar-width: none; overscroll-behavior-x: contain; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 10px 0; margin-bottom: -1px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: .9375rem; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.search { margin-bottom: 8px; }

/* ---------- recipe list ---------- */
.recipe-list { list-style: none; padding: 0; margin: 0; }
.recipe-list > li { border-bottom: 1px solid var(--rule); }
.recipe-card { display: grid; gap: 3px; padding: 18px 0; color: var(--ink); text-decoration: none; }
.recipe-card:hover .card-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.recipe-card.has-photo { grid-template-columns: 1fr 112px; column-gap: 16px; }
.recipe-card.has-photo > :not(.card-photo) { grid-column: 1; }
.card-photo { grid-column: 2; grid-row: 1 / span 6; width: 112px; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; align-self: start; }
.card-chapter { font-size: .8125rem; color: var(--muted); margin: 0; }
.card-title { font-family: var(--serif); font-size: 1.3125rem; font-weight: 600; line-height: 1.25; }
.card-replaces { color: var(--muted); font-size: .9375rem; margin: 0; }
.card-time { font-size: .8125rem; color: var(--muted); }
.match { font-size: .8125rem; color: var(--accent); }
.empty { color: var(--muted); padding: 24px 0; }
.nutri { list-style: none; display: flex; gap: 18px; padding: 0; margin: 4px 0 0; font-size: .875rem; color: var(--muted); }
.nutri b { color: var(--ink); font-weight: 600; }

/* ---------- recipe page ---------- */
.recipe { max-width: 640px; }
.back { display: inline-block; padding: 4px 0 12px; font-size: .875rem; text-decoration: none; }
.back:hover { text-decoration: underline; }
.recipe-photo { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; margin: 0 0 20px; border-radius: 2px; background: var(--rule); }
.moment { font-family: var(--serif); font-style: italic; font-size: 1.125rem; color: var(--muted); margin: 0 0 14px; }
.recipe .card-replaces { margin-bottom: 14px; }
.meta { display: flex; gap: 28px; margin: 0; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.meta div { display: grid; }
.meta dt { font-size: .8125rem; color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }
.recipe .nutri { margin-top: 12px; }

.diet { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 4px; }
.diet-tag { display: grid; grid-template-columns: 7.5em auto 1fr; gap: 0 12px; font-size: .875rem; align-items: baseline; }
.diet-name { font-weight: 600; }
.diet-status { color: var(--muted); }
.diet-no .diet-status { color: var(--accent); }
.diet-fix { color: var(--muted); }
@media (max-width: 520px) { .diet-tag { grid-template-columns: 7.5em 1fr; } .diet-fix { grid-column: 2; } }

.ingredients { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.ingredients > li { border-bottom: 1px solid var(--rule); }
.ing-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; text-align: left;
  background: none; border: 0; padding: 12px 0; cursor: pointer; min-height: 46px;
}
.swap-hint { flex: none; font-size: .8125rem; font-weight: 600; color: var(--accent); }
@media (hover: hover) { .ing-btn:hover .swap-hint { text-decoration: underline; text-underline-offset: 2px; } }
.ing-plain { display: block; padding: 12px 0; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 18px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; line-height: 1.6; }
.steps li::before { content: counter(step); font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--accent); line-height: 1.3; }

.why { margin-top: 32px; padding-left: 16px; border-left: 2px solid var(--rule-strong); }
.why h2 { margin-top: 0; font-size: 1rem; }
.why p { margin: 0; font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6; }

.tips ul { padding-left: 1.1em; margin: 0; display: grid; gap: 6px; }
.tips li::marker { color: var(--muted); }

.ask { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--rule-strong); display: grid; gap: 10px; }
.ask label { font-family: var(--serif); font-size: 1.125rem; font-weight: 600; }
.ask .btn { justify-self: start; }
.ask-answer { white-space: pre-wrap; min-height: 1em; }
.ask-answer:not(:empty) { padding: 12px 0 4px; }

.storage { margin-top: 40px; padding-top: 4px; border-top: 1px solid var(--rule-strong); }
.storage h2 { margin-top: 16px; }
.storage dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.storage dt { color: var(--muted); }
.storage dd { margin: 0; }

/* ---------- nav + library ---------- */
.topnav { display: flex; align-items: center; gap: 18px; font-size: .875rem; }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover { color: var(--ink); }
.library { list-style: none; padding: 0; margin: 20px 0 0; border-top: 1px solid var(--rule-strong); }
.library-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.library-title { font-family: var(--serif); font-size: 1.125rem; font-weight: 600; }
.library-get { flex: none; font-weight: 600; font-size: .9375rem; }
.library-next { margin-top: 24px; }
.upsell { margin-top: 40px; padding: 20px; border: 1px solid var(--rule-strong); border-radius: 4px; }
.upsell h2 { margin-top: 0; }
.upsell p { margin: 0 0 14px; max-width: 38em; }
.upsell-link { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- footer ---------- */
.site-foot { max-width: 760px; margin: 32px auto 0; padding: 16px 20px calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); color: var(--muted); font-size: .8125rem; }
.site-foot p { margin: 0 0 8px; max-width: 46em; }
.site-foot ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-foot a { color: var(--muted); }

/* ---------- swap sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); opacity: 0; transition: opacity .2s; z-index: 20; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 85vh; overflow-y: auto; overscroll-behavior: contain;
  max-width: 640px; margin: 0 auto; padding: 8px 20px calc(18px + env(safe-area-inset-bottom));
  background: var(--bg); border-radius: 10px 10px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .12);
  transform: translateY(100%); transition: transform .26s var(--ease);
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--rule-strong); margin: 0 auto 8px; }
.sheet-title { margin: 8px 0 4px; font-size: 1.375rem; }
.swap-list { list-style: none; padding: 0; margin: 0 0 16px; }
.swap { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.swap p { margin: 0 0 4px; }
.swap-name { font-weight: 600; font-size: 1.0625rem; }
.swap-adds, .swap-costs { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; font-size: .9375rem; }
.tag { font-size: .8125rem; font-weight: 600; }
.tag-good { color: var(--ink); }
.tag-cost { color: var(--muted); }

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