/*
 *  Copyright IBM Corp. 2025
 *
 *  This source code is licensed under the Apache-2.0 license found in the
 *  LICENSE file in the root directory of this source tree.
 */

/**
 * Launcher positioning styles for Carbon AI Chat floating widget mode.
 * Following @carbon/styles component patterns where styles are wrapped in mixins.
 *
 * These styles provide fixed positioning and entrance animation for a launcher
 * button, matching the positioning of the float layout. Extended (pill/CTA)
 * styles are intentionally excluded — include Launcher.scss for those.
 *
 * Usage (Sass — mixin, for composing into your own stylesheet):
 * @use "@carbon/ai-chat/scss/chat-launcher-layout";
 * @include chat-launcher-layout.launcher-positioning;
 *
 * Usage (CSS — pre-compiled, no Sass pipeline needed):
 * @import "@carbon/ai-chat/css/chat-launcher-layout.css";
 *
 * Classes generated:
 * - .cds-aichat-launcher         — base fixed positioning
 * - .cds-aichat-launcher--hidden — visually hidden (preserves layout)
 */

@use "@carbon/styles/scss/motion";
@use "@carbon/layout";
@use "@carbon/ai-chat-components/scss/utilities" as *;
@use "./chat-theme";

// Launcher layout variables (only used in this file)
$launcher-position-bottom: get-var(
  "launcher-position-bottom",
  #{layout.$spacing-09}
);
$launcher-position-right: get-var(
  "launcher-position-right",
  #{layout.$spacing-07}
);

@mixin launcher-positioning {
  /* ============================================================================
     LAUNCHER - BASE POSITIONING
     Fixed positioning for the launcher button
     Uses logical properties for automatic RTL support
     ============================================================================ */

  .#{$prefix}-launcher {
    position: fixed;
    z-index: chat-theme.$z-index;
    inset-block-end: $launcher-position-bottom;
    inset-inline-end: $launcher-position-right;

    @media (prefers-reduced-motion: no-preference) {
      animation: #{$prefix}-launcher-in motion.$duration-moderate-01
        motion.motion(entrance, expressive) both;
    }
  }

  /* ============================================================================
     LAUNCHER - RTL POSITIONING
     Use physical left/right instead of logical properties — logical properties
     on position:fixed elements resolve against the viewport direction, which
     may not reflect a dir="rtl" set on a sub-element of the page.
     ============================================================================ */

  .#{$prefix}-launcher:dir(rtl) {
    right: unset;
    left: $launcher-position-right;
  }

  /* ============================================================================
     LAUNCHER - HIDDEN STATE
     Hides the launcher while preserving its space (avoids re-triggering
     the entrance animation on remount)
     ============================================================================ */

  .#{$prefix}-launcher--hidden {
    visibility: hidden;
  }

  /* ============================================================================
     LAUNCHER - KEYFRAME ANIMATIONS
     ============================================================================ */

  @keyframes #{$prefix}-launcher-in {
    0% {
      opacity: 0;
    }

    100% {
      opacity: 1;
    }
  }
}

@include launcher-positioning;
