/*
 * static/css/cu.css — computer use (batch 4 spec §3.6, Ray's additions of 2026-11-07): the cursor, its cues, the
 * banner (a line naming the app above the "Click to stop Computer Use" button), the golden glow around the page and
 * the copy toast. static/js/cu/overlay.js builds the DOM:
 *   <div id="cu-layer" class="cu-layer" data-cu-ui>   (the first child of <body>: the banner's button is the first Tab stop)
 *     p#cu-live.visually-hidden (role=status: announces a session), .cu-glow, trail svg, .cu-cursor,
 *     div.cu-banner (p.cu-banner__line, button.cu-banner__stop), .cu-toast
 *   </div>
 *
 * Owner: lane cu-client (plan R-106); restyled by the UI overhaul (batch 4 §9 phase 2, brief §6.17): one small
 * card for the banner with the primary pill (it stops the chat like Send's neighbour Stop, so it gets Send's
 * weight), the glow as Ray's one glow, the cursor's cue as a line icon. Tokens only (tokens.css, the profile's
 * theme.css); every selector once (I7). Nothing outside this layer is styled for computer use: the screenshot,
 * the snapshot and hit tests leave the layer out, so anything else would show in the model's picture. Two exceptions,
 * both meant for the model's picture too: the band below, and the sidebar rows' rename and delete, which show on
 * every row while a session runs (`data-cu-session` on <html>, overlay.js; the rules live in sidebar.css).
 * The layer is above every overlay, the dialogs included (I1: --z-system-notice < --z-dialog < --z-cu), and lets
 * pointer events through except on the banner and the toast; `[data-cu-passthrough]` (set for the instant of the
 * model's hit test) makes those click-through too, so the model's actions pass through them.
 * Where the banner sits is measured by overlay.js (`--cu-banner-top`, `--cu-banner-x`: just below the nav, centred
 * over the main area, at every width); the toast sits above the composer (`--composer-clearance`, composer.js).
 * While a sheet, the phone drawer, the image viewer or a dialog covers the nav, the banner sits at the very top and
 * those surfaces start below it (the band: `data-cu-band` and `--cu-band` on <html>, overlay.js), so it covers none
 * of their controls.
 */

.cu-layer { position: fixed; inset: 0; z-index: var(--z-cu); pointer-events: none; overflow: hidden; }
.cu-layer[data-cu-passthrough] .cu-banner, .cu-layer[data-cu-passthrough] .cu-toast { pointer-events: none; }
/* Over browser fullscreen the layer is a manual popover in the top layer (overlay.js syncTopLayer): none of the
   popover's own box (it stays the same transparent, full-viewport, click-through layer). */
.cu-layer[popover] {
    width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
    background: transparent; color: inherit; overflow: hidden;
}

/* ---- glow (Ray's addition 4, the only glow in the system): a 2 px accent line around the page with a soft
   Boilermaker-gold edge inside it, pulsing slowly; steady under reduced motion; never takes a click ---- */
.cu-glow {
    position: absolute; inset: 0; pointer-events: none;
    box-shadow: inset 0 0 0 2px var(--c-accent), inset 0 0 24px 4px var(--c-glow-edge);
    animation: cu-glow 3.6s ease-in-out infinite;
}

/* ---- banner (user-only: the model never sees it): one small card, the line above the stop pill ---- */
.cu-banner {
    position: absolute; top: var(--cu-banner-top, calc(env(safe-area-inset-top, 0px) + 10px)); left: var(--cu-banner-x, 50%);
    transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: var(--space-2); width: max-content;
    max-width: min(calc(100vw - 32px), var(--cu-banner-max, 100vw));
    box-sizing: border-box; padding: 10px 12px 12px; border: 0;
    border-radius: var(--radius-lg); background: var(--c-surface-raised); color: var(--c-on);
    box-shadow: var(--elev-3); pointer-events: auto;
}
.cu-banner__line {
    margin: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--c-on-2); font: var(--t-label-m);
}
/* the stop: the filled primary pill (gold with a black label in dark, ink with an ivory label and gold accents in
   light), its live dot before the words and a stop icon after them */
.cu-banner__stop {
    display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; height: 40px;
    padding: 0 16px 0 14px; border: 0; border-radius: var(--radius-pill);
    background: var(--c-primary); color: var(--c-on-primary); box-shadow: inset 0 0 0 1px var(--c-primary-edge);
    font: var(--t-label-l); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    cursor: pointer; transition: background-color var(--dur-1) var(--ease-standard);
}
.cu-banner__stop::after {
    content: ''; flex: none; width: 16px; height: 16px; background: var(--c-on-primary-accent);
    -webkit-mask: var(--icon-stop) center / contain no-repeat; mask: var(--icon-stop) center / contain no-repeat;
}
.cu-banner__stop:hover { background: var(--c-primary-hover); }
.cu-banner__stop:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 3px; }
.cu-banner__dot { flex: none; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--c-on-primary-accent); animation: cu-dot 1.6s ease-in-out infinite; }

/* Over a fullscreen frame the layer is shown but inert (overlay.js syncTopLayer): no Stop no click can reach. */
.cu-banner[data-cu-inert] .cu-banner__stop { display: none; }

/* A main area narrower than the banner (the side viewer pane dragged wide): the banner takes its width and its line and
   button wrap instead of reaching over the sidebar or the pane's divider (overlay.js fitBanner). */
.cu-banner[data-cu-fit] .cu-banner__line { white-space: normal; text-align: center; overflow-wrap: anywhere; }
.cu-banner[data-cu-fit] .cu-banner__stop {           /* the 40 px pill grows with its wrapped words */
    white-space: normal; text-align: center; overflow-wrap: anywhere;
    height: auto; min-height: 40px; padding-top: var(--space-2); padding-bottom: var(--space-2);
}

/* ---- the band: the surfaces over the nav make room for the banner at the top (overlay.js placeBanner) ---- */
:root[data-cu-band] .wsp-overlay,
:root[data-cu-band] .aiw-stage--sheet,
:root[data-cu-band] .aiw-lightbox { padding-top: var(--cu-band); }
:root[data-cu-band] .confirm-modal,
:root[data-cu-band] .prompt-modal { padding-top: max(var(--space-5), var(--cu-band)); }
:root[data-cu-band] .wsp-panel,
:root[data-cu-band] .settings-panel { max-height: 100%; }

/* ---- cursor: the tip of the arrow is the element's origin; Boilermaker Gold with a dark edge ---- */
.cu-cursor { position: absolute; top: 0; left: 0; width: 0; height: 0; will-change: transform; filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.35)); }
.cu-cursor__arrow { position: absolute; left: -5px; top: -3px; overflow: visible; }
.cu-cursor__arrow path { fill: var(--c-brand); stroke: var(--c-on-brand); stroke-width: 1.5px; paint-order: stroke; }
/* the cue badge: a 20 px gold chip with the cue as a line icon (a sparkle while it only moves) */
.cu-cursor__badge {
    position: absolute; left: 15px; top: 19px; width: 20px; height: 20px; box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-pill);
    background: var(--c-brand); color: var(--c-on-brand); box-shadow: 0 0 0 1.5px var(--c-on-brand);
}
.cu-cursor__badge::after {
    content: ''; width: 13px; height: 13px; background: currentColor;
    -webkit-mask: var(--icon-sparkle) center / contain no-repeat; mask: var(--icon-sparkle) center / contain no-repeat;
}
/* near the right or bottom edge the badge goes to the other side of the tip, inside the page (overlay.js data-edge) */
.cu-cursor[data-edge~="right"] .cu-cursor__badge { left: auto; right: 8px; }
.cu-cursor[data-edge~="bottom"] .cu-cursor__badge { top: auto; bottom: 6px; }
.cu-cursor__ring {
    position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; box-sizing: border-box;
    border: 2px solid var(--c-accent); border-radius: var(--radius-pill); opacity: 0; transform: scale(0.4);
}
.cu-cursor[data-cue="click"] .cu-cursor__ring { animation: cu-ring 0.48s var(--ease-enter); }
.cu-cursor[data-cue="double"] .cu-cursor__ring { animation: cu-ring 0.26s var(--ease-enter) 2; }
.cu-cursor[data-cue="right"] .cu-cursor__ring { border-style: dashed; animation: cu-ring 0.48s var(--ease-enter); }
.cu-cursor[data-cue="middle"] .cu-cursor__ring { border-style: double; border-width: 5px; animation: cu-ring 0.48s var(--ease-enter); }
.cu-cursor[data-cue="drag"] .cu-cursor__ring { opacity: 0.9; transform: scale(0.6); background: color-mix(in srgb, var(--c-accent) 14%, transparent); }
.cu-cursor[data-cue="focus"] .cu-cursor__ring { border-width: 1.5px; animation: cu-ring 0.36s var(--ease-enter); }
.cu-cursor:is([data-cue="click"], [data-cue="double"]) .cu-cursor__badge::after { -webkit-mask-image: var(--icon-pointer); mask-image: var(--icon-pointer); }
.cu-cursor[data-cue="right"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-list); mask-image: var(--icon-list); }
.cu-cursor:is([data-cue="middle"], [data-cue="focus"]) .cu-cursor__badge::after { -webkit-mask-image: var(--icon-target); mask-image: var(--icon-target); }
.cu-cursor[data-cue="drag"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-move); mask-image: var(--icon-move); }
.cu-cursor[data-cue="type"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-keyboard); mask-image: var(--icon-keyboard); }
.cu-cursor[data-cue="type"] .cu-cursor__badge { animation: cu-typing 0.7s ease-in-out infinite; }
.cu-cursor[data-cue="scroll-up"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-arrow-up); mask-image: var(--icon-arrow-up); }
.cu-cursor[data-cue="scroll-down"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-arrow-down); mask-image: var(--icon-arrow-down); }
.cu-cursor[data-cue="scroll-left"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-arrow-left); mask-image: var(--icon-arrow-left); }
.cu-cursor[data-cue="scroll-right"] .cu-cursor__badge::after { -webkit-mask-image: var(--icon-arrow-right); mask-image: var(--icon-arrow-right); }
.cu-trail { position: absolute; inset: 0; overflow: visible; }
.cu-trail line { stroke: var(--c-accent); stroke-width: 2px; stroke-dasharray: 5 5; stroke-linecap: round; opacity: 0.8; }

/* ---- copy toast (the browser refused a copy without the user's click): a callout above the composer ---- */
.cu-toast {
    position: absolute; left: 50%; bottom: calc(var(--composer-clearance, 104px) + 12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: flex; align-items: center; gap: var(--space-3); width: max-content; max-width: calc(100vw - 32px); box-sizing: border-box;
    padding: 8px 6px 8px 16px; border: 0; border-radius: var(--radius-md);
    background: var(--c-surface-raised); color: var(--c-on); box-shadow: var(--elev-2); font: var(--t-body-m);
    pointer-events: auto;
}
.cu-toast__text { min-width: 0; }
.cu-toast__copy {
    flex: none; height: 32px; padding: 0 14px; border: 0; border-radius: var(--radius-pill);
    background: var(--c-primary); color: var(--c-on-primary); box-shadow: inset 0 0 0 1px var(--c-primary-edge);
    font: var(--t-label-m); cursor: pointer;
}
.cu-toast__copy:hover:not(:disabled) { background: var(--c-primary-hover); }
.cu-toast__copy:disabled { cursor: default; opacity: 0.85; }
/* × (kept in the DOM) as an icon */
.cu-toast__close {
    flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--c-on-2);
    font-size: 0; line-height: 0; cursor: pointer;
}
.cu-toast__close::before {
    content: ''; width: 16px; height: 16px; background: currentColor;
    -webkit-mask: var(--icon-x) center / contain no-repeat; mask: var(--icon-x) center / contain no-repeat;
}
.cu-toast__close:hover { background: var(--c-hover); color: var(--c-on); }
.cu-toast__copy:focus-visible, .cu-toast__close:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

@keyframes cu-ring {
    0% { opacity: 0.95; transform: scale(0.35); }
    100% { opacity: 0; transform: scale(1.45); }
}
@keyframes cu-glow {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
@keyframes cu-dot {
    0%, 100% { opacity: 0.95; }
    50% { opacity: 0.35; }
}
@keyframes cu-typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* The phone drawer (sidebar.js MOBILE_QUERY) starts below the banner too while it is open over the nav. */
@media (max-width: 768px) {
    :root[data-cu-band] #sidebar { padding-top: var(--cu-band); }
    .cu-banner__stop { height: 36px; font: var(--t-label-m); }
}

/* Phones: a tighter banner. */
@media (max-width: 480px) {
    .cu-banner { padding: 8px 10px 10px; gap: 6px; }
}

/* Forced colours: the icons are masks; the stop keeps a visible edge. */
@media (forced-colors: active) {
    .cu-banner__stop::after, .cu-cursor__badge::after, .cu-toast__close::before { forced-color-adjust: none; background: ButtonText; }
    .cu-banner__stop { border: 1px solid ButtonText; }
}

/* Reduced motion: the cursor jumps (overlay.js) and every cue shows without moving. */
@media (prefers-reduced-motion: reduce) {
    .cu-glow { animation: none; opacity: 0.85; }
    .cu-banner__dot { animation: none; }
    .cu-cursor[data-cue] .cu-cursor__ring { animation: none; opacity: 0.85; transform: scale(1); }
    .cu-cursor[data-cue="type"] .cu-cursor__badge { animation: none; }
}
