// =============================================================================
// Boost.js | Component Styles
// (c) Mathigon
// =============================================================================


@use 'sass:color';
@import './mixins';

$success: #22ab24 !default;
$warn: #fd8c00 !default;
$error: #cd0e66 !default;
$dark-mode-background: #2d2c38 !default;


// Alert -----------------------------------------------------------------------

.snackbar {
  position: fixed;
  top: 52px;
  left: 50%;
  z-index: 500;
  transform: translateX(-50%);
}

x-alert {
  background: black;
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(black, 30%);
  padding: 8px 20px;
  color: white;
  display: none;
  max-width: 300px;
  font-size: 16px;
  line-height: 1.4;
  width: max-content;

  x-icon { margin: -2px 6px 20px -4px; float: left; }
  &.error { background: color.adjust($error, $lightness: -5%); }
  &.warn { background: color.adjust($warn, $lightness: -5%); }
  &.success { background: color.adjust($success, $lightness: -5%); }
}

// Icons -----------------------------------------------------------------------

x-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  fill: currentColor;
  svg { display: block; }
  &[name="warning"] { fill: $error; }
}

.button x-icon { margin: -10px 3px -10px -8px; }


// Modals ----------------------------------------------------------------------

.modal-background {
  position: fixed;
  z-index: 400;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(black, 80%);
  display: none;
  transition: background .4s;
  -webkit-backdrop-filter: blur(4px);
  &.light { background: rgba(white, 90%); }
  html.webview & { top: 0; }
}

x-modal {
  z-index: 401;
  position: fixed;
  width: 520px;
  max-width: calc(100% - 40px);
  max-height: calc(100vh - 84px);
  @include theme(background, white, $dark-mode-background);
  border-radius: 12px;
  top: 50%;
  left: 50%;
  margin-top: 22px;
  transform: translate(-50%, -50%);
  box-shadow: 0 6px 32px rgba(black, 80%);
  display: none;
  box-sizing: border-box;

  &.light { box-shadow: 0 4px 20px rgba(black, 25%); }
  html.webview & { max-height: calc(100% - 40px); margin-top: 0; }

  .modal-body {
    height: 100%;
    max-height: calc(100vh - 84px);
    padding: 24px;
    box-sizing: border-box;
    @include overflow-scroll();
  }

  @media screen and (max-height: 720px) {
    &.interactive { top: 42px; transform: translate(-50%, 0); }
  }

  // This value should actually be 84px, however, on iOS Safari, vh also
  // includes the toolbar at the bottom. We can't use 100% in .modal-body below,
  // since it doesn't take account of the max-height of parents. This compromise
  // adds unnecessary space on other devices,
  .is-safari:not(.is-webview) & {
    &, .modal-body { max-height: calc(100vh - 200px); }
  }

  h2 { margin-top: 0; }
  h2 x-icon { margin: -6px 4px -6px -2px; }

  h3 { margin: 1.5em 0 .8em; }
  h3 x-icon { margin: 0 5px -5px 0; }

  .btn-row { text-align: right; margin: 0; }
  .form-large { margin: 0 -8px -10px; }
  p:last-child:not(.btn-row), ul:last-child { margin-bottom: 0; }
  .form-checkbox { margin: 16px 0; }
  hr { margin: 1.5em 0; }

  .close  {
    @include theme(fill, rgba(black, 40%), rgba(white, 40%));
    position: absolute;
    right: 0; top: 0;
    padding: 8px;
    transition: transform .2s, color .2s;
    cursor: pointer;
    z-index: 10;
    display: block;
    &:hover { transform: scale(1.4); @include theme(color, black, white);  }
  }

  &.video {
    border-radius: 0;
    background: black;
    width: 1200px;
    .video-wrap { position: relative; height: 0; padding-bottom: 56.25%; }
    iframe, video { position: absolute; width: 100%; height: 100%; }
    .close x-icon { fill: rgba(white, 80%); top: -40px; }
  }
}
