/*
 * Shared rich-content stylesheet.
 *
 * Every renderer of structured rich content — the Tiptap editor content, the
 * application-DOM display (RichTextDisplay / LocalizedStringDisplay / the
 * registration ContentPanel), and the broadcast iframe (SceneSlot.buildHtmlSrcDoc)
 * — links this same file so a saved node looks materially the same while
 * editing and after publishing.
 *
 * Saved structures use an outer `.rich-text-display` class supplied by the
 * renderer, plus the stable descendant classes (.rt-section, .rt-columns, …)
 * and `data-rt-*` attributes that the sanitizer allows. The CSS uses custom
 * properties with fallbacks so a renderer (or a registration content theme)
 * can override brand colors without rewriting saved HTML; explicit inline
 * styles on a node always win over these defaults.
 *
 * This file is linked from the root Remix `links` export and from the broadcast
 * iframe document. Do NOT use a late CSS `@import` to load it: CSS imports must
 * precede ordinary rules and the app stylesheet already contains generated
 * layers and application rules.
 */

.rich-text-display {
  /* Brandable defaults. A renderer sets these via inline style or a
   * registration content theme; explicit per-node inline styles win. */
  --rt-primary: #8b1d41;
  --rt-text: #383b3e;
  --rt-muted: #6b7280;
  --rt-surface: #ffffff;
  --rt-border: #e5e7eb;
  --rt-rule: #808080;
  --rt-button-bg: #8b1d41;
  --rt-button-fg: #ffffff;

  color: var(--rt-text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.rich-text-display > :last-child {
  margin-bottom: 0;
}

/* Spacing scale shared by sections, columns gap, and disclosure content. */
.rich-text-display [data-rt-padding="none"] {
  padding: 0;
}
.rich-text-display [data-rt-padding="small"] {
  padding: 0.5rem;
}
.rich-text-display [data-rt-padding="medium"] {
  padding: 1rem;
}
.rich-text-display [data-rt-padding="large"] {
  padding: 1.75rem;
}

/* ----- Section ----------------------------------------------------------- */
.rich-text-display .rt-section {
  display: block;
  background-color: var(--rt-surface);
  color: var(--rt-text);
  border-radius: 0.25rem;
}
.rich-text-display .rt-section[data-rt-align="center"] > * {
  text-align: center;
}
.rich-text-display .rt-section[data-rt-align="right"] > * {
  text-align: right;
}
.rich-text-display .rt-section[data-rt-align="left"] > * {
  text-align: left;
}

/* ----- Columns ----------------------------------------------------------- */
.rich-text-display .rt-columns {
  display: grid;
  grid-template-columns: repeat(var(--rt-columns, 2), minmax(0, 1fr));
  gap: var(--rt-gap, 1rem);
}
.rich-text-display .rt-columns[data-rt-columns="2"] {
  --rt-columns: 2;
}
.rich-text-display .rt-columns[data-rt-columns="3"] {
  --rt-columns: 3;
}
.rich-text-display .rt-columns[data-rt-gap="none"] {
  --rt-gap: 0;
}
.rich-text-display .rt-columns[data-rt-gap="small"] {
  --rt-gap: 0.5rem;
}
.rich-text-display .rt-columns[data-rt-gap="medium"] {
  --rt-gap: 1rem;
}
.rich-text-display .rt-columns[data-rt-gap="large"] {
  --rt-gap: 1.75rem;
}
.rich-text-display .rt-column {
  min-width: 0; /* prevent grid blowout from wide content */
}

/* ----- Collapsible (native <details>/<summary>) -------------------------- */
.rich-text-display .rt-details {
  margin: 0.75rem 0;
  border-top: 1px dashed var(--rt-border);
  border-bottom: 1px dashed var(--rt-border);
  background-color: transparent;
}
.rich-text-display .rt-details > summary,
.rich-text-display .rt-details > .rt-details-summary {
  list-style: none;
  cursor: pointer;
  padding: 0.625rem 0.875rem;
  font-weight: 600;
  color: var(--rt-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rich-text-display .rt-details > summary::-webkit-details-marker,
.rich-text-display .rt-details > .rt-details-summary::-webkit-details-marker {
  display: none;
}
.rich-text-display .rt-details > summary::before,
.rich-text-display .rt-details > .rt-details-summary::before {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  flex: 0 0 auto;
  border-right: 0.15em solid currentColor;
  border-bottom: 0.15em solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-left: 0.15em;
  color: var(--rt-arrow-color, currentColor);
}
.rich-text-display .rt-details[open] > summary::before,
.rich-text-display .rt-details[open] > .rt-details-summary::before {
  transform: rotate(45deg);
}
.rich-text-display .rt-details-content {
  padding: 0.75rem 0.875rem 0.875rem;
  border-top: 1px dashed var(--rt-border);
}

/* ----- Button link ------------------------------------------------------- */
.rich-text-display .rt-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin: 0.5rem 0;
  border-radius: 0.25rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}
.rich-text-display .rt-button[data-rt-button-style="solid"] {
  background-color: var(--rt-button-bg);
  color: var(--rt-button-fg);
  border-color: var(--rt-button-bg);
}
.rich-text-display .rt-button[data-rt-button-style="solid"]:hover {
  opacity: 0.9;
}
.rich-text-display .rt-button[data-rt-button-style="outline"] {
  background-color: transparent;
  color: var(--rt-button-bg);
  border-color: var(--rt-button-bg);
}
.rich-text-display .rt-button[data-rt-button-style="outline"]:hover {
  background-color: var(--rt-button-bg);
  color: var(--rt-button-fg);
}
.rich-text-display .rt-button[data-rt-align="center"] {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
}
.rich-text-display .rt-button[data-rt-align="right"] {
  margin-left: auto;
  width: fit-content;
}

/* ----- Image ------------------------------------------------------------- */
.rich-text-display .rt-image {
  height: auto;
  max-width: 100%;
  display: block;
}
.rich-text-display .rt-image[data-rt-width="25"] {
  width: 25%;
}
.rich-text-display .rt-image[data-rt-width="50"] {
  width: 50%;
}
.rich-text-display .rt-image[data-rt-width="75"] {
  width: 75%;
}
.rich-text-display .rt-image[data-rt-width="100"] {
  width: 100%;
}
.rich-text-display .rt-image[data-rt-align="center"] {
  margin-left: auto;
  margin-right: auto;
}
.rich-text-display .rt-image[data-rt-align="right"] {
  margin-left: auto;
}

/* ----- Divider ----------------------------------------------------------- */
.rich-text-display .rt-divider {
  border: none;
  border-top: 1px solid var(--rt-rule);
  margin: 1rem 0;
}

/* ----- Focus visibility (do not hide the native focus indicator) -------- */
.rich-text-display :focus-visible {
  outline: 2px solid var(--rt-primary);
  outline-offset: 2px;
}

/* ----- Responsive: collapse columns to one track on narrow screens ------ */
@media (max-width: 48rem) {
  .rich-text-display .rt-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}
