/* Reader rich text: the composer (toolbar + preview tabs), the rendered body,
   the author chip, and the author mini-profile card.

   Shared by article comments (sx-comments.css) and listing reviews, so the two
   surfaces can't drift apart visually. Uses the `--sx-*` design tokens, so it
   tracks light/dark with the rest of the site. */

/* ---- composer ---------------------------------------------------------- */

.rt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.rt-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--sx-r-sm, 6px);
  background: var(--sx-surface-2, #f3f4f6);
}

.rt-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 4px 12px;
  border-radius: var(--sx-r-sm, 6px);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--sx-text-3, #6b7280);
  cursor: pointer;
}

.rt-tab:hover {
  color: var(--sx-text, #111827);
}

.rt-tab.is-active {
  background: var(--sx-surface, #fff);
  color: var(--sx-text, #111827);
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
}

.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.rt-toolbar[hidden] {
  display: none;
}

.rt-tool {
  appearance: none;
  border: 0;
  background: transparent;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border-radius: var(--sx-r-sm, 6px);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  color: var(--sx-text-2, #4b5563);
  cursor: pointer;
}

.rt-tool:hover {
  background: var(--sx-surface-2, #f3f4f6);
  color: var(--sx-text, #111827);
}

.rt-tool--bold { font-weight: 800; }
.rt-tool--italic { font-style: italic; font-family: Georgia, "Times New Roman", serif; }

/* ---- emoji picker ---- */

.rt-emoji {
  position: relative;
  display: inline-flex;
}

.rt-emoji-panel {
  position: absolute;
  top: calc(100% + 4px);
  /* Right-anchored: the emoji button is the last tool in the toolbar, so a
     left-anchored panel opens off the right edge of the page. Opening leftward
     from the button keeps all eight columns on screen. */
  right: 0;
  left: auto;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 6px;
  width: max-content;
  max-width: 88vw;
  border-radius: var(--sx-r-md, 10px);
  background: var(--sx-surface, #fff);
  border: 1px solid var(--sx-line, #e5e7eb);
  box-shadow: 0 10px 28px rgb(0 0 0 / 14%);
}

.rt-emoji-panel[hidden] {
  display: none;
}

.rt-emoji-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--sx-r-sm, 6px);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.rt-emoji-btn:hover {
  background: var(--sx-surface-2, #f3f4f6);
}

.rt-preview {
  min-height: 84px;
  padding: 12px 14px;
  border: 1px solid var(--sx-line, #d1d5db);
  border-radius: var(--sx-r-md, 10px);
  background: var(--sx-surface, #fff);
}

.rt-preview--empty {
  color: var(--sx-text-3, #9ca3af);
  font-size: 14px;
  font-style: italic;
}

.rt-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--sx-text-3, #9ca3af);
}

/* ---- rendered body ----------------------------------------------------- */
/* Applied to any element carrying `rt-body` — a posted comment, a review card,
   and the live preview, so what you preview is what you get. */

.rt-body {
  font-size: 15px;
  line-height: 1.6;
  color: var(--sx-text, #111827);
  overflow-wrap: anywhere;
}

.rt-body > :first-child { margin-top: 0; }
.rt-body > :last-child { margin-bottom: 0; }

.rt-body p {
  margin: 0 0 10px;
}

.rt-body h4 {
  margin: 14px 0 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.rt-body ul,
.rt-body ol {
  margin: 0 0 10px;
  padding-left: 22px;
}

.rt-body li {
  margin: 2px 0;
}

.rt-body blockquote {
  margin: 10px 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--sx-line, #e5e7eb);
  color: var(--sx-text-2, #4b5563);
}

.rt-body blockquote .attrib {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--sx-text-3, #6b7280);
}

.rt-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sx-surface-2, #f3f4f6);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.rt-body pre {
  position: relative;
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: var(--sx-r-md, 10px);
  background: var(--sx-surface-2, #f3f4f6);
  border: 1px solid var(--sx-line-2, #eef0f3);
  /* A long line scrolls inside the block instead of widening the column. */
  overflow-x: auto;
}

.rt-body pre code {
  padding: 0;
  background: none;
  white-space: pre;
}

.rt-body pre .filename {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sx-text-3, #9ca3af);
}

.rt-body a {
  color: var(--sx-accent, #4f46e5);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rt-body hr {
  margin: 14px 0;
  border: 0;
  border-top: 1px solid var(--sx-line, #e5e7eb);
}

/* A pipe table is boxed into its own scroll container: reader content sits in
   a narrow column and a wide table must not push the page sideways. */
.rt-body .md-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.rt-body .md-table th,
.rt-body .md-table td {
  padding: 6px 12px;
  text-align: left;
  border-bottom: 1px solid var(--sx-line-2, #eef0f3);
  white-space: nowrap;
}

.rt-body .md-table thead th {
  font-weight: 600;
  color: var(--sx-text-2, #374151);
}

/* ---- author chip ------------------------------------------------------- */

.ac-chip {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ac-chip:hover .ac-chip-name,
.ac-chip:focus-visible .ac-chip-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ac-chip-name {
  font-weight: 600;
  color: var(--sx-text, #111827);
}

/* The avatar tile: an <img> when the author has a picture, a monogram when
   they don't. Sized by the surface that uses it (comments set --ac-avatar). */
.ac-avatar-tile {
  flex: 0 0 auto;
  width: var(--ac-avatar, 34px);
  height: var(--ac-avatar, 34px);
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: calc(var(--ac-avatar, 34px) * 0.36);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--sx-accent, #4f46e5);
}

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

.ac-verified {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sx-accent, #4f46e5);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.ac-role {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sx-accent, #4f46e5);
  background: color-mix(in srgb, var(--sx-accent, #4f46e5) 12%, transparent);
}

/* ---- mini profile card ------------------------------------------------- */

.ac-card {
  position: absolute;
  z-index: 90;
  width: 288px;
  border-radius: var(--sx-r-lg, 14px);
  overflow: hidden;
  background: var(--sx-surface, #fff);
  border: 1px solid var(--sx-line, #e5e7eb);
  box-shadow: 0 12px 32px rgb(0 0 0 / 16%);
}

.ac-card[hidden] {
  display: none;
}

.ac-cover {
  position: relative;
  height: 72px;
  overflow: hidden;
  background: linear-gradient(120deg, #3D4DFF 0%, #1A1F6B 58%, #0B0D12 100%);
}

/* The banner lives on its own layer so the seller's saved focal point + zoom
   apply to the photo alone — same treatment as the storefront hero. */
.ac-cover-media {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: 50% 50%;
}

.ac-avatar {
  position: relative;
  margin: -26px 0 0 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 3px solid var(--sx-surface, #fff);
  box-sizing: border-box;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

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

.ac-avatar-img[hidden],
.ac-avatar-mono[hidden] {
  display: none;
}

.ac-body {
  padding: 8px 16px 16px;
}

.ac-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.ac-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--sx-text, #111827);
}

.ac-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sx-accent, #4f46e5);
  background: color-mix(in srgb, var(--sx-accent, #4f46e5) 12%, transparent);
}

.ac-handle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--sx-text-3, #6b7280);
}

.ac-tagline {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--sx-text-2, #4b5563);
}

.ac-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sx-accent, #4f46e5);
}

.ac-badge[hidden],
.ac-handle[hidden],
.ac-tagline[hidden],
.ac-link[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ac-card {
    animation: ac-card-in 120ms ease-out;
  }
}

@keyframes ac-card-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
