/**
 * Pixelary Tools - Mobile & Responsive UI Enhancements
 * Optimized for touch interactions, high density displays, and modern devices
 */

/* ==========================================================================
   1. Tablet Viewports (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    .header-nav {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.1rem;
    }

    .categories-grid,
    .category-tiles-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.1rem;
    }

    .value-props-split-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
}

/* ==========================================================================
   2. Mobile Viewports (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --header-height: 62px;
    }

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

    /* Fixed Header on Mobile */
    .header-container {
        padding: 0 0.85rem;
        gap: 0.75rem;
    }

    .brand-logo-img {
        width: 26px;
        height: 26px;
    }

    .brand-name {
        font-size: 1.12rem;
    }

    .brand-sub {
        font-size: 0.62rem;
    }

    .header-actions {
        gap: 0.45rem;
    }

    /* Hide redundant search button in mobile top header (Search is in bottom nav & drawer) */
    .header-search-btn {
        display: none;
    }

    .theme-toggle-btn {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .mobile-menu-btn {
        width: 36px;
        height: 36px;
        padding: 8px;
    }

    /* Main Content Spacing */
    .main-content {
        padding-top: calc(var(--header-height) + 0.85rem);
        padding-bottom: 5.5rem; /* Room for mobile bottom nav bar */
    }

    /* Hero Section on Mobile */
    .hero-section {
        padding: 1.75rem 0 1.25rem;
    }

    .hero-badge-wrapper {
        margin-bottom: 0.85rem;
    }

    .hero-badge {
        font-size: 0.74rem;
        padding: 0.3rem 0.85rem;
    }

    .hero-title {
        font-size: 1.95rem;
        line-height: 1.2;
        margin-bottom: 0.65rem;
        letter-spacing: -0.02em;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 1.35rem;
        padding: 0 0.25rem;
    }

    /* Hero Omnibar Search Mobile */
    .hero-search-box {
        margin-bottom: 0.85rem;
    }

    .hero-omnibar-wrapper {
        min-height: 50px;
        padding: 0.35rem 0.45rem 0.35rem 0.85rem;
        border-radius: var(--radius-lg);
    }

    .hero-omnibar-icon {
        font-size: 1rem;
        margin-right: 0.65rem;
    }

    .hero-omnibar-input {
        font-size: 0.9rem;
        padding: 0.45rem 0;
    }

    .hero-omnibar-kbd {
        display: none;
    }

    .hero-omnibar-btn {
        padding: 0.55rem 1rem;
        font-size: 0.86rem;
        border-radius: var(--radius-md);
    }

    .hero-quick-chips,
    .hero-quick-tags {
        gap: 0.35rem;
        margin-top: 0.85rem;
    }

    .hero-quick-chip-label,
    .hero-quick-tag-label {
        font-size: 0.75rem;
    }

    .hero-quick-chip,
    .hero-quick-tag {
        padding: 0.25rem 0.65rem;
        font-size: 0.76rem;
    }

    /* Native Sponsor Banner Card Mobile */
    .native-sponsor-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .native-sponsor-desc {
        white-space: normal;
    }

    .native-sponsor-link {
        width: 100%;
        justify-content: center;
    }

    /* Recent Tools Rail Mobile */
    .recent-tool-pill {
        min-width: 200px;
        padding: 0.5rem 0.65rem;
    }

    .recent-tool-icon {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .recent-tool-name {
        font-size: 0.8rem;
    }

    .recent-tool-cat {
        font-size: 0.62rem;
    }

    /* Sections on Mobile */
    .section {
        padding: 1.75rem 0;
    }

    .section-header {
        margin-bottom: 1rem;
        gap: 0.65rem;
    }

    .section-title {
        font-size: 1.35rem;
        letter-spacing: -0.02em;
    }

    .section-desc {
        font-size: 0.82rem;
        line-height: 1.4;
    }

    .section-view-all {
        font-size: 0.78rem;
        padding: 0.3rem 0.75rem;
    }

    /* Mobile Tool Cards: Two (2) Tool Cards per Row */
    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .tool-card {
        padding: 0.85rem 0.75rem;
        border-radius: var(--radius-lg);
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .tool-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.5rem;
        gap: 0.35rem;
    }

    .tool-card-icon-wrapper {
        gap: 0.45rem;
        min-width: 0;
    }

    .tool-card-icon {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
        border-radius: var(--radius-md);
        flex-shrink: 0;
    }

    .tool-card-cat-badge {
        font-size: 0.6rem;
        padding: 0.12rem 0.4rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .tool-card-actions {
        gap: 0.35rem;
    }

    .tool-card-badge {
        font-size: 0.62rem;
        padding: 0.15rem 0.4rem;
    }

    .favorite-btn {
        width: 28px;
        height: 28px;
        font-size: 0.78rem;
        border-radius: var(--radius-sm);
    }

    .tool-card-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .tool-card-title {
        font-size: 0.88rem;
        font-weight: 700;
        line-height: 1.28;
        margin-bottom: 0.25rem;
        letter-spacing: -0.01em;
        word-break: break-word;
    }

    .tool-card-title a {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .tool-card-desc {
        font-size: 0.73rem;
        line-height: 1.35;
        color: var(--text-secondary);
        margin-bottom: 0.55rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .tool-card-footer {
        margin-top: auto;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-subtle);
    }

    .tool-card-stat {
        display: none;
    }

    .tool-card-btn {
        font-size: 0.76rem;
        font-weight: 600;
        width: 100%;
        justify-content: space-between;
    }

    .tool-card-btn i {
        font-size: 0.7rem;
    }

    /* Mobile Category Grid: 2 Columns on Mobile */
    .categories-grid,
    .category-tiles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .category-card,
    .category-tile-card {
        padding: 0.85rem 0.75rem;
        border-radius: var(--radius-lg);
        display: flex;
        flex-direction: column;
        min-width: 0;
        gap: 0.5rem;
    }

    .category-card-header {
        margin-bottom: 0.55rem;
    }

    .category-card-icon,
    .category-tile-icon-box {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
        border-radius: var(--radius-md);
        flex-shrink: 0;
    }

    .category-tile-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
        margin-bottom: 0.25rem;
    }

    .category-card-count,
    .category-tile-count {
        font-size: 0.62rem;
        padding: 0.1rem 0.35rem;
    }

    .category-card-title,
    .category-tile-title {
        font-size: 0.86rem;
        font-weight: 700;
        margin-bottom: 0.2rem;
        word-break: break-word;
    }

    .category-card-desc,
    .category-tile-desc {
        font-size: 0.72rem;
        line-height: 1.35;
        margin-bottom: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .category-tile-arrow {
        display: none;
    }

    /* Two-Column Value Props & Metrics Split Mobile */
    .value-props-split-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .value-props-title {
        font-size: 1.45rem;
    }

    .value-props-desc {
        font-size: 0.86rem;
        margin-bottom: 1.25rem;
    }

    .metrics-showcase-card {
        padding: 1.15rem;
        border-radius: var(--radius-lg);
    }

    .metrics-stats-grid {
        gap: 0.65rem;
    }

    .metric-stat-box {
        padding: 0.75rem;
    }

    .metric-stat-number {
        font-size: 1.2rem;
    }

    /* FAQ Accordion Mobile */
    .faq-accordion-trigger {
        padding: 0.95rem 1rem;
        font-size: 0.88rem;
    }

    .faq-accordion-content {
        padding: 0 1rem 1rem;
        font-size: 0.82rem;
    }

    /* Mobile Bottom Navigation Bar */
    .mobile-bottom-nav {
        display: block;
        height: 62px;
        background: var(--bg-header);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-subtle);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        z-index: 1000;
    }

    .mobile-bottom-item {
        gap: 2px;
        font-size: 0.68rem;
        font-weight: 600;
    }

    .mobile-bottom-item i {
        font-size: 1.15rem;
    }

    .mobile-bottom-search-circle {
        width: 38px;
        height: 38px;
        font-size: 1rem;
        box-shadow: 0 3px 12px rgba(124, 58, 237, 0.45);
    }

    /* Tool Workspace on Mobile */
    .tool-page-header {
        margin-bottom: 1.25rem;
    }

    .tool-header-top {
        gap: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .tool-header-icon {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
        border-radius: var(--radius-md);
    }

    .tool-page-title {
        font-size: 1.45rem;
        line-height: 1.25;
    }

    .tool-page-description {
        font-size: 0.86rem;
        line-height: 1.45;
    }

    .tool-workspace-split {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tool-workspace {
        padding: 1rem;
        border-radius: var(--radius-lg);
        margin-bottom: 1.25rem;
    }

    .tool-textarea {
        min-height: 190px;
        padding: 0.8rem;
        font-size: 0.86rem;
    }

    .tool-actions {
        gap: 0.5rem;
        flex-direction: column;
        align-items: stretch;
    }

    .tool-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 0.7rem 1rem;
    }

    .tool-options-bar {
        padding: 0.6rem 0.75rem;
        gap: 0.55rem;
    }

    .tool-guide-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .tool-guide-section {
        padding: 1.15rem;
        border-radius: var(--radius-lg);
    }

    .seo-content-block {
        padding: 1.15rem;
        border-radius: var(--radius-lg);
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.75rem;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 0.85rem;
    }

    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 4.85rem;
    }

    .toast {
        max-width: 100%;
    }

    .search-modal {
        padding-top: 4vh;
    }
}

/* ==========================================================================
   3. Small Mobile Devices (<= 380px)
   ========================================================================== */
@media (max-width: 380px) {
    .container {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .header-container {
        padding: 0 0.65rem;
    }

    .brand-name {
        font-size: 1.02rem;
    }

    .hero-title {
        font-size: 1.55rem;
    }

    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .tool-card {
        padding: 0.7rem 0.55rem;
    }

    .tool-card-icon {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }

    .tool-card-title {
        font-size: 0.82rem;
    }

    .tool-card-desc {
        font-size: 0.7rem;
    }

    .categories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .category-card {
        padding: 0.7rem 0.55rem;
    }

    .category-card-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .category-card-title {
        font-size: 0.82rem;
    }

    .category-card-desc {
        font-size: 0.7rem;
    }

    .mobile-theme-switches {
        gap: 0.25rem;
    }

    .mobile-theme-switches .theme-select-btn {
        font-size: 0.74rem;
        padding: 0.45rem 0.2rem;
    }
}
