/* Share modal — ported from reader_v3 with iOS 12+ compatibility adjustments. */

.sh-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10060;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid;
  place-items: center;
  padding-top: calc(env(safe-area-inset-top, 0px) + 18px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  padding-left: 12px;
  padding-right: 12px;
  background: #f2f2f7;
}

.sh-modal.hidden { display: none !important; }

.sh-backdrop {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: transparent;
}

.sh-card {
  position: relative;
  z-index: 1;
  width: min(460px, 92vw);
  max-height: calc(var(--vh, 1vh) * 100 - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 36px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 16px;
  border: 1px solid #e6ebf1;
  background: #ffffff;
  box-shadow:
    0 1px 3px rgba(16, 24, 40, 0.05),
    0 12px 32px rgba(16, 24, 40, 0.08);
  padding: 24px 22px 20px;
  display: grid;
  justify-items: center;
  gap: 14px;
  box-sizing: border-box;
}

.sh-card > * {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.sh-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid #e6ebf1;
  background: #ffffff;
  color: #4b5563;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  transition: transform 120ms ease, background 160ms ease, color 160ms ease;
}

.sh-close:active { transform: scale(0.98); }

@media (hover: hover) and (pointer: fine) {
  .sh-close:hover { background: #f3f4f6; color: #111928; }
}

.sh-cover {
  width: 200px;
  height: 200px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #e6ebf1;
  background: #f9fafb;
  box-shadow: 0 10px 30px rgba(17, 25, 40, 0.12);
}

.sh-cover-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.sh-title {
  max-width: 40ch;
  text-align: center;
  margin-top: 4px;
  display: grid;
  gap: 6px;
  line-height: 1.15;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sh-title-book {
  font-family: 'Nunito', system-ui, sans-serif;
  color: #111928;
  font-weight: 800;
  font-size: 20px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sh-sub {
  font-family: 'Nunito', system-ui, sans-serif;
  color: #6b7280;
  font-weight: 600;
  font-size: 13.5px;
  text-align: center;
  max-width: 98%;
}

.sh-sharebar {
  width: 100%;
  max-width: min(520px, 100%);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  margin-top: 2px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #e6ebf1;
  background: #f9fafb;
}

.sh-sharebar-spacer { flex: 1 1 auto; min-width: 6px; }

.sh-icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid #e6ebf1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
  transition: transform 120ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.sh-icon-btn:active { transform: scale(0.98); }

@media (hover: hover) and (pointer: fine) {
  .sh-icon-btn:hover {
    transform: translateY(-1px);
    border-color: #5750f1;
    box-shadow: 0 2px 6px rgba(87, 80, 241, 0.18);
  }
}

.sh-ico {
  width: 34px;
  height: 34px;
  display: block;
  object-fit: contain;
}

.sh-copy {
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: none;
  background: #5750f1;
  color: #ffffff;
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(87, 80, 241, 0.3);
  transition: transform 120ms ease, background 160ms ease, box-shadow 160ms ease;
}

.sh-copy:active { transform: scale(0.98); }

@media (hover: hover) and (pointer: fine) {
  .sh-copy:hover {
    transform: translateY(-1px);
    background: #4338ca;
    box-shadow: 0 4px 14px rgba(87, 80, 241, 0.4);
  }
}

.sh-copy-txt { line-height: 1; white-space: nowrap; }

.sh-nativebar { width: 100%; display: none; }

.sh-nativebtn {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  border: none;
  background: #5750f1;
  color: #ffffff;
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(87, 80, 241, 0.3);
  transition: transform 120ms ease, background 160ms ease, box-shadow 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .sh-nativebtn:hover {
    transform: translateY(-1px);
    background: #4338ca;
    box-shadow: 0 4px 14px rgba(87, 80, 241, 0.4);
  }
}

.sh-nativebtn:active { transform: scale(0.98); }

.sh-hint {
  font-family: 'Nunito', system-ui, sans-serif;
  color: #6b7280;
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}

@media (max-height: 640px) {
  .sh-modal { place-items: start center; }
  .sh-card { gap: 10px; padding: 12px 12px 10px; }
  .sh-cover { width: 120px; height: 120px; }
  .sh-title-book { font-size: 17px; }
}

@media (max-width: 520px) {
  .sh-card { width: min(92vw, 520px); padding: 18px 16px 16px; gap: 12px; }
  .sh-cover { width: 138px; height: 138px; border-radius: 16px; }
  .sh-title-book { font-size: 18px; }
  .sh-sub { font-size: 13px; }
  .sh-nativebar { display: block; }
  .sh-sharebar { display: none !important; }
}

@media (min-width: 521px) {
  .sh-nativebar { display: none !important; }
  .sh-sharebar { display: flex; }
}
