/* VYSHKA Cloud product switcher — ONE shell (CHAT A 2026-07-31)
 * Canon: Onest · Unbounded · cobalt #1d4ed8 · icon-first · 390 / 1280
 * ONE_TOP_CHROME: geometry/z from vyshka-ecosystem-one.css shared vars */
.vy-product-switcher {
  position: fixed;
  top: max(10px, calc((var(--vy-chrome-h, 52px) - var(--vy-services-fab, 52px)) / 2 + env(safe-area-inset-top, 0px)));
  right: max(var(--vy-chrome-pad-x, 14px), env(safe-area-inset-right, 0px));
  z-index: var(--vy-z-services, 1600);
  font: 14px/1.35 var(--vy-font-body, "Onest", "Segoe UI", system-ui, sans-serif);
  color: var(--vy-text, #111827);
}

.vy-product-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 13px 0 8px;
  border: 1px solid var(--vy-line, #d8e1ec);
  border-radius: 14px;
  background: color-mix(in srgb, var(--vy-surface, #fff) 92%, transparent);
  color: inherit;
  box-shadow: 0 8px 24px rgba(15, 47, 104, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  transition: transform 220ms cubic-bezier(.16,1,.3,1), border-color 220ms ease, box-shadow 220ms ease;
}

.vy-product-launcher::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid color-mix(in srgb, #1d4ed8 40%, transparent);
  border-radius: 18px;
  opacity: 0;
  transform: scale(.86);
  pointer-events: none;
}
.vy-product-launcher:hover {
  border-color: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(29, 78, 216, 0.16);
}
.vy-product-launcher:hover::after { animation: vy-switcher-ring 1.1s ease-out; }
.vy-product-launcher:focus-visible {
  outline: 3px solid var(--vy-sky, #38bdf8);
  outline-offset: 3px;
}
.vy-product-launcher[aria-expanded="true"] {
  border-color: #1d4ed8;
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.22);
}

.vy-product-launcher__mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1d4ed8, #38bdf8 58%, #2ccf9b);
  background-size: 160% 160%;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 5px 14px rgba(29, 78, 216, 0.24);
}
@media (prefers-reduced-motion: no-preference) {
  .vy-product-launcher:hover .vy-product-launcher__mark {
    animation: vy-mark-drift 2.4s ease-in-out infinite;
  }
}
@keyframes vy-mark-drift {
  0%, 100% { background-position: 0% 40%; }
  50% { background-position: 100% 60%; }
}
.vy-product-launcher__mark img,
.vy-product-card__icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vy-product-launcher__chevron {
  transition: transform 200ms ease;
}
.vy-product-launcher[aria-expanded="true"] .vy-product-launcher__chevron {
  transform: rotate(180deg);
}

.vy-product-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 6000;
  width: min(420px, calc(100vw - 28px));
  max-height: min(78vh, 640px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--vy-line, #d8e1ec);
  border-radius: 20px;
  background: var(--vy-surface, #fff);
  color: inherit;
  box-shadow: 0 24px 60px rgba(15, 47, 104, 0.16);
  transform-origin: top right;
  animation: vy-panel-in 240ms cubic-bezier(.16,1,.3,1);
}
.vy-product-panel[hidden] { display: none; }

/* Portaled to body when Messenger (or any transformed ancestor) would clip fixed coords */
.vy-product-panel[data-vy-portaled="1"] {
  position: fixed !important;
  top: max(56px, env(safe-area-inset-top, 0px)) !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 28px)) !important;
  max-height: min(78vh, 640px) !important;
  z-index: var(--vy-z-services-panel, 7000) !important;
  overflow: auto;
  opacity: 1 !important;
  pointer-events: auto !important;
  display: block !important;
  visibility: visible !important;
  animation: vy-panel-in 260ms cubic-bezier(.16,1,.3,1) both;
}
body.vy-product-panel-open .vy-product-panel[data-vy-portaled="1"]:not([hidden]) {
  display: block !important;
  opacity: 1 !important;
}
.vy-product-switcher.is-open .vy-product-launcher,
.vy-product-switcher[data-open="true"] .vy-product-launcher {
  border-color: #1d4ed8;
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.22);
  transform: translateY(-1px);
}

.vy-product-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.vy-product-panel__head strong {
  display: block;
  font-family: var(--vy-font-display, "Unbounded", "Avenir Next", system-ui, sans-serif);
  font-size: 16px;
  letter-spacing: -0.03em;
  color: #1e3a8a;
}
.vy-product-panel__head small {
  display: block;
  margin-top: 3px;
  color: var(--vy-muted, #475569);
  font-size: 12px;
}
.vy-product-panel__close {
  width: 44px;
  height: 44px;
  border: 1px solid var(--vy-line, #d8e1ec);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  flex: none;
}
.vy-product-panel__close:hover { border-color: #1d4ed8; color: #1d4ed8; }

.vy-product-panel__more {
  margin: 14px 2px 8px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--vy-muted, #475569);
}

.vy-product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.vy-product-grid[data-grid="secondary"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.vy-product-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  gap: 6px;
  min-height: 96px;
  padding: 12px 8px 10px;
  border: 1px solid var(--vy-line, #d8e1ec);
  border-radius: 14px;
  background: #f7f9fc;
  color: inherit;
  text-decoration: none;
  text-align: center;
  transition: transform 220ms cubic-bezier(.16,1,.3,1), border-color 220ms ease, box-shadow 220ms ease, background 220ms ease;
  animation: vy-card-in 360ms cubic-bezier(.16,1,.3,1) both;
  animation-delay: var(--vy-i, 0ms);
}
.vy-product-card:hover {
  border-color: #1d4ed8;
  text-decoration: none;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px rgba(15, 47, 104, 0.12);
  background: #fff;
}
.vy-product-card:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}
.vy-product-card[data-current="true"] {
  border-color: #1d4ed8;
  box-shadow: inset 0 0 0 1px #1d4ed8, 0 8px 18px rgba(29, 78, 216, 0.12);
  background: #eff6ff;
}

.vy-product-card__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, #1d4ed8 12%, #fff);
  color: #1d4ed8;
}
.vy-product-card__icon svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vy-product-card__meta b {
  display: block;
  font-size: 12.5px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.vy-product-card__meta small {
  display: block;
  margin-top: 1px;
  color: var(--vy-muted, #475569);
  font-size: 10.5px;
  line-height: 1.2;
}
.vy-product-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #1f9d63;
  font-size: 10px;
  font-weight: 750;
}
.vy-product-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.vy-product-status[data-status="public-beta"] { color: #b45309; }
.vy-product-status[data-status="development"],
.vy-product-status[data-status="waitlist"] { color: #1d4ed8; }
.vy-product-status[data-status="planned"] { color: #64748b; }

.vy-product-panel__legal {
  margin: 14px 2px 0;
  color: var(--vy-muted, #475569);
  font-size: 11px;
}
.vy-product-panel__legal a { color: #1d4ed8; }

/* Per-product glyph accents — same on every service */
.vy-product-card[data-product="ecosystem"] .vy-product-card__icon { background: linear-gradient(135deg, #1d4ed8, #38bdf8); color: #fff; }
.vy-product-card[data-product="messenger"] .vy-product-card__icon { background: #e0f2fe; color: #0284c7; }
.vy-product-card[data-product="voice"] .vy-product-card__icon { background: linear-gradient(135deg, #1d4ed8, #38bdf8); color: #fff; }
.vy-product-card[data-product="store"] .vy-product-card__icon { background: #ecfdf5; color: #047857; }
.vy-product-card[data-product="files"] .vy-product-card__icon { background: #eff6ff; color: #1d4ed8; }
.vy-product-card[data-product="ai"] .vy-product-card__icon { background: #f0f9ff; color: #0369a1; }
.vy-product-card[data-product="remote"] .vy-product-card__icon { background: #f8fafc; color: #334155; }
.vy-product-card[data-product="video"] .vy-product-card__icon { background: #fef2f2; color: #b91c1c; }
.vy-product-card[data-product="leads"] .vy-product-card__icon { background: #fff7ed; color: #c2410c; }
.vy-product-card[data-product="account"] .vy-product-card__icon { background: #eef2ff; color: #1e40af; }
.vy-product-card[data-product="uslugi"] .vy-product-card__icon { background: #f0fdf4; color: #15803d; }
.vy-product-card[data-product="find"] .vy-product-card__icon { background: #e0e7ff; color: #1d4ed8; }
.vy-product-card[data-product="academy"] .vy-product-card__icon { background: #fffbeb; color: #a16207; }
.vy-product-card[data-product="dock"] .vy-product-card__icon { background: #f1f5f9; color: #475569; }

:root[data-theme="dark"] .vy-product-launcher,
:root[data-theme="dark"] .vy-product-panel {
  background: color-mix(in srgb, var(--vy-surface, #14181f) 94%, transparent);
  color: var(--vy-text, #e8eef7);
}
:root[data-theme="dark"] .vy-product-card { background: #1a2030; }

/* Desktop 1280+ */
@media (min-width: 1280px) {
  .vy-product-switcher {
    top: max(24px, env(safe-area-inset-top, 0px));
    right: max(24px, env(safe-area-inset-right, 0px));
  }
  .vy-product-panel { width: 440px; }
}

/* WAVE07 canon @≤640: ONE fixed thumb FAB (bottom-right) on every surface.
 * No static page-end · no top-icon fork · no messenger header slot on mobile.
 * CRITICAL: never set both top+bottom (that stretches into a full-height rail). */
@media (max-width: 640px) {
  html body .vy-product-switcher,
  html body > .vy-product-switcher,
  html body[data-page] > .vy-product-switcher,
  html body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-switcher,
  html body[data-page="messenger"] .vy-messenger-product-slot .vy-product-switcher,
  html body .vy-product-switcher:not([data-open="true"]):not(.is-open) {
    position: fixed !important;
    inset: unset !important;
    top: unset !important;
    left: unset !important;
    right: max(14px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(18px, calc(18px + env(safe-area-inset-bottom, 0px))) !important;
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    width: fit-content !important;
    max-width: 56px !important;
    height: fit-content !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    z-index: 1900 !important;
    justify-content: unset !important;
    overflow: visible !important;
  }
  /* Lift above Voice/Files tabbar when present */
  html body:has(.vm-tabbar) > .vy-product-switcher,
  html body:has(.vm-tabbar) .vy-product-switcher,
  html body:has(.vm-tabbar) .vy-product-switcher:not([data-open="true"]):not(.is-open) {
    bottom: max(86px, calc(72px + env(safe-area-inset-bottom, 0px))) !important;
  }
  .vy-product-launcher {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    min-height: 52px !important;
    height: 52px !important;
    padding: 0 !important;
    justify-content: center;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(15, 47, 104, 0.22);
  }
  .vy-product-launcher__label,
  .vy-product-launcher__chevron { display: none !important; }
  .vy-product-panel[hidden],
  .vy-product-switcher:not([data-open="true"]):not(.is-open) > .vy-product-panel {
    display: none !important;
  }
  .vy-product-panel:not([hidden]) {
    position: fixed !important;
    z-index: 1901 !important;
    top: max(10px, env(safe-area-inset-top, 0px)) !important;
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
    left: max(10px, env(safe-area-inset-left, 0px)) !important;
    width: auto !important;
    max-height: none !important;
    overflow: auto;
    transform-origin: bottom right;
    animation: vy-panel-sheet 280ms cubic-bezier(.16,1,.3,1);
  }
  .vy-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .vy-product-card { min-height: 108px; }

  /* Empty header slots — FAB is the only switcher on mobile */
  html body[data-page="messenger"] .vy-msg-switcher-slot:empty,
  html body[data-page="messenger"] .vy-messenger-product-slot:empty {
    display: none !important;
  }
}

/* Desktop / tablet: messenger may host compact launcher in header slot */
@media (min-width: 641px) {
  body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-switcher,
  body[data-page="messenger"] .vy-messenger-product-slot .vy-product-switcher {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    width: auto;
    padding: 0;
    z-index: 1500;
  }
  body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-launcher {
    width: 36px;
    min-height: 36px;
    padding: 0;
    justify-content: center;
    box-shadow: none;
  }
  body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-launcher__label,
  body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-launcher__chevron {
    display: none;
  }
body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-panel,
body[data-page="messenger"] .vy-messenger-product-slot .vy-product-panel {
  position: fixed !important;
  top: max(56px, env(safe-area-inset-top, 0px)) !important;
  right: max(12px, env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  bottom: auto !important;
  width: min(420px, calc(100vw - 24px)) !important;
  max-height: min(78vh, 640px) !important;
  z-index: 6000 !important;
  overflow: auto;
}
}

@media (prefers-reduced-motion: reduce) {
  .vy-product-launcher,
  .vy-product-card,
  .vy-product-launcher__chevron,
  .vy-product-panel {
    transition: none !important;
    animation: none !important;
  }
  .vy-product-launcher:hover,
  .vy-product-card:hover { transform: none; }
}

@keyframes vy-switcher-ring {
  0% { opacity: .72; transform: scale(.86); }
  100% { opacity: 0; transform: scale(1.16); }
}
@keyframes vy-panel-in {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes vy-panel-sheet {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes vy-card-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: none; }
}

/* CHAT_C_SWITCHER_RAIL · collapsed = FAB only, never full-height strip.
 * WAVE07 owns mobile placement; this only kills stretch/background leftovers. */
.vy-product-switcher {
  width: fit-content !important;
  max-width: none;
  height: fit-content !important;
  min-height: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.vy-product-switcher:not([data-open="true"]):not(.is-open) > .vy-product-panel,
.vy-product-switcher:not([data-open="true"]):not(.is-open) > .vy-product-grid,
.vy-product-panel[hidden] {
  display: none !important;
}
body[data-page="messenger"] .vy-msg-switcher-slot {
  position: relative;
  z-index: 8;
  width: auto;
  height: auto;
  overflow: visible;
}
@media (min-width: 641px) {
  body[data-page="messenger"] .vy-msg-switcher-slot .vy-product-switcher {
    position: static !important;
    inset: auto !important;
    height: auto !important;
    width: auto !important;
    background: transparent !important;
  }
}
