/* Universal Mobile Optimization CSS - Site-Wide Mobile Enhancement */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* Universal Container System */
.container,
.wp-block-group,
.entry-content,
.site-content,
.content-area {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

/* Mobile-First Typography */
h1, h2, h3, h4, h5, h6 {
    font-size: clamp(1.5rem, 4vw, 3rem);
    line-height: 1.2;
    margin: 0 0 1rem 0;
    word-wrap: break-word;
    hyphens: auto;
}

h1 { font-size: clamp(1.8rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.3rem, 3.5vw, 2rem); }
h4 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h5 { font-size: clamp(1.1rem, 2.5vw, 1.3rem); }
h6 { font-size: clamp(1rem, 2vw, 1.1rem); }

p, li, td, th {
    font-size: clamp(14px, 2.5vw, 16px);
    line-height: 1.6;
    word-wrap: break-word;
}

/* Universal Form Elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    min-height: 44px; /* Better touch targets */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Universal Buttons */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.button,
.wp-block-button__link,
.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    line-height: 1.2;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Universal Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(12px, 2vw, 14px);
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

table thead,
table tbody,
table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

table th,
table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    word-wrap: break-word;
    white-space: normal;
}

/* Universal Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Universal Navigation */
nav ul,
.menu ul,
.navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

nav li,
.menu li,
.navigation li {
    display: block;
    width: 100%;
}

nav a,
.menu a,
.navigation a {
    display: block;
    padding: 12px 15px;
    text-decoration: none;
    color: inherit;
    min-height: 44px;
    line-height: 1.2;
    box-sizing: border-box;
}

/* Universal Cards and Containers */
.card,
.wp-block-group,
.entry-content > *,
.content-area > * {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 1rem 0;
}

/* Mobile-First Breakpoints */
/* Extra Small devices (phones, 320px and up) */
@media (min-width: 320px) {
    .container,
    .wp-block-group,
    .entry-content,
    .site-content,
    .content-area {
        padding: 0 15px;
    }
    
    .grid,
    .wp-block-columns {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container,
    .wp-block-group,
    .entry-content,
    .site-content,
    .content-area {
        max-width: 540px;
        padding: 0 20px;
    }
    
    .grid,
    .wp-block-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container,
    .wp-block-group,
    .entry-content,
    .site-content,
    .content-area {
        max-width: 720px;
        padding: 0 25px;
    }
    
    .grid,
    .wp-block-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    nav ul,
    .menu ul,
    .navigation ul {
        display: flex;
        flex-wrap: wrap;
    }
    
    nav li,
    .menu li,
    .navigation li {
        display: inline-block;
        width: auto;
    }
    
    nav a,
    .menu a,
    .navigation a {
        display: inline-block;
        padding: 8px 15px;
        min-height: auto;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container,
    .wp-block-group,
    .entry-content,
    .site-content,
    .content-area {
        max-width: 960px;
        padding: 0 30px;
    }
    
    .grid,
    .wp-block-columns {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container,
    .wp-block-group,
    .entry-content,
    .site-content,
    .content-area {
        max-width: 1140px;
        padding: 0 40px;
    }
    
    .grid,
    .wp-block-columns {
        grid-template-columns: repeat(4, 1fr);
        gap: 2.5rem;
    }
}

/* Mobile-Specific Optimizations */
@media (max-width: 767px) {
    /* Ensure full width on mobile */
    * {
        max-width: 100%;
    }
    
    /* Better spacing for mobile */
    body {
        padding: 0;
    }
    
    /* Improve touch targets */
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    .button,
    .wp-block-button__link,
    .btn,
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better form layout */
    form {
        width: 100%;
    }
    
    .form-group,
    .wp-block-group {
        margin-bottom: 1rem;
    }
    
    label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: bold;
    }
    
    /* Improve table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 100%;
    }
    
    /* Better button spacing */
    .button + .button,
    .btn + .btn {
        margin-top: 10px;
    }
    
    /* Hide elements that don't work well on mobile */
    .desktop-only,
    .hide-mobile {
        display: none !important;
    }
    
    /* Show mobile-specific elements */
    .mobile-only,
    .show-mobile {
        display: block !important;
    }
}

/* Tablet-specific optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
    .grid,
    .wp-block-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .tablet-only,
    .show-tablet {
        display: block !important;
    }
    
    .hide-tablet {
        display: none !important;
    }
}

/* Desktop-specific optimizations */
@media (min-width: 1024px) {
    .desktop-only,
    .show-desktop {
        display: block !important;
    }
    
    .hide-desktop {
        display: none !important;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 767px) and (orientation: landscape) {
    h1, h2, h3, h4, h5, h6 {
        font-size: clamp(1.2rem, 3vw, 2rem);
    }
    
    .card,
    .wp-block-group {
        padding: 0.75rem;
        margin: 0.25rem 0;
    }
}

/* Very small screens (320px and below) */
@media (max-width: 320px) {
    .container,
    .wp-block-group,
    .entry-content,
    .site-content,
    .content-area {
        padding: 0 10px;
    }
    
    h1, h2, h3, h4, h5, h6 {
        font-size: clamp(1.2rem, 4vw, 1.8rem);
    }
    
    p, li, td, th {
        font-size: 14px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Skip links for accessibility */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999999;
    text-decoration: none;
    padding: 8px 16px;
    background: #000;
    color: #fff;
}

.skip-link:focus {
    left: 6px;
    top: 7px;
}

/* Print styles */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    p, li {
        orphans: 3;
        widows: 3;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Fix for iOS Safari viewport issues */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Universal utility classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none !important; }
.visible { display: block !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.m-0 { margin: 0 !important; }
.p-0 { padding: 0 !important; }

.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

/* Responsive utility classes */
@media (max-width: 767px) {
    .mobile-text-center { text-align: center !important; }
    .mobile-text-left { text-align: left !important; }
    .mobile-text-right { text-align: right !important; }
    
    .mobile-hidden { display: none !important; }
    .mobile-visible { display: block !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .tablet-text-center { text-align: center !important; }
    .tablet-text-left { text-align: left !important; }
    .tablet-text-right { text-align: right !important; }
    
    .tablet-hidden { display: none !important; }
    .tablet-visible { display: block !important; }
}

@media (min-width: 1024px) {
    .desktop-text-center { text-align: center !important; }
    .desktop-text-left { text-align: left !important; }
    .desktop-text-right { text-align: right !important; }
    
    .desktop-hidden { display: none !important; }
    .desktop-visible { display: block !important; }
}
