/**
 * Mobile Responsive Fixes
 * Centralized mobile CSS for the entire theme.
 * Loaded globally via functions.php.
 */

/* ── Global Mobile Reset ── */
html,
body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

/* ── Hamburger Menu Button Fix ──
   The 3 spans inside .menu-toggle were rendering as tiny dots.
   Force visible bars. */
.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #1f2937;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

/* ── 768px and below: Tablet / Large Phone ── */
@media (max-width: 768px) {

    /* Header */
    .header-inner {
        padding: 0 16px;
        flex-wrap: nowrap;
    }

    .menu-toggle {
        display: flex !important;
        flex-direction: column;
        gap: 5px;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
    }

    /* Hero Sections */
    .hero h1,
    .archive-hero h1,
    .color-title {
        font-size: 28px !important;
    }

    .hero p,
    .archive-hero p {
        font-size: 15px;
    }

    /* Cards & Containers */
    .card,
    .post-item,
    .page-card {
        border-radius: 12px;
    }

    .content,
    .archive-container {
        padding: 0 16px 40px;
    }

    /* Grids */
    .conv-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .preview-grid,
    .blind-grid,
    .access-grid,
    .scheme-grid {
        grid-template-columns: 1fr !important;
    }

    /* Archive / Blog */
    .post-item {
        grid-template-columns: 1fr !important;
    }

    .post-item-thumb {
        height: 180px !important;
    }

    /* Search Bars */
    .search-bar {
        flex-direction: column;
        gap: 10px;
    }

    .search-bar input,
    .search-input {
        width: 100% !important;
        min-width: 0 !important;
    }

    .search-bar button,
    .search-btn {
        width: 100%;
    }

    /* Tab Navigation */
    .tools-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 12px;
    }

    .tools-tabs::-webkit-scrollbar {
        display: none;
    }

    /* Footer */
    .footer-widgets {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }

    /* Touch-friendly active states */
    .card:active,
    .feature-card:active,
    .faq-item:active {
        transform: scale(0.98);
    }

    .upload-btn:active,
    .color-search-btn:active,
    .search-btn:active,
    .copy-btn:active {
        transform: scale(0.95);
    }

    /* Better touch target for nav links in mobile panel */
    .main-nav a {
        min-height: 44px;
        display: flex !important;
        align-items: center;
    }

    .main-nav a:active {
        background: #fff5f0;
    }
}

/* ── 500px and below: Small Phone ── */
@media (max-width: 500px) {

    /* Header */
    .header-inner {
        padding: 0 12px;
        height: auto;
    }

    .logo {
        font-size: 16px;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    /* Titles & Text */
    .hero h1,
    .archive-hero h1,
    .color-title {
        font-size: 24px !important;
    }

    .hero p,
    .archive-hero p {
        font-size: 14px;
    }

    .card-title {
        font-size: 18px !important;
    }

    /* Grids → single column */
    .conv-grid {
        grid-template-columns: 1fr !important;
    }

    .gradient-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    /* Cards */
    .card {
        padding: 16px !important;
        border-radius: 12px;
    }

    .page-card {
        padding: 16px !important;
    }

    /* Color Info Page */
    .swatch-large {
        width: 140px !important;
        height: 140px !important;
    }

    .color-hex-display {
        font-size: 18px !important;
    }

    .download-btn {
        font-size: 13px !important;
        padding: 10px 18px !important;
    }

    /* Color tabs (Info, Conversions, Schemes etc.) */
    .section-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }

    .section-tabs a,
    .section-tabs button {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Content */
    .content {
        padding: 0 12px 30px;
    }

    .archive-container {
        padding: 0 12px 30px;
    }

    /* Buttons */
    button,
    .btn,
    [type="button"],
    [type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Footer */
    .footer-widgets {
        grid-template-columns: 1fr !important;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    /* Tables */
    .tech-table {
        font-size: 11px;
    }

    .tech-table td {
        padding: 8px 6px;
    }

    .tech-lbl {
        width: 35%;
    }
}

/* ── 375px and below: Very Small Phone ── */
@media (max-width: 375px) {

    .hero h1,
    .archive-hero h1,
    .color-title {
        font-size: 20px !important;
    }

    .conv-item {
        padding: 10px !important;
    }

    .swatch-large {
        width: 120px !important;
        height: 120px !important;
    }
}

/* ── Page-Specific Fixes ── */

/* Color Code Page */
@media (max-width: 768px) {
    .color-input-section {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .color-preview-large {
        height: 120px !important;
    }

    .copy-btn-grid {
        grid-template-columns: 1fr !important;
    }

    .shade-grid,
    .tint-grid,
    .harmony-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

/* Front Page */
@media (max-width: 768px) {
    .tool-card {
        padding: 20px !important;
    }

    .popular-colors-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .feature-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 500px) {
    .popular-colors-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .tool-card {
        padding: 16px !important;
    }

    .tool-card h3 {
        font-size: 16px !important;
    }
}

/* Color Info Page - override duplicate inline header/nav CSS */
@media (max-width: 768px) {

    /* Force nav to hide (overrides page-color-info inline styles) */
    .main-nav {
        display: none !important;
    }

    .main-nav.active {
        display: flex !important;
        transform: translateX(0) !important;
    }

    /* Color hero section */
    .color-hero {
        padding: 20px 16px !important;
    }

    .color-title {
        font-size: 28px !important;
    }

    .color-hex-display {
        font-size: 18px !important;
    }

    /* Share button */
    .share-btn {
        padding: 10px 20px !important;
        font-size: 14px !important;
    }
}

/* Blog / Home Posts */
@media (max-width: 768px) {

    .post-card,
    .blog-post {
        grid-template-columns: 1fr !important;
    }

    .post-excerpt {
        font-size: 14px;
    }

    .read-more {
        font-size: 13px;
    }
}

/* Single Post */
@media (max-width: 500px) {
    .post-content {
        padding: 0 12px !important;
    }

    .post-content h1 {
        font-size: 24px !important;
    }

    .post-content h2 {
        font-size: 20px !important;
    }

    .post-content img {
        border-radius: 8px;
    }
}

/* Blindness Simulator - fix grid on mobile */
@media (max-width: 768px) {
    .sim-grid {
        grid-template-columns: 1fr !important;
    }

    .sim-controls {
        flex-direction: column;
    }
}

/* Contrast Checker - inputs side by side to stacked */
@media (max-width: 768px) {
    .contrast-inputs {
        flex-direction: column !important;
        gap: 16px;
    }

    .contrast-result {
        flex-direction: column;
        text-align: center;
    }
}

/* Gradient Maker */
@media (max-width: 768px) {
    .gradient-controls {
        flex-direction: column !important;
        gap: 12px;
    }

    .gradient-preview {
        height: 150px !important;
    }
}

/* Palette Generator */
@media (max-width: 768px) {
    .palette-colors {
        flex-direction: column !important;
    }

    .palette-color {
        height: 80px !important;
        width: 100% !important;
    }
}