/* ============================================
   Mobile Styles - Joe for RTD
   Always load this file AFTER main.css
   ============================================ */

/* Mobile breakpoint: 768px and below */
@media (max-width: 768px) {
    /* CSS custom properties for mobile popup sizing */
    :root {
        --mobile-popup-width: 210px;
        --mobile-popup-offset: 1px;
    }

    /* Header - Remove sticky positioning on mobile */
    header {
        position: relative;
    }

    .header-main {
        padding: 0.5rem 1rem;
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        grid-template-rows: auto;
        column-gap: 1rem;
        align-items: center;
    }

    .logo-container {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
        display: flex;
        flex-direction: column;
        gap: 0;
        align-items: flex-start;
    }

    /* Smaller logo on mobile */
    .logo {
        max-width: 50px;
        max-height: 50px;
        margin-right: 0;
        margin-bottom: -0.15rem;
    }

    /* Update text on mobile - much smaller and below logo */
    .logo-text {
        font-size: 9px;
        margin: 0;
        padding-left: 0.25rem;
        text-align: left;
        line-height: 1;
    }

    .logo-text::after {
        content: " District C";
    }

    .support-button {
        grid-column: 3;
        grid-row: 1;
        align-self: center;
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    /* Show hamburger menu on mobile - to the right of support button */
    .hamburger {
        display: flex;
        justify-content: space-between;
        grid-column: 4;
        grid-row: 1;
        align-self: center;
        height: 1.5rem;
        aspect-ratio: 1 / 1;
    }

    .hamburger span {
        width: 100%;
        height: 3px;
        background: #FFFFFF;
        border-radius: 1px;
        transition: all 0.3s ease;
        display: block;
        position: relative;
        flex-shrink: 0;
    }

    /* Override X animation for smaller mobile hamburger */
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(0rem, 0.75rem);
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(0rem, -0.75rem);
    }

    /* Navigation dropdown - full screen overlay */
    .nav-dropdown {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 47, 135, 0.98);
        backdrop-filter: blur(10px);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
    }

    .nav-dropdown.active {
        transform: translateX(0);
    }

    .nav-dropdown-content {
        padding: 5rem 2rem 2rem 2rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
    }

    .nav-menu {
        flex-direction: column;
        gap: 1.5rem;
        padding: 2rem 0;
        text-align: center;
        width: 100%;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        font-size: 1.5rem;
        padding: 1rem;
        border-radius: 8px;
        transition: all 0.3s ease;
    }

    .nav-menu a:hover {
        background: rgba(65, 193, 239, 0.1);
    }

    /* Main content - reduced padding */
    main {
        padding: 0.625rem;
    }

    /* Hero section - single column */
    .hero-section {
        grid-template-columns: 1fr;
    }

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

    .hero-content p {
        text-align: center;
    }

    /* Features - single column */
    .features {
        grid-template-columns: 1fr;
    }

    /* Tighter padding in feature boxes */
    .feature-box {
        padding: 0.75rem 0.5rem;
    }

    .feature-box h3 {
        margin-bottom: 0.5rem;
    }

    /* Page title section padding */
    .page-title-section {
        padding: 1.5rem 1rem;
    }

    /* Contact section */
    .contact-section {
        justify-content: center;
    }

    .contact-methods {
        grid-template-columns: 1fr;
    }

    /* Footer - reduced padding and margins */
    footer {
        padding: 0.5rem 0;
        margin-top: 1.5rem;
    }

    .footer-content {
        padding: 0 1rem;
    }

    .footer-legal {
        font-size: clamp(7px, 1.8vw, 0.85rem);
        line-height: 1.5;
    }

    .footer-legal p {
        margin-bottom: 0.1rem;
    }
}

/* Extra small mobile breakpoint: 480px and below */
@media (max-width: 480px) {
    .popup-donate-buttons {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .popup-donate-button.large {
        grid-column: span 1;
    }

    .popup-donate-section {
        padding: 2rem 1.5rem 1.5rem 1.5rem;
    }
}

/* ============================================
   Map Page Mobile Styles
   ============================================ */
@media (max-width: 768px) {
    /* Mobile-specific popup styles - these override the inline styles in map.html */
    .mapboxgl-popup {
        max-height: 90vh !important;
    }

    .mapboxgl-popup-content {
        border-radius: 8px !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* Mobile popup class - fixed width at ~2/3 screen for predictable positioning */
    .mobile-popup .mapboxgl-popup-content {
        width: var(--mobile-popup-width) !important;
        max-width: var(--mobile-popup-width) !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin: 0px;
    }

    .popup-content {
        padding: 0.4rem;
        max-height: 45vh;
        margin: 8px;
        border-radius: 4px;
    }

    .popup-content h3 {
        font-size: 0.85rem;
        margin-bottom: 0.35rem;
        padding-bottom: 0.25rem;
        line-height: 1.2;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .popup-content .stop-type {
        font-size: 0.65rem;
        padding: 0.1rem 0.3rem;
        margin-bottom: 0.3rem;
    }

    .popup-content p {
        font-size: 0.75rem;
        margin: 0.15rem 0;
        line-height: 1.3;
    }

    .popup-content .stop-code {
        font-size: 0.7rem;
        margin-top: 0.4rem;
        margin-bottom: 0;
    }

    .routes-list {
        max-height: 35vh;
        margin-top: 0.4rem;
    }

    .routes-list .label {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }

    .route-item {
        gap: 0.3rem;
        margin-bottom: 0.3rem;
    }

    .route-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.3rem;
        min-width: 22px;
        min-height: 22px;
    }

    .route-directions {
        font-size: 0.75rem;
        color: #666;
        line-height: 1.3;
        flex: 1;
    }

    .route-directions-label {
        font-weight: 600;
        color: #444;
        margin-right: 0.25rem;
    }

    .route-name {
        font-size: 0.75rem;
        line-height: 1.2;
    }

    .popup-navigation {
        padding: 0.3rem 0.4rem;
        gap: 0.3rem;
    }

    .popup-nav-button {
        padding: 0.25rem 0.4rem;
        font-size: 0.85rem;
        min-width: 26px;
    }

    .popup-nav-info {
        font-size: 0.7rem;
    }

    .popup-loading {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .mapboxgl-popup-close-button {
        font-size: 18px !important;
        padding: 4px 6px !important;
    }

    /* Make schedule buttons smaller on mobile */
/*     .popup-content a[href*="rtd-denver.com"] {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        font-weight: 500;
        border-radius: 4px;
    } */

    /* Route detail popup mobile overrides */
    .route-detail-header {
        gap: 0.5rem;
        margin-bottom: 0.4rem;
    }

    .route-detail-header .route-badge {
        font-size: 0.9rem;
        min-width: 28px;
        min-height: 28px;
        padding: 0.3rem;
        align-items: center;
    }

    .route-detail-header h3 {
        font-size: 0.85rem;
    }

    .route-detail-directions {
        margin-bottom: 0.3rem;
    }

    .direction-group {
        margin-bottom: 0.3rem;
    }

    .direction-label {
        font-size: 0.7rem;
        margin-bottom: 0;
    }

    .direction-headsign {
        font-size: 0.7rem;
        margin-left: 0.75rem;
    }

    .direction-unavailable {
        font-size: 0.7rem;
    }

    .stop-schedule-link {
        margin-top: 0.2rem;
    }

    /*Mobile-specifc Schedule button styles */
    .route-detail-schedule {
        margin-top: 0;
    }
    
    .schedule-button {
        display: inline-block;
        background: #002F87;
        color: white;
        padding: 0.25rem 0.7rem;
        border-radius: 4px;
        text-decoration: none;
        font-weight: 500;
        font-size: 0.6rem;
        transition: background 0.2s;
    }

    .schedule-button:hover {
        background: #001f5c;
    }

    .schedule-button-small {
        display: inline-block;
        background: #666;
        color: white;
        padding: 0.25rem 0.7rem;
        border-radius: 4px;
        text-decoration: none;
        font-weight: 500;
        font-size: 0.6rem;
        transition: background 0.2s;
    }

    .schedule-button-small:hover {
        background: #444;
    }

    /* Mobile map-specific header and layout - only on map page */
    body:has(.map-container) .page-header {
        display: none;
    }

    /* Hide title section on mobile to maximize map space - only on map page */
    body:has(.map-container) .page-title-section {
        display: none;
    }

    /* Hide desktop legend and controls on mobile */
    .route-legend,
    .map-controls {
        display: none !important;
    }

    /* Reduce main content padding on map page only */
    body:has(.map-container) main {
        padding: 0;
    }

    /* Map takes full viewport height minus header, footer, and tab buttons */
    /* Mobile header ≈ 4.5rem, footer = 1.5rem (fixed), tab buttons ≈ 2.5rem = 8.5rem total */
    .map-container {
        height: calc(100vh - 8.5rem);
        min-height: calc(100vh - 8.5rem);
        position: relative;
    }

    /* Compact footer on mobile - fixed to bottom with FIXED HEIGHT - only on map page */
    body:has(.map-container) footer {
        padding: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 400;
        height: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body:has(.map-container) .footer-content {
        padding: 0 0.5rem;
        width: 100%;
    }

    body:has(.map-container) .footer-legal {
        font-size: clamp(6px, 1.5vw, 0.5rem);
    }

    /* District C boundary watermark on mobile map */
    .map-watermark {
        display: block;
        position: absolute;
        top: 0.5rem;
        left: 0.5rem;
        background: rgba(255, 255, 255, 0.7);
        padding: 0.15rem 0.25rem;
        border-radius: 4px;
        font-size: 0.7rem;
        font-weight: 600;
        color: rgba(246, 135, 31, 0.85);
        z-index: 450;
        pointer-events: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    /* Mobile tab container - float above footer */
    .mobile-tab-container {
        position: fixed;
        bottom: 1.5rem;
        left: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        background: white;
        border-top: 2px solid #002F87;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        z-index: 500;
        max-height: calc(60vh - 1.5rem);
    }

    .mobile-tab-buttons {
        display: flex;
        background: #f5f5f5;
        border-bottom: 1px solid #ddd;
    }

    .mobile-tab-button {
        flex: 1;
        padding: 0.5rem;
        background: #f5f5f5;
        border: none;
        border-bottom: 3px solid transparent;
        border-right: 1px solid #002F87;
        font-size: 0.9rem;
        font-weight: 600;
        color: #666;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-tab-button:last-child {
        border-right: none;
    }

    .mobile-tab-button.active {
        background: white;
        color: #002F87;
        border-bottom-color: #41C1EF;
    }

    .mobile-tab-content {
        display: none;
        max-height: 40vh;
        overflow-y: auto;
        padding: 0.5rem 0.75rem;
        background: white;
    }

    .mobile-tab-content.active {
        display: block;
    }

    /* Adjust legend styles for mobile */
    .mobile-tab-content .legend-routes {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .mobile-tab-content .legend-section {
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #e0e0e0;
    }

    .mobile-tab-content .legend-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .mobile-tab-content .legend-section-title {
        font-size: 0.75rem;
        font-weight: 700;
        color: #002F87;
        margin-bottom: 0.35rem;
        text-transform: uppercase;
    }

    /* Adjust controls styles for mobile */
    .mobile-tab-content label {
        display: block;
        margin-bottom: 0.75rem;
        font-size: 0.85rem;
        padding: 0.5rem;
        background: #f8f9fa;
        border-radius: 6px;
    }

    .mobile-tab-content input[type="radio"],
    .mobile-tab-content input[type="checkbox"] {
        margin-right: 0.75rem;
        transform: scale(1.2);
    }

    .mobile-tab-content hr {
        margin: 1rem 0;
        border: none;
        border-top: 1px solid #ddd;
    }

    /* Two-column grid for mobile controls */
    .mobile-controls-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .mobile-controls-column {
        display: flex;
        flex-direction: column;
    }

    .mobile-controls-column label {
        margin-bottom: 0.5rem;
    }

    /* Mobile search box styles */
    .map-search-container {
        top: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        max-width: none;
        transform: none;
        border-radius: 8px;
        z-index: 600;
    }

    .search-mode-btn {
        padding: 0.6rem;
        font-size: 0.85rem;
    }

    .search-input {
        padding: 0.75rem 2.5rem 0.75rem 0.75rem;
        font-size: 0.9rem;
    }

    .search-clear-btn {
        right: 0.5rem;
        font-size: 1.25rem;
    }

    .search-results {
        max-height: 300px;
    }

    .search-result-item {
        padding: 0.6rem 0.75rem;
    }

    .search-result-title {
        font-size: 0.85rem;
    }

    .search-result-subtitle {
        font-size: 0.75rem;
    }

    .search-result-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.3rem;
        min-width: 20px;
    }

    .search-no-results {
        padding: 1rem;
        font-size: 0.85rem;
    }
}
