/* ============================================================
   Veteran Benefits Directory — Design System v2
   Style: Accessible & Ethical | WCAG AAA
   Fonts: Lexend (headings) + Source Sans 3 (body)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&family=Source+Sans+3:wght@300;400;500;600;700&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
    --color-primary:      #0F172A;   /* Deep navy */
    --color-primary-mid:  #1E293B;   /* Mid navy (secondary nav bg) */
    --color-accent:       #0369A1;   /* Accessible blue */
    --color-accent-hover: #0284C7;   /* Lighter blue for hover */
    --color-patriot:      #DC2626;   /* Patriotic red — subtle only */
    --color-gold:         #D97706;   /* Amber gold — stars only */
    --color-bg:           #F8FAFC;
    --color-card:         #FFFFFF;
    --color-text:         #020617;
    --color-text-light:   #64748B;
    --color-border:       #E2E8F0;
    --color-muted:        #E8ECF1;

    --font-heading: 'Lexend', system-ui, sans-serif;
    --font-body:    'Source Sans 3', system-ui, sans-serif;

    --radius-sm:   6px;
    --radius-md:   12px;
    --radius-lg:   20px;
    --radius-pill: 9999px;

    --shadow-card:  0 2px 8px rgba(0, 0, 0, 0.07);
    --shadow-hover: 0 8px 24px rgba(3, 105, 161, 0.15);

    --transition: 150ms ease-out;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --color-primary:      #0F172A;
    --color-primary-mid:  #1E293B;
    --color-accent:       #38BDF8;
    --color-accent-hover: #7DD3FC;
    --color-bg:           #0F172A;
    --color-card:         #1E293B;
    --color-text:         #F1F5F9;
    --color-text-light:   #94A3B8;
    --color-border:       #334155;
    --color-muted:        #1E293B;
    --shadow-card:        0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-hover:       0 8px 24px rgba(56, 189, 248, 0.15);
}

[data-theme="dark"] body {
    background: var(--color-bg);
    color: var(--color-text);
}

[data-theme="dark"] .card-front,
[data-theme="dark"] .card-back,
[data-theme="dark"] .benefit-card {
    background: var(--color-card);
    border-color: var(--color-border);
}

[data-theme="dark"] .breadcrumb {
    color: var(--color-text-light);
}

[data-theme="dark"] .footer {
    background: #020617;
}

[data-theme="dark"] .home-hero {
    background: linear-gradient(135deg, #020617 0%, #0F172A 100%);
}

[data-theme="dark"] .category-hero {
    background: var(--color-card);
    color: var(--color-text);
}

[data-theme="dark"] .subcategory-btn {
    background: var(--color-card);
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] .subcategory-btn.active {
    background: var(--color-accent);
    color: #0F172A;
    border-color: var(--color-accent);
}

[data-theme="dark"] .sort-select {
    background: var(--color-card);
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] .tips-section {
    background: var(--color-card);
    border-color: var(--color-border);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--color-card) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

/* ===== DARK MODE TOGGLE BUTTON (fixed floating) ===== */
.dark-mode-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary-mid);
    border: 2px solid var(--color-border);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* ===== RESET ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== ACCESSIBILITY: SKIP LINK ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-accent);
    color: white;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    z-index: 9999;
    transition: top var(--transition);
}
.skip-link:focus {
    top: 1rem;
}

/* ===== ACCESSIBILITY: FOCUS RINGS ===== */
:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===== ACCESSIBILITY: REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ===== BASE ===== */
body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* ===== HEADER & NAV ===== */
.header {
    background: var(--color-primary);
    color: white;
    padding: 1rem 1rem 0;
    padding-top: env(safe-area-inset-top);
    text-align: center;
    border-bottom: 3px solid var(--color-patriot);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.75rem;
    color: white;
}

.nav-links {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    padding-bottom: 0;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: background var(--transition), color var(--transition);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.nav-links a.active {
    background: var(--color-accent);
    color: white;
}

/* Secondary nav row (About / FAQ / Contact) */
.nav-secondary {
    background: var(--color-primary-mid);
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 1rem;
    flex-wrap: wrap;
    margin: 0 -1rem;
}

.nav-secondary a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: color var(--transition);
}

.nav-secondary a:hover {
    color: white;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    max-width: 1400px;
    margin: 1.25rem auto 0;
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--color-text-light);
    font-family: var(--font-body);
}

.breadcrumb a {
    color: var(--color-accent);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.container--narrow {
    max-width: 1000px;
}

/* ===== CATEGORY HERO ===== */
.category-hero {
    background: var(--color-card);
    padding: 2rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-card);
    text-align: center;
}

.category-hero h2 {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.category-hero p {
    font-size: 1.1rem;
    color: var(--color-text-light);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ===== SUBCATEGORY FILTER PILLS ===== */
.subcategory-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    background: var(--color-card);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.subcategory-btn {
    padding: 0.5rem 1.1rem;
    background: var(--color-muted);
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    transition: all var(--transition);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.subcategory-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-card);
}

.subcategory-btn.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* ===== SORT CONTROLS ===== */
.sort-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.result-count {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.95rem;
}

.sort-select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--color-text);
    min-height: 44px;
}

.sort-select:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===== BENEFITS GRID ===== */
.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ===== FLIP CARDS ===== */
.benefit-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    perspective: 1000px;
    height: 300px;
}

.benefit-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.benefit-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.card-front {
    background: var(--color-card);
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid var(--color-border);
}

/* Card back: navy → accent blue gradient (replaces old navy → red) */
.card-back {
    background: linear-gradient(145deg, var(--color-primary) 0%, #0F4C81 100%);
    color: white;
    transform: rotateY(180deg);
    overflow-y: auto;
}

/* ===== CARD CONTENT ===== */
.company-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
}

.company-logo {
    width: 80px;
    height: 80px;
    background: var(--color-card);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    overflow: hidden;
    padding: 6px;
}

.company-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.company-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.discount-badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    background: var(--color-accent);
    color: white;
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 700;
    font-family: var(--font-body);
    margin-top: 0.5rem;
    letter-spacing: 0.02em;
}

/* FREE badge keeps patriotic red — it's special */
.discount-badge.free-badge {
    background: var(--color-patriot);
}

.discount-badge.no-discount-badge {
    background: var(--color-muted);
    color: var(--color-text-light);
    font-size: 0.8rem;
}

.subcategory-tag {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.benefit-summary {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 1rem;
}

.benefit-meta {
    font-family: var(--font-body);
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 1rem;
}

.benefit-link {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    background: white;
    color: var(--color-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: auto;
    transition: background var(--transition), transform var(--transition);
}

.benefit-link:hover {
    background: var(--color-muted);
    transform: scale(1.03);
}

/* ===== PORTAL VERIFICATION SYSTEM ===== */

/* --- Portal badge pill (shown on card front) --- */
.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    margin-top: 0.4rem;
    letter-spacing: 0.01em;
    line-height: 1.4;
    white-space: nowrap;
}

/* Free portals (ID.me, SheerID): teal */
.portal-badge--free {
    background: rgba(13, 148, 136, 0.12);
    color: #0d9488;
    border: 1px solid rgba(13, 148, 136, 0.3);
}

/* Paid portals (WeSalute+, GovX+): amber */
.portal-badge--paid {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
    border: 1px solid rgba(217, 119, 6, 0.3);
}

[data-theme="dark"] .portal-badge--free {
    background: rgba(13, 148, 136, 0.2);
    color: #2dd4bf;
    border-color: rgba(13, 148, 136, 0.4);
}

[data-theme="dark"] .portal-badge--paid {
    background: rgba(217, 119, 6, 0.2);
    color: #fbbf24;
    border-color: rgba(217, 119, 6, 0.4);
}

/* --- Portal card left-border colors ---
   Border applied to both .card-front and .card-back so it persists on flip.
*/

/* Free portals (ID.me, SheerID, GovX): teal */
.portal-card--free .card-front,
.portal-card--free .card-back,
.portal-card--freemium .card-front,
.portal-card--freemium .card-back {
    border-left: 4px solid #0d9488;
}

.portal-card--free .card-front,
.portal-card--freemium .card-front {
    background-color: rgba(13, 148, 136, 0.04);
}

/* Paid portals (WeSalute+): amber */
.portal-card--paid .card-front,
.portal-card--paid .card-back {
    border-left: 4px solid #d97706;
}

.portal-card--paid .card-front {
    background-color: rgba(217, 119, 6, 0.05);
}

[data-theme="dark"] .portal-card--free .card-front,
[data-theme="dark"] .portal-card--freemium .card-front {
    background-color: rgba(13, 148, 136, 0.09);
}

[data-theme="dark"] .portal-card--paid .card-front {
    background-color: rgba(217, 119, 6, 0.09);
}

/* --- Last verified date (shown on card back) --- */
.last-verified {
    font-family: var(--font-body);
    font-size: 0.72rem;
    opacity: 0.55;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    letter-spacing: 0.01em;
}

/* --- Portal filter row (second filter row on category pages) --- */
.portal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0 10px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.25rem;
}

/* Portal filter pill buttons — same shape as subcategory-btn but with color accents */
.portal-filter-btn {
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-text-light);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    min-height: 36px;
    display: inline-flex;
    align-items: center;
}

.portal-filter-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* "All" active state: accent blue border + light bg */
.portal-filter-btn.active {
    background: rgba(3, 105, 161, 0.1);
    border-color: var(--color-accent);
    color: var(--color-accent);
    font-weight: 700;
}

/* Free portals (ID.me, SheerID, GovX): teal border, matching card color */
.portal-filter-btn[data-portal="idme"].active,
.portal-filter-btn[data-portal="sheerid"].active,
.portal-filter-btn[data-portal="govx"].active {
    background: rgba(13, 148, 136, 0.12);
    border-color: #0d9488;
    border-width: 2px;
    color: #0d9488;
    font-weight: 700;
}

/* Paid portals (WeSalute+): amber border, matching card color */
.portal-filter-btn[data-portal="wesalute"].active {
    background: rgba(217, 119, 6, 0.12);
    border-color: #d97706;
    border-width: 2px;
    color: #d97706;
    font-weight: 700;
}

/* GovX info button and tooltip */
.portal-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid currentColor;
    background: transparent;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 0;
    margin-left: 4px;
    position: relative;
    vertical-align: middle;
}

.portal-info-btn .portal-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 220px;
    white-space: normal;
    width: 220px;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.portal-info-btn .portal-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
}

.portal-info-btn:hover .portal-tooltip,
.portal-info-btn:focus .portal-tooltip {
    display: block;
}

/* Small label above the portal filter row */
.portal-filters-label {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 8px;
    padding-bottom: 2px;
    width: 100%;
}

[data-theme="dark"] .portal-filter-btn {
    background: var(--color-card);
    color: var(--color-text-light);
    border-color: var(--color-border);
}

/* ===== TIPS SECTION ===== */
.tips-section {
    background: var(--color-card);
    padding: 2rem;
    border-radius: var(--radius-md);
    margin-top: 3rem;
    box-shadow: var(--shadow-card);
}

.tips-section h3 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.tips-section ul {
    list-style: none;
    padding: 0;
}

.tips-section li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    font-family: var(--font-body);
}

.tips-section li:last-child {
    border-bottom: none;
}

.tip-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    line-height: 1.6;
}

/* ===== BANNER ===== */
.banner {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    text-align: center;
}

.banner h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--color-primary);
    color: #94A3B8;
    text-align: center;
    padding: 2.5rem 1rem;
    margin-top: 4rem;
    border-top: 3px solid var(--color-patriot);
    font-family: var(--font-body);
}

.footer a {
    color: white;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer .disclaimer {
    margin-top: 1rem;
    font-size: 0.8rem;
    opacity: 0.65;
    line-height: 1.7;
}

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-block;
    padding: 0.875rem 1.75rem;
    background: var(--color-accent);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    transition: background var(--transition);
    border: none;
    cursor: pointer;
    min-height: 44px;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
}

/* ===== SVG LOGO FALLBACK ===== */
.logo-svg-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
}

.logo-svg-fallback span {
    color: white;
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* ===== HOME PAGE — HERO ===== */
.home-hero {
    background: linear-gradient(160deg, var(--color-primary) 0%, #0C3060 100%);
    color: white;
    padding: 4rem 1rem 3.5rem;
    text-align: center;
}

.home-hero h2 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.home-hero p {
    font-family: var(--font-body);
    font-size: 1.15rem;
    opacity: 0.88;
    margin-bottom: 2rem;
    max-width: 580px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
}

/* ===== HOME PAGE — SEARCH BAR ===== */
.home-search-bar {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.home-search-bar input {
    flex: 1;
    padding: 1rem 1.5rem;
    font-family: var(--font-body);
    font-size: 1rem;
    border: none;
    outline: none;
    color: var(--color-text);
    background: white;
    min-height: 52px;
}

.home-search-bar input:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: -3px;
}

.home-search-bar button {
    padding: 1rem 1.75rem;
    background: var(--color-accent);
    color: white;
    border: none;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
    min-height: 52px;
}

.home-search-bar button:hover {
    background: var(--color-accent-hover);
}

.home-search-bar button:disabled {
    background: var(--color-text-light);
    cursor: not-allowed;
    opacity: 0.7;
}

/* ===== HOME PAGE — STATS BAR ===== */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    background: var(--color-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text);
}

.stat-pill-accent {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: #EFF6FF;
}

/* ===== HOME PAGE — CATEGORY CARDS ===== */
.category-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.category-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 1.75rem 1.25rem;
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    box-shadow: var(--shadow-card);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.category-card-icon {
    font-size: 2.25rem;
    line-height: 1;
}

.category-card-label {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.category-card-count {
    font-family: var(--font-body);
    font-size: 0.825rem;
    color: var(--color-text-light);
    font-weight: 500;
}

/* ===== HOME PAGE — SEARCH RESULTS ===== */
.search-results-section {
    display: none;
    margin-bottom: 2rem;
}

.search-results-section.visible {
    display: block;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-results-header h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-primary);
}

.search-clear-btn {
    background: none;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-text-light);
    transition: border-color var(--transition), color var(--transition);
    min-height: 44px;
}

.search-clear-btn:hover {
    border-color: var(--color-patriot);
    color: var(--color-patriot);
}

/* ===== FAQ PAGE STYLES (moved from faq.html inline) ===== */
.page-title {
    text-align: center;
    margin-bottom: 3rem;
}

.page-title h2 {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.page-title p {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--color-text-light);
    line-height: 1.7;
}

.search-faq {
    width: 100%;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-card);
    transition: border-color var(--transition);
    min-height: 48px;
}

.search-faq:focus-visible {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}

.faq-categories {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.category-tag {
    padding: 0.5rem 1.1rem;
    background: var(--color-muted);
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    transition: all var(--transition);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.category-tag:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-card);
}

.category-tag.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.faq-list {
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.faq-item {
    border-bottom: 1px solid var(--color-border);
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    padding: 1.25rem 1.5rem;
    background: var(--color-card);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition);
    min-height: 60px;
}

.faq-question:hover {
    background: var(--color-bg);
}

.faq-question h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    flex: 1;
    margin-right: 1rem;
    letter-spacing: -0.01em;
}

.faq-icon {
    font-size: 1.3rem;
    color: var(--color-accent);
    transition: transform 0.25s ease-out;
    flex-shrink: 0;
}

.faq-item.active .faq-icon {
    transform: rotate(180deg);
}

/* Active FAQ item: accent left border */
.faq-item.active .faq-question {
    border-left: 3px solid var(--color-accent);
    padding-left: calc(1.5rem - 3px);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.faq-item.active .faq-answer {
    max-height: 600px;
}

.faq-answer-content {
    padding: 0 1.5rem 1.5rem 1.5rem;
    font-family: var(--font-body);
    color: var(--color-text-light);
    line-height: 1.8;
    font-size: 0.975rem;
}

.faq-answer-content a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
}

.faq-answer-content a:hover {
    text-decoration: underline;
}

.faq-answer-content ul {
    margin: 0.875rem 0 0.875rem 1.5rem;
}

.faq-answer-content li {
    margin-bottom: 0.5rem;
}

/* FAQ help/contact section */
.help-section {
    background: var(--color-card);
    padding: 2rem;
    border-radius: var(--radius-md);
    margin-top: 3rem;
    text-align: center;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}

.help-section h3 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.help-section p {
    font-family: var(--font-body);
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .nav-links a {
        font-size: 0.875rem;
        padding: 0.5rem 0.6rem;
    }

    .category-hero h2,
    .page-title h2 {
        font-size: 1.75rem;
    }

    .home-hero h2 {
        font-size: 2rem;
    }

    .home-hero p {
        font-size: 1rem;
    }

    .home-search-bar {
        flex-direction: column;
        border-radius: var(--radius-sm);
    }

    .home-search-bar input,
    .home-search-bar button {
        border-radius: 0;
        width: 100%;
    }

    .category-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .benefits-grid {
        grid-template-columns: 1fr;
    }

    .sort-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .category-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stats-bar {
        gap: 0.5rem;
    }

    .stat-pill {
        font-size: 0.825rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (min-width: 1024px) {
    .header {
        padding: 1rem 2rem 0;
        text-align: left;
        display: flex;
        align-items: stretch;
        flex-direction: column;
    }

    .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        max-width: 1400px;
        margin: 0 auto;
        padding-bottom: 0;
    }

    .nav-links {
        justify-content: center;
        gap: 0.1rem;
    }

    .nav-secondary {
        justify-content: center;
        max-width: 1400px;
        margin: 0 auto;
        width: 100%;
        padding: 0;
    }
}

/* ============================================================
   MOBILE APP SHELL — Bottom Tab Bar + Overlays
   Shown only on screens < 768px (phone-sized)
   ============================================================ */

/* Hide desktop nav on mobile, keep slim title bar */
@media (max-width: 767px) {
    .nav-links,
    .nav-secondary { display: none; }

    .header {
        padding: 0.75rem 1rem;
        text-align: center;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .header h1 { font-size: 1.1rem; margin-bottom: 0; }

    /* Push page content above the tab bar */
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

    /* Move dark mode toggle so it doesn't clash with tab bar */
    .dark-mode-toggle {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* When the A-Z index bar is visible, shift the toggle left so it doesn't overlap */
    body.has-alpha-bar .dark-mode-toggle {
        right: calc(2px + 32px + 8px); /* 2px bar offset + 28px bar width + 8px gap */
    }
}

/* ===== BOTTOM TAB BAR ===== */
.bottom-tab-bar {
    display: none; /* desktop: hidden */
}

@media (max-width: 767px) {
    .bottom-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--color-primary);
        border-top: 1px solid var(--color-border);
        z-index: 996;
        justify-content: space-around;
        align-items: stretch;
    }
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    padding: 0.5rem 0;
    font-family: var(--font-body);
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.tab-item.active,
.tab-item:hover {
    color: var(--color-accent-hover);
}

.tab-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.tab-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== MOBILE OVERLAYS (bottom sheets) ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1002;
    background: rgba(0, 0, 0, 0.55);
    align-items: flex-end;
}

.mobile-overlay.open {
    display: flex;
}

.overlay-sheet {
    background: var(--color-card);
    border-radius: 20px 20px 0 0;
    padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-height: 82vh;
    overflow-y: auto;
    animation: sheetSlideUp 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.overlay-handle {
    width: 36px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 0 auto 1rem;
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.overlay-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
}

.overlay-close {
    background: var(--color-muted);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

/* Browse overlay — 2-col category grid */
.category-grid-mobile {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.category-card-mobile {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.1rem 0.75rem;
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    transition: background var(--transition), transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.category-card-mobile:active { transform: scale(0.96); background: var(--color-muted); }
.cat-icon  { font-size: 1.6rem; line-height: 1; }
.cat-name  { font-size: 0.82rem; font-weight: 700; color: var(--color-text); }
.cat-count { font-size: 0.68rem; color: var(--color-text-light); }

/* Search overlay */
.search-overlay-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}

.search-overlay-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.search-go-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    margin-bottom: 0.75rem;
}

.search-hint {
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.82rem;
    font-family: var(--font-body);
}

/* More overlay */
.more-links {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.more-link-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    font-weight: 500;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.more-link-item:active { background: var(--color-muted); }
.more-link-icon { font-size: 1.2rem; }

/* ============================================================
   ALPHA SCROLL — Alphabetical section headers + A-Z index bar
   Used on large category pages (Shopping, etc.)
   ============================================================ */

/* Grid switches from CSS grid to block when alpha mode is active */
.benefits-grid.alpha-mode {
    display: block;
}

.alpha-section {
    margin-bottom: 0.5rem;
}

/* Sticky letter header — stays visible as user scrolls through a section */
.alpha-header {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-accent);
    padding: 0.5rem 0 0.375rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--color-accent);
    position: sticky;
    top: 140px; /* below sticky site header (~140px on desktop) */
    background: var(--color-bg);
    z-index: 10;
}

/* Cards within each letter section use the same grid as .benefits-grid */
.alpha-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

/* ===== A-Z INDEX BAR (fixed right strip) ===== */
.alpha-index-bar {
    position: fixed;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200; /* above content, below header/overlays */
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 5px 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.alpha-index-bar::-webkit-scrollbar { display: none; }

.alpha-index-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--color-accent);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
    transition: background var(--transition), color var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
    user-select: none;
}

.alpha-index-letter:hover {
    background: var(--color-muted);
    color: var(--color-text);
}

.alpha-index-letter.active {
    background: var(--color-accent);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
}

/* Discount-band mode: widen bar and buttons to fit multi-character labels like "MIL PRICE" */
.alpha-index-bar.discount-mode {
    right: 4px;
    padding: 5px 2px;
}
.alpha-index-bar.discount-mode .alpha-index-letter {
    width: 52px;
    height: 18px;
    font-size: 9px;
    letter-spacing: 0.01em;
    padding: 0 2px;
}
.alpha-index-bar.discount-mode .alpha-index-letter.active {
    border-radius: 4px; /* pill shape doesn't work for wide labels — use rounded rect */
    width: 52px;
    height: 18px;
}

[data-theme="dark"] .alpha-index-bar {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

@media (max-width: 767px) {
    /* On mobile: anchor to bottom above the tab bar */
    .alpha-index-bar {
        right: 2px;
        top: auto;
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        transform: none;
        max-height: calc(100svh - 140px - env(safe-area-inset-bottom, 0px));
    }

    /* Mobile header is shorter — adjust sticky offset */
    .alpha-header {
        top: 54px;
    }

    /* Single column on phones */
    .alpha-cards {
        grid-template-columns: 1fr;
    }
}
