/* app-shell.css - Main app container with Midnight Teal theme
 * 12 Oct 2026 v4
 *
 * v4 - A-4 SHARED-POLISH. The bottom bar's icons are inline line icons
 *   (index.html v12), sized by .nav-icon as before.
 *
 * 06 Oct 2026 v3
 *
 * v3 - D-12 PROGRESS-FIT. The bottom navigation's labels and icons grow
 *   with the text size up to about 1.45x (19px, 36px) and no further: at
 *   2x four labels cannot fit across a phone ("Wellbeing" alone is wider
 *   than a quarter of it) and ran into each other. Everything else keeps
 *   growing; the browser's own zoom still enlarges the bar.
 *
 * 03 Oct 2026 v2
 *
 * v2 - W5-17 A11Y-W5. The loading screen's floating logo and spinner stand
 *   still under Reduce motion (the phone's setting, or the app's).
 */

/* ============================================
   APP CONTAINER
   ============================================ */

.app-container {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-deep);
  position: relative;
}

/* Desktop: subtle containment */
@media (min-width: 481px) {
  .app-container {
    box-shadow: 
      0 0 60px rgba(45, 212, 191, 0.05),
      inset 0 0 0 1px var(--color-border-light);
  }
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-deep);
  z-index: 1000;
}

.loading-content {
  text-align: center;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Logo container */
.loading-logo {
  width: 100px;
  height: 100px;
  margin-bottom: var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

.loading-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fallback icon if image doesn't load */
.logo-icon {
  font-size: calc(3rem * var(--user-text-scale, 1));
  display: none;
}

.loading-logo img:not([src]), 
.loading-logo img[src=""] {
  display: none;
}

.loading-logo img:not([src]) + .logo-icon,
.loading-logo img[src=""] + .logo-icon {
  display: block;
}

/* Title */
.loading-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-tight);
}

/* Tagline */
.loading-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
  max-width: 280px;
  line-height: var(--leading-relaxed);
}

/* Spinner */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* W5-17: still under Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .loading-logo, .loading-spinner { animation: none; }
}
.reduce-motion .loading-logo, .reduce-motion .loading-spinner { animation: none; }

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(12px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
  flex: 1;
  padding: var(--content-padding);
  padding-bottom: calc(var(--nav-height) + var(--space-6));
  animation: fadeIn 0.4s ease-out;
  display: flex;
  flex-direction: column;
}

/* Centered content variant */
.main-content.centered {
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* ============================================
   VIEW CONTAINERS
   ============================================ */

.view {
  width: 100%;
  max-width: 100%;
  animation: fadeIn 0.3s ease-out;
}

.view-header {
  margin-bottom: var(--space-6);
}

.view-header.centered {
  text-align: center;
}

.view-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-tight);
}

.view-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--nav-height);
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: var(--z-nav);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  color: var(--color-text-muted);
  transition: all var(--transition-normal);
  border-radius: var(--radius-lg);
  min-width: 72px;
  min-height: 52px;
  position: relative;
}

.nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
  transition: width var(--transition-normal);
}

.nav-item:hover {
  color: var(--color-text-secondary);
}

.nav-item.active {
  color: var(--color-primary);
}

.nav-item.active::before {
  width: 32px;
}

.nav-item.active .nav-icon {
  transform: scale(1.1);
}

.nav-icon {
  font-size: min(calc(1.5rem * var(--user-text-scale, 1)), 2.25rem);
  margin-bottom: var(--space-1);
  transition: transform var(--transition-spring);
}

.nav-label {
  font-size: min(var(--text-xs), 1.1875rem);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wide);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-5) + env(safe-area-inset-bottom));
  left: var(--content-padding);
  right: var(--content-padding);
  max-width: calc(var(--max-width) - var(--space-10));
  margin: 0 auto;
  z-index: var(--z-toast);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  background: var(--color-bg-card);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}

.toast-success {
  border-color: var(--color-success);
  background: var(--color-success-light);
}

.toast-warning {
  border-color: var(--color-warning);
  background: var(--color-warning-light);
}

.toast-error {
  border-color: var(--color-danger);
  background: var(--color-danger-light);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================
   FEEDBACK FLOATING BUTTON
   ============================================ */

.feedback-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-4) + env(safe-area-inset-bottom));
  right: var(--content-padding);
  width: 48px;
  height: 48px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: calc(1.25rem * var(--user-text-scale, 1));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: var(--z-fab);
  transition: all var(--transition-normal);
}

.feedback-fab:hover {
  transform: scale(1.05);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}

.feedback-fab:active {
  transform: scale(0.95);
}

/* ============================================
   MODAL CONTAINER
   ============================================ */

.modal-container {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--content-padding);
  z-index: var(--z-modal);
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  animation: slideUp 0.3s ease-out;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Small phones */
@media (max-width: 380px) {
  :root {
    --content-padding: var(--space-4);
  }
  
  .loading-logo {
    width: 80px;
    height: 80px;
  }
  
  .loading-title {
    font-size: var(--text-2xl);
  }
  
  .nav-item {
    min-width: 60px;
    padding: var(--space-2) var(--space-2);
  }
}

/* Large phones / small tablets */
@media (min-width: 400px) {
  .loading-logo {
    width: 120px;
    height: 120px;
  }
}

/* A-4 SHARED-POLISH, 12 Oct 2026. The bar's icons are line icons sized by
   .nav-icon's font-size (1em), coloured by the item (currentColor). */
.nav-icon { display: inline-flex; line-height: 1; }
.nav-svg { display: block; }
