/* Mobile Responsiveness Overrides */
/* Include this AFTER template <style> blocks to override defaults */

/* ===== TABLET BREAKPOINT (768px) ===== */
@media (max-width: 768px) {
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Header flex container - use !important to override inline styles.
       Targets .hwrap, which the shared _header.html partial uses on every page.
       This previously read `header .container > div`, which matched only
       district_detail.html back when that was the one page not using .hwrap. */
    header .hwrap {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }

    /* Nav: Wrap links and position below title */
    header nav {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px 16px !important;
        width: 100% !important;
        order: 2 !important;
    }

    /* Stats grid: Smaller minimum */
    .stats-grid,
    .stats-summary {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 12px !important;
    }

    /* Report links: Stack vertically */
    .report-links {
        flex-direction: column !important;
        gap: 12px !important;
    }

    /* Tables: Horizontal scroll wrapper */
    .divisions-table,
    .clubs-table,
    .table-wrapper,
    .assessment-table,
    div[class*="-table"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        display: block !important;
    }

    /* Ensure tables have minimum width for readability */
    table {
        min-width: 500px;
    }

    /* Assessment table specific - fixed layout for mobile */
    table.assessment-table {
        display: table !important;
        table-layout: fixed !important;
        width: 100% !important;
        min-width: auto !important;
        overflow: visible !important;
        font-size: 0.75rem !important;
    }

    table.assessment-table th,
    table.assessment-table td {
        padding: 8px 4px !important;
        font-size: 0.75rem !important;
        vertical-align: top !important;
    }

    /* Goal column - widest */
    table.assessment-table th:first-child,
    table.assessment-table td:first-child {
        width: 30% !important;
        font-size: 0.7rem !important;
        line-height: 1.3 !important;
    }

    /* Actual, Target, Gap, On Track columns - equal narrow widths */
    table.assessment-table th:nth-child(2),
    table.assessment-table td:nth-child(2),
    table.assessment-table th:nth-child(3),
    table.assessment-table td:nth-child(3),
    table.assessment-table th:nth-child(4),
    table.assessment-table td:nth-child(4),
    table.assessment-table th:nth-child(5),
    table.assessment-table td:nth-child(5) {
        width: 17% !important;
        text-align: center !important;
    }

    /* Table scroll wrapper */
    .table-scroll-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Container: Reduce padding, prevent overflow */
    .container {
        padding: 16px !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }

    /* Typography: Scale down */
    h1 {
        font-size: 1.75rem !important;
        word-wrap: break-word;
    }

    .section-title {
        font-size: 1.4rem !important;
    }

    /* Stat cards: Reduce padding */
    .stat-card {
        padding: 16px !important;
    }

    .stat-value {
        font-size: 2rem !important;
    }

    /* Header padding */
    header {
        padding: 20px 0 !important;
        margin-bottom: 20px !important;
    }

    /* Selector container */
    .selector-container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* ===== SMALL MOBILE BREAKPOINT (480px) ===== */
@media (max-width: 480px) {
    /* Nav: Smaller text */
    header nav {
        font-size: 0.9rem !important;
        gap: 6px 12px !important;
    }

    header nav a {
        padding: 4px 0 !important;
    }

    /* Even smaller grid - 2 columns */
    .stats-grid,
    .stats-summary {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Typography: Even smaller */
    h1 {
        font-size: 1.4rem !important;
        line-height: 1.3 !important;
    }

    .subtitle {
        font-size: 0.9rem !important;
    }

    .section-title {
        font-size: 1.25rem !important;
    }

    /* Container: Tighter padding */
    .container {
        padding: 12px !important;
    }

    /* Stat cards: Compact */
    .stat-card {
        padding: 12px !important;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.7rem !important;
    }

    /* Progress bars: Flexible width */
    .progress-bar {
        width: 100% !important;
        max-width: 80px !important;
    }

    /* Breadcrumb: Smaller, wrap */
    .breadcrumb {
        font-size: 0.8rem !important;
        line-height: 1.5 !important;
    }

    /* Table cells: Reduce padding */
    th, td {
        padding: 8px 6px !important;
        font-size: 0.8rem !important;
    }

    /* Badges: Smaller */
    .badge {
        padding: 2px 6px !important;
        font-size: 0.7rem !important;
    }

    /* Assessment table - extra compact at small sizes */
    table.assessment-table th,
    table.assessment-table td {
        padding: 8px 4px !important;
        font-size: 0.7rem !important;
    }

    table.assessment-table td:first-child {
        max-width: 100px !important;
        font-size: 0.65rem !important;
        line-height: 1.3 !important;
    }

    /* Assessment table - tighter at small sizes */
    table.assessment-table th,
    table.assessment-table td {
        padding: 6px 2px !important;
        font-size: 0.65rem !important;
    }

    table.assessment-table td:first-child {
        font-size: 0.6rem !important;
    }

    /* Hide sub-text in goal cells on very small screens */
    table.assessment-table td:first-child div {
        font-size: 0.55rem !important;
        line-height: 1.2 !important;
    }

    /* Go button: Full width */
    .go-button {
        width: 100% !important;
        padding: 14px !important;
    }

    /* Report links: Reduce padding */
    .report-link {
        padding: 14px !important;
    }

    .report-link-title {
        font-size: 1rem !important;
    }

    .report-link-desc {
        font-size: 0.8rem !important;
    }

    /* Goal cards: Stack content */
    .goal-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .goal-number {
        min-width: auto !important;
    }

    /* Info rows: Stack */
    .info-row {
        flex-direction: column !important;
        gap: 4px !important;
    }

    /* View all link: Reduce padding */
    .view-all-link {
        padding: 16px !important;
    }

    .view-all-title {
        font-size: 1.1rem !important;
    }

    /* District selector box */
    .district-selector {
        padding: 14px !important;
    }

    /* Header padding tighter */
    header {
        padding: 16px 0 !important;
    }
}

/* ===== DATE NAVIGATION - MOBILE ===== */
@media (max-width: 768px) {
    .date-nav {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
    }

    .date-nav .nav-link {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }

    .compare-selector {
        margin-left: 0 !important;
        font-size: 0.8rem !important;
    }

    .compare-selector input,
    .compare-selector select {
        font-size: 0.8rem !important;
        padding: 4px 6px !important;
    }
}

@media (max-width: 480px) {
    .date-nav {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    /* Group nav links in a row */
    .date-nav .nav-link {
        font-size: 0.75rem !important;
        padding: 8px !important;
        text-align: center;
    }

    .compare-selector {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
        width: 100% !important;
    }

    .compare-selector input,
    .compare-selector select {
        width: 100% !important;
        padding: 8px !important;
    }
}

/* ===== DAILY REPORT TABLES - MOBILE ===== */
@media (max-width: 768px) {
    /* All section tables - compact fixed layout */
    .section table {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: auto !important;
    }

    /* Club ID column - narrow, it's just numbers */
    .section table th:first-child,
    .section table td:first-child {
        width: 60px !important;
        font-size: 0.7rem !important;
    }

    /* Club name column - flexible, allow wrap */
    .section table th:nth-child(2),
    .section table td:nth-child(2) {
        word-wrap: break-word !important;
        word-break: break-word !important;
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
    }

    /* Status/other columns - compact */
    .section table th:nth-child(n+3),
    .section table td:nth-child(n+3) {
        font-size: 0.7rem !important;
    }

    /* Table headers smaller */
    .section table th {
        padding: 8px 4px !important;
        font-size: 0.65rem !important;
        text-transform: uppercase;
    }

    /* Table cells compact */
    .section table td {
        padding: 8px 4px !important;
    }
}

@media (max-width: 480px) {
    /* Even more compact */
    .section table th:first-child,
    .section table td:first-child {
        width: 50px !important;
        font-size: 0.65rem !important;
    }

    .section table td:nth-child(2) {
        font-size: 0.7rem !important;
    }

    .section table th,
    .section table td {
        padding: 6px 3px !important;
    }
}

/* ===== TOUCH-FRIENDLY ENHANCEMENTS ===== */
@media (pointer: coarse) {
    /* Larger touch targets for links in nav */
    header nav a {
        padding: 8px 4px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Larger touch targets for table rows */
    tbody tr {
        min-height: 48px;
    }

    /* Ensure buttons are easy to tap */
    .go-button,
    button {
        min-height: 44px;
    }

    /* Links in tables */
    .club-link,
    .division-link {
        padding: 4px 0;
        display: inline-block;
    }
}

/* ---- "Updates" nav pill: draws the eye, invites a click ---- */
.nav-updates {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
    animation: updates-pulse 2.4s ease-in-out infinite;
    transition: transform 0.15s ease, filter 0.15s ease;
}
.nav-updates:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
    text-decoration: none;
}
@keyframes updates-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 201, 77, 0.65); }
    50%      { box-shadow: 0 0 0 7px rgba(255, 201, 77, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .nav-updates { animation: none; }
}

/* v2 shared district sub-report nav (_district_nav.html). Colors hardcoded so the
   include is self-sufficient on any page regardless of its :root variables. */
.subtabs { display: flex; flex-wrap: wrap; border: 1px solid #E2E8F0; }
.subtab {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
    font-size: .8rem; font-weight: 700; color: #2C3E50; text-decoration: none;
    border-right: 1px solid #E2E8F0;
}
.subtab:last-child { border-right: 0; }
.subtab svg { width: 15px; height: 15px; stroke: currentcolor; fill: none; stroke-width: 2; }
.subtab:hover { background: #0D7377; color: #fff; }
.subtab.active, .subtab[aria-current="page"] { background: #0D7377; color: #fff; }
.subtabs-bar { margin-bottom: 20px; }
@media (max-width: 560px) {
    .subtab { flex: 1 1 auto; justify-content: center; }
}
