@layer reset, base, components, motion;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, p { margin: 0; }
  button, textarea { font: inherit; }
  button, a, textarea { -webkit-tap-highlight-color: transparent; }
  button { color: inherit; cursor: pointer; }
  button, textarea { border: 0; }
  button { touch-action: manipulation; }
  svg, img { display: block; }
}

@layer base {
  :root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    --background: #03101e;
    --surface: #061a2d;
    --surface-raised: #0a233b;
    --text: #f6f9ff;
    --muted: #98b9d6;
    --accent: #00b5ff;
    --blue: #0076f5;
    --border: #164364;
    --radius: 18px;
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    background: #020a13;
    color: var(--text);
  }
  html { scroll-padding-bottom: 110px; }
  body { min-width: 280px; line-height: 1.45; }
  button:focus-visible, a:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #a3e6ff; outline-offset: 4px; }
  button:disabled { cursor: default; }
  [hidden] { display: none !important; }
  ::selection { color: #fff; background: #086bb9; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
  .icon { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .app-shell { position: relative; max-width: 480px; min-height: 100svh; margin-inline: auto; padding-bottom: calc(106px + env(safe-area-inset-bottom)); background: var(--background) url('./assets/showroom-background.webp') center top / 100% auto no-repeat; isolation: isolate; }
}

@layer components {
  /* Пьедестал и камера используют один масштаб по ширине. На низких экранах страницу можно прокрутить. */
  #main-content { display: flex; flex-direction: column; min-height: calc(100svh - 106px - env(safe-area-inset-bottom)); }
  .hero { position: relative; flex: 1 0 auto; min-height: min(80vw, 384px); overflow: hidden; isolation: isolate; }
  .hero-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
  .pc-loading, .pc-error { position: absolute; z-index: 1; top: min(42vw, 202px); left: 50%; width: min(232px, 68%); transform: translate(-50%, -50%); text-align: center; }
  /* Голограмма состоит из света и открытых уголков: подложки поверх шоурума нет. */
  .pc-loading { padding: 18px 15px 15px; background: transparent; color: #c8f5ff; transition: opacity 120ms ease, visibility 120ms ease; }
  .pc-loading::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .72;
    background:
      linear-gradient(#75ddff, #75ddff) left top / 14px 1px,
      linear-gradient(#75ddff, #75ddff) left top / 1px 10px,
      linear-gradient(#75ddff, #75ddff) right top / 14px 1px,
      linear-gradient(#75ddff, #75ddff) right top / 1px 10px,
      linear-gradient(#75ddff, #75ddff) left bottom / 14px 1px,
      linear-gradient(#75ddff, #75ddff) left bottom / 1px 10px,
      linear-gradient(#75ddff, #75ddff) right bottom / 14px 1px,
      linear-gradient(#75ddff, #75ddff) right bottom / 1px 10px;
    background-repeat: no-repeat; }
  .pc-loading::after { content: ""; position: absolute; top: 6px; left: 8%; right: 8%; height: 1px; background: linear-gradient(90deg, transparent, #a8efff, transparent); box-shadow: 0 0 8px #00b5ff; pointer-events: none; opacity: 0; }
  .pc-loading-title { margin-bottom: 14px; color: #dcfaff; font-size: 20px; font-weight: 650; letter-spacing: -.02em; text-shadow: 0 1px 3px #00121f, 0 0 10px #28baff, 0 0 24px #00aaff80; }
  .pc-progress-row { display: flex; align-items: center; gap: 10px; }
  #pc-progress { appearance: none; display: block; flex: 1; min-width: 0; width: 100%; height: 7px; overflow: hidden; border: 1px solid #77dfff9c; border-radius: 1px; background: transparent; color: #91edff; box-shadow: 0 0 9px #00b5ff55; }
  #pc-progress::-webkit-progress-bar { background: transparent; }
  #pc-progress::-webkit-progress-value { background: linear-gradient(90deg, #119de4, #b7f6ff); box-shadow: 0 0 6px #83e6ff; }
  #pc-progress::-moz-progress-bar { background: linear-gradient(90deg, #119de4, #b7f6ff); box-shadow: 0 0 6px #83e6ff; }
  #pc-progress:indeterminate { background: linear-gradient(90deg, transparent 25%, #91edff 50%, transparent 75%); background-size: 220% 100%; animation: pc-loading-wait 1.4s linear infinite; }
  #pc-progress:indeterminate::-webkit-progress-bar { background: transparent; }
  #pc-percent { min-width: 4ch; color: #d3f8ff; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; text-shadow: 0 1px 3px #00121f, 0 0 8px #00b5ff; }
  .pc-loading-detail { min-height: 18px; margin-top: 10px; color: #b5eaff; font-size: 11px; text-shadow: 0 1px 3px #00121f, 0 0 6px #0076f5; }
  .hero[data-state="landing"] .pc-loading, .hero[data-state="ready"] .pc-loading { opacity: 0; visibility: hidden; pointer-events: none; }
  .pc-error { padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #03101ef5; }
  .pc-error > p:first-child { font-size: 16px; font-weight: 650; }
  #pc-error-description { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
  .pc-error button { min-height: 44px; margin-top: 12px; padding: 10px 22px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 13px; }
  .pc-motion { position: absolute; right: 14px; top: calc(12px + env(safe-area-inset-top)); z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #164364; border-radius: 12px; background: #03101ed9; color: #a3e6ff; }
  .pc-motion .icon { width: 18px; height: 18px; }
  .pc-play-icon, .pc-motion[aria-pressed="true"] .pc-pause-icon { display: none; }
  .pc-motion[aria-pressed="true"] .pc-play-icon { display: initial; }
  .pc-no-script { position: absolute; top: 25%; left: 15%; width: 70%; padding: 14px; border-radius: 12px; background: #03101ef5; font-size: 13px; text-align: center; }
  .hero:has(.pc-no-script) .pc-loading { display: none; }
  .page-content { position: relative; flex: 0 0 auto; padding-inline: 18px; }
  .offer { position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; width: fit-content; min-width: 244px; min-height: 52px; margin: -26px auto 16px; padding: 8px 18px; border: 1px solid #009df0; border-radius: 18px; background: linear-gradient(120deg, #062847, #03172c 68%, #04315a); text-align: left; font-size: 14px; line-height: 1.25; }
  /* Текст и процент в строку: так плашка ниже и остаётся место под остальное. */
  .offer > span { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
  .offer strong { font-size: 20px; font-weight: 750; letter-spacing: -.025em; color: var(--accent); }
  .offer-icon { width: 28px; height: 28px; color: #86b7ff; }
  .offer-arrow { width: 18px; height: 18px; margin-left: 3px; color: #82bbdf; }
  .panel { padding: 13px 10px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(130deg, #07223beb, #041525f0); }
  .section-heading { padding-inline: 2px; margin-bottom: 9px; }
  .section-heading h2 { font-size: 19px; font-weight: 720; line-height: 1.15; letter-spacing: -.03em; text-wrap: balance; }
  .panel + .panel { margin-top: 10px; }
  /* Маркетплейсы и соцсети — две панели одного устройства: четыре плитки
     в первой, три во второй. Общий компонент плитки, разная ширина колонки. */
  .platforms-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  /* Соцсетей три, но плитка у них та же, что у маркетплейсов: одинаковая сетка
     читается как одна система. Неполный ряд встаёт по центру. */
  .platforms-grid--three { display: flex; justify-content: center; }
  .platforms-grid--three .platform-button { flex: 0 0 calc(25% - 4.5px); }
  /* Плитка без подписи: знак площадки узнаётся сам, имя кнопки — в aria-label.
     Иконка крупнее прежней ровно на высоту ушедшей подписи. */
  .platform-button { display: grid; place-items: center; min-height: 56px; padding: 8px 4px; border: 1px solid #113b5c; border-radius: 12px; background: linear-gradient(140deg, #0b2c49, #081e33); box-shadow: inset 0 1px 0 #ffffff12; }
  .platform-icon { width: 34px; height: 34px; }
  .chat-dock { position: fixed; z-index: 3; bottom: 0; left: 50%; width: min(100%, 480px); transform: translateX(-50%); padding: 18px 18px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, #03101ef0 24%); pointer-events: none; }
  .chat-action { position: relative; display: flex; align-items: center; min-height: 66px; padding: 5px; border: 1px solid #3fc9ff; border-radius: 19px; background: linear-gradient(112deg, #0b9bff, #0069e8 72%, #0079f7); box-shadow: 0 10px 26px -6px #0076f5b8, 0 3px 10px #0010228c, inset 0 1px 0 #ffffff40; pointer-events: auto; }
  /* Шеврон — подсказка «откроется», а не вторая кнопка: боковые поля кнопки
     равны его ширине, поэтому иконка с подписью стоят ровно по центру. */
  .open-chat { position: relative; display: flex; justify-content: center; align-items: center; gap: 12px; flex: 1; min-height: 54px; padding: 10px 48px; border-radius: 15px; background: transparent; color: #fff; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
  .open-chat .icon { width: 28px; height: 28px; stroke-width: 1.9; }
  .chat-go { position: absolute; inset: 4px 0 4px auto; right: 2px; display: grid; place-items: center; width: 46px; border-left: 1px solid #a5e0ff5c; color: #d8f2ff; }
  .chat-go .icon { width: 16px; height: 20px; stroke-width: 2.6; }
  .toast { position: fixed; z-index: 5; bottom: calc(106px + env(safe-area-inset-bottom)); left: 50%; width: max-content; max-width: min(calc(100% - 40px), 424px); padding: 13px 17px; border: 1px solid #326286; border-radius: 13px; background: #102b43; color: var(--text); font-size: 14px; text-align: center; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
  .toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
  .chat-is-open { overflow: hidden; }
  #support-dialog { position: fixed; inset: auto 0 0; width: min(100%, 480px); max-width: 100%; max-height: 100%; margin: auto auto 0; padding: 0; border: 0; border-radius: 26px 26px 0 0; background: transparent; color: var(--text); overflow: visible; }
  #support-dialog::backdrop { background: #000a14b8; backdrop-filter: blur(5px); }
  .chat-sheet { display: flex; flex-direction: column; height: min(710px, 87dvh); min-height: min(350px, 92dvh); padding-bottom: env(safe-area-inset-bottom); border: 1px solid #205479; border-bottom: 0; border-radius: 26px 26px 0 0; background: var(--background); overflow: hidden; box-shadow: 0 -16px 60px #000b; }
  .sheet-handle { display: grid; place-items: center; flex: 0 0 25px; width: 100%; min-height: 25px; padding: 8px; background: transparent; touch-action: none; }
  .sheet-handle > span { width: 36px; height: 4px; border-radius: 5px; background: #3e5b73; }
  .chat-header { display: flex; align-items: center; gap: 11px; padding: 6px 19px 17px; }
  .support-avatar { display: grid; place-items: center; flex: 0 0 43px; height: 43px; border-radius: 14px; background: #092d48; color: var(--accent); }
  .support-avatar .icon { width: 25px; height: 25px; }
  .chat-header h2 { font-size: 17px; font-weight: 650; letter-spacing: -.025em; }
  .chat-header p { margin-top: 2px; color: var(--muted); font-size: 12px; }
  .icon-button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; margin-left: auto; border-radius: 50%; background: #0d263b; color: #bdd4e8; }
  .icon-button .icon { width: 20px; height: 20px; }
  .chat-context { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-block: 1px solid #153047; color: #b6d7ee; font-size: 12px; }
  .demo-label { padding: 3px 8px; border-radius: 5px; background: #12324b; color: #adcee6; font-size: 10px; }
  .chat-messages { display: flex; flex: 1; flex-direction: column; gap: 12px; min-height: 0; padding: 17px 18px 22px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #234663 transparent; }
  .chat-date { align-self: center; margin: 0 0 7px; color: #7f9bb3; font-size: 11px; }
  .message { max-width: 89%; padding: 12px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
  .message--support { align-self: flex-start; border-bottom-left-radius: 5px; background: #0d263c; }
  .message--user { align-self: flex-end; border-bottom-right-radius: 5px; background: #075bb5; }
  .message-author { display: block; margin-bottom: 5px; color: #68caff; font-size: 10px; font-weight: 700; letter-spacing: .045em; }
  .message p + p { margin-top: 9px; }
  .message .demo-description { color: #a3c0d6; font-size: 12px; }
  .message time { display: block; margin-top: 6px; color: #bbd6ed; font-size: 10px; text-align: right; }
  .chat-form { flex: 0 0 auto; padding: 12px 16px 10px; border-top: 1px solid #153047; background: #061727; }
  .composer { display: flex; align-items: flex-end; gap: 8px; padding: 7px; border: 1px solid #234761; border-radius: 17px; background: #0d253a; }
  #message-input { flex: 1; width: 100%; min-width: 0; min-height: 42px; max-height: 112px; padding: 10px 7px; resize: none; field-sizing: content; background: transparent; color: #fff; font-size: 16px; line-height: 1.4; scrollbar-width: thin; }
  #message-input::placeholder { color: #9bb5cb; }
  #message-input:focus-visible { outline-offset: 0; border-radius: 7px; }
  .send-button { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px; background: var(--blue); color: #fff; }
  .send-button:disabled { background: #193b57; color: #7d9ab1; }
  .composer-meta { display: flex; justify-content: space-between; gap: 12px; min-height: 28px; padding: 7px 3px 0; color: #96b3ca; font-size: 10px; }
  #message-count { flex: 0 0 auto; }
  .noscript-notice { position: fixed; bottom: 0; z-index: 6; width: 100%; padding: 16px; background: #0a2844; text-align: center; font-size: 14px; }
  @media (min-width: 430px) {
    .hero { flex-basis: calc(378px + env(safe-area-inset-top)); }
    .page-content { padding-inline: 22px; }
    .section-heading > span { font-size: 11px; }
    .service-button { min-height: 63px; }
    .service-button > span { font-size: 16px; }
    .platform-button { min-height: 66px; }
    .platform-icon { width: 40px; height: 40px; }
    .chat-dock { padding-inline: 22px; }
  }
  @media (max-width: 350px) {
    .hero { flex-basis: calc(302px + env(safe-area-inset-top)); min-height: 108px; }
    .page-content { padding-inline: 12px; }
    .section-heading { flex-wrap: wrap; gap: 5px; }
    .section-heading h2 { font-size: 20px; }
    .service-button { gap: 11px; padding-inline: 10px; }
    .service-button > span { font-size: 14px; }
    .service-icon { width: 26px; height: 26px; }
    .platform-button { min-height: 48px; padding-inline: 2px; }
    .platform-icon { width: 28px; height: 28px; }
    .platforms-grid { gap: 4px; }
    .service-button { min-height: 46px; }
    .chat-dock { padding-inline: 12px; }
    .open-chat { padding-inline: 42px; font-size: 17px; }
    .chat-go { width: 40px; }
    .chat-header { gap: 8px; padding-inline: 12px; }
    .chat-header h2 { font-size: 15px; }
  }
  @media (max-height: 500px) {
    .chat-sheet { height: 96dvh; }
    .chat-header { padding-bottom: 8px; }
    .chat-context { padding-block: 6px; }
  }
}

@layer motion {
  /* Одна световая развёртка при загрузке поддерживает появление ПК, не мерцая в цикле. */
  .hero[data-state="loading"] .pc-loading::after { animation: pc-hologram-scan 2s ease-out both; }
  @keyframes pc-hologram-scan {
    0% { opacity: 0; transform: translateY(0); }
    18% { opacity: .65; }
    75% { opacity: .3; }
    100% { opacity: 0; transform: translateY(92px); }
  }
  @keyframes pc-loading-wait { from { background-position: 100% 0; } to { background-position: -100% 0; } }
  .pressable { transition: transform 180ms var(--ease-out), background-color 180ms ease, filter 180ms ease; }
  .pressable:active:not(:disabled) { transform: scale(.97); filter: brightness(1.16); }
  .toast { transition: opacity 200ms ease, transform 240ms var(--ease-out); }
  /* На стене за ПК горит неоновая вывеска — кнопка чата сделана её отблеском.
     Раз в 5,5 с под кнопкой слева направо проходит свет: ядро и отстающий на
     160 мс шлейф; кант разгорается тогда, когда свет под ним.

     Перегон один и linear, без задержки на пике — неравномерный ход и был тем,
     что бросалось в глаза. Смещение и прозрачность разведены по двум анимациям:
     свет успевает появиться и уйти, не меняя при этом скорости.

     Ядро прячется за непрозрачной заливкой кнопки, наружу выходит только
     периферия — поэтому читается как свет из-под предмета, а не пятно рядом.
     Свет вынесен отдельным слоем внутрь дока: любое transform, filter или
     will-change на самой кнопке сделало бы её stacking context и выбросило
     свечение ПОВЕРХ заливки. */
  .chat-glow { position: absolute; z-index: 0; top: 4px; right: 2px; bottom: calc(env(safe-area-inset-bottom) - 6px); left: 2px; pointer-events: none; }
  /* Оба слоя одной ширины: одинаковый перегон в процентах от себя — значит
     одинаковая скорость. Различаются только плотностью градиента. */
  .chat-glow::before,
  .chat-glow::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 76%; opacity: 0; will-change: transform, opacity;
    animation: chat-glow-pass 5.5s linear infinite, chat-glow-fade 5.5s linear infinite; }
  .chat-glow::before { --peak: .62;
    background: radial-gradient(26% 54% at 50% 50%, #cbf9ffed, #4fd8ffb8 30%, #00b5ff5e 58%, #0090ff21 80%, #007ff500 100%);
    background: radial-gradient(in oklab, 26% 54% at 50% 50%, #cbf9ffed, #4fd8ffb8 30%, #00b5ff5e 58%, #0090ff21 80%, #007ff500 100%); }
  .chat-glow::after { --peak: .3; animation-delay: .16s, .16s;
    background: radial-gradient(50% 50% at 50% 50%, #35c5ff7a, #00b5ff38 44%, #007ff500 100%);
    background: radial-gradient(in oklab, 50% 50% at 50% 50%, #35c5ff7a, #00b5ff38 44%, #007ff500 100%); }
  /* Кант трубки. Тени нарисованы один раз, в цикле меняется только opacity. */
  .chat-action::after { content: ""; position: absolute; inset: -1px; border-radius: 20px; opacity: 0; pointer-events: none;
    box-shadow: 0 0 0 1px #8fe4ff, 0 0 12px #4fd2ff, 0 0 30px var(--accent);
    animation: chat-rim 5.5s linear infinite; }
  .chat-is-open .chat-glow::before,
  .chat-is-open .chat-glow::after,
  .chat-is-open .chat-action::after { animation: none; }
  /* Пока по кнопке идут с клавиатуры, разряд выключен: кольцо фокуса не должно
     спорить со свечением. Отдельным правилом — в браузерах без :has() оно
     отвалится целиком и не утащит за собой глушилку для открытого чата. */
  .chat-action:has(:focus-visible)::after { animation: none; }
  /* Свет ждёт за левым краем, потом одним ровным ходом уходит за правый.
     Оба ключевых кадра перегона — единственные, между ними linear. */
  @keyframes chat-glow-pass {
    0%, 70% { transform: translate3d(-110%, 0, 0); }
    100% { transform: translate3d(140%, 0, 0); }
  }
  @keyframes chat-glow-fade {
    0%, 70% { opacity: 0; }
    78%, 92% { opacity: var(--peak); }
    100% { opacity: 0; }
  }
  @keyframes chat-rim {
    0%, 70% { opacity: 0; }
    85% { opacity: .5; }
    100% { opacity: 0; }
  }
  #support-dialog[open] .chat-sheet { animation: sheet-enter 420ms var(--ease-out) both; }
  #support-dialog[open]::backdrop { animation: backdrop-enter 250ms ease both; }
  #support-dialog.is-closing .chat-sheet { animation: sheet-exit 220ms ease-in both; }
  #support-dialog.is-closing::backdrop { animation: backdrop-enter 220ms ease reverse both; }
  @keyframes sheet-enter { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes sheet-exit { from { transform: translateY(0); } to { transform: translateY(100%); } }
  @keyframes backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
  @media (hover: hover) {
    .pressable:hover:not(:disabled) { filter: brightness(1.15); }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .pressable:active:not(:disabled) { transform: none; }
    /* Движение выключено, но кнопка не гаснет: разряд замирает на нижней грани,
       отсвет под ней остаётся ровным. Статично, ноль кадров. */
    .chat-action::after { opacity: .3; }
  }
}
