/*
 Alert  -- Message only (categorized as danger, error, success, warning),
 Dialog -- Decision prompt (ie. Are you sure you want to delete this item?)
 Popup  -- Floating container (ie. settings/options on the same page)
 Panel  -- Page container
 Modal  -- Forces/requires user interaction. Wrapper/parent of Alerts & Dialogs only.
 -------------------------------------------------*/
.alert,
.dialog,
.popup {
    border-radius: 8px;
    box-shadow: 0 0 2em rgba(255, 255, 255, .5), 0 0 1em rgba(0, 0, 0, .15);
    color: #333;
    font-weight: 400;
    margin: 0;
    padding: 2em;
    position: absolute;
    z-index: 99;
}

.alert,
.dialog {
    display: flex;
    left: 50%; top: 50%;
    max-width: 95vw;
    transform: translate3d(-50%, -50%, 0) scale3d(0, 0, 0);
}

.dialog > :not(.action-buttons):first-of-type,
.panel:first-child,
.panel > :not(.grid):first-child,
.popup > :not(.wrap):first-child,
.popup > .wrap > :first-child {
    margin-top: 0;
}

.panel:last-child,
.panel > :not(.grid):last-child,
.popup > :not(.wrap):last-child,
.popup > .wrap > :last-child {
    margin-bottom: 0;
}

/*
 Button Group for Panel, Dialog and Popup
 -------------------------------------------------*/
.action-buttons {
    align-content: end;
    display: grid;
    gap: 1em 2em;
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    margin: 2em 0 0 0;
    order: 1;
    width: 100%;
}

.action-buttons > .btn {
    margin: 0;
}

/*
 Alert
 -------------------------------------------------*/
.alert {
    align-items: center;
    background-color: white;
}

.alert button {
    align-self: stretch;
    background-color: transparent;
    border-radius: 0 8px 8px 0;
    border-left: 1px solid #f0f0f0;
    color: #aaa;
    margin: -2em -2em -2em 1.5em;
    order: 1;
    padding: 0 2.5em;
    text-transform: uppercase;
    transition: color .3s;
}

.alert button:hover {
    box-shadow: none;
    color: #666;
}

/*
 Alert - Icons
 -------------------------------------------------*/
.alert::before {
    color: #999;
    content: "info";
    display: flex;
    font: 400 4em "Material Icons";
    height: 4rem;
    line-height: 1;
    margin: 0 1.5rem 0 -.5rem;
    width: 4rem;
}

.alert.alert-danger::before {
    color: orangered;
    content: "error_outline";
}

.alert.alert-error::before {
    color: red;
    content: "highlight_off";
}

.alert.alert-success::before {
    color: green;
    content: "check_circle_outline";
}

.alert.alert-warning::before {
    color: orange;
    content: "warning_amber";
}

/*
 Dialog
 -------------------------------------------------*/
.dialog {
    background: #f9f9f9 linear-gradient(180deg, #fff, #f9f9f9) no-repeat 0 0;
    border: 8px solid white;
    flex-direction: column;
}

/*
 Modal
 -------------------------------------------------*/
.modal {
    background: rgba(0, 0, 0, .25);
    position: fixed;
    left: 0; top: 0; bottom: 0; right: 0;
    z-index: 9999;
}

.modal:not(.open) {
    display: none;
}

/*
 Panel
 -------------------------------------------------*/
.panel {
    background: white linear-gradient(180deg, #fff 60%, #f9f9fc 100%);
    border-radius: 12px;
    box-shadow: 0 3px 3px rgba(0, 0, 0, .05);
    margin: 2em 0;
    padding: 3em;
}

/*
 Panel - Floating
 -------------------------------------------------*/
.panel.floating {
    box-shadow: 0 .25em 1em rgba(0, 0, 0, .1);
    display: flex;
    flex-flow: column;
    opacity: 0;
    padding: 0;
    position: fixed;
    left: 50%; bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    z-index: 9998;
    transform: translate3d(-50%, 105%, 0);
    transition: transform .35s, opacity 0s .4s;
}

.panel.floating.open {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
    transition-delay: 0s, 0s;
}

.panel.floating:before {
    content: "close";
    font: 400 2.125rem "Material Icons";
    padding: 5px;
    width: 44px;
}

@media screen and (min-width: 420px) {
    .panel.floating {
        height: auto;
        margin: 3rem 0 1.25rem 0;
        max-height: calc(100vh - 4em);
        max-width: 65vw;
        min-width: 316px;
        width: auto;
    }

    .panel.floating:before {
        display: none;
    }
}

@media screen and (min-width: 720px) {
    .panel.floating {
        margin-top: 1.25rem;
        max-width: 50vw;
        left: auto;
        bottom: auto;
        top: calc(50% - 1.25rem);
        right: 1.25rem;
        transform: translate3d(105%, -50%, 0);
    }

    .panel.floating.open {
        transform: translate3d(0, -50%, 0);
    }
}
/*




@media screen and (min-width: 420px) {
    .panel.floating {
        margin: 1em 14px 1em 0;
        width: auto;
        height: auto;
        min-width: 316px;
        max-height: calc(100vh - 2em);
        max-width: 65vw;
        top: calc(50% - 1em);
    }

    .panel.floating:before {
        display: none;
    }
}

@media screen and (min-width: 960px) {
    .panel.floating {
        max-width: 45vw;
    }
}

*/


.panel.floating > * {
    flex: 0 0 auto;
    margin: 0;
    padding: 2rem;
    width: 100%;
}

.panel.floating > .wrap {
    padding: 0 2rem;
    overflow: auto;
    flex: 1 1 auto;
}

/*
 Popup
 -------------------------------------------------*/
.popup {
    background: #f9f9f9 linear-gradient(180deg, #fff, #f9f9f9) no-repeat 0 0;
    border: none;
    display: none;
    max-height: 50vh;
    max-width: 50vw;
    padding: 1.5em;
}

body > .popup {
    display: flex;
}

.popup > .wrap {
    margin: -1.5em;
    padding: 1.5em;
    overflow: auto;
}

.popup .action-buttons {
    grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
}

/*
  Popup - Arrows (.arrow)
 -------------------------------------------------*/
.popup.open.arrow::before,
.popup.open.arrow::after {
    content: "";
    display: block;
    border: 12px solid transparent;
    position: absolute;
    z-index: 1;
}

/* above the container (.arrow-above) */
.popup.arrow.arrow-above::before,
.popup.arrow.arrow-above::after {
    border-bottom-color: white;
    left: calc(50% - 12px); bottom: 100%;
}

/* below the container (.arrow-below) */
.popup.arrow.arrow-below::before,
.popup.arrow.arrow-below::after {
    border-top-color: #f9f9f9;
    left: calc(50% - 12px); top: 100%;
}

/* left of the container (.arrow-left) */
.popup.arrow.arrow-left::before,
.popup.arrow.arrow-left::after {
    border-right-color: white;
    right: 100%; top: calc(50% - 12px);
}

/* right of the container (.arrow-right) */
.popup.arrow.arrow-right::before,
.popup.arrow.arrow-right::after {
    border-left-color: white;
    left: 100%; top: calc(50% - 12px);
}

/*
  Popup - Arrow Shadows (included with arrow)
 -------------------------------------------------*/
.popup.arrow.arrow-above::before {
    border-bottom-color: rgba(0, 0, 0, .1);
    margin-bottom: 1px;
}

.popup.arrow.arrow-below::before {
    border-top-color: rgba(0, 0, 0, .1);
    margin-top: 1px;
}

.popup.arrow.arrow-left::before {
    border-right-color: rgba(0, 0, 0, .1);
    margin-right: 1px;
}

.popup.arrow.arrow-right::before {
    border-left-color: rgba(0, 0, 0, .1);
    margin-left: 1px;
}

/*
 Alert & Dialog - Animation
 -------------------------------------------------*/
.alert.open,
.dialog.open {
    animation: appear-scaled .4s forwards;
}

.alert.closed,
.dialog.closed {
    animation: appear-scaled .4s reverse forwards;
}

@keyframes appear-scaled {
    0%, 50% {
        transform: translate3d(-50%, -50%, 0) scale3d(0, 0, 0) ;
    }
    100% {
        transform: translate3d(-50%, -50%, 0) scale3d(1, 1, 1) ;
    }
}

/*
 Popup - Animation
 -------------------------------------------------*/
.popup {
    transition: opacity .25s, transform 0s;
}

.popup:not(.open) {
    opacity: 0;
    transform: scale3d(0, 0, 0);
    transition-delay: 0s, .25s;
}
