/* Weight Management Web - Phase 1 skeleton.
 *
 * Target: iOS Safari first (the only browser the owner actually uses for this), then everything
 * else. Three consequences, each deliberate:
 *
 * 1. `-webkit-` prefixed properties appear where Safari still needs them, and `env(safe-area-
 *    inset-*)` is used so the tab bar clears the home indicator on a notched device.
 * 2. `font: -apple-system-body`-adjacent sizing: a system font stack with `text-size-adjust:100%`
 *    so landscape rotation does not inflate the type.
 * 3. Nothing depends on a service worker or on offline caching - 03 §9 puts both out of Phase 1
 *    scope, and `tests/integration/test_web_no_service_worker.py` asserts it.
 */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: #d1d1d6;
  --accent: #0a84ff;
  --ok: #248a3d;
  --warn: #b25e00;
  --radius: 14px;
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #98989d;
    --line: #38383a;
    --accent: #0a84ff;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0 var(--gap) calc(64px + env(safe-area-inset-bottom)) var(--gap);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.app-bar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 2px 8px;
  padding-top: calc(14px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.app-bar h1 { font-size: 22px; margin: 0; }

.badge {
  font-size: 12px;
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.stack { display: flex; flex-direction: column; gap: var(--gap); }

.auth-required > :not(.auth-card) { display: none; }
.auth-card h2 { font-size: 18px; color: var(--text); }
.auth-card .form { margin-top: 14px; }
.auth-card input { width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  -webkit-overflow-scrolling: touch;
}

.card h2 { font-size: 13px; text-transform: none; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

.summary { font-size: 17px; font-variant-numeric: tabular-nums; }

.fine { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.notice {
  color: var(--warn);
  font-size: 13px;
  margin: 6px 0 0;
}

.list, .highlights { list-style: none; margin: 0; padding: 0; }

.list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.list li:last-child { border-bottom: 0; }

.meal-metrics { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-variant-numeric: tabular-nums; }
.meal-metrics small { color: var(--muted); font-size: 12px; line-height: 1.35; }

.highlights { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.highlights li { min-width: 96px; }
.highlights .value { font-size: 19px; font-variant-numeric: tabular-nums; display: block; }
.highlights .label { color: var(--muted); font-size: 12px; }
.highlights .state-estimate { color: var(--warn); }
.highlights .state-unavailable { color: var(--muted); }

.form { display: flex; flex-direction: column; gap: 6px; }

.form label { font-size: 13px; color: var(--muted); }

input, select, button, textarea {
  font: inherit;
  color: inherit;
}

input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  min-height: 40px; /* iOS zooms a smaller control on focus */
}

.check { display: flex; align-items: center; gap: 8px; }

button {
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  min-height: 44px; /* the iOS touch-target floor */
  margin-top: 6px;
}

button[disabled] { opacity: 0.5; }

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.tab { font-size: 12px; color: var(--muted); text-decoration: none; padding: 6px 4px; }
.tab.active { color: var(--accent); }

@media (min-width: 700px) {
  body { max-width: 720px; margin: 0 auto; }
}
