/* Cortex (amendments A7.1, A7.2): the floating actions, the ember halo and the assistant sheet.
   Colours come only from tokens.css. The halo animates transform and opacity (the spin and the glow) on its own
   compositor layers; the open and close sweeps animate one registered angle for under 650ms. */

/* ---------- floating actions: desktop and tablet bottom-right (mic 56, New lead 44 above it); phones, the mic ---------- */
.fab-cluster{position:fixed;right:calc(24px + env(safe-area-inset-right));bottom:calc(24px + env(safe-area-inset-bottom));z-index:var(--z-fab);display:flex;flex-direction:column;align-items:center;gap:12px;pointer-events:none}
.fab-cluster>*{pointer-events:auto}
.fab-cluster[hidden],html.ui-sheet-open .fab-cluster{display:none}
.fab-mic,.fab-new{display:grid;place-items:center;padding:0;border-radius:50%;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:transform var(--dur-press) var(--ease-out-soft),background-color var(--dur-quick) ease,box-shadow var(--dur-quick) ease,border-color var(--dur-quick) ease}
.fab-mic{width:56px;height:56px;border:0;background:var(--accent);color:var(--on-accent);box-shadow:var(--glow-accent),var(--shadow-pop)}
.fab-mic:hover{background:var(--accent-hover)}
.fab-mic:active{transform:scale(.97);background:var(--accent-active)}
.fab-new{width:44px;height:44px;border:1px solid var(--hairline);background:var(--surface-sheen),var(--surface);color:var(--accent-icon);box-shadow:var(--shadow-pop)}
.fab-new:hover{border-color:var(--accent-border)}
.fab-new:active{transform:scale(.97)}
.fab-mic:focus-visible,.fab-new:focus-visible{outline:2px solid var(--focus-ring);outline-offset:3px}
/* A8: an open lead panel is never covered. Desktop and tablet: the cluster moves left of the panel, sliding with it
   (transform only: the panel's width, 600 desktop / 560 tablet). Phones: it rises above the panel's footer bar. */
.fab-cluster{transition:transform var(--dur-view) var(--ease-out-soft)}
@media (min-width:768px){
 #drawer.show~.fab-cluster{transform:translateX(calc(-1 * min(600px,100vw)))}
 /* every scrolling screen except the board and Leads (which size their own panes) ends clear of the cluster */
 .app:not([data-view="pipeline"]):not([data-view="leads"]) #main{padding-bottom:calc(24px + 56px + 12px + 44px + 24px)}
 /* the board columns and the Leads table scroll in their own panes: their ends scroll clear of the cluster too (B12) */
 .app[data-view="pipeline"] .col-body{padding-bottom:calc(56px + 12px + 44px + 24px)}
 .app[data-view="leads"] .leads-table{padding-bottom:calc(56px + 12px + 44px)}
}
@media (min-width:768px) and (max-width:1099px){
 #drawer.show~.fab-cluster{transform:translateX(calc(-1 * min(560px,100vw)))}
}
/* the reminder banner keeps clear of the cluster */

/* ---------- the ember halo: a full-viewport overlay that never takes a pointer ---------- */
@property --halo-spread{syntax:'<angle>';inherits:true;initial-value:180deg}
.halo{position:fixed;inset:0;width:100vw;height:100vh;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden;pointer-events:none;z-index:var(--z-toast);--halo-origin:135deg;--halo-spread:180deg;
 -webkit-mask-image:conic-gradient(from calc(var(--halo-origin) - var(--halo-spread)),currentColor 0deg calc(var(--halo-spread) * 2),transparent calc(var(--halo-spread) * 2));mask-image:conic-gradient(from calc(var(--halo-origin) - var(--halo-spread)),currentColor 0deg calc(var(--halo-spread) * 2),transparent calc(var(--halo-spread) * 2));
 opacity:1;transition:opacity 220ms var(--ease-out-soft)}
.halo:not([popover])[hidden],.halo[popover]:not(:popover-open){display:none}
.halo::backdrop{display:none}
.halo-glow,.halo-band{position:absolute;inset:0;overflow:hidden}
/* the band: a crisp 4-12px edge; the glow: a soft 26px edge whose opacity follows the voice */
.halo-band{opacity:.75;-webkit-mask-image:linear-gradient(to right,currentColor 4px,transparent 12px),linear-gradient(to left,currentColor 4px,transparent 12px),linear-gradient(to bottom,currentColor 4px,transparent 12px),linear-gradient(to top,currentColor 4px,transparent 12px);mask-image:linear-gradient(to right,currentColor 4px,transparent 12px),linear-gradient(to left,currentColor 4px,transparent 12px),linear-gradient(to bottom,currentColor 4px,transparent 12px),linear-gradient(to top,currentColor 4px,transparent 12px)}
.halo-glow{opacity:.5;-webkit-mask-image:linear-gradient(to right,currentColor,transparent 26px),linear-gradient(to left,currentColor,transparent 26px),linear-gradient(to bottom,currentColor,transparent 26px),linear-gradient(to top,currentColor,transparent 26px);mask-image:linear-gradient(to right,currentColor,transparent 26px),linear-gradient(to left,currentColor,transparent 26px),linear-gradient(to bottom,currentColor,transparent 26px),linear-gradient(to top,currentColor,transparent 26px)}
.halo-spin{position:absolute;left:50%;top:50%;width:150vmax;height:150vmax;margin:-75vmax 0 0 -75vmax;border-radius:50%;background:conic-gradient(from 0deg,var(--halo-ember),var(--halo-gold) 22%,var(--halo-hi) 38%,var(--halo-rose) 55%,var(--halo-ember) 72%,var(--halo-gold) 88%,var(--halo-ember));will-change:transform;animation:halo-spin 4.5s linear infinite}
@keyframes halo-spin{to{transform:rotate(1turn)}}
@keyframes halo-open{from{--halo-spread:0deg}to{--halo-spread:180deg}}
@keyframes halo-close{from{--halo-spread:180deg}to{--halo-spread:0deg}}
@keyframes halo-shimmer{0%,100%{opacity:.4}50%{opacity:.75}}
.halo[data-state="opening"]{animation:halo-open 620ms var(--ease-out-soft) both}
.halo[data-state="closing"]{animation:halo-close 320ms cubic-bezier(.4,0,.6,1) both}
.halo[data-state="thinking"] .halo-spin{animation-duration:9s}
.halo[data-state="thinking"] .halo-glow{animation:halo-shimmer 1.6s ease-in-out infinite}
/* reduced motion: no sweep and no spin; a static soft edge glow that fades in and out */
.halo[data-motion="reduce"],.halo[data-motion="reduce"][data-state]{animation:none;--halo-spread:180deg}
.halo[data-motion="reduce"] .halo-spin,.halo[data-motion="reduce"] .halo-glow{animation:none}
.halo[data-motion="reduce"][data-state="closing"]{opacity:0}
@media (prefers-reduced-motion:reduce){
 .halo,.halo[data-state]{animation:none;--halo-spread:180deg}
 .halo .halo-spin,.halo .halo-glow{animation:none}
 .halo[data-state="closing"]{opacity:0}
}

/* ---------- the assistant sheet: a bottom sheet on phones, a panel anchored above the mic on desktop ---------- */
.ui-sheet.cortex-sheet[data-variant="center"]{inset:auto calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) auto;margin:0;width:min(440px,calc(100vw - 48px));max-height:min(680px,calc(100dvh - 48px - var(--kb-offset)))}
.ui-sheet.cortex-sheet::backdrop{background:var(--scrim-panel)}
.cortex-sheet .ui-sheet-title{display:flex;align-items:center;gap:8px}
.ai{display:flex;flex-direction:column;gap:12px}
.ai-top{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:36px}
.ai-state{font:500 14px/20px var(--font);color:var(--text-2)}
.ai-lang{flex:none}
.ai-context{display:flex;align-items:center;gap:6px;margin:0;font:400 13px/18px var(--font);color:var(--muted)}
.ai-context .icon{color:var(--accent-icon)}
.ai-consent[hidden]{display:none}
.ai-transcript{min-height:52px;margin:0;padding:12px 14px;border-radius:var(--r);background:var(--well);border:1px solid var(--line-soft);font:500 17px/24px var(--font);color:var(--text-strong);overflow-wrap:anywhere}
.ai-interim{color:var(--muted);font-weight:400}
.ai-hint{font:400 14px/20px var(--font);color:var(--muted)}
.ai-controls{display:flex;align-items:flex-end;gap:10px}
.ai-mic{display:grid;flex:none;place-items:center;width:56px;height:56px;padding:0;border:1.5px solid var(--accent-border);border-radius:50%;background:var(--accent-tint-soft);color:var(--accent-icon);cursor:pointer;transition:transform var(--dur-press) var(--ease-out-soft),background-color var(--dur-quick) ease,box-shadow var(--dur-quick) ease}
.ai-mic:hover{background:var(--accent-tint)}
.ai-mic:active{transform:scale(.97)}
.ai-mic.is-on{background:var(--accent);color:var(--on-accent);border-color:transparent;box-shadow:var(--glow-accent)}
.ai-mic:focus-visible{outline:2px solid var(--focus-ring);outline-offset:3px}
/* Ember Means Act: while the dictation consent banner shows, its "Turn on dictation" is the only ember; the mic waits neutral */
.ai-consent:not([hidden])~.ai-controls .ai-mic{border-color:var(--line-strong);background:transparent;color:var(--text-2);box-shadow:none}
.ai-type{display:flex;flex:1;align-items:flex-end;gap:8px;min-width:0}
.ui-sheet .ai-type textarea{flex:1;min-height:44px;max-height:140px;resize:none;padding-block:11px}
.ai-send.btn{flex:none;width:44px;min-height:44px;height:44px;padding:0}
.ai-basic{display:flex;align-items:center;gap:6px;margin:0;font:400 12px/16px var(--font);color:var(--muted)}
.ai-basic[hidden]{display:none}
.ai-results{display:flex;flex-direction:column;gap:10px}
.ai-results:empty{display:none}

/* a confirm card: the lead chip, the date and time chips, the remark; one tap on Apply */
.ai-card{display:flex;flex-direction:column;gap:10px;padding:14px;border:1px solid var(--line);border-radius:var(--r-lg);background:var(--surface-sheen),var(--surface);box-shadow:var(--shadow-card)}
.ai-card.is-applied{border-color:color-mix(in srgb,var(--success) 35%,transparent)}
.ai-card-skeleton{gap:8px}
.ai-card-skeleton .skeleton-line:last-child{width:60%}
.ai-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:4px 10px}
.ai-kind{font:600 12px/16px var(--font);color:var(--accent-text)}
.ai-line{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.ai-arrow{color:var(--muted)}
.ai-plain{font:500 14px/20px var(--font);color:var(--text-strong)}
.ai-plain b{font-weight:600}
.ai-lead .icon,.ai-when .icon{color:var(--accent-icon)}
.ai-lead.is-missing{border-style:dashed;border-color:var(--accent-border);color:var(--text-2)}
.ai-lead span{max-width:240px;overflow:hidden;text-overflow:ellipsis}
.ai-unlink.btn-icon{width:32px;height:32px;margin-left:-4px}
.ai-warn{font:500 12px/16px var(--font);color:var(--warn)}
.ai-when-edit{display:flex;flex-direction:column;gap:8px;padding:10px;border-radius:var(--r);background:var(--well);border:1px solid var(--line-soft)}
.ai-pick{display:flex;align-items:center;gap:8px;font:500 13px/18px var(--font);color:var(--muted)}
.ui-sheet .ai-pick input{width:auto;min-width:0;flex:0 1 200px}
.ai-lead-search{display:flex;flex-direction:column;gap:8px}
.ai-field{display:flex;flex-direction:column;gap:6px}
.ai .field-label{font:500 12px/16px var(--font);color:var(--muted)}
.ui-sheet .ai-field textarea{min-height:64px}
.ai-small{margin:0;font:400 12px/16px var(--font);color:var(--muted)}
.ai-card-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px}
.ai-reason{margin-right:auto;font:400 13px/18px var(--font);color:var(--muted)}
.ai-reason:empty{display:none}
.ai-done{display:inline-flex;align-items:center;gap:6px;margin-right:auto;font:500 14px/20px var(--font);color:var(--success)}
.cortex-sheet .ai-foot-note{flex:1 1 100%;margin:0;font:400 13px/18px var(--font);color:var(--muted)}
.cortex-sheet .ai-foot-note:empty{display:none}

/* ---------- touch ---------- */
@media (pointer:coarse){
 .ai-unlink.btn-icon{width:44px;height:44px}
}

/* ---------- phone: the mic floats on every screen above the tab bar, clear of ＋ and the banner ---------- */
@media (max-width:767px){
 .fab-new{display:none}
 .fab-cluster{right:max(16px,env(safe-area-inset-right));bottom:calc(64px + 16px + env(safe-area-inset-bottom))}
 /* with the lead panel open the mic stays, 16px above its footer bar (Log call row, the Save bar or the discard row; its
    height is measured into --drawer-foot and already holds the safe area), so it never covers a Save; a locked panel
    has no footer, so the safe area is kept instead */
 #drawer.show~.fab-cluster{bottom:calc(max(var(--drawer-foot,72px),env(safe-area-inset-bottom)) + 16px)}
 html.kb-open .fab-cluster{display:none}
 #main,.app[data-view] #main{padding-bottom:calc(64px + env(safe-area-inset-bottom) + 88px)}
 .ai-transcript{font-size:16px;line-height:22px}
}
@media (prefers-reduced-motion:reduce){
 .fab-mic,.fab-new,.ai-mic,.fab-cluster{transition:none}
}
@media (forced-colors:active){
 .fab-mic,.fab-new,.ai-mic{border:1px solid CanvasText}
 .halo{display:none}
}
