/* ============================================================
   Educated Carbs shared design system
   Headings: Bricolage Grotesque · Body: Newsreader
   ============================================================ */

:root {
  --paper:      #F3F5F1;
  --paper-2:    #FBFCFA;
  --ink:        #17201B;
  --ink-soft:   #3C463F;
  --muted:      #6A7269;
  --spruce:     #123B2E;
  --spruce-2:   #1C5A45;
  --line:       #DDE2DA;
  --line-soft:  #E9ECE6;
  --lime:       #B7E63A;   /* ketones / fat-burning */
  --lime-deep:  #7FA81E;
  --glucose:    #E7A63C;   /* carbs / glucose */
  --glucose-dp: #C77C1E;
  --danger:     #B4472E;

  --maxw: 1120px;
  --readw: 720px;
  --radius: 4px;
  --shadow: 0 1px 0 rgba(23,32,27,.04), 0 12px 32px -18px rgba(18,59,46,.28);

  --f-display: "Bricolage Grotesque", system-ui, sans-serif;
  --f-body: "Newsreader", Georgia, "Times New Roman", serif;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 19px;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: var(--spruce-2); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--spruce); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- type ---------- */
h1, h2, h3, h4, .display, .eyebrow, nav, .btn, .tag, .label {
  font-family: var(--f-display);
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.08; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: clamp(2.3rem, 5.4vw, 4rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); margin: 2.6rem 0 1rem; }
h3 { font-size: 1.3rem; margin: 2rem 0 .6rem; }

.eyebrow {
  font-size: .74rem; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--spruce-2);
  display: inline-flex; align-items: center; gap: .55rem;
}
.eyebrow::before {
  content: ""; width: 26px; height: 2px; background: var(--lime-deep); display: inline-block;
}

.lead { font-size: 1.24rem; color: var(--ink-soft); line-height: 1.55; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 66px;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand .mark { width: 30px; height: 30px; flex: 0 0 auto; }
.brand b {
  font-family: var(--f-display); font-weight: 700; color: var(--ink);
  font-size: 1.18rem; letter-spacing: -.02em;
}
.brand b span { color: var(--spruce-2); }

.nav-links { display: flex; align-items: center; gap: 1.6rem; }
.nav-links a {
  font-family: var(--f-display); font-size: .92rem; font-weight: 500;
  color: var(--ink-soft); text-decoration: none; letter-spacing: .01em;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--spruce); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--line);
  border-radius: var(--radius); width: 42px; height: 38px; cursor: pointer;
  align-items: center; justify-content: center;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 18px; height: 2px; background: var(--ink);
  position: relative; transition: .2s;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after  { position: absolute; top: 6px; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute; top: 66px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--paper-2); border-bottom: 1px solid var(--line);
    padding: .4rem 24px 1rem;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .75rem 0; width: 100%; border-bottom: 1px solid var(--line-soft); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .95rem; font-weight: 600; letter-spacing: .01em;
  padding: .72rem 1.3rem; border-radius: 999px; cursor: pointer;
  text-decoration: none; border: 1px solid transparent; transition: transform .12s ease, background .2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--spruce); color: #fff; }
.btn-primary:hover { background: var(--spruce-2); color: #fff; }
.btn-ghost { background: transparent; color: var(--spruce); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--spruce-2); color: var(--spruce); }

/* ---------- fuel gauge signature ---------- */
.gauge { --pos: 74%; width: 100%; max-width: 460px; }
.gauge-track {
  position: relative; height: 16px; border-radius: 999px;
  background: linear-gradient(90deg, var(--glucose) 0%, #d9c24a 42%, var(--lime) 100%);
  box-shadow: inset 0 0 0 1px rgba(23,32,27,.08);
}
.gauge-knob {
  position: absolute; top: 50%; left: var(--pos);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--paper-2); border: 3px solid var(--spruce);
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px -4px rgba(18,59,46,.6);
  transition: left 1.1s cubic-bezier(.65,.05,.36,1);
}
.gauge-labels {
  display: flex; justify-content: space-between; margin-top: .7rem;
  font-family: var(--f-display); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
}
.gauge-labels .g { color: var(--glucose-dp); }
.gauge-labels .k { color: var(--lime-deep); }

/* ---------- hero ---------- */
.hero { padding: clamp(3rem, 8vw, 6.5rem) 0 clamp(2.5rem,5vw,4rem); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(2rem,5vw,4rem); align-items: center; }
.hero h1 { margin: 1.1rem 0 0; }
.hero .lead { margin: 1.4rem 0 2rem; max-width: 34ch; }
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; }
.hero-panel {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 2rem; box-shadow: var(--shadow);
}
.hero-panel h4 { margin: 0 0 1.3rem; font-size: .95rem; letter-spacing: .04em; color: var(--muted); font-weight: 500; }
.hero-stat { display: flex; align-items: baseline; gap: .5rem; margin-top: 1.4rem; }
.hero-stat b { font-family: var(--f-display); font-size: 1.5rem; color: var(--spruce); }
.hero-stat span { font-size: .95rem; color: var(--muted); }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } }

/* ---------- section headers ---------- */
.section { padding: clamp(2.5rem,6vw,4.5rem) 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.section-head h2 { margin: .6rem 0 0; }
.section-head p { margin: 0; color: var(--muted); max-width: 46ch; }

/* ---------- article cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
@media (max-width: 900px) { .card-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px) { .card-grid { grid-template-columns: 1fr; } }

.card {
  display: flex; flex-direction: column; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  text-decoration: none; color: inherit; transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--spruce-2); }
.card-top { height: 6px; }
.card-body { padding: 1.3rem 1.3rem 1.5rem; display: flex; flex-direction: column; height: 100%; }
.tag {
  font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  padding: .28rem .6rem; border-radius: 999px; align-self: flex-start;
}
.tag.carbs   { background: #fbeed3; color: var(--glucose-dp); }
.tag.keto    { background: #e9f6c9; color: var(--lime-deep); }
.tag.exercise{ background: #d7ebe3; color: var(--spruce-2); }
.card h3 { margin: .9rem 0 .5rem; font-size: 1.22rem; line-height: 1.15; }
.card p { margin: 0; font-size: .98rem; color: var(--ink-soft); line-height: 1.5; }
.card .meta { margin-top: auto; padding-top: 1rem; font-family: var(--f-display); font-size: .78rem; color: var(--muted); letter-spacing: .03em; }

/* ---------- article page ---------- */
.article { padding: 2.5rem 0 1rem; }
.article-head { max-width: var(--readw); margin: 0 auto; }
.article-head h1 { margin: 1rem 0 1.2rem; }
.article-meta {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  font-family: var(--f-display); font-size: .82rem; color: var(--muted);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: .9rem 0; margin-bottom: 2rem;
}
.article-body { max-width: var(--readw); margin: 0 auto; }
.article-body > p { margin: 1.15rem 0; }
.article-body h2 { border-bottom: 1px solid var(--line-soft); padding-bottom: .4rem; }
.article-body ul, .article-body ol { padding-left: 1.3rem; margin: 1.1rem 0; }
.article-body li { margin: .5rem 0; }
.article-body strong { color: var(--ink); }

.callout {
  background: var(--paper-2); border: 1px solid var(--line);
  border-left: 4px solid var(--spruce-2); border-radius: 6px;
  padding: 1.1rem 1.3rem; margin: 1.8rem 0; font-size: .98rem;
}
.callout.warn { border-left-color: var(--glucose-dp); background: #fdf6e8; }
.callout b { font-family: var(--f-display); }

.keytakeaways {
  background: var(--spruce); color: #eaf3ee; border-radius: 12px;
  padding: 1.6rem 1.7rem; margin: 2.2rem 0;
}
.keytakeaways h3 { color: #fff; margin: 0 0 .8rem; font-size: 1.05rem; letter-spacing: .04em; text-transform: uppercase; }
.keytakeaways ul { margin: 0; padding-left: 1.1rem; }
.keytakeaways li { margin: .5rem 0; color: #dcebe3; }

.disclaimer-strip {
  max-width: var(--readw); margin: 2.5rem auto 0;
  font-size: .86rem; color: var(--muted); line-height: 1.55;
  border-top: 1px dashed var(--line); padding-top: 1.2rem;
}

.related { border-top: 1px solid var(--line); margin-top: 3rem; padding-top: 2rem; }

/* ---------- legal / text pages ---------- */
.doc { padding: 2.5rem 0 2rem; }
.doc-inner { max-width: 800px; margin: 0 auto; }
.doc-inner h1 { font-size: clamp(2rem,4vw,2.8rem); }
.doc-inner h2 { font-size: 1.35rem; margin-top: 2.2rem; }
.doc-inner h3 { font-size: 1.08rem; }
.doc-inner p, .doc-inner li { font-size: 1.02rem; }
.doc-meta { color: var(--muted); font-family: var(--f-display); font-size: .85rem; margin: .5rem 0 2rem; }
.doc-inner table { width: 100%; border-collapse: collapse; margin: 1.4rem 0; font-size: .95rem; }
.doc-inner th, .doc-inner td { border: 1px solid var(--line); padding: .6rem .8rem; text-align: left; vertical-align: top; }
.doc-inner th { background: var(--paper-2); font-family: var(--f-display); }
.placeholder { background: #fdf6e8; padding: 0 .25rem; border-radius: 3px; color: var(--glucose-dp); font-style: normal; }

/* ---------- callout box for legal notice ---------- */
.notice-box {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.3rem 1.5rem; margin: 1.5rem 0; font-size: .95rem;
}

/* ---------- forms (contact) ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-family: var(--f-display); font-size: .85rem; margin-bottom: .35rem; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--f-body); font-size: 1rem; background: var(--paper-2); color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--spruce-2); border-color: var(--spruce-2); }

/* ---------- footer ---------- */
.site-footer { background: var(--spruce); color: #cfe0d7; margin-top: 4rem; }
.site-footer a { color: #e7f1ea; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-grid {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 2rem;
  padding: 3rem 0 2rem;
}
.footer-grid h5 { font-family: var(--f-display); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: #8fb4a4; margin: 0 0 1rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin: .55rem 0; font-size: .95rem; }
.footer-brand b { font-family: var(--f-display); font-size: 1.3rem; color: #fff; }
.footer-brand p { font-size: .95rem; color: #a9c6ba; max-width: 34ch; margin: .8rem 0 0; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.12); padding: 1.4rem 0 2.4rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: .82rem; color: #9fbfb1;
}
@media (max-width: 780px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------- cookie consent ---------- */
.cookie-bar {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60;
  max-width: 720px; margin: 0 auto;
  background: var(--ink); color: #eef2ee; border-radius: 12px;
  padding: 1.1rem 1.3rem; box-shadow: 0 18px 40px -16px rgba(0,0,0,.6);
  display: none; gap: 1rem; align-items: center; flex-wrap: wrap;
}
.cookie-bar.show { display: flex; }
.cookie-bar p { margin: 0; font-size: .9rem; flex: 1 1 320px; line-height: 1.5; color: #d6ded7; }
.cookie-bar a { color: var(--lime); }
.cookie-bar .actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.cookie-bar .btn { padding: .55rem 1.1rem; font-size: .85rem; }
.cookie-bar .btn-primary { background: var(--lime); color: var(--ink); }
.cookie-bar .btn-primary:hover { background: #c8ef54; color: var(--ink); }
.cookie-bar .btn-ghost { color: #eef2ee; border-color: rgba(255,255,255,.25); }

/* ---------- misc ---------- */
.breadcrumb { font-family: var(--f-display); font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.breadcrumb a { color: var(--muted); }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
hr.rule { border: none; border-top: 1px solid var(--line); margin: 2.5rem 0; }

:focus-visible { outline: 3px solid var(--spruce-2); outline-offset: 2px; border-radius: 3px; }

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

/* ---------- hero intake widget ---------- */
.quiz {
  background: linear-gradient(180deg, var(--paper-2), #fff);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1rem;
  max-width: 34rem;
}
.quiz-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.1rem; }
.quiz-eyebrow {
  font-family: var(--f-display); font-weight: 600; font-size: .72rem;
  letter-spacing: .09em; text-transform: uppercase; color: var(--spruce-2);
  white-space: nowrap;
}
.quiz-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.quiz-bar i { display: block; height: 100%; width: 12%; border-radius: 99px;
  background: linear-gradient(90deg, var(--lime), var(--spruce-2)); transition: width .4s ease; }
.quiz-stage { min-height: 148px; }
.q-title { font-family: var(--f-display); font-weight: 600; font-size: 1.18rem;
  line-height: 1.25; color: var(--ink); margin: 0 0 .3rem; }
.q-sub { font-size: .92rem; color: var(--muted); margin: 0 0 1rem; }

/* draggable sex switch */
.sexswitch {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 99px; padding: 4px; margin: .2rem 0 .3rem; touch-action: none; user-select: none;
}
.sexswitch .ss-knob {
  position: absolute; top: 4px; left: 4px; bottom: 4px; width: calc(50% - 4px);
  border-radius: 99px; background: var(--spruce);
  box-shadow: 0 6px 16px -8px rgba(18,59,46,.7);
  transform: translateX(0); transition: transform .38s cubic-bezier(.22,1.2,.36,1);
  opacity: 0; pointer-events: none;
}
.sexswitch[data-value] .ss-knob { opacity: 1; }
.sexswitch[data-value="male"] .ss-knob { transform: translateX(100%); }
.sexswitch.dragging .ss-knob { transition: none; }
.ss-opt {
  position: relative; z-index: 2; background: none; border: 0; cursor: pointer;
  font-family: var(--f-display); font-weight: 600; font-size: .98rem;
  padding: .72rem 0; color: var(--ink-soft); border-radius: 99px; transition: color .3s;
}
.sexswitch[data-value="female"] .ss-opt[data-val="female"],
.sexswitch[data-value="male"]   .ss-opt[data-val="male"] { color: #fff; }
.ss-hint { display:block; text-align:center; font-size:.82rem; color:var(--muted); margin-top:.15rem; }
.sexswitch[data-value] + .ss-hint { visibility: hidden; }

/* text + choice inputs */
.q-field { display: flex; align-items: center; gap: .6rem; margin-top: .3rem; }
.q-input {
  flex: 1; font-family: var(--f-body); font-size: 1.15rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .85rem; width: 100%;
}
.q-input:focus-visible { outline: 2px solid var(--spruce-2); outline-offset: 1px; }
.q-unit { font-family: var(--f-display); font-weight: 600; color: var(--muted); font-size: .95rem; }
.q-choices { display: grid; gap: .55rem; margin-top: .2rem; }
.q-choices.cols-2 { grid-template-columns: 1fr 1fr; }
.q-choice {
  text-align: left; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .8rem .9rem; cursor: pointer;
  font-family: var(--f-display); font-weight: 500; font-size: .98rem; color: var(--ink-soft);
  transition: border-color .2s, background .2s, color .2s;
}
.q-choice:hover { border-color: var(--spruce-2); }
.q-choice[aria-pressed="true"] { background: var(--spruce); border-color: var(--spruce); color: #fff; }

/* footer buttons */
.quiz-foot { display: flex; align-items: center; gap: .7rem; margin-top: 1.1rem; }
.quiz-next { margin-left: auto; }
.quiz-back {
  background: none; border: 0; cursor: pointer; color: var(--muted);
  font-family: var(--f-display); font-weight: 500; font-size: .92rem; padding: .4rem .2rem;
}
.quiz-back:hover { color: var(--ink); }
.quiz-next:disabled { opacity: .45; cursor: not-allowed; }
.quiz-fine { font-size: .78rem; color: var(--muted); margin: .8rem 0 0; line-height: 1.4; }

/* result */
.q-result { animation: qfade .45s ease both; }
.q-badge {
  display: inline-block; font-family: var(--f-display); font-weight: 600; font-size: .74rem;
  letter-spacing: .06em; text-transform: uppercase; padding: .28rem .6rem; border-radius: 99px; margin-bottom: .6rem;
}
.q-badge.warm { background: #FBEFD9; color: var(--glucose-dp); }
.q-badge.good { background: #EBF6D2; color: var(--lime-deep); }
.q-result p { margin: 0 0 .7rem; font-size: .98rem; color: var(--ink-soft); }
.q-result .bmi { font-family: var(--f-display); font-weight: 700; color: var(--spruce); }
.q-mail {
  display: inline-flex; align-items: center; gap: .5rem; margin-top: .2rem;
  background: var(--spruce); color: #fff; text-decoration: none; border-radius: var(--radius);
  padding: .75rem 1.1rem; font-family: var(--f-display); font-weight: 600; font-size: .98rem;
}
.q-mail:hover { background: var(--spruce-2); }
.q-restart {
  display: inline-block; margin-top: .9rem; background: none; border: 0; cursor: pointer;
  color: var(--muted); font-family: var(--f-display); font-size: .88rem; text-decoration: underline;
}
@keyframes qfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sexswitch .ss-knob, .quiz-bar i { transition: none; }
  .q-result { animation: none; }
}
