/* rich-text.css - the shared look of merchant rich text (BUILD_BRIEF_2026-10-06-D section 5c).
 *
 * One block for EVERY place the theme prints a merchant's rich text, each of which carries the
 * `rich-text` class next to its own (.body / .rte / .policy-body):
 *   product description   templates/product.liquid, sections/main_product.liquid (inline + collapsible)
 *   product collapsible tab sections/main_product.liquid (collapsible_row)
 *   collection description templates/collection.liquid, sections/collection_banner.liquid
 *   page                  templates/page.liquid, sections/page_content.liquid
 *   blog post             templates/article.liquid, sections/main_article.liquid
 *   policy                templates/policy.liquid (both languages)
 *   metaobject rich text  templates/metaobject.liquid
 *
 * It styles only the pieces the shared admin editor adds (components/ui/RichTextEditor.tsx):
 * quotes, callout boxes, captioned images at three sizes, video cards, tables and dividers.
 * Paragraphs, lists and headings keep the rules each surface already had, so a description
 * written before the editor looks the same.
 *
 * Colours come from the theme: the heading/body fonts and --primary, and every tint is mixed
 * from currentColor. That is what makes the same rules readable on the collection banner's
 * white-on-photo text as on a white product page, without a second set.
 */

.rich-text {
  overflow-wrap: break-word;
}

/* Pictures never push the page sideways: an old description's <img width="1200"> included. */
.rich-text img {
  max-width: 100%;
  height: auto;
}

/* --- quote ---------------------------------------------------------------------------- */
.rich-text blockquote {
  margin: 1.25em 0;
  padding: 0.25em 0 0.25em 1.1em;
  border-left: 3px solid var(--primary, currentColor);
  font-family: var(--font-heading, var(--font-body));
  font-size: 1.15em;
  font-style: italic;
  line-height: 1.5;
}

.rich-text blockquote > :first-child {
  margin-top: 0;
}

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

.rich-text blockquote cite {
  display: block;
  margin-top: 0.35em;
  font-family: var(--font-body);
  font-size: 0.8em;
  font-style: normal;
  opacity: 0.75;
}

/* --- callout box ------------------------------------------------------------------------ */
.rich-text [data-callout] {
  --rte-tone: currentColor;
  margin: 1.25em 0;
  padding: 0.875em 1em;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-left-width: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
  border-color: color-mix(in srgb, var(--rte-tone) 22%, transparent);
  border-left-color: color-mix(in srgb, var(--rte-tone) 70%, transparent);
  background: color-mix(in srgb, var(--rte-tone) 7%, transparent);
}

.rich-text [data-callout="info"] {
  --rte-tone: #2f6fde;
}

.rich-text [data-callout="success"] {
  --rte-tone: #1f8a4c;
}

.rich-text [data-callout="warning"] {
  --rte-tone: #c77700;
}

.rich-text [data-callout] > :first-child {
  margin-top: 0;
}

.rich-text [data-callout] > :last-child {
  margin-bottom: 0;
}

/* --- images: small / medium / full, with a centred caption --------------------------------- */
.rich-text figure {
  margin: 1.5em 0;
}

.rich-text figure[data-size] {
  margin-inline: auto;
}

.rich-text figure[data-size="small"] {
  width: 40%;
}

.rich-text figure[data-size="medium"] {
  width: 70%;
}

.rich-text figure[data-size="full"] {
  width: 100%;
}

.rich-text figure[data-size] img {
  display: block;
  width: 100%;
  border-radius: 12px;
}

.rich-text figcaption {
  margin-top: 0.5em;
  font-size: 0.8125em;
  line-height: 1.4;
  text-align: center;
  opacity: 0.72;
}

/* --- video card (expanded in Go, storefront/richtext_render.go) ---------------------------- */
.rich-text .rte-video {
  width: 100%;
  margin: 1.5em 0;
}

.rte-video__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: #111;
}

.rte-video__poster {
  position: absolute;
  inset: 0;
  display: block;
  color: #fff;
}

.rte-video__poster:hover {
  text-decoration: none;
}

.rte-video__poster:focus-visible {
  outline: 3px solid var(--primary, #fff);
  outline-offset: -3px;
}

/* Vimeo: no thumbnail can be derived from the ID, so a dark poster carrying the caption. */
.rte-video__poster--dark {
  background: linear-gradient(135deg, #3b3b44, #16161b);
}

/* Scoped under .rich-text so it outranks `.rich-text img { height: auto }` above: without that, the
   poster kept its 4:3 shape and YouTube's baked-in black bars showed above and below (2026-10-06). */
.rich-text .rte-video__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

.rte-video__label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  overflow: hidden;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-style: normal;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rte-video__play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}

.rte-video__poster:hover .rte-video__play,
.rte-video__poster:focus-visible .rte-video__play {
  transform: translate(-50%, -50%) scale(1.06);
}

.rte-video__play svg {
  width: 44%;
  height: auto;
  margin-left: 6%;
}

/* The player replaces the poster in place, so it fills the same 16:9 box. */
.rte-video__iframe,
.rte-video__media {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.rte-video__media {
  object-fit: contain;
}

/* --- table ------------------------------------------------------------------------------- */
.rich-text table {
  width: 100%;
  margin: 1em 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-color: color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 10px;
  font-size: 0.95em;
}

.rich-text th,
.rich-text td {
  padding: 0.55em 0.75em;
  text-align: left;
  vertical-align: top;
}

.rich-text th {
  background: rgba(0, 0, 0, 0.04);
  background: color-mix(in srgb, currentColor 6%, transparent);
  font-weight: 600;
}

.rich-text tr + tr > td,
.rich-text tr + tr > th,
.rich-text thead + tbody > tr:first-child > td,
.rich-text thead + tbody > tr:first-child > th {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-top-color: color-mix(in srgb, currentColor 12%, transparent);
}

.rich-text th > :first-child,
.rich-text td > :first-child {
  margin-top: 0;
}

.rich-text th > :last-child,
.rich-text td > :last-child {
  margin-bottom: 0;
}

/* --- divider ----------------------------------------------------------------------------- */
.rich-text hr {
  height: 1px;
  margin: 2em 0;
  border: 0;
  background: currentColor;
  opacity: 0.18;
}

/* --- a phone -------------------------------------------------------------------------------
 * A wide table scrolls INSIDE its own box, never the page: the table becomes a scrolling block
 * (as wide as its rows, at most the column) whose rows lay out as before. min-width is reset
 * because an older page's inline `min-width:420px` would otherwise hold the box wider than a
 * 390px screen, and !important is the only way past an inline style. */
@media screen and (max-width: 749px) {
  .rich-text table {
    display: block;
    width: max-content;
    max-width: 100%;
    min-width: 0 !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .rich-text figure[data-size="small"] {
    width: 60%;
  }

  .rich-text figure[data-size="medium"] {
    width: 100%;
  }

  .rte-video__play {
    width: 3.25rem;
    height: 3.25rem;
  }
}

/* --- on the collection banner's photo: white text, so the accent follows the text -------- */
.collection-banner--overlay .rich-text blockquote {
  border-left-color: currentColor;
}

.collection-banner .rich-text table,
.collection-banner .rich-text figure,
.collection-banner .rich-text .rte-video {
  text-transform: none;
  letter-spacing: normal;
}
