/* ══════════════════════════════════════════════════════════════
   Mobile App Layout — App-like mode (full-width, sticky tabBar)
   Active on ALL screen sizes — page width adapts to screen
   ══════════════════════════════════════════════════════════════ */

/* ── Hide desktop navbar/footer everywhere; show mobile header ── */
.hp-navbar,
.hp-navbar-desktop,
.hp-footer,
.hp-footer-desktop {
  display: none !important;
}

/* App frame: full-width on every screen, no hard max-width */
.app-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--hp-bg-1, #F7F6F1);
}

/* Reserve space at the bottom for the always-visible fixed tabBar */
.app-frame > .flex-1 {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

body {
  background: var(--hp-bg-1, #F7F6F1) !important;
  background-image: none !important;
}

/* ── Mobile Top Header (sticky, bright) ── */
.mobile-app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  padding-top: calc(0.625rem + env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(61, 155, 125, 0.08);
  box-shadow: 0 1px 3px rgba(42, 50, 46, 0.03);
}

.mobile-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--hp-font-heading, 'Poppins', sans-serif);
  font-size: 1.0625rem;
  font-weight: 700;
  color: #2A322E;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.mobile-header-brand .brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3D9B7D 0%, #2D8065 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 8px rgba(61, 155, 125, 0.30);
}

.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-points-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--hp-tint-amber, #FEF3C7);
  border: 1px solid rgba(224, 160, 48, 0.25);
  color: #B45309;
  text-decoration: none;
  transition: all 0.2s;
  min-height: 28px;
}
.mobile-points-pill:active { transform: scale(0.95); }

.mobile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D9B7D, #3D9B7D);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 2px 6px rgba(61, 155, 125, 0.25);
}

/* ── Bottom TabBar (fixed, always visible at the bottom) ── */
.mobile-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid rgba(61, 155, 125, 0.10);
  box-shadow: 0 -4px 20px rgba(42, 50, 46, 0.05);
}
.mobile-tabbar.show { display: flex; }

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #6E766F;
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding: 8px 0 6px;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tabbar-item svg {
  width: 22px;
  height: 22px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tabbar-item .tabbar-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

/* Active state — indigo */
.tabbar-item.active {
  color: var(--hp-neon-purple, #3D9B7D);
}
.tabbar-item.active svg {
  transform: translateY(-2px) scale(1.06);
}
.tabbar-item.active .tabbar-label {
  color: var(--hp-neon-purple, #3D9B7D);
  font-weight: 700;
}
/* Active indicator bar */
.tabbar-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, #3D9B7D, #3D9B7D);
}
/* Press feedback */
.tabbar-item:active { transform: scale(0.92); }

/* ══════════════════════════════════════════════════════════════
   Page content — full width, adapts to screen size
   ══════════════════════════════════════════════════════════════ */
.hp-page-wrap {
  width: 100%;
  max-width: 100% !important;
  padding: 0.75rem !important;
}
.home-container {
  width: 100%;
  max-width: 100% !important;
  padding: 1rem !important;
}

/* Mobile page header */
.hp-page-header {
  flex-direction: column !important;
  gap: 0.75rem !important;
  margin-bottom: 1rem !important;
  padding: 1rem 1.125rem !important;
}
.hp-page-actions {
  width: 100% !important;
  display: flex !important;
  gap: 0.5rem !important;
  flex-wrap: wrap !important;
}
.hp-page-actions .hp-btn {
  flex: 1;
  justify-content: center;
  font-size: 0.8125rem !important;
  padding: 0.5rem 0.75rem !important;
}
.hp-page-title { font-size: 1.25rem !important; }
.hp-page-sub { font-size: 0.8125rem !important; }

/* ── Home page ── */
.home-hero { padding: 1.25rem 0 !important; }
.home-hero-title { font-size: 1.75rem !important; line-height: 1.3 !important; }
.home-hero-sub { font-size: 0.8125rem !important; line-height: 1.6 !important; }
.home-hero-cta { flex-direction: column !important; gap: 0.5rem !important; }
.home-hero-cta .home-btn { width: 100% !important; justify-content: center !important; }

/* Stats — 2 columns on mobile, up to 4 on wider screens */
.home-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem !important;
}
.home-stat { padding: 0.75rem 0.625rem !important; border-radius: 0.75rem !important; }
.home-stat-value { font-size: 1.25rem !important; }
.home-stat-label { font-size: 0.6875rem !important; }
.home-stat-icon { font-size: 1.125rem !important; width: 32px !important; height: 32px !important; }

/* Section headers */
.home-section { margin-bottom: 1.25rem !important; }
.home-section-title { font-size: 1rem !important; }
.home-section-header { margin-bottom: 0.625rem !important; }

/* Card grid — 1 column on mobile, more on wider screens */
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem !important;
}

.home-card {
  padding: 0.875rem !important;
  border-radius: 0.875rem !important;
}
.home-card-icon {
  font-size: 1.5rem !important;
  width: 40px !important;
  height: 40px !important;
}
.home-card-icon svg { width: 20px !important; height: 20px !important; }
.home-card-title { font-size: 0.9375rem !important; }
.home-card-desc {
  font-size: 0.75rem !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}
.home-card-stat { font-size: 0.6875rem !important; }

/* HP feature card (articles) */
.home-card.hp-feature { grid-template-columns: auto 1fr !important; gap: 0.875rem !important; padding: 1rem !important; }

/* Pet strip */
.home-pet-strip {
  flex-direction: row !important;
  align-items: center !important;
  padding: 0.875rem !important;
  gap: 0.75rem !important;
}
.home-pet-emoji { font-size: 2rem !important; }
.home-pet-title { font-size: 0.875rem !important; }
.home-pet-desc {
  font-size: 0.6875rem !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 1 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

/* ── Vocabulary page ── */
.hp-table { font-size: 0.8125rem !important; }
.hp-table th { font-size: 0.6875rem !important; padding: 0.5rem 0.625rem !important; }
.hp-table td { padding: 0.625rem !important; }

.hp-pills {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap !important;
  gap: 0.375rem !important;
  padding-bottom: 0.25rem;
}
.hp-chip { white-space: nowrap; font-size: 0.75rem !important; padding: 0.375rem 0.75rem !important; }

/* ── Vocabulary cards mode ── */
.vocab-mobile-card { display: none !important; }
.vocab-mobile-item {
  background: #FFFFFF;
  border: 1px solid rgba(61, 155, 125, 0.10);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(42, 50, 46, 0.04);
}
.vocab-mobile-item:active {
  transform: scale(0.98);
  border-color: rgba(61, 155, 125, 0.30);
}
.vocab-mobile-word { font-size: 1rem; font-weight: 700; color: #2A322E; margin-bottom: 0.25rem; }
.vocab-mobile-phonetic { font-size: 0.75rem; color: #2D8065; margin-bottom: 0.375rem; }
.vocab-mobile-meaning { font-size: 0.8125rem; color: var(--hp-text-dim, #6E766F); }
.vocab-mobile-badge {
  display: inline-block;
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: var(--hp-tint-purple, #E8F4EE);
  color: var(--hp-neon-purple, #3D9B7D);
  margin-left: 0.375rem;
  font-weight: 600;
}

/* ── Wrong book ── */
.hp-grid { grid-template-columns: 1fr !important; gap: 0.75rem !important; }
.hp-wb-category-card { padding: 1rem !important; }

/* ── Pet page ── */
.hp-panel { padding: 1rem !important; border-radius: 0.875rem !important; }
#pet-emoji { width: 5.5rem !important; height: 5.5rem !important; font-size: 3rem !important; }

/* ── Me page ── */
.hp-me-row { grid-template-columns: 1fr !important; gap: 1rem !important; }
.home-card.theme-purple > div { grid-template-columns: 1fr !important; text-align: center !important; gap: 1rem !important; }
.hp-avatar { margin: 0 auto !important; }

/* Calendar */
.hp-cal-grid { grid-template-columns: repeat(7, 34px) !important; }
.hp-cal-cell { width: 34px !important; height: 30px !important; font-size: 0.6875rem !important; }
.hp-cal-weekdays-row { grid-template-columns: repeat(7, 34px) !important; }
.hp-cal-weekday { width: 34px !important; }

/* ── Buttons ── */
.hp-btn { font-size: 0.8125rem !important; padding: 0.5rem 0.875rem !important; }

/* ── Floating shapes hidden ── */
.home-floating-shape { display: none !important; }

/* ── Mobile FAB (Floating Action Button) ── */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: 1rem;
  z-index: 150;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D9B7D 0%, #2D8065 100%);
  border: none;
  color: white;
  box-shadow: 0 4px 16px rgba(61, 155, 125, 0.40);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}
.mobile-fab.show { display: flex; }
.mobile-fab:active { transform: scale(0.9); }
.mobile-fab svg { width: 22px; height: 22px; }

/* ── HP badge ── */
.hp-badge { font-size: 0.625rem !important; padding: 0.2rem 0.5rem !important; }

/* ── Table → card view (mobile only) ── */
@media (max-width: 640px) {
  .hp-table thead { display: none !important; }
  .hp-table,
  .hp-table tbody,
  .hp-table tr,
  .hp-table td {
    display: block !important;
    width: 100% !important;
  }
  .hp-table tr {
    margin-bottom: 0.5rem !important;
    border: 1px solid rgba(61, 155, 125, 0.10) !important;
    border-radius: 0.625rem !important;
    overflow: hidden !important;
    background: #FFFFFF !important;
  }
  .hp-table td {
    padding: 0.5rem 0.75rem !important;
    border: none !important;
    text-align: left !important;
  }
  .hp-table td::before {
    content: attr(data-label);
    font-size: 0.625rem !important;
    color: var(--hp-text-dim, #6E766F) !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.125rem;
    font-weight: 600;
  }
}

/* ── Login/Register auth buttons ── */
.mobile-auth-buttons {
  display: flex !important;
  gap: 0.5rem;
  margin-left: auto;
}
.mobile-auth-buttons a {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-weight: 600;
  text-decoration: none;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.mobile-auth-buttons .login-btn {
  color: var(--hp-neon-purple, #3D9B7D);
  border: 1px solid rgba(61, 155, 125, 0.25);
  background: #FFFFFF;
}
.mobile-auth-buttons .register-btn {
  background: linear-gradient(135deg, #3D9B7D, #3D9B7D);
  color: #fff;
  box-shadow: 0 2px 6px rgba(61, 155, 125, 0.25);
}

/* ══════════════════════════════════════════════════════════════
   Responsive — adapt to wider screens
   ══════════════════════════════════════════════════════════════ */

/* Tablet / small desktop ≥ 640px — more breathing room */
@media (min-width: 640px) {
  .home-hero { padding: 2rem 0 !important; }
  .home-hero-title { font-size: 2.25rem !important; }
  .home-hero-sub { font-size: 0.9375rem !important; max-width: 640px; margin: 1rem auto 0 !important; }
  .home-hero-cta { flex-direction: row !important; justify-content: center !important; }
  .home-hero-cta .home-btn { width: auto !important; }

  .hp-page-wrap { padding: 1.25rem 1.5rem !important; }
  .home-container { padding: 1.5rem 1.5rem !important; }

  .home-stats { grid-template-columns: repeat(4, 1fr) !important; gap: 0.75rem !important; }
  .home-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.875rem !important; }

  .home-card { padding: 1.125rem !important; }
  .home-card-icon { width: 44px !important; height: 44px !important; }
  .home-card-title { font-size: 1rem !important; }
  .home-card-desc { font-size: 0.8125rem !important; -webkit-line-clamp: 3 !important; }
  .home-card-stat { font-size: 0.75rem !important; }

  .hp-page-header { flex-direction: row !important; align-items: center !important; }
  .hp-page-actions { width: auto !important; flex-wrap: nowrap !important; }
  .hp-page-title { font-size: 1.5rem !important; }
}

/* Desktop ≥ 1024px — multi-column bento layout */
@media (min-width: 1024px) {
  .home-container { padding: 2rem 2rem !important; }

  .home-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 1rem !important; }
  .home-grid .home-card.hp-feature { grid-column: span 2 !important; }

  .home-stats { gap: 1rem !important; }
  .home-stat-value { font-size: 1.5rem !important; }

  .hp-page-wrap { padding: 1.5rem 2rem !important; }
  .hp-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 1rem !important; }
  .hp-me-row { grid-template-columns: 1fr 1fr !important; gap: 1.25rem !important; }
}

/* Wide desktop ≥ 1440px — 4-column grid */
@media (min-width: 1440px) {
  .home-grid { grid-template-columns: repeat(4, 1fr) !important; }
  .home-grid .home-card.hp-feature { grid-column: span 2 !important; }
  .home-container { padding: 2.5rem 2.5rem !important; }
}
