/* ─── Mobile-First Styles for Family Alignment ──────────────────────────── */

/* ─── Bottom Navigation ─────────────────────────────────────────────────── */

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fffff8;
    border-top: 1px solid #ddd;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-items {
    display: flex;
    height: 56px;
}

.mobile-nav-items a,
.mobile-nav-items button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #555;
    font-size: 0.65rem;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'EB Garamond', Georgia, serif;
    padding: 0;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-items a:active,
.mobile-nav-items button:active {
    background: #f0f0f0;
}

.mobile-nav-items .nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.mobile-nav-items .nav-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ─── Slide-up Drawer ───────────────────────────────────────────────────── */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1001;
}

.drawer-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fffff8;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 1rem 1.25rem 2rem;
    z-index: 1002;
    max-height: 70vh;
    overflow-y: auto;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
}

.drawer-handle {
    width: 36px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 0 auto 1rem;
}

.drawer-panel a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.25rem;
    text-decoration: none;
    color: #111;
    font-size: 1rem;
    border-bottom: 1px solid #f0f0f0;
    min-height: 44px;
}

.drawer-panel a:last-child {
    border-bottom: none;
}

.drawer-panel a:hover,
.drawer-panel a:active {
    background: #f5f5f0;
}

.drawer-panel a .drawer-icon {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
}

/* ─── Toast Notifications ───────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: #111;
    color: #fffff8;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
}

/* ─── Responsive Tables → Cards ─────────────────────────────────────────── */

@media (max-width: 600px) {
    /* Show mobile nav, hide desktop nav */
    .mobile-nav {
        display: block;
    }

    .desktop-nav {
        display: none;
    }

    /* Body padding for bottom nav */
    body {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0)) !important;
        max-width: 100% !important;
        font-size: 16px;
    }

    /* Prevent iOS zoom on focus */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Touch target minimums */
    button, .btn, .btn-small,
    a.btn, a.btn-secondary, a.btn-small {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-small {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.85rem !important;
    }

    select {
        min-height: 44px;
        padding: 0.4rem 0.5rem !important;
    }

    /* Responsive tables */
    table.responsive {
        border: 0;
    }

    table.responsive thead {
        display: none;
    }

    table.responsive tr {
        display: block;
        margin-bottom: 0.75rem;
        border-left: 3px solid #ddd;
        padding: 0.5rem 0.75rem;
        background: #fff;
    }

    table.responsive tr.closed {
        border-left-color: #eee;
    }

    table.responsive td {
        display: block;
        border-bottom: none;
        padding: 0.15rem 0;
        text-align: left;
    }

    table.responsive td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #999;
        display: block;
    }

    table.responsive td:first-child::before {
        display: none;
    }

    /* Grid adjustments */
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    .role-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }

    /* Rock items — bigger tap targets */
    .rock-item {
        min-height: 44px;
        padding: 0.5rem 0;
    }

    .rock-item button,
    .rock-item .btn-small {
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 1rem !important;
        padding: 0.3rem 0.5rem !important;
    }

    /* Progress bar touch-friendly range */
    input[type="range"] {
        min-height: 44px;
        width: 100px !important;
    }

    /* Goal cards on mobile */
    .card {
        padding: 0.75rem !important;
    }

    /* Paste textarea full width */
    textarea {
        min-height: 200px;
    }

    /* Full width buttons on mobile */
    .mobile-full-width {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-full-width .btn,
    .mobile-full-width a.btn {
        width: 100%;
        text-align: center;
    }

    /* Steps — stack on mobile */
    .steps {
        flex-direction: column;
    }

    /* Filter buttons wrap nicely */
    .filter-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }

    .filter-bar button {
        min-height: 44px;
    }

    /* Prompt box */
    .prompt-box {
        font-size: 0.75rem;
        max-height: 45vh;
    }

    /* Footer */
    footer {
        text-align: center;
        padding-bottom: 0.5rem;
    }
}

/* ─── Medium screens (tablets) ──────────────────────────────────────────── */

@media (min-width: 601px) and (max-width: 900px) {
    .mobile-nav {
        display: none;
    }

    body {
        max-width: 100%;
        padding: 1.5rem;
    }

    table.responsive td {
        padding: 0.3rem 0.4rem;
        font-size: 0.9rem;
    }
}

/* ─── htmx swap animations ──────────────────────────────────────────────── */

.htmx-swapping {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 0.3s;
}

/* ─── PWA standalone mode ───────────────────────────────────────────────── */

@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top, 0);
    }
}
