/* ============================================================
   咕噜噜 GULULU 设计系统 — TRAE AI 大赛演示版
   主题：日光开吃 Daylight
   ============================================================ */

/* ===== CSS Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Font */
  --font-zh: 'PingFang SC', 'HarmonyOS Sans SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  --font-en: 'Inter', 'SF Pro Display', 'Nunito', 'Helvetica Neue', Arial, sans-serif;
  --font-num: 'SF Pro Display', 'DIN Alternate', 'Nunito', Arial, sans-serif;

  /* Font Size */
  --fs-display-xl: 32px; --lh-display-xl: 40px; --fw-display-xl: 700;
  --fs-display-lg: 28px; --lh-display-lg: 36px; --fw-display-lg: 700;
  --fs-h1: 24px; --lh-h1: 32px; --fw-h1: 700;
  --fs-h2: 20px; --lh-h2: 28px; --fw-h2: 700;
  --fs-h3: 18px; --lh-h3: 26px; --fw-h3: 600;
  --fs-body-lg: 16px; --lh-body-lg: 24px; --fw-body-lg: 400;
  --fs-body-md: 14px; --lh-body-md: 22px; --fw-body-md: 400;
  --fs-body-sm: 13px; --lh-body-sm: 20px; --fw-body-sm: 400;
  --fs-label-lg: 15px; --lh-label-lg: 20px; --fw-label-lg: 600;
  --fs-label-md: 14px; --lh-label-md: 20px; --fw-label-md: 600;
  --fs-label-sm: 12px; --lh-label-sm: 16px; --fw-label-sm: 600;
  --fs-caption: 11px; --lh-caption: 16px; --fw-caption: 400;

  /* Canvas */
  --bg-canvas: #FBFAF8;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F6F3EF;
  --bg-brandSoft: #FFF4EC;
  --bg-goldSoft: #FFF9E8;

  /* Text */
  --text-primary: #211F1D;
  --text-secondary: #6F6761;
  --text-tertiary: #91877F;
  --text-brand: #E95416;
  --text-success: #28835A;
  --text-warning: #B86717;
  --text-danger: #C73E35;
  --text-inverse: #FFFFFF;

  /* Action - Primary Gold */
  --action-primary: #FFC94D;
  --action-primary-hover: #F5BC3A;
  --action-primary-pressed: #D9A52E;
  --action-primary-text: #4D2C16;

  /* Action - Accent Orange */
  --action-accent: #FF6A2A;
  --action-accent-hover: #E95416;
  --action-accent-pressed: #BF3F0F;
  --action-accent-text: #FFFFFF;

  /* Secondary */
  --action-secondary-bg: #FFF9E8;
  --action-secondary-text: #8B6914;
  --action-secondary-border: #F0DFB8;

  /* Danger */
  --action-danger: #E55248;
  --action-danger-text: #FFFFFF;

  /* AI */
  --action-ai-bg: #F3F1FF;
  --action-ai-text: #574DCA;

  /* Glass */
  --glass-bg: rgba(255,255,255,0.72);
  --glass-blur: 16px;
  --glass-border: rgba(255,255,255,0.55);

  /* Spacing (4px grid) */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px;

  /* Radius */
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;
  --radius-xl: 20px; --radius-2xl: 24px; --radius-full: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-xl: 0 16px 40px rgba(0,0,0,0.10);
  --shadow-glow: 0 0 24px rgba(255,201,77,0.3);

  /* Motion */
  --motion-fast: 120ms; --motion-normal: 180ms;
  --motion-medium: 240ms; --motion-slow: 320ms;
  --motion-enter: 360ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-enter: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring-soft: cubic-bezier(0.22, 1.18, 0.36, 1);
  --ease-spring-strong: cubic-bezier(0.18, 1.35, 0.32, 1);

  /* Z-index */
  --z-tabbar: 100; --z-navbar: 90; --z-modal: 200; --z-toast: 300;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-zh);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
  color: var(--text-primary);
  background: var(--bg-canvas);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 0; }

/* ===== Common Components ===== */

/* Glass Card */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Button Base */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border: none; cursor: pointer; font-family: var(--font-zh);
  font-weight: 600; border-radius: var(--radius-full);
  user-select: none; white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.96); }

.btn--primary {
  background: var(--action-primary); color: var(--action-primary-text);
  box-shadow: 0 2px 8px rgba(255,201,77,0.3);
}
.btn--primary:hover { background: var(--action-primary-hover); }

.btn--accent {
  background: var(--action-accent); color: var(--action-accent-text);
  box-shadow: 0 2px 8px rgba(255,106,42,0.25);
}

.btn--secondary {
  background: var(--action-secondary-bg); color: var(--action-secondary-text);
  border: 1px solid var(--action-secondary-border);
}

.btn--ai {
  background: var(--action-ai-bg); color: var(--action-ai-text);
}

.btn--ghost {
  background: transparent; color: var(--text-secondary);
}

.btn--lg { padding: 14px 28px; font-size: var(--fs-body-lg); }
.btn--md { padding: 10px 20px; font-size: var(--fs-body-md); }
.btn--sm { padding: 6px 14px; font-size: var(--fs-body-sm); }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: var(--radius-full);
  font-size: var(--fs-body-sm); font-weight: 500;
  border: 1px solid var(--action-secondary-border);
  background: var(--bg-surface); color: var(--text-secondary);
  cursor: pointer; user-select: none;
}
.chip.active {
  background: var(--action-primary); color: var(--action-primary-text);
  border-color: var(--action-primary);
}
.chip--sm { padding: 4px 10px; font-size: var(--fs-caption); }

/* Hero Section */
.hero-section {
  position: relative; overflow: hidden;
  padding: var(--space-10) var(--space-5) var(--space-8);
  background: linear-gradient(135deg, #FFF4EC 0%, #FFF9E8 50%, #FFF4EC 100%);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
  margin: 0 var(--space-3);
}

/* Page Title */
.page-title {
  font-size: var(--fs-h1); font-weight: var(--fw-h1);
  line-height: var(--lh-h1); color: var(--text-primary);
}

.page-subtitle {
  font-size: var(--fs-body-md); color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Section Header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-3);
}
.section-title {
  font-size: var(--fs-h3); font-weight: var(--fw-h3);
  color: var(--text-primary);
}

/* Grid layouts */
.chip-grid {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
}
.chip-row {
  display: flex; gap: var(--space-2); overflow-x: auto;
  padding: 0 var(--space-5); scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.card-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3); padding: 0 var(--space-5);
}

.card-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* Card */
.card {
  background: var(--bg-surface); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.card:hover { box-shadow: var(--shadow-md); }
.card:active { transform: scale(0.98); }

.card__image {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: var(--bg-subtle);
}
.card__body { padding: var(--space-3); }
.card__title {
  font-size: var(--fs-label-md); font-weight: var(--fw-label-md);
  color: var(--text-primary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__subtitle {
  font-size: var(--fs-caption); color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Section content wrapper */
.section-content {
  padding: 0 var(--space-5);
}

/* Badge / Tag */
.tag {
  display: inline-flex; padding: 2px 10px; border-radius: var(--radius-full);
  font-size: var(--fs-caption); font-weight: 500;
}
.tag--gold { background: #FFF9E8; color: #8B6914; }
.tag--red { background: #FFF0EE; color: #C73E35; }
.tag--green { background: #E8F5EE; color: #28835A; }
.tag--purple { background: #F3F1FF; color: #574DCA; }
.tag--orange { background: #FFF4EC; color: #E95416; }

/* NavBar */
.navbar {
  position: sticky; top: 0; z-index: var(--z-navbar);
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
}
.navbar__title {
  font-size: var(--fs-label-lg); font-weight: var(--fw-label-lg);
  color: var(--text-primary);
}
.navbar__back, .navbar__action {
  width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; border-radius: var(--radius-full);
  background: var(--bg-subtle); cursor: pointer; border: none;
  font-size: 18px; color: var(--text-primary);
}

/* TabBar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-tabbar);
  display: flex; justify-content: space-around; align-items: center;
  padding: var(--space-2) var(--space-4) calc(var(--space-2) + env(safe-area-inset-bottom, 0));
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0,0,0,0.06);
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md); transition: all var(--motion-fast);
  border: none; background: none; font-family: var(--font-zh);
}
.tabbar__icon { font-size: 22px; line-height: 1; }
.tabbar__label { font-size: 10px; font-weight: 500; }
.tabbar__item.active .tabbar__icon { color: var(--action-primary); }
.tabbar__item.active .tabbar__label { color: var(--action-primary-text); font-weight: 700; }
.tabbar__item:not(.active) .tabbar__icon { color: var(--text-tertiary); }
.tabbar__item:not(.active) .tabbar__label { color: var(--text-tertiary); }

/* Page Container */
.page-container {
  min-height: 100vh; padding-bottom: 80px;
}

/* Modal */
.modal-mask {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  width: 100%; max-height: 85vh; background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden; display: flex; flex-direction: column;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-sheet__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5); border-bottom: 1px solid var(--bg-subtle);
}
.modal-sheet__title { font-size: var(--fs-label-lg); font-weight: 700; }
.modal-sheet__close {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--bg-subtle); border: none; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
}
.modal-sheet__body {
  flex: 1; overflow-y: auto; padding: var(--space-5);
}

/* Toast */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast); padding: 10px 24px; border-radius: var(--radius-full);
  background: var(--glass-bg); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg); font-size: var(--fs-body-sm);
  font-weight: 500; color: var(--text-primary);
  pointer-events: none;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Skeleton */
.skeleton {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Empty State */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-12) var(--space-5); gap: var(--space-3);
}
.empty-state__icon { font-size: 48px; opacity: 0.5; }
.empty-state__text {
  font-size: var(--fs-body-md); color: var(--text-tertiary);
  text-align: center;
}

/* Divider */
.divider {
  height: 1px; background: var(--bg-subtle);
  margin: var(--space-4) var(--space-5);
}

/* FAB */
.fab {
  position: fixed; bottom: 100px; right: var(--space-5); z-index: 80;
  width: 52px; height: 52px; border-radius: var(--radius-full);
  background: var(--action-primary); border: none; cursor: pointer;
  box-shadow: var(--shadow-glow); font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--motion-fast);
}
.fab:active { transform: scale(0.9); }

/* Utility */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }

/* ===== Decision Wheel ===== */
.wheel-container {
  position: relative; width: 260px; height: 260px; margin: 0 auto;
}
.wheel-canvas { width: 100%; height: 100%; }
.wheel-pointer {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 48px; border-radius: 50%; background: var(--action-accent);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 2px 12px rgba(255,106,42,0.4);
  z-index: 2; cursor: pointer; border: 3px solid white;
}

/* ===== Blind Box ===== */
.blind-box {
  position: relative; width: 160px; height: 160px; margin: 0 auto;
  perspective: 600px; cursor: pointer;
}
.blind-box__inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d; transition: transform 0.8s var(--ease-spring-soft);
}
.blind-box__inner.open { transform: rotateY(180deg); }
.blind-box__face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--radius-xl); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--space-2);
}
.blind-box__front {
  background: linear-gradient(135deg, #FFC94D, #FF6A2A);
  box-shadow: 0 8px 32px rgba(255,106,42,0.3);
  font-size: 48px; color: white;
}
.blind-box__back {
  background: var(--bg-surface); transform: rotateY(180deg);
  box-shadow: var(--shadow-lg); padding: var(--space-4);
  text-align: center;
}
.blind-box__label { font-size: var(--fs-label-sm); color: white; font-weight: 700; }
.blind-box__result { font-size: var(--fs-h3); font-weight: 700; color: var(--text-primary); }
/* ============================================================
   手机壳框架 - 模拟真机效果
   ============================================================ */

html {
  height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
  padding: 20px;
}

.phone-frame {
  position: relative;
  width: 390px;
  height: 694px;
  background: #1a1a1a;
  border-radius: 44px;
  box-shadow:
    0 0 0 3px #2a2a2a,
    0 0 0 6px #1a1a1a,
    0 0 0 8px #333,
    0 20px 60px rgba(0,0,0,0.5),
    inset 0 0 4px rgba(255,255,255,0.05);
  overflow: hidden;
  flex-shrink: 0;
}

.phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 30px;
  background: #1a1a1a;
  border-radius: 0 0 20px 20px;
  z-index: 10;
}

.phone-screen {
  position: absolute;
  inset: 8px;
  border-radius: 36px;
  overflow: hidden;
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
}

/* 主内容区可滚动 */
.phone-screen main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.phone-screen main::-webkit-scrollbar { display: none; }

/* 页面切换：默认隐藏，active 显示 */
.phone-screen .page {
  display: none;
}
.phone-screen .page.active {
  display: block;
}

/* 在手机壳内，所有 fixed/absolute 定位元素相对于 phone-screen */
.phone-screen .tabbar {
  position: relative;
  flex-shrink: 0;
}

.phone-screen .gheader {
  position: relative;
  flex-shrink: 0;
}

.phone-screen .toast {
  position: absolute;
  top: 50px;
}

.phone-screen .cooking-overlay,
.phone-screen .recipe-modal {
  position: absolute;
}

/* 响应式：小屏幕缩放 */
@media (max-width: 430px) {
  body { padding: 0; }
  .phone-frame {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .phone-screen { border-radius: 0; inset: 0; }
  .phone-notch { display: none; }
}

@media (min-width: 431px) and (max-height: 900px) {
  .phone-frame {
    width: 360px;
    height: 630px;
    border-radius: 36px;
  }
  .phone-screen { border-radius: 28px; }
}

/* 手机壳内 fixed → absolute 修复 */
.phone-screen .cooking-overlay {
  position: absolute;
}

.phone-screen .recipe-modal {
  position: absolute;
}

.phone-screen .toast {
  position: absolute;
  top: 50px;
  z-index: 999;
}

.phone-screen .page-container {
  padding-top: var(--space-3);
  padding-bottom: var(--space-4);
}

.phone-screen .navbar {
  position: sticky;
  top: 0;
  z-index: 89;
}

/* 二级子页面：有 navbar，少量顶部间距（通过 id 匹配） */
.phone-screen #cookPage .page-container,
.phone-screen #fridgePage .page-container,
.phone-screen #tablePage .page-container,
.phone-screen #fortunePage .page-container,
.phone-screen #saucePage .page-container,
.phone-screen #rankPage .page-container,
.phone-screen #knowledgePage .page-container,
.phone-screen #classroomPage .page-container,
.phone-screen #communityPage .page-container,
.phone-screen #dietPage .page-container,
.phone-screen #achievementPage .page-container,
.phone-screen #favoritesPage .page-container,
.phone-screen #menusPage .page-container,
.phone-screen #planPage .page-container,
.phone-screen #settingsPage .page-container {
  padding-top: var(--space-2);
}
