/* DEV-877: touch and narrow-screen layer, loaded last by _Layout, _AuthLayout and _LayoutEmpty.
   Width rules use the Bootstrap breakpoints; touch-only rules sit under (pointer: coarse), so a desktop with a mouse
   keeps today's density. */

/* ── Navigation: the hamburger opens Fillow's overlay sidebar below 1024px ─────────────────────────────────── */
@media (max-width: 1023.98px) {
    .nav-control { display: flex !important; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0; }   /* _sidebar.scss hides it for every width */
}

/* ── Tablets (768-1023): Fillow's "mini" rail cannot work without the icons Animo hides, so it took 238px of a
      768px screen. Hide it like the phone overlay; the hamburger slides it in. ───────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023.98px) {
    [data-sidebar-style="mini"] .dlabnav { left: -100%; width: 17rem; transition: left .2s ease; }
    [data-sidebar-style="mini"] .menu-toggle .dlabnav { left: 0; }
    [data-sidebar-style="mini"] .content-body,
    [data-sidebar-style="mini"] .footer { margin-left: 0; }
    [data-sidebar-style="mini"] .nav-header .nav-control { z-index: 9999; }   /* Fillow mini sends it behind (-1) */
    [data-sidebar-style="mini"] .nav-header .nav-control .hamburger { display: block; left: auto !important; }
}

/* ── Header below 1024px: logo + hamburger in a 9rem block, the account controls fit the rest ─────────────── */
@media (max-width: 1023.98px) {
    [data-sidebar-style] .nav-header { width: 9rem; }
    [data-sidebar-style] .nav-header .brand-logo { overflow: hidden; padding-left: 14px; justify-content: flex-start; }   /* Fillow mini pads 33px: logo touched the hamburger */
    .nav-header .brand-logo img { max-width: 60px; height: auto; }
    .nav-header .nav-control { right: 0; }
    [data-sidebar-style] .header { padding-left: 9rem; }
    [data-sidebar-style] .header .header-content { padding-left: 0; }
}
@media (max-width: 575.98px) {
    #animoUserSegment .ws-name, #animoUserSegment .ws-header-arrow { display: none; }   /* the house icon stays */
}

/* ── DEV-875 phone path pages ─────────────────────────────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    .setup-head { flex-wrap: wrap; padding: 16px; }          /* /status: the "Ready" time drops under the title */
    .setup-head__side { flex: 1 1 100%; padding-top: 0; }
}

/* The closed drill-down drawer waits just off the right edge; its shadow showed as a grey strip on narrow screens. */
.animo-drawer:not(.open) { box-shadow: none; }

/* Header "Getting started" menu is 440px wide (inline style in GettingStarted/Default.cshtml). */
.dropdown-menu.ns-menu { max-width: calc(100vw - 24px); }

/* 100vh runs under the mobile browser bars; dvh is the visible height (browsers without it keep the vh line). */
.drawer { height: 100dvh; }
.billing-paymodal { max-height: calc(100dvh - 48px); }

/* ── iOS zooms into a focused field under 16px ───────────────────────────────────────────────────────────── */
@media (pointer: coarse) {
    /* :is() takes its strongest argument's specificity, so this also beats "!important" rules like the filter bar's 0.8rem */
    :root :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]),
              select, textarea, .form-control, .form-select) { font-size: 16px !important; }
}

/* ── Tap targets: 44px on touch screens ───────────────────────────────────────────────────────────────────── */
@media (pointer: coarse) {
    .btn, .form-select, .as-btn-sm, [role=button] { min-height: 44px; }
    .ds-input { height: 44px; }   /* /Connections search and filters (fixed 36px) */
    .animo-sidebar .sb-item, .animo-sidebar .sb-sub-item { min-height: 44px; }
    /* DEV-877: header icons (Action Center 32px, bell 37px, workspace 36px tall): a transparent layer grows the tap
       area past 44px and the icons look the same. .ac: -8px because the layer starts inside its 1px border; no side
       growth, its two halves touch. */
    .header .ws-trigger { position: relative; }
    .header .ac::after, .header .header-right .nav-link::after, .header .ws-trigger::after { content: ""; position: absolute; inset: -6px -2px; }
    .header .ac::after { inset: -8px 0; }
    /* DEV-873 WI-4: every control in the page body. Page styles fix heights of 24-36px (Tabulator filter and page size,
       Action center, Notifications, Billing, Profile); min-height wins over height. :root lifts these over page rules
       that set their own min-height (.btn.billing-btn 32px in online.css, .mmm-check__act in mmm-setup.css). */
    :root .content-body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]):not([type=file]), select, button),
    :root .content-body :is(.btn-check + label, .ac-btn, .ws2-ico, .billing-btn, .cm-btn, .gr-btn, .ds-platform, .settings-nav__tab, .wss-link, .notif-act,
                      .profile-you__link, .profile-strip-link) { min-height: 44px; }
    .content-body :is(.btn-check + label, .gr-btn, .notif-act, .profile-you__link, .profile-strip-link, .settings-nav__tab) { display: inline-flex; align-items: center; }
    /* checkboxes keep their size; the row and its label take the tap (Compare periods was 15px) */
    .content-body .form-check { display: flex; align-items: center; min-height: 44px; }
    .content-body .form-check .form-check-input { margin-top: 0; }
    .content-body .form-check-label { display: inline-flex; align-items: center; min-height: 44px; padding-left: 6px; }
    /* ponytail: Tabulator's row-select box sits in a 21px header title; 24px is the most it takes without a JS tap on the cell */
    .content-body .tabulator input[type=checkbox] { width: 24px; height: 24px; }
    :root .content-body .mmm-check__act { min-height: 44px !important; }   /* mmm-setup.css pins 32px with !important */
    /* boxes with a fixed height that hold those controls grow with them (the Notifications filter scrolled inside itself) */
    .content-body :is(.notif-segs, .animo-seg) { height: auto; }
    .content-body .ai-code { display: flex; align-items: center; min-height: 52px; }   /* its Copy button sits 4px in, absolutely */
}

/* ── DEV-878 dashboards ───────────────────────────────────────────────────────────────────────────────────── */
/* Grid items default to min-width:auto: a chart canvas drawn at a wider size held its card, and the grid column, wide,
   so cards ran past the screen (CCO at 375, Saturation at 1024). min-width:0 lets each card shrink with its column. */
.animo-chart-card, .oo-card { min-width: 0; }

@media (max-width: 767.98px) {
    .animo-chart-grid { grid-template-columns: minmax(0, 1fr); }      /* CCO: two chart columns become one */
    .provider-breakdown-table { display: block; overflow-x: auto; }    /* the per-platform table scrolls inside itself */
}
@media (max-width: 575.98px) {
    /* KPI strips: two per row on a phone (page styles set 4, 6, 8 or 9). !important beats the inline column count that
       Website Analytics, E-commerce and YouTube write after loading prefs (8 columns at 375). */
    .content-body .animo-kpi-strip.animo-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
/* A canvas Chart.js has not sized yet keeps the 300px default and pushed out of narrow cards. */
.animo-chart-container canvas { max-width: 100%; }
@media (pointer: coarse) {
    /* card corner icons (expand, customise): 25x19 targets on touch */
    .animo-card-cog { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .animo-tip { display: inline-block; min-height: 0; padding: 16px; margin: -16px; }   /* info icons: 44px hit area (12px icon + 2x16), same layout */
}
/* Online filter bar: one summary line on a phone, the controls open under it (_OnlineFilterBar, animo-online-filter.js) */
.afb-summary { display: none; }
@media (max-width: 575.98px) {
    .afb-summary { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 500; color: #1A2035; }
    .afb-summary::-webkit-details-marker { display: none; }
    .afb-summary-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .afb-summary-cta { flex: 0 0 auto; color: #3D4B6B; font-weight: 600; text-decoration: underline; }
    .afb-summary-cta::before { content: "Change"; }
    .afb-details[open] .afb-summary-cta::before { content: "Close"; }
    .afb-details[open] > .row { margin-top: 4px; }
}

/* Online chart with no rows to draw (online-charts.js marks the container); Chart.js charts of zeros get the same
   line from chartDefaults.js. Not a mobile-only rule: the blank card was the same on desktop.
   DEV-873 WI-5: any canvas holder, not only .animo-chart-container: Online campaigns and Website analytics wrap their
   canvases in a plain div, so their empty charts stayed a blank white card. */
[data-empty] { display: flex; align-items: center; justify-content: center; }
[data-empty] > canvas { display: none; }
[data-empty]::after { content: "No data for this period"; font-size: 13px; font-weight: 500; color: #4B5A7A; }
/* DEV-1012: a page that shows its own empty note (Social organic, platform pages) keeps it; the generic line printed over it */
[data-empty]:has(> [class*="chart-empty"][style*="flex"])::after { content: none; }
@media (max-width: 767.98px) {
    /* a phone scrolled past 240px of white per empty chart: an empty chart keeps its title and one line */
    [data-empty] { height: 64px !important; min-height: 0 !important; }
}

/* ── DEV-873 WI-7/9/10 ────────────────────────────────────────────────────────────────────────────────────── */
/* Tabulator's "no rows" text was centred across the table's full width (870px on Campaigns), off a phone screen and
   past the edge of any table wider than its card */
.tabulator .tabulator-tableholder .tabulator-placeholder { width: 100% !important; }
/* An empty table: with a classic 16px scrollbar the "no rows" text wrapped to 2 lines, the taller box dropped the scrollbar,
   the text went back to 1 line, the scrollbar came back... until "Maximum call stack" (Campaigns at ~390px). Nothing to scroll. */
.tabulator .tabulator-tableholder:has(> .tabulator-placeholder) { overflow-y: hidden; }
.animo-phone-title, .cx-jump { display: none; }
@media (max-width: 575.98px) {
    /* the pager: Prev, page, Next and the size (First, Last and the "Page Size" label crowded the row) */
    .tabulator .tabulator-paginator > label, .tabulator .tabulator-page[data-page=first], .tabulator .tabulator-page[data-page=last] { display: none; }
    /* room for the back-to-top button (DEV-934, 44px bottom-right): it covered Next when a table footer met the screen bottom */
    .tabulator .tabulator-footer { padding-right: 52px; }
    /* the page title (_Layout), where the page has no h1 of its own */
    .content-body:not(:has(h1)) .animo-phone-title { display: block; margin: 0 0 12px; font-size: 18px; font-weight: 600; line-height: 24px; color: #1A2035; }
    /* /Connectors: one row of category links over a ~4,900px catalog */
    .cx-jump { display: flex; gap: 8px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
    .cx-jump::-webkit-scrollbar { display: none; }
    .content-body .cx-jump a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--animo-border); border-radius: 22px;
                               background: #FFFFFF; font-size: 13px; font-weight: 500; color: #3D4B6B; text-decoration: none; }
    .connector-category-section { scroll-margin-top: 64px; }
}

/* ── DEV-873 phone polish ─────────────────────────────────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    /* WI-6: settings tabs in one row that scrolls sideways (they wrapped onto two rows); _SettingsNav scrolls the
       active tab into view */
    .settings-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav__tab { flex: none; white-space: nowrap; }
    /* WI-8: nothing under 11px on a phone (filter labels and KPI labels were 9px). :root lifts this over the page
       styles that load after this file. */
    :root .content-body :is(.animo-kpi-label, .adt-count, .ga-goals-badge, .gsc-legend, .geo-src,
                            .so-follower-tile .platform, .so-follower-tile .delta, .oo-section-label, .pb-status, .ws2-table th, .campaign-timeline-grid th,
                            .ws2-mod, .ws2-role, .billing-rung__tag, .ls-form-text,
                            .mgr-section-title, .animo-empty-sub, .media-metric, .effectiveness-badge, .cpt-sticky,
                            .wtd-label, .wtd-comp-note, .wtd-kpi-l, .wtd-act-class, .wtd-chip, .wtd-where, .wtd-th,
                            .bo-conflab, .bo-held-chip) { font-size: 11px; }
    /* the filter bar label is 0.65rem !important (animo-tables.css); the Online campaigns pill counts set 10px inline */
    :root .content-body :is(.filter-label, .ci-pills span) { font-size: 11px !important; }
}

/* /Connections: a shade on the right edge while the table has more to scroll ("local" cover rides with the content
   and hides the shade at the end); the toolbar fills the row on a phone */
@media (max-width: 767.98px) {
    .ds-table-wrap {
        background: linear-gradient(to left, #FFFFFF 30%, rgba(255, 255, 255, 0)) right / 40px 100% no-repeat local,
                    radial-gradient(farthest-side at 100% 50%, rgba(26, 32, 53, .2), transparent) right / 14px 100% no-repeat scroll;
    }
}
@media (max-width: 575.98px) {
    .ds-search { flex: 1 1 100%; max-width: none; }
    .ds-toolbar select.ds-input { flex: 1 1 0; min-width: 0; }
}

@media (max-width: 575.98px) {
    /* DEV-880: info tips centred on an icon near the edge ran off the screen; on a phone the open tip is a card along
       the bottom of the screen. The .intel-tip prefix also beats the corner variant .intel-tip--end (intelligence.css). */
    .intel-tip .intel-tip-bubble { position: fixed; top: auto; left: 16px; right: 16px; bottom: 16px; width: auto; max-width: none; transform: none; z-index: 1060; }
    .intel-tip:hover .intel-tip-bubble, .intel-tip:focus .intel-tip-bubble, .intel-tip:focus-within .intel-tip-bubble { transform: none; }
    .intel-tip-bubble::after { display: none; }
    /* onboarding trail (Account · Business · Goal · Connect) touched the right edge at 375 */
    .as-steps { gap: 4px; font-size: 11px; }
    .as-steps li + li::before { width: 10px; }
}

@media (max-width: 1023.98px) {
    /* open sidebar: dim the page behind it (a spread shadow, no extra element); a tap there closes it (_NavHeader) */
    #main-wrapper.menu-toggle .dlabnav { box-shadow: 0 0 0 100vmax rgba(26, 32, 53, .35); }
    .nav-control .hamburger:focus-visible { outline: 2px solid #3D4B6B; outline-offset: 4px; border-radius: 4px; }
    /* DEV-881: open menu shows an X (Fillow morphs the lines into a right arrow, which reads as "go forward").
       Lines are 3px tall with 6px margins: 9px between centres. */
    .nav-control .hamburger.is-active .line { width: 1.625rem; height: 0.1875rem; }
    .nav-control .hamburger.is-active .line:nth-child(1) { transform: translateY(9px) rotate(45deg); }
    .nav-control .hamburger.is-active .line:nth-child(2) { opacity: 0; }
    .nav-control .hamburger.is-active .line:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
}

/* ── DEV-880: no phone wall. Desktop-best screens show one line at the top (_DesktopNotice, _Layout) ─────── */
.animo-desktop-notice { display: none; }
@media (max-width: 767.98px) {
    .animo-desktop-notice { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 4px 8px 12px; border: 1px solid var(--animo-border); border-radius: 8px; background: #F4F5F7; font-size: 13px; line-height: 18px; color: #3D4B6B; }
    .animo-desktop-notice > span { flex: 1 1 auto; }
    .animo-desktop-notice > button { flex: none; min-width: 44px; min-height: 44px; border: none; background: none; font-size: 20px; color: #4B5A7A; cursor: pointer; }
    .animo-desktop-notice > button:focus-visible { outline: 2px solid #3D4B6B; outline-offset: -2px; border-radius: 4px; }   /* keyboard focus ring (UX review) */
    #notif-tabs { max-width: 100%; overflow-x: auto; }   /* /Notifications filter tabs were 498px wide */
}
@media (max-width: 575.98px) {
    /* WhatToDo: the comparison block kept its content width (431px at 375) once the status row wrapped */
    .wtd-status { padding: 18px 16px; }
    .wtd-comps, .wtd-kpis { flex: 1 1 100%; min-width: 0; }
    #wssMembersTable { display: block; overflow-x: auto; }   /* /settings/members table is 496px wide: it scrolls inside itself */
    /* table card head (title, count, search, export, cog): the tools drop to their own row instead of running past
       the card (GoogleAnalytics: 382px of head in a 300px card) */
    .adt-head { flex-wrap: wrap; }
}
@media (max-width: 767.98px) {
    /* Optimization drilldown: two chart rows set 2 columns inline (Drilldown.cshtml), which beat the page's own
       one-column rule; the second card was cut at 529px on a phone. !important is the only way past an inline style. */
    .dd-chart-grid { grid-template-columns: minmax(0, 1fr) !important; }
    /* DEV-880 simplified drilldown: KPIs, then the campaign grid, then the charts. Six chart cards (240-320px each)
       used to sit above the grid, several screens of scrolling before anything a phone user could tap. */
    .row > .col-12:has(> .dd-chart-grid) { order: 1; }
    #dd-campaigns-dt { margin-bottom: 12px; }
    .animo-drawer-tab { min-height: 44px; }   /* the detail pane's tabs were 35px tall, below a touch target */
}
@media (max-width: 1023.98px) {
    .ws2-table-card.ws2-table-card { overflow-x: auto; }   /* /settings/workspaces table is 1038px wide: it scrolls inside its card (doubled class beats the view's inline overflow:hidden) */
}

/* ── DEV-881 touch alternatives ──────────────────────────────────────────────────────────────────────────── */
/* Action Center "Useful? 👍 👎" showed on hover only; a touch screen has no hover, so show it */
/* action-center.css loads after this file (from the header component), so each selector here needs the extra class to win */
@media (hover: none) {
    .ac-item .ac-fb { display: flex; }
}
@media (pointer: coarse) {
    .ac-fb .ac-fb__btn { width: 44px; height: 44px; }
    .ac-fb .ac-fb__chip { height: 44px; border-radius: 22px; }
}
/* Header Action Center and "Next step" menus hang from their button's right edge, so on a phone they opened past the
   left of the screen (x=-154 at 375). There they span the screen under the 52px header. !important beats main.css
   .navbar-expand .navbar-nav .dropdown-menu { position: absolute }. */
@media (max-width: 767.98px) {
    .dropdown-menu.ac-menu, .dropdown-menu.ns-menu { position: fixed !important; inset: 56px 16px auto; width: auto; max-width: none; margin: 0; }
}
/* prefs drawer: the up/down buttons that replace drag on touch (prefs-drawer.js renders them on coarse pointers) */
.pd-mv { min-width: 44px; min-height: 44px; border: none; background: none; color: #3D4B6B; font-size: 12px; cursor: pointer; }

/* DEV-1006: platform pages - on a phone the conversion picker (266px) pushed the chart title row 90px past the card; the picker takes its own row.
   Kept here, not in Drilldown.cshtml: an escaped media rule in a Razor section ended the section early. */
@media (max-width: 767px) {
    .dd-card h3:has(> .dd-convtype) { flex-wrap: wrap; }
    .dd-card h3 > .dd-convtype { order: 9; flex: 1 1 100%; }
    .dd-card h3:has(> .dd-convtype) > .animo-tip { margin-right: auto; }
}
