/*
 * Xnnoying — Quick Block & Mute for X
 *
 * All button chrome is owned here. Do not depend on X's hashed CSS
 * class names (css-*, r-*); those change when X redeploys.
 *
 * X restyles generic `button` and `[role="button"]` elements. Beat that
 * with a non-button host, high-specificity selectors, and !important.
 *
 * Layout rule: never contribute height to the tweet header. The actions
 * wrapper is height:0 with overflow visible so icons paint without
 * stretching the username row.
 *
 * Shared colors are the tokens below (X's own palette). --xnnoying-icon
 * is copied by content.js from the color X gives its "More" caret, so
 * idle icons match X in light, dim and lights out.
 */

html {
  --xnnoying-blue: rgb(29, 155, 240);
  --xnnoying-red: rgb(244, 33, 46);
  --xnnoying-orange: rgb(255, 122, 0);
}

html body .xnnoying-actions {
  all: unset !important;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  align-self: center !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  width: auto !important;
  margin: 0 8px 0 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: visible !important;
  line-height: 0 !important;
  /* Measured on x.com: 8px here and before the caret leaves ~12px of
     visible space between each icon, matching the Grok-to-block gap. */
  gap: 8px !important;
  background: transparent !important;
  pointer-events: none !important;
}

html body .xnnoying-btn {
  all: unset !important;
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  width: 18.75px !important;
  height: 18.75px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 18.75px !important;
  max-height: 18.75px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 9999px !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  /* Full-size but invisible, so hover only fades a color in. */
  box-shadow: 0 0 0 8px transparent !important;
  color: var(--xnnoying-icon, rgb(113, 118, 123)) !important;
  cursor: pointer !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  line-height: 0 !important;
  font-size: 0 !important;
  overflow: visible !important;
  pointer-events: auto !important;
  user-select: none !important;
  /* X's own hover timing (0.15s ease-out). */
  transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

html body .xnnoying-btn.xnnoying-block {
  --xnnoying-hue: var(--xnnoying-red);
}

html body .xnnoying-btn.xnnoying-mute {
  --xnnoying-hue: var(--xnnoying-orange);
}

html body .xnnoying-btn::before,
html body .xnnoying-btn::after {
  display: none !important;
  content: none !important;
}

html body .xnnoying-btn svg {
  position: relative !important;
  z-index: 1 !important;
  width: 18.75px !important;
  height: 18.75px !important;
  max-width: 18.75px !important;
  max-height: 18.75px !important;
  fill: none !important;
  background: transparent !important;
  pointer-events: none !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
}

html body .xnnoying-btn.xnnoying-mute svg path {
  fill: currentColor !important;
}

html body .xnnoying-btn:hover,
html body .xnnoying-btn:focus-visible,
html body .xnnoying-btn.xnnoying-done {
  color: var(--xnnoying-hue) !important;
}

/*
 * Tinted circle like X's own header icons: the glyph's own background
 * plus 8px of shadow around it fill a ~34.75px circle without taking
 * any layout space. The tint is a fixed color, not currentColor, so it
 * doesn't start gray while the icon color is still fading.
 */
html body .xnnoying-btn:hover,
html body .xnnoying-btn:focus-visible {
  background-color: color-mix(in srgb, var(--xnnoying-hue) 10%, transparent) !important;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--xnnoying-hue) 10%, transparent) !important;
}

html body .xnnoying-btn:focus-visible {
  outline: 2px solid currentColor !important;
  outline-offset: 8px !important;
}

html body .xnnoying-btn.xnnoying-loading {
  opacity: 0.35 !important;
  pointer-events: none !important;
}

html body .xnnoying-btn.xnnoying-done {
  pointer-events: none !important;
}

/*
 * Home history: a floating button and popover pinned to the timeline
 * column. Colors are tokens on the panel; content.js sets --xnnoying-bg
 * to X's page background and adds .xnnoying-dark for dim / lights out.
 */

html body .xnnoying-history-btn {
  all: unset !important;
  position: fixed !important;
  bottom: 16px !important;
  z-index: 1000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 9999px !important;
  background: var(--xnnoying-blue) !important;
  color: #fff !important;
  cursor: pointer !important;
  box-shadow: rgba(101, 119, 134, 0.2) 0 0 8px, rgba(101, 119, 134, 0.25) 0 1px 3px 1px !important;
  transition: background-color 0.2s, transform 0.2s !important;
}

html body .xnnoying-history-btn:hover,
html body .xnnoying-history-btn[aria-expanded="true"] {
  background: rgb(26, 140, 216) !important;
}

html body .xnnoying-history-btn:active {
  transform: scale(0.94) !important;
}

html body .xnnoying-history-btn:focus-visible {
  outline: 2px solid var(--xnnoying-blue) !important;
  outline-offset: 2px !important;
}

html body .xnnoying-history-btn[hidden] {
  display: none !important;
}

html body .xnnoying-history-btn svg {
  width: 20px !important;
  height: 20px !important;
  pointer-events: none !important;
}

html body .xnnoying-history {
  --xnnoying-text: rgb(15, 20, 25);
  --xnnoying-muted: rgb(83, 100, 113);
  --xnnoying-line: rgb(239, 243, 244);
  --xnnoying-hover: rgba(15, 20, 25, 0.04);
  --xnnoying-accent: var(--xnnoying-blue);
  --xnnoying-accent-soft: color-mix(in srgb, var(--xnnoying-blue) 10%, transparent);
  --xnnoying-shadow: rgba(101, 119, 134, 0.2) 0 0 15px, rgba(101, 119, 134, 0.15) 0 0 3px 1px;

  position: fixed !important;
  bottom: 68px !important;
  z-index: 1000 !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
  width: 380px !important;
  max-width: calc(100vw - 16px) !important;
  max-height: min(600px, calc(100vh - 140px)) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: var(--xnnoying-bg, #fff) !important;
  color: var(--xnnoying-text) !important;
  font: 400 15px/20px TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  text-align: left !important;
  box-shadow: var(--xnnoying-shadow) !important;
  animation: xnnoying-pop 0.14s ease-out !important;
}

html body .xnnoying-history.xnnoying-dark {
  --xnnoying-text: rgb(231, 233, 234);
  --xnnoying-muted: rgb(139, 152, 165);
  --xnnoying-line: rgba(255, 255, 255, 0.12);
  --xnnoying-hover: rgba(255, 255, 255, 0.04);
  --xnnoying-accent-soft: color-mix(in srgb, var(--xnnoying-blue) 14%, transparent);
  --xnnoying-shadow: rgba(255, 255, 255, 0.2) 0 0 15px, rgba(255, 255, 255, 0.15) 0 0 3px 1px;
}

@keyframes xnnoying-pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .xnnoying-history {
    animation: none !important;
  }
}

html body .xnnoying-history * {
  box-sizing: border-box !important;
}

html body .xnnoying-history-head {
  flex-shrink: 0 !important;
  padding: 14px 16px 12px !important;
  border-bottom: 1px solid var(--xnnoying-line) !important;
}

html body .xnnoying-history-title {
  font-size: 20px !important;
  line-height: 24px !important;
  font-weight: 800 !important;
}

html body .xnnoying-history-hint {
  margin-top: 2px !important;
  color: var(--xnnoying-muted) !important;
  font-size: 13px !important;
  line-height: 16px !important;
}

/* Positioned so a post's offsetTop is measured from here. */
html body .xnnoying-history-body {
  position: relative !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-width: thin !important;
  scrollbar-color: var(--xnnoying-muted) transparent !important;
}

html body .xnnoying-history-empty {
  margin: 0 !important;
  padding: 32px 24px !important;
  color: var(--xnnoying-muted) !important;
  text-align: center !important;
}

html body .xnnoying-history details {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

html body .xnnoying-history details + details {
  border-top: 1px solid var(--xnnoying-line) !important;
}

html body .xnnoying-history details[open] {
  padding-bottom: 8px !important;
}

/*
 * Feed header: stays in view while scrolling its posts. Grid, so the
 * date sits over the tab and count with the chevron, badge and Restore
 * button centered beside them.
 */
html body .xnnoying-history summary {
  position: sticky !important;
  top: 0 !important;
  z-index: 1 !important;
  display: grid !important;
  grid-template-columns: 20px minmax(0, 1fr) auto auto !important;
  align-items: center !important;
  column-gap: 8px !important;
  margin: 0 !important;
  padding: 10px 12px 10px 12px !important;
  list-style: none !important;
  background: var(--xnnoying-bg, #fff) !important;
  cursor: pointer !important;
  user-select: none !important;
  outline: none !important;
}

html body .xnnoying-history details[open] > summary {
  box-shadow: 0 1px 0 var(--xnnoying-line) !important;
}

html body .xnnoying-history summary::-webkit-details-marker {
  display: none !important;
}

/* Chevron: points right when closed, down when open. */
html body .xnnoying-history summary::before {
  content: "" !important;
  grid-area: 1 / 1 / 3 / 2 !important;
  justify-self: center !important;
  width: 7px !important;
  height: 7px !important;
  border: solid var(--xnnoying-muted) !important;
  border-width: 0 2px 2px 0 !important;
  transform: rotate(-45deg) !important;
  transition: transform 0.15s !important;
}

html body .xnnoying-history details[open] > summary::before {
  transform: translateY(-2px) rotate(45deg) !important;
}

html body .xnnoying-history summary:hover {
  background-image: linear-gradient(var(--xnnoying-hover), var(--xnnoying-hover)) !important;
}

html body .xnnoying-history summary:focus-visible {
  box-shadow: inset 0 0 0 2px var(--xnnoying-accent) !important;
}

html body .xnnoying-when {
  grid-area: 1 / 2 !important;
  overflow: hidden !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
}

html body .xnnoying-meta {
  grid-area: 2 / 2 !important;
  overflow: hidden !important;
  color: var(--xnnoying-muted) !important;
  font-size: 13px !important;
  line-height: 16px !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
}

html body .xnnoying-badge {
  grid-area: 1 / 3 / 3 / 4 !important;
  padding: 0 8px !important;
  border-radius: 9999px !important;
  background: var(--xnnoying-accent-soft) !important;
  color: var(--xnnoying-accent) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 20px !important;
}

html body .xnnoying-restore {
  grid-area: 1 / 4 / 3 / 5 !important;
  padding: 0 14px !important;
  border-radius: 9999px !important;
  background: var(--xnnoying-text) !important;
  color: var(--xnnoying-bg, #fff) !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 32px !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: opacity 0.2s !important;
}

html body .xnnoying-restore:hover {
  opacity: 0.85 !important;
}

html body .xnnoying-restore:focus-visible {
  outline: 2px solid var(--xnnoying-accent) !important;
  outline-offset: 2px !important;
}

html body .xnnoying-history a {
  display: block !important;
  margin: 0 !important;
  padding: 8px 16px 8px 40px !important; /* lines up with the feed date */
  color: var(--xnnoying-text) !important;
  font-size: 14px !important;
  line-height: 19px !important;
  text-decoration: none !important;
  transition: background-color 0.15s !important;
}

html body .xnnoying-history a:hover {
  background: var(--xnnoying-hover) !important;
}

html body .xnnoying-history a:focus-visible {
  outline: none !important;
  box-shadow: inset 0 0 0 2px var(--xnnoying-accent) !important;
}

html body .xnnoying-post {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  overflow-wrap: anywhere !important;
}

html body .xnnoying-user {
  margin-right: 6px !important;
  font-weight: 700 !important;
}

html body .xnnoying-media {
  color: var(--xnnoying-muted) !important;
  font-style: italic !important;
}

html body .xnnoying-history a.xnnoying-here {
  margin: 4px 0 !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  background: var(--xnnoying-accent-soft) !important;
  box-shadow: inset 3px 0 0 var(--xnnoying-accent) !important;
}

html body .xnnoying-history a.xnnoying-here::before {
  content: "You were here" !important;
  display: block !important;
  margin-bottom: 2px !important;
  color: var(--xnnoying-accent) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 16px !important;
  letter-spacing: 0.02em !important;
}

/* A short message like X's own toasts, in place of alert(). No
   `all: unset` here: its !important would stop the fade-in animation. */
html body .xnnoying-toast {
  position: fixed !important;
  left: 50% !important;
  bottom: 72px !important; /* above the History button */
  z-index: 1001 !important;
  box-sizing: border-box !important;
  max-width: calc(100vw - 32px) !important;
  margin: 0 !important;
  padding: 12px 16px !important;
  border: 0 !important;
  border-radius: 4px !important;
  background: var(--xnnoying-blue) !important;
  color: #fff !important;
  font: 400 15px/20px TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  text-align: center !important;
  transform: translateX(-50%) !important;
  box-shadow: rgba(101, 119, 134, 0.2) 0 0 15px, rgba(101, 119, 134, 0.15) 0 0 3px 1px !important;
  animation: xnnoying-toast 0.2s ease-out !important;
}

html body .xnnoying-toast:empty {
  visibility: hidden !important;
}

@keyframes xnnoying-toast {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .xnnoying-toast {
    animation: none !important;
  }
}

html body article.xnnoying-found {
  outline: 2px solid var(--xnnoying-blue) !important;
  outline-offset: -2px !important;
}

@media (max-width: 500px) {
  html body .xnnoying-history-btn {
    bottom: 68px !important;
  }

  html body .xnnoying-history {
    bottom: 120px !important;
    max-height: calc(100vh - 200px) !important;
  }

  /* Above X's bottom nav bar and the History button. */
  html body .xnnoying-toast {
    bottom: 120px !important;
  }
}
