/* ==========================================================================
   Article CSAT ("Was this article helpful?") + mobile action dock

   Markup lives in templates/article_page.hbs, behaviour in np-csat.js.

   Two presentations of the same Zendesk {{vote}} buttons:
     - >= 1401px : sticky card in the right rail, under the table of contents
     - <= 1400px : fixed bottom dock (thumbs | chat | email)
   The 1400px edge is the same one TOC_NPass.js / TOC_NPass.css used for the
   in-article vs sidebar table of contents. Below it there is no room for a
   320px rail without squeezing the article, so the dock takes over. It is
   full-width under 768px and a floating pill above that.
   Keep the breakpoint in sync with DOCK_QUERY in np-csat.js.
   ========================================================================== */

:root {
  --np-rail-width: 320px;
  /* Sticky offset = sticky header height (72px) + breathing room. */
  --np-rail-top: 120px;
  --np-dock-h: 68px;
}

.np-csat,
.np-dock {
  --np-ink: #191a1c;
  --np-muted: #5b5e65;
  --np-line: #e3dfd6;
  --np-line-strong: #b9b4a8;
  --np-surface: #fff;
  --np-soft: #f5f4f1;
  --np-brand: #00cfb6;
  --np-brand-ink: #004a4d;
  --np-brand-tint: #e3f8f5;
}

/* --- Icons for the Zendesk-rendered vote buttons (mask => takes currentColor) --- */

.np-vote::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask: var(--np-icon) center / contain no-repeat;
  mask: var(--np-icon) center / contain no-repeat;
  font-family: inherit;
}

.article-vote-up {
  --np-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10v12'/%3E%3Cpath d='M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z'/%3E%3C/svg%3E");
}

.article-vote-down {
  --np-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 14V2'/%3E%3Cpath d='M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z'/%3E%3C/svg%3E");
}

.article-vote-up.np-is-selected {
  --np-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z'/%3E%3C/svg%3E");
}

.article-vote-down.np-is-selected {
  --np-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z'/%3E%3C/svg%3E");
}

/* --- Segmented thumbs control (shared by the card and the dock) --- */

.np-votes {
  display: flex;
  align-items: stretch;
  margin: 0;
  border: 1px solid var(--np-line);
  border-radius: 14px;
  background: var(--np-surface);
}

.np-vote {
  position: relative;
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  min-width: 44px;
  min-height: 48px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--np-ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.np-vote:first-child {
  border-radius: 13px 0 0 13px;
}

.np-vote:last-child {
  border-radius: 0 13px 13px 0;
}

.np-vote + .np-vote {
  border-left: 1px solid var(--np-line);
}

.np-vote::after {
  content: none;
}

@media (hover: hover) {
  .np-vote:hover {
    background: var(--np-soft);
    color: var(--np-ink);
    text-decoration: none;
  }
}

.np-vote:active {
  transform: scale(0.96);
  background: var(--np-soft);
}

.np-vote:focus-visible {
  z-index: 1;
  outline: 2px solid var(--np-brand-ink);
  outline-offset: 2px;
}

.np-vote.np-is-selected,
.np-vote.np-is-selected:hover {
  background: var(--np-brand-tint);
  color: var(--np-brand-ink);
}

.np-vote.np-is-selected::before {
  animation: np-pop 0.28s ease-out;
}

@keyframes np-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* --- Desktop rail --------------------------------------------------------- */

.np-rail,
.np-dock,
.np-dock-spacer {
  display: none;
}

.np-rail__toc:empty,
.np-dock__votes:empty {
  display: none;
}

.np-csat {
  box-sizing: border-box;
  padding: 20px;
  border: 1px solid var(--np-line);
  border-radius: 16px;
  background: var(--np-surface);
  box-shadow: 0 1px 2px rgba(25, 26, 28, 0.04), 0 8px 24px -12px rgba(25, 26, 28, 0.12);
  color: var(--np-ink);
}

.np-csat__title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--np-ink);
}

.np-csat__thanks {
  max-height: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--np-brand-ink);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  transition: max-height 0.25s ease, margin-top 0.25s ease, opacity 0.2s ease;
}

.np-csat__thanks.is-visible {
  max-height: 48px;
  margin-top: 14px;
  opacity: 1;
}

@media (min-width: 1401px) {
  /* style.css caps .container-page at 1340px, which left the article only about
     640px wide on big screens. Match the header's 1600px container instead:
     the left panel and the rail move out to the edges and the article column
     (flex: 1) takes all of the extra width. */
  #page-container.np-article-page {
    max-width: 1600px;
  }

  #page-container > .row {
    flex-wrap: nowrap;
  }

  .np-rail {
    display: block;
    flex: 0 0 var(--np-rail-width);
    width: var(--np-rail-width);
    /* Stretch to the row so the sticky child has the whole article to travel. */
    align-self: stretch;
  }

  /* Voting off and no TOC: nothing to show, so don't reserve an empty column. */
  .np-rail--toc-only:not(.np-rail--has-toc) {
    display: none;
  }

  .np-rail__sticky {
    position: sticky;
    top: var(--np-rail-top);
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 40px;
    /* On short screens the TOC scrolls internally; the CSAT card never leaves. */
    max-height: calc(100vh - var(--np-rail-top) - 24px);
  }

  .np-rail__toc {
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .np-csat {
    flex: none;
  }
}

/* --- Mobile / tablet dock -------------------------------------------------- */

@media (max-width: 1400px) {
  /* style.css makes html/body a height-clamped flex column, so padding on
     <body> would not extend the scroll area. A flex:none spacer after the
     footer (added by np-csat.js) keeps the last footer row clear of the dock. */
  .np-dock-spacer {
    display: block;
    flex: none;
    height: calc(var(--np-dock-h) + 16px + env(safe-area-inset-bottom, 0px));
  }

  /* style.css zeroes .container-page padding at <=420px while .row keeps its
     -1rem margins, so the page overflows sideways by 16px. Mobile browsers
     answer that by widening the layout viewport, which would push a fixed
     dock partly off-screen. Clip it (no scroll container, no sticky needed
     at this width). */
  html.np-has-dock #page-container {
    overflow-x: hidden;
    overflow-x: clip;
  }

  .np-dock {
    display: block;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    box-sizing: border-box;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--np-line);
    box-shadow: 0 -6px 24px rgba(25, 26, 28, 0.1);
    color: var(--np-ink);
  }

  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .np-dock {
      background: rgba(255, 255, 255, 0.82);
      -webkit-backdrop-filter: saturate(1.6) blur(16px);
      backdrop-filter: saturate(1.6) blur(16px);
    }
  }

  .np-dock__inner {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .np-dock .np-votes {
    flex: none;
  }

  .np-dock .np-vote {
    flex: none;
    width: 48px;
    padding: 0;
    /* Zendesk renders a text label ("Yes" / "No"); it stays as the accessible
       name but is not painted here, the thumbs icon carries the meaning. */
    font-size: 0;
  }

  .np-dock .np-vote::before {
    width: 22px;
    height: 22px;
  }

  .np-dock__chat,
  .np-dock__email {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 48px;
    margin: 0;
    border-radius: 999px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
  }

  .np-dock__chat {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
    padding: 0 20px;
    border: 0;
    background: var(--np-brand);
    color: var(--np-ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
  }

  .np-dock__chat span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .np-dock__email {
    flex: none;
    width: 48px;
    border: 1px solid var(--np-line-strong);
    background: var(--np-surface);
    color: var(--np-ink);
  }

  .np-dock__chat svg,
  .np-dock__email svg {
    flex: none;
    width: 22px;
    height: 22px;
  }

  @media (hover: hover) {
    .np-dock__chat:hover {
      background: #19e8cc;
    }

    .np-dock__email:hover {
      background: var(--np-soft);
      border-color: var(--np-ink);
      color: var(--np-ink);
      text-decoration: none;
    }
  }

  .np-dock__chat:active,
  .np-dock__email:active {
    transform: scale(0.97);
  }

  /* Attention pulse: 3 cycles, then stops (np-pulse-done is set by the footer
     script on first interaction, a longer scroll, or once per session). */
  .np-dock__chat {
    animation: np-chatbar-pulse 3s ease-out 3;
  }

  html.np-pulse-done .np-dock__chat,
  .np-dock__chat:focus-visible {
    animation: none;
  }

  .np-dock__chat:focus-visible,
  .np-dock__email:focus-visible {
    outline: 2px solid var(--np-brand-ink);
    outline-offset: 2px;
  }

  .np-dock--votes-only .np-dock__inner {
    justify-content: center;
  }

  /* Confirmation toast, floats just above the dock. Stays in the accessibility
     tree (opacity, not display) so the live region announces reliably. */
  .np-dock__toast {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    left: 0;
    width: max-content;
    max-width: calc(100% - 32px);
    margin: 0 auto;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--np-ink);
    box-shadow: 0 6px 20px rgba(25, 26, 28, 0.28);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .np-dock__toast.is-visible {
    opacity: 1;
    transform: none;
  }

  /* The dock already offers chat, so the floating launcher would be a duplicate.
     Without a chat button (internal KB articles) lift the launcher clear of it. */
  html.np-dock-support .np-chat-launcher {
    display: none !important;
  }

  html.np-has-dock .np-chat-launcher {
    bottom: calc(var(--np-dock-h) + 16px + env(safe-area-inset-bottom, 0px));
  }
}

/* Tablet / small laptop: float the dock instead of stretching it edge to edge. */
@media (min-width: 768px) and (max-width: 1400px) {
  .np-dock {
    right: 0;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 0;
    width: min(560px, calc(100% - 32px));
    margin: 0 auto;
    padding: 10px;
    border: 1px solid var(--np-line);
    border-radius: 24px;
    box-shadow: 0 12px 32px rgba(25, 26, 28, 0.18), 0 2px 6px rgba(25, 26, 28, 0.08);
  }

  .np-dock-spacer {
    height: calc(var(--np-dock-h) + 40px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 479px) {
  .np-dock__inner {
    gap: 8px;
  }

  .np-dock__chat {
    gap: 6px;
    padding: 0 12px;
  }
}

@media (max-width: 380px) {
  .np-dock__inner {
    gap: 6px;
  }

  .np-dock__chat {
    padding: 0 10px;
    font-size: 0.9375rem;
  }

  .np-dock__chat svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 359px) {
  .np-dock__chat svg {
    display: none;
  }

  .np-dock__chat {
    padding: 0 12px;
    font-size: 0.9375rem;
  }
}

/* Dock label: let it wrap instead of clipping when text is enlarged or spaced
   (1.4.4 / 1.4.12). At default size the label still fits on one line. */
@media (max-width: 1400px) {
  .np-dock__chat {
    height: auto;
    min-height: 48px;
    padding-top: 6px;
    padding-bottom: 6px;
    line-height: 1.2;
  }

  .np-dock__chat span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
  }

  /* Keep focused elements clear of the fixed dock (2.4.11). */
  html.np-has-dock {
    scroll-padding-bottom: calc(var(--np-dock-h) + 16px + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 768px) and (max-width: 1400px) {
  html.np-has-dock {
    scroll-padding-bottom: calc(var(--np-dock-h) + 40px + env(safe-area-inset-bottom, 0px));
  }
}

/* Very short phone viewports (e.g. 400% zoom, ~320x256): a fixed dock would
   cover a large part of the screen, so let it sit at the end of the page. */
@media (max-width: 767px) and (max-height: 480px) {
  .np-dock {
    position: relative;
  }

  .np-dock-spacer {
    display: none;
  }

  html.np-has-dock {
    scroll-padding-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .np-vote,
  .np-dock__chat,
  .np-dock__email,
  .np-csat__thanks,
  .np-dock__toast {
    transition: none;
  }

  .np-dock__chat {
    animation: none;
  }

  .np-vote.np-is-selected::before {
    animation: none;
  }
}

@media (forced-colors: active) {
  .np-dock__chat {
    border: 1px solid ButtonText;
  }

  .np-vote.np-is-selected {
    outline: 2px solid Highlight;
    outline-offset: -4px;
  }

  .np-vote::before {
    background-color: CanvasText;
  }
}

@media print {
  .np-rail,
  .np-dock,
  .np-dock-spacer {
    display: none !important;
  }
}
