/* ── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:   #2563eb;
  --color-lose:      #f97316;
  --color-maintain:  #10b981;
  --color-gain:      #3b82f6;
  --color-protein:   #8b5cf6;
  --color-carbs:     #f59e0b;
  --color-fat:       #ef4444;
  --color-bg:        #f8fafc;
  --color-surface:   #ffffff;
  --color-text:      #1e293b;
  --color-muted:     #64748b;
  --color-border:    #e2e8f0;
  --radius:          12px;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --font:            -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html { font-size: 100%; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); line-height: 1.6; }
a { color: var(--color-primary); }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: 820px; margin: 0 auto; padding: 0 1rem; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header { background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: .75rem 0; }
.site-logo { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--color-text); }

/* ── Hero ───────────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: clamp(1.25rem, 4vw, 2.5rem) 0 1.25rem; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.2; margin-bottom: .5rem; }
.hero-subtitle { color: var(--color-muted); font-size: 1.05rem; }

/* ── Calculator wrapper ─────────────────────────────────────────────────────── */
.calculator-wrapper { background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; margin-bottom: 2rem; }

/* ── Form ───────────────────────────────────────────────────────────────────── */
.calc-form { display: grid; gap: 1rem; }
@media (min-width: 600px) {
  .calc-form { grid-template-columns: 1fr 1fr; }
  .calc-form > .unit-toggle-group,
  .calc-form > #imperial-fields,
  .calc-form > .btn-calculate { grid-column: 1 / -1; }
}
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-group label, .radio-group-label { font-weight: 600; font-size: .875rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input, .form-group select {
  padding: .75rem 1rem; border: 1.5px solid var(--color-border); border-radius: 8px;
  font-size: 1rem; font-family: inherit; background: var(--color-bg); color: var(--color-text);
  transition: border-color .15s; min-height: 44px;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--color-primary); }
.form-group input:focus-visible, .form-group select:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-calculate:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--color-primary); }
.unit-toggle-group { display: flex; flex-direction: row; gap: 1.5rem; }
.toggle-label { display: flex; align-items: center; gap: .4rem; font-weight: 500; cursor: pointer; min-height: 44px; padding: 0 .75rem; border-radius: 8px; }
.input-row { display: flex; gap: .5rem; }
.input-row input { flex: 1; }
.btn-calculate {
  margin-top: .5rem; padding: .875rem; background: var(--color-primary); color: #fff;
  border: none; border-radius: 8px; font-size: 1.05rem; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-calculate:hover { background: #1d4ed8; }
.btn-calculate:active { transform: scale(.98); }

/* ── Results ────────────────────────────────────────────────────────────────── */
.calc-results { display: none; margin-top: 1.5rem; }
.calc-results.visible { display: block; animation: fadeSlideUp .35s ease; }
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .calc-results.visible { animation: none; }
  html { scroll-behavior: auto; }
}

.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.result-card {
  background: var(--color-bg); border-radius: var(--radius); padding: 1.25rem;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .25rem;
}
.result-card--highlight { background: var(--color-primary); color: #fff; }
.result-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }
.result-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.result-value--large { font-size: 2.5rem; }
.result-unit { font-size: .8rem; opacity: .75; }

/* Goal color variants on highlight card */
.goal-lose     { background: var(--color-lose); }
.goal-lose .result-label,
.goal-lose .result-unit { color: rgba(0,0,0,.7); }
.goal-maintain { background: var(--color-maintain); }
.goal-gain     { background: var(--color-gain); }

/* ── Result explanation ─────────────────────────────────────────────────────── */
.result-explanation { text-align: center; color: var(--color-muted); font-size: .95rem; margin-bottom: 1.5rem; min-height: 1.4em; }

/* ── Macros ─────────────────────────────────────────────────────────────────── */
.macros-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; }
.food-table-link { margin-top: 1rem; font-size: .9rem; text-align: center; }
.macro-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 1rem; }
.macro-segment { transition: width .4s ease; }
.macro-protein { background: var(--color-protein); }
.macro-carbs   { background: var(--color-carbs); }
.macro-fat     { background: var(--color-fat); }

.macro-legend { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.macro-item { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.macro-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Ad unit ────────────────────────────────────────────────────────────────── */
.ad-unit { margin: 1.5rem 0; min-height: 90px; }

/* ── SEO content ────────────────────────────────────────────────────────────── */
.seo-content { margin: 2rem 0; }
.seo-content h2 { font-size: 1.5rem; margin: 2rem 0 .75rem; }
.seo-content h3 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
.seo-content p  { margin-bottom: 1rem; color: var(--color-text); }
.seo-content ul, .seo-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.seo-content li { margin-bottom: .4rem; }
.seo-content table, .article-content table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-bottom: 1.5rem; font-size: .95rem; }
.seo-content table th, .seo-content table td,
.article-content table th, .article-content table td { padding: .5rem .75rem; border: 1px solid var(--color-border); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seo-content table th, .article-content table th { background: var(--color-bg); font-weight: 700; color: var(--color-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.seo-content table tr:nth-child(even), .article-content table tr:nth-child(even) { background: var(--color-bg); }
.seo-content table th:nth-child(1), .seo-content table td:nth-child(1),
.article-content table th:nth-child(1), .article-content table td:nth-child(1) { width: 55%; }
.seo-content table th:nth-child(2), .seo-content table td:nth-child(2),
.article-content table th:nth-child(2), .article-content table td:nth-child(2) { width: 25%; }
.seo-content table th:nth-child(3), .seo-content table td:nth-child(3),
.article-content table th:nth-child(3), .article-content table td:nth-child(3) { width: 20%; }

/* ── Article ────────────────────────────────────────────────────────────────── */
.article-content { padding: 2rem 0; }
.article-content h1 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: 1.5rem; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--color-border); padding: 1.5rem 0; margin-top: 3rem; font-size: .875rem; color: var(--color-muted); }
.lang-switcher { display: flex; gap: 1rem; margin-top: .5rem; flex-wrap: wrap; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .calculator-wrapper { padding: 1.25rem; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .result-card--highlight { grid-column: 1 / -1; }
  .macro-legend { flex-direction: column; gap: .75rem; }
}
