/**
 * Mobile Responsiveness Fixes - Phase 14 Front-End Quality Audit
 *
 * PURPOSE: Defensive enhancements for mobile responsiveness
 * SOURCE: .planning/phases/14-frontend-quality-audit/audits/mobile-audit.md
 *
 * AUDIT FINDING: No critical mobile issues found.
 * The site has comprehensive responsive infrastructure via responsive-global.css.
 * This file adds optional defensive enhancements only.
 *
 * @package Skitterskoon
 * @since Phase 14
 * @generated 2026-01-28
 */

/* ==========================================================================
   DEFENSIVE OVERFLOW PREVENTION
   Already handled by responsive-global.css, but reinforced here for safety
   ========================================================================== */

html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Prevent any fixed-width children from causing overflow */
* {
    max-width: 100%;
    box-sizing: border-box;
}

/* Exclude specific elements that need fixed dimensions */
svg,
canvas,
video {
    max-width: none;
}

/* ==========================================================================
   TOUCH ACTION OPTIMIZATION
   Improves scrolling responsiveness on touch devices
   ========================================================================== */

html {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Smoother scrolling on iOS */
body {
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   SAFE AREA INSETS FOR NOTCHED DEVICES
   Supports iPhone X+, modern Android devices with notches/punch-holes
   ========================================================================== */

@supports (padding: env(safe-area-inset-top)) {
    body {
        /* Account for notch and home indicator */
        padding-top: env(safe-area-inset-top);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
    }

    /* Fixed bottom elements need safe area consideration */
    .sk-sticky-cta,
    .sticky-footer,
    .fixed-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Fixed header elements */
    .sticky-header,
    .fixed-top {
        padding-top: env(safe-area-inset-top);
    }
}

/* ==========================================================================
   TOUCH TARGET REINFORCEMENT
   Ensures interactive elements are easily tappable (44x44px minimum)
   ========================================================================== */

@media (max-width: 768px) {
    /* Ensure all interactive elements meet minimum size */
    a,
    button,
    input[type="submit"],
    input[type="button"],
    input[type="reset"],
    .btn,
    .sk-btn,
    .clickable,
    [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Phone links need adequate tap area */
    a[href^="tel:"],
    a[href^="mailto:"] {
        display: inline-block;
        min-height: 44px;
        line-height: 44px;
        padding: 0 12px;
    }

    /* Social media icons */
    .social-links a,
    .social-icon,
    .share-button {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   FORM INPUT MOBILE OPTIMIZATION
   Prevents iOS zoom on input focus (requires 16px+ font-size)
   ========================================================================== */

@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="month"],
    input[type="week"],
    input[type="time"],
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 44px;
    }
}

/* ==========================================================================
   TOUCH FEEDBACK STATES
   Provides visual feedback for touch interactions
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch-only devices */
    .btn:active,
    .sk-btn:active,
    button:active,
    a:active {
        opacity: 0.85;
        transform: scale(0.98);
        transition: opacity 0.1s ease, transform 0.1s ease;
    }

    /* Prevent text selection on tap */
    .btn,
    .sk-btn,
    button,
    [role="button"] {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ==========================================================================
   IMAGE AND MEDIA DEFENSIVE RULES
   ========================================================================== */

/* Ensure all images respect container width */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive embedded content */
iframe,
embed,
object,
video {
    max-width: 100%;
    height: auto;
}

/* Video container for 16:9 aspect ratio */
.video-responsive,
.video-container,
.embed-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-responsive iframe,
.video-responsive video,
.video-container iframe,
.video-container video,
.embed-responsive iframe,
.embed-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   TABLE HORIZONTAL SCROLL
   Makes tables scrollable on mobile without breaking layout
   ========================================================================== */

@media (max-width: 768px) {
    .table-responsive,
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    /* Auto-wrap standalone tables */
    table:not([class]) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
}

/* ==========================================================================
   PRINT MEDIA ADJUSTMENTS
   Ensures printable pages work correctly
   ========================================================================== */

@media print {
    /* Reset max-width restrictions for print */
    * {
        max-width: none !important;
    }

    /* Hide mobile-specific elements when printing */
    .mobile-only,
    .sk-sticky-cta,
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* ==========================================================================
   PREFERS-REDUCED-MOTION SUPPORT
   Accessibility enhancement for users who prefer less motion
   ========================================================================== */

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

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   Windows High Contrast Mode accessibility
   ========================================================================== */

@media (forced-colors: active) {
    .btn,
    .sk-btn,
    button {
        border: 2px solid currentColor;
    }

    a:focus-visible,
    button:focus-visible {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* ==========================================================================
   ORIENTATION CHANGE HANDLING
   Prevents layout issues during device rotation
   ========================================================================== */

@media (orientation: landscape) and (max-height: 500px) {
    /* Reduce vertical padding on landscape mobile */
    .hero-section,
    .hero,
    .banner {
        min-height: auto !important;
        padding-top: 20px;
        padding-bottom: 20px;
    }

    section,
    .section {
        padding-top: 30px;
        padding-bottom: 30px;
    }
}

/* ==========================================================================
   END OF MOBILE FIXES
   ========================================================================== */
