/* ==========================================================================
   wm-post-app — dedicated mobile UI for single posts (PWA reading mode)
   Desktop: inert — original blog layout unchanged above 768px
   ========================================================================== */

@media (min-width: 768px) {
    .wm-post-app {
        display: none !important;
    }
}

@media (max-width: 767.98px) {
    :root {
        --wm-post-app-bg: var(--wm-brand-bg, #f7f6fe);
        --wm-post-app-surface: var(--wm-brand-surface, #ffffff);
        --wm-post-app-ink: var(--wm-brand-ink, #1e242b);
        --wm-post-app-muted: var(--wm-brand-muted, #6b6578);
        --wm-post-app-accent: var(--wm-brand-primary, #5546c9);
        --wm-post-app-pill: var(--wm-brand-pill, #eeebfc);
        --wm-post-app-line: var(--wm-brand-border, rgba(85, 70, 201, 0.12));
        --wm-post-app-shadow: var(--wm-brand-shadow, 0 22px 56px rgba(60, 49, 140, 0.08));
        --wm-post-app-radius: 22px;
        --wm-post-app-gutter: 18px;
    }

    body.wm-post-app-active,
    body.wm-single-app-view,
    body.single-post {
        background: var(--wm-post-app-bg) !important;
    }

    body.wm-post-app-active .app,
    body.wm-post-app-active #primary,
    body.wm-post-app-active .site-main.wm-single-post {
        padding-inline: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    body.wm-post-app-active .site-main.wm-single-post {
        padding-bottom: calc(72px + var(--wm-safe-bottom, 0px)) !important;
    }

    body.wm-post-app-active .wm-single-post__article {
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        margin: 0;
        overflow: visible;
    }

    body.wm-post-app-active .wm-single-app__body {
        padding: 0 !important;
    }

    /* Hide Elementor scatter once app shell is built */
    body.wm-post-app-active .wm-single-app__hero[hidden],
    body.wm-post-app-active .wm-blog-breadcrumb[hidden],
    body.wm-post-app-active .wm-blog-sidebar {
        display: none !important;
    }

    body.wm-post-app-active .wm-single-app__body > .elementor.elementor-location-single:not(:has(.wm-post-app)),
    body.wm-post-app-active .wm-single-app__body > .elementor:not(:has(.wm-post-app)),
    body.wm-post-app-active .elementor-location-single > .e-con:not(:has(.wm-post-app)),
    body.wm-post-app-active .wm-blog-page--section:has([hidden]),
    body.wm-post-app-active .wm-blog-header[hidden],
    body.wm-post-app-active .wm-blog-hero[hidden],
        display: none !important;
    }

    body.wm-post-app-active .elementor-widget:empty,
    body.wm-post-app-active .elementor-widget-container:empty {
        display: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ── App shell ── */
    .wm-post-app {
        display: flex;
        flex-direction: column;
        background: var(--wm-post-app-surface);
        border-radius: var(--wm-post-app-radius) var(--wm-post-app-radius) 0 0;
        margin-top: 6px;
        box-shadow: var(--wm-post-app-shadow);
        overflow: hidden;
        min-height: calc(100dvh - 56px - 72px - var(--wm-safe-top, 0px));
    }

    /* ── Top bar (in-app back) ── */
    .wm-post-app__topbar {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px var(--wm-post-app-gutter);
        background: var(--wm-post-app-surface);
        border-bottom: 1px solid var(--wm-post-app-line);
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .wm-post-app__back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 10px 6px 6px;
        border-radius: 999px;
        background: var(--wm-post-app-pill);
        color: var(--wm-post-app-accent);
        text-decoration: none;
        font-size: 0.82rem;
        font-weight: 700;
        line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }

    .wm-post-app__back-icon {
        font-size: 1.05rem;
        line-height: 1;
    }

    /* ── Cover media ── */
    .wm-post-app__cover {
        margin: 0;
        background: #0f0f14;
        overflow: hidden;
    }

    .wm-post-app__cover .wm-blog-hero__figure,
    .wm-post-app__cover .wm-blog-article-intro__media,
    .wm-post-app__cover .entry-thumbnail {
        margin: 0;
        border: 0;
        border-radius: 0;
        width: 100%;
    }

    .wm-post-app__cover .wm-blog-hero__ratio {
        aspect-ratio: 16 / 9;
        width: 100%;
    }

    .wm-post-app__cover img,
    .wm-post-app__cover .wm-blog-hero__thumb,
    .wm-post-app__cover .wm-single-app__thumb {
        width: 100%;
        height: auto;
        display: block;
        object-fit: cover;
        max-height: 52vw;
    }

    /* ── Hero (title + meta) ── */
    .wm-post-app__hero {
        padding: 16px var(--wm-post-app-gutter) 12px;
        background: var(--wm-post-app-surface);
    }

    .wm-post-app__title,
    .wm-post-app__hero .wm-blog-header__title,
    .wm-post-app__hero .wm-blog-hero__title,
    .wm-post-app__hero .entry-title {
        margin: 0 0 12px !important;
        padding: 0 !important;
        font-size: clamp(1.22rem, 5.8vw, 1.55rem) !important;
        font-weight: 800 !important;
        line-height: 1.48 !important;
        letter-spacing: -0.02em !important;
        color: var(--wm-post-app-ink) !important;
        text-align: start !important;
        word-break: break-word;
    }

    .wm-post-app__meta,
    .wm-post-app__hero .wm-blog-header__meta,
    .wm-post-app__hero .wm-blog-hero__meta,
    .wm-post-app__hero .entry-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 10px;
        margin: 0;
        padding: 0;
        font-size: 0.75rem;
        color: var(--wm-post-app-muted);
        line-height: 1.4;
    }

    .wm-post-app__meta .wm-blog-meta-chip,
    .wm-post-app__hero .wm-blog-meta-chip {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 5px 9px;
        margin: 0;
        background: var(--wm-post-app-pill);
        border: none;
        border-radius: 999px;
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--wm-post-app-muted);
        white-space: nowrap;
    }

    .wm-post-app__meta .wm-blog-meta-chip--accent,
    .wm-post-app__hero .wm-blog-meta-chip--accent {
        color: var(--wm-post-app-accent);
        background: rgba(85, 70, 201, 0.1);
    }

    .wm-post-app__meta .wm-blog-meta-chip i,
    .wm-post-app__hero .wm-blog-meta-chip i {
        font-size: 0.68rem;
        color: var(--wm-post-app-accent);
        opacity: 0.85;
    }

    .wm-post-app__meta .wm-blog-meta-chip__avatar {
        width: 22px;
        height: 22px;
    }

    /* ── Reading content ── */
    .wm-post-app__content,
    .wm-post-app__content.wm-blog-prose {
        padding: 6px var(--wm-post-app-gutter) 28px !important;
        margin: 0 !important;
        background: var(--wm-post-app-surface);
        font-size: 1rem;
        line-height: 1.9;
        color: var(--wm-post-app-ink);
    }

    .wm-post-app__content > *:first-child {
        margin-top: 0;
    }

    .wm-post-app__content p {
        margin: 0 0 1.1em;
    }

    .wm-post-app__content h2,
    .wm-post-app__content h3,
    .wm-post-app__content h4 {
        font-size: 1.08rem;
        font-weight: 800;
        line-height: 1.45;
        margin: 1.6em 0 0.6em;
        padding-inline-start: 11px;
        border-inline-start: 3px solid var(--wm-post-app-accent);
        color: var(--wm-post-app-ink);
    }

    .wm-post-app__content ul,
    .wm-post-app__content ol {
        padding-inline-start: 1.25em;
        margin: 0 0 1.1em;
    }

    .wm-post-app__content li {
        margin-bottom: 0.45em;
    }

    .wm-post-app__content a {
        color: var(--wm-post-app-accent);
        text-decoration: underline;
        text-underline-offset: 2px;
    }

    .wm-post-app__content img,
    .wm-post-app__content figure {
        max-width: 100%;
        height: auto;
        border-radius: 14px;
        margin: 1.1em 0;
    }

    .wm-post-app__content iframe,
    .wm-post-app__content video {
        max-width: 100%;
        width: 100%;
        border: 0;
        border-radius: 14px;
        aspect-ratio: 16 / 9;
    }

    .wm-post-app__content blockquote {
        margin: 1.2em 0;
        padding: 14px 16px;
        background: var(--wm-post-app-pill);
        border-inline-start: 3px solid var(--wm-post-app-accent);
        border-radius: 0 12px 12px 0;
        font-size: 0.92rem;
        color: var(--wm-post-app-muted);
    }

    .wm-post-app__content table {
        display: table;
        width: max-content;
        min-width: 100%;
        overflow-x: visible;
        font-size: 0.84rem;
        border-collapse: collapse;
    }

    .wm-post-app__content .wm-blog-table-scroll,
    .wm-post-app__content .wm-blog-compare__scroll,
    .wm-post-app__content figure.wp-block-table,
    .wm-post-app__content figure:has(> table) {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        touch-action: pan-x;
    }

    .wm-post-app__content pre,
    .wm-post-app__content code {
        font-size: 0.84rem;
        border-radius: 8px;
    }

    /* ── Bottom sections (related, author, comments) ── */
    .wm-post-app__sections,
    .wm-post-app__comments {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 4px 12px 20px;
        background: var(--wm-post-app-bg);
    }

    .wm-post-app__sections .wm-blog-block,
    .wm-post-app__comments {
        margin: 0 !important;
        padding: 18px 16px !important;
        background: var(--wm-post-app-surface) !important;
        border-radius: 16px !important;
        border: none !important;
        box-shadow: 0 4px 20px rgba(55, 43, 125, 0.06) !important;
    }

    .wm-post-app__sections .wm-blog-section-title,
    .wm-post-app__comments .wm-blog-comments__title {
        font-size: 1rem;
        font-weight: 800;
        margin: 0 0 14px;
        color: var(--wm-post-app-ink);
    }

    .wm-post-app__sections .wm-blog-related__grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .wm-post-app__sections .wm-blog-related__card {
        border-radius: 14px;
        overflow: hidden;
        border: 1px solid var(--wm-post-app-line);
    }

    .wm-post-app__sections .wm-blog-author__card {
        flex-direction: row;
        align-items: flex-start;
        text-align: start;
        gap: 14px;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    .wm-post-app__sections .wm-blog-author__avatar {
        width: 52px;
        height: 52px;
        flex-shrink: 0;
    }

    .wm-post-app__sections .wm-blog-callout,
    .wm-post-app__sections .wm-blog-highlight,
    .wm-post-app__sections .wm-blog-compare,
    .wm-post-app__sections .wm-blog-promo,
    .wm-post-app__sections .wm-blog-process {
        border-radius: 12px;
    }

    .wm-post-app__sections .wm-blog-compare__scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* In-content blocks inside prose */
    .wm-post-app__content .wm-blog-block {
        margin: 1.4em 0 !important;
        padding: 16px !important;
        background: var(--wm-post-app-pill) !important;
        border-radius: 14px !important;
        border: 1px solid var(--wm-post-app-line) !important;
        box-shadow: none !important;
    }

    /* Elementor wrappers inside mount — collapse spacing */
    body.wm-post-app-active .wm-blog-page,
    body.wm-post-app-active .wm-blog-page--section {
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.wm-post-app-active .elementor-widget-wrap,
    body.wm-post-app-active .elementor-widget-container {
        padding: 0 !important;
    }

    body.wm-post-app-active .elementor-element[hidden],
    body.wm-post-app-active .elementor-widget[hidden] {
        display: none !important;
    }

    /* Hide sidebar only on mobile app view */
    body.wm-single-app-view.wm-post-app-active .wm-blog-sidebar {
        display: none !important;
    }
}

@media (display-mode: standalone) and (max-width: 767.98px) {
    body.wm-post-app-active .site-main.wm-single-post {
        padding-bottom: calc(80px + var(--wm-safe-bottom, 0px)) !important;
    }

    .wm-post-app {
        min-height: calc(100dvh - 56px - 80px - var(--wm-safe-top, 0px));
    }
}
