/* ============================================
   HSB CUSTOM MOBILE MENU SYSTEM
   Home State Bank of Minnesota
   Created: November 2025

   Modern, accessible mobile menu replacement for SlickNav
   Database-driven structure from field table
   Uses CSS variables from site-theme.css
   ============================================ */

/* ============================================
   MOBILE MENU BUTTON (HAMBURGER)
   ============================================ */

.mobile-menu-btn {
    display: none; /* Hidden by default, shown at mobile breakpoint */
    position: fixed;
    top: 10px;
    right: 10px;
    width: 48px;
    height: 48px;
    background: var(--hsb-blue-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    z-index: 100;
    padding: 0;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mobile-menu-btn:hover,
.mobile-menu-btn:focus {
    background: var(--hsb-blue-dark);
}

.mobile-menu-btn:focus-visible {
    outline: 2px solid var(--hsb-gold);
    outline-offset: 2px;
}

/* Hamburger Icon */
.hamburger-icon {
    display: block;
    position: relative;
    width: 24px;
    height: 18px;
    margin: 0 auto;
}

.hamburger-bar {
    display: block;
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--hsb-white);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-bar:nth-child(1) {
    top: 0;
}

.hamburger-bar:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.hamburger-bar:nth-child(3) {
    bottom: 0;
}

/* Hamburger Animation to X when active */
.mobile-menu-btn.active .hamburger-bar:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.mobile-menu-btn.active .hamburger-bar:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active .hamburger-bar:nth-child(3) {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

/* Menu Label (optional text) */
.menu-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   MOBILE MENU OVERLAY (BACKDROP)
   ============================================ */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MOBILE MENU PANEL
   ============================================ */

.mobile-menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 350px;
    height: 100%;
    background: var(--hsb-white);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-menu-panel.active {
    transform: translateX(0);
}

/* ============================================
   MOBILE MENU HEADER
   ============================================ */

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--hsb-grey-light);
    border-bottom: 2px solid var(--hsb-gold);
}

.mobile-menu-header h2 {
    font-family: var(--hsb-font-primary);
    font-size: 18px;
    color: var(--hsb-blue-primary);
    text-transform: uppercase;
    margin: 0;
    font-weight: bold;
}

.mobile-menu-close {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    border-radius: 4px;
}

.mobile-menu-close:hover,
.mobile-menu-close:focus {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-menu-close:focus-visible {
    outline: 2px solid var(--hsb-gold);
    outline-offset: 2px;
}

.close-icon {
    font-size: 32px;
    line-height: 1;
    color: var(--hsb-grey);
    font-weight: 300;
}

/* ============================================
   MOBILE MENU CONTENT
   ============================================ */

.mobile-menu-content {
    padding: 0;
}

/* ============================================
   MOBILE MENU ITEMS
   ============================================ */

.mobile-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-menu > li {
    border-bottom: 1px solid var(--hsb-grey-light);
}

.mobile-menu > li:last-child {
    border-bottom: none;
}

/* Menu Item Links */
.mobile-menu a {
    display: block;
    padding: 14px 20px;
    font-family: var(--hsb-font-regular);
    font-size: 16px;
    color: var(--hsb-grey);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.mobile-menu a:hover,
.mobile-menu a:focus {
    background: var(--hsb-grey-light);
    color: var(--hsb-blue-primary);
}

.mobile-menu a:focus-visible {
    outline: 2px solid var(--hsb-gold);
    outline-offset: -2px;
}

/* Active Page Indicator */
.mobile-menu li.active > a {
    background: var(--hsb-blue-primary);
    color: var(--hsb-white);
    font-weight: bold;
}

/* ============================================
   PARENT ITEMS (WITH CHILDREN)
   ============================================ */

.mobile-menu-parent {
    position: relative;
}

.mobile-menu-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.mobile-menu-item-header > a {
    flex: 1;
    padding-right: 50px; /* Make room for toggle button */
}

/* Toggle Button */
.mobile-menu-toggle {
    position: absolute;
    right: 0;
    top: 0;
    width: 50px;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-menu-toggle:focus-visible {
    outline: 2px solid var(--hsb-gold);
    outline-offset: -2px;
}

/* Toggle Icon (Chevron) */
.toggle-icon {
    display: inline-block;
    font-size: 24px;
    line-height: 1;
    color: var(--hsb-grey);
    transition: transform 0.3s ease;
    transform: rotate(90deg); /* Points right */
}

.mobile-menu-parent.open .toggle-icon {
    transform: rotate(270deg); /* Points down */
}

/* ============================================
   CHILDREN (NESTED ITEMS)
   ============================================ */

.mobile-menu-children {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--hsb-grey-light);
    display: none;
}

.mobile-menu-parent.open > .mobile-menu-children {
    display: block;
}

.mobile-menu-children li {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.mobile-menu-children li:first-child {
    border-top: none;
}

.mobile-menu-children a {
    padding: 12px 20px 12px 40px; /* Indent for visual hierarchy */
    font-size: 15px;
    color: var(--hsb-grey-dark);
}

.mobile-menu-children a:hover,
.mobile-menu-children a:focus {
    background: rgba(0, 0, 0, 0.05);
    color: var(--hsb-blue-primary);
}

/* Nested Children (Third Level) */
.mobile-menu-children .mobile-menu-children a {
    padding-left: 60px; /* Further indent */
    font-size: 14px;
}

/* ============================================
   BODY SCROLL LOCK
   ============================================ */

body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Mobile menu button visibility controlled by PHP in menu.php */
/* Uses $mobile_menu_width['s_value'] database setting for breakpoint */
/* Header adjustments also controlled by PHP for responsive layout */

/* Adjustments for very small screens */
@media (max-width: 360px) {
    .mobile-menu-panel {
        width: 90%;
        max-width: none;
    }

    .mobile-menu a {
        font-size: 15px;
        padding: 12px 16px;
    }

    .mobile-menu-children a {
        padding: 10px 16px 10px 32px;
        font-size: 14px;
    }
}

/* ============================================
   ACCESSIBILITY - FOCUS STATES
   ============================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-menu-panel {
        border: 2px solid currentColor;
    }

    .mobile-menu a:focus,
    .mobile-menu-toggle:focus,
    .mobile-menu-btn:focus {
        outline: 3px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mobile-menu-panel,
    .mobile-menu-overlay,
    .mobile-menu-toggle,
    .hamburger-bar,
    .toggle-icon {
        transition: none !important;
        animation: none !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .mobile-menu-btn,
    .mobile-menu-overlay,
    .mobile-menu-panel {
        display: none !important;
    }
}
