/* Gamify V2 — Apple bubble aesthetic + Planet Fitness minimal palette */

:root {
  --pf-purple: #7B2D8E;
  --pf-purple-light: #9B4DB0;
  --pf-yellow: #F5D000;
  --pf-black: #231F20;
  --pf-gray: #58595B;
  --pf-white: #FFFFFF;
  --bubble-bg: linear-gradient(145deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.04) 45%, rgba(0,0,0,0.08) 100%);
  --bubble-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.18);
  --bubble-press: 0 2px 12px rgba(0,0,0,0.3), inset 0 2px 6px rgba(0,0,0,0.15);
  --ring-track: rgba(255,255,255,0.08);
  --ring-fill: var(--green);
  --v2-radius: 28px;
  --v2-radius-sm: 20px;
}

/* ── V2 Home Shell ─────────────────────────────────────────── */
.v2-home {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(123,45,142,0.12) 0%, transparent 55%),
              radial-gradient(ellipse 80% 50% at 80% 100%, rgba(29,184,122,0.06) 0%, transparent 50%),
              var(--bg);
  overflow: hidden;
}

.v2-home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  flex-shrink: 0;
}

.v2-settings-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}
.v2-settings-btn:active { transform: scale(0.94); box-shadow: var(--bubble-press); }

.v2-home-greeting {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
  text-align: right;
}
.v2-home-greeting strong { color: var(--text); font-weight: 700; }

/* Resources bar */
.v2-resources-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 16px 12px;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.v2-resources-bar::-webkit-scrollbar { display: none; }

.v2-resource-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.v2-resource-chip:active { transform: scale(0.96); background: var(--surface2); }

/* Bubble tile grid */
.v2-tile-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 16px 24px 32px;
  align-content: center;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.v2-bubble-tile {
  aspect-ratio: 1;
  border-radius: var(--v2-radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bubble-bg);
  box-shadow: var(--bubble-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.v2-bubble-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}
.v2-bubble-tile:active {
  transform: scale(0.94);
  box-shadow: var(--bubble-press);
}
.v2-bubble-tile.workout { --tile-accent: var(--green); }
.v2-bubble-tile.budget  { --tile-accent: var(--pf-yellow); }
.v2-bubble-tile.goals   { --tile-accent: var(--purple); }
.v2-bubble-tile.nutrition { --tile-accent: var(--orange); }

.v2-bubble-icon {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 4px 12px rgba(0,0,0,0.2);
}
.v2-bubble-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

/* ── Section Full-Screen Experience ────────────────────────── */
.v2-section {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--bg);
  display: none;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.v2-section.open {
  display: flex;
  transform: translateX(0);
}

.v2-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  flex-shrink: 0;
}
.v2-back-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.v2-section-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

/* TikTok-style vertical card stack */
.v2-card-stack {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.v2-card {
  position: absolute;
  inset: 0;
  padding: 16px 56px 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(40px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.v2-card.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.v2-card-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--v2-radius);
  padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
  max-height: 85%;
  overflow-y: auto;
}

/* Right rail navigation */
.v2-rail {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
  padding: 8px 4px;
}

.v2-rail-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.2s, height 0.2s, box-shadow 0.2s;
  opacity: 0.6;
}
.v2-rail-icon.active {
  width: 48px;
  height: 48px;
  font-size: 20px;
  opacity: 1;
  border-color: var(--purple);
  background: var(--purple-dim);
  box-shadow: 0 4px 16px rgba(139,131,232,0.3);
}
.v2-rail-icon.hover-preview {
  width: 44px;
  height: 44px;
  font-size: 18px;
  opacity: 0.85;
}

/* Apple Health-style progress rings */
.v2-ring-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
}
.v2-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.v2-ring-track { fill: none; stroke: var(--ring-track); stroke-width: 10; }
.v2-ring-fill {
  fill: none;
  stroke: var(--ring-fill, var(--green));
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.v2-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.v2-ring-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.v2-ring-label { font-size: 10px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; }

/* Workout-specific cards */
.wk-exercise-name { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
.wk-set-meta { font-size: 14px; color: var(--muted); font-family: var(--mono); margin-bottom: 24px; }
.wk-weight-display { font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.wk-rep-target { font-size: 18px; color: var(--green); font-weight: 700; margin-top: 8px; }
.wk-log-btn {
  width: 100%;
  margin-top: 24px;
  padding: 18px;
  border-radius: var(--v2-radius-sm);
  border: none;
  background: var(--green);
  color: #fff;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(29,184,122,0.35);
  transition: transform 0.12s;
}
.wk-log-btn:active { transform: scale(0.97); }

.wk-timer-display {
  font-size: 72px;
  font-weight: 800;
  font-family: var(--mono);
  text-align: center;
  letter-spacing: -2px;
  color: var(--purple);
}
.wk-timer-label { text-align: center; font-size: 14px; color: var(--muted); margin-top: 8px; }

.wk-alert-card { border-color: var(--amber) !important; }
.wk-alert-title { font-size: 20px; font-weight: 800; color: var(--amber); margin-bottom: 8px; }
.wk-science-toggle {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border2);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.wk-science-detail { display: none; margin-top: 12px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.wk-science-detail.open { display: block; }

/* Milestone celebration */
.v2-celebrate {
  text-align: center;
  padding: 32px 16px;
}
.v2-celebrate-emoji { font-size: 64px; animation: celebrate-bounce 0.6s ease infinite alternate; }
@keyframes celebrate-bounce { from { transform: scale(1); } to { transform: scale(1.08); } }

/* Settings drawer overlay */
.v2-settings-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: flex-end;
}
.v2-settings-panel.open { display: flex; }
.v2-settings-sheet {
  width: 100%;
  max-height: 85vh;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 24px 16px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.v2-settings-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.v2-settings-item:active { background: var(--surface2); }

/* Coach onboarding overlay */
.v2-coach-onboard {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: var(--bg);
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 20px 40px;
  display: none;
}
.v2-coach-onboard.open { display: block; }

/* Hide legacy nav when V2 active */
body.v2-mode .nav { display: none !important; }
body.v2-mode #page-home { display: none !important; }
body.v2-mode .pages { overflow: hidden; min-height: 0; }

/* Keep v2 home visible when re-activated after tab navigation */
body.v2-mode #page-v2-home.page.active {
  display: flex !important;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

body.v2-mode #page-v2-home .v2-home {
  position: relative;
  inset: auto;
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* Pressable tactile buttons */
.v2-pressable {
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.v2-pressable:active {
  transform: scale(0.97);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.15);
}
