/* ==========================================================================
   AXIONMESK — TRADE mobile: animações (CSS)
   ========================================================================== */

@media (max-width: 900px) {

  /* ------------------------------------------------------------------------
     1) PULSO NO PREÇO
     ------------------------------------------------------------------------ */
  .trade-page #pairPrice {
    transition: color .2s ease, text-shadow .3s ease;
    position: relative;
    will-change: transform;
  }

  /* sobe: verde + brilho */
  .trade-page #pairPrice.cm-price-up {
    animation: cmPriceUp .85s cubic-bezier(.22, 1, .36, 1) both;
  }

  /* desce: vermelho + brilho */
  .trade-page #pairPrice.cm-price-down {
    animation: cmPriceDown .85s cubic-bezier(.22, 1, .36, 1) both;
  }

  @keyframes cmPriceUp {
    0%   { transform: scale(1);    text-shadow: 0 0 0 rgba(22, 199, 132, 0); }
    18%  { transform: scale(1.06); text-shadow: 0 0 22px rgba(22, 199, 132, .75); }
    55%  { transform: scale(1.02); text-shadow: 0 0 12px rgba(22, 199, 132, .35); }
    100% { transform: scale(1);    text-shadow: 0 0 0 rgba(22, 199, 132, 0); }
  }

  @keyframes cmPriceDown {
    0%   { transform: scale(1);    text-shadow: 0 0 0 rgba(246, 70, 93, 0); }
    18%  { transform: scale(1.06); text-shadow: 0 0 22px rgba(246, 70, 93, .75); }
    55%  { transform: scale(1.02); text-shadow: 0 0 12px rgba(246, 70, 93, .35); }
    100% { transform: scale(1);    text-shadow: 0 0 0 rgba(246, 70, 93, 0); }
  }

  /* seta de tendência automática */
  .trade-page #pairPrice::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 8px;
    vertical-align: middle;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    opacity: 0;
    transition: opacity .25s ease;
  }
  .trade-page #pairPrice[data-trend="up"]::after {
    border-bottom: 7px solid #16C784;
    opacity: 1;
  }
  .trade-page #pairPrice[data-trend="down"]::after {
    border-top: 7px solid #F6465D;
    opacity: 1;
  }

  /* ------------------------------------------------------------------------
     2) FLASH NAS LINHAS DE PREÇO (qLast / subPrice)
     ------------------------------------------------------------------------ */
  .trade-page #qLast,
  .trade-page #subPrice {
    transition: color .18s ease;
    border-radius: 5px;
    padding: 0 3px;
    margin: 0 -3px;
    display: inline-block;
  }

  .trade-page #qLast.cm-flash-up,
  .trade-page #subPrice.cm-flash-up {
    animation: cmFlashUp .65s ease-out both;
  }
  .trade-page #qLast.cm-flash-down,
  .trade-page #subPrice.cm-flash-down {
    animation: cmFlashDown .65s ease-out both;
  }

  @keyframes cmFlashUp {
    0%   { background: rgba(22, 199, 132, .38); color: #16C784; }
    100% { background: transparent; color: inherit; }
  }
  @keyframes cmFlashDown {
    0%   { background: rgba(246, 70, 93, .38); color: #F6465D; }
    100% { background: transparent; color: inherit; }
  }

  /* ------------------------------------------------------------------------
     3) FLASH NO CANVAS DO GRÁFICO (candle mais recente)
     ------------------------------------------------------------------------ */
  .trade-page .chart-panel {
    position: relative;
  }

  .cm-candle-flash {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 74px;
    pointer-events: none;
    border-radius: 0 14px 0 0;
    opacity: 0;
    transition: opacity .2s ease;
    z-index: 2;
  }

  .cm-candle-flash.is-up {
    animation: cmCandleUp .42s ease-out both;
  }
  .cm-candle-flash.is-down {
    animation: cmCandleDown .42s ease-out both;
  }

  @keyframes cmCandleUp {
    0%   { opacity: 1; background: linear-gradient(90deg, transparent, rgba(22, 199, 132, .22)); }
    100% { opacity: 0; background: linear-gradient(90deg, transparent, rgba(22, 199, 132, 0)); }
  }
  @keyframes cmCandleDown {
    0%   { opacity: 1; background: linear-gradient(90deg, transparent, rgba(246, 70, 93, .22)); }
    100% { opacity: 0; background: linear-gradient(90deg, transparent, rgba(246, 70, 93, 0)); }
  }

  /* ------------------------------------------------------------------------
     4) BOTÃO FLUTUANTE "LIVRO"
     ------------------------------------------------------------------------ */
  .cm-book-btn {
    position: absolute;
    right: 10px;
    top: 8px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 11px;
    border-radius: 9px;
    border: 1px solid rgba(56,107,255, .3);
    background: rgba(56,107,255, .12);
    color: #386BFF;
    font-size: 11.5px;
    font-weight: 800;
    font-family: inherit;
    letter-spacing: -.01em;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform .12s ease, background .15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .cm-book-btn:active {
    transform: scale(.94);
    background: rgba(56,107,255, .22);
  }

  /* ------------------------------------------------------------------------
     5) BOTTOM SHEET DO LIVRO
     ------------------------------------------------------------------------ */
  .cm-book-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(3, 5, 9, .68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s ease, visibility .24s ease;
  }
  .cm-book-overlay.is-open { opacity: 1; visibility: visible; }

  .cm-book-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1301;
    max-height: 76dvh;
    display: flex;
    flex-direction: column;
    padding: 0 14px calc(env(safe-area-inset-bottom, 0px) + 16px);
    border-radius: 24px 24px 0 0;
    background: linear-gradient(180deg, #1B1F27 0%, #12151A 42%, #0B1220 100%);
    border-top: 1px solid rgba(255, 255, 255, .09);
    box-shadow: 0 -22px 56px rgba(0, 0, 0, .72);
    transform: translateY(102%);
    transition: transform .34s cubic-bezier(.22, 1, .36, 1);
    will-change: transform;
  }
  .cm-book-sheet.is-open { transform: translateY(0); }

  .cm-book-sheet::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #386BFF, transparent);
    opacity: .85;
  }

  .cm-book-handle {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .26);
    margin: 10px auto 4px;
    flex: 0 0 auto;
    touch-action: none;
  }

  .cm-book-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px 12px;
    flex: 0 0 auto;
  }

  .cm-book-title {
    font-size: 15px;
    font-weight: 800;
    color: #F5F7FA;
    letter-spacing: -.01em;
  }

  .cm-book-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    color: #C9CED6;
    font-size: 20px;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
  }
  .cm-book-close:active { background: rgba(255, 255, 255, .14); }

  .cm-book-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 120px;
    padding-right: 2px;
  }
  .cm-book-body::-webkit-scrollbar { width: 0; }

  /* Torna o book legível dentro da sheet */
  .cm-book-body .book-row,
  .cm-book-body .brow,
  .cm-book-body > div > div {
    display: flex !important;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 6px !important;
    border-radius: 7px;
    font-size: 12.5px !important;
    font-variant-numeric: tabular-nums;
  }

  .cm-book-body .book-row:nth-child(odd),
  .cm-book-body .brow:nth-child(odd) {
    background: rgba(255, 255, 255, .022);
  }

  .cm-book-empty {
    text-align: center;
    color: #8996AA;
    font-size: 13px;
    padding: 32px 0;
  }

  .cm-book-foot {
    display: flex;
    justify-content: space-between;
    padding: 12px 4px 2px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    font-size: 11.5px;
    color: #8996AA;
    flex: 0 0 auto;
  }

  .cm-green { color: #16C784 !important; }
  .cm-red { color: #F6465D !important; }

  /* Trava o scroll da página quando a sheet está aberta */
  body.cm-book-open {
    overflow: hidden !important;
    touch-action: none;
  }
}

/* --------------------------------------------------------------------------
   ACESSIBILIDADE
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .trade-page #pairPrice,
  .trade-page #qLast,
  .trade-page #subPrice,
  .cm-candle-flash,
  .cm-book-sheet,
  .cm-book-overlay,
  .cm-book-btn {
    animation: none !important;
    transition: none !important;
  }
}
