/* Shared legacy content rules; no page ID, slug or home-page overrides. */
.post_body {
    --koiniwa-space-text: 16px;
    --koiniwa-space-block: 32px;
    font-family: sans-serif;
    line-height: 1.8;
}

.post_body p {
    margin-top: 0;
    margin-bottom: var(--koiniwa-space-text);
}
.post_body small, .post_body .small { font-size: 80%; }
.post_body :is(h1, h2, h3) { margin-top: 0; }
.post_body h3 { margin-bottom: var(--koiniwa-space-text); }
.post_body :is(h4, h5, h6) { font-weight: 700; }
.post_body h2:not(.maker-animation):not([class*="is-style-"]) { padding: 1rem 0 calc(1rem - 3px); }
.post_body h2:not(.maker-animation):not([class*="is-style-"])::after { content: none; }
.post_body .list-title { margin-top: .5em; margin-bottom: var(--koiniwa-space-text); }
.post_body :is(.wp-block-cover__inner-container, .wp-block-group__inner-container, .wp-block-column) > * {
    margin-block-start: 0;
}
.post_body .wp-block-cover {
    margin-top: 0;
    margin-bottom: var(--koiniwa-space-block);
    height: 100%;
}
.post_body .wp-block-cover > .wp-block-cover__inner-container { width: calc(100% - 70px); }
.post_body .wp-block-columns { margin-bottom: var(--koiniwa-space-block); }
.post_body .wp-block-column { margin-bottom: 0; }
.post_body figure.wp-block-image { margin-bottom: var(--koiniwa-space-text); }

/* Contain absolute WordPress embeds without clipping the page or visible content. */
.post_body .wp-block-embed__wrapper:has(> iframe.wp-embedded-content) {
    position: relative;
}
.post_body iframe.wp-embedded-content { max-width: 100%; }

/* Legacy covers keep their background on the container itself. */
.post_body .wp-block-cover[style*="background-image"]:not(.has-parallax):not(:has(> .wp-block-cover__image-background, > .wp-block-cover__video-background)) {
    background-size: cover;
}

/* Match the original desktop spacing without restoring legacy column margins. */
@media (min-width: 782px) {
    .post_body .wp-block-columns:not([style*="gap"]) {
        gap: 32px;
    }
}

/* Explicit legacy palette classes must override the cover's inherited white. */
.has-koiniwa-dark-gray-color {
    color: #6d6d6d !important;
}

.has-koiniwa-black-color {
    color: #3b4546 !important;
}

.has-koiniwa-light-gray-color {
    color: #ebebeb !important;
}

/* Complete the original site palette used by existing article classes. */
.has-koiniwa-red-color { color: #de1d61 !important; }
.has-koiniwa-orange-color { color: #e9981a !important; }
.has-koiniwa-light-blue-color { color: #85d0d2 !important; }
.has-koiniwa-gray-color { color: #bdbdbd !important; }
.has-koiniwa-title-gray-color { color: #d7d1c9 !important; }
.has-koiniwa-light-sky-color { color: #cdedee !important; }

.has-koiniwa-red-background-color { background-color: #de1d61 !important; }
.has-koiniwa-dark-background-gray-color,
.has-koiniwa-dark-gray-background-color { background-color: #6d6d6d !important; }
.has-koiniwa-black-background-color { background-color: #3b4546 !important; }
.has-koiniwa-orange-background-color { background-color: #e9981a !important; }
.has-koiniwa-light-blue-background-color { background-color: #85d0d2 !important; }
.has-koiniwa-gray-background-color { background-color: #bdbdbd !important; }
.has-koiniwa-title-gray-background-color { background-color: #d7d1c9 !important; }
.has-koiniwa-light-gray-background-color { background-color: #ebebeb !important; }
.has-koiniwa-light-sky-background-color { background-color: #cdedee !important; }

/* Restore the configured brand color instead of the block preset's default blue. */
.has-liquid-theme-color {
    color: var(--main-color, #48a8ab) !important;
}
.has-liquid-theme-background-color {
    background-color: var(--main-color, #48a8ab) !important;
}

/* Shortcode-generated download columns do not have the modern layout class. */
@media (min-width: 782px) {
    .post_body .wp-block-columns:not(.is-layout-flex):has(> .wp-block-column a[href*="koiniwa.onelink.me/"]) {
        display: flex;
        gap: 32px;
        align-items: center;
    }
    .post_body .wp-block-columns:not(.is-layout-flex):has(> .wp-block-column a[href*="koiniwa.onelink.me/"]) > .wp-block-column {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* Preserve the original LP content gutter without changing navigation or footer. */
.post_body > .container {
    padding-right: 15px;
    padding-left: 15px;
}

/* Match wide blocks to the legacy 15px content gutter, not the new 1rem gutter. */
.post_body .alignwide {
    width: calc(100% + 30px);
    max-width: calc(100% + 30px);
    left: -15px;
}

/* These marker headings existed before the new theme's larger heading spacing. */
.post_body .maker-animation {
    margin-top: 0;
    margin-bottom: var(--koiniwa-space-text);
}

/* Only restore the old wrapper/figure structure, not modern figure-only blocks. */
.post_body div.wp-block-image,
.post_body div.wp-block-image > figure {
    margin-bottom: 1rem;
}

/* Legacy raw text and lists inherit the same rhythm as paragraphs. */
.post_body {
    line-height: 1.8;
}

.post_body p:not([style*="line-height"]) {
    line-height: 1.8;
}

/* Restore the shared legacy medium preset across all article templates. */
.post_body .has-medium-font-size:not([style*="font-size"]) {
    font-size: 20px !important;
}

/* Remove trailing space without collapsing gaps between multiple paragraphs. */
.post_body .liquid-speech-balloon-text > p:last-of-type {
    margin-bottom: 0 !important;
}

/* Preserve the legacy gap after speech balloons inside modern flow layouts. */
.post_body .liquid-speech-balloon-wrap {
    margin-bottom: var(--koiniwa-space-block);
}

/* Keep list thumbnails at their legacy scale, including narrow screens. */
.post_body .list-block .post_thumb {
    background-size: 100% auto;
}

/* Restore the shared legacy large preset without replacing explicit sizes. */
.post_body .has-large-font-size:not([style*="font-size"]) {
    font-size: 36px !important;
}

/* Match the original heading box without adding its old span wrapper. */
.post_body .maker-animation {
    padding: 1rem 0 calc(1rem - 3px);
    background-image: linear-gradient(to right, #85d0d2 50%, transparent 50%);
    background-repeat: no-repeat;
    background-size: 200% .5em;
    background-position: 0% 2em;
}

.post_body h2.maker-animation::after {
    content: none;
}

@media (max-width: 781.98px) {
    .post_body .wp-block-columns:not([style*="gap"]) { row-gap: 0; }
}

/* Motion is enabled only after the shared scroll handler is initialized. */
body.koiniwa-motion-ready .post_body .js-markerScrollAnimation {
    background-position: 100% 2em;
    transition: none;
}

body.koiniwa-motion-ready .post_body .js-markerScrollAnimation.is-active {
    background-position: 0% 2em;
    transition: background-position 2s;
}

body.koiniwa-motion-ready .post_body .huwa:not(.huwa_active),
body.koiniwa-motion-ready .post_body .huwa:not(.huwa_active) > li,
body.koiniwa-motion-ready .post_body .huwa:not(.huwa_active) > .wp-block-column {
    opacity: .1;
    /* Do not fade out when initialization restores the legacy hidden state. */
    transition: none;
}

body.koiniwa-motion-ready .post_body .huwa_active,
body.koiniwa-motion-ready .post_body .huwa_active > li,
body.koiniwa-motion-ready .post_body .huwa_active > .wp-block-column {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .post_body .js-markerScrollAnimation {
        background-position: 0% 2em !important;
        transition: none !important;
    }

    /* Override the parent theme's important active transform as well. */
    .post_body .huwa,
    .post_body .huwa > li,
    .post_body .huwa > .wp-block-column {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}
