/* MyFoodManager blog. Static pages generated by scripts/generate-blog.mjs.
   The token blocks below are copied verbatim from apps/web/src/index.css (Basil):
   keep them in step when the app palette changes. */

:root {
  /* Basil ("Copper & Thyme"): warm paper ground, white panels, sage accent,
     hairlines instead of drop shadows. */
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #e8e9e4;
  --text: #20221e;
  --text-muted: #62665d;
  --border: rgba(32, 34, 30, 0.14);
  --primary: #405248;
  --primary-hover: #364540;
  --primary-soft: #e8e9e4;
  --accent: #d9542b;
  /* Tomato is the only warm colour in the palette and it must stay usable as TYPE.
     #d9542b is 3.72:1 on --bg and 4.00:1 on --surface, so it fails WCAG AA for
     anything under 18px — which is exactly where it was being used: the savings
     figure, the stale flag, the scaled-serving flag. Use --accent for fills and
     large display text, --accent-text (5.07:1 / 5.44:1) for body-size type. */
  --accent-text: #b8431f;
  --success: #166534;
  --success-soft: #e2ece2;
  --danger: #b91c1c;
  --warn: #92400e;
  --warn-soft: #f4ead6;
  --danger-soft: #f7e3df;
  --on-primary: #fff;
  --radius: 12px;
  /* A whisper — elevation belongs to hairlines now. */
  --shadow: 0 1px 2px rgb(32 34 30 / 0.04);
  /* Functional elevation only: modals, toasts, floating menus. */
  --shadow-lift: 0 2px 6px rgb(32 34 30 / 0.06), 0 16px 40px rgb(32 34 30 / 0.14);
  /* Display face for page titles, card headings, the wordmark (theme.css loads it). */
  --font-serif: var(--font-display, "Cormorant Garamond", Georgia, "Times New Roman", serif);

  color-scheme: light dark;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Dark palette. Two selectors, one palette: the OS preference applies unless the user
   explicitly chose light, and an explicit dark choice applies whatever the OS says.
   Set by lib/theme.ts stamping <html data-theme="light|dark">. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Near-neutral dark grounds with the faintest green cast, matched to the UUI
       .dark-mode grays in styles/theme.css (bg-primary = neutral-950) so the shell
       and UUI components sit on the same floor. Sage lightens to brand-300 for text. */
    --bg: #0c0e0c;
    --surface: #161917;
    --surface-2: #232624;
    --text: #edeeea;
    --text-muted: #a3a8a0;
    --border: rgba(237, 238, 234, 0.14);
    --primary: #adb8a8;
    --primary-hover: #c2cabb;
    --primary-soft: #242e2a;
    --accent: #e8724c;
    --accent-text: #e8724c;  /* 6.41:1 on --bg — already AA as type */
    --success: #82b98d;
    --success-soft: #1e2d22;
    --danger: #e88070;
    --warn: #d9a648;
    --warn-soft: #382c14;
    --danger-soft: #3a201b;
    --on-primary: #10120f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.5);
    --shadow-lift: 0 2px 6px rgb(0 0 0 / 0.5), 0 16px 40px rgb(0 0 0 / 0.55);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e0c;
  --surface: #161917;
  --surface-2: #232624;
  --text: #edeeea;
  --text-muted: #a3a8a0;
  --border: rgba(237, 238, 234, 0.14);
  --primary: #adb8a8;
  --primary-hover: #c2cabb;
  --primary-soft: #242e2a;
  --accent: #e8724c;
  --accent-text: #e8724c;  /* 6.41:1 on --bg — already AA as type */
  --success: #82b98d;
  --success-soft: #1e2d22;
  --danger: #e88070;
  --warn: #d9a648;
  --warn-soft: #382c14;
  --danger-soft: #3a201b;
  --on-primary: #10120f;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.5);
  --shadow-lift: 0 2px 6px rgb(0 0 0 / 0.5), 0 16px 40px rgb(0 0 0 / 0.55);
}
/* Keep native controls and scrollbars in step with an explicit choice. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ------------------------------------------------------------------ blog */

:root {
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --measure: 65ch;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

a { color: var(--primary); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; display: block; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 10;
  background: var(--surface); color: var(--text); padding: 0.5rem 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }

.shell { width: 100%; max-width: 74rem; margin-inline: auto; padding-inline: 1.25rem; }
.shell-narrow { max-width: calc(var(--measure) + 2.5rem); }
.shell-hero { max-width: 48rem; }
@media (min-width: 640px) {
  .shell { padding-inline: 2.5rem; }
  .shell-narrow { max-width: calc(var(--measure) + 5rem); }
}

.kicker {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent-text);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.75rem 1.4rem;
  border-radius: 0.25rem; border: 1px solid transparent;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-sm { min-height: 40px; padding: 0.55rem 0.95rem; font-size: 0.6875rem; }

/* ---- header / footer ---- */

.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.25rem; }
.wordmark {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; line-height: 1;
  letter-spacing: 0.01em; color: var(--text); text-decoration: none; white-space: nowrap;
}
.wordmark:hover { color: var(--text); }
.wordmark .dot { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 1rem; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-muted); text-decoration: none; white-space: nowrap;
}
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--text); }
/* At phone width the breadcrumb and footer already lead to the blog; the masthead keeps the
   two actions that matter to a new reader. */
@media (max-width: 479px) {
  .nav-blog { display: none; }
  .wordmark { font-size: 1.2rem; }
  .site-nav { gap: 0.85rem; }
}
@media (min-width: 640px) { .site-nav { gap: 1.75rem; } .wordmark { font-size: 1.45rem; } }

.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; }
.site-footer-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem; padding-block: 1.5rem;
}
.footer-copy { font-size: 0.8125rem; color: var(--text-muted); }
.footer-nav { display: flex; gap: 1.5rem; }
.footer-nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-muted); text-decoration: none;
}
.footer-nav a:hover { color: var(--text); }

/* ---- post ---- */

.draft-banner {
  margin: 1.25rem 0 0; padding: 0.6rem 0.9rem; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--warn); font-size: 0.875rem; font-weight: 600;
}

.breadcrumb { margin: 1.75rem 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.breadcrumb ol { display: flex; gap: 0.4rem; list-style: none; margin: 0; padding: 0; min-width: 0; }
.breadcrumb li { white-space: nowrap; }
.breadcrumb li + li::before { content: "/"; margin-right: 0.4rem; color: var(--text-muted); opacity: 0.6; }
.breadcrumb li:last-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

.post-header { margin: 1.25rem 0 1.75rem; }
.post-header h1, .listing-header h1 {
  margin: 0 0 1rem;
  font-family: var(--font-display); font-weight: 600; line-height: 1.08; letter-spacing: -0.01em;
  font-size: clamp(2.1rem, 6.5vw, 3.25rem);
  text-wrap: balance;
}
.post-meta { margin: 0; font-size: 0.875rem; color: var(--text-muted); }

.post-hero { margin: 0 auto 2.25rem; }
.post-hero img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }

.prose { font-size: 1.0625rem; line-height: 1.72; }
.prose > * { max-width: var(--measure); }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose .table-wrap { margin: 0 0 1.25rem; }
.prose h2, .prose h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; scroll-margin-top: 1.5rem; text-wrap: balance; }
.prose h2 { font-size: clamp(1.7rem, 4.5vw, 2.1rem); margin: 2.75rem 0 0.9rem; }
.prose h3 { font-size: 1.4rem; margin: 2rem 0 0.6rem; }
.prose h4 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
.prose ul, .prose ol { padding-left: 1.35rem; }
.prose li { margin: 0.35rem 0; }
.prose li > p { margin: 0 0 0.5rem; }
.prose strong { font-weight: 600; }
.prose img { border-radius: var(--radius); margin: 0.5rem 0; }
.prose blockquote {
  margin-left: 0; padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 3px solid var(--primary); color: var(--text-muted); font-style: italic;
}
.prose code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.prose pre { background: var(--surface-2); padding: 1rem; border-radius: var(--radius); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
.prose th, .prose td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }

/* The featured-snippet answer: the first thing a reader (and a search engine) sees. */
.short-answer {
  margin: 0 0 1.5rem; padding: 1.1rem 1.25rem 1.15rem;
  background: var(--primary-soft); border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 1.0625rem; line-height: 1.6;
}
.short-answer p { margin: 0; }
.short-answer .short-answer-label {
  margin-bottom: 0.35rem;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--primary);
}
.post-reviewed { font-size: 0.875rem; color: var(--text-muted); }

.takeaways {
  margin: 2rem 0; padding: 1.1rem 1.4rem 0.4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.prose .takeaways h2 {
  margin: 0 0 0.6rem; font-family: inherit; font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted);
}
.takeaways ul { margin-bottom: 1rem; }

.prose ol.steps { list-style: none; padding: 0; counter-reset: step; }
.prose ol.steps > li {
  counter-increment: step; position: relative;
  padding: 0 0 0 2.75rem; margin: 0 0 1.1rem; min-height: 2rem;
}
.prose ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.05rem;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
  font-size: 0.875rem; font-weight: 600; line-height: 1;
}

.faq { margin-top: 3rem; padding-top: 0.25rem; }
.faq-item { border-top: 1px solid var(--border); padding-top: 0.25rem; }
.faq-item:last-child { border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.prose .faq-item h3 { margin: 1.25rem 0 0.5rem; font-size: 1.35rem; }

.post-cta {
  margin: 3rem 0 0; padding: 1.75rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  border-top: 3px solid var(--accent);
}
.post-cta h2 {
  margin: 0 0 0.6rem; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.6rem, 4.5vw, 2rem); line-height: 1.12;
}
.post-cta p { margin: 0 0 1.25rem; color: var(--text-muted); max-width: 52ch; }
.post-cta .kicker { margin-bottom: 0.5rem; }

/* ---- cards: listing, related, 404 ---- */

.section-title {
  margin: 0 0 1.25rem; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2rem); line-height: 1.15;
}
.related { margin-top: 4rem; padding-top: 2.5rem; border-top: 1px solid var(--border); }

.post-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .post-grid { grid-template-columns: repeat(3, 1fr); } }

.post-card { height: 100%; }
.post-card-link {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: inherit; text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.post-card-link:hover { border-color: var(--primary); transform: translateY(-2px); color: inherit; }
.post-card-image { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-bottom: 1px solid var(--border); }
.post-card-body { padding: 1rem 1.15rem 1.25rem; }
.post-card-meta { margin: 0 0 0.4rem; font-size: 0.8125rem; color: var(--text-muted); }
.post-card-title {
  margin: 0 0 0.5rem; font-family: var(--font-display); font-weight: 600;
  font-size: 1.4rem; line-height: 1.15; color: var(--text);
}
.post-card-desc { margin: 0; font-size: 0.9375rem; color: var(--text-muted); line-height: 1.55; }

.listing-header { padding: 2.75rem 0 2rem; max-width: 46rem; }
.listing-header .lede { margin: 0; font-size: 1.125rem; color: var(--text-muted); max-width: 40rem; }

.featured { margin-bottom: 3rem; }
.featured .post-card-title { font-size: clamp(1.6rem, 4.5vw, 2.25rem); }
@media (min-width: 860px) {
  .featured .post-card-link { flex-direction: row; align-items: stretch; }
  .featured .post-card-image { width: 58%; aspect-ratio: auto; border-bottom: 0; border-right: 1px solid var(--border); }
  .featured .post-card-body { width: 42%; padding: 2rem; align-self: center; }
  .featured .post-card-desc { font-size: 1rem; }
}

.empty { color: var(--text-muted); font-size: 1.125rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .post-card-link:hover { transform: none; }
}

@media print {
  .site-header, .site-footer, .post-cta, .related, .breadcrumb { display: none; }
}
