/* ============================================================
   healthnut — shared design system (Apple Health, responsive)
   Mobile-first. Centered column on desktop.
   Translated from /designs/001-006 to live web.
   ============================================================ */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --grouped: #efeff4;
  --ink: #000000;
  --ink-2: #1c1c1e;
  --secondary: #3c3c43;
  --muted: rgba(60, 60, 67, 0.6);
  --muted-2: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.12);

  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --green: #34c759;
  --mint: #00c7be;
  --teal: #30b0c7;
  --blue: #007aff;
  --indigo: #5856d6;
  --purple: #af52de;
  --pink: #ff2d92;
  --leaf: #6b9e3f;

  --radius: 14px;
  --radius-lg: 18px;
  --maxw: 720px; /* desktop centered column width */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --grouped: #2c2c2e;
    --ink: #ffffff;
    --ink-2: #ebebf5;
    --secondary: #ebebf5;
    --muted: rgba(235, 235, 245, 0.6);
    --muted-2: rgba(235, 235, 245, 0.3);
    --sep: rgba(235, 235, 245, 0.12);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html, body { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  color: var(--ink);
  font-size: 15px;
  min-height: 100vh;
}

/* ---- App container — centered single column ---- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 16px 32px;
  position: relative;
}

@media (min-width: 800px) {
  .app { padding: 24px 24px 48px; }
}

/* ---- Navbar (top of each page) ---- */
.nav-block {
  padding: 8px 4px 14px;
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 10;
}
.nav-back {
  display: inline-flex; align-items: center;
  color: var(--blue); font-size: 16px; font-weight: 400;
  padding: 6px 0; text-decoration: none; cursor: pointer;
}
.nav-back::before { content: '‹'; font-size: 22px; margin-right: 4px; line-height: 1; }
.nav-title {
  font-size: 32px; font-weight: 800; letter-spacing: -0.6px; line-height: 1.1;
  margin-top: 2px;
}
@media (min-width: 800px) {
  .nav-title { font-size: 38px; letter-spacing: -0.8px; }
}
.nav-sub {
  font-size: 13px; color: var(--muted); font-weight: 500;
  margin-top: 6px; line-height: 1.4;
}
.nav-sub a { color: var(--blue); text-decoration: none; }

/* ---- Cross-page nav pills (sub-row under title) ---- */
.hn-nav {
  display: flex; gap: 6px; flex-wrap: wrap;
  font-size: 12.5px; margin: 14px 0 6px;
}
.hn-nav a {
  padding: 5px 11px; border-radius: 999px;
  background: var(--grouped); color: var(--muted);
  text-decoration: none; font-weight: 500;
}
.hn-nav a.active { background: var(--ink); color: var(--bg); font-weight: 600; }

/* ---- In-page tab pills (segmented) ---- */
.tab-pills {
  display: flex; gap: 2px; margin: 14px 0 18px;
  padding: 2px; background: rgba(118,118,128,0.12); border-radius: 9px;
  flex-wrap: nowrap; overflow: hidden;
}
.tab-pill {
  flex: 1; padding: 8px 12px; font-size: 13.5px; font-weight: 500;
  text-align: center; color: var(--ink); border-radius: 7px;
  border: 0; background: transparent; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.tab-pill.active {
  background: var(--card); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.tab-section { display: none; }
.tab-section.active { display: block; }

/* ---- Section headings ---- */
.section-head {
  padding: 18px 4px 6px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.section-head .ttl {
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.section-head .ttl.big {
  font-size: 22px; font-weight: 700; color: var(--ink);
  text-transform: none; letter-spacing: -0.4px;
}
.section-head .more {
  color: var(--blue); font-size: 14px; font-weight: 400; text-decoration: none;
}

/* ---- Card primitives ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  overflow: hidden;
  margin: 0 0 8px;
}
.card.padded { padding: 14px 16px; }
.card-row {
  padding: 13px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--sep);
}
.card-row:last-child { border-bottom: 0; }
.card-row > .body { flex: 1; min-width: 0; }
.card-row .ttl { font-size: 14.5px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; }
.card-row .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.card-row .chev { color: var(--muted-2); font-size: 18px; line-height: 1; flex-shrink: 0; }
.card-row a, a.card-row { color: inherit; text-decoration: none; display: flex; }
.card-row.link { cursor: pointer; }
.card-row.link:active { background: var(--grouped); }

/* ---- Icon chips ---- */
.icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; flex-shrink: 0;
  color: white; font-size: 14px; font-weight: 700;
  background: var(--blue);
}
.icon.sm { width: 24px; height: 24px; border-radius: 6px; font-size: 12px; }
.icon.lg { width: 40px; height: 40px; border-radius: 10px; font-size: 18px; }
.icon.red { background: var(--red); }
.icon.orange { background: var(--orange); }
.icon.yellow { background: var(--yellow); color: var(--ink); }
.icon.green { background: var(--green); }
.icon.mint { background: var(--mint); }
.icon.teal { background: var(--teal); }
.icon.blue { background: var(--blue); }
.icon.indigo { background: var(--indigo); }
.icon.purple { background: var(--purple); }
.icon.pink { background: var(--pink); }
.icon.leaf { background: var(--leaf); }
.icon.muted { background: rgba(60,60,67,0.4); }

/* ---- Hero card (used on detail screens) ---- */
.hero {
  padding: 4px 4px 16px;
}
.hero .eyebrow {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.hero .ttl {
  font-size: 26px; font-weight: 800; letter-spacing: -0.5px;
  margin-top: 6px; line-height: 1.15;
}
.hero .stat {
  display: flex; align-items: flex-end; gap: 14px; margin-top: 14px;
}
.hero .big-num {
  font-size: 56px; font-weight: 800; line-height: 0.9;
  letter-spacing: -1.5px; font-variant-numeric: tabular-nums;
}
.hero .big-num .pct { font-size: 24px; color: var(--secondary); font-weight: 600; margin-left: 2px; }
.hero .delta { font-size: 13px; color: var(--green); font-weight: 600; padding-bottom: 6px; }
.hero .delta.flat { color: var(--muted); }
.hero .delta.down { color: var(--red); }
.hero .meta-line { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* ---- Featured banner card (gradient hero — for "today's signature" etc) ---- */
.feat {
  background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  margin: 0 0 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}
.feat.purple { background: linear-gradient(135deg, #af52de 0%, #5856d6 100%); box-shadow: 0 4px 16px rgba(175,82,222,0.18); }
.feat.green { background: linear-gradient(135deg, #34c759 0%, #00c7be 100%); box-shadow: 0 4px 16px rgba(52,199,89,0.18); }
.feat.red { background: linear-gradient(135deg, #ff3b30 0%, #ff9500 100%); box-shadow: 0 4px 16px rgba(255,59,48,0.18); }
.feat .eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.7); font-weight: 600; }
.feat .ttl { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; margin-top: 6px; }
.feat .big { font-size: 44px; font-weight: 800; letter-spacing: -1.2px; line-height: 1; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.feat .big .unit { font-size: 18px; font-weight: 600; color: rgba(255,255,255,0.7); margin-left: 4px; }
.feat .sub { font-size: 13.5px; color: rgba(255,255,255,0.78); line-height: 1.45; }
.feat .footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.14); font-size: 12px; color: rgba(255,255,255,0.7); }

/* ---- Stat grid (2-up cards) ---- */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 0 0 8px;
}
@media (min-width: 800px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 14px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.stat-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
}
.stat-name { font-size: 13px; font-weight: 500; flex: 1; color: var(--secondary); }
.stat-num {
  font-size: 26px; font-weight: 700; letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat-num .unit { font-size: 14px; color: var(--secondary); font-weight: 500; margin-left: 2px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.3; }

/* ---- Tag pills ---- */
.tag {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; color: white;
  background: var(--blue); vertical-align: middle;
}
.tag.red { background: var(--red); }
.tag.orange { background: var(--orange); }
.tag.yellow { background: var(--yellow); color: var(--ink); }
.tag.green { background: var(--green); }
.tag.purple { background: var(--purple); }
.tag.muted { background: rgba(60,60,67,0.32); }
.tag.outline {
  background: transparent; color: var(--secondary);
  box-shadow: inset 0 0 0 1px var(--sep);
}

/* ---- Build chip ---- */
.build-tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: 10px;
  color: var(--muted); background: var(--grouped);
  font-family: ui-monospace, monospace;
  margin-left: 8px; vertical-align: middle;
  font-weight: 500;
}

/* ---- Inline list (Apple Health style data list) ---- */
.list {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  margin: 0 0 8px;
}
.li {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--sep);
}
.li:last-child { border-bottom: 0; }
.li .lbl { color: var(--secondary); font-size: 14.5px; }
.li .val { margin-left: auto; font-size: 14.5px; font-weight: 600; }
.li .val.muted { color: var(--muted); font-weight: 500; }

/* ---- Tables (used in genetics, substrate) — light Apple aesthetic ---- */
table.t {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
table.t th, table.t td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--sep);
  vertical-align: top;
}
table.t th {
  background: var(--grouped); color: var(--muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
table.t tr:last-child td { border-bottom: 0; }
table.t td code {
  background: var(--grouped); padding: 1px 6px; border-radius: 4px; font-size: 12px;
}

/* ---- Notes & utility ---- */
.note { color: var(--muted); font-size: 12.5px; margin: 18px 4px 0; line-height: 1.5; }
.note a { color: var(--blue); text-decoration: none; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---- Empty-state placeholder (still used sparingly in scaffold spots) ---- */
.placeholder {
  border: 1.5px dashed var(--muted-2);
  border-radius: var(--radius);
  padding: 18px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  font-style: italic;
  line-height: 1.45;
  margin-bottom: 10px;
}
.placeholder b {
  color: var(--secondary); font-style: normal; font-weight: 600;
  display: block; margin-bottom: 4px;
}
