/**
 * Hello Middleton - Mobile Responsive Styles
 * Mobile-first approach with progressive enhancement.
 *
 * Breakpoints:
 * - Base: < 480px (small phones, default)
 * - sm: 480px+ (large phones)
 * - md: 768px+ (tablets) - see tablet.css
 * - lg: 1024px+ (laptops) - see tablet.css
 * - xl: 1280px+ (desktops) - see tablet.css
 *
 * @requires critical/tokens.css
 */

/* =========================================================================
   BASE MOBILE STYLES (< 480px)
   All styles here apply to smallest screens first
   ========================================================================= */

/* --- Viewport & Safe Areas --- */
html {
    /* Support iOS safe areas */
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

body {
    /* Reserve space for mobile bottom nav */
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0));
}

/* --- Typography Adjustments --- */
body {
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4, h5, h6 { font-size: var(--text-base); }

/* --- Layout Resets --- */
.site-content,
.content-area,
main {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
}

/* Single column layout */
.hm-master-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

/* Hide sidebars on mobile */
.sidebar,
.widget-area:not(.footer-widgets) {
    display: none;
}

/* --- Header --- */
.site-header .container {
    padding: 0 var(--space-3);
    min-height: 56px;
}

.site-title {
    font-size: var(--text-lg);
}

.custom-logo,
.site-logo img {
    max-height: 36px;
}

/* Hide desktop navigation */
.main-navigation,
.primary-menu,
#site-navigation {
    display: none;
}

/* --- Cards --- */
.hm-card,
.rss_item,
.activity-item {
    border-radius: var(--radius-md);
}

.hm-card__content,
.rss_item .rss_content {
    padding: var(--space-3);
}

.hm-card__title,
.rss_item .rss_title {
    font-size: var(--text-base);
}

/* --- News Hub / Tabs --- */
.hm-category-tabs,
.news-tabs {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
}

.hm-tab,
.news-tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

/* --- Quick Actions --- */
.hm-quick-actions,
.quick-actions {
    padding: var(--space-2) var(--space-3);
}

.hm-quick-action {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

/* --- Forms - Touch Targets --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    min-height: 48px;
    padding: var(--space-3);
    font-size: 16px; /* Prevents iOS zoom */
}

/* --- Buttons - Touch Targets --- */
.hm-btn,
button,
input[type="submit"],
.button {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
}

/* --- Weather Widget --- */
.weather-bar {
    padding: var(--space-3);
}

.weather-bar-inner {
    flex-direction: column;
    gap: var(--space-2);
    text-align: center;
}

.weather-temp {
    font-size: var(--text-2xl);
}

.weather-details {
    border: none;
    padding: 0;
    justify-content: center;
}

/* --- Events Strip --- */
.upcoming-events-strip {
    gap: var(--space-2);
}

.upcoming-events-strip .event-item {
    padding: var(--space-2);
}

/* --- Footer --- */
.site-footer {
    padding-bottom: calc(var(--mobile-nav-height) + var(--space-4));
}

/* Optionally hide footer on mobile for app-like feel */
.hm-hide-footer-mobile .site-footer {
    display: none;
}

/* --- Touch Optimizations --- */
* {
    -webkit-tap-highlight-color: transparent;
}

a, button, .hm-btn {
    touch-action: manipulation;
}

/* Momentum scrolling */
.hm-category-tabs,
.hm-quick-actions,
.weather-forecast {
    -webkit-overflow-scrolling: touch;
}

/* =========================================================================
   SMALL PHONES (480px+)
   Slightly larger screens, still single column
   ========================================================================= */

@media (min-width: 480px) {
    /* Slightly more padding */
    .site-content,
    .content-area,
    main {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    /* Larger typography */
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }

    /* Two-column card grid */
    .hm-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Weather layout improvement */
    .weather-bar-inner {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Section headers */
    .hm-section-header {
        flex-direction: row;
    }
}

/* =========================================================================
   MOBILE BOTTOM NAVIGATION
   Fixed at bottom, app-like experience
   ========================================================================= */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--hm-bg-elevated);
    border-top: 1px solid var(--hm-border);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: var(--z-fixed);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-1);
    min-width: 56px;
    min-height: 44px;
    font-size: 10px;
    font-weight: var(--font-medium);
    color: var(--hm-text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: color var(--duration-fast) var(--ease-out);
}

.mobile-nav-item.active {
    color: var(--hm-primary);
}

.mobile-nav-icon {
    font-size: 20px;
    line-height: 1;
}

/* Elevated center button */
.mobile-nav-item.nav-post {
    position: relative;
    color: var(--hm-text-inverse);
    background: var(--hm-primary);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-3);
    margin-top: -16px;
    box-shadow: var(--shadow-md);
    min-width: auto;
}

/* =========================================================================
   MOBILE MENU SHEET
   ========================================================================= */

.mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--duration-normal) var(--ease-out),
        visibility var(--duration-normal) var(--ease-out);
    z-index: var(--z-modal-backdrop);
}

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

.mobile-menu-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--hm-bg-elevated);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-xl);
    transform: translateY(100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: var(--z-modal);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-menu-sheet.open {
    transform: translateY(0);
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--hm-border);
}

.mobile-menu-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.mobile-menu-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hm-bg-subtle);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--text-lg);
    cursor: pointer;
}

.mobile-menu-content {
    padding: var(--space-2) var(--space-3);
    overflow-y: auto;
    max-height: calc(70vh - 60px);
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    color: var(--hm-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-out);
}

.mobile-menu-item:active {
    background: var(--hm-bg-subtle);
}

.mobile-menu-icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
}

/* =========================================================================
   LANDSCAPE PHONE ADJUSTMENTS
   ========================================================================= */

@media (max-height: 480px) and (orientation: landscape) {
    /* Reduce bottom nav height */
    .mobile-bottom-nav {
        height: 48px;
    }

    body {
        padding-bottom: 48px;
    }

    /* Reduce menu sheet height */
    .mobile-menu-sheet {
        max-height: 60vh;
    }

    /* Compact header */
    .site-header .container {
        min-height: 48px;
    }
}

/* =========================================================================
   ACCESSIBILITY - Reduced Motion
   ========================================================================= */

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

/* =========================================================================
   DARK MODE PREPARATION (if enabled in future)
   ========================================================================= */

@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode support */
    /* Variables would be overridden here */
}
