@import 'base.scss';
@import 'components/atoms/_color.scss';
@import 'components/atoms/_text.scss';
@import 'components/atoms/_icon.scss';
@import 'components/atoms/anchor.scss';
@import 'components/organisms/header.scss';
@import 'components/molecules/homepage-link.scss';
@import 'components/molecules/format-toggle.scss';

:root {
  --header-height: 3.5rem;
}

.#{organism('header')} {
  &-home {
      &-title, &-sub-title {
        @media (max-width: 1023px) {
          @include txt-1;
        }
      }
  }
}

.#{molecule('code-snippet')} {
  margin: 0;
  max-height: 100%;
  box-shadow: shadows('regular');
  pre {
    max-height: 100%;
  }
  code {
    @include txt-mono;
  }
}

.#{molecule('format-toggle')} {
  margin-left: 0;
  max-width: 240px;

  .#{molecule('format-toggle')}-angle {
    transition: all 0.2s ease;
    transition-delay: 0.05s;
  }

  &.open .#{molecule('format-toggle')}-angle {
    transform: rotate(-180deg);
  }

  &-link {
    &.active {
      display: none;
    }
  }

  &-link,
  &-selected {
    line-height: 2rem;
    font-size: 16px;
  }

  &-formats {
    .#{molecule('format-toggle')}-selected:focus + &,
    .#{molecule('format-toggle')}-selected:hover + &,
    &:focus-within,
    &:hover {
      pointer-events: none;
      opacity: 0;
      transform: translateY(-20px);
    }

    .#{molecule('format-toggle')}.open & {
      pointer-events: auto;
      opacity: 1;
      transform: translateY(0);
    }
  }
}

main {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  flex-flow: row wrap;
  > * {
    flex: 1;
    margin: 1rem 1rem;
    min-width: 288px;
  }
}

section {
  &.config {
    max-width: 420px;
    margin-right: 6rem;

    .config-footer {
      margin-top: 4rem;
    }
  }
  &.boilerplate {
    flex: 1 auto;
    width: 500px;
    height: 100%;
  }
}

/* options */

.category {
  margin-bottom: 1rem;
}

.option {
  margin: 4px 0;
  max-width: 100%;
  width: 300px;
  min-width: 100px;
  @include txt;
  @include txt-1;
  position: relative;
  a {
    @include txt;
    text-decoration: underline;
  }
  .value {
    max-width: 500px;
    padding: 8px;
    background-color: color('athens-gray');
    display: flex;
    justify-content: space-between;
    > * {
      display: inline-block;
      width: calc(50% - 8px);
    }
    label {
      line-height: 32px;
    }
    input[type=text] {
      padding: 0 8px;
      border: none;
    }
    input[type=checkbox] {
      margin-right: auto;
      margin-left: 1rem;
      margin-top: 0.3rem;
    }
  }
  input {
    &[type=radio], &[type=checkbox] {
      font-size: 100%;
      line-height: 1.5rem;
      border-radius: 0;
      background: none;
      outline: 0;
      position: relative;
      margin-top: 0;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      width: 20px;
      height: 20px;
      border: 1px solid color('blue-ribbon');
      vertical-align: middle;
      margin-right: .5rem;
      text-align: center;
    }
    &[type=radio]:after {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      content: " ";
      line-height: 1.4rem;
      vertical-align: middle;
      text-align: center;
      background-color: #fff;
    }
    &[type=checkbox] {
      &:after {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        content: " ";
        line-height: 1.4rem;
        vertical-align: middle;
        text-align: center;
        background-color: #fff;
      }
      &:checked:after {
        line-height: 1.2rem;
        vertical-align: middle;
        text-align: center;
        background-color: color('blue-ribbon');
        color: #fff;
        content: "✓";
      }
    }
    &[type=radio] {
      &:checked {
        background-color: #fff;
        &:after {
          content: "";
          font-size: 3rem;
          background-color: color('blue-ribbon');
        }
      }
      border-radius: 20px;
      &:after {
        top: 3px;
        bottom: 3px;
        left: 3px;
        right: 3px;
        border-radius: 12px;
      }
    }
  }
}

.help {
  background-color: color('athens-gray');
  padding: 8px;
  @include txt;
  @include txt-1;
  margin: 8px 0;
  font-size: 1rem;
  a {
    @include color-blue-ribbon;
    text-decoration: none;
  }
  @media (min-width: 1024px) {
    margin: 0;
    margin-left: 14px;
    background-color: color('white');
    box-shadow: shadows('regular');
    display: inline;
    position: absolute;
    width: fit-content;
    max-width: 400px;
    z-index: 100;
  }
}
.help:after {
  box-shadow: shadows('regular');
  position: absolute;
  top: 5px;
  left: -10px;
  content: '';
  width: 0;
  height: 0;
  border-right: solid 10px color('white');
  border-bottom: solid 10px transparent;
  border-top: solid 10px transparent;
}

.help-toggle {
  display: inline-block;
  width: 24px;
  height: 24px;
  cursor: pointer;
  background-color: color('athens-gray');
  border-radius: 50%;
  text-align: center;
  @include txt;
  @include txt-strong;
  line-height: inherit;
}

.fab {
  color: #fafafa;
  font-size: 14px;
  font-weight: 400;
  box-shadow: 0 1px 1.5px 0 rgba(0, 0, 0, 0.12), 0 1px 1px 0 rgba(0, 0, 0, 0.24);
  height: 48px;
  padding: 0 20px;
  line-height: 48px;
  border-radius: 100px;
  border: none;
  outline: none;
  background: color('blue-ribbon');
  z-index: 9999;
  bottom: 16px;
  right: 16px;
  position: fixed;
  text-transform: uppercase;
  transform: scale(0.0);
  @include txt-font-accent;
  @include txt-strong;
}

@media (min-width: 930px) {
  .fab {
    display: none;
  }
}

.select {
  position: relative;
  display: inline-block;
  display: inline-flex;
  align-items: center;
  background: color('white');
  border: 1px solid color('blue-ribbon');

  &-toggle {
    padding: 0.1em 0.25em;
    padding: 3px 32px 3px 8px;
    border: 0;
    border-radius: 0;
    background: color('white');
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;

    @include txt;
  }

  &:after {
    content: '';
    position: absolute;
    pointer-events: none;
    top: 6px;
    right: 8px;
    width: 16px;
    height: 20px;
    background: color('white');
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='%2348525C'%3E%3Cpath d='M59.863 17.14l4.137 5.488-32 24.232-32-24.232 4.137-5.488 27.863 21.108z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
  }
}

a.anchor {
  display: block;
  position: relative;
  top: calc(-1 * var(--header-height) - 1rem);
  visibility: hidden;
}

.highlight-block {
  padding: 0;
  width: 100%;
  background-color: #516477;
}

/* Disable inputs while AMP Runtime is still loading */

body {
  &.amp-mode-mouse .fab, &.amp-mode-touch .fab {
    animation: expand .25s ease-in-out .25s forwards;
    pointer-events: auto;
  }
  &:not(.amp-mode-mouse):not(.amp-mode-touch) {
    label, input {
      opacity: 0.3;
      pointer-events: none;
    }
    button {
      opacity: 0.3;
      pointer-events: none;
      &.active {
        opacity: 0.5;
      }
    }
  }
}

@keyframes expand {
  0% {
    transform: scale(0.0);
  }

  100% {
    transform: scale(1);
  }
}
