/* Neeve v2 design system — aligned to the Neeve Design Brief (May 2026).
   Palette anchored on Ink #2B2018 / Cream #F8F1E7. The five named
   sleep-stage colours are normative for charts and the four-stage
   mix bar. Legacy variables are kept as aliases so older pages don't
   break while the refactor lands progressively. */
:root {
  /* Brief-canonical palette */
  --ink:         #2B2018;   /* primary text */
  --taupe:       #9A8369;   /* secondary text / muted */
  --cream:       #F8F1E7;   /* primary surface */
  --cream-soft:  #FFFDF9;   /* frosted card base */
  --plum:        #8F6C86;   /* deep sleep */
  --salmon:      #CB8270;   /* light sleep */
  --clay:        #BF5A3C;   /* REM, Alys dot */
  --gold:        #C8A23F;   /* awake */
  --ink-text-on-warm: #fff7f0; /* text laid over hero gradient */
  --ink-text-on-day:  #5A3F2E; /* text in day-phase content */

  /* Aliases mapped to the canonical names so old code keeps working
     while pages are progressively migrated. */
  --bone:        var(--cream);
  --bone-deep:   #F2EBE0;
  --ink-soft:    #5C4F45;
  --ink-mute:    var(--taupe);
  --hair:        #E5DCCE;
  --rose:        var(--salmon);
  /* Light sleep should be salmon (per the canonical base palette
     comments); REM stays on clay. Both were aliased to --clay so the
     hypnogram showed light + REM as identical pixels — Patrick's
     "light and REM are too close in colour" was actually "they ARE
     the same colour." Fixed. */
  --rose-deep:   var(--salmon);
  --terra:       var(--clay);

  /* Canonical sleep-stage palette. Single source of truth so the
     Ring page's hypnogram bar, the sleep.html detail page's legend
     dots + nightly bars, and any future surface all agree. The hex
     values come from a hand-picked separation pass: gold vs
     sage-deep are clearly distinguishable on a small bar, clay vs
     plum are clearly distinguishable for the bookends. */
  /* Patrick's pick: earthy warm + cool. No yellow/gold anywhere; the
     bar reads as two warm tones (clay → salmon) lying alongside two
     cool tones (plum → sage). Awake stays clay because it should pop
     when it appears; light gets the lighter, calmer salmon since it
     dominates the night and shouldn't visually shout. */
  --stage-awake: #BF5A3C;   /* clay   — brief get-ups stand out warmly */
  --stage-light: #CB8270;   /* salmon — the bulk of the night, calm warm */
  --stage-deep:  #8F6C86;   /* plum   — restorative */
  --stage-rem:   #A091B5;   /* lavender — dreamy, soft cool to complement plum */
  --sage:        #A9B89A;
  --sage-deep:   #7E927A;
  --butter:      #EBC982;
  --butter-deep: var(--gold);
}

/* Tap-to-explain affordance — small "ⓘ" in the corner of any card
   that has a METRIC_EXPLAINERS entry in lib.js. Defined globally so
   Today vitals tiles, Ring page cards and any future surface all use
   the same button styling. */
.stat-help {
  position: absolute; top: 10px; right: 10px;
  font-size: 14px; color: var(--ink-mute, #b9a994);
  background: transparent; border: 0; padding: 4px 8px;
  cursor: pointer; line-height: 1; z-index: 2;
}
.stat-help:active { color: var(--ink-2, #2b2018); }

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Apricosa — Neeve's display face by Sweetest Goods. Self-hosted at
   /health/v2/fonts/. Available on every v2 page via this stylesheet. */
@font-face {
  font-family: 'Apricosa';
  src: url('/v2/fonts/Apricosa-Regular.woff') format('woff'),
       url('/v2/fonts/Apricosa-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html, body {
  background: var(--cream);
  color: var(--ink);
  /* Hanken Grotesk is the brief's body face. Inter Tight stays as a
     fallback for any inline overrides that haven't migrated yet. */
  font-family: 'Hanken Grotesk', 'Inter Tight', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.45;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
  position: relative;
}

.page {
  max-width: 540px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}

/* Typography */
.title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 34px;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.5px;
}
.title-sm {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--ink);
}
.label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 500;
}
.body { color: var(--ink-soft); }
.caption { color: var(--ink-mute); font-size: 13px; }

/* Cards */
.card {
  background: white;
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 20px;
  margin-top: 16px;
}
.card-cream {
  background: var(--cream);
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 20px;
  margin-top: 16px;
}

/* Hero metric row */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--hair);
}
.metric-row:last-child { border-bottom: none; }
.metric-value {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 28px;
  color: var(--ink);
}
.metric-unit {
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  color: var(--ink-mute);
  margin-left: 4px;
}
.metric-label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 14px;
  color: var(--ink-soft);
}

/* Sparkline mini-chart (taller now to fit a time axis) */
.sparkline {
  width: 100%;
  height: 100px;
  margin-top: 8px;
}

/* Floating pill nav — sits centred above the home indicator with a soft
   shadow. Replaces the old edge-to-edge bar (which fought the brand's
   "negative space" pillar). Stays calm: warm cream surface, soft sage
   active indicator, no border line above. */
.nav {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 251, 244, 0.92);
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
  backdrop-filter: blur(18px) saturate(1.05);
  border: 1px solid rgba(44, 32, 23, .07);
  border-radius: 999px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 20;
  box-shadow:
    0 18px 38px -22px rgba(70, 45, 25, .35),
    0 4px 14px -8px rgba(70, 45, 25, .18);
  max-width: calc(100% - 32px);
}
.nav-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
  padding: 8px 6px 6px;
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--ink-mute);
  text-decoration: none;
  font-weight: 500;
  border-radius: 999px;
  position: relative;
  transition: color .18s ease;
}
.nav-item svg {
  width: 20px; height: 20px;
  stroke-width: 1.5;
  transition: transform .18s ease;
}
.nav-item.active { color: var(--ink); }
.nav-item.active svg { transform: translateY(-1px); }
/* Active dot beneath the active item — sage, soft, no shouting. */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--sage-deep, #7E927A);
}

/* Buttons */
.btn {
  display: inline-block;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 500;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--terra); color: white; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--hair); }

/* Section spacing */
.section { margin-top: 32px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-link { color: var(--terra); font-size: 13px; text-decoration: none; }

/* Loading / empty states */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink-mute);
  font-size: 14px;
}

/* Pills (status / sleep stage labels) */
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bone-deep);
  color: var(--ink-soft);
}
.pill-sage  { background: rgba(169, 184, 154, 0.25); color: var(--sage-deep); }
.pill-rose  { background: rgba(224, 153, 139, 0.25); color: var(--rose-deep); }
.pill-butter { background: rgba(235, 201, 130, 0.3); color: var(--butter-deep); }
