/* ============================================================
   Dietly — generated pages stylesheet (food detail, browse,
   category landings). Standalone: do NOT load styles.css with it.
   Design language: beige canvas, deep ink-green, flat white
   cards, thin lines, no gradients, no emoji decoration.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --canvas:     #F5F2EB;
  --card:       #FFFFFF;
  --card-soft:  #FAF8F2;
  --line:       #E7E1D2;
  --line-soft:  #EFEAE0;
  --ink:        #14231A;
  --ink-green:  #0E3D20;
  --ink-2:      #46544B;
  --mute:       #79857C;
  --green:      #23A943;
  --green-soft: #E7F5EB;
  --gold:       #D9A441;
  --gold-soft:  #F8EFDD;
  --brick:      #C2452D;
  --brick-soft: #F9EAE6;
  --radius:     16px;
  --radius-sm:  10px;
  --shadow:     0 1px 2px rgba(20, 35, 26, .05), 0 4px 16px -8px rgba(20, 35, 26, .08);
  --font-body:  'Inter', system-ui, -apple-system, sans-serif;
  --font-head:  'Plus Jakarta Sans', 'Inter', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink-green); text-decoration: none; }
a:hover { color: var(--green); }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 0 0 .45em;
}

img { max-width: 100%; }

/* ===== Nav ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245, 242, 235, .88);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1140px; margin: 0 auto;
  padding: 13px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 800;
  font-size: 18px; color: var(--ink);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: block;
}
.nav-links { display: flex; gap: 26px; }
.nav-links a {
  color: var(--ink-2); font-weight: 500; font-size: 14px;
  transition: color .15s;
}
.nav-links a:hover { color: var(--ink-green); }
.nav-cta {
  background: var(--ink-green);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 9px;
  font-weight: 600; font-size: 13.5px;
  transition: background .15s;
}
.nav-cta:hover { background: #0B331A; }
@media (max-width: 700px) { .nav-links { display: none; } }

/* ===== Page shell (detail) ===== */
.detail {
  max-width: 1140px;
  margin: 0 auto;
  padding: 26px 24px 60px;
}

.breadcrumb {
  font-size: .82rem;
  color: var(--mute);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 22px;
}
.breadcrumb a { color: var(--ink-2); font-weight: 500; }
.breadcrumb a:hover { color: var(--ink-green); }
.breadcrumb [aria-current] { color: var(--mute); }

/* ===== Hero card: image + identity ===== */
.food-hero {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
.detail-image {
  background: var(--card-soft);
  border-right: 1px solid var(--line-soft);
  min-height: 340px;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
}
.detail-image img {
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.img-fallback {
  font-family: var(--font-head);
  font-size: 64px; font-weight: 800;
  color: var(--line);
}
.related-img .img-fallback, .card-image .img-fallback { font-size: 38px; }
.food-hero-body { padding: 34px 36px 30px; }

.detail-tag {
  display: inline-block;
  font-size: .72rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-green);
  background: var(--green-soft);
  border: 1px solid #D3EBDA;
  padding: 4px 10px; border-radius: 6px;
  margin-bottom: 14px;
}
.food-hero-body h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  font-weight: 800;
  margin-bottom: 4px;
}
.detail-brand { color: var(--mute); font-size: .95rem; font-weight: 500; margin-bottom: 14px; }
.detail-desc { color: var(--ink-2); font-size: .95rem; max-width: 56ch; margin: 14px 0 0; }

/* Nutri-Score — official scale kept, framed flat */
.nutri-ribbon-wrap { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; }
.nutri-ribbon-label {
  font-size: .72rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mute);
}
.nutri-score { display: inline-flex; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.ns-cell {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; color: #fff;
  opacity: .35;
}
.ns-cell.on {
  opacity: 1;
  width: 34px; height: 26px;
  font-size: .85rem;
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  border-radius: 6px;
}
.ns-a { background: #038141; } .ns-b { background: #85BB2F; }
.ns-c { background: #FECB02; color: #5A4B00; } .ns-d { background: #EE8100; }
.ns-e { background: #E63E11; }

/* Highlights — flat outlined chips */
.highlights { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.highlight-pill {
  font-size: .7rem; font-weight: 600; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 6px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.highlight-pill.h-high-protein,
.highlight-pill.h-good-protein { background: var(--green-soft); border-color: #D3EBDA; color: var(--ink-green); }
.highlight-pill.h-low-carb,
.highlight-pill.h-low-cal { background: var(--gold-soft); border-color: #EFE0C2; color: #7A5A17; }

.serving-pill {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 16px;
  font-size: .8rem; font-weight: 500; color: var(--ink-2);
  background: var(--card-soft);
  border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 8px;
}

/* ===== Calculator card: serving selector + macros ===== */
.calc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px 26px;
  margin-bottom: 22px;
}
.calc-card > h2 {
  font-size: 1.05rem; font-weight: 700; margin-bottom: 16px;
}
.calc-card > h2 .sub { font-size: .78rem; font-weight: 400; color: var(--mute); margin-left: 6px; }

.serving-selector {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}
.serving-selector-label {
  font-size: .72rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mute);
  margin-right: 4px;
}
.ss-btn {
  font-family: var(--font-body);
  font-size: .82rem; font-weight: 600;
  color: var(--ink-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.ss-btn:hover { border-color: var(--ink-green); color: var(--ink-green); }
.ss-btn.active {
  background: var(--ink-green);
  border-color: var(--ink-green);
  color: #fff;
}
.ss-input {
  font-family: var(--font-body);
  width: 78px;
  font-size: .82rem; font-weight: 600; color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}
.ss-input:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }

.macro-block-label { font-size: .82rem; color: var(--mute); margin-bottom: 12px; }
.macro-block-label strong { color: var(--ink); font-weight: 700; }

.macro-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.macro-card {
  background: var(--card-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px 12px;
  border-top: 3px solid var(--ink-green);
}
.macro-card .n {
  font-family: var(--font-head);
  font-size: 1.45rem; font-weight: 800; color: var(--ink);
  line-height: 1.1;
}
.macro-card .n .u { font-size: .8rem; font-weight: 600; color: var(--mute); }
.macro-card .l {
  font-size: .7rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--mute); margin-top: 3px;
}
.macro-card.protein { border-top-color: var(--green); }
.macro-card.carbs   { border-top-color: var(--gold); }
.macro-card.fat     { border-top-color: var(--brick); }

/* Macro distribution */
.macro-split { margin-top: 20px; }
.macro-split h3 {
  font-size: .72rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mute); margin-bottom: 10px;
}
.split-bar {
  display: flex; height: 10px; border-radius: 6px; overflow: hidden;
  background: var(--line-soft);
}
.split-p { background: var(--green); }
.split-c { background: var(--gold); }
.split-f { background: var(--brick); }
.split-legend {
  display: flex; gap: 18px; margin-top: 10px;
  font-size: .8rem; color: var(--ink-2); font-weight: 500;
}
.split-legend i {
  display: inline-block; width: 9px; height: 9px;
  border-radius: 3px; margin-right: 6px;
}

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tag {
  font-size: .75rem; font-weight: 500; color: var(--mute);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 6px;
}

/* ===== Nutrition facts (label-style) ===== */
.facts-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px 22px;
  margin-bottom: 22px;
}
.facts-card > h2 {
  font-size: 1.05rem; font-weight: 700;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 4px;
}
.facts-card > h2 .sub { font-size: .78rem; font-weight: 400; color: var(--mute); margin-left: 6px; }
.nutrient-grid { display: block; }
.nutrient {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: .9rem;
}
.nutrient:last-child { border-bottom: none; }
.nutrient .l { color: var(--ink-2); font-weight: 500; }
.nutrient .v { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.facts-source { margin: 14px 0 0; font-size: .8rem; color: var(--mute); }
.facts-source strong { color: var(--ink-2); }

@media (min-width: 720px) {
  .nutrient-grid { columns: 2; column-gap: 44px; }
  .nutrient { break-inside: avoid; }
}

/* ===== API CTA band ===== */
.api-cta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  background: var(--ink-green);
  border-radius: var(--radius);
  padding: 22px 28px;
  margin: 0 0 26px;
}
.api-cta-text { color: #E8F1EA; font-size: .9rem; max-width: 60ch; }
.api-cta-text strong { display: block; color: #fff; font-family: var(--font-head); font-size: 1.02rem; margin-bottom: 2px; }
.api-cta-btn {
  flex-shrink: 0;
  background: #fff;
  color: var(--ink-green) !important;
  font-weight: 700; font-size: .88rem;
  padding: 10px 18px;
  border-radius: 9px;
  transition: transform .12s;
}
.api-cta-btn:hover { transform: translateY(-1px); }

/* ===== Related foods ===== */
.related h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 16px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.related-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  display: flex; flex-direction: column;
}
.related-card:hover {
  border-color: #CFC7B2;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.related-img {
  position: relative;
  background: var(--card-soft);
  border-bottom: 1px solid var(--line-soft);
  height: 120px;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
}
.related-img img { max-height: 100px; object-fit: contain; }
.related-body { padding: 12px 14px 13px; }
.related-name {
  font-size: .86rem; font-weight: 600; color: var(--ink);
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-brand { font-size: .74rem; color: var(--mute); margin-top: 2px; }
.related-meta { font-size: .76rem; color: var(--ink-2); font-weight: 500; margin-top: 6px; }

/* Nutri badge (corner of cards) */
.nutri-badge {
  position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  font-size: .72rem; font-weight: 800; color: #fff;
  font-family: var(--font-head);
}
.nutri-a { background: #038141; } .nutri-b { background: #85BB2F; }
.nutri-c { background: #FECB02; color: #5A4B00; } .nutri-d { background: #EE8100; }
.nutri-e { background: #E63E11; }

/* ===== Listing pages (browse + categories) ===== */
.hero {
  max-width: 1140px; margin: 0 auto;
  padding: 54px 24px 10px;
}
.hero-eyebrow {
  display: inline-block;
  font-size: .72rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-green);
  background: var(--green-soft);
  border: 1px solid #D3EBDA;
  padding: 4px 10px; border-radius: 6px;
  margin-bottom: 14px;
}
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 800; }
.hero h1 span { color: var(--green); }
.hero .lead { color: var(--ink-2); font-size: 1rem; max-width: 60ch; margin: 8px 0 0; }

#explore { max-width: 1140px; margin: 0 auto; padding: 18px 24px 50px; }
.controls {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0 18px;
}
.controls h2 { font-size: 1.02rem !important; color: var(--ink) !important; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover {
  border-color: #CFC7B2;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card-image {
  position: relative;
  background: var(--card-soft);
  border-bottom: 1px solid var(--line-soft);
  height: 150px;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.card-image img { max-height: 128px; object-fit: contain; }
.card-emoji { display: none; }
.card-cat {
  position: absolute; top: 8px; right: 8px;
  font-size: .64rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 5px;
}
.card-bar { display: flex; height: 4px; background: var(--line-soft); }
.bar-p { background: var(--green); }
.bar-c { background: var(--gold); }
.bar-f { background: var(--brick); }
.card-body { padding: 13px 15px 14px; }
.card-title {
  font-size: .9rem; font-weight: 600; color: var(--ink);
  margin: 0 0 2px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-brand { font-size: .74rem; color: var(--mute); margin-bottom: 8px; }
.card-macros {
  display: flex; gap: 14px; margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.card-macros .macro .v {
  font-size: .85rem; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.card-macros .macro .l {
  font-size: .62rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--mute);
}

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin: 34px 0 6px;
  font-size: .88rem;
}
.pg-numbers { display: flex; gap: 6px; }
.pg-num, .pg-prev, .pg-next {
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2); font-weight: 600;
}
.pg-num:hover, .pg-prev:hover, .pg-next:hover { border-color: var(--ink-green); color: var(--ink-green); }
.pg-current {
  background: var(--ink-green); border-color: var(--ink-green);
  color: #fff;
}
.pg-disabled { opacity: .4; pointer-events: none; }
.pg-gap { color: var(--mute); }

/* ===== Footer ===== */
.footer { background: var(--ink-green); margin-top: 30px; }
.footer-inner {
  max-width: 1140px; margin: 0 auto;
  padding: 44px 24px 30px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 30px;
}
.footer p { color: #A9C4B1; font-size: .88rem; max-width: 34ch; }
.footer h4 {
  color: #fff; font-size: .78rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 12px;
}
.footer a { display: block; color: #C4D8CB; font-size: .88rem; padding: 3px 0; }
.footer a:hover { color: #fff; }
.footer-bottom {
  max-width: 1140px; margin: 0 auto;
  padding: 16px 24px 26px;
  border-top: 1px solid rgba(255,255,255,.12);
  color: #A9C4B1; font-size: .8rem;
}
@media (max-width: 700px) {
  .footer-inner { grid-template-columns: 1fr; gap: 22px; }
}

/* ===== Responsive: detail ===== */
@media (max-width: 860px) {
  .food-hero { grid-template-columns: 1fr; }
  .detail-image {
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    min-height: 240px;
  }
  .detail-image img { max-height: 220px; }
  .food-hero-body { padding: 24px 22px 24px; }
  .macro-row { grid-template-columns: repeat(2, 1fr); }
  .calc-card, .facts-card { padding: 20px 20px 20px; }
}

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