/* NS WIKI paragraph comments — dashed underline, selection button, popup.
 * Colors follow the active MkDocs Material palette via --md-* variables,
 * so light/slate schemes both work without extra rules.
 * Radius/animation language matches docs/assets/chat-widget.js (4-6px, .open transitions).
 */

/* ---------- commented paragraph: dashed underline, no DOM insertion ---------- */

[data-ns-pid].ns-pc-has-comments {
  text-decoration: underline dashed var(--md-primary-fg-color, #4051b5) 1px;
  text-underline-offset: 3px;
  text-decoration-skip-ink: auto;
  cursor: pointer;
}

/* slate 主题的 primary 是黑色，虚线会看不见，换成浅色 */
[data-md-color-scheme="slate"] [data-ns-pid].ns-pc-has-comments {
  text-decoration-color: rgba(255, 255, 255, 0.75);
}

/* ---------- floating selection button ---------- */

.ns-sel-btn {
  position: absolute;
  z-index: 10001;
  transform: translateX(-50%);
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  background: var(--md-primary-fg-color, #4051b5);
  color: var(--md-primary-bg-color, #fff);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: opacity 0.15s;
}

.ns-sel-btn:hover {
  opacity: 0.85;
}

/* ---------- popup ---------- */

.ns-pc-overlay {
  position: fixed;
  inset: 0;
  /* above the chat-widget button (9998) and panel (9999) */
  z-index: 10000;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ns-pc-overlay--open {
  opacity: 1;
}

.ns-pc-panel {
  position: absolute;
  top: 72px;
  right: 16px;
  bottom: 16px;
  width: min(440px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-family: var(--md-text-font-family, sans-serif);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.25s ease, transform 0.25s ease, height 0.25s ease;
}

.ns-pc-overlay--open .ns-pc-panel {
  opacity: 1;
  transform: none;
}

.ns-pc-panel--dragging {
  transition: none;
}

/* drag grip: only visible on the mobile bottom sheet */
.ns-pc-grip {
  display: none;
}

.ns-pc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  font-weight: 600;
  flex: none;
}

.ns-pc-close {
  border: none;
  background: transparent;
  color: var(--md-default-fg-color--light);
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.ns-pc-close:hover {
  color: var(--md-default-fg-color);
}

.ns-pc-hl-slot {
  flex: none;
  padding: 0 14px;
}

.ns-pc-hl-slot:empty {
  padding: 0;
}

.ns-pc-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 14px;
  -webkit-overflow-scrolling: touch;
}

/* waline (#waline) is relocated into the popup body while it is open */
.ns-pc-error {
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--md-default-fg-color--lighter);
}

/* ---------- selected-text context card ---------- */

.ns-hl-quote-card {
  margin: 10px 0 6px;
  padding: 8px 10px;
  border-left: 3px solid var(--md-primary-fg-color, #4051b5);
  border-radius: 4px;
  background: var(--md-code-bg-color);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

[data-md-color-scheme="slate"] .ns-hl-quote-card {
  border-left-color: rgba(255, 255, 255, 0.75);
}

/* ---------- mobile: bottom sheet, pullable ---------- */

@media screen and (max-width: 719px) {
  .ns-pc-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80vh;
    max-height: 94vh;
    border: none;
    border-radius: 6px 6px 0 0;
    transform: translateY(100%);
  }

  .ns-pc-overlay--open .ns-pc-panel {
    transform: none;
  }

  .ns-pc-grip {
    display: block;
    height: 18px;
    flex: none;
    cursor: grab;
    touch-action: none;
    position: relative;
  }

  .ns-pc-grip::after {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: var(--md-default-fg-color--lightest);
  }
}
