@use "../util" as *;
@use "../globals" as *;

// stylelint-disable function-disallowed-list

// .modal-open      - body class for killing the scroll
.scroll-disabled{
    overflow: hidden;
    padding-right: 0;
    }
// .modal           - container to scroll within
// .modal-dialog    - positioning shell for the actual modal
// .modal-content   - actual modal w/ bg and corners and stuff


// Container that the modal scrolls within


.modal {  
    --modal-zindex: #{$modal-zindex};
    --modal-width: 60vw;
    --modal-height: 50vh;
    --modal-padding: 1.5rem;
    --modal-margin: 1.5rem;
    --modal-color: var(--text-core);
    --modal-bg: var(--bg-core-primary-light);
    --modal-border-color: var(--bg-core-primary-light);
    --modal-border-width: 1px;
    --modal-border-radius: 1rem;
    --modal-box-shadow: 0 0.5rem 1rem rgba(var(--bg-core-primary), 0.15);

    --modal-header-padding-x: 1.5rem; //close button
    --modal-header-padding-y: 1.5rem; //close button
    --modal-header-bg: var(--modal-bg);
    --modal-header-padding: 1.5rem;  
    --modal-header-border-color: var(--bg-core-primary-light);
    --modal-header-border-width: 1px;
    
    --modal-footer-bg: var(--modal-bg);
    --modal-footer-padding: 1.5rem;  
    --modal-footer-border-color: var(--bg-core-primary-light);
    --modal-footer-border-width: 1px; 

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0,0,0,.65);
    z-index: var(--modal-zindex);
    display: none;
    opacity: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    transition: opacity .15s linear;
    // Prevent Chrome on Windows from adding a focus outline. For details, see
    // https://github.com/twbs/bootstrap/pull/10951.
    outline: 0;
  }
  


    // When fading in the modal, animate it to slide down
    .modal.fade {
        opacity: 1;
        transition: opacity .15s linear;
    }
    .modal.show{
      display: block;
      
    }
  
    // When trying to close, animate focus to scale
    .modal.modal-static {
      transform:scale(1.1);
    }


  // Shell div to position the modal with bottom padding
  .modal-dialog {
    position: relative;
    width: auto;
    margin: var(--modal-margin);
    // allow clicks to pass through for custom click handling to close modal
    pointer-events: none;
  }
  
  .modal-dialog-scrollable {
    height: calc(100% - var(--modal-margin) * 2);
  

    .modal-content {
      max-height: 100%;
      overflow: hidden;
    }
  
    .modal-body {
      overflow-y: auto;
    }
  }
  
  .modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - var(--modal-margin) * 2);

  }
  
  // Actual modal
  .modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%; // Ensure `.modal-content` extends the full width of the parent `.modal-dialog`
    // counteract the pointer-events: none; in the .modal-dialog
    color: var(--modal-color);
    pointer-events: auto;
    background-color: var(--modal-bg);
    background-clip: padding-box;
    border: var(--modal-border-width) solid var(--modal-border-color);
    border-radius: var(--modal-border-radius);
    box-shadow: var(--modal-box-shadow);
    // Remove focus outline from opened modal
    outline: 0;
  }
  

  
  // Modal header
  // Top section of the modal w/ title and dismiss 
  .modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between; // Put modal header elements (title and dismiss) on opposite ends
    padding: var(--modal-header-padding);
    background-color: var(--modal-header-bg);
    border-bottom: var(--modal-header-border-width) solid var(--modal-header-border-color);
   
  
    .btn-close {
      padding: calc(var(--modal-header-padding-y) * .5) calc(var(--modal-header-padding-x) * .5);
      margin: calc(-.5 * var(--modal-header-padding-y)) calc(-.5 * var(--modal-header-padding-x)) calc(-.5 * var(--modal-header-padding-y)) auto;
    }
  }
  
  // Title text within header
  .modal-title {
    margin-bottom: 0;

  }
  
  // Modal body
  // Where all modal content resides (sibling of .modal-header and .modal-footer)
  .modal-body {
    position: relative;
    // Enable `flex-grow: 1` so that the body take up as much space as possible
    // when there should be a fixed height on `.modal-dialog`.
    flex: 1 1 auto;
    padding: var(--modal-padding);
  }
  
  // Footer (for actions)
  .modal-footer {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center; // vertically center
    justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
    padding: var(--modal-footer-padding);
    background-color: var(--modal-footer-bg);
    border-radius: var(--modal-border-radius);
    gap: .5rem;
  
}
    // Automatically set modal's width for larger viewports
    
    
    
    .modal-dialog { 
      max-width: 100%;
      max-height: 100%;
      padding: 0;
     

      @include breakpoint(sm) {
        max-width: 75vw;
        margin-right: auto;
        margin-left: auto;
        padding: var(--modal-padding);
       
        }  
      
      @include breakpoint(lg) {
        max-width: var(--modal-width);
        margin-right: auto;
        margin-left: auto;
        }
    }
    
  
    // // Modal background
    // .modal-backdrop {
    //     opacity: 0;
    //     display: none;
    //     position: fixed;
    //     top: 0;
    //     left: 0;
    //     z-index: #{$backdrop-zindex};
    //     width: 100vw;
    //     height: 100vh;
    //     background-color: #000;
    //     transition: opacity .15s linear;
    // }

    // .modal-backdrop.fade {
    //     opacity: .5;
    //     transition: opacity .15s linear;
    // }
    
    //   .modal-backdrop.show {
    //     display: block;
    // }


/*IMAGE MODAL*/
.modal.modal-image{

  --modal-image-height: 80vh;
  --modal-image-border-width: 0;
 
  
  .modal-content{
    overflow: hidden;
    height: var( --modal-image-height);
    border: var(--modal-image-border-width);
  }

  button.close{
    float: right;
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 0;
    text-shadow: none;
    color: inherit;
    background-color: rgba(255,255,255,.35);
    &:hover{
      background-color: rgba(255,255,255,.5);
    }
  }

img{
  height: 100%;
  object-fit:cover;
  }
}


/*ACTION MODAL*/
.modal.modal-basic{

  --modal-basic-width: 40vw;
  --modal-basic-height: 40vh;
  --modal-basic-padding: 1.5rem;
  --modal-basic-color: var(--text-core);
  --modal-basic-bg: var(--bg-core-primary-light);
  --modal-basic-border-color: var(--bg-core-primary-light);
  --modal-basic-border-width: 1px;
  --modal-basic-border-radius: 1rem;

  --modal-basic-header-bg: var(--modal-basic-bg);
  --modal-basic-header-padding: 1.5rem 1.5rem 0;  
  --modal-basic-header-border-color: var(--bg-core-primary-light);
  --modal-basic-header-border-width: 1px;
  
  --modal-basic-footer-bg: var(--modal-basic-bg);
  --modal-basic-footer-padding: 0 1.5rem 1.5rem;  
  --modal-basic-footer-border-color: var(--bg-core-primary-light);
  --modal-basic-footer-border-width: 1px; 


.modal-header {
  padding: var(--modal-basic-header-padding);
  background-color: var(--modal-basic-header-bg);
  border-bottom: var(--modal-basic-header-border-width) solid var(--modal-basic-header-border-color);
} 

.modal-body {
  position: relative;
  flex: 1 1 auto;
  padding: var(--modal-basic-padding);
}

.modal-footer {   
  padding: var(--modal-basic-footer-padding);
  background-color: var(--modal-basic-footer-bg);
  border-radius: var(--modal-basic-border-radius);  
}

.modal-dialog { 
  max-width: 100%;
  max-height: 100%;
  padding: 0;

  @include breakpoint(sm) {
    max-width: 75vw;
    margin-right: auto;
    margin-left: auto;
    padding: var(--modal-basic-padding);
    }  
  
  @include breakpoint(lg) {
    max-width: var(--modal-basic-width);
    margin-right: auto;
    margin-left: auto;
    }
  }

}
  



