/* CM24 additions on top of the WordPress CSS (cm24.css): blocks of the CM24 editor that the
   SmartMag theme does not know. Styled to look like their WordPress counterparts. */

/* Gallery (editor "qm-gallery") ≈ core/gallery, columns-default, is-cropped */
.post-content .qm-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 1.7em; }
.post-content .qm-gallery[data-count="2"], .post-content .qm-gallery[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
/* Slider (editor "qm-gallery--slider") = the Otter/Glide slider of WP: 400px high, one photo at a time, arrows and bullets
   (cm24-gallery.js wraps it in .qm-slider and adds them), the caption over the photo. Without JS: a swipeable strip. */
.post-content .qm-gallery--slider { display: flex; gap: 0; height: 400px; margin: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.post-content .qm-gallery--slider::-webkit-scrollbar { display: none; }
.post-content .qm-gallery--slider .qm-gallery__item { flex: 0 0 100%; height: 100%; scroll-snap-align: start; }
.post-content .qm-gallery--slider .qm-gallery__link, .post-content .qm-gallery--slider picture { height: 100%; }
.post-content .qm-gallery--slider .qm-gallery__img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; }
.post-content .qm-gallery--slider .qm-gallery__caption { position: absolute; bottom: 0; width: 100%; max-height: 100%; margin: 0; padding: 40px 10px 9px; overflow: auto; color: #fff; font-size: 16px; font-style: italic; background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.3) 70%, transparent); }
.post-content .qm-slider { position: relative; margin: 0 0 1.7em; }
.post-content .qm-slider .qm-gallery--slider { margin: 0; }
.post-content .qm-slider__arrow { position: absolute; top: 50%; z-index: 2; display: block; box-sizing: border-box; width: 42px; height: 36px; padding: 9px 12px; color: #333; line-height: 1; background: #fff; border: 0; border-radius: 4px; box-shadow: 0 0.25em 0.5em 0 rgba(0, 0, 0, 0.1); opacity: 0.75; cursor: pointer; transform: translateY(-50%); transition: opacity 150ms ease; }
.post-content .qm-slider__arrow:hover { opacity: 1; }
.post-content .qm-slider__arrow svg { display: block; fill: #333; }
.post-content .qm-slider__arrow--left { left: 2em; }
.post-content .qm-slider__arrow--right { right: 2em; }
.post-content .qm-slider__arrow--right svg { transform: rotate(180deg); }
.post-content .qm-slider__bullets { position: absolute; bottom: 2em; left: 50%; z-index: 2; display: inline-flex; transform: translateX(-50%); }
.post-content .qm-slider__bullet { width: 9px; height: 9px; margin: 0 0.25em; padding: 0; line-height: 0; background: rgba(255, 255, 255, 0.5); border: 2px solid transparent; border-radius: 50%; box-shadow: 0 0.25em 0.5em 0 rgba(0, 0, 0, 0.1); cursor: pointer; transition: all 300ms ease-in-out; }
.post-content .qm-slider__bullet:hover, .post-content .qm-slider__bullet:focus { border-color: #fff; outline: none; }
.post-content .qm-slider__bullet.is-active { background: #fff; }
.post-content .qm-gallery__item { margin: 0; position: relative; display: flex; flex-direction: column; }
.post-content .qm-gallery__link, .post-content .qm-gallery picture { display: block; height: 100%; }
.post-content .qm-gallery__img { display: block; width: 100%; height: 100%; object-fit: cover; }
.post-content .qm-gallery__caption { font-size: 13px; font-style: italic; color: var(--c-contrast-450, #7d7d7d); text-align: center; margin-top: 6px; }
/* A phone: two photos in a row, the odd last one over the full width, as the WP gallery */
@media (max-width: 599px) {
	.post-content .qm-gallery:not(.qm-gallery--slider) { grid-template-columns: repeat(2, 1fr); }
	.post-content .qm-gallery:not(.qm-gallery--slider) .qm-gallery__item:last-of-type:nth-child(odd) { grid-column: 1 / -1; }
}
/* Photo captions of a grid gallery: as the WP gallery - hidden, shown over the bottom of the photo on hover (a tap on a phone) */
.post-content .qm-gallery--grid .qm-gallery__caption { position: absolute; right: 0; bottom: 0; left: 0; margin: 0; padding: 13px; font-size: 13px; line-height: 1.7; color: #fff; background: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0)); visibility: hidden; opacity: 0; transition: opacity 0.3s ease-in, visibility 0.3s ease-in; pointer-events: none; }
.post-content .qm-gallery--grid .qm-gallery__item:hover .qm-gallery__caption, .post-content .qm-gallery--grid .qm-gallery__item:focus-within .qm-gallery__caption { visibility: visible; opacity: 1; }
/* The caption of the whole gallery (WP gallery block caption), under the photos */
/* Links in a photo caption (CM24-68): the colour of the caption, underlined; clickable although the hover caption ignores the pointer */
.post-content .qm-gallery__caption a, .post-content .qm-gallery__note a { color: inherit; text-decoration: underline; pointer-events: auto; }
.post-content .qm-gallery__note { grid-column: 1 / -1; margin: 5px 0 0; padding: 0 0 2px; font-size: 0.767em; line-height: 1.7; font-style: italic; color: var(--c-contrast-450, #7d7d7d); text-align: center; }
.post-content .qm-gallery--slider .qm-gallery__note { display: none; }

/* Columns (WP core/columns): photos side by side, stacked below 782px as the WP block does */
.post-content .qm-columns { display: flex; flex-wrap: nowrap; gap: 1.54em 2em; margin: 0 0 1.54em; }
.post-content .qm-columns__col { flex: 1 1 0; min-width: 0; overflow-wrap: break-word; }
.post-content .qm-columns__col > figure, .post-content .qm-columns__col > figure:has(> picture > img.inline-picture) { margin: 0; }
.post-content .qm-columns__col > :last-child { margin-bottom: 0; }
@media (max-width: 781px) { .post-content .qm-columns { flex-wrap: wrap; } .post-content .qm-columns__col { flex-basis: 100%; } }

/* Media & Text (editor/importer "qm-media-text" = WP core/media-text): the photo at the left (or right) in 50% of the width
   (--qm-media-width), the text beside it, centred vertically; stacked (photo first) below 601px as the WP block does */
.post-content .qm-media-text { display: grid; grid-template-columns: var(--qm-media-width, 50%) 1fr; grid-template-rows: auto; align-items: center; margin: calc(var(--post-content-gaps) + 0.66em) auto; }
.post-content .qm-media-text--right { grid-template-columns: 1fr var(--qm-media-width, 50%); }
.post-content .qm-media-text--top { align-items: start; }
.post-content .qm-media-text--bottom { align-items: end; }
.post-content .qm-media-text__media { grid-column: 1; grid-row: 1; min-width: 0; margin: 0; }
.post-content .qm-media-text__text { grid-column: 2; grid-row: 1; min-width: 0; padding: 0 8%; word-break: break-word; }
.post-content .qm-media-text--right > .qm-media-text__media { grid-column: 2; }
.post-content .qm-media-text--right > .qm-media-text__text { grid-column: 1; }
.post-content .qm-media-text__media > figure, .post-content .qm-media-text__media > figure:has(> picture > img.inline-picture) { margin: 0; }
.post-content .qm-media-text__media img, .post-content .qm-media-text__media video { display: block; width: 100%; max-width: none; height: auto; margin: 0; }
@media (max-width: 600px) {
	.post-content .qm-media-text:not(.qm-media-text--nostack) { grid-template-columns: 100%; }
	.post-content .qm-media-text:not(.qm-media-text--nostack) > .qm-media-text__media { grid-column: 1; grid-row: 1; }
	.post-content .qm-media-text:not(.qm-media-text--nostack) > .qm-media-text__text { grid-column: 1; grid-row: 2; }
}

/* Inline photo: same caption look as WP figure captions */
.post-content figure > picture > img.inline-picture { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.post-content figure > figcaption { font-size: 0.767em; line-height: 1.7; font-style: italic; color: var(--c-contrast-450, #7d7d7d); text-align: center; margin-top: 0.862em; padding-bottom: 2px; }

/* YouTube: responsive 16:9 like wp-embed-aspect-16-9 */
.post-content .youtube-block { position: relative; aspect-ratio: 16 / 9; margin: 0 0 1.7em; }
.post-content .youtube-block iframe, .post-content .youtube-block .fluid-width-video-wrapper { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0 !important; }

/* Social embeds (Instagram, Telegram, TikTok, X, Threads, Facebook) */
.post-content .frame-block { display: flex; justify-content: center; margin: 0 0 1.7em; }
.post-content .frame-block > * { max-width: 100%; }
.post-content .frame-block iframe { max-width: 100%; }

/* Smooth scrolling to anchors, as on the WP sites (it came with Elementor's CSS there) */
@media (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
}

/* CMS «Просмотр» of an unpublished post (/preview/<id>/) */
.cm24-preview-bar {
	position: sticky;
	top: 0;
	z-index: 1000;
	padding: 8px 16px;
	background: #d92b2b;
	color: #fff;
	font: 600 14px/1.4 "Open Sans", sans-serif;
	text-align: center;
}

/* «RU / KZ» in the mobile header (CM24-34; desktop uses the WP «RU ▾» menu item): only while the Kazakh version is on. Takes the colour of the row
   it sits in: white on the dark top bar, dark in the light mobile bar. The current language is underlined. */
.lang-switch { display: inline-flex; align-items: center; margin: 0 8px; font-size: 12px; font-weight: 600; line-height: 1; letter-spacing: .05em; white-space: nowrap; }
.lang-switch__item { display: inline-block; padding: 7px 6px; color: inherit; text-decoration: none; opacity: .7; border-bottom: 2px solid transparent; }
a.lang-switch__item:hover, a.lang-switch__item:focus-visible { color: inherit; opacity: 1; }
.lang-switch__item.is-current { opacity: 1; border-bottom-color: currentColor; }
@media (max-width: 940px) { .lang-switch { margin: 0 2px; } }
