/* platform-native.css — CSS gates for native iOS/Android (Capacitor) vs web.
 *
 * All rules gated by .platform-native on <html> (set by platform-theme.js).
 * Dark mode: rules compose with existing .dark class on <html>.
 *
 * WHAT: styles that should only apply inside the native app shell.
 * WHAT NOT: PWA-specific styles (those live in standalone CSS files).
 */

/* ── Hide marketing / web-only elements ──────────────────────────────── */
.platform-native .hero,
.platform-native .web-only,
.platform-native [data-pwa-guide],
.platform-native .pwa-install-banner,
.platform-native .cookie-banner,
.platform-native .cookie-banner-overlay {
  display: none !important;
}

/* ── Safe area insets ────────────────────────────────────────────────────
 * Topbar gets inset-top. Body/main do NOT — avoids double-padding on
 * devices that already push content via the status bar. */
.platform-native .mobile-topbar {
  padding-top: env(safe-area-inset-top);
}

/* Bottom safe-area on main content only (no double-padding with tab bar) */
.platform-native main,
.platform-native .app-content {
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Child pages — no native tab bar, no shell UI ───────────────────────── */
.platform-native.platform-child-page .native-tab-bar,
.platform-native.platform-child-page .tab-bar {
  display: none !important;
}

/* ── Hide hamburger / mobile nav (native has its own shell UI) ─────────── */
.platform-native body.has-native-tab-bar .mobile-hamburger,
.platform-native body.has-native-tab-bar .mobile-dropdown,
.platform-native body.has-native-tab-bar .mobile-topbar,
html.is-native body.has-native-tab-bar .mobile-hamburger,
html.is-native body.has-native-tab-bar .mobile-dropdown,
html.is-native body.has-native-tab-bar .mobile-topbar {
  display: none !important;
}

/* ── Hide web payment elements (not used in native apps) ───────── */
.platform-native .web-payment-only {
  display: none !important;
}

/* ── Tap highlight — native apps feel snappy, no blue flash ──────────── */
.platform-native * {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent accidental double-tap zoom on tappable controls */
.platform-native button,
.platform-native a.tab-item,
.platform-native .cl-key {
  touch-action: manipulation;
}

/* ── User-select: allow text selection in inputs / textareas ─────────── */
.platform-native input,
.platform-native textarea {
  user-select: text;
  -webkit-user-select: text;
}

/* ── Scroll momentum (iOS native feel) ─────────────────────────────────── */
.platform-native main,
.platform-native .app-content {
  -webkit-overflow-scrolling: touch;
}

/* ── Status bar styling hint (iOS) ────────────────────────────────────── */
.platform-native.platform-ios {
  /* Safe area + notch: let content flow naturally under the status bar */
}

/* ── Native Tab Bar ──────────────────────────────────────────────────────
 * Only shown on parent-shell pages (not child-dashboard / child-login).
 * Dark mode: dark background with light active color (#0A84FF = iOS blue). */
.platform-native .native-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.12);
  z-index: var(--layer-bottom-nav, 400);
}
.platform-native .tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: #8E8E93;
  font-size: 10px;
  padding: 6px 12px;
  transition: color 0.15s;
}
.platform-native .tab-icon { font-size: 24px; }
.platform-native .tab-item.active { color: #007AFF; }

/* Dark mode — works with .dark class OR html.dark on <html> */
.platform-native.dark .native-tab-bar,
.platform-native.html.dark .native-tab-bar {
  background: rgba(28, 28, 30, 0.92);
  border-top-color: rgba(255, 255, 255, 0.1);
}
.platform-native.dark .tab-item,
.platform-native.html.dark .tab-item { color: #8E8E93; }
.platform-native.dark .tab-item.active,
.platform-native.html.dark .tab-item.active { color: #0A84FF; }

/* Push main content above tab bar */
.platform-native main,
.platform-native .app-content {
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

/* Floating help + feedback sit on the FAB layer, under modals. */
html.platform-native #helpBtn,
html.platform-native #hbBtn,
html.is-native #helpBtn,
html.is-native #hbBtn {
  bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 64px) !important;
  z-index: var(--layer-fab, 300) !important;
}

html.platform-native #globalFeedbackBtn,
html.is-native #globalFeedbackBtn {
  bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px) !important;
  z-index: var(--layer-fab, 300) !important;
}

/* ── Android WebView GPU stability ───────────────────────────────────────
 * backdrop-filter and filter:blur crash the renderer on many mid/low-end
 * Android WebViews (Play pre-launch / Family Policy stability).
 * is-native-android is set synchronously in <head> before these rules apply. */
html.is-native-android,
html.is-native-android *,
html.is-native-android *::before,
html.is-native-android *::after {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  filter: none !important;
}

html.is-native-android .native-tab-bar {
  background: #ffffff !important;
}

html.is-native-android.dark .native-tab-bar,
html.is-native-android.parent-theme-dark .native-tab-bar {
  background: #1c1c1e !important;
}

html.is-native-android .cloud {
  background: rgba(255, 255, 255, 0.05) !important;
}

html.is-native-android .role-card,
html.is-native-android .entry-choice-btn,
html.is-native-android .entry-highlight-chip {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
}

/* Login form — keep dark-theme glass (white bg + white text was unreadable) */
html.is-native-android .login-magic-bg .magic-form-fields label {
  color: rgba(255, 255, 255, 0.75) !important;
}

html.is-native-android .login-magic-bg .magic-form-fields .magic-input {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  color: #fff !important;
}

html.is-native-android .login-magic-bg .magic-form-fields .magic-input::placeholder {
  color: rgba(255, 255, 255, 0.45) !important;
}

/* Google OAuth — crisp branded button on flat Android WebView (no glass bleed) */
html.is-native-android .google-btn-magic {
  background: #ffffff !important;
  color: #1f1f1f !important;
  border-color: #dadce0 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08) !important;
}

/* Parent magic 3D orbs — filter:blur + perspective crash post-login on mid Android */
html.is-native-android .magic-3d-orbs {
  display: none !important;
}

/* Parent magic flat mode — perspective/translateZ/preserve-3d crash dashboard on Android */
html.is-native-android body.parent-magic-view .magic-3d-scene,
html.is-native-android body.parent-magic-view .magic-3d-orbs {
  perspective: none !important;
  transform-style: flat !important;
}

html.is-native-android body.parent-magic-view .magic-3d-card,
html.is-native-android body.parent-magic-view .parent-glass-card,
html.is-native-android body.parent-magic-view .library-magic-menu-card,
html.is-native-android body.parent-magic-view .library-magic-schedule-card,
html.is-native-android body.parent-magic-view .parent-action-tile,
html.is-native-android body.parent-magic-view .parent-ready-child,
html.is-native-android body.parent-magic-view .magic-settings-group-card,
html.is-native-android body.parent-magic-view .magic-page-stat-card,
html.is-native-android body.parent-magic-view .parent-hub-mascot,
html.is-native-android body.parent-magic-view .library-magic-mascot,
html.is-native-android body.parent-magic-view .magic-page-hero-icon,
html.is-native-android body.parent-magic-view .parent-hub-family-avatar,
html.is-native-android body.parent-magic-view .parent-hub-icon-btn,
html.is-native-android body.parent-magic-view .parent-bottom-nav,
html.is-native-android body.parent-magic-view .parent-handoff-primary,
html.is-native-android body.parent-magic-view .library-magic-btn-primary,
html.is-native-android body.parent-magic-view .magic-3d-btn-primary,
html.is-native-android body.parent-magic-view .schedule-mode-btn.active,
html.is-native-android body.parent-magic-view .library-magic-hub .library-magic-menu-card {
  transform: none !important;
  transform-style: flat !important;
  animation: none !important;
}

html.is-native-android body.parent-magic-view .parent-ready-child:hover,
html.is-native-android body.parent-magic-view .parent-ready-child.is-active,
html.is-native-android body.parent-magic-view .library-magic-menu-card:hover,
html.is-native-android body.parent-magic-view .magic-settings-group-card:hover,
html.is-native-android body.parent-magic-view .parent-action-tile:active,
html.is-native-android body.parent-magic-view .library-magic-menu-card:active,
html.is-native-android body.parent-magic-view .parent-ready-child:active,
html.is-native-android body.parent-magic-view .magic-settings-group-card:active,
html.is-native-android body.parent-magic-view .parent-handoff-primary:active,
html.is-native-android body.parent-magic-view .library-magic-btn-primary:active,
html.is-native-android body.parent-magic-view .parent-bottom-nav-btn.is-active {
  transform: none !important;
}

html.is-native-android .app-entry-screen .entry-choice-card,
html.is-native-android #ppin-overlay > div {
  background: rgba(255, 255, 255, 0.98) !important;
}

/* Dashboard uses parent-magic-dashboard (not only parent-magic-view) — flat 3D globally */
html.is-native-android body.parent-magic-view,
html.is-native-android body.parent-magic-dashboard {
  perspective: none !important;
  transform-style: flat !important;
}

html.is-native-android .magic-3d-scene,
html.is-native-android body.parent-magic-dashboard .parent-home-hub {
  perspective: none !important;
  transform-style: flat !important;
}

html.is-native-android body.parent-magic-dashboard .parent-action-tile,
html.is-native-android body.parent-magic-dashboard .parent-quick-tile,
html.is-native-android body.parent-magic-dashboard .parent-handoff-primary,
html.is-native-android body.parent-magic-dashboard .parent-handoff-secondary,
html.is-native-android body.parent-magic-dashboard .parent-coparent-cta-btn,
html.is-native-android body.parent-magic-dashboard .parent-ready-child,
html.is-native-android body.parent-magic-dashboard .parent-glass-card,
html.is-native-android body.parent-magic-dashboard .parent-hub-mascot {
  transform: none !important;
  transform-style: flat !important;
  animation: none !important;
}

/* Classic parent shell — top chrome layout when magic bootstrap is skipped (Play safe mode) */
html.is-native-android .parent-top-chrome {
  background: rgba(255, 255, 255, 0.98) !important;
}

html.is-native-android main > .parent-nav-header-actions:not(.parent-top-chrome .parent-nav-header-actions) {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid rgba(27, 35, 64, 0.08);
}

/* Classic dashboard only — when magic Hem hub is active, legacy cards stay hidden */
html.is-native-android body:not(.parent-magic-dashboard) #childCardsGrid {
  display: flex !important;
}

/* Hide Swedish data-i18n placeholders until apply() for non-Swedish locales. */
html[data-i18n-pending] [data-i18n],
html[data-i18n-pending] [data-i18n-html],
html[data-i18n-pending] [data-i18n-placeholder],
html[data-i18n-pending] [data-i18n-title],
html[data-i18n-pending] [data-i18n-aria-label] {
  visibility: hidden !important;
}