/* ═══════════════════════════════════════════════════════════════════════════
   MP.CSS — Master Stylesheet for Metabolic Protocol
   Single source of truth for colors. Landing.css handles layout only.
   Palette: Soft Gray bg (#f8fafc), Dark Charcoal text (#1e293b),
            Emerald accent (#059669), Dark Navy footer (#0f172a).
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --mp-bg: #ffffff;
  --mp-bg-soft: #f8fafc;
  --mp-bg-alt: #f1f5f9;
  --mp-text: #1e293b;
  --mp-text-body: #334155;
  --mp-text-muted: #475569;
  --mp-accent: #059669;
  --mp-accent-hover: #047857;
  --mp-border: #e2e8f0;
  --mp-footer-bg: #0f172a;
  --mp-footer-text: #cbd5e1;
  --mp-transition: 0.2s ease;
}

/* Alpine x-cloak — hide until Alpine hydrates */
[x-cloak] { display: none !important; }

/* ─── Base ─── */
html {
  overflow-x: clip;
}
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  background: var(--mp-bg-soft);
  color: var(--mp-text);
}

/* ─── Skip link ─── */
.skip-link {
  position: absolute;
  top: -4rem;
  left: 0.75rem;
  z-index: 9999;
  padding: 0.65rem 1rem;
  background: var(--mp-accent);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border: none;
  transition: top var(--mp-transition);
}
.skip-link:focus {
  top: 0.75rem;
  outline: 2px solid var(--mp-text);
  outline-offset: 2px;
}

/* ─── Nav ─── */
.mp-nav {
  background: var(--mp-bg);
  border-bottom: 1px solid var(--mp-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.mp-nav .navbar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--mp-text);
}
.mp-nav .nav-link {
  color: var(--mp-text-muted);
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  transition: color var(--mp-transition);
}
.mp-nav .nav-link:hover {
  color: var(--mp-accent);
}
.mp-nav .nav-link:focus-visible {
  outline: 2px solid var(--mp-accent);
  outline-offset: 2px;
}

/* Primary CTA button */
.mp-btn-primary {
  background: var(--mp-accent);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  padding: 0.75rem 1.5rem;
  min-height: 2.75rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--mp-transition), transform var(--mp-transition);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}
.mp-btn-primary:hover {
  background: var(--mp-accent-hover);
  color: #fff;
  transform: translateY(-1px);
}
.mp-btn-primary:focus-visible {
  outline: 2px solid var(--mp-text);
  outline-offset: 2px;
}

/* Mobile menu — top dropdown, allows page scroll behind */
@media (max-width: 991.98px) {
  .mp-mobile-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1040;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                padding 0.3s ease;
    padding: 0 1.5rem;
  }
  .mp-mobile-nav.mp-mobile-nav-open {
    max-height: 28rem;
    opacity: 1;
    padding: 1.25rem 1.5rem 1.5rem;
  }
  .mp-mobile-nav .navbar-nav {
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
  }
  .mp-mobile-nav .nav-link {
    color: #e2e8f0 !important;
    font-size: 1rem;
    padding: 0.65rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
  }
  .mp-mobile-nav .nav-link:hover {
    color: #34d399 !important;
    background: rgba(255, 255, 255, 0.05);
  }
  .mp-mobile-nav .mp-btn-primary {
    margin-top: 0.5rem;
  }
  .mp-nav .navbar {
    position: relative;
  }
}
@media (min-width: 992px) {
  .mp-mobile-nav {
    position: static;
    background: transparent;
    backdrop-filter: none;
    display: flex !important;
    padding: 0;
    max-height: none;
    opacity: 1;
    overflow: visible;
    border-bottom: none;
    box-shadow: none;
    transition: none;
  }
}

/* Hamburger button — 3-bar animated */
.mp-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
@media (max-width: 991.98px) {
  .mp-hamburger {
    display: flex;
  }
}
.mp-hamburger:hover {
  background: var(--mp-bg-soft);
}
.mp-hamburger:focus-visible {
  outline: 2px solid var(--mp-accent);
  outline-offset: 2px;
}
.mp-hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  transform-origin: center;
}
.mp-hamburger-open:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mp-hamburger-open:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mp-hamburger-open:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Close button inside mobile overlay */
.mp-menu-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1100;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}
.mp-menu-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Dark nav: hamburger visible on form/dashboard */
body.form-view .mp-hamburger,
body.dashboard-view .mp-hamburger {
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
body.form-view .mp-hamburger:hover,
body.dashboard-view .mp-hamburger:hover {
  background: rgba(255, 255, 255, 0.08);
}
body.plan-view .mp-hamburger {
  border-color: #cbd5e1;
  color: #64748b;
}
body.plan-view .mp-hamburger:hover {
  background: #f1f5f9;
  color: #059669;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER — Dark with teal accent line
   ═══════════════════════════════════════════════════════════════════════════ */
.mp-footer {
  background: #0c1222 !important;
  color: var(--mp-footer-text) !important;
  border-top: 2px solid rgba(16, 185, 129, 0.35);
}
.mp-footer-main {
  padding-top: 2.5rem;
  padding-bottom: 2rem;
}
.mp-footer-bottom {
  padding: 1rem 0;
  min-height: auto;
}
.mp-footer .mp-footer-brand,
.mp-footer .footer-heading {
  color: #ffffff !important;
}
.mp-footer .mp-footer-desc,
.mp-footer p.small,
.mp-footer .footer-legal,
.mp-footer .footer-legal a,
.mp-footer p,
.mp-footer a,
.mp-footer li {
  color: #94a3b8 !important;
  transition: color 0.2s ease;
}
.mp-footer a:hover,
.mp-footer a:focus-visible {
  color: #34d399 !important;
}
.mp-footer .footer-border {
  border-color: rgba(255, 255, 255, 0.08) !important;
}
.mp-footer .mp-footer-desc {
  max-width: 320px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK-THEME PAGES: Form, Plan (NOT landing, NOT dashboard)
   ═══════════════════════════════════════════════════════════════════════════ */
body.form-view {
  background: #0f172a !important;
  background-image: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%) !important;
  color: #f1f5f9 !important;
  min-height: 100vh;
}

body.plan-view {
  background: #f1f5f9 !important;
  background-image: none !important;
  color: #1e293b !important;
  min-height: 100vh;
}

/* Auth (login / register): light, readable, matches landing brand */
body.auth-view {
  background: #f8fafc !important;
  background-image: none !important;
  color: #1e293b !important;
  min-height: 100vh;
}
body.auth-view .mp-alert {
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  font-size: 0.9rem;
}
body.auth-view .mp-nav {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}
body.auth-view .mp-nav .navbar-brand {
  color: #1e293b !important;
}
body.auth-view .mp-nav .nav-link {
  color: #64748b !important;
}
body.auth-view .mp-nav .nav-link:hover {
  color: #059669 !important;
}

/* Dashboard: lighter, high-visibility, professional */
body.dashboard-view {
  background: #f1f5f9 !important;
  background-image: none !important;
  color: #1e293b !important;
  min-height: 100vh;
}
body.dashboard-view .mp-nav {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}
body.dashboard-view .mp-nav .navbar-brand {
  color: #1e293b !important;
}
body.dashboard-view .mp-nav .nav-link {
  color: #64748b !important;
}
body.dashboard-view .mp-nav .nav-link:hover {
  color: #059669 !important;
}

/* Plan view: light nav matching dashboard */
body.plan-view .mp-nav {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}
body.plan-view .mp-nav .navbar-brand {
  color: #1e293b !important;
}
body.plan-view .mp-nav .nav-link {
  color: #64748b !important;
}
body.plan-view .mp-nav .nav-link:hover {
  color: #059669 !important;
}

/* Nav on dark-theme pages */
body.form-view .mp-nav {
  background: rgba(15, 23, 42, 0.92) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: none;
}
body.form-view .mp-nav .navbar-brand {
  color: #ffffff !important;
}
body.form-view .mp-nav .nav-link {
  color: #cbd5e1 !important;
}
body.form-view .mp-nav .nav-link:hover {
  color: #ffffff !important;
}
body.form-view .mp-nav .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.25) !important;
}
body.form-view .mp-nav .navbar-toggler-icon {
  filter: invert(1) !important;
}

/* CTA on dark pages */
body.form-view .mp-btn-primary {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%) !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4), 0 1px 0 rgba(255,255,255,0.2) inset;
  border-radius: 12px;
  color: #fff !important;
}
body.form-view .mp-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.5), 0 1px 0 rgba(255,255,255,0.25) inset;
  color: #fff !important;
}

/* ═══ Form page specifics ═══ */
body.form-view main,
body.form-view .nf-container {
  background: transparent !important;
  color: #e2e8f0 !important;
}
body.form-view .nf-header .display-4,
body.form-view .nf-header h1,
body.form-view .phase-card h2,
body.form-view .phase-card h3,
body.form-view .phase-card .text-white {
  color: #ffffff !important;
}
body.form-view .phase-card,
body.form-view .glass-panel {
  background: rgba(30, 41, 59, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}
body.form-view .form-dark-label,
body.form-view .form-theme-label {
  color: #94a3b8 !important;
}
body.form-view .form-dark-input,
body.form-view .form-control {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #f1f5f9 !important;
}
body.form-view .form-dark-input::placeholder {
  color: #64748b !important;
}
body.form-view .text-muted,
body.form-view .text-muted-light,
body.form-view .hint-clinical,
body.form-view .phase-card p.small {
  color: #94a3b8 !important;
}
body.form-view .goal-option-content .text-white,
body.form-view .goal-option-content .fw-bold {
  color: #ffffff !important;
}
body.form-view .goal-option-content .text-muted {
  color: #94a3b8 !important;
}
body.form-view .allergy-pill {
  color: #e2e8f0 !important;
  border-color: rgba(255, 255, 255, 0.15);
}
body.form-view .allergy-option-chip input:checked + .allergy-pill {
  color: #fff !important;
}
body.form-view .btn-primary-glow {
  color: #fff !important;
}

/* ═══ Alerts ═══ */
.alert.mp-alert {
  background: var(--mp-bg);
  color: var(--mp-text);
  border: 1px solid var(--mp-accent);
}
body.form-view .alert.mp-alert,
body.dashboard-view .alert.mp-alert {
  background: rgba(30, 41, 59, 0.95) !important;
  color: #f1f5f9 !important;
  border-color: #10b981 !important;
}

/* ═══ 320px safe ═══ */
@media (max-width: 374px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SCROLL-REVEAL ANIMATION SYSTEM
   Uses CSS transitions. Alpine x-intersect adds .revealed class.
   If Alpine fails to load, .no-alpine fallback makes everything visible.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Fade + slide up */
.reveal-up {
  opacity: 0;
  transform: translateY(2rem);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-up.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Fade only */
.reveal-fade {
  opacity: 0;
  transition: opacity 0.9s ease;
}
.reveal-fade.revealed {
  opacity: 1;
}

/* Scale up */
.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* Stagger delays for sequential card reveals */
.stagger-1 { transition-delay: 0.08s; }
.stagger-2 { transition-delay: 0.16s; }
.stagger-3 { transition-delay: 0.24s; }
.stagger-4 { transition-delay: 0.32s; }

/* FALLBACK: if Alpine never loads, show everything immediately */
.no-alpine .reveal-up,
.no-alpine .reveal-fade,
.no-alpine .reveal-scale {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HERO ENTRANCE — pure CSS keyframes, plays on page load, no JS needed
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(1.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes heroScaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
.hero-enter {
  opacity: 0;
  animation: heroFadeUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero-enter-1 { animation-delay: 0.05s; }
.hero-enter-2 { animation-delay: 0.15s; }
.hero-enter-3 { animation-delay: 0.3s; }
.hero-enter-4 { animation-delay: 0.45s; }
.hero-enter-scale {
  opacity: 0;
  animation: heroScaleIn 1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BACK TO TOP — Alpine.js on body, window scroll, ~300px threshold
   Round, emerald, fixed bottom-right, does not block footer
   ═══════════════════════════════════════════════════════════════════════════ */
.back-to-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1050;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border: none;
  background: #059669;
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.5);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.back-to-top-btn:hover {
  background: #047857;
  color: #fff;
  box-shadow: 0 6px 28px rgba(5, 150, 105, 0.6);
}
.back-to-top-btn:focus-visible {
  outline: 2px solid var(--mp-text);
  outline-offset: 2px;
}

/* Marketing-pixel consent prompt (shown only when META_PIXEL_ID is configured) */
.mp-cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 2050;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  box-shadow: 0 10px 32px rgba(2, 6, 23, 0.55);
  font-size: 0.9rem;
}
.mp-cookie-banner a {
  color: #34d399;
  text-decoration: underline;
}
.mp-cookie-banner-text {
  flex: 1 1 260px;
}
.mp-cookie-banner-actions {
  display: inline-flex;
  gap: 0.5rem;
}
@media (min-width: 768px) {
  .mp-cookie-banner {
    left: auto;
    max-width: 480px;
  }
}

/* Mobile polish: safe padding, touch-friendly alerts, no horizontal scroll */
@media (max-width: 767px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .mp-alert {
    font-size: 0.9rem;
    padding: 0.85rem 2.5rem 0.85rem 1rem;
  }
  .mp-alert .btn-close {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
  }
  .back-to-top-btn {
    bottom: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
  }
}
