/*
 * Editor templates (core/includes/editor-templates.php, classes/EditorTemplates.php): the layout of the blocks a
 * writer inserts with the "Template" button. Only classes, no fixed colours: everything follows the colours of the
 * theme (--primary-color ...) and Bootstrap 5.3 (--bs-...), so dark mode works by itself. Loaded on the website and
 * in the editor; the fallbacks after the comma are for the editor, which has no Bootstrap.
 */

.cms-tpl { margin: 1.5rem 0; }
.cms-tpl > :first-child { margin-top: 0; }
.cms-tpl > :last-child { margin-bottom: 0; }
.cms-tpl img { max-width: 100%; height: auto; border-radius: var(--bs-border-radius, .375rem); }

/* Columns: --2 (50/50), --3, --1-2 (33/66), --2-1 (66/33); stacked on small screens */
.cms-tpl-columns { display: grid; gap: 1.25rem; grid-template-columns: 1fr 1fr; }
.cms-tpl-columns--3 { grid-template-columns: repeat(3, 1fr); }
.cms-tpl-columns--1-2 { grid-template-columns: 1fr 2fr; }
.cms-tpl-columns--2-1 { grid-template-columns: 2fr 1fr; }
.cms-tpl-columns > * > :first-child { margin-top: 0; }
@media (max-width: 767.98px) {
    .cms-tpl-columns, .cms-tpl-columns--3, .cms-tpl-columns--1-2, .cms-tpl-columns--2-1 { grid-template-columns: 1fr; }
}

/* Hero: theme colour, or light */
.cms-tpl-hero {
    padding: 3rem 2rem; text-align: center; border-radius: calc(var(--bs-border-radius, .375rem) * 2);
    background: linear-gradient(135deg, var(--primary-color, #0d6efd), var(--primary-gradient-end, var(--primary-hover-color, #0a58ca)));
    color: var(--primary-contrast, #fff);
}
.cms-tpl-hero h1, .cms-tpl-hero h2, .cms-tpl-hero p { color: inherit; }
.cms-tpl-hero h1 { font-size: 2.5em; margin-bottom: 1rem; }
.cms-tpl-hero p { font-size: 1.2em; }
.cms-tpl-hero--light { background: var(--bs-tertiary-bg, #f8f9fa); color: var(--bs-emphasis-color, #212529); }
.cms-tpl-hero--light h1, .cms-tpl-hero--light h2 { color: var(--primary-color, #0d6efd); }

/* Button: on a coloured block it turns light */
.cms-tpl-button {
    display: inline-block; padding: .75rem 2rem; border-radius: var(--bs-border-radius, .375rem); font-weight: 600;
    text-decoration: none; background: var(--primary-color, #0d6efd); color: var(--primary-contrast, #fff);
}
.cms-tpl-button:hover, .cms-tpl-button:focus { background: var(--primary-hover-color, #0a58ca); color: var(--primary-contrast, #fff); }
.cms-tpl-hero:not(.cms-tpl-hero--light) .cms-tpl-button { background: var(--primary-contrast, #fff); color: var(--primary-color, #0d6efd); }

/* Card and a row of cards */
.cms-tpl-card {
    border: 1px solid var(--bs-border-color, #dee2e6); border-radius: calc(var(--bs-border-radius, .375rem) * 1.5);
    padding: 1.25rem; background: var(--bs-body-bg, #fff);
}
.cms-tpl-card > :first-child { margin-top: 0; }
.cms-tpl-card > :last-child { margin-bottom: 0; }
.cms-tpl-cards { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.cms-tpl-cards .cms-tpl-card { text-align: center; }

/* Image next to text; --reverse = image right */
.cms-tpl-media { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center; }
.cms-tpl-media--reverse > :first-child { order: 2; }
@media (max-width: 767.98px) {
    .cms-tpl-media { grid-template-columns: 1fr; }
    .cms-tpl-media--reverse > :first-child { order: 0; }
}

/* Call to action */
.cms-tpl-cta {
    text-align: center; padding: 2.5rem 1.5rem; border: 2px solid var(--primary-color, #0d6efd);
    border-radius: calc(var(--bs-border-radius, .375rem) * 2); background: var(--bs-tertiary-bg, #f8f9fa);
}
.cms-tpl-cta h2 { color: var(--primary-color, #0d6efd); }

/* Quote */
.cms-tpl-quote {
    border-left: 4px solid var(--bs-border-color, #dee2e6); padding-left: 1.25rem; font-style: italic;
    color: var(--bs-secondary-color, #6c757d);
}
.cms-tpl-quote footer { font-style: normal; font-size: .9em; margin-top: .5rem; }
.cms-tpl-quote--highlight {
    border-left: 5px solid var(--primary-color, #0d6efd); background: var(--bs-tertiary-bg, #f8f9fa);
    padding: 1.5rem; border-radius: var(--bs-border-radius, .375rem); color: var(--bs-emphasis-color, #212529);
}
.cms-tpl-quote--highlight p:first-child { font-size: 1.3em; }
.cms-tpl-quote--highlight footer { font-weight: 600; color: var(--primary-color, #0d6efd); }

/* Checklist */
.cms-tpl-checklist { list-style: none; padding-left: 0; }
.cms-tpl-checklist li { position: relative; padding: .4rem 0 .4rem 1.75rem; }
.cms-tpl-checklist li::before { content: "\2713"; position: absolute; left: 0; font-weight: 700; color: var(--bs-success, #198754); }

/* Table */
.cms-tpl-table { width: 100%; border-collapse: collapse; }
.cms-tpl-table th, .cms-tpl-table td { padding: .75rem; border: 1px solid var(--bs-border-color, #dee2e6); text-align: left; }
.cms-tpl-table thead th { background: var(--primary-color, #0d6efd); color: var(--primary-contrast, #fff); }
.cms-tpl-table tbody tr:nth-child(even) { background: var(--bs-tertiary-bg, #f8f9fa); }

/* Notice boxes: --info, --tip, --warning, --success, --danger */
.cms-tpl-box {
    padding: 1.25rem; border: 1px solid; border-radius: var(--bs-border-radius, .375rem);
    background: var(--bs-info-bg-subtle, #cff4fc); border-color: var(--bs-info-border-subtle, #9eeaf9); color: var(--bs-info-text-emphasis, #055160);
}
.cms-tpl-box h3, .cms-tpl-box h4 { color: inherit; margin-top: 0; }
.cms-tpl-box > :last-child { margin-bottom: 0; }
.cms-tpl-box--tip, .cms-tpl-box--warning {
    background: var(--bs-warning-bg-subtle, #fff3cd); border-color: var(--bs-warning-border-subtle, #ffe69c); color: var(--bs-warning-text-emphasis, #664d03);
}
.cms-tpl-box--success {
    background: var(--bs-success-bg-subtle, #d1e7dd); border-color: var(--bs-success-border-subtle, #a3cfbb); color: var(--bs-success-text-emphasis, #0a3622);
}
.cms-tpl-box--danger {
    background: var(--bs-danger-bg-subtle, #f8d7da); border-color: var(--bs-danger-border-subtle, #f1aeb5); color: var(--bs-danger-text-emphasis, #58151c);
    border-left-width: 6px;
}

/* Divider */
.cms-tpl-divider { text-align: center; margin: 2.5rem 0; color: var(--bs-secondary-color, #6c757d); letter-spacing: .5em; font-size: 1.25rem; }

/* Date tile (event, agenda item) */
.cms-tpl-date {
    min-width: 4.5rem; padding: .6rem; text-align: center; border-radius: var(--bs-border-radius, .375rem);
    background: var(--primary-color, #0d6efd); color: var(--primary-contrast, #fff); line-height: 1.1;
}
.cms-tpl-date strong { display: block; font-size: 1.9em; }
.cms-tpl-date span { font-size: .85em; text-transform: uppercase; }
.cms-tpl-event { display: flex; gap: 1.25rem; align-items: flex-start; }
.cms-tpl-event > :last-child { flex: 1; }
.cms-tpl-event h3 { margin-top: 0; color: var(--primary-color, #0d6efd); }
.cms-tpl-agenda {
    display: flex; gap: 1rem; align-items: center; padding: .9rem; border-left: 4px solid var(--primary-color, #0d6efd);
    background: var(--bs-tertiary-bg, #f8f9fa);
}
.cms-tpl-agenda .cms-tpl-date { background: none; color: var(--primary-color, #0d6efd); min-width: 3.5rem; padding: 0; }
.cms-tpl-agenda .cms-tpl-date span { color: var(--bs-secondary-color, #6c757d); }
.cms-tpl-agenda h4 { margin: 0 0 .25rem; }
.cms-tpl-agenda p { margin: 0; font-size: .9em; color: var(--bs-secondary-color, #6c757d); }

/* People */
.cms-tpl-person { display: flex; gap: 1.25rem; align-items: center; }
.cms-tpl-person img { width: 6rem; height: 6rem; object-fit: cover; border-radius: 50%; }
.cms-tpl-person h3, .cms-tpl-person h4 { margin: 0 0 .25rem; }
.cms-tpl-person p { margin: .2rem 0; }
.cms-tpl-role { font-weight: 600; color: var(--primary-color, #0d6efd); }
.cms-tpl-team .cms-tpl-card img { width: 5rem; height: 5rem; object-fit: cover; border-radius: 50%; margin-bottom: .5rem; }
.cms-tpl-team .cms-tpl-card h4 { margin: .25rem 0; }
.cms-tpl-team .cms-tpl-card p { margin: .2rem 0; font-size: .9em; }

/* News header */
.cms-tpl-newsheader { border-bottom: 3px solid var(--primary-color, #0d6efd); padding-bottom: 1rem; }
.cms-tpl-newsheader .cms-tpl-meta { font-size: .85em; color: var(--bs-secondary-color, #6c757d); display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.cms-tpl-newsheader h1 { margin: .5rem 0 0; }

/* Label (badge) */
.cms-tpl-label {
    display: inline-block; padding: .2rem .8rem; border-radius: 2rem; font-size: .85em; font-weight: 600;
    background: var(--primary-color, #0d6efd); color: var(--primary-contrast, #fff);
}
.cms-tpl-label--success { background: var(--bs-success, #198754); color: #fff; }
.cms-tpl-label--warning { background: var(--bs-warning, #ffc107); color: #000; }

/* Timeline */
.cms-tpl-timeline { border-left: 3px solid var(--primary-color, #0d6efd); padding-left: 1.5rem; }
.cms-tpl-timeline > div { position: relative; margin-bottom: 1.5rem; }
.cms-tpl-timeline > div::before {
    content: ""; position: absolute; left: calc(-1.5rem - 9px); top: .3rem; width: 15px; height: 15px; border-radius: 50%;
    background: var(--primary-color, #0d6efd); border: 3px solid var(--bs-body-bg, #fff);
}
.cms-tpl-timeline .cms-tpl-meta { font-size: .85em; color: var(--bs-secondary-color, #6c757d); }
.cms-tpl-timeline h4 { margin: .25rem 0; }

/* Figures */
.cms-tpl-stats { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); text-align: center; }
.cms-tpl-stats > div {
    padding: 1.75rem 1rem; border-radius: calc(var(--bs-border-radius, .375rem) * 2);
    background: rgba(var(--primary-rgb, 13, 110, 253), .1); color: var(--bs-emphasis-color, #212529);
}
.cms-tpl-stats strong { display: block; font-size: 2.75em; line-height: 1.1; color: var(--primary-color, #0d6efd); }

/* Progress */
.cms-tpl-progress { height: 1.75rem; border-radius: 1rem; overflow: hidden; background: var(--bs-secondary-bg, #e9ecef); margin: 1rem 0; }
.cms-tpl-progress > div {
    height: 100%; display: flex; align-items: center; justify-content: center; font-size: .85em; font-weight: 700;
    background: var(--bs-success, #198754); color: #fff;
}

/* Download */
.cms-tpl-download {
    display: flex; gap: 1rem; align-items: center; padding: 1.25rem; border: 2px dashed var(--primary-color, #0d6efd);
    border-radius: var(--bs-border-radius, .375rem); background: rgba(var(--primary-rgb, 13, 110, 253), .05);
}
.cms-tpl-download > :nth-child(2) { flex: 1; }
.cms-tpl-download h4 { margin: 0 0 .25rem; color: var(--primary-color, #0d6efd); }
.cms-tpl-download p { margin: 0; font-size: .9em; color: var(--bs-secondary-color, #6c757d); }
.cms-tpl-icon { font-size: 2.5em; line-height: 1; color: var(--primary-color, #0d6efd); }

/* Steps: numbered automatically */
.cms-tpl-steps { list-style: none; padding-left: 0; counter-reset: cms-step; }
.cms-tpl-steps li { position: relative; padding-left: 3.5rem; margin: 1.25rem 0; counter-increment: cms-step; }
.cms-tpl-steps li::before {
    content: counter(cms-step); position: absolute; left: 0; top: 0; width: 2.5rem; height: 2.5rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
    background: var(--primary-color, #0d6efd); color: var(--primary-contrast, #fff);
}
.cms-tpl-steps h4 { margin: 0 0 .3rem; }
.cms-tpl-steps p { margin: 0; color: var(--bs-secondary-color, #6c757d); }

/* Question and answer (open and close) */
.cms-tpl-faq { border: 1px solid var(--bs-border-color, #dee2e6); border-radius: var(--bs-border-radius, .375rem); padding: 1rem 1.25rem; }
.cms-tpl-faq summary { cursor: pointer; font-weight: 600; color: var(--primary-color, #0d6efd); }
.cms-tpl-faq[open] summary { margin-bottom: .5rem; }

/* Project status: title and label on one line */
.cms-tpl-status { border-left: 5px solid var(--bs-success, #198754); background: var(--bs-tertiary-bg, #f8f9fa); padding: 1.25rem; border-radius: var(--bs-border-radius, .375rem); }
.cms-tpl-status > div:first-child { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.cms-tpl-status h3 { margin: 0; }

/* Video (16:9) */
.cms-tpl-video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: calc(var(--bs-border-radius, .375rem) * 2); overflow: hidden; color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; }
.cms-tpl-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cms-tpl-caption { text-align: center; font-style: italic; color: var(--bs-secondary-color, #6c757d); margin-top: .5rem; }

/* Photo grid */
.cms-tpl-gallery { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.cms-tpl-gallery--3 { grid-template-columns: repeat(3, 1fr); }
.cms-tpl-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
@media (max-width: 575.98px) { .cms-tpl-gallery--3 { grid-template-columns: 1fr 1fr; } }

/* Address */
.cms-tpl-address { background: var(--bs-tertiary-bg, #f8f9fa); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: var(--bs-border-radius, .375rem); padding: 1.25rem; }
.cms-tpl-address h4 { margin-top: 0; }
.cms-tpl-address p { margin: .2rem 0; }
.cms-tpl-address .cms-tpl-button { margin-top: .75rem; }
