/* Clay Org, round 6: the rise from world to sky to map, moving things by hand, calls, and the
   building picker's previews. Kept apart from styles.css so the round reads as one piece; it
   uses the same tokens (and the same glass) and loads after it. */

/* ------------------------------------------------------------------ the haze
   Between the sky and the map the camera climbs through a layer of cloud. Three soft fields of
   radial gradients, opening outwards from the centre as --hz (0 → 1) grows, thickest halfway.
   By night they are a cool grey rather than white. Purely decorative and never hit-tested. */

.haze { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; visibility: hidden; overflow: hidden; --hz: 0; --haze-c: 236 240 246; }
:root[data-theme='night'] .haze { --haze-c: 120 132 152; }
.haze i { position: absolute; inset: -40%; display: block; will-change: transform; }
/* Two cloud fields at different scales open outwards past the camera as it climbs (--hz 0 → 1),
   over a soft wash that is thickest halfway. */
.haze .hz-a { background: var(--cloud) 0 0 / 720px 720px repeat; transform: scale(calc(0.8 + var(--hz) * 1.5)) rotate(calc(var(--hz) * 5deg)); filter: blur(1.5px); }
.haze .hz-b { background: var(--cloud) 300px 180px / 460px 460px repeat; transform: scale(calc(1 + var(--hz) * 2.3)) rotate(calc(var(--hz) * -7deg)); opacity: 0.85; filter: blur(3px); }
.haze .hz-c {
  background: radial-gradient(60% 50% at 50% 50%, rgb(var(--haze-c) / 0.7), rgb(var(--haze-c) / 0.25) 60%, rgb(var(--haze-c) / 0.1) 100%);
  transform: scale(calc(0.7 + var(--hz) * 2.2));
  opacity: calc(1 - var(--hz) * 0.5);
}
:root[data-theme='night'] .haze .hz-a, :root[data-theme='night'] .haze .hz-b { filter: blur(2px) brightness(0.62) saturate(0.8); }
:root { --haze-night: 0; }
.haze { filter: brightness(calc(1 - var(--haze-night) * 0.35)); }

/* ------------------------------------------------------------------ the building picker
   Each type is a card: a real preview of its model on a plot (rendered in the current theme,
   glass and light), the name, the footprints it comes in, and one line of what it is for. */

#dlg-site { width: min(860px, calc(100vw - 24px)); }
#dlg-site .type-list { max-height: min(54vh, 520px); }
#dlg-site .type-grid { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 8px; }
.type-opt.has-pv span { padding: 6px 8px 8px; gap: 1px; border-radius: 10px; height: 100%; }
.type-pv { display: block; width: 100%; aspect-ratio: 168 / 104; margin: 0 0 5px; border-radius: 7px; background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 70%, var(--card)) 0%, var(--card-2) 100%); }
:root[data-light='night'] .type-pv { background: linear-gradient(180deg, #2b3446 0%, #3a4356 100%); }
:root[data-light='sunrise'] .type-pv, :root[data-light='sunset'] .type-pv { background: linear-gradient(180deg, #f3e3d6 0%, #ece6e0 100%); }
.type-opt .type-foot { font-style: normal; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.type-opt.has-pv small { line-height: 1.35; }
.type-opt.has-pv:hover .type-pv { box-shadow: inset 0 0 0 1px var(--line-2); }

/* ------------------------------------------------------------------ the account menu
   Who you are viewing as. The roles are simulated; they decide what you can pick up. */

.acct-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 3px 8px 3px 3px; cursor: pointer; height: 30px; font-size: 12px; color: var(--ink); }
.acct-btn:hover { background: var(--card-2); }
.acct-btn .caret { width: 0; height: 0; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 4px solid var(--ink-3); }
.acct-av { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 600; background: var(--ink); color: var(--card); flex: none; letter-spacing: 0.02em; }
.acct-av.sm { width: 22px; height: 22px; margin-top: 1px; }
.acct-menu { min-width: 330px; left: auto; right: 0; }
.acct-menu [role=menuitemradio] { align-items: flex-start; }
.acct-badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 9px; font-size: 10px; font-weight: 600; padding: 1px 6px; align-self: center; }
.acct-menu [role=menuitemradio][aria-checked="true"] .acct-badge { margin-left: 6px; }
@media (max-width: 1180px) { .acct-role, .acct-btn .caret { display: none; } .acct-btn { padding: 3px; } }

/* ------------------------------------------------------------------ picking things up
   The chip that follows the pointer while something is carried: what it is, and what dropping
   it here will do. A lock when it is not yours to move. */

body.lifting, body.lifting * { cursor: grabbing !important; }
.lift { position: fixed; left: 0; top: 0; z-index: 72; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); max-width: 300px; box-shadow: 0 12px 30px -10px rgba(20, 28, 40, 0.45); animation: lift-in 140ms var(--ease); }
@keyframes lift-in { from { opacity: 0; transform: scale(0.94); } }
.lift-g { position: relative; display: grid; place-items: center; flex: none; }
.lift-t { display: flex; flex-direction: column; min-width: 0; }
.lift-t b { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lift-t small { font-size: 11px; color: var(--ink-3); line-height: 1.3; }
.lift.ok { border-color: color-mix(in srgb, var(--ok) 60%, var(--line)); }
.lift.ok .lift-t small { color: var(--ok); }
.lift.locked .lift-t small { color: var(--ink-2); }
.lift-lock, .mv-lock { position: absolute; right: -5px; bottom: -5px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); color: var(--card); display: grid; place-items: center; box-shadow: 0 0 0 1.5px var(--card); }
.lift-lock svg, .mv-lock svg { width: 9px; height: 9px; }
/* The source the thing was picked up from fades a little while it is carried. */
.lifting.p-hit, .r-row.lifting, .r-face.lifting, .pf.lifting { opacity: 0.45; }
body.lifting .p-hit.lifting { pointer-events: none; }

.move-confirm { position: fixed; left: 0; top: 0; z-index: 64; width: 280px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; gap: 4px; animation: pop 140ms var(--ease); }
.move-confirm p:first-child { font-size: 13px; }
.mc-actions { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.mc-actions .icon-btn { margin-left: auto; }

.undo-toast { position: fixed; bottom: 112px; left: var(--gap-cx); transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; max-width: min(620px, calc(100vw - 24px)); animation: rise 200ms var(--ease); }
.undo-toast .ut-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-toast .btn svg { margin-right: 3px; vertical-align: -2px; }
.undo-toast .ut-x { border: 0; background: transparent; }

.ticker li.note .thing { background: color-mix(in srgb, var(--ok) 16%, var(--card)); color: var(--ok); }
.ticker li.note.call .thing { background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent-ink); }

/* Requests to move, at the top of the side panel for whoever approves them. */
.mv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mv-req { display: flex; gap: 9px; padding: 7px 4px; align-items: flex-start; }
.mv-face { position: relative; flex: none; margin-top: 2px; }
.mv-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mv-text b { font-weight: 600; font-size: 12.5px; }
.mv-text small { font-size: 11.5px; color: var(--ink-2); line-height: 1.35; }
.mv-text .t-decide { display: flex; gap: 4px; margin-top: 6px; }
.mv-sec.asked h3 { color: var(--ink-3); }

/* The sky's line ends: drag one to another building to reconnect the agent. */
.route-handles { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
.route-end { position: absolute; left: 0; top: 0; width: 14px; height: 14px; padding: 0; border-radius: 50%; border: 2px solid #cfe0ff; background: rgba(16, 22, 36, 0.85); pointer-events: auto; cursor: grab; box-shadow: 0 0 0 3px rgba(169, 187, 216, 0.18), 0 0 10px rgba(169, 205, 255, 0.5); transition: box-shadow 160ms var(--ease), transform 0s; }
.route-end:hover, .route-end:focus-visible { box-shadow: 0 0 0 5px rgba(169, 187, 216, 0.3), 0 0 14px rgba(169, 205, 255, 0.8); }
.route-end.lifting { opacity: 0.35; }

/* ------------------------------------------------------------------ calls
   A ringing call is a card; a call in progress is a pill. Round 7 moved the stack beside the rail
   (round7.css) and gave the rail a row of live avatars instead of pushing it down. */

.rail { transition: width 220ms var(--ease), box-shadow 220ms var(--ease); }
.callstack { position: fixed; left: 10px; top: 62px; width: max(250px, calc(var(--rail-l) - 10px)); z-index: 30; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.callstack > * { pointer-events: auto; }
.cs-card, .cs-pill { position: relative; border: 1px solid var(--line); border-radius: 16px; background: var(--card); padding: 9px 10px 9px; display: flex; flex-direction: column; gap: 5px; overflow: hidden; animation: rise-l 220ms var(--ease); }
.cs-card { cursor: grab; touch-action: none; user-select: none; }
.cs-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cs-card.ringing { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent), 0 16px 34px -14px rgba(30, 50, 90, 0.45); }
.cs-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cs-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cs-who b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-who small { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-timer { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink-2); flex: none; }
.cs-where, .cs-wait { font-size: 11.5px; color: var(--ink-2); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.cs-where svg { color: var(--ink-3); }
.cs-wait b { font-weight: 600; }
.cs-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.cs-actions .btn svg { margin-right: 3px; vertical-align: -2px; }
.cs-actions .btn.on, .cv-actions .btn.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent-ink); }
.cs-end { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); }
.cs-end:hover { background: var(--danger); color: #fff; }
.cs-hint { font-size: 10.5px; color: var(--ink-3); }
.cs-menu { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--card); }
.cs-menu [role=menuitem] { border: 0; background: transparent; text-align: left; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 12px; display: flex; gap: 7px; align-items: center; line-height: 1.35; }
.cs-menu [role=menuitem]:hover, .cs-menu [role=menuitem]:focus-visible { background: var(--card-2); outline: none; }
.cs-menu small { margin-left: auto; color: var(--ink-3); font-size: 11px; }

/* The caller's face rings: two soft waves leave it while the call waits. */
.cs-face { --s: 34px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; display: grid; place-items: center; font-size: calc(var(--s) * 0.36); font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 60%, transparent); position: relative; }
.cs-face.ringing::before, .cs-face.ringing::after { content: ''; position: absolute; inset: -1px; border-radius: 50%; border: 1.5px solid var(--accent); opacity: 0; animation: cs-wave 1.8s var(--ease) infinite; }
.cs-face.ringing::after { animation-delay: 0.9s; }
@keyframes cs-wave { 0% { transform: scale(1); opacity: 0.55; } 100% { transform: scale(1.75); opacity: 0; } }

/* Hold to answer by voice: a fill grows across the card. */
.cs-hold { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--hold, 0) * 100%); background: var(--ok); border-radius: 0 2px 2px 0; pointer-events: none; }
.cs-card.holding { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 60%, transparent), 0 16px 34px -14px rgba(30, 50, 90, 0.45); }
.cs-card.lifting { opacity: 0.5; }

/* The live pill: a waveform that moves while someone speaks, and the rolling transcript. */
.cs-pill.agent { box-shadow: 0 0 0 1px color-mix(in srgb, #8fb3ef 55%, transparent), 0 14px 30px -14px rgba(60, 90, 150, 0.45); }
.cs-pill.stuck { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--orange) 80%, transparent), 0 14px 30px -14px rgba(160, 90, 30, 0.45); }
.cs-pill .face.agent { flex: none; }
.cs-wave { display: flex; align-items: center; gap: 2px; height: 18px; flex: none; }
.cs-wave i { width: 2.5px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 70%, var(--ink-3)); transition: height 120ms ease; }
.cs-wave.on i { animation: cs-bar 0.9s ease-in-out infinite; }
.cs-wave.on i:nth-child(2) { animation-delay: -0.2s; } .cs-wave.on i:nth-child(3) { animation-delay: -0.45s; } .cs-wave.on i:nth-child(4) { animation-delay: -0.1s; }
.cs-wave.on i:nth-child(5) { animation-delay: -0.6s; } .cs-wave.on i:nth-child(6) { animation-delay: -0.3s; } .cs-wave.on i:nth-child(7) { animation-delay: -0.75s; }
@keyframes cs-bar { 0%, 100% { height: 4px; } 50% { height: 16px; } }
.cs-pill.stuck .cs-wave i { background: var(--orange); }
.cs-line { font-size: 12px; line-height: 1.4; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.cs-line b { font-weight: 600; color: var(--ink-2); }
.cs-caret { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 4px; vertical-align: middle; animation: breathe 1s ease-in-out infinite; }
.cs-ask { display: flex; align-items: center; gap: 6px; font-size: 12px; background: var(--orange-soft); color: #7a4515; border-radius: 9px; padding: 5px 6px 5px 8px; }
.cs-ask span { flex: 1; line-height: 1.3; }
:root[data-theme='night'] .cs-ask { color: var(--orange-1); }
.cs-whisper { display: flex; gap: 4px; align-items: center; }
.cs-whisper input { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 8px; font-size: 12px; background: var(--card); }
.cs-mic { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; }
.cs-mic.rec { background: var(--danger); color: #fff; border-color: var(--danger); animation: breathe 1s ease-in-out infinite; }

/* A ringing building: its label pulses, and a ring glyph sits by its face pile. */
.lbl.site.ringing { box-shadow: 0 0 0 0 rgba(91, 125, 177, 0.5); animation: lbl-ring 1.6s var(--ease) infinite; border-color: var(--accent) !important; }
@keyframes lbl-ring { 0% { box-shadow: 0 0 0 0 rgba(91, 125, 177, 0.55); } 100% { box-shadow: 0 0 0 10px rgba(91, 125, 177, 0); } }
.ring-glyph { position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 0 0 2px var(--card); pointer-events: none; }
.ring-glyph i { display: grid; place-items: center; animation: ring-wiggle 1.2s ease-in-out infinite; }
@keyframes ring-wiggle { 0%, 60%, 100% { rotate: 0deg; } 10%, 30%, 50% { rotate: -14deg; } 20%, 40% { rotate: 14deg; } }

/* The call view in the side panel. */
.cv-summary { margin: 8px 0 4px; padding: 9px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 12px; line-height: 1.45; color: var(--ink); }
.cv-summary .eyebrow { color: var(--accent-ink); }
.cv-wave { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; }
.cv-wave canvas { flex: 1; min-width: 0; height: 40px; border-radius: 8px; background: var(--card-2); }
.cv-transcript { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.tl { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; line-height: 1.4; padding: 6px 9px; border-radius: 10px; background: var(--card-2); max-width: 92%; }
.tl b { font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
.tl.agent { background: color-mix(in srgb, #8fb3ef 16%, var(--card)); }
.tl.caller { align-self: flex-end; }
.tl.me { background: color-mix(in srgb, var(--ok) 15%, var(--card)); }
.tl.whisper { align-self: center; background: transparent; border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); color: var(--accent-ink); }
.tl.whisper b { color: var(--accent-ink); display: flex; gap: 4px; align-items: center; }
.tl.note { align-self: center; background: transparent; color: var(--ink-3); font-size: 11px; padding: 2px; }
.tl.live span::after { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-left: 4px; vertical-align: middle; animation: breathe 1s ease-in-out infinite; }
.cv-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.cv-actions .btn svg { margin-right: 3px; vertical-align: -2px; }
.cv-row { display: flex; gap: 4px; flex-wrap: wrap; }
.cv-menu { width: 100%; }
.sd-sec .cs-whisper { margin-top: 2px; }
.mv-face .cs-face { --s: 26px; }

/* The phone screen: under 820 px a new call takes over the screen for a moment. */
.callscreen { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: color-mix(in srgb, #0e1320 72%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3); animation: fade-in 200ms ease; }
@keyframes fade-in { from { opacity: 0; } }
.csn { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #eef2f8; text-align: center; padding: 24px; width: min(360px, 100vw); }
.csn-eyebrow { font-size: 12px; color: #b9c4d6; display: flex; gap: 6px; align-items: center; margin-bottom: 18px; }
.csn .cs-face { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35); }
.csn .cs-face.ringing::before, .csn .cs-face.ringing::after { border-color: rgba(220, 230, 255, 0.7); }
.csn h2 { font-size: 26px; font-weight: 600; margin-top: 10px; }
.csn-where { font-size: 13px; color: #b9c4d6; }
.csn-timer { font-size: 13px; color: #8f9bb0; font-variant-numeric: tabular-nums; }
.csn-actions { display: flex; gap: 26px; margin-top: 46px; }
.csn-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: transparent; color: #eef2f8; font-size: 12px; cursor: pointer; }
.csn-btn > span { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.14); }
.csn-btn.answer > span { background: #4f9a6c; }
.csn-btn.decline > span { background: #c0574d; }
.csn-btn .face.agent { display: grid; place-items: center; }
.csn-later { margin-top: 26px; border: 0; background: transparent; color: #b9c4d6; font-size: 12px; text-decoration: underline; cursor: pointer; }

body.focus-mode .callstack { top: 62px; }
@media (max-width: 999px) {
  .callstack { width: min(300px, calc(100vw - 24px)); }
}
@media (prefers-reduced-motion: reduce) {
  .cs-face.ringing::before, .cs-face.ringing::after, .ring-glyph i, .lbl.site.ringing, .cs-wave.on i, .cs-caret, .tl.live span::after { animation: none !important; }
  .cs-wave.on i { height: 10px; }
}
.pin[data-asset-id] { cursor: grab; }
.cs-where { gap: 2px 8px; }
.cs-line-id { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; color: var(--ink-3); }
/* In Focus the calls keep their place top left, and Focus moves over to make room for them. */
@media (min-width: 1000px) {
  body.focus-mode.has-calls .focus { left: calc(50% + 136px); width: min(1320px, calc(100vw - 296px)); }
}
/* Over the dark sky the round's floating glass is denser, like the rails, so its type stays legible. */
:root:not([data-glass='off']) body.dark :is(.cs-card, .cs-pill, .lift, .undo-toast, .move-confirm).glass { background-color: rgb(var(--glass-tint) / 0.9); }
body.placing .p-hits, body.placing .piles, body.placing .ring-glyph { pointer-events: none !important; }
body.placing .p-hits > *, body.placing .piles * { pointer-events: none !important; }
