/* AriaConnectAI — App experience on phones and small tablets (Gate 1).
   Same information architecture, agent identity, Interpreter states,
   notifications and settings model as desktop; only the layout changes:
   a top bar with alerts and language, a five-tab bar (Home, Agents,
   Interpret, Conversations, Settings), single-column screens, and a
   full-height live stage for the Interpreter. No admin complexity here.
   Loaded after styles.css and interpreter.css. */

@media (max-width: 960px) {
  .app { flex-direction: column; }
  .main { width: 100%; }
  .sidebar { display: none; }
  .topbar { display: none; }

  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between; height: 58px;
    padding: 0 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 60;
    background: rgba(11,15,25,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .mobile-topbar .brand { padding: 0; }
  .mobile-topbar .brand img { width: 26px; }
  .mobile-topbar .brand .wordmark { font-size: .95rem; }
  .mobile-topbar-right { display: flex; align-items: center; gap: .5rem; }
  .mobile-topbar .icon-btn { width: 36px; height: 36px; }

  .route-outlet { padding: 1.1rem 1rem calc(var(--tab-h) + var(--safe-b) + 1.6rem); }
  .page-title { font-size: 1.35rem; }
  .page-head { margin-bottom: 1.1rem; }

  /* Tab bar with the Interpret orb in the middle */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: rgba(15,20,33,.96); border-top: 1px solid var(--border); z-index: 300;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; font-size: .62rem; color: var(--text-2); font-weight: 600; min-width: 0; }
  .tabbar button .ic { width: 22px; height: 22px; flex-basis: 22px; }
  .tabbar button.active { color: #fff; }
  .tabbar button.active .ic { color: var(--blue-400); }
  .tabbar .tab-orb { position: relative; }
  .tab-orb-ball.aria-orb { --size: 46px; margin-top: -24px; box-shadow: 0 8px 22px rgba(37,99,235,.45), 0 0 0 4px var(--navy-950); }
  .tabbar .tab-orb.active { color: var(--cyan-400); }

  /* Home */
  .home-hero { grid-template-columns: 1fr; gap: .9rem; }
  .hero-card { min-height: 0; padding: 1.25rem; }
  .hero-card h2 { font-size: 1.12rem; max-width: 18ch; }
  .hero-card p { max-width: 28ch; font-size: .82rem; }
  .hero-card .hero-orb { --size: 92px; right: 1rem; }
  /* G1-QA-12: swipe strips stay inside the page box (no negative side
     margins, never wider than 100%), so the page itself never scrolls
     sideways at any gutter width; only the strip scrolls. */
  .quick-actions { display: flex; overflow-x: auto; gap: .6rem; scroll-snap-type: x mandatory; max-width: 100%; margin: 0 0 1.2rem; padding: 0 0 .2rem; scrollbar-width: none; }
  .quick-actions::-webkit-scrollbar { display: none; }
  .quick-actions .qa { flex: 0 0 auto; min-width: 168px; scroll-snap-align: start; }
  .today-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .conv-detail-grid { grid-template-columns: minmax(0, 1fr); }

  /* Agents / Studio */
  .grid-cards { grid-template-columns: 1fr; }
  .studio-head { gap: .8rem; }
  .studio-head h1 { font-size: 1.25rem; }
  .studio-head .page-actions { width: 100%; }
  .studio-head .page-actions .btn { flex: 1; }
  .flow { display: flex; overflow-x: auto; gap: .5rem; max-width: 100%; margin: 0; padding: 0 0 .3rem; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .flow::-webkit-scrollbar { display: none; }
  .flow-step { flex: 0 0 142px; scroll-snap-align: start; }
  .studio-layout { grid-template-columns: minmax(0, 1fr); gap: .8rem; }
  /* The sticky rail also stays inside the page box; its background reaches
     the screen edges through a clipped box-shadow, which is paint only and
     never adds scrollable width. */
  .studio-rail { position: sticky; top: 58px; z-index: 20; flex-direction: row; overflow-x: auto; gap: .35rem; max-width: 100%; margin: 0; padding: .55rem 0; background: rgba(11,15,25,.92); box-shadow: 0 0 0 100vmax rgba(11,15,25,.92); clip-path: inset(0 -100vmax); scrollbar-width: none; }
  .studio-rail::-webkit-scrollbar { display: none; }
  .studio-rail a { flex: 0 0 auto; border: 1px solid var(--border-2); border-radius: var(--radius-pill); padding: .35rem .7rem; font-size: .76rem; gap: .4rem; }
  .studio-section { scroll-margin-top: 120px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
  .kv dt { font-size: .74rem; margin-top: .55rem; }
  .template-grid { grid-template-columns: 1fr; }

  /* Conversations */
  .row-item { padding: .75rem .2rem; gap: .7rem; }
  .row-item .lead-ic { width: 34px; height: 34px; flex-basis: 34px; }
  .row-item .side .time { display: none; }
  .turn { max-width: 94%; }

  /* Dialogs become bottom sheets */
  .dialog-backdrop { align-items: flex-end; padding: 0; }
  .dialog, .dialog-lg, .dialog-xl { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 1.3rem 1.1rem calc(1.3rem + var(--safe-b)); }

  .notif-panel { top: 64px; right: .75rem; left: .75rem; width: auto; }

  /* Legacy tables stay usable */
  .data-table { font-size: .8rem; }
  .audio-controls { grid-template-columns: repeat(2, 1fr); }
  .transcript-cols { grid-template-columns: 1fr; }
  .lang-picker-row { flex-direction: column; align-items: stretch; }
  .lang-swap-btn { align-self: center; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Interpreter live stage on phones: the Orb leads, controls stay reachable ── */
@media (max-width: 720px) {
  body[data-screen="interpreter-live"] .route-outlet { padding-left: .6rem; padding-right: .6rem; }
  .live-v2 { padding: 1rem .8rem .8rem; border-radius: 22px; }
  .live-v2-stage { grid-template-columns: 1fr 1fr; grid-template-areas: "orb orb" "a b"; gap: .8rem; padding: 1.2rem 0 1rem; }
  .live-v2-stage .orb-wrap { grid-area: orb; min-width: 0; }
  .live-v2-stage .lang-side.a { grid-area: a; justify-content: stretch; }
  .live-v2-stage .lang-side.b { grid-area: b; justify-content: stretch; }
  .lang-side .lang-pill { flex: 1 1 auto; padding: .6rem .5rem; }
  .lang-side .lang-pill .code { font-size: .86rem; }
  .live-v2 .aria-orb { --size: 136px; }
  .orb-state { font-size: 1.05rem; }
  .live-v2 .transcript-cols { grid-template-columns: 1fr; gap: .6rem; }
  .live-v2 .col-body { min-height: 80px; max-height: 24vh; }
  .live-dock {
    grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .45rem;
    position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + .5rem); z-index: 10;
    margin: 1rem 0 .2rem; padding: .5rem; border-radius: 18px;
    background: rgba(15,20,33,.94); border: 1px solid var(--border-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .live-dock .audio-btn { flex-direction: column; gap: .3rem; padding: .6rem .2rem; font-size: .64rem; line-height: 1.2; border-radius: 14px; }
  .live-dock .audio-btn .lbl { text-align: center; }
  /* One state word per line; the other stays hidden by interpreter.css. */
  .live-dock .toggle[aria-checked="true"] .lbl b.state-on,
  .live-dock .toggle[aria-checked="false"] .lbl b.state-off { display: block; }
  .live-dock .toggle .switch { flex: none; }
  .complete-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
  .complete-stats .metric-card { padding: .7rem; }
  .complete-stats .metric-card .v { font-size: 1.1rem; }
  .step-indicator { font-size: .7rem; gap: .35rem; }
  .step-indicator .sep { width: .7rem; }
  /* Only the current step keeps its label; the [data-lang] rules still
     pick the one language to show. */
  .step-indicator .step:not(.current) > span:not(.num) { display: none; }
}

/* ── Narrow phones (iPhone 12–15: 390px; Pro Max: 430px) ── */
@media (max-width: 430px) {
  .route-outlet { padding-left: .85rem; padding-right: .85rem; }
  .mobile-topbar .lang-select button { padding: .26rem .42rem; font-size: .66rem; }
  .hero-card .hero-orb { --size: 76px; top: 1.2rem; transform: none; }
  .hero-card h2 { max-width: 16ch; }
  .today-strip .metric-card .v { font-size: 1.15rem; }
  .page-actions .btn { flex: 1 1 auto; }
  .flow-step { flex-basis: 128px; }
  .segmented button { padding: .38rem .7rem; }
  .tabbar button { font-size: .6rem; }
}

/* Touch targets on phones: at least 44px for every control in the screen
   (measured by the Gate 1 evidence run: small buttons were 28-30px). */
@media (max-width: 960px) {
  .route-outlet .btn, .route-outlet .btn-sm, .dialog .btn, .segmented button, .qa, .studio-rail a { min-height: 44px; }
  .mobile-topbar .icon-btn { width: 44px; height: 44px; }
  .mobile-topbar .lang-select button { min-height: 32px; }
  .data-table a[data-route], .row-item { min-height: 44px; }
  .live-dock .audio-btn { min-height: 56px; }
}

/* Gate 1 QA follow-ups (phones) */
@media (max-width: 960px) {
  /* Residual touch targets from the evidence run: swap button 42px, legacy table links 17px. */
  .lang-swap-btn { width: 44px; height: 44px; }
  .data-table td a[data-route] { display: inline-flex; align-items: center; min-height: 44px; }
  /* WARN: "EN-US↔PT-BR" broke mid-code at 390px; keep a language pair on one line. */
  #ov-interp-langpair { white-space: nowrap; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; }
  /* Cards inside a scrolling strip: draw the focus ring inside, where the strip can't clip it. */
  .quick-actions .qa:focus-visible, .flow-step:focus-visible, .flow-step :focus-visible, .studio-rail a:focus-visible { outline-offset: -2px; }
}
