/* VYSHKA · windows / modals / sheets — personal soft motion + stacking
 * Scope: Account login · consent · invite · call UI · assist FAB · Voice sheets
 * Canon: Onest/Unbounded · cobalt #1d4ed8 · light-first · no purple slop
 * 2026-07-31 WINDOWS_MODALS_HONEST_FIX
 */
:root {
  --vy-win-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --vy-win-z-sheet: 1300;
  --vy-win-z-assist: 1450;
  --vy-win-z-consent-btn: 1460;
  --vy-win-z-consent: 2147483000;
  --vy-win-z-call: 2300;
  --vy-win-z-switcher: 6000;
}

/* Soft enter for any role=dialog surface */
@keyframes vy-win-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes vy-win-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes vy-win-sheet-up {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  body[data-page="account"] .dialog,
  body[data-page="invite"] .card,
  .vy-analytics-consent:not([hidden]),
  .vapi-modal-scrim.on .vapi-modal,
  .vmodal-scrim .vmodal,
  .tg-call-ui:not([hidden]) {
    animation: vy-win-rise 0.55s var(--vy-win-ease) both;
  }
  .vm-sheet-scrim.vm-open .vm-sheet {
    animation: vy-win-sheet-up 0.32s var(--vy-win-ease) both;
  }
  .vy-analytics-consent:not([hidden]) {
    transition: opacity 0.28s var(--vy-win-ease), transform 0.34s var(--vy-win-ease);
  }
}

/* ── Account status: always readable near active method ───────────────────── */
body[data-page="account"] #status.status {
  min-height: 0;
  margin: 10px 0 4px;
  padding: 0;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
  scroll-margin: 96px 0 48px;
}
body[data-page="account"] #status.status:not(:empty) {
  padding: 12px 14px;
  border: 1px solid rgba(29, 78, 216, 0.14);
  background: rgba(239, 246, 255, 0.92);
  color: #1e3a8a;
}
body[data-page="account"] #status.status.error:not(:empty) {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff1f0;
  color: #b42318;
  font-weight: 800;
  box-shadow: 0 10px 28px -18px rgba(180, 35, 24, 0.45);
}
body[data-page="account"] #status.status.ok:not(:empty) {
  border-color: rgba(8, 116, 67, 0.24);
  background: #ecfdf5;
  color: #087443;
}
@media (prefers-reduced-motion: no-preference) {
  body[data-page="account"] #status.status:not(:empty) {
    animation: vy-win-rise 0.38s var(--vy-win-ease) both;
  }
}

/* ── Consent: above FAB, soft animation, readable taps ─────────────────────── */
.vy-analytics-consent {
  z-index: var(--vy-win-z-consent) !important;
}
.vy-analytics-settings {
  z-index: var(--vy-win-z-consent-btn) !important;
  bottom: max(18px, env(safe-area-inset-bottom, 0px)) !important;
  left: max(12px, env(safe-area-inset-left, 0px)) !important;
  right: auto !important;
}
.vy-analytics-consent button {
  min-height: 48px !important;
}

/* ── Assist FAB: never cover Messenger composer / Voice chrome ───────────── */
html body[data-page="messenger"] .vy-eco-assist,
html body[data-page="voice"] .vy-eco-assist {
  z-index: var(--vy-win-z-assist) !important;
  bottom: max(78px, calc(64px + env(safe-area-inset-bottom, 0px))) !important;
}
html body[data-page="messenger"] .vy-eco-assist[data-open="true"] .vy-eco-assist__fab {
  /* Panel owns controls while open — FAB must not sit on the composer */
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(8px) scale(0.94) !important;
}
html body[data-page="messenger"] .vy-eco-assist[data-open="false"] .vy-eco-assist__fab,
html body[data-page="messenger"] .vy-eco-assist:not([data-open="true"]) .vy-eco-assist__fab {
  max-width: min(240px, calc(100vw - 100px));
}

/* ── Call UI: soft presence + readable controls ──────────────────────────── */
.tg-call-ui {
  z-index: var(--vy-win-z-call) !important;
}
.tg-call-ui[hidden] {
  display: none !important;
  animation: none !important;
}
.tg-call-ui:not([hidden]) {
  backdrop-filter: blur(8px) saturate(120%);
}
.tg-call-ctrl {
  min-width: 58px;
  min-height: 58px;
  transition: transform 0.22s var(--vy-win-ease), background 0.2s ease, filter 0.2s ease;
}
.tg-call-ctrl:hover {
  transform: translateY(-2px) scale(1.04);
}
.tg-call-ui__login:not([hidden]) {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  margin-top: 8px;
  border-radius: 14px;
  background: #1d4ed8;
  color: #fff !important;
  font: 700 14px/1 Onest, system-ui, sans-serif;
  text-decoration: none;
  box-shadow: 0 14px 32px -14px rgba(29, 78, 216, 0.7);
}

/* ── Voice invite / join modals ──────────────────────────────────────────── */
.vapi-modal-scrim.on,
.vmodal-scrim {
  backdrop-filter: blur(6px);
}
.vapi-modal,
.vmodal {
  border-radius: 18px !important;
}
.vapi-modal .b.grad,
.vapi-modal .b.ghost {
  min-height: 44px;
}

/* ── Invite page card as a personal window ───────────────────────────────── */
body[data-page="invite"] .card {
  border-radius: 24px;
  box-shadow: 0 24px 56px -28px rgba(15, 47, 104, 0.28);
}
body[data-page="invite"] #msg.err:not(:empty) {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: #fff1f0;
  color: #b42318;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.45;
}
body[data-page="invite"] #join.btn.primary {
  min-height: 52px;
  transition: transform 0.22s var(--vy-win-ease), box-shadow 0.22s ease, filter 0.2s ease;
}
body[data-page="invite"] #join.btn.primary:not(:disabled):hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

/* ── Sheets stacking ─────────────────────────────────────────────────────── */
.vm-sheet-scrim { z-index: var(--vy-win-z-sheet) !important; }
.vm-sheet { z-index: calc(var(--vy-win-z-sheet) + 1) !important; }

@media (prefers-reduced-motion: reduce) {
  body[data-page="account"] .dialog,
  body[data-page="invite"] .card,
  .vy-analytics-consent,
  .vapi-modal,
  .tg-call-ui,
  .vm-sheet,
  body[data-page="account"] #status.status {
    animation: none !important;
    transition: none !important;
  }
}

/* Assist restore after junk-purge overkill — WINDOWS_MODALS */
html body[data-page="messenger"] .vy-eco-assist {
  display: block !important;
  visibility: visible !important;
  pointer-events: none !important;
  height: auto !important;
  width: fit-content !important;
  overflow: visible !important;
  z-index: 1450 !important;
  opacity: 1 !important;
}
html body[data-page="messenger"] .vy-eco-assist .vy-eco-assist__fab,
html body[data-page="messenger"] .vy-eco-assist .vy-eco-assist__panel,
html body[data-page="messenger"] .vy-eco-assist button,
html body[data-page="messenger"] .vy-eco-assist textarea,
html body[data-page="messenger"] .vy-eco-assist a {
  pointer-events: auto !important;
}
html body[data-page="messenger"] .vy-eco-assist[data-open="true"] .vy-eco-assist__panel {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  width: min(380px, calc(100vw - 28px)) !important;
  overflow: hidden !important;
  z-index: 1451 !important;
}
html body[data-page="messenger"] .vy-eco-assist:not([data-open="true"]) .vy-eco-assist__panel {
  display: none !important;
}
html body[data-page="messenger"] .vy-eco-assist:not([data-open="true"]) .vy-eco-assist__fab {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  width: auto !important;
  min-width: 48px !important;
  overflow: visible !important;
}

/* Cookie / first-party note: soft, not covering primary CTA */
body[data-page="account"] .cookie-note:not([hidden]) {
  z-index: 1200;
}
@media (prefers-reduced-motion: no-preference) {
  body[data-page="account"] .cookie-note:not([hidden]) {
    animation: vy-win-rise 0.45s var(--vy-win-ease) both;
  }
}
body[data-page="account"]:has(.cookie-note:not([hidden])) main.shell {
  padding-bottom: max(120px, calc(96px + env(safe-area-inset-bottom, 0px)));
}

/* Stamp for LIVE verify */
html[data-vy-windows-modals="1"] body::after {
  content: none;
}
