/* =====================================================================
 * rich-content.css - how content written with RichEditor renders.
 *
 * Loaded by BOTH the editor (admin, .rt-content) and the storefront
 * (.content). Spacing rules are shared and use normal specificity so
 * CSS resets (Tailwind preflight) cannot flatten them, and so the editor
 * and the live page always have identical spacing.
 * Page templates must NOT redefine margins/padding of content elements.
 * ================================================================== */

.rt-content, .content { overflow-wrap: anywhere; }
.rt-content::after, .content::after { content: ""; display: table; clear: both; }

/* ---- paragraphs ---- */
.rt-content p, .content p { margin: 0 0 1em; line-height: 1.65; }
/* paragraphs stored as plain <div>s */
.content > div:not([class]) { margin: 0 0 1em; line-height: 1.65; }

/* ---- headings ---- */
.rt-content :is(h1, h2, h3, h4, h5, h6),
.content :is(h1, h2, h3, h4, h5, h6) { line-height: 1.25; font-weight: 600; margin: 1.25em 0 .45em; }
.rt-content h1, .content h1 { font-size: 1.9em; }
.rt-content h2, .content h2 { font-size: 1.55em; }
.rt-content h3, .content h3 { font-size: 1.3em; }
.rt-content h4, .content h4 { font-size: 1.15em; }
.rt-content h5, .content h5 { font-size: 1em; }
.rt-content h6, .content h6 { font-size: .9em; text-transform: uppercase; letter-spacing: .04em; }

/* ---- lists ---- */
.rt-content :is(ul, ol), .content :is(ul, ol) { margin: 0 0 1em; padding-left: 1.6em; line-height: 1.65; }
.rt-content ul, .content ul { list-style: disc; }
.rt-content ol, .content ol { list-style: decimal; }
.rt-content ul ul, .content ul ul { list-style: circle; }
.rt-content ul ul ul, .content ul ul ul { list-style: square; }
.rt-content li, .content li { margin: 0; }
.rt-content li + li, .content li + li { margin-top: .25em; }
.rt-content li > :is(ul, ol), .content li > :is(ul, ol) { margin: .25em 0 0; }
.rt-content li > p, .content li > p { margin: 0; }

/* outer edges: no extra space before the first / after the last block */
.rt-content > :first-child, .content > :first-child { margin-top: 0; }
.rt-content > :last-child, .content > :last-child { margin-bottom: 0; }

/* ---- checklist ---- */
.rt-content ul.rt-checklist, .content ul.rt-checklist { list-style: none; padding-left: 0; }
.rt-content ul.rt-checklist > li, .content ul.rt-checklist > li { position: relative; padding-left: 1.9em; }
.rt-content ul.rt-checklist > li::before, .content ul.rt-checklist > li::before {
  content: ""; position: absolute; left: .15em; top: .3em; width: 1.05em; height: 1.05em;
  border: 2px solid #9ca3af; border-radius: 4px; background: #fff; box-sizing: border-box;
}
.rt-content ul.rt-checklist > li[data-checked="true"]::before, .content ul.rt-checklist > li[data-checked="true"]::before {
  background: #2563eb; border-color: #2563eb;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}
.rt-content ul.rt-checklist > li[data-checked="true"], .content ul.rt-checklist > li[data-checked="true"] { color: #6b7280; text-decoration: line-through; }

/* ---- quote / code / rule ---- */
.rt-content blockquote, .content blockquote {
  margin: 0 0 1em; padding: .1em 1.1em; border-left: 4px solid #d1d5db; color: #4b5563; font-style: italic;
}
.rt-content blockquote > p:last-child, .content blockquote > p:last-child { margin-bottom: 0; }
.rt-content pre, .content pre {
  margin: 0 0 1em; padding: 1em 1.2em; overflow-x: auto; white-space: pre-wrap; tab-size: 2;
  font: .9em/1.6 ui-monospace, SFMono-Regular, Consolas, Monaco, monospace;
}
.rt-content hr, .content hr { margin: 1.5em 0; }

.rt-content code, :where(.content) :where(code) {
  background: #f3f4f6; color: #be185d; padding: .15em .4em; border-radius: 4px;
  font: .92em/1.4 ui-monospace, SFMono-Regular, Consolas, Monaco, monospace;
}
.rt-content pre, :where(.content) :where(pre) { background: #111827; color: #e5e7eb; border-radius: 8px; }
.rt-content pre code, :where(.content) :where(pre code) { background: none; color: inherit; padding: 0; }
.rt-content hr, :where(.content) :where(hr) { border: 0; border-top: 1px solid #d1d5db; }
.rt-content a[href], :where(.content) :where(a[href]) { color: #2563eb; text-decoration: underline; text-underline-offset: 2px; }
.rt-content mark, :where(.content) :where(mark) { background: #fff59d; padding: 0 .15em; }
.rt-content sub, .rt-content sup, :where(.content) :where(sub, sup) { font-size: .75em; line-height: 0; }

/* ---- tables ---- */
.rt-content table, .content table { width: 100%; border-collapse: collapse; margin: 0 0 1em; table-layout: auto; }
.rt-content th, .rt-content td, :where(.content) :where(th, td) { border: 1px solid #d1d5db; padding: .55em .75em; vertical-align: top; text-align: left; }
.rt-content th, :where(.content) :where(th) { background: #f3f4f6; font-weight: 600; }
.rt-content td > p, .rt-content th > p, .content td > p, .content th > p { margin: 0; }
@media (max-width: 640px) {
  .rt-content table, .content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ---- figures: images, video, audio ---- */
.rt-content figure, .content figure.rt-figure { display: block; margin: 0 auto 1em; max-width: 100%; width: fit-content; text-align: center; }
.rt-content figure img, .rt-content figure video,
.content figure.rt-figure img, .content figure.rt-figure video { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 6px; }
.rt-content figure[style*="width"] img, .rt-content figure[style*="width"] video,
.content figure.rt-figure[style*="width"] img, .content figure.rt-figure[style*="width"] video { width: 100%; }
.rt-content figure audio, .content figure.rt-figure audio { width: 100%; min-width: 260px; }
.rt-content figure a, .content figure.rt-figure a { display: block; }
.rt-content figcaption, .content figure.rt-figure figcaption { font-size: .875em; color: #6b7280; margin-top: .45em; text-align: center; }
/* file attachment block */
.rt-content figure.rt-file, .content figure.rt-figure.rt-file { text-align: left; margin-left: 0; margin-right: auto; }
.rt-content figure.rt-file a, .content figure.rt-figure.rt-file a {
  display: inline-block; padding: .55em 1em; border: 1px solid #d1d5db; border-radius: 8px; text-decoration: none;
}
/* alignment: block positions (no text wrap) */
.rt-content figure.rt-align-left,   .content figure.rt-figure.rt-align-left   { float: none; margin-left: 0;    margin-right: auto; }
.rt-content figure.rt-align-center, .content figure.rt-figure.rt-align-center { float: none; margin-left: auto; margin-right: auto; }
.rt-content figure.rt-align-right,  .content figure.rt-figure.rt-align-right  { float: none; margin-left: auto; margin-right: 0; }
/* alignment: floats (text wraps around the image) */
.rt-content figure.rt-float-left,  .content figure.rt-figure.rt-float-left  { float: left;  margin: .25em 1.5em 1em 0; max-width: 50%; }
.rt-content figure.rt-float-right, .content figure.rt-figure.rt-float-right { float: right; margin: .25em 0 1em 1.5em; max-width: 50%; }
@media (max-width: 600px) {
  .rt-content figure.rt-float-left, .rt-content figure.rt-float-right,
  .content figure.rt-figure.rt-float-left, .content figure.rt-figure.rt-float-right { float: none; margin: 0 auto 1em; max-width: 100%; }
}

/* responsive video embeds */
.rt-content .rt-embed, .content .rt-embed { position: relative; aspect-ratio: 16 / 9; margin: 0 0 1em; max-width: 100%; }
.rt-content .rt-embed iframe, .content .rt-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }