/* ── HEMINGWAY PERFORMANCE — BASE STYLES ─────────────────────────────────────
   Shared across app.html and dashboard.html
   Import: <link rel="stylesheet" href="/css/hp-base.css">
──────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ── VARIABLES ───────────────────────────────────────────────────────────── */
:root {
  --bg:        #f7f5f0;
  --bg2:       #efecea;
  --bg3:       #e8e4de;
  --white:     #ffffff;
  --border:    #e0dbd4;
  --border2:   #ccc7be;
  --green:     #2d6a4f;
  --green-lt:  #e8f4ee;
  --green-mid: #52b788;
  --amber:     #c77d0a;
  --amber-lt:  #fdf3e3;
  --rose:      #c0392b;
  --rose-lt:   #fdecea;
  --blue:      #2563a8;
  --blue-lt:   #e8f0fb;
  --ink:       #1a1814;
  --ink2:      #4a4540;
  --ink3:      #9a9490;
  --sans:      'Outfit', sans-serif;
  --serif:     'Outfit', serif;
  /* Typography scale — pages should reference these rather than hardcoding px.
     Shared classes (.slabel, .met-label, .met-sub, .form-label) are ALSO declared in page
     fragments (training.html, protocols.html, blood.html) for layout reasons (flex dividers,
     spacing/color variants) — but as of 2026-07-24 none of those fragment declarations set
     font-size anymore; they inherit it from here. A token change now propagates everywhere
     without needing to touch fragments. Rule going forward: add label sizes as tokens here,
     never as a font-size line in a fragment override — even a value that currently matches
     the token will silently stop tracking it. (body.html's .slabel is a known pre-existing
     exception, still hardcoded at 10px — out of scope here, would be a visual change to fix.) */
  --fs-label:      12px;  /* uppercase micro-labels (was 10px) */
  --fs-sub:        13px;  /* card sub-text / meta lines (was 11–12px) */
  --fs-card-title: 19px;  /* name of a card/item — must exceed the values inside it */
  --r:         10px;
  --r2:        16px;
  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow2:   0 2px 8px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
}

/* ── DARK MODE ───────────────────────────────────────────────────────────── */
body.dark {
  --bg:        #0f0e0c;
  --bg2:       #1a1916;
  --bg3:       #242220;
  --white:     #1e1c1a;
  --border:    #2e2c29;
  --border2:   #3d3b37;
  --green:     #52b788;
  --green-lt:  #0d2318;
  --green-mid: #52b788;
  --amber:     #f0a030;
  --amber-lt:  #2a1e08;
  --rose:      #e05c4a;
  --rose-lt:   #2a0f0a;
  --blue:      #5b9be8;
  --blue-lt:   #0a1628;
  --ink:       #f0ede8;
  --ink2:      #b8b4ae;
  --ink3:      #9a958e;
  --shadow:    0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --shadow2:   0 2px 8px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.3);
}

/* ── RESET ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* NOTE: top inset is intentionally NOT applied here. The app shell handles it
     via the fixed .app-header + .app-content padding-top (both safe-area-aware).
     Applying it on body too double-counts the inset and opens a gap on notched
     devices (invisible on desktop where the inset is 0). See CONTEXT.md §5. */
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ── TYPOGRAPHY ──────────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--sans); color: var(--ink); }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── SHARED COMPONENTS ───────────────────────────────────────────────────── */

/* Cards */
.card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r2);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* Section labels */
.slabel {
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 12px;
}

/* Metric cards */
.met {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r2);
  padding: 16px;
  box-shadow: var(--shadow);
}
.met-label { font-size: var(--fs-label); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink3); margin-bottom: 6px; }
.met-val   { font-size: 32px; font-weight: 300; color: var(--ink); line-height: 1; }
.met-sub   { font-size: var(--fs-sub); color: var(--ink3); margin-top: 4px; }

/* Buttons */
.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 12px 24px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  background: none;
  color: var(--ink2);
  border: 1.5px solid var(--border2);
  border-radius: 100px;
  padding: 12px 24px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge-green  { background: var(--green-lt);  color: var(--green); }
.badge-amber  { background: var(--amber-lt);  color: var(--amber); }
.badge-rose   { background: var(--rose-lt);   color: var(--rose); }
.badge-blue   { background: var(--blue-lt);   color: var(--blue); }

/* Progress bar */
.prog-bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.prog-bar-fill { height: 100%; background: var(--green-mid); border-radius: 3px; transition: width 0.4s ease; }

/* Divider */
.divider { border: none; border-top: 1.5px solid var(--border); margin: 24px 0; }

/* Alert banners */
.alert {
  border-radius: var(--r);
  padding: 14px 16px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-amber { background: var(--amber-lt); color: var(--amber); border: 1px solid #f5d9a0; }
.alert-rose  { background: var(--rose-lt);  color: var(--rose);  border: 1px solid #f5c6c0; }
.alert-green { background: var(--green-lt); color: var(--green); border: 1px solid #b7e0c8; }

/* Sync message */
.sync-msg {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--green-lt);
  color: var(--green);
  display: none;
}

/* Progress bar top */
.progress-bar-top {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: var(--green-mid);
  z-index: 999;
  transition: width 0.3s ease;
  width: 0%;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.5);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: 16px;
  padding: 24px 24px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  margin: auto 0 80px;
}
.modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 20px;
}

/* Bottom nav must stay pinned — never let a transform (keyboard/scroll handlers, etc.)
   shift or detach it. !important overrides the inline translate3d in app.html. */
.bottom-nav {
  transform: none !important;
  -webkit-transform: none !important;
}

/* Form inputs */
.form-label {
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 6px;
  display: block;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 15px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  color: var(--ink);
  outline: none;
}
.form-input:focus { border-color: var(--green); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 16px; }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.4s ease both; }
