/**
 * Mobile Navigation Optimizations for Vendor Directory
 *
 * This stylesheet provides enhanced mobile UX including:
 * - Smooth flyout menu transitions
 * - Minimum 44px touch targets
 * - Horizontal scrolling category pills
 * - Single-column vendor card stacking
 * - Full-screen modal on mobile
 *
 * @see US-033 in PRD
 */

/* ============================================
   FLYOUT MENU SMOOTH TRANSITIONS
   ============================================ */

/* Ensure flyout backdrop has smooth transition */
.flyout-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.flyout-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* Flyout menu slide-in transition */
.flyout-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    background: var(--surface, #1a1a1a);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-left: 1px solid var(--border-default, #333);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 4px;
}

.flyout-menu.open {
    transform: translateX(0);
}

/* Prevent body scroll when flyout is open */
body.flyout-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Light mode flyout styling */
[data-theme="light"] .flyout-menu {
    background: #ffffff;
    border-left-color: rgba(0, 0, 0, 0.12);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
}

/* ============================================
   MINIMUM 44px TOUCH TARGETS
   ============================================ */

/* Flyout drawer toggles */
.flyout-drawer-toggle {
    min-height: 48px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.flyout-drawer-toggle:active {
    transform: scale(0.98);
    background: rgba(38, 196, 255, 0.15);
}

[data-theme="light"] .flyout-drawer-toggle:active {
    background: rgba(0, 84, 255, 0.12);
}

/* Flyout drawer links */
.flyout-drawer-content a {
    min-height: 44px;
    padding: 12px 16px 12px 20px;
    display: flex;
    align-items: center;
    font-size: 14px;
    text-decoration: none;
    color: var(--text-primary, #fff);
    border-radius: 6px;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.flyout-drawer-content a:hover,
.flyout-drawer-content a:focus {
    background: rgba(38, 196, 255, 0.1);
    color: var(--accent, #26c4ff);
}

.flyout-drawer-content a:active {
    transform: translateX(4px);
    background: rgba(38, 196, 255, 0.18);
}

[data-theme="light"] .flyout-drawer-content a:hover,
[data-theme="light"] .flyout-drawer-content a:focus {
    background: rgba(0, 84, 255, 0.08);
    color: var(--accent, #0054ff);
}

[data-theme="light"] .flyout-drawer-content a:active {
    background: rgba(0, 84, 255, 0.12);
}

/* Flyout close button */
.flyout-close {
    min-height: 48px;
    padding: 14px 16px;
    margin-top: auto;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted, #999);
    border-top: 1px solid var(--border-default, #333);
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.flyout-close:hover,
.flyout-close:focus {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #fff);
}

[data-theme="light"] .flyout-close {
    border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .flyout-close:hover,
[data-theme="light"] .flyout-close:focus {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary, #000);
}

/* Menu hamburger icon */
.menu-icon {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-primary, #fff);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.menu-icon:active {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .menu-icon:active {
    background: rgba(0, 0, 0, 0.1);
}

/* Theme toggle button */
.theme-toggle {
    min-width: 44px;
    min-height: 44px;
}

/* Category navigation pills */
.cat-pill {
    min-height: 36px;
    padding: 8px 14px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Vendor cards - ensure tappable */
.vendor-card {
    min-height: 80px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Featured cards */
.featured-card {
    min-height: 150px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Search input */
.search-input {
    min-height: 48px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-outline,
.back-btn {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Search clear button */
.search-clear {
    min-width: 32px;
    min-height: 32px;
}

/* Filters toggle button */
.filters-toggle {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Clear filters button */
.clear-filters-btn {
    min-height: 36px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Filter checkboxes - ensure tappable label area */
.filter-checkbox {
    min-height: 44px;
    padding: 8px 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Compare checkbox area */
.compare-checkbox {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

/* Comparison bar buttons */
.compare-bar-btn {
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Modal close button */
.modal-close button {
    min-width: 44px;
    min-height: 44px;
}

/* Cross-reference links */
.cross-ref-link {
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ============================================
   CATEGORY PILLS HORIZONTAL SCROLL ON MOBILE
   ============================================ */

@media (max-width: 768px) {
    .cat-nav-inner {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 10px 12px;
        gap: 8px;
        scroll-snap-type: x proximity;
    }

    .cat-nav-inner::-webkit-scrollbar {
        display: none;
    }

    .cat-pill {
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 8px 16px;
        font-size: 13px;
    }

    /* Add horizontal scroll hint shadow on edges */
    .cat-nav {
        position: relative;
    }

    .cat-nav::before,
    .cat-nav::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px;
        z-index: 10;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .cat-nav::before {
        left: 0;
        background: linear-gradient(to right, var(--section-alt, #111) 0%, transparent 100%);
    }

    .cat-nav::after {
        right: 0;
        background: linear-gradient(to left, var(--section-alt, #111) 0%, transparent 100%);
    }

    .cat-nav.scroll-hint-right::after {
        opacity: 1;
    }

    .cat-nav.scroll-hint-left::before {
        opacity: 1;
    }

    [data-theme="light"] .cat-nav::before {
        background: linear-gradient(to right, var(--section-alt, #f1f1f1) 0%, transparent 100%);
    }

    [data-theme="light"] .cat-nav::after {
        background: linear-gradient(to left, var(--section-alt, #f1f1f1) 0%, transparent 100%);
    }
}

/* ============================================
   VENDOR CARDS SINGLE COLUMN ON SMALL SCREENS
   ============================================ */

@media (max-width: 768px) {
    .vendor-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .vendor-card {
        padding: 14px;
    }

    .vendor-card .vendor-icon {
        width: 40px;
        height: 40px;
    }

    .vendor-card .vendor-name {
        font-size: 15px;
    }

    .vendor-card .vendor-desc {
        font-size: 13px;
        -webkit-line-clamp: 3;
    }

    .vendor-card .vendor-tags .tag {
        font-size: 11px;
        padding: 3px 8px;
    }
}

@media (max-width: 480px) {
    .vendor-grid {
        gap: 10px;
    }

    .vendor-card {
        padding: 12px;
        gap: 10px;
    }

    .vendor-card .vendor-icon {
        width: 36px;
        height: 36px;
    }

    .vendor-card .vendor-name {
        font-size: 14px;
    }

    .vendor-card .vendor-desc {
        font-size: 12px;
    }
}

/* ============================================
   MODAL FULL SCREEN ON MOBILE
   ============================================ */

/* Top padding for nav menu clearance (all screen sizes) */
.modal,
.vendor-modal {
    padding-top: 100px !important;
}

@media (max-width: 768px) {
    .modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        border-radius: 0;
        border-left: none;
    }

    .modal-body {
        padding: 0 16px 24px;
    }

    .modal-close {
        padding: 12px 16px 8px;
    }

    .modal-logo {
        max-height: 80px;
    }

    .modal-logo img {
        max-width: 180px;
        max-height: 70px;
    }

    .modal-name {
        font-size: 1.3rem;
    }

    .modal-desc {
        font-size: 14px;
        padding: 14px;
    }

    .modal-caps {
        gap: 6px;
    }

    .modal-cap {
        font-size: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .modal-body {
        padding: 0 12px 20px;
    }

    .modal-logo img {
        max-width: 140px;
        max-height: 60px;
    }

    .modal-name {
        font-size: 1.15rem;
    }

    .modal-domain {
        font-size: 13px;
    }

    .modal-desc {
        font-size: 13px;
        padding: 12px;
    }

    .modal-section-title {
        font-size: 11px;
    }

    .modal-market {
        font-size: 13px;
    }

    .modal-cap {
        font-size: 11px;
        padding: 5px 8px;
    }

    .modal-notable {
        font-size: 13px;
        padding: 12px;
    }
}

/* ============================================
   FEATURED VENDORS GRID MOBILE
   ============================================ */

@media (max-width: 768px) {
    .featured-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .featured-card {
        padding: 14px;
    }

    .featured-card .logo-wrap {
        height: 60px;
    }

    .featured-card .logo-wrap img {
        max-height: 50px;
    }

    .featured-card .vendor-name {
        font-size: 13px;
    }

    .featured-card .vendor-market {
        font-size: 10px;
    }

    .featured-card .notable-badge {
        font-size: 9px;
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    .featured-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .featured-card {
        padding: 10px;
    }

    .featured-card .logo-wrap {
        height: 50px;
        margin-bottom: 8px;
    }

    .featured-card .logo-wrap img {
        max-height: 40px;
    }

    .featured-card .vendor-name {
        font-size: 12px;
    }
}

/* ============================================
   COMPARISON BAR MOBILE
   ============================================ */

@media (max-width: 768px) {
    .compare-bar {
        padding: 12px 16px;
        flex-direction: column;
        gap: 10px;
    }

    .compare-bar-vendors {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .compare-bar-actions {
        width: 100%;
        justify-content: center;
    }

    .compare-chip {
        font-size: 12px;
        padding: 6px 10px;
    }

    .compare-chip img {
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   COMPARISON MODAL MOBILE
   ============================================ */

@media (max-width: 768px) {
    .comparison-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .comparison-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .comparison-table {
        min-width: 600px;
    }

    .comparison-table th,
    .comparison-table td {
        min-width: 150px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .comparison-table .vendor-logo {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   ADVANCED FILTERS MOBILE
   ============================================ */

@media (max-width: 768px) {
    .advanced-filters {
        padding: 0 12px;
    }

    .filters-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .filters-toggle {
        font-size: 13px;
    }

    .filters-panel {
        padding: 16px;
    }

    .filter-group {
        margin-bottom: 20px;
    }

    .filter-group-title {
        font-size: 12px;
        margin-bottom: 10px;
    }

    .filter-checkboxes {
        gap: 4px;
    }

    .filter-checkbox {
        font-size: 13px;
    }

    .filter-select {
        width: 100%;
        min-height: 44px;
        font-size: 14px;
    }
}

/* ============================================
   HEADER MOBILE
   ============================================ */

@media (max-width: 768px) {
    .header {
        padding: 24px 16px 20px;
    }

    .header h1 {
        font-size: 1.4rem;
        padding-right: 50px; /* Space for theme toggle */
    }

    .header p {
        font-size: 14px;
        margin-bottom: 16px;
    }

    .search-wrap {
        max-width: 100%;
    }

    .search-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .search-hints {
        font-size: 12px;
        margin-top: 8px;
    }

    .search-hint-btn {
        font-size: 11px;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 20px 12px 16px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .header p {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* ============================================
   MAIN CONTENT AREA MOBILE
   ============================================ */

@media (max-width: 768px) {
    .main {
        padding: 16px 12px;
    }

    .section-title {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .section-subtitle {
        font-size: 13px;
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 12px 10px;
    }
}

/* ============================================
   LANDSCAPE LEGEND MOBILE
   ============================================ */

@media (max-width: 768px) {
    .landscape-legend {
        padding: 12px;
        gap: 8px 12px;
    }

    .legend-item {
        font-size: 11px;
    }

    .legend-dot {
        width: 8px;
        height: 8px;
    }
}

/* ============================================
   CATEGORY CARD GRID MOBILE
   ============================================ */

@media (max-width: 768px) {
    .cat-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cat-card {
        padding: 14px;
    }

    .cat-card-name {
        font-size: 14px;
    }

    .cat-card-count {
        font-size: 1.3rem;
    }
}

/* ============================================
   SCROLLBAR HIDE ON TOUCH DEVICES
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Hide scrollbars on touch devices for cleaner look */
    .cat-nav-inner::-webkit-scrollbar,
    .comparison-table-wrap::-webkit-scrollbar {
        display: none;
    }

    .cat-nav-inner,
    .comparison-table-wrap {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
}

/* ============================================
   SAFE AREA INSETS (iPhone X+, etc.)
   ============================================ */

@supports (padding: max(0px)) {
    .flyout-menu {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .modal {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .compare-bar {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   FLYOUT DRAWER EXPAND/COLLAPSE
   ============================================ */

.flyout-drawer {
    border-bottom: 1px solid var(--border-default, #333);
}

.flyout-drawer:last-of-type {
    border-bottom: none;
}

.flyout-drawer-toggle {
    background: transparent;
    color: var(--text-primary, #fff);
    font-weight: 600;
    font-size: 14px;
}

.flyout-drawer-toggle .drawer-label {
    flex: 1;
    text-align: left;
}

.flyout-drawer-toggle .drawer-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: var(--text-muted, #999);
}

.flyout-drawer.open .drawer-arrow {
    transform: rotate(90deg);
}

.flyout-drawer-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 8px;
}

.flyout-drawer.open .flyout-drawer-content {
    max-height: 500px;
    padding: 4px 8px 12px;
}

.flyout-section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #666);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px 4px 20px;
    margin-top: 4px;
}

/* Light mode flyout drawer */
[data-theme="light"] .flyout-drawer {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .flyout-drawer-toggle {
    color: var(--text-primary, #000);
}

[data-theme="light"] .flyout-drawer-content a {
    color: var(--text-secondary, #333);
}

[data-theme="light"] .flyout-section-label {
    color: var(--text-muted, #888);
}

/* ============================================
   REDUCED MOTION PREFERENCE
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .flyout-menu,
    .flyout-backdrop,
    .modal,
    .modal-backdrop,
    .vendor-card,
    .featured-card,
    .cat-pill,
    .flyout-drawer-toggle,
    .flyout-drawer-content,
    .flyout-drawer-content a {
        transition: none;
    }

    .flyout-drawer-toggle:active,
    .flyout-drawer-content a:active {
        transform: none;
    }
}

/* ============================================
   MOBILE UI IMPROVEMENTS - APRIL 2026
   Comprehensive mobile responsiveness overhaul
   ============================================ */

/* ============================================
   1. TOUCH TARGET COMPLIANCE (44px minimum)
   ============================================ */

/* Category pills - increase from 36px to 44px */
.cat-pill {
    min-height: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Search clear button - increase from 32px to 44px */
.search-clear,
.index-search-clear {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Landscape cards */
.landscape-card {
    min-height: 100px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Search hint buttons */
.search-hint-btn,
.hint-chip {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 14px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Nav dropdown toggles */
.sn-toggle,
.vd-nav-dropdown-toggle,
.nav-dropdown-toggle {
    min-height: 44px;
    padding: 10px 14px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Modal sector links */
.vendor-modal-sector-link,
.cross-ref-link {
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Back button */
.back-btn {
    min-height: 44px;
    padding: 10px 16px;
    -webkit-tap-highlight-color: transparent;
}

/* Filter checkboxes wrapper */
.filter-checkbox label {
    min-height: 44px;
    padding: 10px 0;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

/* Category cards */
.cat-card {
    min-height: 80px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ============================================
   2. LONG TEXT HANDLING
   ============================================ */

/* Vendor names and titles */
.vendor-name,
.vendor-card .vendor-name,
.featured-card .vendor-name,
.modal-name,
.vendor-modal-name,
.search-item-name,
.cat-card-name,
.landscape-card .card-title {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* Descriptions */
.vendor-desc,
.vendor-card .vendor-desc,
.modal-desc,
.vendor-modal-description,
.card-desc,
.search-item-meta {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Domain names */
.modal-domain a,
.vendor-modal-domain a,
.cross-ref-link {
    word-break: break-all;
    overflow-wrap: anywhere;
}

/* Table cells */
.comparison-table td {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ============================================
   3. HOMEPAGE HERO SECTION OPTIMIZATION
   ============================================ */

@media (max-width: 480px) {
    .index-hero {
        padding: 1.25rem 1rem 1rem;
    }

    .index-hero h1 {
        font-size: clamp(1.1rem, 5vw, 1.3rem);
        margin-bottom: 0.5rem;
        line-height: 1.25;
    }

    .index-hero .hero-desc {
        font-size: 0.85rem;
        line-height: 1.5;
        margin-bottom: 1rem;
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .index-search-wrap {
        max-width: 100%;
    }

    .index-search {
        padding: 0.65rem 2.5rem 0.65rem 2.5rem;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .search-hint {
        font-size: 0.68rem;
        margin-top: 0.4rem;
    }
}

@media (max-width: 375px) {
    .index-hero {
        padding: 1rem 0.75rem 0.75rem;
    }

    .index-hero h1 {
        font-size: 1.05rem;
    }

    .index-hero .hero-desc {
        -webkit-line-clamp: 3;
        font-size: 0.8rem;
    }
}

/* ============================================
   4. LANDSCAPE CARDS GRID SPACING
   ============================================ */

@media (max-width: 768px) {
    .landscape-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }

    .landscape-card {
        padding: 0.85rem;
    }

    .landscape-card .card-title {
        font-size: 0.82rem;
        line-height: 1.25;
    }

    .landscape-card .card-desc {
        font-size: 0.7rem;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 0.4rem;
    }

    .vendor-badge {
        font-size: 0.6rem;
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    .landscape-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    .landscape-card {
        padding: 1rem;
        min-height: auto;
    }

    .landscape-card .card-title {
        font-size: 0.9rem;
    }

    .landscape-card .card-desc {
        font-size: 0.75rem;
        -webkit-line-clamp: 3;
    }

    .domain-group {
        padding: 1rem 0.75rem 0.5rem;
    }

    .domain-group-title {
        font-size: 0.9rem;
        margin-bottom: 0.65rem;
    }
}

@media (max-width: 375px) {
    .landscape-card {
        padding: 0.85rem;
    }
}

/* ============================================
   5. VENDOR CARDS OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    .vendor-card {
        padding: 14px 12px;
        gap: 12px;
        min-height: 90px;
    }

    .vendor-card .vendor-icon {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    .vendor-card .vendor-icon img {
        width: 100%;
        height: 100%;
    }

    .vendor-card .vendor-name {
        font-size: 0.92rem;
        line-height: 1.25;
    }

    .vendor-card .vendor-desc {
        font-size: 0.78rem;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .vendor-card .vendor-tags {
        gap: 4px;
        margin-top: 6px;
    }

    .vendor-card .vendor-tags .tag {
        font-size: 0.65rem;
        padding: 3px 8px;
    }
}

@media (max-width: 480px) {
    .vendor-card {
        padding: 12px 10px;
        gap: 10px;
    }

    .vendor-card .vendor-icon {
        width: 40px;
        height: 40px;
    }

    .vendor-card .vendor-name {
        font-size: 0.88rem;
    }

    .vendor-card .vendor-desc {
        font-size: 0.75rem;
    }
}

@media (max-width: 375px) {
    .vendor-card {
        padding: 10px 8px;
    }

    .vendor-card .vendor-icon {
        width: 36px;
        height: 36px;
    }
}

/* ============================================
   6. CATEGORY PILLS MOBILE REFINEMENT
   ============================================ */

@media (max-width: 768px) {
    .cat-nav-inner {
        padding: 8px 12px;
        gap: 8px;
    }

    .cat-pill {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 0.8rem;
        flex-shrink: 0;
        scroll-snap-align: start;
    }

    .cat-pill .pill-count {
        padding: 2px 6px;
        font-size: 0.65rem;
        margin-left: 5px;
    }
}

@media (max-width: 480px) {
    .cat-nav-inner {
        padding: 6px 10px;
        gap: 6px;
    }

    .cat-pill {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 0.75rem;
    }
}

/* ============================================
   7. STICKY POSITIONING FIX
   ============================================ */

:root {
    --nav-height: 70px;
    --site-nav-height: 32px;
    --sticky-offset: calc(var(--nav-height) + var(--site-nav-height) + 10px);
}

@media (max-width: 768px) {
    :root {
        --nav-height: 58px;
        --site-nav-height: 28px;
        --sticky-offset: calc(var(--nav-height) + var(--site-nav-height));
    }

    .cat-nav {
        position: sticky;
        top: var(--sticky-offset, 86px);
        z-index: 90;
    }

    .vd-nav {
        top: var(--nav-height, 58px);
    }
}

@media (max-width: 480px) {
    :root {
        --nav-height: 54px;
        --site-nav-height: 26px;
    }

    .cat-nav {
        top: var(--sticky-offset, 80px);
    }
}

/* ============================================
   8. MODAL REFINEMENTS
   ============================================ */

@media (max-width: 620px) {
    .modal,
    .vendor-modal {
        max-width: 100%;
        width: 100%;
        border-radius: 0;
        border-left: none;
    }

    .modal-body,
    .vendor-modal-content {
        padding: 1.25rem 1rem 1.5rem;
    }

    .modal-close,
    .vendor-modal-close {
        padding: 0.75rem 1rem 0.5rem;
    }

    .modal-name,
    .vendor-modal-name {
        font-size: 1.25rem;
    }

    .modal-desc,
    .vendor-modal-description {
        font-size: 0.88rem;
        padding: 0.85rem;
    }
}

@media (max-width: 480px) {
    .modal,
    .vendor-modal {
        padding-top: 80px;
    }

    .modal-body,
    .vendor-modal-content {
        padding: 1rem 0.85rem 1.25rem;
    }

    .modal-name,
    .vendor-modal-name {
        font-size: 1.15rem;
    }

    .modal-logo img,
    .vendor-modal-logo {
        max-width: 140px;
        max-height: 60px;
    }

    .modal-caps,
    .vendor-modal-capabilities {
        gap: 0.4rem;
    }

    .modal-cap,
    .vendor-modal-capability {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .modal-section,
    .vendor-modal-section {
        margin-bottom: 1rem;
    }

    .modal-section-title,
    .vendor-modal-section-title {
        font-size: 0.68rem;
        margin-bottom: 0.4rem;
    }
}

@media (max-width: 375px) {
    .modal-body,
    .vendor-modal-content {
        padding: 0.85rem 0.75rem 1rem;
    }
}

/* ============================================
   9. SEARCH DROPDOWN VIEWPORT FIX
   ============================================ */

@media (max-width: 768px) {
    .search-dropdown,
    #searchDropdown {
        position: fixed;
        top: auto;
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
        margin-top: 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .search-dropdown[style*="display: block"],
    #searchDropdown[style*="display: block"] {
        transform: translateY(0);
    }

    .search-section {
        padding: 10px 0;
    }

    .search-item {
        padding: 12px 14px;
        min-height: 48px;
    }

    .search-item-name {
        font-size: 0.92rem;
    }

    .search-item-meta {
        font-size: 0.78rem;
    }

    .search-view-all {
        padding: 14px;
        font-size: 0.88rem;
    }
}

@media (max-width: 480px) {
    .search-dropdown,
    #searchDropdown {
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-height: 55vh;
    }

    .search-item {
        padding: 14px 12px;
    }
}

/* ============================================
   10. TYPOGRAPHY CONSISTENCY
   ============================================ */

/* Hero sections - fluid typography */
.header h1,
.index-hero h1,
.search-hero h1 {
    font-size: clamp(1.15rem, 4vw, 1.5rem);
}

.header p,
.index-hero .hero-desc,
.search-hero .hero-desc {
    font-size: clamp(0.78rem, 2.5vw, 0.95rem);
}

/* Section titles */
.section-title,
.domain-group-title {
    font-size: clamp(0.88rem, 2.5vw, 1.1rem);
}

/* Card titles */
.vendor-card .vendor-name,
.featured-card .vendor-name {
    font-size: clamp(0.82rem, 2vw, 0.92rem);
}

/* Card descriptions */
.vendor-card .vendor-desc {
    font-size: clamp(0.7rem, 1.8vw, 0.8rem);
}

/* Minimum font sizes for accessibility */
@media (max-width: 375px) {
    body {
        font-size: max(14px, 1rem);
    }

    .vendor-card .vendor-desc,
    .search-item-meta,
    .legend-item {
        font-size: max(11px, 0.68rem);
    }
}

/* ============================================
   11. SITE NAVIGATION FIX
   ============================================ */

@media (max-width: 768px) {
    .site-nav {
        padding: 0;
    }

    .site-nav-inner {
        padding: 0.35rem 1rem;
    }

    .sn-menu {
        min-width: 0;
        width: calc(100vw - 1.5rem);
        max-width: 320px;
        left: auto;
        right: 0;
        columns: 1;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sn-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        white-space: normal;
        word-break: break-word;
    }

    .sn-group-title {
        padding: 0.4rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .sn-menu {
        max-width: calc(100vw - 1rem);
        right: 0.5rem;
        left: 0.5rem;
    }

    .site-nav-inner {
        padding: 0.3rem 0.75rem;
    }
}

/* VD Nav dropdown fix */
@media (max-width: 480px) {
    .vd-nav-dropdown-menu {
        min-width: calc(100vw - 2rem);
        max-width: calc(100vw - 1rem);
        left: 0;
        right: auto;
        transform: translateX(-50%);
        margin-left: 50%;
    }
}

/* ============================================
   12. COMPREHENSIVE SAFE AREA INSETS
   ============================================ */

@supports (padding: max(0px)) {
    /* Main content areas */
    .main,
    .results-area,
    .av-main {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    /* Header areas */
    .header,
    .index-hero,
    .search-hero {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .header,
        .index-hero,
        .search-hero {
            padding-left: max(0.75rem, env(safe-area-inset-left));
            padding-right: max(0.75rem, env(safe-area-inset-right));
        }
    }

    /* Footer */
    .footer {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    /* Modal and flyout - already have some coverage, extend it */
    .modal,
    .vendor-modal {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .flyout-menu {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
    }

    /* Comparison bar */
    .compare-bar {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    /* Category navigation */
    .cat-nav-inner {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    /* Domain groups */
    .domain-group {
        padding-left: max(1.25rem, env(safe-area-inset-left));
        padding-right: max(1.25rem, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .domain-group {
            padding-left: max(0.75rem, env(safe-area-inset-left));
            padding-right: max(0.75rem, env(safe-area-inset-right));
        }
    }

    /* Search dropdown safe area */
    @media (max-width: 768px) {
        .search-dropdown,
        #searchDropdown {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
    }
}

/* iOS Safari viewport height fix */
@supports (height: 100dvh) {
    .modal,
    .vendor-modal,
    .flyout-menu {
        height: 100dvh;
    }
}
