/* Mobile-Specific Optimizations for All Device Sizes (index.php and dashboard.php) */

/* Apply styles only for mobile devices (max-width: 767px) */
@media (max-width: 767px) {
    /* Reset and Base Styles for Mobile */
    * {
        -webkit-tap-highlight-color: transparent; /* Prevent tap highlight on mobile */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    body {
        font-size: 16px; /* Base font size for better readability on mobile */
        line-height: 1.5; /* Slightly tighter line-height for mobile */
    }

    /* Starry/Wave Background */
    #stars-background, #shooting-stars, #stars-background-support, #shooting-stars-support {
        will-change: transform; /* Optimize for mobile rendering */
        z-index: 0; /* Ensure background stays behind content */
    }

    /* Header Styles (applies to index.php and dashboard.php) */
    .header {
        height: 3.5rem; /* Reduced height for mobile */
        padding: 0.25rem;
        display: flex;
        align-items: center;
        justify-content: center; /* Center content in header */
    }

    .header .max-w-7xl {
        padding: 0.25rem;
        display: flex;
        align-items: center;
        justify-content: space-between; /* Space for logo and hamburger */
        width: 100%;
        position: relative;
    }

    .header .logo-mobile {
        display: inline-flex;
        align-items: center;
        position: absolute;
        left: 50%;
        transform: translateX(-50%); /* Center logo horizontally */
        z-index: 10; /* Above other elements */
    }

    .header .logo-mobile img {
        height: 3rem; /* Smaller logo for mobile */
        width: auto;
    }

    .header .logo-desktop {
        display: none; /* Hide desktop logo on mobile */
    }

    .header nav {
        display: none; /* Hide nav by default on mobile */
        position: absolute;
        top: 3.5rem;
        left: 0;
        width: 100%;
        background: #ffffff; /* Match header background */
        padding: 0.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        flex-direction: column; /* Stack nav items vertically */
        gap: 0.25rem;
        align-items: flex-start; /* Align nav items to the start */
        z-index: 5; /* Below logo but above background */
    }

    .header nav.active {
        display: flex; /* Show nav when hamburger is toggled */
    }

    .header .hamburger {
        display: block;
        font-size: 1.5rem;
        cursor: pointer;
        color: #1E3A8A;
        padding: 0.25rem;
        line-height: 1; /* Ensure hamburger icon aligns properly */
        margin-left: auto; /* Push hamburger to the right */
        z-index: 10; /* Ensure hamburger is clickable */
    }

    .header nav a {
        font-size: 0.85rem; /* Smaller font size for mobile */
        padding: 0.4rem 0.8rem;
        width: 100%; /* Full width for touch targets */
        text-align: left; /* Align text for better readability */
    }

    /* Homepage and Content Container */
    .homepage {
        padding-top: 3.5rem; /* Adjust for smaller header */
    }

    .content-container {
        padding: 0 0.5rem;
    }

    /* Hero Section */
    .hero {
        min-height: 80vh;
        padding: 1rem 0.5rem;
    }

    .hero-logo {
        max-width: 200px;
        width: 60%;
    }

    .hero-content h1 {
        font-size: 1.8rem;
        margin-bottom: 0.75rem;
    }

    .hero-content p {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .cta-button, #join-team-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    /* Our Mission Section */
    .our-mission {
        padding: 1.5rem 0.5rem;
    }

    .our-mission h2 {
        font-size: 1.6rem;
    }

    .our-mission p {
        font-size: 0.9rem;
    }

    .our-mission .mission-card {
        padding: 1rem;
    }

    /* Features Section */
    .features {
        padding: 1.5rem 0.5rem;
    }

    .features h2 {
        font-size: 1.6rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 0.5rem;
    }

    .feature-card {
        padding: 1rem;
    }

    .feature-card h3 {
        font-size: 1.1rem;
    }

    .feature-card p {
        font-size: 0.85rem;
    }

    /* FAQ Section */
    .faq-container {
        padding: 0.75rem;
    }

    .faq-container h2 {
        font-size: 1.3rem;
    }

    .faq-tab-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .faq-tab-content {
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    .faq-tab-content:not(.hidden) {
        max-height: 300px;
    }

    /* Contact Section */
    #contact .content-container {
        padding: 1.5rem 0.5rem;
        flex-direction: column;
        gap: 2rem;
    }

    .contact-flip-card {
        min-height: 350px;
        padding: 1rem;
    }

    .contact-flip-card h2 {
        font-size: 1.3rem;
    }

    .contact-form .form-group label {
        font-size: 0.6rem;
    }

    .contact-form .form-group select,
    .contact-form .form-group input,
    .contact-form .form-group textarea {
        font-size: 0.6rem;
        padding: 0.2rem;
    }

    .contact-form .btn {
        font-size: 0.6rem;
        padding: 0.2rem;
    }

    /* Support Section (if present in dashboard.php) */
    .support-section {
        padding: 1.5rem 0.5rem; /* Reduced padding to fit content */
        display: flex;
        flex-direction: column;
        align-items: center; /* Center content horizontally */
        overflow: visible; /* Prevent content clipping */
        box-sizing: border-box;
        width: 100%; /* Ensure full viewport width */
        position: relative;
        z-index: 1; /* Above wave background */
    }

    .support-section .content-container {
        max-width: 100%; /* Prevent overflow */
        padding: 0 0.5rem;
        display: flex;
        flex-direction: column;
        align-items: center; /* Center content within container */
        justify-content: center;
        box-sizing: border-box;
        z-index: 2; /* Above wave background */
    }

    .support-title {
        font-size: 1.6rem; /* Slightly smaller for mobile */
        margin-bottom: 0.75rem;
        text-align: center;
        z-index: 3; /* Above wave background */
    }

    .support-description {
        font-size: 0.9rem;
        margin-bottom: 1rem;
        max-width: 100%; /* Ensure description fits viewport */
        text-align: center;
        z-index: 3; /* Above wave background */
    }

    .support-goal-container {
        display: flex;
        flex-direction: column; /* Stack heart and text vertically */
        align-items: center; /* Center horizontally */
        justify-content: center;
        width: 100%;
        margin-bottom: 1rem;
        z-index: 3; /* Above wave background */
    }

    .support-goal-container .heart-wrap {
        margin: 0 auto; /* Center the heart */
        display: flex;
        justify-content: center;
        align-items: center;
        width: 80px; /* Match heart dimensions */
        height: 70px;
        z-index: 3; /* Above wave background */
    }

    .heart {
        margin: 0 auto; /* Ensure heart is centered */
        width: var(--dim-x);
        height: var(--dim-y);
        z-index: 3; /* Above wave background */
    }

    .support-goal-container .goal-text {
        font-size: 0.8rem;
        text-align: center;
        margin-top: 0.5rem;
        max-width: 100%; /* Prevent text overflow */
        z-index: 3; /* Above wave background */
        position: relative; /* Ensure text is positioned correctly */
    }

    .support-options {
        flex-direction: column; /* Stack buttons vertically */
        gap: 0.5rem;
        width: 100%; /* Full width for buttons */
        max-width: 300px; /* Limit button width for balance */
        margin: 0 auto; /* Center buttons */
        z-index: 3; /* Above wave background */
    }

    .support-options .support-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        width: 100%; /* Full width for touch targets */
        text-align: center;
        box-sizing: border-box;
        z-index: 3; /* Above wave background */
    }

    /* Sponsors Section */
    .sponsors-section {
        padding: 1.5rem 0.5rem;
        z-index: 1; /* Above wave background */
    }

    .sponsors-section h2 {
        font-size: 1.6rem;
    }

    .sponsor-grid {
        gap: 2rem;
        width: 2000px;
        animation: slide 20s linear infinite;
    }

    .sponsor-img {
        width: 120px;
        height: 80px;
    }

    @keyframes slide {
        0% {
            transform: translateX(0);
        }
        100% {
            transform: translateX(-1000px);
        }
    }

    /* Progress Circle */
    .progress-circle-container {
        width: 120px;
        height: 120px;
        z-index: 3; /* Above wave background */
    }

    .progress-percentage {
        font-size: 1.5rem;
    }

    .progress-goal {
        font-size: 0.75rem;
    }

    /* Dashboard Styles */
    .dashboard {
        padding-top: 3.5rem;
        flex-direction: column;
    }

    .sidebar {
        margin: 0.5rem;
        height: auto;
        padding: 0.75rem;
    }

    .profile-pic {
        width: 3rem;
        height: 3rem;
    }

    .sidebar h2 {
        font-size: 1rem;
    }

    .sidebar p {
        font-size: 0.7rem;
    }

    .main-content {
        padding: 0.75rem 0.5rem;
    }

    .main-content h1 {
        font-size: 1.3rem;
    }

    .card {
        padding: 1rem;
    }

    .card h2 {
        font-size: 1.1rem;
    }

    .card h3 {
        font-size: 0.9rem;
    }

    .card p {
        font-size: 0.8rem;
    }

    /* Notebook-Style Tabs */
    .tab-nav nav {
        flex-direction: column;
    }

    .tab-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    /* Form and Button Styles */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 0.8rem;
        padding: 0.4rem;
    }

    button, .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* Password Strength Meter */
    #password-strength {
        margin-bottom: 1rem;
    }

    /* Journal Section */
    #journal-section {
        padding: 0.5rem;
    }

    .journal-toggle {
        font-size: 0.8rem;
    }

    #journal-entries > div {
        padding: 0.4rem;
    }

    #journal-entries span.text-sm {
        font-size: 0.8rem;
    }

    #journal-entries .text-gray-500,
    #journal-entries .text-gray-400 {
        font-size: 0.7rem;
    }

    #journal-search,
    #journal-filter {
        font-size: 0.8rem;
        padding: 0.2rem;
    }

    /* Admin Section */
    #admin-section {
        padding: 0.5rem;
    }

    .admin-subsection th,
    .admin-subsection td {
        font-size: 0.7rem;
        padding: 0.4rem;
    }

    .admin-tab-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* Modal Styles */
    .modal-content {
        padding: 1rem;
        max-width: 90%;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }

    .modal-content h3 {
        font-size: 1rem;
    }

    .modal-content button {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    #delete-account-modal .modal-content {
        padding: 1rem;
    }

    #delete-account-modal .modal-content input#delete-confirm-input {
        font-size: 0.8rem;
        padding: 0.4rem;
    }

    #delete-account-modal .modal-content button#delete-confirm,
    #delete-account-modal .modal-content button#delete-cancel {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* Footer Styles */
    .footer {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .quick-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .social-icons {
        gap: 1rem;
    }

    .social-icon {
        font-size: 1.2rem;
    }

    /* Back to Top */
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2rem;
        height: 2rem;
    }

    .back-to-top svg {
        width: 1.2rem;
        height: 1.2rem;
    }
}

/* Extra Small Devices (below 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .header {
        height: 3rem;
    }

    .header .logo-mobile img {
        height: 2.5rem;
    }

    .header nav {
        top: 3rem;
    }

    .hero-logo {
        max-width: 150px;
        width: 50%;
    }

    .hero-content h1 {
        font-size: 1.5rem;
    }

    .hero-content p {
        font-size: 0.85rem;
    }

    .support-section {
        padding: 1rem 0.25rem; /* Further reduced padding */
    }

    .support-title {
        font-size: 1.4rem;
    }

    .support-description {
        font-size: 0.85rem;
    }

    .support-goal-container .heart-wrap {
        width: 60px; /* Smaller heart for tiny screens */
        height: 50px;
    }

    .heart {
        width: 60px;
        height: 50px;
    }

    .support-goal-container .goal-text {
        font-size: 0.75rem;
    }

    .support-options .support-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .sponsor-img {
        width: 100px;
        height: 60px;
    }

    .progress-circle-container {
        width: 100px;
        height: 100px;
    }

    .progress-percentage {
        font-size: 1.2rem;
    }

    .progress-goal {
        font-size: 0.7rem;
    }
}

/* Desktop Styles (ensure logo-desktop is visible for index.php and dashboard.php) */
@media (min-width: 768px) {
    .header .logo-mobile {
        display: none; /* Hide mobile logo on desktop */
    }

    .header .logo-desktop {
        display: inline-flex; /* Show desktop logo */
        align-items: center;
    }

    .header .hamburger {
        display: none; /* Hide hamburger on desktop */
    }
}