/* Upchatty FLOW (2026-12-03) — depth + motion for Messenger, on top of uc-ember.css (palette) and uc-vivid.css.
   Two jobs:
     1. DEPTH. One light from the top-left. Every surface you can press is a keycap: a lit top edge, a hard
        bottom edge, a soft shadow; pressing it sinks it. Transform + opacity only, no WebGL (the app shell
        keeps the softphone registered next door).
     2. FLOW. On a phone the room list and the conversation are two cards that slide, the way a chat app
        should: push in, swipe back from the edge, swipe a bubble to reply, a floating date, a jump-to-latest
        button, and the conversation stays glued to the newest message while photos load.
   `.uc-in-chat` on <body> is still the only state (uc-msgr.js reads it); this file only changes how it LOOKS.
   Pairs with uc-flow.js. Roll back = remove the two tags. Motion is off under prefers-reduced-motion. */

:root { --ucf-ease:cubic-bezier(.32,.72,0,1); --ucf-spring:cubic-bezier(.34,1.4,.5,1); --ucf-push:.36s; --ucf-drag:0px; --ucf-p:0 }
html.ucf-paused *, html.ucf-paused *::before, html.ucf-paused *::after { animation-play-state:paused !important }

/* ── touch manners ── */
button, a, label, .channel-item, .nav-item, .uc-hbtn, .msg-row { -webkit-tap-highlight-color:transparent }
button, .channel-item, .nav-item, .uc-hbtn, .input-send { touch-action:manipulation }
.nav-rail, .sidebar-hdr, #sidebar-content .channel-item, .chat-header, .sidebar-foot { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none }
.chat-messages, .sidebar-content { overscroll-behavior:contain; -webkit-overflow-scrolling:touch }
.chat-textarea:focus-visible, .search-inp:focus-visible { outline:none }

/* ══ 1. DEPTH ═══════════════════════════════════════════════════════════════════════════════════════════ */

/* nav rail: section chips become keycaps */
.nav-rail .nav-item .ic { box-shadow:inset 0 1px 0 var(--ucd-hi), 0 2px 0 color-mix(in srgb, var(--sc) 30%, var(--ucd-edge)), 0 6px 12px -4px var(--ucd-lo);
  transition:transform .22s var(--ucf-spring), background .2s, box-shadow .2s }
.nav-rail .nav-item.active .ic { background:linear-gradient(160deg, color-mix(in srgb, var(--sc) 82%, #fff), var(--sc) 55%, color-mix(in srgb, var(--sc) 78%, #000));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.55), 0 3px 0 color-mix(in srgb, var(--sc) 52%, #000), 0 10px 18px -6px color-mix(in srgb, var(--sc) 60%, transparent);
  transform:translateY(-2px) }
.nav-rail .nav-item:active .ic { transform:translateY(1px) scale(.96); box-shadow:inset 0 1px 0 var(--ucd-hi), 0 0 0 var(--ucd-edge) }
.nav-rail .nav-item.active { box-shadow:none; border-color:transparent; background:none }
.nav-rail .nav-item .nav-badge:empty { min-width:11px; width:11px; height:11px; padding:0; top:4px; right:14px }
.nav-rail { box-shadow:inset -1px 0 0 var(--border2) }

/* the mark: a tile you can flip */
.nav-logo { perspective:420px }
.nav-logo img.ucv-mark, .uc-lockup img.ucv-mark { transform-style:preserve-3d; transition:transform .9s var(--ucf-ease) }
.nav-logo:hover img.ucv-mark, .uc-lockup:hover img.ucv-mark { transform:rotateY(360deg) }

/* avatars: coins with a rim */
.mp-av, .avatar, .nav-avatar { box-shadow:inset 0 1.5px 0 rgba(255,255,255,.34), inset 0 -2px 0 rgba(0,0,0,.22), 0 3px 8px -2px var(--ucd-lo) }

/* headers: frosted glass that floats above the conversation */
.chat-header, .sidebar-hdr { background:var(--glass); -webkit-backdrop-filter:blur(16px) saturate(1.3); backdrop-filter:blur(16px) saturate(1.3);
  box-shadow:0 1px 0 var(--border2), 0 10px 24px -18px var(--ucd-lo); position:relative; z-index:6 }
.uc-hbtn:active { transform:translateY(1px) scale(.95) }

/* sidebar rows: a pressed row sinks, the open one is a raised card */
#sidebar-content .channel-item { border:1px solid transparent; border-radius:14px }
#sidebar-content .channel-item.active { background:linear-gradient(180deg, color-mix(in srgb, var(--blue) 15%, var(--card)), color-mix(in srgb, var(--blue) 8%, var(--card)));
  border-color:color-mix(in srgb, var(--blue) 34%, transparent); color:var(--text);
  box-shadow:inset 0 1px 0 var(--ucd-hi), 0 2px 0 color-mix(in srgb, var(--blue) 22%, var(--ucd-edge)), 0 10px 20px -12px var(--ucd-lo) }
#sidebar-content .channel-item:active { transform:scale(.985); background:var(--card2) }
#sidebar-content .mp-row .mp-av { width:44px !important; height:44px !important; font-size:15px !important }
#sidebar-content .mp-ico { border-radius:11px; box-shadow:inset 0 1px 0 var(--ucd-hi), 0 2px 0 var(--ucd-edge) }
.channel-item .ch-badge, .mp-badge { box-shadow:inset 0 1px 0 rgba(255,255,255,.35), 0 2px 0 rgba(0,0,0,.25) }
.search-inp { box-shadow:inset 0 2px 5px -2px var(--ucd-lo) }

/* bubbles: theirs is a lit card, mine is a coral slab; the first of a run carries the tail corner */
.chat-messages { gap:1px; padding-top:10px; scroll-padding-bottom:12px; overflow-x:hidden }
.msg-row { padding:1px 0 }
.msg-row:not(.continued) { margin-top:9px }
.msg-row:hover { background:none }
.msg-bubble:not(.system) { border-radius:18px; padding:8px 13px; font-size:.92rem; line-height:1.42;
  box-shadow:inset 0 1px 0 var(--ucd-hi), 0 1.5px 0 var(--ucd-edge), 0 8px 16px -10px var(--ucd-lo) }
.msg-row:not(.mine):not(.continued) .msg-bubble:not(.system) { border-top-left-radius:6px }
.msg-row.mine:not(.continued) .msg-bubble:not(.system) { border-top-right-radius:6px }
.msg-row.mine .msg-bubble:not(.system) { background:linear-gradient(160deg, color-mix(in srgb, var(--ucv-mine-a) 88%, #fff) 0%, var(--ucv-mine-a) 38%, var(--ucv-mine-b) 100%);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.36), 0 2px 0 color-mix(in srgb, var(--ucv-mine-b) 62%, #000), 0 10px 20px -10px rgba(184,50,92,.55) }
.msg-row.mp-pressed .msg-bubble { transform:scale(.97); transition:transform .18s var(--ucf-ease) }
.msg-img { border-radius:16px; box-shadow:0 2px 0 var(--ucd-edge), 0 12px 22px -12px var(--ucd-lo) }
.reaction-pill { box-shadow:inset 0 1px 0 var(--ucd-hi), 0 1.5px 0 var(--ucd-edge); transition:transform .18s var(--ucf-spring) }
.reaction-pill:active { transform:scale(.9) }
.msg-row.ucv-in { transform-origin:0 100% }
.msg-row.mine.ucv-in { transform-origin:100% 100% }
@keyframes ucvIn { from{opacity:0;transform:translateY(16px) scale(.86)} 60%{opacity:1} to{opacity:1;transform:none} }
@keyframes ucvInMine { from{opacity:0;transform:translateY(22px) scale(.8)} 60%{opacity:1} to{opacity:1;transform:none} }

/* the day: a floating pill that stays with you while you scroll */
.msg-day-divider { position:sticky; top:4px; z-index:4; justify-content:center; margin:10px 0 4px; pointer-events:none; font-family:var(--uc-display) }
.msg-day-divider::before, .msg-day-divider::after { display:none }
.msg-day-divider { width:max-content; max-width:90%; align-self:center; padding:5px 13px; border-radius:999px; color:var(--text); font-size:.72rem; font-weight:700;
  background:var(--glass); -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px);
  box-shadow:inset 0 1px 0 var(--ucd-hi), 0 1.5px 0 var(--ucd-edge), 0 8px 18px -10px var(--ucd-lo) }

/* while you are not scrolling, the pinned day steps aside so it never sits on a message (uc-flow.js marks it) */
.msg-day-divider { transition:opacity .28s }
.msg-day-divider.ucf-idle { opacity:0 }

/* composer: a dock that floats, with a round key to send */
.chat-input-area { background:var(--glass); -webkit-backdrop-filter:blur(16px) saturate(1.3); backdrop-filter:blur(16px) saturate(1.3); border-top:1px solid var(--border2) }
.chat-input-row { border-radius:26px; padding:6px 6px 6px 10px; align-items:center; border-color:var(--border2);
  box-shadow:inset 0 2px 6px -3px var(--ucd-lo), 0 1px 0 var(--ucd-hi); transition:border-color .2s, box-shadow .25s }
.chat-input-row:focus-within { border-color:color-mix(in srgb, var(--blue) 70%, transparent); box-shadow:inset 0 2px 6px -3px var(--ucd-lo), 0 0 0 4px color-mix(in srgb, var(--blue) 14%, transparent) }
.chat-textarea { padding:6px 0; font-size:.94rem }
.input-send, #send-btn { width:42px; height:42px; min-width:42px; border-radius:50%;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.4), 0 3px 0 color-mix(in srgb, var(--ucv-mine-b) 60%, #000), 0 10px 18px -8px rgba(184,50,92,.6);
  transition:transform .16s var(--ucf-spring), box-shadow .16s }
.input-send:active, #send-btn:active { transform:translateY(2px) scale(.96); box-shadow:inset 0 1px 0 rgba(255,255,255,.4), 0 1px 0 color-mix(in srgb, var(--ucv-mine-b) 60%, #000) }
.btn-primary { box-shadow:inset 0 1px 0 rgba(255,255,255,.34), 0 3px 0 color-mix(in srgb, var(--ucv-mine-b) 60%, #000), 0 12px 22px -10px rgba(207,63,37,.55) }
.btn-primary:active { transform:translateY(2px); box-shadow:inset 0 1px 0 rgba(255,255,255,.34), 0 1px 0 color-mix(in srgb, var(--ucv-mine-b) 60%, #000) }

/* sheets and menus rise like a card being lifted off the table */
.modal, .mp-sheet, #ucv-tip { box-shadow:inset 0 1px 0 var(--ucd-hi), 0 3px 0 var(--ucd-edge), var(--shadow) }
.overlay.show .modal, .mp-sheet-wrap.show .mp-sheet { animation:ucfLift .42s var(--ucf-ease) both }
@keyframes ucfLift { from{opacity:0;transform:perspective(900px) rotateX(14deg) translateY(34px) scale(.96)} to{opacity:1;transform:none} }

/* a section opening: its content settles in */
.main-section.active > * { animation:ucfSettle .34s var(--ucf-ease) both }
#panel-chats.active > * { animation:none }
@keyframes ucfSettle { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:none} }

/* login: the card and the story stand in real space and lean toward the pointer (uc-flow.js feeds --rx/--ry) */
#auth-screen { perspective:1400px }
#auth-screen .auth-card { transform:rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)); transform-style:preserve-3d; transition:transform .5s var(--ucf-ease);
  box-shadow:inset 0 1px 0 var(--ucd-hi), 0 4px 0 var(--ucd-edge), 0 40px 70px -30px var(--ucd-lo); animation:ucfLift .7s var(--ucf-ease) both }
#auth-screen .auth-logo img { animation:ucfCoin 1.1s var(--ucf-ease) .2s both }
@keyframes ucfCoin { from{transform:rotateY(-180deg) scale(.6);opacity:0} to{transform:none;opacity:1} }
.ucv-story .ucv-phone { transform:perspective(1100px) rotateY(calc(-9deg + var(--ry,0deg))) rotateX(calc(4deg + var(--rx,0deg))); transform-origin:60% 50%;
  box-shadow:-18px 26px 50px -22px var(--ucd-lo), 0 4px 0 var(--ucd-edge), 0 0 0 6px color-mix(in srgb, var(--card) 60%, transparent); transition:transform .5s var(--ucf-ease) }
.ucv-b { box-shadow:inset 0 1px 0 var(--ucd-hi), 0 1.5px 0 var(--ucd-edge) }
.ucv-tile { box-shadow:inset 0 1px 0 var(--ucd-hi), 0 2px 0 var(--ucd-edge) }

/* the last two blue pictures on the login card take the palette */
.auth-join img { filter:hue-rotate(150deg) }

/* backdrop: three depths of drifting bubbles; the far ones are small, slow and soft (uc-flow.js adds parallax) */
.ucv-drift { transform:translate3d(var(--px,0px), var(--py,0px), 0); transition:transform .8s var(--ucf-ease) }
.ucv-drift i:nth-child(3n) { filter:blur(1.6px); border-width:1px }
.ucv-drift i:nth-child(3n+1) { border-width:2px; box-shadow:0 10px 18px -8px var(--c) }

/* jump to the newest message */
#ucf-jump { position:absolute; right:16px; bottom:92px; z-index:29; width:44px; height:44px; border-radius:50%; border:1px solid var(--border); background:var(--card);
  color:var(--text); display:flex; align-items:center; justify-content:center; cursor:pointer; opacity:0; transform:translateY(12px) scale(.8); pointer-events:none;
  box-shadow:inset 0 1px 0 var(--ucd-hi), 0 3px 0 var(--ucd-edge), 0 14px 24px -10px var(--ucd-lo); transition:opacity .22s, transform .3s var(--ucf-spring) }
#ucf-jump.on { opacity:1; transform:none; pointer-events:auto }
#ucf-jump:active { transform:translateY(2px) scale(.95) }
#ucf-jump svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round }
#mp-newpill { right:70px; box-shadow:inset 0 1px 0 rgba(255,255,255,.34), 0 3px 0 color-mix(in srgb, var(--ucv-mine-b) 60%, #000), 0 12px 20px -10px rgba(184,50,92,.6);
  background:linear-gradient(135deg,var(--ucv-mine-a),var(--ucv-mine-b)); border-color:transparent; animation:ucfSettle .3s var(--ucf-spring) }

/* swipe a bubble to reply: the row follows the finger, an arrow fills in behind it */
.msg-row.ucf-swipe { transition:none }
.msg-row.ucf-back { transition:transform .32s var(--ucf-spring) }
#ucf-reply-hint { position:absolute; left:10px; width:34px; height:34px; border-radius:50%; background:var(--card2); color:var(--blue); display:flex; align-items:center; justify-content:center;
  pointer-events:none; z-index:3; opacity:var(--o,0); transform:scale(var(--s,.5)); box-shadow:inset 0 1px 0 var(--ucd-hi), 0 2px 0 var(--ucd-edge) }
#ucf-reply-hint.armed { background:var(--blue); color:#fff }
#ucf-reply-hint svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2.3; stroke-linecap:round; stroke-linejoin:round }
#reply-preview { animation:ucfSettle .26s var(--ucf-ease); border-radius:12px !important }

/* ══ 2. FLOW on a phone: two cards, one slides over the other ══════════════════════════════════════════ */
@media (max-width:700px) {
  /* the list and the conversation share one cell; the conversation also covers the tab bar, like a pushed screen */
  #app-shell { display:grid; grid-template-columns:100%; grid-template-rows:minmax(0,1fr) auto }
  #app-shell > .nav-rail { grid-area:2/1 }
  #app-shell > .sidebar { grid-area:1/1; min-height:0 }
  #app-shell > .main-area { grid-area:1/1; min-height:0 }
  body[data-nav="chats"] #app-shell > .sidebar { display:flex !important; transform:translate3d(calc(-26% * var(--ucf-p)),0,0); filter:brightness(calc(1 - .22 * var(--ucf-p)));
    transition:transform var(--ucf-push) var(--ucf-ease), filter var(--ucf-push) var(--ucf-ease), visibility 0s linear 0s }
  body[data-nav="chats"] #app-shell > .main-area { display:flex !important; grid-area:1/1/3/2; z-index:120; background:var(--bg);
    transform:translate3d(calc(100% * (1 - var(--ucf-p))),0,0); visibility:hidden;
    box-shadow:-16px 0 40px -16px var(--ucd-lo); transition:transform var(--ucf-push) var(--ucf-ease), visibility 0s linear var(--ucf-push) }
  body[data-nav="chats"].uc-in-chat { --ucf-p:1 }
  body[data-nav="chats"].uc-in-chat #app-shell > .main-area { visibility:visible; transition:transform var(--ucf-push) var(--ucf-ease), visibility 0s }
  body[data-nav="chats"].uc-in-chat #app-shell > .sidebar { visibility:hidden; transition:transform var(--ucf-push) var(--ucf-ease), filter var(--ucf-push) var(--ucf-ease), visibility 0s linear var(--ucf-push) }
  /* a finger is dragging the conversation back: both cards follow it, no easing */
  body.ucf-dragging #app-shell > .sidebar, body.ucf-dragging #app-shell > .main-area { transition:none !important; visibility:visible !important }
  body.ucf-noanim #app-shell > .sidebar, body.ucf-noanim #app-shell > .main-area { transition:none !important }

  /* the conversation owns the bottom of the screen now, so it holds the home-indicator space itself */
  body[data-nav="chats"] #chat-view .chat-input-area, body[data-nav="chats"] .mp-th-comp { padding-bottom:calc(8px + var(--sab,env(safe-area-inset-bottom,0px))) }
  body[data-nav="chats"] .mp-vbody { padding-bottom:calc(20px + var(--sab,env(safe-area-inset-bottom,0px))) }

  /* conversation: my own face and name are noise on a phone; give the words the width */
  .chat-messages { padding:8px 10px 10px }
  .msg-row { gap:7px }
  .msg-row.mine .msg-avatar-slot { display:none }
  .msg-row.mine .msg-meta .msg-sender, .msg-row.mine .msg-meta .mp-aitag, .msg-row.mine .msg-meta .mp-st { display:none }
  .msg-avatar-slot { width:30px } .msg-avatar-slot .mp-av, .msg-avatar-slot .avatar { width:30px !important; height:30px !important; font-size:11px !important }
  .msg-body, .mp-th-list .msg-body { max-width:86% }
  .msg-bubble:not(.system) { font-size:1rem; padding:8px 13px }
  .msg-actions { display:none !important }
  .chat-header { padding-top:8px; padding-bottom:8px }
  .chat-header .ch-title { font-size:1.02rem }
  .chat-input-row { border-radius:24px }
  #ucf-jump { right:12px; bottom:calc(78px + var(--sab,env(safe-area-inset-bottom,0px))) } #mp-newpill { right:64px; bottom:calc(82px + var(--sab,env(safe-area-inset-bottom,0px))) }

  /* room list: roomier rows, hairlines between them, no hover slide under a thumb */
  #sidebar-content { padding:6px 8px 10px }
  #sidebar-content .channel-item.mp-row { padding:9px 8px; min-height:62px; gap:12px }
  #sidebar-content .channel-item:hover { transform:none }
  #sidebar-content .mp-top .ch-name { font-size:16px } #sidebar-content .mp-prev { font-size:14px }
  #sidebar-content .mp-row + .mp-row { box-shadow:inset 0 1px 0 var(--border2) } #sidebar-content .mp-row.active + .mp-row, #sidebar-content .mp-row.active { box-shadow:none }
  #sidebar-content .channel-item.active { background:none; border-color:transparent; box-shadow:none }
  .nav-rail { background:var(--glass); -webkit-backdrop-filter:blur(16px); backdrop-filter:blur(16px) }
  .nav-rail .nav-item.active .ic { transform:translateY(-3px) }
  .nav-rail .nav-item:hover { transform:none; background:none }
  body:not([data-nav="chats"]) #app-shell > .sidebar { display:none }
  /* small targets the phone audit found: reaction chips, the admin tab strip, the media search box */
  .reaction-pill { min-height:32px; padding-left:10px; padding-right:10px }
  .admin-tabs { overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch } .admin-tabs::-webkit-scrollbar { display:none }
  .atab { flex:none; min-height:38px }
  .gallery-topbar { flex-wrap:wrap; row-gap:8px } .gallery-search-wrap { flex:1 1 100%; max-width:none } .gallery-search { min-height:40px; width:100% }
  .gf-btn { min-height:34px }
}
.media-tile-meta { font-size:11px }
/* the director has two buttons in the sidebar foot; on the narrow desktop column the tour shrinks to its compass */
@media (min-width:701px) { .sidebar-foot .ucw-btn + .ucv-tour-btn { font-size:0; gap:0; padding:0 10px } }
body.ucf-first #sidebar-content .channel-item { animation:ucfRow .42s var(--ucf-ease) both; animation-delay:calc(var(--i,0) * 28ms) }
@keyframes ucfRow { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:none} }

/* the keyboard is up (uc-flow.js follows the visual viewport on iOS, where the layout viewport does not shrink) */
html.ucf-kb #app-shell { top:var(--ucf-vvt,0px); bottom:auto; height:var(--ucf-vvh,100%) }
html.ucf-kb body[data-nav="chats"] #chat-view .chat-input-area { padding-bottom:8px }

@media (hover:none) { .nav-rail .nav-item:hover .ic { transform:none } .nav-rail .nav-item.active:hover .ic { transform:translateY(-3px) } }

@media (prefers-reduced-motion: reduce) {
  :root { --ucf-push:.001s }
  #auth-screen .auth-card, .ucv-story .ucv-phone { transform:none !important }
  .ucv-drift { transform:none !important }
}
