/* A staff ticket on a phone (GitHub issue 488, stage 3; docs/adr/0247-show-changes-and-the-phone.md;
   public/js/app/ticket-phone.js). At 700 px and narrower: a bar at the bottom (the main action, Reply, Actions), a sheet
   of every action from the bottom, Help for this ticket as a tab beside Conversation, and the header's toolbar out of the
   way (the bar and the sheet have all of it). Tap targets are 44 px or more. Colors are the palette's tokens, so the dark
   theme follows. Wider than a phone nothing here shows. */

.tpb-bar[hidden], .tpb-sheet-layer[hidden], .tpb-help-tab[hidden] { display:none !important; }
.tpb-bar { position:fixed; left:0; right:0; bottom:0; z-index:var(--z-banner); display:flex; align-items:center; gap:var(--space-100); padding:var(--space-100) var(--space-200) calc(var(--space-100) + env(safe-area-inset-bottom, 0px)); border-top:1px solid var(--line-strong); background:var(--surface); box-shadow:0 -6px 18px color-mix(in srgb, var(--ink) 10%, transparent); }
.tpb-bar .tpb-button { flex:1 1 0; min-width:0; min-height:44px; padding:var(--space-75) var(--space-100); border-radius:var(--radius-lg); font-size:var(--text-md); white-space:normal; overflow-wrap:break-word; line-height:1.2; }
/* Actions keeps its word whole; the others share what is left, wrapping between words at the narrowest. */
.tpb-bar .tpb-actions { flex:0 0 auto; white-space:nowrap; }
.tpb-bar .tpb-button.is-greyed { opacity:.55; }
.tpb-bar .tpb-button.is-greyed:focus-visible { opacity:1; }
.tpb-bar .tpb-actions::after { content:""; display:inline-block; width:.4em; height:.4em; margin-left:var(--space-75); border-right:2px solid currentColor; border-top:2px solid currentColor; transform:translateY(.05em) rotate(-45deg); }

/* The sheet: from the bottom, over a dimmed page, scrolling inside. */
html.tpb-sheet-open { overflow:hidden; }
.tpb-sheet-layer { position:fixed; inset:0; z-index:var(--z-drawer); display:flex; flex-direction:column; justify-content:flex-end; }
.tpb-scrim { position:absolute; inset:0; background:color-mix(in srgb, var(--ink) 40%, transparent); }
.tpb-sheet { position:relative; display:flex; flex-direction:column; max-height:min(85vh, 100% - 3rem); max-height:min(85dvh, 100% - 3rem); border-top:1px solid var(--line-strong); border-radius:var(--radius-xl) var(--radius-xl) 0 0; background:var(--surface); box-shadow:var(--shadow-pop); }
.tpb-sheet-head { display:flex; align-items:center; gap:var(--space-100); padding:var(--space-100) var(--space-100) var(--space-50) var(--space-200); border-bottom:1px solid var(--line); }
.tpb-sheet-title { flex:1 1 auto; min-width:0; margin:0; color:var(--ink); font-size:var(--text-lg); font-weight:var(--weight-semibold); overflow-wrap:anywhere; }
.tpb-close { flex:none; width:44px; height:44px; border:0; border-radius:var(--radius-lg); background:transparent; color:var(--ink-2); font-size:var(--text-2xl); line-height:1; cursor:pointer; }
.tpb-close:hover { background:var(--hover-bg); }
.tpb-close:focus-visible { outline:2px solid var(--spruce); outline-offset:-2px; }
.tpb-sheet-body { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:var(--space-50) 0 calc(var(--space-150) + env(safe-area-inset-bottom, 0px)); }
.tpb-sheet .tb-item { display:grid; grid-template-columns:1fr auto; align-items:center; gap:var(--space-25) var(--space-150); width:100%; min-height:44px; padding:var(--space-100) var(--space-200); border:0; background:transparent; color:var(--ink); font-size:var(--text-md); text-align:left; white-space:normal; overflow-wrap:anywhere; cursor:pointer; }
.tpb-sheet .tb-item:hover, .tpb-sheet .tb-item:focus-visible { background:var(--hover-bg); outline:none; box-shadow:inset 3px 0 0 var(--spruce); }
.tpb-sheet .tb-item kbd { display:none; }
.tpb-sheet .tb-item.is-greyed { color:var(--muted); }
.tpb-sheet .tb-item-why { grid-column:1 / -1; color:var(--muted); font-size:var(--text-sm); white-space:normal; }
.tpb-sheet .tb-group[data-group="urgent"] { border-top:2px solid var(--line-strong); margin-top:var(--space-50); }
.tpb-sheet .tb-group[data-group="urgent"] .tb-group-heading { color:var(--bad); }
.tpb-sheet .tb-menu-empty { margin:0; padding:var(--space-150) var(--space-200); color:var(--muted); }

@media (max-width:700px) {
  /* The bottom bar and the sheet have every action: the header keeps the number, the title, its chips and the save line. */
  .tp.tpb-phone > .detail-header .tb-wrap { display:none; }
  /* Room under the page for the bar, and the toasts above it. */
  body.tpb-on #ticketDetailModal .ticket-detail.tp { padding-bottom:calc(var(--tpb-h, 64px) + var(--space-300)); }
  body.tpb-on .toast { bottom:calc(var(--tpb-h, 64px) + var(--space-150)); }
  /* Help for this ticket is the Help tab: the column shows only while that tab is chosen, the conversation then not. */
  .tp.tpb-phone:not(.tpb-help) .detail-sidebar { display:none; }
  .tp.tpb-phone.tpb-help .detail-sidebar { margin-top:var(--space-100); }
  .tp.tpb-phone.tpb-help .tp-conversation { display:none !important; }
  /* Overview, Related and Details are the tabs beside Messages (the Record workspace, the owner's RW4): the panel's own
     tab row steps aside. */
  .tp.tpb-phone .th-tabs { display:none !important; }
  .tp.tpb-phone .detail-tabs { scroll-margin-top:calc(var(--topbar-height) + var(--outage-banner-h, 0px) + var(--space-100)); }
  /* Short labels: the row fits, so none hides off screen; at the narrowest it may wrap onto a second line, never scroll. */
  .tp.tpb-phone .detail-tabs { flex-wrap:wrap; overflow-x:visible; gap:0; -webkit-mask-image:none; mask-image:none; }
  .tp.tpb-phone .detail-tabs > button, [data-theme="dark"] .tp.tpb-phone .detail-tabs > button { min-height:44px; padding:var(--space-75) var(--space-75) !important; }
  /* The reply box's "N people will get this" line wraps at the narrowest instead of running past the card. */
  .tp.tpb-phone .composer-footer > .tp-reach { flex:1 1 100%; max-width:100%; }
  .tp.tpb-phone .tp-reach > .tp-reach-line { min-width:0; max-width:100%; overflow-wrap:anywhere; }
  .tp.tpb-phone .detail-tabs .tw-tab-count { margin-left:var(--space-50); padding:0 var(--space-50); }
}
@media print { .tpb-bar, .tpb-sheet-layer { display:none !important; } }
