/* Reserve space only where needed; preserve the full article width on mobile. */
@media screen and (min-width: 1024px) {
  body.article:has(.topic-feedback) .body { padding-right: 80px; }
}

@media screen and (max-width: 1023px) {
  body.article:has(.topic-feedback) { padding-bottom: 88px; }

  /* Keep the feedback control out of the open mobile navigation. */
  html.is-clipped--nav .doc .topic-feedback { display: none; }
}

.doc .topic-feedback {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 3;
  margin: 0;
}

.doc .topic-feedback-button {
  align-items: center;
  background: #3a3632;
  border: 1px solid #3a3632;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
  color: #fff;
  display: flex;
  justify-content: center;
  width: 52px;
  height: 52px;
  box-sizing: border-box;
  text-decoration: none;
}

.doc .topic-feedback-button:hover { background: #514b46; color: #fff; }
.topic-feedback-button:focus-visible {
  outline: 3px solid #346597;
  outline-offset: 3px;
}

.topic-feedback-icon {
  fill: currentColor;
  flex: 0 0 auto;
  height: 24px;
  width: 24px;
}

/* Touching boxes keep the pointer inside the same hover area all the way
   from the envelope to the label. The label itself is not an email link. */
.topic-feedback-label {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  box-sizing: border-box;
  max-width: calc(100vw - 88px);
  width: max-content;
  padding: 10px 14px;
  border-radius: 4px;
  background: #242424;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  visibility: hidden;
}

/* Only enable the visual tooltip once Escape dismissal is installed.
   The link's accessible name and mailto target work without JavaScript. */
.topic-feedback[data-feedback-ready]:not(.is-dismissed):hover .topic-feedback-label,
.topic-feedback[data-feedback-ready]:not(.is-dismissed):focus-within .topic-feedback-label {
  visibility: visible;
}

@media print {
  .doc .topic-feedback { display: none; }
}

/* Keep footer links outside the fixed envelope's hit area while scrolling. */
@media screen {
  body:has(.topic-feedback) footer.footer {
    padding-right: calc(76px + max(16px, env(safe-area-inset-right)));
  }

  footer.footer a { display: inline-block; }
}
