@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 400;
  src: url(https://cdn.bfree.ai/shared/Material-Symbols-Outlined.woff2) format("woff2");
}

@font-face {
  font-family: "Open Dyslexic";
  font-size: normal;
  font-weight: 400;
  src: url(https://cdn.bfree.ai/shared/OpenDyslexic-Regular.woff2) format("woff2");
}

@keyframes a11ySpinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: a11ySpinner 1s linear infinite;
}

a11y-widget,
a11y-container,
a11y-btn,
a11y-container,
a11y-feature-item,
a11y-feature-item-link,
a11y-feature-item-link a,
a11y-icon,
a11y-main,
a11y-text,
a11y-switch,
a11y-page-summarize {
  box-sizing: border-box;
}

a11y-widget {
  font-size: 16px;

  a11y-main {
    position: fixed;
    z-index: 9002;
    /* default position (bottom-right) */
    bottom: 16px;
    right: 16px;

    transition: all 0.3s allow-discrete;
    opacity: 1;
    transform: scale(1);
    transform-origin: 100% 100%;

    &:not([open="true"]) {
      display: none;
      opacity: 0;
      transform: scale(0.8);
    }

    @starting-style {
      opacity: 0;
      transform: scale(0.8);
    }
  }

  a11y-btn[data-type="fab"] {
    position: fixed;
    z-index: 9000;
    /* default position (bottom-right) */
    bottom: 16px;
    right: 16px;

    width: 56px;
    height: 56px;
    color: var(--text);
    transition: all 0.3s;

    outline: 2px solid var(--background-faded);
    border-radius: 8px;
    background-color: var(--background);
    box-shadow: 0 0 12px var(--shadow);

    a11y-icon {
      font-size: 32px;
    }

    &:hover {
      outline: 2px solid var(--border);
      box-shadow: 0 0 24px -8px var(--border);
    }
  }

  &[data-position="top-left"] {
    a11y-main {
      top: 16px;
      left: 16px;
      transform-origin: 0 0;
    }
    a11y-btn[data-type="fab"] {
      top: 16px;
      left: 16px;
    }
  }

  &[data-position="top-center"] {
    a11y-main {
      top: 16px;
      left: 50%;
      transform: translateX(-50%) scale(1);
      transform-origin: 50% 0;
      &:not([open="true"]) {
        transform: translateX(-50%) scale(0.8);
      }
      @starting-style {
        transform: translateX(-50%) scale(0.8);
      }
    }
    a11y-btn[data-type="fab"] {
      top: 16px;
      left: 50%;
      transform: translateX(-50%);
    }
  }

  &[data-position="top-right"] {
    a11y-main {
      top: 16px;
      right: 16px;
      transform-origin: 100% 0;
    }
    a11y-btn[data-type="fab"] {
      top: 16px;
      right: 16px;
    }
  }

  &[data-position="center-left"] {
    a11y-main {
      top: 50%;
      left: 16px;
      transform: translateY(-50%) scale(1);
      transform-origin: 0 50%;
      &:not([open="true"]) {
        transform: translateY(-50%) scale(0.8);
      }
      @starting-style {
        transform: translateY(-50%) scale(0.8);
      }
    }
    a11y-btn[data-type="fab"] {
      top: 50%;
      left: 16px;
      transform: translateY(-50%);
    }
  }

  &[data-position="center"] {
    a11y-main {
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(1);
      transform-origin: 50% 50%;
      &:not([open="true"]) {
        transform: translate(-50%, -50%) scale(0.8);
      }
      @starting-style {
        transform: translate(-50%, -50%) scale(0.8);
      }
    }
    a11y-btn[data-type="fab"] {
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }

  &[data-position="center-right"] {
    a11y-main {
      top: 50%;
      right: 16px;
      transform: translateY(-50%) scale(1);
      transform-origin: 100% 50%;
      &:not([open="true"]) {
        transform: translateY(-50%) scale(0.8);
      }
      @starting-style {
        transform: translateY(-50%) scale(0.8);
      }
    }
    a11y-btn[data-type="fab"] {
      top: 50%;
      right: 16px;
      transform: translateY(-50%);
    }
  }

  &[data-position="bottom-left"] {
    a11y-main {
      bottom: 16px;
      left: 16px;
      transform-origin: 0% 100%;
    }
    a11y-btn[data-type="fab"] {
      bottom: 16px;
      left: 16px;
    }
  }

  &[data-position="bottom-center"] {
    a11y-main {
      bottom: 16px;
      left: 50%;
      transform: translateX(-50%) scale(1);
      transform-origin: 50% 100%;
      &:not([open="true"]) {
        transform: translateX(-50%) scale(0.8);
      }
      @starting-style {
        transform: translateX(-50%) scale(0.8);
      }
    }
    a11y-btn[data-type="fab"] {
      bottom: 16px;
      left: 50%;
      transform: translateX(-50%);
    }
  }

  &[data-position="bottom-right"] {
    a11y-main {
      bottom: 16px;
      right: 16px;
      transform-origin: 100% 100%;
    }
    a11y-btn[data-type="fab"] {
      bottom: 16px;
      right: 16px;
    }
  }
}

a11y-container {
  display: block;
}

a11y-text {
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 125%;
}

a11y-icon.a11y-material-symbols {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
}

a11y-btn {
  display: flex;
  justify-content: center;
  align-items: center;

  width: auto;
  height: auto;
  min-height: 44px;
  min-width: 44px;
  font: inherit;
  background-color: inherit;
  border: none;

  &:not(:disabled):hover {
    cursor: pointer;
  }
}

a11y-switch {
  display: inline-block;
  width: 50px;
  height: 28px;
  cursor: pointer;
  outline: none;

  a11y-container.a11y-switch-track {
    width: 100%;
    height: 100%;
    background-color: var(--background-faded2);
    border-radius: 14px;
    position: relative;
    transition: background-color 0.3s;
  }

  a11y-container.a11y-switch-knob {
    width: 24px;
    height: 24px;
    background-color: var(--background);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
  }

  &[active="true"] .a11y-switch-track {
    background-color: var(--primary);
  }

  &[active="true"] .a11y-switch-knob {
    transform: translateX(22px);
  }
}

a11y-main {
  font-family: Arial, Helvetica, sans-serif;
  display: flex;
  flex-direction: column;
  height: min(80vh, 800px);
  width: min(calc(100% - 32px), 600px);

  background-color: var(--background);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 48px var(--shadow);

  .a11y-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    min-height: 60px;
    box-shadow: 0 4px var(--shadow);
    border-bottom: 2px solid var(--border-faded);

    a11y-menu {
      box-sizing: border-box;
      display: block;

      .a11y-menu__button {
        color: var(--text);
        line-height: 0;
        padding: 6px;
        border-radius: 50%;
        cursor: pointer;
        user-select: none;

        &:hover {
          outline: 1px solid var(--border);
        }
      }

      &[open="true"] {
        .a11y-menu__button {
          outline: 1px solid var(--border);
        }
      }

      &:not([open="true"]) .a11y-menu__dropdown {
        display: none;
        opacity: 0;
        transform: scale(0.8);
      }

      .a11y-menu__dropdown {
        position: absolute;
        z-index: 9002;
        background: var(--background);
        top: 56px;
        left: 12px;
        box-shadow: 0 0 4px var(--shadow);
        width: 100%;
        max-width: 320px;
        border-radius: 8px;
        overflow: hidden;

        display: block;
        opacity: 1;
        transform: scale(1);
        transform-origin: top left;
        transition: all 0.3s allow-discrete;

        @starting-style {
          opacity: 0;
          transform: scale(0.8);
        }

        a {
          text-decoration: none;
          color: inherit;
        }
      }

      .a11y-menu__dropdown-item {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: start;
        padding: 16px;
        gap: 12px;

        &:hover {
          background-color: var(--background-faded);
        }

        a11y-icon {
          color: var(--text);
          line-height: 0;
        }
        a11y-text {
          color: var(--text);
          font-size: 1em;
        }
      }
    }

    .a11y-title {
      font-size: 1.2em;
      font-weight: bold;
      color: var(--text);
    }

    .a11y-close-btn {
      color: var(--text);
      border-radius: 50%;
      min-width: 36px;
      min-height: 36px;
      &:hover {
        background-color: var(--background-faded);
      }
    }
  }

  .a11y-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-background);
    background-color: var(--background-faded);

    a11y-container.a11y-body-header {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 16px;

      background-color: var(--background);
      padding: 32px 24px;
      box-shadow: 0 0 4px var(--shadow);

      .a11y-body-header__icon {
        font-size: 36px;
        padding: 4px;
        border: 3px solid var(--text);
        border-radius: 50%;
        color: var(--text);
      }

      a11y-text {
        font-size: 1.2em;
        text-align: center;
        color: var(--text-faded);
        line-height: 150%;
      }
    }

    a11y-page-summarize {
      position: relative;
      display: flex;
      flex-direction: row;
      justify-content: start;
      align-items: center;
      gap: 16px;

      width: 100%;
      padding: 8px;
      user-select: none;

      outline: 2px solid var(--border-faded);
      background-color: var(--background);
      border-radius: 8px;
      transition: all 0.3s allow-discrete;
      opacity: 1;

      &:not([open="true"]) {
        display: none;
        opacity: 0;
      }

      @starting-style {
        opacity: 0;
      }

      a11y-text,
      * a11y-text {
        color: var(--text-faded);
        text-align: center;
      }

      a11y-container.a11y-spinner {
        width: 32px;
        height: 32px;
        border: 4px solid var(--text);
        border-bottom-color: transparent;
        border-radius: 50%;
        display: inline-block;
        box-sizing: border-box;
        animation: a11ySpinner 1s linear infinite;
        margin: 20px auto;
      }
    }

    .a11y-feature-container {
      padding: 16px;
    }

    .a11y-feature-info {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      gap: 4px;
    }

    .a11y-feature-title {
      font-size: 1.3em;
      font-weight: 600;
      text-align: center;
    }

    .a11y-feature-description {
      color: var(--text-faded);
    }

    .a11y-feature-item-container {
      margin-top: 16px;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
  }

  a11y-feature-item {
    position: relative;
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: center;
    gap: 16px;

    width: 100%;
    padding: 8px;
    user-select: none;

    outline: 2px solid var(--border-faded);
    background-color: var(--background);
    border-radius: 8px;
    transition: box-shadow 0.1s;

    &:hover {
      cursor: pointer;
      box-shadow: 0 0 16px var(--shadow);
    }

    a11y-container.a11y-feature_item__icon-container {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 64px;
      height: 64px;
      border: 3px solid var(--border);
      border-radius: 8px;
    }

    a11y-icon.a11y-feature-item__icon {
      color: var(--text);
      line-height: 100%;
      font-size: 42px;
    }

    a11y-container.a11y-feature_item__content-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    a11y-text.a11y-feature_item__content__title {
      font-weight: 600;
      font-size: 1.2em;
    }

    a11y-text.a11y-feature_item__content__description {
      font-size: 0.8em;
      color: var(--text-faded);
    }
  }

  a11y-feature-item-link a {
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: center;
    gap: 8px;

    width: 100%;
    padding: 8px;
    user-select: none;
    text-decoration: none;

    outline: 2px solid var(--border-faded);
    background-color: var(--background);
    border-radius: 8px;
    transition: box-shadow 0.1s;

    &:hover {
      cursor: pointer;
      box-shadow: 0 0 16px rgba(0, 0, 0, 0.2);
    }

    a11y-icon.a11y-feature-item_link__icon {
      line-height: 100%;
      font-size: 32px;
      text-decoration: none;
      color: var(--text);
    }

    a11y-text.a11y-feature_item_link__title {
      font-weight: 600;
      font-size: 1.2em;
      text-decoration: none;
      color: var(--text);
    }
  }

  .a11y-footer {
    text-align: center;
    padding: 6px 0;
    border-top: 2px solid var(--border-faded);
    color: var(--text-faded);
    font-size: 0.9em;

    a {
      font: inherit;
      color: inherit;
      text-decoration: none;
      transition: all 0.3s;
      cursor: pointer;

      &:hover {
        color: var(--text);
      }
    }
  }

  &[open="true"] ~ a11y-backdrop {
    position: fixed;
    z-index: 9001;

    inset: 0;
    width: 100%;
    height: 100%;
  }
}

a11y-feature-item#a11y-feature-ai-summarize {
  a11y-btn.a11y-summarize-speech-btn {
    border-radius: 50%;
    background-color: var(--background-faded);
    color: var(--text-faded);
    transition: all 0.2s;
    &:hover {
      color: var(--text);
      background-color: var(--background-faded2);
    }
  }

  &[active="false"] a11y-btn.a11y-summarize-speech-btn {
    display: none;
  }
}

body.a11y-grayscale::after,
body.a11y-higherContrast::after,
body.a11y-invertColors::after,
body.a11y-reduceBrightness::after {
  content: "";
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

body.a11y-reduceTransparency {
  & > *:not(a11y-widget):not(script):not(noscript),
  & > *:not(a11y-widget):not(script):not(noscript) * {
    background: solid !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
  }
}

body.a11y-focusText {
  & > *:not(a11y-widget):not(script):not(noscript),
  & > *:not(a11y-widget):not(script):not(noscript) * {
    color: #000 !important;
    background-color: transparent !important;
    background-image: none !important;
    letter-spacing: 0px !important;
  }
}

body.a11y-dyslexic {
  & > *:not(a11y-widget):not(script):not(noscript),
  & > *:not(a11y-widget):not(script):not(noscript) * {
    font-family: "Open Dyslexic", Arial, Helvetica, sans-serif !important;
  }
}

body.a11y-fontSystem {
  & > *:not(a11y-widget):not(script):not(noscript),
  & > *:not(a11y-widget):not(script):not(noscript) * {
    font-family:
      system-ui,
      -apple-system,
      BlinkMacSystemFont,
      "Segoe UI",
      Roboto,
      Oxygen,
      Ubuntu,
      Cantarell,
      "Open Sans",
      "Helvetica Neue",
      sans-serif !important;
  }
}

body.a11y-highlightHeading {
  & > h1,
  & > h2,
  & > h3,
  & > h4,
  & > h5,
  & > h6,
  & > *:not(a11y-widget):not(script):not(noscript) h1,
  & > *:not(a11y-widget):not(script):not(noscript) h2,
  & > *:not(a11y-widget):not(script):not(noscript) h3,
  & > *:not(a11y-widget):not(script):not(noscript) h4,
  & > *:not(a11y-widget):not(script):not(noscript) h5,
  & > *:not(a11y-widget):not(script):not(noscript) h6 {
    outline: 3px solid rgb(255, 100, 0) !important;
  }
}

body.a11y-highlightLink {
  & > a,
  & > *:not(a11y-widget):not(script):not(noscript) a {
    background: #000 !important;
    color: #fff !important;
    text-decoration: underline !important;
    outline: 3px solid rgb(255, 100, 0) !important;
  }
  & > a *,
  & > *:not(a11y-widget):not(script):not(noscript) a * {
    background: #000 !important;
    color: #fff !important;
    text-decoration: underline !important;
  }
}

body.a11y-hideImage {
  & > *:not(a11y-widget):not(script):not(noscript),
  & > *:not(a11y-widget):not(script):not(noscript) * {
    background-image: none !important;
  }
  & > img,
  & > video,
  & > *:not(a11y-widget):not(script):not(noscript) img,
  & > *:not(a11y-widget):not(script):not(noscript) video {
    visibility: hidden !important;
  }
}

body.a11y-largerCursor,
body.a11y-largerCursor * {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M20.978 13.21a1 1 0 0 0-.396-1.024l-14-10a.999.999 0 0 0-1.575.931l2 17a1 1 0 0 0 1.767.516l3.612-4.416 3.377 5.46 1.701-1.052-3.357-5.428 6.089-1.218a.995.995 0 0 0 .782-.769z'/%3E%3C/svg%3E")
      6 0,
    pointer !important;
}

body.a11y-reduceMotion {
  & > *:not(a11y-widget):not(script):not(noscript),
  & > *:not(a11y-widget):not(script):not(noscript) *,
  & > *:not(a11y-widget):not(script):not(noscript) *:hover,
  & > *:not(a11y-widget):not(script):not(noscript) *:active,
  & > *:not(a11y-widget):not(script):not(noscript) *:focus,
  & > *:not(a11y-widget):not(script):not(noscript) *::after,
  & > *:not(a11y-widget):not(script):not(noscript) *::before {
    transition: none !important;
    animation-duration: 0s !important;
    animation-fill-mode: forwards !important;
  }
}

@media screen and (max-width: 640px) {
  a11y-widget {
    font-size: 14px;
  }

  a11y-main {
    transform: translate(0) !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }
}
