/*
   Shared responsive rules. Breakpoints (keep in sync with wwwroot/js/viewport.js):
     Mobile  : max-width 639.98px
     Tablet  : 640px+ that is not Desktop (includes large touch-only screens)
     Desktop : min-width 1024px with a fine pointer

   Components render only one layout once ViewportState reports; these media rules are
   the fallback for the brief window before the first report.
*/

.grid-desktop {
    display: block;
}

.grid-mobile {
    display: none;
}

@media not ((min-width: 1024px) and (pointer: fine)) {
    .grid-desktop {
        display: none;
    }

    .grid-mobile {
        display: block;
    }
}

/* Card lists size their columns from their own width, not the viewport. */
.grid-mobile {
    container-type: inline-size;
    container-name: card-list;
}

.card-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    align-content: start;
}

.card-list > .mobile-card {
    margin-bottom: 0 !important;
}

/* Virtualize spacers and empty states must span the whole row. */
.card-list > :not(.mobile-card) {
    grid-column: 1 / -1;
}

@container card-list (min-width: 600px) {
    .card-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container card-list (min-width: 1100px) {
    .card-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Card toolbar: sort selector shown above card lists. */
.card-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0 0.75rem;
}

.card-toolbar label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin: 0;
}

.card-toolbar select {
    min-height: 44px;
    width: auto;
    flex: 1 1 10rem;
    max-width: 18rem;
}

/* Comfortable touch targets on cards. */
.grid-mobile .btn,
.grid-mobile select {
    min-height: 44px;
    min-width: 44px;
}

/* Tap-to-tag picker on cards. */
.card-tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0;
}

.card-tag-picker .card-tag-option {
    min-height: 44px;
    border: 1px solid rgba(139, 94, 52, 0.45);
    border-radius: 999px;
    background: #fff;
    color: #5c3d1f;
    padding: 0.25rem 0.85rem;
}

.card-tag-picker .card-tag-empty {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Full-screen dialogs on phones. */
@media (max-width: 639.98px) {
    .modal-dialog {
        margin: 0;
        max-width: none;
        width: 100%;
        min-height: 100dvh;
    }

    .modal-content {
        min-height: 100dvh;
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .e-dialog.e-popup {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100dvh !important;
        left: 0 !important;
        border-radius: 0;
    }
}
