/*
 * macOS Compatibility Layer
 * Ensures consistent rendering across macOS devices while preserving
 * the Hunter Green (#355E3B) glassmorphism design system
 * Version: 1.0.0
 */

/* ==========================================================================
   macOS Detection and Base Styles
   ========================================================================== */

/* Apply macOS-specific styles only when detected */
.macos-detected {
  /* Base macOS optimizations */
}

/* ==========================================================================
   Typography Fixes for macOS
   ========================================================================== */

/* Font weight normalization for macOS */
.macos-detected h1,
.macos-detected h2,
.macos-detected h3,
.macos-detected h4,
.macos-detected h5,
.macos-detected h6 {
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* Body text optimization for Retina displays */
.macos-detected body,
.macos-detected p,
.macos-detected span,
.macos-detected div {
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Bold text adjustment for macOS */
.macos-detected strong,
.macos-detected b,
.macos-detected .font-bold {
  font-weight: 600;
}

/* Medium weight text adjustment */
.macos-detected .font-medium {
  font-weight: 500;
}

/* Semibold text adjustment */
.macos-detected .font-semibold {
  font-weight: 600;
}

/* Code and monospace font optimization */
.macos-detected code,
.macos-detected pre,
.macos-detected .font-mono {
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  letter-spacing: 0;
}

/* ==========================================================================
   Glassmorphism Enhancements for macOS
   ========================================================================== */

/* Enhanced backdrop-filter support for macOS Chrome */
.macos-detected .glass,
.macos-detected [class*="backdrop-blur"],
.macos-detected .glassmorphism {
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  background-color: rgba(53, 94, 59, 0.1); /* Hunter Green with transparency */
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Navigation glass effects optimization */
.macos-detected nav.glass,
.macos-detected .nav-glass {
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  backdrop-filter: blur(20px) saturate(200%);
  background-color: rgba(53, 94, 59, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Card glass effects with Hunter Green theme */
.macos-detected .card-glass,
.macos-detected .glass-card {
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  background: linear-gradient(
    135deg,
    rgba(53, 94, 59, 0.1) 0%,
    rgba(53, 94, 59, 0.05) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Button glass effects */
.macos-detected .btn-glass,
.macos-detected .glass-button {
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  backdrop-filter: blur(10px) saturate(150%);
  background-color: rgba(53, 94, 59, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.macos-detected .btn-glass:hover,
.macos-detected .glass-button:hover {
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  background-color: rgba(53, 94, 59, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Color Profile Adjustments for P3 Displays
   ========================================================================== */

/* P3 wide color gamut normalization */
@media (color-gamut: p3) {
  .macos-detected {
    /* Hunter Green color adjustments for P3 displays */
    --hunter-green-p3: color(display-p3 0.208 0.369 0.231);
    --hunter-green-light-p3: color(display-p3 0.259 0.420 0.282);
    --hunter-green-dark-p3: color(display-p3 0.157 0.318 0.180);
  }
  
  .macos-detected .bg-hunter-green,
  .macos-detected [style*="#355E3B"] {
    background-color: var(--hunter-green-p3, #355E3B);
  }
  
  .macos-detected .text-hunter-green {
    color: var(--hunter-green-p3, #355E3B);
  }
  
  .macos-detected .border-hunter-green {
    border-color: var(--hunter-green-p3, #355E3B);
  }
}

/* ==========================================================================
   Retina Display Optimizations
   ========================================================================== */

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .macos-detected {
    /* Sharper borders and shadows for Retina */
  }
  
  .macos-detected .glass,
  .macos-detected .glassmorphism {
    border-width: 0.5px;
    box-shadow: 
      0 4px 16px rgba(0, 0, 0, 0.1),
      0 1px 4px rgba(0, 0, 0, 0.05);
  }
  
  .macos-detected img,
  .macos-detected svg {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ==========================================================================
   Performance Optimizations for macOS
   ========================================================================== */

/* GPU acceleration for smooth animations */
.macos-detected .glass,
.macos-detected .glassmorphism,
.macos-detected [class*="backdrop-blur"] {
  transform: translateZ(0);
  will-change: backdrop-filter, transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .macos-detected * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .macos-detected .glass,
  .macos-detected .glassmorphism {
    will-change: auto;
  }
}

/* ==========================================================================
   Safari-Specific Optimizations
   ========================================================================== */

/* Safari on macOS specific fixes */
.macos-safari {
  /* Safari-specific glassmorphism fallbacks */
}

.macos-safari .glass,
.macos-safari .glassmorphism {
  /* Enhanced Safari support */
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* ==========================================================================
   Fallbacks for Older macOS Versions
   ========================================================================== */

/* Fallback styles when backdrop-filter is not supported */
.macos-detected.no-backdrop-filter .glass,
.macos-detected.no-backdrop-filter .glassmorphism {
  background-color: rgba(53, 94, 59, 0.8);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.macos-detected.no-backdrop-filter .nav-glass {
  background-color: rgba(53, 94, 59, 0.9);
}

.macos-detected.no-backdrop-filter .card-glass {
  background: linear-gradient(
    135deg,
    rgba(53, 94, 59, 0.8) 0%,
    rgba(53, 94, 59, 0.7) 100%
  );
}

/* ==========================================================================
   Utility Classes for macOS-Specific Adjustments
   ========================================================================== */

/* Hide elements on macOS */
.macos-detected .hide-on-macos {
  display: none !important;
}

/* Show elements only on macOS */
.show-on-macos {
  display: none;
}

.macos-detected .show-on-macos {
  display: block;
}

.macos-detected .show-on-macos.inline {
  display: inline;
}

.macos-detected .show-on-macos.inline-block {
  display: inline-block;
}

.macos-detected .show-on-macos.flex {
  display: flex;
}

.macos-detected .show-on-macos.grid {
  display: grid;
}

/* macOS-specific spacing adjustments */
.macos-detected .macos-spacing {
  letter-spacing: -0.01em;
}

.macos-detected .macos-line-height {
  line-height: 1.5;
}

/* ==========================================================================
   Debug Utilities (Remove in Production)
   ========================================================================== */

/* Debug indicator for development */
.macos-compatibility-debug::before {
  content: "macOS Compatibility Active";
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(53, 94, 59, 0.9);
  color: white;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  z-index: 9999;
  font-family: monospace;
}

/* End of macOS Compatibility Layer */