/* ===== BMI Health Suite — ธีมเขียว-มินต์สะอาดตา ===== */
:root {
  --mint-50:  #f2fbf7;
  --mint-100: #dff5ec;
  --mint-200: #b8ecd6;
  --mint-300: #86dcbb;
  --emerald:  #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --ink:      #0f2e26;
  --ink-soft: #4b6b62;
  --line:     #e3f1ea;
  --white:    #ffffff;
  --amber:    #f59e0b;
  --rose:     #f43f5e;
  --sky:      #38bdf8;
  --radius:   20px;
  --shadow:   0 10px 30px -12px rgba(6, 78, 59, .25);
  --shadow-sm:0 4px 14px -8px rgba(6, 78, 59, .3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Noto Sans Thai", "Prompt", -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--mint-100), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #eafaf3, transparent 55%),
    var(--mint-50);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex; align-items: center; gap: 18px;
  max-width: 880px; margin: 0 auto; padding: 14px 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.12rem; color: var(--ink);
  text-decoration: none; margin-right: auto;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, var(--emerald), var(--mint-300));
  display: grid; place-items: center; color: #fff; font-size: 1.15rem;
  box-shadow: var(--shadow-sm);
}
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav-links a {
  text-decoration: none; color: var(--ink-soft); font-weight: 600;
  padding: 8px 14px; border-radius: 12px; font-size: .95rem;
  transition: .18s;
}
.nav-links a:hover { background: var(--mint-100); color: var(--emerald-700); }
.nav-links a.active { background: var(--emerald); color: #fff; box-shadow: var(--shadow-sm); }

/* ---------- Layout ---------- */
main { padding: 40px 0 70px; }
.hero { text-align: center; margin-bottom: 30px; }
.hero .eyebrow {
  display: inline-block; background: var(--mint-100); color: var(--emerald-700);
  font-weight: 700; font-size: .8rem; padding: 5px 14px; border-radius: 999px;
  letter-spacing: .3px; margin-bottom: 14px;
}
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.25; letter-spacing: -.5px; }
.hero p { color: var(--ink-soft); margin-top: 10px; font-size: 1.02rem; }

.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.section-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.section-sub { color: var(--ink-soft); font-size: .92rem; margin-bottom: 20px; }

/* ---------- Unit toggle ---------- */
.unit-toggle {
  display: inline-flex; background: var(--mint-100); border-radius: 999px;
  padding: 4px; gap: 4px; margin: 0 auto 26px;
}
.unit-toggle button {
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  font-weight: 700; color: var(--ink-soft); padding: 8px 18px; border-radius: 999px;
  font-size: .9rem; transition: .18s;
}
.unit-toggle button.on { background: #fff; color: var(--emerald-700); box-shadow: var(--shadow-sm); }
.center { text-align: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 7px; }
input[type=number], select {
  width: 100%; font-family: inherit; font-size: 1rem; color: var(--ink);
  padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--mint-50); transition: .18s; -moz-appearance: textfield;
}
input:focus, select:focus {
  outline: none; border-color: var(--emerald); background: #fff;
  box-shadow: 0 0 0 4px rgba(16,185,129,.13);
}
.dual { display: flex; gap: 10px; }
.with-unit { position: relative; }
.dual .with-unit { flex: 1; }
.with-unit .u {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); font-size: .82rem; font-weight: 600; pointer-events: none;
}

.btn {
  width: 100%; border: 0; cursor: pointer; font-family: inherit; font-weight: 700;
  font-size: 1.02rem; color: #fff; padding: 15px; border-radius: 14px; margin-top: 4px;
  background: linear-gradient(135deg, var(--emerald), var(--emerald-600));
  box-shadow: var(--shadow-sm); transition: .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -10px rgba(5,150,105,.55); }
.btn:active { transform: translateY(0); }

/* Segmented control (goal / activity chips) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg label {
  display: block; text-align: center; padding: 11px 6px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--mint-50); cursor: pointer;
  font-weight: 600; font-size: .9rem; color: var(--ink-soft); transition: .15s;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + label,
.seg label:hover { border-color: var(--emerald); color: var(--emerald-700); background: #fff; }
.seg input:checked + label { background: var(--mint-100); }

/* ---------- BMI result ---------- */
.result { text-align: center; }
.result.empty { color: var(--ink-soft); }
.result.empty .big-emoji { font-size: 2.6rem; opacity: .5; }
.bmi-value { font-size: 3.6rem; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.bmi-cat {
  display: inline-block; font-weight: 700; padding: 6px 16px; border-radius: 999px;
  margin-top: 12px; font-size: .95rem;
}
.bmi-note { color: var(--ink-soft); margin-top: 14px; font-size: .95rem; }

/* gradient BMI meter */
.meter { margin: 26px 0 6px; }
.meter-bar {
  position: relative; height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--sky) 0%, var(--emerald) 30%, var(--amber) 62%, var(--rose) 100%);
}
.meter-pin {
  position: absolute; top: 50%; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink); transform: translate(-50%, -50%);
  transition: left .5s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-sm);
}
.meter-labels { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-soft); margin-top: 8px; }

.stat-row { display: flex; gap: 12px; margin-top: 22px; }
.stat {
  flex: 1; background: var(--mint-50); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; text-align: center;
}
.stat .k { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.stat .v { font-size: 1.25rem; font-weight: 800; color: var(--emerald-700); margin-top: 3px; }

/* ---------- Calorie result ---------- */
.kcal-hero { text-align: center; padding: 8px 0 4px; }
.kcal-hero .k { color: var(--ink-soft); font-weight: 600; }
.kcal-hero .v { font-size: 3.2rem; font-weight: 800; color: var(--emerald-700); line-height: 1.1; }
.kcal-hero .v small { font-size: 1.1rem; color: var(--ink-soft); font-weight: 600; }

.macros { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 22px; }
.macro { border-radius: 14px; padding: 15px; text-align: center; color: #fff; }
.macro.p { background: linear-gradient(135deg,#0ea5e9,#38bdf8); }
.macro.c { background: linear-gradient(135deg,#f59e0b,#fbbf24); }
.macro.f { background: linear-gradient(135deg,#ec4899,#f472b6); }
.macro .mk { font-size: .82rem; opacity: .95; font-weight: 600; }
.macro .mv { font-size: 1.5rem; font-weight: 800; margin-top: 2px; }
.macro .ms { font-size: .74rem; opacity: .9; }

.mini-row { display: flex; gap: 12px; margin-top: 20px; }
.mini { flex: 1; background: var(--mint-50); border: 1px solid var(--line); border-radius: 14px; padding: 13px; text-align: center; }
.mini .k { font-size: .76rem; color: var(--ink-soft); font-weight: 600; }
.mini .v { font-size: 1.1rem; font-weight: 800; margin-top: 2px; }

/* ---------- Food ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 24px; }
.chips { display: inline-flex; background: var(--mint-100); border-radius: 999px; padding: 4px; gap: 4px; }
.chips button {
  border: 0; background: transparent; cursor: pointer; font-family: inherit; font-weight: 700;
  color: var(--ink-soft); padding: 8px 16px; border-radius: 999px; font-size: .88rem; transition: .18s;
}
.chips button.on { background: #fff; color: var(--emerald-700); box-shadow: var(--shadow-sm); }
.search { flex: 1; min-width: 180px; }

.food-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 720px) { .food-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 460px) { .food-grid { grid-template-columns: 1fr; } }
.food {
  display: flex; flex-direction: column;
  background: var(--white); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow-sm); transition: .18s;
  text-decoration: none; color: inherit;
}
.food:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.food .foot { margin-top: auto; }
.see-recipe {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  color: var(--emerald-700); font-weight: 700; font-size: .84rem;
}
.food:hover .see-recipe { text-decoration: underline; }
.food .emoji { font-size: 2rem; }
.food h3 { font-size: 1.02rem; margin: 8px 0 4px; }
.food .desc { color: var(--ink-soft); font-size: .84rem; min-height: 34px; }
.food .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.food .kcal { font-weight: 800; color: var(--emerald-700); }
.food .kcal small { font-weight: 600; color: var(--ink-soft); font-size: .72rem; }
.tag { font-size: .68rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.tag.clean { background: #dcfce7; color: #15803d; }
.tag.keto  { background: #ede9fe; color: #6d28d9; }
.empty-msg { grid-column: 1/-1; text-align: center; color: var(--ink-soft); padding: 30px; }

/* ---------- Misc ---------- */
.disclaimer {
  margin-top: 26px; text-align: center; color: var(--ink-soft); font-size: .82rem;
  background: var(--mint-100); padding: 12px 16px; border-radius: 13px;
}
.hidden { display: none !important; }

/* ---------- Article ---------- */
.article { margin-top: 34px; }
.article .card { padding: 30px 30px 34px; }
.article h2 {
  font-size: 1.4rem; letter-spacing: -.3px; margin: 26px 0 10px;
  display: flex; align-items: center; gap: 9px;
}
.article h2:first-child { margin-top: 0; }
.article h3 { font-size: 1.05rem; margin: 20px 0 6px; color: var(--emerald-700); }
.article p { color: #33534a; margin-bottom: 10px; }
.article ul { margin: 6px 0 10px; padding-left: 4px; list-style: none; }
.article ul:not(.ingredients):not(.steps) li { position: relative; padding-left: 26px; margin-bottom: 8px; color: #33534a; }
.article ul:not(.ingredients):not(.steps) li::before { content: "🌿"; position: absolute; left: 0; font-size: .9rem; }
.article .formula {
  background: var(--mint-50); border: 1px dashed var(--mint-300); border-radius: 13px;
  padding: 16px 18px; text-align: center; font-weight: 700; color: var(--emerald-700);
  margin: 12px 0; font-size: 1.05rem;
}
.article .formula small { display: block; font-weight: 500; color: var(--ink-soft); margin-top: 4px; font-size: .82rem; }

.cat-table { width: 100%; border-collapse: collapse; margin: 14px 0 6px; font-size: .92rem; overflow: hidden; border-radius: 13px; }
.cat-table th, .cat-table td { padding: 12px 14px; text-align: left; }
.cat-table thead th { background: var(--emerald); color: #fff; font-weight: 700; }
.cat-table tbody tr { border-bottom: 1px solid var(--line); background: #fff; }
.cat-table tbody tr:nth-child(even) { background: var(--mint-50); }
.cat-table .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.cat-table td:first-child { white-space: nowrap; font-weight: 700; }
@media (max-width: 560px) { .cat-table th, .cat-table td { padding: 9px 8px; font-size: .84rem; } }

.faq { border-top: 1px solid var(--line); padding-top: 6px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer; font-weight: 700; padding: 14px 2px; list-style: none;
  display: flex; justify-content: space-between; align-items: center; color: var(--ink);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "＋"; color: var(--emerald); font-weight: 700; }
.faq details[open] summary::after { content: "－"; }
.faq details p { padding: 0 2px 16px; margin: 0; }

/* ---------- Posts / บทความ (การ์ดข้อความเท่ากันทุกใบ) ---------- */
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
@media (max-width: 760px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .post-grid { grid-template-columns: 1fr; } }

.post {
  display: flex; flex-direction: column;
  background: var(--white); border: 1px solid var(--line); border-radius: 18px;
  overflow: hidden; box-shadow: var(--shadow-sm); transition: .18s; text-decoration: none; color: inherit;
}
.post:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.post .cover {
  position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center;
  color: #fff; overflow: hidden;
}
.post .cover.has-photo { background-size: cover; background-position: center; }
.post .cover .ico { font-size: 3.4rem; filter: drop-shadow(0 4px 10px rgba(0,0,0,.2)); }
.post .cover::after { /* แสงนุ่มมุมบน */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 80% 0%, rgba(255,255,255,.28), transparent 55%);
}

.post .body { display: flex; flex-direction: column; flex: 1; padding: 18px 18px 20px; }
.post .cat {
  font-size: .74rem; font-weight: 700; color: var(--emerald-600);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
/* หัวข้อ: ล็อก 2 บรรทัดเท่ากันทุกใบ */
.post h3 {
  font-size: 1.06rem; line-height: 1.4; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: calc(1.4em * 2);
}
/* เกริ่น: ล็อก 3 บรรทัดเท่ากันทุกใบ */
.post .excerpt {
  color: var(--ink-soft); font-size: .9rem; line-height: 1.6; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: calc(1.6em * 3);
}
.post .read {
  margin-top: 14px; font-weight: 700; font-size: .88rem; color: var(--emerald-700);
}
.post:hover .read { text-decoration: underline; }

/* ---------- หน้าบทความเต็ม ---------- */
.back-link {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  color: var(--emerald-700); font-weight: 700; font-size: .92rem; margin-bottom: 18px;
}
.back-link:hover { text-decoration: underline; }
.post-hero {
  border-radius: var(--radius); padding: 40px 30px; color: #fff; text-align: center;
  margin-bottom: 26px; position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.post-hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 80% 0%, rgba(255,255,255,.25), transparent 55%);
}
.post-hero .ico { font-size: 3rem; filter: drop-shadow(0 4px 10px rgba(0,0,0,.2)); position: relative; }
.post-hero .cat-badge {
  display: inline-block; background: rgba(255,255,255,.22); backdrop-filter: blur(4px);
  font-weight: 700; font-size: .78rem; padding: 5px 14px; border-radius: 999px;
  margin: 12px 0 8px; position: relative; letter-spacing: .3px;
}
.post-hero h1 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); line-height: 1.3; letter-spacing: -.4px; position: relative; }
.post-hero .art-meta { margin-top: 12px; font-size: .86rem; opacity: .95; position: relative; }
.post-hero .art-meta span { margin: 0 8px; }

.lead { font-size: 1.08rem !important; color: var(--ink) !important; font-weight: 600; }

/* รูปหน้าปกบทความ (featured image) */
.post-cover { margin: 0 0 22px; }
.post-cover img { width: 100%; height: auto; display: block; border-radius: 14px; box-shadow: var(--shadow-sm); }
.post-cover figcaption { font-size: .8rem; color: var(--ink-soft); text-align: center; margin-top: 8px; }

.related { margin-top: 40px; }
.related h2 {
  font-size: 1.25rem; text-align: center; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* ---------- หน้าสูตรอาหาร (recipe) ---------- */
.recipe-meta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; position: relative; }
.recipe-meta .chip {
  background: rgba(255,255,255,.22); backdrop-filter: blur(4px); color: #fff;
  font-weight: 700; font-size: .82rem; padding: 6px 14px; border-radius: 999px;
}
.ingredients { list-style: none; margin: 8px 0 10px; padding: 0; }
.ingredients li {
  position: relative; padding: 10px 12px 10px 38px; margin-bottom: 8px;
  background: var(--mint-50); border: 1px solid var(--line); border-radius: 11px; color: #33534a;
}
.ingredients li::before { content: "🥄"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .9rem; }
.steps { list-style: none; counter-reset: step; margin: 8px 0 10px; padding: 0; }
.steps li {
  position: relative; padding: 4px 0 18px 48px; margin: 0; color: #33534a; line-height: 1.7;
}
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald), var(--emerald-600)); color: #fff;
  font-weight: 800; display: grid; place-items: center; font-size: .95rem;
}
.steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 15px; top: 34px; bottom: 6px; width: 2px; background: var(--line);
}
.nutri-row { display: flex; gap: 12px; margin: 14px 0 4px; flex-wrap: wrap; }
.nutri {
  flex: 1; min-width: 90px; background: var(--mint-50); border: 1px solid var(--line);
  border-radius: 13px; padding: 13px; text-align: center;
}
.nutri .k { font-size: .76rem; color: var(--ink-soft); font-weight: 600; }
.nutri .v { font-size: 1.15rem; font-weight: 800; color: var(--emerald-700); margin-top: 2px; }
.tip-box {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 13px;
  padding: 14px 16px; color: #92620a; margin: 12px 0;
}
footer { text-align: center; color: var(--ink-soft); font-size: .82rem; padding: 30px 20px 40px; }
.feat-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.feat {
  text-decoration: none; color: var(--ink); background: var(--white); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 22px; box-shadow: var(--shadow-sm); transition: .18s; min-width: 150px;
}
.feat:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--mint-300); }
.feat .fi { font-size: 1.6rem; }
.feat .ft { font-weight: 700; margin-top: 6px; }
.feat .fd { font-size: .82rem; color: var(--ink-soft); }
