/**
 * CMS Content Styles
 *
 * Platform-level defaults for admin editor content (Page Editor and Blog
 * Editor output). Automatically linked on pages that render the
 * {{page:content}} or {{blog:post_content}} shortcodes via the template
 * injection system (see server/config/template-injections.js), and on the
 * header/footer fallback for custom pages.
 *
 * The stylesheet is injected before the template's own stylesheet so any
 * rule here can be overridden by a template with equal or higher
 * specificity. Values are intentionally neutral (no template CSS
 * variables) so they look reasonable on any template.
 */

/* Tables (Page/Blog Editor table-better output) */
.cms-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.875rem;
}

.cms-content table th,
.cms-content table td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem 1rem;
    text-align: left;
    vertical-align: top;
}

.cms-content table th {
    background-color: #f9fafb;
    font-weight: 600;
}

/* Embedded videos (iframe) — never overflow the page on small screens.
   New editor insertions are width 100% with a 16/9 aspect ratio; this
   covers older embeds with fixed pixel widths. */
.cms-content iframe {
    max-width: 100%;
}

/* Image/video alignment (quill-blot-formatter2 output) */
.cms-content {
    --blot-align-left-margin: 0.5rem 1rem 0.5rem 0;
    --blot-align-center-margin: 1rem auto;
    --blot-align-right-margin: 0.5rem 0 0.5rem 1rem;
}

.cms-content [class^="ql-image-align-"] {
    display: flex;
    flex-wrap: wrap;
    width: var(--resize-width);
    max-width: 100%;
}

.cms-content [class^="ql-image-align-"] > img {
    flex: 1 1 auto;
    z-index: 1;
}

.cms-content .ql-image-align-left,
.cms-content .ql-iframe-align-left {
    margin: var(--blot-align-left-margin);
    float: left;
}

.cms-content .ql-image-align-center,
.cms-content .ql-iframe-align-center {
    margin: var(--blot-align-center-margin);
}

.cms-content .ql-iframe-align-center {
    display: block;
}

.cms-content .ql-image-align-right,
.cms-content .ql-iframe-align-right {
    margin: var(--blot-align-right-margin);
    float: right;
}

/* Image captions: the editor's alt/title tool mirrors the title onto
   aligned wrappers as data-title; display it as a caption. Kept neutral
   (inherited color, transparent background) so it works on any template. */
.cms-content [class^="ql-image-align-"][data-title] {
    margin-bottom: 0;
}

.cms-content [class^="ql-image-align-"][data-title]::after {
    content: attr(data-title);
    width: 100%;
    padding: 0.25rem 0.2rem;
    font-size: 0.875rem;
    line-height: 1.3;
    opacity: 0.7;
}

.cms-content .ql-image-align-left[data-title]::after {
    text-align: left;
}

.cms-content .ql-image-align-center[data-title]::after {
    text-align: center;
}

.cms-content .ql-image-align-right[data-title]::after {
    text-align: right;
}

/* No underline bleed when a linked image has a caption */
.cms-content a:has([class^="ql-image-align-"] > img) {
    text-decoration: none;
}
