/* =========================================================
   macOS font picker for new editor panel
   Works only when body has .editor-macos-font-picker-enabled
   ========================================================= */

body:not(.editor-macos-font-picker-enabled) #macos_font_select_root,
body:not(.editor-macos-font-picker-enabled) #macos_font_modal {
  display: none !important;
}

body.editor-macos-font-picker-enabled
  #enp_font_select.macos-native-font-select-hidden {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.editor-macos-font-picker-enabled #macos_font_select_root {
  position: relative;
  width: 190px;
}

body.editor-macos-font-picker-enabled .macos-font-trigger {
  width: 190px;
  height: 38px;
  padding: 0 32px 0 11px;

  display: flex;
  align-items: center;

  border: 1px solid #d3d3d3;
  border-radius: 7px;
  background: #ffffff;
  color: #222;

  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
  position: relative;
}

body.editor-macos-font-picker-enabled .macos-font-trigger:hover {
  border-color: #f37421;
}

body.editor-macos-font-picker-enabled .macos-font-trigger.is-disabled {
  opacity: 0.35;
  filter: grayscale(1);
  pointer-events: none;
}

body.editor-macos-font-picker-enabled .macos-font-trigger-label {
  display: block;
  max-width: 135px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  font-size: 16px;
  line-height: 36px;
}

body.editor-macos-font-picker-enabled .macos-font-trigger-arrow {
  position: absolute;
  right: 10px;
  top: 8px;

  font-size: 18px;
  line-height: 20px;
  color: #555;
  pointer-events: none;
}

/* modal */

body.editor-macos-font-modal-open {
  overflow: hidden;
}

body.editor-macos-font-picker-enabled #macos_font_modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20000;
}

body.editor-macos-font-picker-enabled #macos_font_modal.is-open {
  display: block;
}

body.editor-macos-font-picker-enabled .macos-font-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 32, 54, 0.28);
  backdrop-filter: blur(2px);
}

body.editor-macos-font-picker-enabled .macos-font-modal-box {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100vw - 42px));
  max-height: min(680px, calc(100vh - 42px));
  transform: translate(-50%, -50%);

  display: flex;
  flex-direction: column;

  background: #ffffff;
  border: 1px solid #f1c9b6;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(31, 32, 54, 0.28);
  overflow: hidden;
}

body.editor-macos-font-picker-enabled .macos-font-modal-head {
  flex: 0 0 auto;
  padding: 16px 18px 12px 18px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  border-bottom: 1px solid #eeeeee;
}

body.editor-macos-font-picker-enabled .macos-font-modal-title {
  font-family: TildaSans, Arial, sans-serif;
  font-size: 20px;
  line-height: 1.2;
  color: #1f2036;
}

body.editor-macos-font-picker-enabled .macos-font-modal-close {
  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 8px;
  color: #555;
  cursor: pointer;
  user-select: none;
  font-size: 24px;
  line-height: 1;
}

body.editor-macos-font-picker-enabled .macos-font-modal-close:hover {
  background: #f1f1f1;
  color: #1f2036;
}

body.editor-macos-font-picker-enabled .macos-font-modal-tools {
  flex: 0 0 auto;
  padding: 12px 18px;
  border-bottom: 1px solid #eeeeee;
}

body.editor-macos-font-picker-enabled .macos-font-search {
  width: 100%;
  height: 38px;
  padding: 0 12px;

  border: 1px solid #d3d3d3;
  border-radius: 9px;
  background: #ffffff;
  color: #222;

  box-sizing: border-box;
  font-size: 15px;
  outline: none;
}

body.editor-macos-font-picker-enabled .macos-font-search:focus {
  border-color: #f37421;
}

body.editor-macos-font-picker-enabled .macos-font-modal-list {
  flex: 1 1 auto;
  min-height: 240px;
  max-height: 520px;
  overflow-y: auto;

  padding: 14px 18px 18px 18px;

  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

body.editor-macos-font-picker-enabled .macos-font-item {
  min-height: 46px;
  padding: 8px 12px;

  display: flex;
  align-items: center;

  border: 1px solid #eeeeee;
  border-radius: 9px;
  background: #ffffff;
  color: #222;

  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
}

body.editor-macos-font-picker-enabled .macos-font-item:hover {
  border-color: #f37421;
  background: #fff7f2;
}

body.editor-macos-font-picker-enabled .macos-font-item.is-selected {
  border-color: #f37421;
  background: #fff0e6;
}

body.editor-macos-font-picker-enabled .macos-font-item-name {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  font-size: 21px;
  line-height: 1.15;
}

body.editor-macos-font-picker-enabled .macos-font-item.is-hidden {
  display: none !important;
}

body.editor-macos-font-picker-enabled #macos_font_select_root.is-disabled,
body.editor-macos-font-picker-enabled .macos-font-trigger.is-disabled {
  opacity: 0.35;
  filter: grayscale(1);
  pointer-events: none;
  cursor: not-allowed !important;
}

body.editor-macos-font-picker-enabled
  #macos_font_select_root.is-disabled
  .macos-font-trigger {
  cursor: not-allowed !important;
}

@media (max-width: 620px) {
  body.editor-macos-font-picker-enabled .macos-font-modal-list {
    grid-template-columns: 1fr;
  }
}
