/*
 * Rendering for a ContentBlock's own content (HTML text + media), shared
 * between the admin preview (templates/admin/content_block/index.html.twig)
 * and the future public homepage rendering. Alternation (background + text/
 * media side) is purely CSS-driven via :nth-child(even), so it stays correct
 * regardless of how the blocks got into that order (including after an
 * admin drag-and-drop reorder) — no server- or JS-side bookkeeping needed.
 *
 * Layout/behavior specific to the admin management UI (block border, drag
 * handle, action buttons column, dragging state) is NOT here — it lives
 * alongside templates/admin/content_block/index.html.twig instead.
 */

.cb-preview {
    padding: 40px 30px;
}

.cb-block:nth-child(even) .cb-preview {
    background: #f8f8f8;
}

.cb-columns {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    gap: 40px;
    align-items: center;
}

.cb-columns > div {
    flex: 1 1 0;
    min-width: 0;
}

.cb-block:nth-child(even) .cb-columns:not(.cb-columns-single) {
    flex-direction: row-reverse;
}

.cb-media img {
    width: 100%;
    border-radius: 12px;
}

/*
 * Typography for a block's HTML content. Applied both where the content is
 * rendered read-only (.cb-text, admin preview / future front) and inside the
 * CKEditor 5 editor itself (ckeditor_controller.js adds this same class to
 * the editable root, which already carries CKEditor's own `.ck-content`) so
 * what the admin edits visually matches what gets rendered — otherwise
 * CKEditor's own generic content styles would make the WYSIWYG preview lie
 * about the real output. The `.ck-content.cb-text` variant matches CKEditor's
 * own heading selector specificity; since this stylesheet loads after
 * ckeditor5.css, the tie is broken in our favor.
 */
.cb-text,
.cb-text.ck-content {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #222;
}

.cb-text h1,
.ck-content.cb-text h1 { font-size: 2rem; margin-bottom: 20px; }
.cb-text h2,
.ck-content.cb-text h2 { font-size: 1.5rem; margin-bottom: 20px; }
.cb-text h3,
.ck-content.cb-text h3 { font-size: 1.5rem; margin-bottom: 16px; }
.cb-text p { margin: 0 0 16px; }
.cb-text ul,
.cb-text ol { padding-left: 25px; margin: 0 0 16px; }
.cb-text strong { font-size: 1.1em; }
.cb-text > *:last-child { margin-bottom: 0; }

/*
 * Tables aren't a loaded CKEditor feature (only General HTML Support keeps
 * them intact when hand-written or pasted via source view) — no plugin CSS
 * comes with them, so style them here.
 */
.cb-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px;
}
.cb-text th,
.cb-text td {
    padding: 10px 14px;
    border: 1px solid #ddd;
    text-align: left;
}
.cb-text th {
    background: #f5f5f5;
    font-weight: 700;
}

.cb-text td .cb-check,
.cb-text th .cb-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #198754;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}

.cb-text .cb-price {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
    color: #555;
}

/*
 * Pricing-style table (.cb-pricing-table): mirrors var/landing/styles.css's
 * .pricing-table exactly — capped width and centered rather than stretched
 * to the block's full width, row-separator borders instead of a full grid,
 * plan columns centered.
 */
.cb-text .cb-pricing-table {
    max-width: 850px;
    margin: 0 auto 16px;
    background: #fff;
    color: #222;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
.cb-text .cb-pricing-table th,
.cb-text .cb-pricing-table td {
    border: none;
    border-bottom: 1px solid #e5e5e5;
}
.cb-text .cb-pricing-table thead th {
    font-size: 1.05rem;
}
.cb-text .cb-pricing-table th:not(:first-child),
.cb-text .cb-pricing-table td:not(:first-child) {
    width: 150px;
    text-align: center;
}
.cb-text .cb-pricing-table tbody tr:last-child td {
    border-bottom: none;
}
.cb-text .cb-pricing-table tbody tr:hover {
    background: #fafafa;
}

/*
 * Card grid — same "not a native feature" situation as tables: only kept
 * intact by General HTML Support, styled here for the same reason.
 */
.cb-text .cb-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin: 0 0 16px;
}
.cb-text .cb-card {
    padding: 24px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
}
.cb-text .cb-card p { margin: 0 0 12px; }
.cb-text .cb-card strong { font-size: 1em; }

/*
 * Inline video embed (a raw <iframe>, kept intact by General HTML Support —
 * no MediaEmbed feature is loaded), for content that embeds a video directly
 * in the text flow instead of using the block's own image/YouTube media slot.
 * Full block width (unlike var/landing/styles.css's capped .video-container),
 * per explicit request.
 */
.cb-text .cb-video {
    width: 100%;
    margin: 0 0 16px;
    aspect-ratio: 4 / 3;
}
.cb-text .cb-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 12px;
}

/* CTA button, matching var/landing/styles.css's .button */
.cb-text .cb-button {
    display: inline-block;
    padding: 15px 30px;
    background: #111;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    margin: 20px 0;
}

/*
 * The last block gets the darker "final CTA" treatment from the mockup's
 * .final-cta section — defined purely by DOM position (like the alternating
 * background above), so it always tracks whichever block is actually last,
 * including after a drag-and-drop reorder. Declared after the nth-child(even)
 * rule so it wins the specificity tie when the last block also happens to be
 * even. A block embedding something with its own background (e.g. the
 * pricing table) resets back to its own colors so it stays readable.
 */
.cb-block:last-child .cb-preview {
    background: #808080;
}
.cb-block:last-child .cb-text {
    color: #fff;
    text-align: center;
}

@media (max-width: 800px) {
    .cb-columns,
    .cb-block:nth-child(even) .cb-columns:not(.cb-columns-single) {
        flex-direction: column;
        align-items: stretch;
    }
}
