/* Phone mode (data-phone="on"): cases. Every rule here is prefixed :root[data-phone="on"] so nothing leaks to desktop. */

/* ── Order: search, chips, backup strip, list ─────────────────────────────────
   The header's inner cluster dissolves (display: contents) so its children can
   be ordered alongside the search row without touching the desktop markup. */
:root[data-phone="on"] .cases-page-container {
    display: flex;
    flex-direction: column;
    /* Room for the floating "+" so the last row is never under it. */
    padding-bottom: 5rem;
}

:root[data-phone="on"] .cases-active-case,
:root[data-phone="on"] .cases-page-title,
:root[data-phone="on"] .cases-scope-toggle {
    display: none;
}

:root[data-phone="on"] .cases-page-container > * { order: 5; }
:root[data-phone="on"] .cases-page-container > .cases-search-row { order: 1; }
:root[data-phone="on"] .cases-page-container > .cases-page-header { order: 2; }
:root[data-phone="on"] .cases-page-container > .cases-date-row { order: 3; }
:root[data-phone="on"] .cases-page-container > .cases-backup-pill-row { order: 4; }

/* ── Search field with the scope flip inside it ─────────────────────────────── */
:root[data-phone="on"] .cases-search-row {
    gap: 0.25rem;
    margin: 0 0 0.6rem;
    padding: 0 0.25rem 0 0.85rem;
    min-height: 2.9rem;
    border: 1px solid var(--ed-hairline-strong);
    border-radius: 999px;
    background: var(--ed-paper-warm);
}

:root[data-phone="on"] .cases-search-row:focus-within {
    border-color: var(--ed-terracotta);
}

:root[data-phone="on"] .cases-search-input {
    min-width: 0;
    border-bottom: none;
    padding: 0.5rem 0;
    font-size: 1rem;
}

:root[data-phone="on"] .cases-scope-flip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    min-height: 2.75rem;
    padding: 0 0.75rem;
    border: none;
    border-left: 1px solid var(--ed-hairline);
    background: transparent;
    font-family: var(--ed-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ed-ink-soft);
}

/* ── Status tabs: one scrolling chip row ────────────────────────────────────── */
:root[data-phone="on"] .cases-page-header {
    display: block;
    margin-bottom: 0.6rem;
}

:root[data-phone="on"] .cases-page-header > div {
    display: block !important;
}

:root[data-phone="on"] .cases-filter-tabs {
    display: flex;
    /* nowrap stated: app.css's <=900px tier sets wrap on this row, and it won. */
    flex-wrap: nowrap;
    gap: 0.45rem;
    padding: 0;
    border-bottom: none;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

:root[data-phone="on"] .cases-filter-tabs::-webkit-scrollbar { display: none; }

/* The shared ink line underlines a tab; chips carry their own active state. */
:root[data-phone="on"] .cases-filter-tabs .fauna-ink-line { display: none; }

:root[data-phone="on"] .cases-filter-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    margin: 0;
    padding: 0 0.85rem;
    border: 1px solid var(--ed-hairline-strong);
    border-radius: 999px;
    font-family: var(--ed-ui);
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    color: var(--ed-ink-soft);
}

:root[data-phone="on"] .cases-filter-tab.active {
    background: var(--ed-ink);
    border-color: var(--ed-ink);
    color: var(--ed-paper);
}

:root[data-phone="on"] .cases-filter-count {
    display: inline-block;
    margin-left: 0.45rem;
    font-family: var(--ed-mono);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}

/* ── Backup: a slim full-width strip ────────────────────────────────────────── */
:root[data-phone="on"] .cases-backup-pill-row {
    display: block;
    margin-bottom: 0.4rem;
}

:root[data-phone="on"] .cases-backup-pill {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 0.85rem;
    border-radius: var(--radius-md, 8px);
    font-size: 0.85rem;
}

:root[data-phone="on"] .cases-backup-pill:not(.cases-backup-pill--warning) {
    min-height: 0;
    padding: 0.15rem 0.2rem;
    border: none;
    background: transparent;
}

/* ── Rows: name / signalment · owner / status + time ────────────────────────── */
:root[data-phone="on"] .cases-grid {
    grid-template-columns: 1fr;
}

:root[data-phone="on"] .cases-day-heading {
    margin-top: 0.9rem;
}

:root[data-phone="on"] .case-card-wrap {
    padding: 0.7rem 3rem 0.7rem 0.75rem;
}

:root[data-phone="on"] .case-card-header {
    justify-content: flex-start;
    margin-bottom: 0.1rem;
}

:root[data-phone="on"] .case-card-working {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--ed-terracotta);
    color: var(--ed-terracotta);
    font-family: var(--ed-body);
    font-size: max(0.72rem, var(--ed-fs-floor, 0rem));
    font-weight: 600;
    line-height: 1.5;
}

/* Signalment and owner share the second line. */
:root[data-phone="on"] .case-card-meta {
    display: inline;
}

:root[data-phone="on"] .case-card-meta + .case-card-meta::before {
    content: " \00B7  ";
}

:root[data-phone="on"] .case-card-recheck,
:root[data-phone="on"] .case-card-creator {
    display: block;
}

:root[data-phone="on"] .case-card-footer {
    margin-top: 0.2rem;
    flex-wrap: wrap;
}

/* Folded away until the row's "more" button opens them. */
:root[data-phone="on"] .case-card-wrap:not(.case-card-wrap--actions) .case-card-addinfo,
:root[data-phone="on"] .case-card-wrap:not(.case-card-wrap--actions) .case-card-archive {
    display: none;
}

:root[data-phone="on"] .case-card-wrap--actions {
    background: var(--ed-paper-deep);
}

:root[data-phone="on"] .case-card-wrap--actions .case-card-footer-left {
    flex: 1 1 100%;
    gap: 0.6rem;
}

:root[data-phone="on"] .case-card-wrap--actions .case-card-addinfo,
:root[data-phone="on"] .case-card-wrap--actions .case-card-archive {
    min-height: 2.75rem;
    padding-inline: 0.9rem;
}

/* Raised above .case-card::after, as the archive pill is, or the tap opens the case. */
:root[data-phone="on"] .case-card-more {
    position: absolute;
    top: 0.2rem;
    right: 0;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--ed-mute);
}

:root[data-phone="on"] .case-card-more[aria-expanded="true"] {
    color: var(--ed-terracotta);
}

/* ── Floating New case ──────────────────────────────────────────────────────── */
:root[data-phone="on"] .cases-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(4.9rem + var(--phone-bar-float) + env(safe-area-inset-bottom));
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: var(--ed-terracotta);
    color: var(--ed-paper);
    font-size: 2rem;
    line-height: 1;
    text-decoration: none;
    /* Glass bubble: a lit top edge over the chestnut fill. */
    box-shadow: inset 0 1px 0 var(--glass-edge), 0 6px 18px color-mix(in srgb, var(--ed-ink) 28%, transparent);
}

:root[data-phone="on"] .cases-fab:active {
    transform: scale(0.96);
}
