/* ============================================================
   CalorieLab for All — Site v2 Polish Layer
   ADDITIVE ONLY. Does not modify or override existing component
   styles from styles.css / supplements.css / food-styles.css.
   Adds: hamburger nav, mobile app feel, micro-interactions,
   glassmorphism accents, floating action button, premium cards.
   ============================================================ */

/* ── Hamburger menu (mobile nav) ─────────────────────────── */
.hamburger-btn {
  display: none;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.hamburger-btn:hover { border-color: var(--teal); background: var(--teal-glow); }
.hamburger-btn:active { transform: scale(0.94); }
.hamburger-btn svg { width: 20px; height: 20px; stroke: var(--text); }

.mobile-nav-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity var(--duration) var(--ease);
}
.mobile-nav-overlay.open { opacity: 1; pointer-events: auto; }

.mobile-nav-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(320px, 84vw);
  background: var(--bg-card); border-left: 1px solid var(--border);
  z-index: 201; transform: translateX(100%); transition: transform 280ms var(--ease);
  display: flex; flex-direction: column; padding: var(--sp-lg);
  box-shadow: -8px 0 32px rgba(0,0,0,0.25);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-nav-panel.open { transform: translateX(0); }
.mobile-nav-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-lg); }
.mobile-nav-close {
  background: var(--bg-card-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.mobile-nav-links { display: flex; flex-direction: column; gap: 2px; }
.mobile-nav-links a {
  display: flex; align-items: center; gap: 12px; padding: 14px var(--sp-md); border-radius: var(--radius-md);
  color: var(--text); font-weight: 600; font-size: 0.98rem; text-decoration: none;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
  min-height: 48px;
}
.mobile-nav-links a:hover, .mobile-nav-links a:active { background: var(--teal-glow); color: var(--teal); opacity: 1; }
.mobile-nav-links a .nav-icon { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }
.mobile-nav-divider { height: 1px; background: var(--border); margin: var(--sp-md) 0; }

@media (max-width: 640px) {
  .hamburger-btn { display: flex; }
}

/* ── Sticky bottom nav (mobile app feel) ─────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 150;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}
.bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; }
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none;
  color: var(--text-faint); font-size: 0.65rem; font-weight: 600; padding: 6px 10px; border-radius: var(--radius-md);
  min-width: 56px; min-height: 48px; justify-content: center;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.bottom-nav-item .bn-icon { font-size: 1.25rem; line-height: 1; }
.bottom-nav-item.active, .bottom-nav-item:hover { color: var(--teal); opacity: 1; }
.bottom-nav-item.active { background: var(--teal-glow); }

@media (max-width: 640px) {
  .bottom-nav { display: block; }
  body { padding-bottom: 64px; }
}

/* ── Floating Action Button ──────────────────────────────── */
.fab {
  position: fixed; z-index: 140; right: 20px; bottom: 84px;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-dim));
  color: var(--navy, #0A0F1E); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  box-shadow: 0 6px 20px rgba(0,196,154,0.4);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.fab:hover { transform: scale(1.08) translateY(-2px); box-shadow: 0 10px 28px rgba(0,196,154,0.5); }
.fab:active { transform: scale(0.94); }
@media (min-width: 641px) { .fab { bottom: 28px; } }

/* ── Glassmorphism accent (opt-in via class) ─────────────── */
.glass-card {
  background: color-mix(in srgb, var(--bg-card) 72%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

/* ── Card tilt + hover lift (opt-in via class, JS sets transform) ── */
.tilt-card { transition: transform 180ms var(--ease), box-shadow 180ms var(--ease); will-change: transform; }
.tilt-card:hover { box-shadow: var(--shadow-md); }

/* ── Floating idle animation (opt-in via class) ──────────── */
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.float-anim { animation: floatY 4.5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .float-anim { animation: none; } }

/* ── Ripple button effect ────────────────────────────────── */
.ripple-btn { position: relative; overflow: hidden; }
.ripple-effect {
  position: absolute; border-radius: 50%; background: rgba(255,255,255,0.5);
  transform: scale(0); animation: rippleAnim 550ms ease-out; pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(3); opacity: 0; } }

/* ── Gradient buttons (opt-in) ────────────────────────────── */
.btn-gradient {
  background: linear-gradient(135deg, var(--teal), #00A8E8);
  color: #05131f; border: none; font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,196,154,0.3);
}
.btn-gradient:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ── Animated counter (JS-driven, just base styling) ─────── */
.counter-num { font-variant-numeric: tabular-nums; }

/* ── Scroll-reveal (opt-in via class, JS toggles .revealed) ──
   Safety net: if JS never runs (blocked, errored, slow to attach),
   a pure-CSS fallback animation still reveals the content after a
   short delay so nothing stays permanently invisible. The JS-driven
   .revealed state fires first in normal conditions and this fallback
   simply won't have anything left to do by the time it would run. */
.v2-reveal { opacity: 0; transform: translateY(16px); transition: opacity 500ms var(--ease), transform 500ms var(--ease); animation: v2RevealFallback 0ms 1800ms forwards; }
.v2-reveal.revealed { opacity: 1; transform: translateY(0); }
@keyframes v2RevealFallback { to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .v2-reveal { opacity: 1; transform: none; transition: none; animation: none; } }

/* ── Premium Food Index homepage card ────────────────────── */
.food-index-promo {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(0,196,154,0.14), rgba(0,168,232,0.08));
  border: 1px solid var(--teal); padding: var(--sp-xl); margin: var(--sp-2xl) 0;
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-lg); align-items: center;
}
.food-index-promo::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 85% 20%, rgba(0,196,154,0.18), transparent 55%);
  pointer-events: none;
}
.food-index-promo-icon { font-size: 3rem; line-height: 1; flex-shrink: 0; }
.food-index-promo-body h3 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 6px; }
.food-index-promo-body p { color: var(--text-muted); font-size: 0.92rem; max-width: 46ch; }
.food-index-promo-cta { flex-shrink: 0; white-space: nowrap; }

@media (max-width: 640px) {
  .food-index-promo { grid-template-columns: 1fr; text-align: center; padding: var(--sp-lg); }
  .food-index-promo-icon { margin: 0 auto; }
  .food-index-promo-cta { width: 100%; }
}

/* ── Loading skeleton shimmer (opt-in) ───────────────────── */
@keyframes shimmerMove { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-card-2) 25%, var(--border) 50%, var(--bg-card-2) 75%);
  background-size: 800px 100%; animation: shimmerMove 1.4s linear infinite; border-radius: var(--radius-md);
}

/* ── Page transition fade (opt-in body class, JS toggles) ── */
.page-fade-in { animation: pageFadeIn 380ms var(--ease); }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .page-fade-in { animation: none; } }

/* ── Touch-friendly minimum tap targets (a11y + mobile app feel) ── */
@media (max-width: 640px) {
  .btn, button, .filter-chip, .category-pill, .page-btn { min-height: 44px; }
  input, select, textarea { min-height: 46px; font-size: 16px; } /* 16px prevents iOS auto-zoom */
}

/* ── Micro-interaction: subtle scale on active for any .btn ── */
.btn:active, button:active { transform: scale(0.97); }

/* ============================================================
   Visual polish additions (v2.1) — attractiveness pass
   All additive: scoped to new/opt-in classes or subtle, safe
   enhancements to existing selectors that don't change layout.
   ============================================================ */

/* Animated gradient underline accent beneath section h2 headings
   inside .content-primary / main content areas. Purely decorative,
   does not affect spacing since it sits in the ::after pseudo-element. */
.content-primary h2, .food-section-head h2 {
  position: relative;
  display: inline-block;
}
.content-primary h2::after, .food-section-head h2::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  width: 46px; height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--teal), #00A8E8);
}

/* Card depth on hover — subtle lift + glow, applied broadly to any
   .card without requiring markup changes. Respects reduced-motion. */
.card {
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), border-color 220ms var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: 0 8px 24px rgba(0,196,154,0.1), var(--shadow-md);
}
@media (prefers-reduced-motion: reduce) { .card:hover { transform: none; } }

/* Stat numbers get a subtle gradient text treatment for visual pop */
.stat-box b {
  background: linear-gradient(135deg, var(--teal), #00A8E8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Sidebar cards get a soft top accent bar to feel more premium */
.sidebar-card, .content-secondary .card {
  position: relative;
  overflow: hidden;
}
.sidebar-card::before, .content-secondary .card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--teal), #00A8E8, var(--teal));
  background-size: 200% 100%;
  animation: gradientSlide 6s linear infinite;
  opacity: 0.7;
}
@media (prefers-reduced-motion: reduce) { .sidebar-card::before, .content-secondary .card::before { animation: none; } }
@keyframes gradientSlide { 0% { background-position: 0% 0%; } 100% { background-position: 200% 0%; } }

/* Hero heading gets a soft text-shadow glow for extra polish on dark theme */
[data-theme="dark"] .hero h1 {
  text-shadow: 0 0 40px rgba(0,196,154,0.15);
}

/* Buttons: add a soft glow on primary buttons for a more premium feel */
.btn-primary {
  box-shadow: 0 4px 14px rgba(0,196,154,0.25);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(0,196,154,0.35);
}

/* Nav underline hover effect for header links */
.header-nav a {
  position: relative;
}
.header-nav a::after {
  content: "";
  position: absolute; left: 0; right: 100%; bottom: -4px; height: 2px;
  background: var(--teal);
  transition: right 200ms var(--ease);
}
.header-nav a:hover::after, .header-nav a.active-nav::after {
  right: 0;
}

/* Section badges (eyebrow text) get a small dot accent */
.section-eyebrow::before, .hero-eyebrow::before {
  content: "●";
  color: var(--teal);
  margin-right: 6px;
  font-size: 0.6em;
  vertical-align: middle;
}
