/* ========================================
 * Mobile-Responsive CSS for Star Trek: Freedom
 * Makes the site mobile-friendly while maintaining backward compatibility
 * Works with existing table-based layouts and Dreamweaver templates
 * ======================================== */

/* ========================================
 * Base Mobile Styles
 * ======================================== */

/* Ensure viewport meta tag is present (should be in header) */
/* <meta name="viewport" content="width=device-width, initial-scale=1.0"> */

/* Make all fixed-width tables responsive */
table[width="1360"],
table[width="1160"],
table[width="1102"],
table[width="664"],
table[width="661"],
table[width="452"],
table[width="456"],
table[width="453"],
table[width="485"],
table[width="129"],
table[width="48"],
table[width="35"],
table[width="30"] {
    width: 100% !important;
    max-width: 100% !important;
}

/* Make all table cells responsive */
td[width],
th[width] {
    width: auto !important;
    max-width: 100% !important;
}

/* Make all fixed-width images responsive */
img[width="1360"],
img[width="1160"],
img[width="1102"],
img[width="664"],
img[width="661"],
img[width="485"],
img[width="453"],
img[width="456"],
img[width="452"],
img[width="283"],
img[width="205"],
img[width="174"],
img[width="129"],
img[width="48"],
img[width="35"],
img[width="30"],
img[width="24"],
img[width="22"],
img[width="20"],
img[width="16"],
img[width="15"] {
    max-width: 100% !important;
    height: auto !important;
}

/* Responsive images in general */
img {
    max-width: 100%;
    height: auto;
}

/* ========================================
 * Mobile Navigation
 * ======================================== */

/* Hide image maps on mobile (they don't work well) */
@media (max-width: 768px) {
    map,
    area {
        display: none;
    }
    
    /* Show alternative text navigation */
    .mobile-nav {
        display: block;
    }
}

/* Mobile-friendly navigation menu */
.mobile-nav {
    display: none;
    background-color: #09131A;
    padding: 15px;
    margin: 10px 0;
}

.mobile-nav a {
    display: block;
    padding: 10px;
    color: #f8a406;
    text-decoration: none;
    border-bottom: 1px solid #333;
}

.mobile-nav a:hover {
    background-color: #0a1a25;
    color: #ffffff;
}

/* ========================================
 * Header Responsive Styles
 * ======================================== */

@media (max-width: 768px) {
    /* Stack header panels vertically */
    .site-header table[width="1360"] td {
        display: block;
        width: 100% !important;
    }
    
    /* Make header banner responsive */
    .site-header img[width="1360"] {
        width: 100% !important;
        height: auto !important;
    }
    
    /* Stack top panels */
    .site-header table tbody tr {
        display: block;
    }
    
    .site-header table tbody tr td {
        display: block;
        width: 100% !important;
        padding: 10px;
    }
    
    /* Hide decorative side images on mobile */
    .site-header img[width="129"] {
        display: none;
    }
}

/* ========================================
 * Main Content Responsive Styles
 * ======================================== */

@media (max-width: 768px) {
    /* Stack main content columns */
    table[width="1360"] tbody tr td[width="661"],
    table[width="1360"] tbody tr td[width="664"],
    table[width="1360"] tbody tr td[width="1102"] {
        display: block;
        width: 100% !important;
    }
    
    /* Hide vertical separator bars on mobile */
    img[width="35"][alt=""],
    img[width="48"][alt=""] {
        display: none;
    }
    
    /* Make content tables stack */
    table[width="100%"] {
        display: block;
    }
    
    table[width="100%"] tbody tr {
        display: block;
        margin-bottom: 10px;
    }
    
    table[width="100%"] tbody tr td {
        display: block;
        width: 100% !important;
        padding: 5px 0;
    }
}

/* ========================================
 * Tables - Make Responsive
 * ======================================== */

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 15px 0;
}

@media (max-width: 768px) {
    /* Make all tables scrollable horizontally on mobile */
    table {
        min-width: 100%;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack table rows on very small screens */
    @media (max-width: 480px) {
        table.pretty-table-roster,
        table[class*="roster"],
        table[class*="table"] {
            display: block;
        }
        
        table.pretty-table-roster tbody,
        table[class*="roster"] tbody,
        table[class*="table"] tbody {
            display: block;
        }
        
        table.pretty-table-roster tr,
        table[class*="roster"] tr,
        table[class*="table"] tr {
            display: block;
            margin-bottom: 15px;
            border: 1px solid #333;
            padding: 10px;
        }
        
        table.pretty-table-roster td,
        table[class*="roster"] td,
        table[class*="table"] td {
            display: block;
            width: 100% !important;
            text-align: left !important;
            padding: 5px 0;
            border: none;
        }
        
        table.pretty-table-roster td:before,
        table[class*="roster"] td:before,
        table[class*="table"] td:before {
            content: attr(data-label) ": ";
            font-weight: bold;
            display: inline-block;
            min-width: 100px;
        }
    }
}

/* ========================================
 * Forms - Mobile Friendly
 * ======================================== */

@media (max-width: 768px) {
    /* Make form elements full width */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    textarea,
    select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Stack form elements */
    form table tr {
        display: block;
        margin-bottom: 15px;
    }
    
    form table tr td {
        display: block;
        width: 100% !important;
        padding: 5px 0;
    }
    
    /* Make buttons full width on mobile */
    input[type="submit"],
    input[type="button"],
    button {
        width: 100% !important;
        padding: 12px;
        font-size: 16px;
        margin: 10px 0;
    }
}

/* ========================================
 * Typography - Mobile Optimized
 * ======================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    p {
        font-size: 14px;
        line-height: 1.6;
        margin: 10px 0;
    }
    
    td {
        font-size: 12px !important;
    }
    
    h1 {
        font-size: 24px;
        margin: 15px 0;
    }
    
    h2 {
        font-size: 20px;
        margin: 12px 0;
    }
    
    h3 {
        font-size: 18px;
        margin: 10px 0;
    }
}

/* ========================================
 * Footer - Mobile Friendly
 * ======================================== */

@media (max-width: 768px) {
    footer table,
    .site-footer table {
        width: 100% !important;
    }
    
    footer table tr,
    .site-footer table tr {
        display: block;
    }
    
    footer table td,
    .site-footer table td {
        display: block;
        width: 100% !important;
        text-align: center;
        padding: 10px 0;
    }
    
    /* Stack social media icons */
    footer table tbody tr td[width="20%"] {
        display: inline-block;
        width: auto !important;
        margin: 0 10px;
    }
    
    .footer-copyright {
        font-size: 10px;
        padding: 15px 10px;
        line-height: 1.4;
    }
}

/* ========================================
 * Image Maps - Mobile Alternative
 * ======================================== */

/* Hide image maps on mobile, show text links instead */
@media (max-width: 768px) {
    img[usemap] {
        display: none;
    }
    
    /* Show alternative navigation */
    .image-map-alternative {
        display: block;
        background-color: #09131A;
        padding: 15px;
        margin: 10px 0;
    }
    
    .image-map-alternative a {
        display: block;
        padding: 10px;
        color: #f8a406;
        text-decoration: none;
        border-bottom: 1px solid #333;
    }
}

/* ========================================
 * Utility Classes for Mobile
 * ======================================== */

/* Hide on mobile */
.hide-mobile {
    display: block;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* Full width on mobile */
@media (max-width: 768px) {
    .mobile-full-width {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Stack on mobile */
@media (max-width: 768px) {
    .mobile-stack {
        display: block !important;
    }
    
    .mobile-stack > * {
        width: 100% !important;
        margin-bottom: 10px;
    }
}

/* ========================================
 * Touch-Friendly Elements
 * ======================================== */

@media (max-width: 768px) {
    /* Make links easier to tap */
    a {
        min-height: 44px;
        display: inline-block;
        padding: 10px 5px;
        line-height: 24px;
    }
    
    /* Make buttons touch-friendly */
    button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ========================================
 * Breakpoints
 * ======================================== */

/* Small mobile (320px - 480px) */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    h2 {
        font-size: 18px;
    }
    
    /* Even more aggressive stacking */
    table {
        font-size: 11px;
    }
}

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    /* Tablet-specific styles */
    table[width="1360"] {
        max-width: 100%;
    }
}

/* Desktop (769px+) */
@media (min-width: 769px) {
    /* Desktop styles - maintain existing layout */
}

/* Large desktop (1361px+) */
@media (min-width: 1361px) {
    /* Center content on very large screens */
    table[width="1360"] {
        margin: 0 auto;
    }
}

/* ========================================
 * Print Styles
 * ======================================== */

@media print {
    table[width="1360"],
    table[width="1160"] {
        width: 100% !important;
    }
    
    .hide-mobile,
    .show-mobile,
    .mobile-nav,
    .image-map-alternative {
        display: none !important;
    }
    
    img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}


