/* Nuvari Mobile-as-App — shared CSS foundation
   Load AFTER each page's inline styles. Vanilla, no framework.
   Contract: all class names are prefixed .nm- (nuvari-mobile) to avoid collisions. */

/* ─── CSS custom properties (global) ──────────────────────────────── */
:root {
  --nm-safe-top: env(safe-area-inset-top, 0px);
  --nm-safe-bottom: env(safe-area-inset-bottom, 0px);
  --nm-safe-left: env(safe-area-inset-left, 0px);
  --nm-safe-right: env(safe-area-inset-right, 0px);
  --nm-cta-height: 72px;
  --nm-tab-height: 64px;
  --nm-top-bar: 64px;
  --nm-top-bar-compact: 48px;
  /* reuse existing Nuvari palette */
  --nm-teal: var(--teal, #00B4C6);
  --nm-navy: var(--navy, #0A1628);
  --nm-cream: var(--warmCream, #FBF8F5);
  --nm-text: var(--text, #1A1A1A);
  --nm-sub: var(--sub, #6B6B6B);
  --nm-border: var(--border, #E8E8E4);
}

/* ─── Global mobile resets (375px–480px) ──────────────────────────── */
@media (max-width: 480px) {
  html, body { overflow-x: hidden; }
  body { padding-bottom: 0; } /* pages add their own bottom padding when sticky CTA exists */
  /* kill iOS zoom on form inputs — 16px minimum */
  input, select, textarea { font-size: 16px !important; }
  /* smooth-scroll for anchor jumps */
  html { scroll-behavior: smooth; }
  /* button press feel — applied globally */
  button, .btn, a.btn, [role="button"] {
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, background .2s ease, opacity .2s ease;
  }
  button:active, .btn:active, a.btn:active, [role="button"]:active {
    transform: scale(.97);
  }
}

/* ─── Sticky bottom CTA bar ───────────────────────────────────────── */
.nm-bottom-cta {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9990;
  padding: 12px 16px calc(12px + var(--nm-safe-bottom));
  padding-left: calc(16px + var(--nm-safe-left));
  padding-right: calc(16px + var(--nm-safe-right));
  background: rgba(251, 248, 245, 0.92);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border-top: 1px solid rgba(10, 22, 40, 0.06);
  transform: translateY(0);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
  display: none;
}
@media (max-width: 820px) {
  .nm-bottom-cta { display: block; }
  /* pages that opt in add padding-bottom matching the CTA height */
  body.nm-has-bottom-cta { padding-bottom: calc(var(--nm-cta-height) + var(--nm-safe-bottom)); }
}
.nm-bottom-cta.nm-hidden { transform: translateY(110%); }
.nm-bottom-cta__btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  background: var(--nm-teal);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 180, 198, 0.25);
  transition: transform .08s ease, box-shadow .2s ease;
}
.nm-bottom-cta__btn:active {
  transform: scale(.98);
  box-shadow: 0 4px 12px rgba(0, 180, 198, 0.2);
}

/* ─── Bottom tab bar (logged-in account pages) ────────────────────── */
.nm-tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9991;
  display: none;
  justify-content: space-around;
  align-items: stretch;
  padding: 6px 4px calc(6px + var(--nm-safe-bottom));
  padding-left: calc(4px + var(--nm-safe-left));
  padding-right: calc(4px + var(--nm-safe-right));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-top: 1px solid rgba(10, 22, 40, 0.08);
  box-shadow: 0 -4px 20px rgba(10, 22, 40, 0.04);
}
@media (max-width: 820px) {
  .nm-tab-bar.nm-active { display: flex; }
  body.nm-has-tab-bar { padding-bottom: calc(var(--nm-tab-height) + var(--nm-safe-bottom)); }
}
.nm-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 6px 2px;
  color: var(--nm-sub);
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  transition: color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.nm-tab-item:active { transform: scale(.92); }
.nm-tab-item svg { width: 22px; height: 22px; stroke-width: 2; display: block; }
.nm-tab-item.nm-current { color: var(--nm-teal); }
.nm-tab-item.nm-current svg { stroke: var(--nm-teal); }

/* ─── Bottom sheet modal ──────────────────────────────────────────── */
.nm-sheet {
  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
  visibility: hidden;
}
.nm-sheet[aria-hidden="false"] {
  pointer-events: auto;
  visibility: visible;
}
.nm-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 40, 0);
  transition: background .3s ease;
}
.nm-sheet[aria-hidden="false"] .nm-sheet__backdrop {
  background: rgba(10, 22, 40, 0.48);
}
.nm-sheet__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--nm-cream);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(24px + var(--nm-safe-bottom));
  padding-left: calc(20px + var(--nm-safe-left));
  padding-right: calc(20px + var(--nm-safe-right));
  transform: translateY(100%);
  transition: transform .36s cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
  box-shadow: 0 -16px 48px rgba(10, 22, 40, 0.18);
  font-family: 'DM Sans', sans-serif;
}
.nm-sheet[aria-hidden="false"] .nm-sheet__panel {
  transform: translateY(0);
}
.nm-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(10, 22, 40, 0.18);
  margin: 8px auto 16px;
}
.nm-sheet__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--nm-text);
  margin: 0 0 12px;
}
.nm-sheet__body { color: var(--nm-text); }
.nm-sheet__body p { font-size: 15px; line-height: 1.55; color: var(--nm-sub); margin: 0 0 12px; }

/* ─── Full-viewport step flow (quiz) ──────────────────────────────── */
.nm-flow {
  position: fixed;
  inset: 0;
  z-index: 10030;
  display: none;
  flex-direction: column;
  background: var(--nm-cream);
  padding-top: calc(56px + var(--nm-safe-top));
  padding-bottom: calc(88px + var(--nm-safe-bottom));
  font-family: 'DM Sans', sans-serif;
}
.nm-flow.nm-active { display: flex; }
.nm-flow__bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: calc(56px + var(--nm-safe-top));
  padding: var(--nm-safe-top) 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--nm-cream);
  z-index: 2;
}
.nm-flow__back {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 22px;
  color: var(--nm-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nm-flow__back:active { background: rgba(10, 22, 40, 0.06); }
.nm-flow__progress {
  flex: 1;
  height: 4px;
  background: rgba(10, 22, 40, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.nm-flow__fill {
  height: 100%;
  width: 0%;
  background: var(--nm-teal);
  border-radius: 2px;
  transition: width .4s cubic-bezier(.22, 1, .36, 1);
}
.nm-flow__close {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  font-size: 26px;
  color: var(--nm-sub);
  cursor: pointer;
}
.nm-flow__step {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 32px;
  animation: nm-step-in .32s cubic-bezier(.22, 1, .36, 1);
}
.nm-flow__step.nm-active { display: block; }
@keyframes nm-step-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.nm-flow__cta {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + var(--nm-safe-bottom));
  padding-left: calc(16px + var(--nm-safe-left));
  padding-right: calc(16px + var(--nm-safe-right));
  background: rgba(251, 248, 245, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(10, 22, 40, 0.06);
  z-index: 3;
}
.nm-flow__next {
  display: block;
  width: 100%;
  padding: 18px 24px;
  background: var(--nm-teal);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 180, 198, 0.25);
}
.nm-flow__next:disabled {
  background: rgba(10, 22, 40, 0.12);
  color: rgba(10, 22, 40, 0.35);
  box-shadow: none;
  cursor: not-allowed;
}

/* ─── Horizontal snap-scroll carousel ─────────────────────────────── */
.nm-snap-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-padding: 0 16px;
  padding: 4px 16px 20px;
  scrollbar-width: none;
  list-style: none;
  margin: 0;
}
.nm-snap-row::-webkit-scrollbar { display: none; }
.nm-snap-card {
  flex: 0 0 78%;
  scroll-snap-align: start;
  min-width: 260px;
}
@media (min-width: 640px) { .nm-snap-card { flex: 0 0 45%; } }

/* ─── Skeleton shimmer ────────────────────────────────────────────── */
.nm-skeleton {
  background: linear-gradient(90deg, #ece6d7 0%, #f5f0e6 50%, #ece6d7 100%);
  background-size: 200% 100%;
  animation: nm-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
.nm-skeleton--line { height: 14px; margin: 8px 0; }
.nm-skeleton--title { height: 22px; width: 60%; }
.nm-skeleton--card { aspect-ratio: 4 / 5; border-radius: 16px; }
@keyframes nm-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .nm-skeleton { animation: none; }
}

/* ─── IntersectionObserver reveal-on-scroll ───────────────────────── */
.nm-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.22, 1, .36, 1);
  will-change: opacity, transform;
}
.nm-reveal.nm-in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .nm-reveal { opacity: 1; transform: none; transition: none; }
}

/* ─── Shrinking top nav helper ────────────────────────────────────── */
.nm-shrink-on-scroll {
  transition: min-height .28s ease, padding .28s ease, background .28s ease, box-shadow .28s ease;
}
.nm-shrink-on-scroll.nm-compact {
  min-height: var(--nm-top-bar-compact);
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  background: rgba(251, 248, 245, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 2px 16px rgba(10, 22, 40, 0.06);
}

/* ─── Legacy sticky CTAs — suppress on mobile when nm-bottom-cta is active ─── */
/* Protocol pages had their own .nv-sticky-cta. We take over on mobile. */
@media (max-width: 820px) {
  body.nm-has-bottom-cta .nv-sticky-cta,
  body.nm-has-bottom-cta .sticky-quiz,
  body.nm-has-tab-bar .nv-sticky-cta {
    display: none !important;
  }
}

/* ─── Utility helpers ─────────────────────────────────────────────── */
.nm-hide-mobile { /* hide element only on mobile */ }
@media (max-width: 820px) {
  .nm-hide-mobile { display: none !important; }
}
.nm-only-mobile { display: none; }
@media (max-width: 820px) {
  .nm-only-mobile { display: block; }
}
.nm-safe-bottom-spacer {
  height: var(--nm-safe-bottom);
  flex-shrink: 0;
}
