/* =========================================================
   Stock Market Floating Widget
   ========================================================= */

.market-widget-card {
  --market-widget-radius: 18px;
  --market-widget-horizontal-offset: 24px;
  --market-widget-vertical-offset: 24px;

  position: fixed;
  left: max(var(--market-widget-horizontal-offset), env(safe-area-inset-left));
  bottom: max(
    var(--market-widget-vertical-offset),
    env(safe-area-inset-bottom)
  );
  z-index: 1045;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  min-width: 180px;
  min-height: 76px;
  padding: 11px 12px 11px 16px;

  direction: rtl;
  color: #ffffff;
  text-decoration: none;

  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--market-widget-radius);

  box-shadow:
    0 12px 30px rgba(18, 32, 55, 0.18),
    0 4px 12px rgba(18, 32, 55, 0.12);

  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  overflow: visible;
  isolation: isolate;

  transition:
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 280ms ease,
    border-color 280ms ease,
    background-color 280ms ease;

  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* Inner glossy border */
.market-widget-card::before {
  content: "";
  position: absolute;

  inset: 1px;

  z-index: 1;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: calc(var(--market-widget-radius) - 1px);

  pointer-events: none;
}

/* Open-state pulse layer */
.market-widget-card::after {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: calc(var(--market-widget-radius) + 6px);
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   Widget states
   ========================================================= */

.market-widget-open {
  background: linear-gradient(135deg, #19915f 0%, #0c774c 55%, #075f3c 100%);

  box-shadow:
    0 14px 34px rgba(9, 101, 64, 0.28),
    0 5px 14px rgba(18, 32, 55, 0.13);

  animation: market-widget-card-pulse-green 2s ease-in-out infinite;
}

.market-widget-open::after {
  border: 3px solid rgba(39, 211, 137, 0.72);

  box-shadow:
    0 0 0 0 rgba(39, 211, 137, 0.48),
    0 0 30px rgba(39, 211, 137, 0.5);

  animation: market-widget-ring-pulse-green 2s ease-out infinite;
}

.market-widget-closed {
  background: linear-gradient(135deg, #dc4141 0%, #c92f2f 55%, #a92323 100%);

  box-shadow:
    0 14px 34px rgba(201, 47, 47, 0.3),
    0 5px 14px rgba(18, 32, 55, 0.13);

  animation: market-widget-card-pulse-red 2s ease-in-out infinite;
}

.market-widget-closed::after {
  border: 3px solid rgba(255, 85, 85, 0.8);

  box-shadow:
    0 0 0 0 rgba(201, 47, 47, 0.55),
    0 0 32px rgba(201, 47, 47, 0.52);

  animation: market-widget-ring-pulse-red 2s ease-out infinite;
}

/* =========================================================
   Content
   ========================================================= */

.market-widget-content {
  position: relative;
  z-index: 2;

  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 3px;

  min-width: 0;

  text-align: center;
}

.market-widget-label {
  display: block;

  margin: 0;

  color: #ffffff;

  font-size: 17px;
  font-weight: 800;
  line-height: 1.5;

  white-space: nowrap;

  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.market-widget-countdown {
  display: inline-block;

  margin: 0;

  color: #ffffff;

  direction: ltr;
  unicode-bidi: isolate;

  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;

  letter-spacing: 0.045em;

  white-space: nowrap;

  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";

  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.market-widget-countdown[hidden] {
  display: none;
}

@keyframes market-widget-card-pulse-green {
  0%,
  100% {
    transform: scale(1);

    box-shadow:
      0 14px 34px rgba(9, 101, 64, 0.28),
      0 5px 14px rgba(18, 32, 55, 0.13);
  }

  50% {
    transform: scale(1.055);

    box-shadow:
      0 20px 50px rgba(9, 140, 84, 0.48),
      0 8px 24px rgba(18, 32, 55, 0.18);
  }
}

@keyframes market-widget-card-pulse-red {
  0%,
  100% {
    transform: scale(1);

    box-shadow:
      0 14px 34px rgba(201, 47, 47, 0.3),
      0 5px 14px rgba(18, 32, 55, 0.13);
  }

  50% {
    transform: scale(1.055);

    box-shadow:
      0 20px 52px rgba(201, 47, 47, 0.52),
      0 8px 24px rgba(18, 32, 55, 0.18);
  }
}

@keyframes market-widget-ring-pulse-green {
  0% {
    opacity: 0.9;
    transform: scale(0.98);
  }

  65% {
    opacity: 0;
    transform: scale(1.22);

    box-shadow:
      0 0 0 18px rgba(39, 211, 137, 0),
      0 0 48px rgba(39, 211, 137, 0);
  }

  100% {
    opacity: 0;
    transform: scale(1.22);
  }
}

@keyframes market-widget-ring-pulse-red {
  0% {
    opacity: 0.95;
    transform: scale(0.98);
  }

  65% {
    opacity: 0;
    transform: scale(1.22);

    box-shadow:
      0 0 0 18px rgba(201, 47, 47, 0),
      0 0 50px rgba(201, 47, 47, 0);
  }

  100% {
    opacity: 0;
    transform: scale(1.22);
  }
}

/* =========================================================
   Interaction
   ========================================================= */
@media (hover: hover) and (pointer: fine) {
  .market-widget-card:hover {
    animation-play-state: paused;

    transform: translateY(-4px) scale(1.035);

    box-shadow:
      0 22px 52px rgba(18, 32, 55, 0.28),
      0 8px 22px rgba(18, 32, 55, 0.18);
  }

  .market-widget-card:hover::after {
    animation-play-state: paused;
    opacity: 0;
  }
}

.market-widget-card:active {
  transform: translateY(-1px);
}

.market-widget-card:focus {
  outline: none;
}

.market-widget-card:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.92);
  outline-offset: 4px;

  box-shadow:
    0 0 0 5px rgba(26, 62, 105, 0.32),
    0 18px 42px rgba(18, 32, 55, 0.24);
}

/* =========================================================
   Accessibility
   ========================================================= */

.market-widget-sr-only {
  position: absolute !important;

  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;

  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;

  white-space: nowrap !important;
  border: 0 !important;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 991.98px) {
  .market-widget-card {
    --market-widget-horizontal-offset: 20px;
    --market-widget-vertical-offset: 20px;
    --market-widget-radius: 16px;

    min-width: 202px;
    min-height: 70px;
    gap: 12px;

    padding: 10px 11px 10px 14px;
  }

  .market-widget-logo-wrapper {
    flex-basis: 48px;

    width: 48px;
    height: 48px;
    padding: 7px;

    border-radius: 13px;
  }

  .market-widget-label {
    font-size: 12px;
  }

  .market-widget-countdown {
    font-size: 18px;
  }
}

@media (max-width: 575.98px) {
  .market-widget-card {
    --market-widget-horizontal-offset: 12px;
    --market-widget-vertical-offset: 12px;
    --market-widget-radius: 14px;

    min-width: 174px;
    min-height: 60px;
    gap: 9px;

    padding: 8px 9px 8px 11px;

    box-shadow:
      0 9px 24px rgba(18, 32, 55, 0.19),
      0 3px 9px rgba(18, 32, 55, 0.11);
  }

  .market-widget-content {
    gap: 1px;
  }

  .market-widget-label {
    font-size: 13px;
    font-weight: 700;
  }

  .market-widget-countdown {
    font-size: 18px;
    font-weight: 800;
  }
}

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .market-widget-open,
  .market-widget-closed,
  .market-widget-open::after,
  .market-widget-closed::after {
    animation: none;
  }
}
