/*
 * HAKARU KANJI DISPLAY V2
 *
 * Desktop:
 *   fixed header button + popover
 *
 * Mobile:
 *   header button + bottom sheet
 */

.hakaru-kanji-display-slot {
  position: relative;
  z-index: 2;
  display: flex;
  width: 64px;
  min-width: 64px;
  margin: 0;
  align-items: center;
  justify-content: flex-end;
}

.hakaru-kanji-trigger {
  display: inline-flex;
  min-width: 54px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 10px;
  border: 1px solid
    rgba(23, 107, 76, 0.18);
  border-radius: 10px;
  color: #315346;
  background: #ffffff;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.hakaru-kanji-trigger::after {
  content: "⌄";
  color: #72847b;
  font-size: 10px;
}

.hakaru-kanji-trigger:hover {
  border-color:
    rgba(23, 107, 76, 0.28);
  background: #f6faf7;
}

.hakaru-kanji-trigger:focus-visible,
.hakaru-kanji-option:focus-visible,
.hakaru-kanji-close:focus-visible {
  outline: 3px solid
    rgba(38, 139, 97, 0.2);
  outline-offset: 2px;
}

.hakaru-kanji-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 80;
  width: 228px;
  padding: 12px;
  border: 1px solid
    rgba(23, 107, 76, 0.15);
  border-radius: 15px;
  background: #ffffff;
  box-shadow:
    0 14px 38px
    rgba(28, 49, 39, 0.16);
}

.hakaru-kanji-panel-header {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 7px;
  color: #253c31;
  font-size: 12px;
}

.hakaru-kanji-close {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #6a7a72;
  background: transparent;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.hakaru-kanji-close:hover {
  background: #f1f5f2;
}

.hakaru-kanji-options {
  display: grid;
  gap: 5px;
}

.hakaru-kanji-option {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #344b40;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.hakaru-kanji-option:hover {
  background: #f3f7f4;
}

.hakaru-kanji-option.is-selected {
  border-color:
    rgba(23, 107, 76, 0.12);
  color: #14573e;
  background: #e9f4ed;
}

.hakaru-kanji-check {
  visibility: hidden;
  color: #176b4c;
  font-size: 14px;
  font-weight: 900;
}

.hakaru-kanji-option.is-selected
.hakaru-kanji-check {
  visibility: visible;
}

.hakaru-kanji-backdrop {
  display: none;
}

.hakaru-kanji-panel[hidden],
.hakaru-kanji-backdrop[hidden] {
  display: none !important;
}

body.hakaru-kanji-sheet-open {
  overflow: hidden;
}


/* ==================================================
   Mobile bottom sheet
   ================================================== */

@media (max-width: 720px) {
  .hakaru-kanji-display-slot {
    width: 48px;
    min-width: 48px;
    justify-self: end;
  }

  .hakaru-kanji-trigger {
    min-width: 48px;
    min-height: 42px;
    padding: 8px 7px;
    border-radius: 10px;
    font-size: 11px;
  }

  .hakaru-kanji-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background:
      rgba(20, 34, 27, 0.28);
  }

  .hakaru-kanji-panel {
    position: fixed;
    top: auto;
    right: 10px;
    bottom:
      max(
        10px,
        env(safe-area-inset-bottom)
      );
    left: 10px;
    z-index: 71;
    width: auto;
    padding: 15px;
    border-radius: 20px;
    box-shadow:
      0 18px 50px
      rgba(17, 29, 23, 0.24);
  }

  .hakaru-kanji-panel-header {
    min-height: 38px;
    padding: 0 2px 10px;
    font-size: 14px;
  }

  .hakaru-kanji-close {
    width: 36px;
    height: 36px;
  }

  .hakaru-kanji-options {
    gap: 7px;
  }

  .hakaru-kanji-option {
    min-height: 52px;
    padding: 12px 14px;
    border-radius: 13px;
    font-size: 14px;
  }
}
