/* =========================================================
   PSD MOBILE CATEGORY BASE
   Clean rebuild from production base 2741594
   ========================================================= */

@media (max-width:768px){

  /* Floating PDF is desktop-only */
  #psdPdfWidget,
  .psd-pdf-widget{
    display:none !important;
  }

  /* Overall mobile category page */
  .ai-page{
    width:calc(100% - 12px) !important;
    max-width:100% !important;
    margin:0 auto !important;
    padding:6px 0 18px !important;
  }

  /* Compact approved top card */
  .ai-hero{
    width:100% !important;
    margin:0 0 5px !important;
    padding:9px 12px !important;
    border-radius:14px !important;
  }

  .ai-hero-grid{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:5px !important;
    width:100% !important;
  }

  .ai-hero-grid > *{
    min-width:0 !important;
  }

  .ai-hero h1{
    margin:0 0 3px !important;
    font-size:22px !important;
    line-height:1.05 !important;
  }

  .ai-hero p{
    margin:0 !important;
    font-size:12px !important;
    line-height:1.18 !important;
  }

  /* Remove the oval Engine PSI / Updated box */
  .ai-hero-center,
  .ai-updated{
    display:none !important;
  }

  /* Native page count + arrows */
  .ai-hero-tools{
    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;
    gap:8px !important;
    width:100% !important;
    margin-top:5px !important;
  }

  .ai-carousel-count{
    margin:0 !important;
    min-width:0 !important;
    font-size:11px !important;
    font-weight:900 !important;
    line-height:1.1 !important;
    white-space:normal !important;
  }

  .ai-hero-arrows{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-end !important;
    gap:6px !important;
    flex:0 0 auto !important;
  }

  .ai-scroll{
    display:grid !important;
    place-items:center !important;
    width:36px !important;
    height:36px !important;
    min-width:36px !important;
    min-height:36px !important;
    padding:0 !important;
    font-size:24px !important;
    line-height:1 !important;
    border-radius:10px !important;
  }

  .ai-scroll:disabled{
    opacity:.38 !important;
  }

  /* One native card occupies the available width */
  .ai-top-grid{
    grid-template-columns:1fr !important;
    grid-template-rows:1fr !important;
    width:100% !important;
  }

  .ai-card{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }
}

@media (max-width:390px){

  .ai-hero{
    padding:8px 10px !important;
  }

  .ai-hero h1{
    font-size:20px !important;
  }

  .ai-hero p{
    font-size:11.5px !important;
  }
}

/* =========================================================
   PSD MOBILE CATEGORY REFINEMENT
   Clean History refinement from base 762a762
   ========================================================= */

@media (max-width:768px){

  /* No Compare on mobile */
  .compare-control{
    display:none !important;
  }


  /* -------------------------------------------------------
     HISTORY WINDOW
     Ribbon remains untouched.
     History starts immediately below it.
     ------------------------------------------------------- */

  .history-layer{
    align-items:flex-start !important;

    padding-top:92px !important;
    padding-left:2px !important;
    padding-right:2px !important;
    padding-bottom:4px !important;

    box-sizing:border-box !important;
  }


  .history-card{
    width:calc(100vw - 8px) !important;
    max-width:calc(100vw - 8px) !important;
    margin:0 auto !important;

    height:calc(100dvh - 96px) !important;
    max-height:calc(100dvh - 96px) !important;

    overflow-x:hidden !important;
    overflow-y:auto !important;

    box-sizing:border-box !important;

    -webkit-overflow-scrolling:touch !important;
  }


  /* Existing History header + existing X stay unchanged */
  .history-head{
    position:sticky !important;
    top:0 !important;
    z-index:100 !important;

    background:var(--theme-card) !important;
  }


  /* -------------------------------------------------------
     SHORTER, EQUAL CHARTS
     Width is deliberately untouched.
     ------------------------------------------------------- */

  .interactive-chart{
    height:205px !important;
    min-height:205px !important;
    max-height:205px !important;
  }


  .pulse-chart-panel{
    padding-top:8px !important;
    padding-bottom:8px !important;
  }

  .pulse-chart-head{
    margin-bottom:4px !important;
  }

  .history-grid{
    gap:9px !important;
  }


  /* -------------------------------------------------------
     Latest News must remain part of History flow
     ------------------------------------------------------- */

  .history-news{
    display:block !important;

    width:100% !important;
    max-width:100% !important;

    grid-column:1 / -1 !important;

    box-sizing:border-box !important;
  }

  .history-news-list{
    display:grid !important;
    grid-template-columns:1fr !important;

    width:100% !important;
    max-width:100% !important;
  }
}


@media (max-width:390px){

  .history-layer{
    padding-top:90px !important;
  }

  .history-card{
    height:calc(100dvh - 94px) !important;
    max-height:calc(100dvh - 94px) !important;
  }

  .interactive-chart{
    height:190px !important;
    min-height:190px !important;
    max-height:190px !important;
  }
}
/* PSD MOBILE CATEGORY REFINEMENT END */

/* V2 HISTORY NORMAL PAGE SCROLL START */

@media (max-width:768px){

  html.psd-history-flow-open,
  body.psd-history-flow-open{
    overflow-x:hidden !important;
    overflow-y:auto !important;
    height:auto !important;
    min-height:100% !important;

    touch-action:pan-y !important;
    overscroll-behavior-y:auto !important;
  }


  /*
    Historical View is no longer a fixed viewport modal on mobile.
    It sits directly below the ribbon and scrolls with the document.
  */
  body.psd-history-flow-open .history-layer.open{
    position:relative !important;

    inset:auto !important;
    top:auto !important;
    right:auto !important;
    bottom:auto !important;
    left:auto !important;

    display:block !important;

    width:100% !important;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;

    margin:0 !important;
    padding:8px !important;

    box-sizing:border-box !important;

    overflow:visible !important;

    touch-action:pan-y !important;

    align-items:initial !important;
    justify-content:initial !important;
  }


  /*
    Remove the second/internal vertical scroll area.
    The phone page itself now performs the scrolling.
  */
  body.psd-history-flow-open .history-card{
    position:relative !important;

    width:100% !important;
    max-width:100% !important;

    height:auto !important;
    min-height:0 !important;
    max-height:none !important;

    margin:0 auto !important;

    overflow:visible !important;
  }


  body.psd-history-flow-open .history-body{
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;

    overflow:visible !important;
    overflow-x:hidden !important;
    overflow-y:visible !important;

    -webkit-overflow-scrolling:auto !important;

    touch-action:pan-y !important;
  }

}

/* V2 HISTORY NORMAL PAGE SCROLL END */

/* V2 MOBILE HISTORY CHART FULLSCREEN START */

@media (max-width:768px){

  /*
    Lock only the page underneath while one History chart
    occupies the mobile viewport.
  */
  body.psd-chart-fullscreen-open{
    overflow-x:hidden !important;
    overflow-y:auto !important;
  }


  /*
    Sentiment or Market History chart becomes one full-screen
    page, similar to the TradingView mobile chart experience.
  */
  body.psd-chart-fullscreen-open .pulse-chart-panel.expanded{
    position:relative !important;

    inset:auto !important;
    top:auto !important;
    right:auto !important;
    bottom:auto !important;
    left:auto !important;

    width:100% !important;
    max-width:100% !important;

    height:72dvh !important;
    min-height:72dvh !important;
    max-height:72dvh !important;

    margin:0 !important;
    padding:8px !important;

    box-sizing:border-box !important;

    border-radius:13px !important;

    background:var(--theme-card) !important;

    display:flex !important;
    flex-direction:column !important;

    overflow:hidden !important;

    z-index:20 !important;
  }


  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .pulse-chart-head{
    position:relative !important;

    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;

    flex:0 0 auto !important;

    min-height:42px !important;

    margin:0 0 6px !important;
    padding:0 2px !important;
  }


  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .pulse-chart-head h3{
    margin:0 !important;
    padding-right:8px !important;
  }


  /*
    Same Maximize button becomes the X.
  */
  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .chart-size{
    display:grid !important;
    place-items:center !important;

    flex:0 0 38px !important;

    width:38px !important;
    min-width:38px !important;
    max-width:38px !important;

    height:38px !important;
    min-height:38px !important;
    max-height:38px !important;

    margin:0 !important;
    padding:0 0 2px !important;

    border:1px solid var(--theme-line) !important;
    border-radius:10px !important;

    background:var(--theme-card-2) !important;
    color:var(--theme-text) !important;

    font-size:25px !important;
    line-height:1 !important;
    font-weight:700 !important;

    z-index:10 !important;
  }


  /*
    When Market Price History is maximized, only its title,
    X and chart are needed. TradingView link remains available
    in normal Historical View.
  */
  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .full-market-chart-link{
    display:none !important;
  }


  /*
    Chart consumes all remaining viewport space.
  */
  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .interactive-chart{
    flex:0 0 auto !important;

    width:100% !important;

    height:calc(72dvh - 64px) !important;
    min-height:calc(72dvh - 64px) !important;
    max-height:calc(72dvh - 64px) !important;

    margin:0 !important;
  }

}

/* V2 MOBILE HISTORY CHART FULLSCREEN END */

/* V2 MOBILE Y SCALE HANDLE START */

.psd-y-scale-handle{
  display:none;
}

@media (max-width:768px){

  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .interactive-chart{
    position:relative !important;
  }

  body.psd-chart-fullscreen-open
  .pulse-chart-panel.expanded
  .psd-y-scale-handle{
    display:block !important;

    position:absolute !important;
    top:0 !important;
    right:0 !important;
    bottom:0 !important;

    width:58px !important;

    z-index:25 !important;

    background:transparent !important;

    touch-action:none !important;
    cursor:ns-resize !important;
  }

}

/* V2 MOBILE Y SCALE HANDLE END */
