/* Mobile-First CSS Enhancements for Telve.ai */

/* Ensure proper viewport behavior and prevent zoom on iOS */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-size: 16px !important; /* Prevent zoom on iOS form focus */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: pan-y; /* Allow vertical scrolling but enable swipe gestures */
}

/* Touch-friendly tap targets - minimum 48x48px */
button,
a,
input,
select,
textarea,
.btn,
.tab-btn,
.cta-btn,
.lang-switcher a,
nav a {
  min-height: 48px !important;
  min-width: 48px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Improve link padding for better touch targets */
a:not(.logo) {
  padding: 12px 16px;
}

/* Button enhancements */
button,
.btn,
.cta-btn {
  padding: 12px 24px !important;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(212, 175, 55, 0.3);
  user-select: none;
}

/* Touch feedback */
.touch-active {
  transform: scale(0.95);
  opacity: 0.8;
  transition: all 0.1s ease;
}

/* Mobile Navigation Enhancements */
.mobile-menu-toggle {
  display: none;
  position: relative;
  background: transparent;
  border: none;
  padding: 12px;
  cursor: pointer;
  z-index: 1001;
  flex-direction: column;
  gap: 5px;
}

.mobile-menu-toggle .hamburger {
  display: block;
  width: 25px;
  height: 3px;
  background: var(--gold, #D4AF37);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex !important;
  }

  nav,
  .mobile-nav {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: var(--background, #0a2922);
    padding: 80px 20px 20px;
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  nav.mobile-nav-open,
  .mobile-nav-open {
    left: 0;
  }

  nav ul,
  .mobile-nav ul {
    flex-direction: column !important;
    gap: 0 !important;
    width: 100%;
  }

  nav ul li,
  .mobile-nav ul li {
    width: 100%;
    border-bottom: 1px solid rgba(173, 229, 219, 0.1);
  }

  nav ul li a,
  .mobile-nav ul li a {
    display: flex !important;
    width: 100%;
    padding: 16px !important;
    min-height: 56px !important;
  }

  /* Overlay when menu is open */
  body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    animation: fadeIn 0.3s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Make header content work with mobile menu */
  .header-content,
  header .container {
    position: relative;
  }

  /* Language switcher mobile adjustments */
  .lang-switcher {
    flex-wrap: wrap;
    gap: 8px !important;
  }

  .lang-switcher a {
    padding: 8px 12px !important;
    min-width: 44px !important;
  }
}

/* Dark Mode Styles */
.dark-mode-toggle {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold, #D4AF37);
  color: var(--background, #0a2922);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 999;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dark-mode-toggle:hover,
.dark-mode-toggle:active {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Dark mode color overrides */
.dark-mode {
  --background: #1a1a1a;
  --primary: #2dd4bf;
  --text-light: #ffffff;
  --text-muted: #b0b0b0;
}

.dark-mode body {
  background: var(--background);
}

.dark-mode .horoscope-card,
.dark-mode .aspect-card,
.dark-mode .sidebar-card,
.dark-mode .article-content,
.dark-mode .sidebar-section {
  background: rgba(45, 212, 191, 0.05);
  border-color: rgba(45, 212, 191, 0.2);
}

/* PWA Install Button */
.pwa-install-btn {
  animation: slideUp 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
}

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

/* Optimize spacing for thumb reach */
.content,
.container,
main {
  padding: 16px !important;
}

@media (min-width: 769px) {
  .content,
  .container,
  main {
    padding: 20px !important;
  }
}

/* Form input optimizations for mobile */
input,
textarea,
select {
  font-size: 16px !important; /* Prevent zoom on iOS */
  padding: 12px 16px !important;
  min-height: 48px !important;
  border-radius: 8px;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--gold, #D4AF37);
  outline-offset: 2px;
}

/* Better touch scrolling */
.main-content,
.article-content,
.sidebar {
  -webkit-overflow-scrolling: touch;
}

/* Swipe indicator for zodiac navigation */
.swipe-indicator {
  display: none;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  padding: 12px;
  background: rgba(212, 175, 55, 0.8);
  color: #0a2922;
  border-radius: 50%;
  font-size: 24px;
  z-index: 998;
  pointer-events: none;
  animation: swipePulse 1s ease infinite;
}

@keyframes swipePulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.swipe-indicator.left {
  left: 20px;
}

.swipe-indicator.right {
  right: 20px;
}

@media (max-width: 768px) {
  /* Show swipe indicator on horoscope pages */
  body[data-page="horoscope"] .swipe-indicator {
    display: flex;
  }
}

/* Improve card layouts on mobile */
@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .aspects-grid,
  .variations {
    grid-template-columns: 1fr !important;
  }

  .hero h1 {
    font-size: 2rem !important;
  }

  .hero-subtitle,
  .hero p {
    font-size: 1rem !important;
  }

  .zodiac-symbol,
  .hero-icon,
  .symbol-icon {
    font-size: 3.5rem !important;
  }

  /* Optimize footer for mobile */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .footer-links {
    flex-direction: column !important;
    align-items: center;
    gap: 12px !important;
  }

  /* CTA buttons full width on mobile */
  .cta-buttons {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .cta-btn {
    width: 100% !important;
    max-width: 300px;
    text-align: center;
    justify-content: center;
  }
}

/* Landscape phone optimizations */
@media (max-width: 896px) and (orientation: landscape) {
  .hero {
    padding: 40px 20px 20px !important;
  }

  .hero h1 {
    font-size: 1.8rem !important;
  }

  .zodiac-symbol,
  .hero-icon {
    font-size: 3rem !important;
  }

  .dark-mode-toggle {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr 250px !important;
    gap: 24px !important;
  }

  .aspects-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    font-weight: 400;
  }

  .logo,
  h1, h2, h3 {
    font-weight: 600;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .header {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }

  .dark-mode-toggle,
  .pwa-install-btn {
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
  }
}

/* Loading state for better perceived performance */
[data-loading="true"] {
  opacity: 0.6;
  pointer-events: none;
  cursor: wait;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--gold, #D4AF37);
  outline-offset: 2px;
}

/* Skip to content link for accessibility */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--gold, #D4AF37);
  color: var(--background, #0a2922);
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  z-index: 1002;
  font-weight: 600;
}

.skip-to-content:focus {
  top: 0;
}

/* Print styles */
@media print {
  .mobile-menu-toggle,
  .dark-mode-toggle,
  .pwa-install-btn,
  nav,
  .lang-switcher,
  .cta-section,
  footer {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}
