@font-face {
  font-family: 'LSBSymbolWeb';
  src:
    url('https://s3.amazonaws.com/lsb-production/fonts/LSBSymbol.eot?')
      format('eot'),
    url('https://s3.amazonaws.com/lsb-production/fonts/LSBSymbol.woff')
      format('woff'),
    url('https://s3.amazonaws.com/lsb-production/fonts/LSBSymbol.ttf')
      format('truetype'),
    url('https://s3.amazonaws.com/lsb-production/fonts/LSBSymbol.svg#LSBSymbol')
      format('svg');
}

:root {
  --lsml-button-background: #f4f4f4;
  --lsml-button-active-background: #e0e0e0;
  --lsml-button-border: 1px solid #e0e0e0;
  --lsml-button-foreground: #000;
  --lsml-button-border-radius: 5px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --lsml-button-background: #333;
    --lsml-button-active-background: #666;
    --lsml-button-border: 1px solid #666;
    --lsml-button-foreground: #fff;
  }
}

/* =================
 * Editor
 * ================= */

.__lsml-editor .ck.ck-editor__editable_inline {
  border: var(--lsml-button-border);
  margin: 0.25rem 0;
}

.__lsml-editor_toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  row-gap: 0.25rem;
}

.__lsml-editor_control-group {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
}

.__lsml-editor_select,
.__lsml-editor_text-input {
  height: 2rem;
  line-height: 1.25rem;
  padding: 0.25rem;
}

.__lsml-editor_separator {
  display: block;
  margin-left: 0.25rem;
  margin-right: 0.25rem;
  height: 2rem;
  width: 1px;
  border-left: var(--lsml-button-border);
}

.__lsml-editor_button {
  display: block;
  margin: 0;
  padding: 0;

  .__lsml-editor_toggle-input {
    display: none;

    & + button {
      display: block;
      cursor: pointer;
      margin: 0;
      padding: calc(0.25rem - 1px);
      width: 2rem;
      height: 2rem;
      color: var(--lsml-button-foreground);
      background-color: var(--lsml-button-background);
      border: var(--lsml-button-border);
      border-radius: 0;

      & > svg {
        display: block;
        width: 1.5rem;
        height: 1.5rem;

        & text:not([fill]),
        & path:not([fill]),
        & rect:not([fill]) {
          fill: var(--lsml-button-foreground);
        }
      }
    }

    &:checked + button {
      background-color: var(--lsml-button-active-background);
    }
  }

  & > button {
    display: block;
    cursor: pointer;
    margin: 0;
    padding: calc(0.25rem - 1px);
    width: 2rem;
    height: 2rem;
    color: var(--lsml-button-foreground);
    background-color: var(--lsml-button-background);
    border: var(--lsml-button-border);
    border-radius: 0;

    & > svg {
      display: block;
      width: 1.5rem;
      height: 1.5rem;

      & text:not([fill]),
      & path:not([fill]),
      & rect:not([fill]) {
        fill: var(--lsml-button-foreground);
      }
    }
  }

  &:first-of-type {
    & button {
      border-top-left-radius: var(--lsml-button-border-radius);
      border-bottom-left-radius: var(--lsml-button-border-radius);
    }
  }

  &:last-of-type {
    & button {
      border-top-right-radius: var(--lsml-button-border-radius);
      border-bottom-right-radius: var(--lsml-button-border-radius);
    }
  }
}

.ck-editor__editable {
  flex-grow: 1;

  /* so that Firefox won't expand this div to the height of its content
     but will instead limit it to the height of its container. */
  flex-basis: 0;

  /* Safari requires us to add user selection back, since surfaces disable
     it. However, that messes up Firefox unless we also specifically set
     -moz-user-select to text in p, div.lsb-responsorial, and div.part.
     (Unfortunately, current versions of FF seem to read the -webkit-
     prefixed attributes if present.) Meanwhile, unless we then set
     user-select: none on the divs, Chrome selects way too much when
     selecting a paragraph. */
  -webkit-user-select: auto;

  p,
  div.lsb-responsorial,
  div.part {
    -moz-user-select: text;
  }

  div.lsb-responsorial,
  div.part {
    user-select: none;
  }

  .ck-widget {
    margin: 0;

    /* System color definitions are deprecated, but still seem to work */
    &.ck-widget_selected {
      background-color: Highlight;
    }
  }

  img.ck-widget {
    display: block;
  }

  /* Poetry is not context-sensitive in the editor, and should always be indented */
  p.poetry {
    margin-left: 2em;
  }

  div.lsb-responsorial {
    display: flex;
    flex-direction: row;

    & > .lsb-symbol:first-child {
      flex-shrink: 0;
    }

    & > .speaker {
      width: 1.5in;
      font-family: 'Times New Roman', Times, serif;
    }

    .ck-editor__nested-editable_focused {
      box-shadow: none !important;
      border-color: transparent !important;
    }

    &.responsorial-icon-C {
      .part p,
      .speaker {
        font-weight: bold;
      }
    }

    &.responsorial-icon-P {
      .part p,
      .speaker {
        font-weight: normal;
      }
    }

    &.responsorial-icon-R {
      .part p,
      .speaker {
        font-style: italic;
      }
    }

    p.poetry:first-child {
      padding-top: 0;
    }
    p.scripture-heading:first-child {
      padding-top: 0;
      font-weight: bold !important;
    }
  }

  .lsb-cross {
    display: inline-block;
    font-family: LSBSymbolWeb;
  }

  .chant-mark {
    display: inline-block;
    color: #ff0000;
  }

  .placeholder {
    display: inline-block;
    border-radius: var(--lsml-button-border-radius);

    & > .placeholder-name {
      display: inline-block;
      background: var(--lsml-button-background);
      padding: 0 0.5rem;
      border: var(--lsml-button-border);
      border-top-left-radius: var(--lsml-button-border-radius);
      border-bottom-left-radius: var(--lsml-button-border-radius);
    }

    & > .placeholder-fallback {
      display: inline-block;
      padding: 0 0.5rem;
      border: var(--lsml-button-border);
      border-left: none;
      border-top-right-radius: var(--lsml-button-border-radius);
      border-bottom-right-radius: var(--lsml-button-border-radius);
    }
  }
}

.__lsml-editor_placeholder-form {
  padding: 1rem;
  border-radius: 4px;
  flex-direction: column;
  row-gap: 0.5rem;
}

.__lsml-editor_placeholder-form[open] {
  display: flex;

  & > h3 {
    font-weight: bold;
    font-size: 1.2rem;
  }
}

.__lsml-editor_placeholder-buttons {
  display: flex;
  flex-direction: row;
  column-gap: 1rem;
  justify-content: flex-end;

  .__lsml-editor_confirm-button {
    display: block;
    margin: 0;
    padding: 0.25rem 0.5rem;
    color: var(--lsml-button-foreground);
    background-color: var(--lsml-button-background);
    border: var(--lsml-button-border);
    border-radius: var(--lsml-button-border-radius);
    cursor: pointer;
  }
}

/* =================
 * Content
 * ================= */

.lsb-symbol {
  text-transform: none !important;
  font-family: LSBSymbolWeb;
}
