/* ============================================
   RESPONSIVE UTILITIES FOR ALL PAGES
   ============================================ */

/* Ensure all HTML files include this viewport meta tag:
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
*/

/* Base responsive setup */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

/* Responsive images and media */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Responsive containers */
.responsive-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Flexible grid system */
.responsive-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Responsive text sizing using clamp() */
.responsive-title-large {
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.3;
}

.responsive-title-medium {
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    line-height: 1.4;
}

.responsive-title-small {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    line-height: 1.4;
}

.responsive-text {
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    line-height: 1.6;
}

/* Responsive spacing */
.responsive-padding {
    padding: clamp(10px, 3vw, 30px);
}

.responsive-margin {
    margin: clamp(10px, 3vw, 30px) 0;
}

/* ============================================
   MOBILE FIRST MEDIA QUERIES
   ============================================ */

/* Extra Small devices (phones, up to 576px) */
@media (max-width: 575.98px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .container, .gita-container {
        margin: 5px;
        padding: 10px;
        border-radius: 10px;
    }
    
    .chapter-header, .header {
        padding: 15px 10px;
        margin-bottom: 15px;
    }
    
    .nav-grid, .chapter-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .nav-card, .theme-section, .benefit {
        padding: 12px;
        margin: 10px 0;
    }
    
    /* Button responsiveness */
    .nav-button, .chapter-link {
        display: block;
        width: 100%;
        margin: 5px 0;
        padding: 10px;
        font-size: 14px;
        text-align: center;
    }
    
    /* Text sizing for mobile */
    h1 { font-size: 1.4em; }
    h2 { font-size: 1.2em; }
    h3 { font-size: 1.1em; }
    
    /* Input responsiveness */
    input, textarea, select {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    /* Hide decorative elements on very small screens */
    .om-decoration, .sacred-symbol {
        display: none;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .nav-grid {
        grid-template-columns: 1fr;
    }
    
    .chapter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .container, .gita-container {
        margin: 10px;
        padding: 15px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .nav-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chapter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .container, .gita-container {
        max-width: 750px;
        padding: 20px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .nav-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .chapter-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .container, .gita-container {
        max-width: 970px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .nav-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .chapter-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .container, .gita-container {
        max-width: 1140px;
    }
}

/* ============================================
   ACCESSIBILITY AND USER PREFERENCES
   ============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .nav-card, .theme-section, .benefit {
        border: 2px solid;
    }
    
    .mantra-text {
        text-shadow: none;
        font-weight: bold;
    }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
    /* Enhance contrast for dark mode if needed */
    .nav-card, .theme-section {
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
    }
    
    .nav-card, .theme-section, .benefit {
        break-inside: avoid;
        border: 1px solid #ccc;
        margin-bottom: 10pt;
    }
    
    .saint-figure, .om-decoration {
        font-size: 14pt;
    }
    
    /* Hide navigation elements */
    .nav-button, .back-to-top {
        display: none;
    }
    
    /* Ensure readability */
    .mantra-text {
        color: black !important;
        text-shadow: none !important;
    }
}

/* ============================================
   ORIENTATION SPECIFIC STYLES
   ============================================ */

/* Landscape orientation adjustments */
@media screen and (orientation: landscape) and (max-height: 600px) {
    .chapter-header, .header {
        padding: 10px;
    }
    
    .maha-mantra {
        padding: 15px;
    }
}

/* Portrait orientation optimizations */
@media screen and (orientation: portrait) {
    .nav-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */

/* Larger touch targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .nav-button, .chapter-link, .nav-card {
        min-height: 44px;
        padding: 12px;
        margin: 8px 0;
    }
    
    /* Remove hover effects on touch devices */
    .nav-card:hover, .theme-section:hover, .nav-button:hover {
        transform: none;
    }
}

/* Mouse/trackpad specific styles */
@media (hover: hover) and (pointer: fine) {
    /* Keep hover effects for devices with precise pointing */
    .nav-card:hover {
        transform: translateY(-3px);
    }
}