/* =================================================
   MOBILE-FIRST RESPONSIVE STYLESHEET
   Optimizes all content for phone screens
   ================================================= */

/* Extra small phones (320px - 374px) */
@media (max-width: 374px) {
    html {
        font-size: 14px;
    }

    body {
        font-size: 14px;
    }

    h1 {
        font-size: clamp(1.4rem, 5vw, 2rem);
    }

    h2 {
        font-size: clamp(1.2rem, 4vw, 1.75rem);
    }

    h3 {
        font-size: 1.1rem;
    }

    h4 {
        font-size: 1rem;
    }

    h5 {
        font-size: 0.9rem;
    }

    h6 {
        font-size: 0.8rem;
    }

    p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

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

    /* Touch targets minimum 44px */
    button, a.btn, input[type="button"], input[type="submit"], a[role="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 0.65rem 1rem;
    }
}

/* Small phones (375px - 575px) */
@media (max-width: 575.98px) {
    html {
        font-size: 15px;
    }

    body {
        font-size: 15px;
        padding-top: 74px;
    }

    /* Typography */
    h1 {
        font-size: clamp(1.5rem, 5.5vw, 2.1rem);
        line-height: 1.2;
        margin-bottom: 0.75rem;
    }

    h2 {
        font-size: clamp(1.3rem, 4.5vw, 1.8rem);
        line-height: 1.25;
        margin-bottom: 0.75rem;
    }

    h3 {
        font-size: 1.15rem;
        margin-bottom: 0.5rem;
    }

    h4 {
        font-size: 1.05rem;
        margin-bottom: 0.5rem;
    }

    h5 {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }

    h6 {
        font-size: 0.85rem;
        margin-bottom: 0.35rem;
    }

    p {
        font-size: 0.95rem;
        line-height: 1.55;
        margin-bottom: 1rem;
    }

    /* Small text */
    small, .small {
        font-size: 0.8rem;
    }

    /* Code blocks */
    code, pre {
        font-size: 0.85rem;
    }

    /* Links */
    a {
        word-break: break-word;
    }

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

    picture {
        display: block;
    }

    /* Buttons & Interactive Elements */
    button,
    a.btn,
    a[role="button"],
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.65rem 1.25rem;
        font-size: 0.95rem;
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.25s ease;
    }

    button:active,
    a.btn:active,
    input[type="button"]:active,
    input[type="submit"]:active {
        transform: scale(0.98);
    }

    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        width: 100%;
        max-width: 100%;
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        border: 1px solid #ccc;
        border-radius: 6px;
        line-height: 1.5;
        font-family: inherit;
        min-height: 44px;
    }

    textarea {
        resize: vertical;
        line-height: 1.5;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-width: 18px;
        min-height: 18px;
        margin-right: 0.5rem;
        cursor: pointer;
    }

    label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 600;
        cursor: pointer;
    }

    /* Containers & Sections */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .row {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    /* Spacing utilities */
    .py-5, .py-lg-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .my-5, .my-lg-5 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    .mt-5, .mt-lg-5 {
        margin-top: 1.5rem !important;
    }

    .mb-5, .mb-lg-5 {
        margin-bottom: 1.5rem !important;
    }

    .px-5, .px-lg-5 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .mx-5, .mx-lg-5 {
        margin-left: 1rem !important;
        margin-right: 1rem !important;
    }

    /* Gaps */
    .g-4, .g-lg-4 {
        gap: 1rem !important;
    }

    .g-5, .g-lg-5 {
        gap: 1.25rem !important;
    }

    /* Display utilities */
    .d-none.d-sm-block {
        display: none !important;
    }

    .d-sm-none {
        display: none !important;
    }

    /* Tables */
    table {
        width: 100%;
        font-size: 0.9rem;
        border-collapse: collapse;
        margin-bottom: 1.5rem;
    }

    th, td {
        padding: 0.75rem;
        text-align: left;
        border-bottom: 1px solid #eee;
    }

    th {
        background-color: #f5f5f5;
        font-weight: 600;
    }

    /* Cards & Boxes */
    .card, [class*="card"] {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    /* Lists */
    ul, ol {
        padding-left: 1.5rem;
        margin-bottom: 1rem;
    }

    li {
        margin-bottom: 0.5rem;
        line-height: 1.6;
    }

    /* Blockquotes */
    blockquote {
        padding-left: 1rem;
        border-left: 3px solid #ddd;
        margin: 1rem 0;
        font-style: italic;
        color: #666;
    }

    /* Horizontal rules */
    hr {
        margin: 1.5rem 0;
        border: none;
        border-top: 1px solid #eee;
    }

    /* Video embeds */
    video, iframe {
        max-width: 100%;
        height: auto;
    }

    /* Prevent horizontal scroll on overflow */
    body {
        overflow-x: hidden;
    }

    /* Ensure content doesn't overflow */
    pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Focus states for accessibility */
    button:focus-visible,
    a:focus-visible,
    input:focus-visible,
    textarea:focus-visible,
    select:focus-visible {
        outline: 2px solid #0066cc;
        outline-offset: 2px;
    }

    /* Mobile menu adjustments */
    .navbar-collapse {
        padding: 1rem 0;
    }

    /* Hero sections on mobile */
    section[class*="hero"],
    .hero {
        min-height: auto !important;
        padding: 2rem 0 !important;
    }

    /* Modals/Dialogs */
    .modal-dialog {
        margin: 1rem;
    }

    /* Alerts */
    .alert {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 6px;
        font-size: 0.95rem;
    }

    /* Utility: Text truncation */
    .text-truncate {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Utility: Line clamping */
    .line-clamp-2 {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .line-clamp-3 {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* Medium devices (576px - 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    body {
        padding-top: 80px;
    }

    .container {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    h1 {
        font-size: clamp(1.7rem, 5vw, 2.3rem);
    }

    h2 {
        font-size: clamp(1.5rem, 4vw, 2rem);
    }

    p {
        font-size: 1rem;
        line-height: 1.6;
    }
}

/* Large devices and up (768px+) - Bootstrap defaults mostly work */
@media (min-width: 768px) {
    body {
        padding-top: 92px;
    }
}

/* Print styles */
@media print {
    body {
        padding-top: 0;
    }

    nav, footer, .no-print {
        display: none !important;
    }

    a {
        text-decoration: underline;
    }

    a::after {
        content: " (" attr(href) ")";
    }

    img {
        max-width: 100%;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding-top: 60px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .hero-section,
    section[class*="hero"] {
        min-height: auto !important;
        padding: 1rem 0 !important;
    }
}

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

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    a, button, input[type="button"], input[type="submit"] {
        min-height: 48px;
        min-width: 48px;
    }

    /* Remove hover effects */
    a:hover {
        opacity: 0.8;
    }

    /* Improve tap feedback */
    input, textarea, select, button, a {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        background-color: #333;
        color: #fff;
        border-color: #555;
    }

    th {
        background-color: #333;
        color: #fff;
    }

    blockquote {
        color: #aaa;
    }
}
