/**
 * Mobile design v2 — "Sunday Morning" homepage, dark bottom button bar and a
 * grouped slide-up menu. Loaded only when the design is switched on
 * (body.ec-m2) and only takes effect below 768px; desktop is untouched.
 */

.m2-header, .m2-home, .m2-footer, .m2-menu, .m2-bar { display: none; }

@media screen and (max-width: 768px) {

    .ec-m2 {
        --m2-bg: #F5F3EC;
        --m2-card: #FFFFFF;
        --m2-ink: #141414;
        --m2-body: #4A4744;
        --m2-muted: #5E5A55;
        --m2-line: #E6E1D6;
        --m2-line-soft: #EEEAE0;
        --m2-accent: #B0061F;
        --m2-accent-ink: #8E0418;
        --m2-dark: #121215;
        --m2-bar-h: 76px;
        --m2-display: 'Phudu', 'Instrument Sans', sans-serif;
        --m2-sans: 'Instrument Sans', system-ui, sans-serif;
        padding-bottom: calc(var(--m2-bar-h) + env(safe-area-inset-bottom));
    }

    /* Original mobile chrome is replaced. */
    .ec-m2 .ec-header,
    .ec-m2 .ec-menu-toggle,
    .ec-m2 .ec-footer,
    .ec-m2 .ec-desktop-home { display: none !important; }

    /* Inner pages: the new header sits in the page flow, so the old fixed-header gap goes. */
    .ec-m2 .ec-page-header { padding-top: 0; min-height: 260px; margin-bottom: 2.5rem; }

    .ec-m2 .m2-header, .ec-m2 .m2-home, .ec-m2 .m2-footer, .ec-m2 .m2-bar { display: flex; }
    .ec-m2 .m2-menu:not([hidden]) { display: flex; }

    .ec-m2 .m2-header *, .ec-m2 .m2-home *, .ec-m2 .m2-footer *, .ec-m2 .m2-menu *, .ec-m2 .m2-bar * { box-sizing: border-box; }

    /* ---------- Buttons ---------- */
    .ec-m2 .m2-btn {
        flex: 1; min-height: 52px; padding: 0 18px; border-radius: 14px;
        display: flex; align-items: center; justify-content: center;
        font: 700 16px/1.2 var(--m2-sans); text-decoration: none;
    }
    .ec-m2 .m2-btn-primary { background: var(--m2-accent); color: #fff; }
    .ec-m2 .m2-btn-ghost { border: 1px solid rgba(245, 243, 236, 0.35); color: #F5F3EC; }
    .ec-m2 .m2-round-btn {
        width: 44px; height: 44px; flex-shrink: 0; padding: 0; border-radius: 50%;
        border: 1px solid #D9D3C5; background: #fff; color: var(--m2-ink);
        display: flex; align-items: center; justify-content: center; cursor: pointer;
    }
    .ec-m2 .m2-btn:focus-visible, .ec-m2 .m2-round-btn:focus-visible, .ec-m2 .m2-tab:focus-visible,
    .ec-m2 .m2-menu a:focus-visible, .ec-m2 .m2-quick-item:focus-visible {
        outline: 3px solid var(--m2-accent); outline-offset: 2px;
    }

    /* ---------- Header ---------- */
    .ec-m2 .m2-header {
        position: sticky; top: 0; z-index: 900; height: 72px; padding: 0 16px;
        align-items: center; justify-content: space-between; gap: 12px;
        background: #fff; border-bottom: 1px solid var(--m2-line);
    }
    .ec-m2 .m2-brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--m2-ink); }
    .ec-m2 .m2-brand-logo { width: 52px; height: 52px; object-fit: contain; flex-shrink: 0; }
    .ec-m2 .m2-brand-name {
        font: 800 17px/1 var(--m2-display); text-transform: uppercase; color: var(--m2-ink);
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 9.5em;
    }
    .ec-m2 .m2-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .ec-m2 .m2-visit {
        height: 44px; padding: 0 16px; border-radius: 999px; background: var(--m2-accent); color: #fff;
        display: flex; align-items: center; font: 700 14px var(--m2-sans); text-decoration: none;
    }

    /* ---------- Homepage ---------- */
    .ec-m2 .m2-home {
        flex-direction: column; background: var(--m2-bg); color: var(--m2-ink);
        font-family: var(--m2-sans); padding-bottom: 36px;
    }
    .ec-m2 .m2-eyebrow {
        font: 700 13px/1.3 var(--m2-sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--m2-accent-ink);
    }
    .ec-m2 .m2-intro { display: flex; flex-direction: column; gap: 14px; padding: 28px 16px 0; }
    .ec-m2 .m2-title {
        margin: 0; font: 800 clamp(36px, 11.5vw, 46px)/0.96 var(--m2-display); text-transform: uppercase;
        color: var(--m2-ink); letter-spacing: 0; overflow-wrap: anywhere;
    }
    .ec-m2 .m2-lead { margin: 0; font-size: 17px; line-height: 1.55; color: var(--m2-body); }

    .ec-m2 .m2-photo { position: relative; padding: 22px 16px 0; margin-bottom: 64px; }
    .ec-m2 .m2-photo > img {
        width: 100%; height: 380px; object-fit: cover; object-position: center 20%;
        border-radius: 28px; display: block;
    }
    .ec-m2 .m2-next {
        position: absolute; left: 32px; right: 32px; bottom: -44px; padding: 16px 16px 16px 18px;
        border-radius: 20px; background: var(--m2-ink); color: #F5F3EC;
        display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 30px rgba(20, 20, 20, 0.18);
    }
    .ec-m2 .m2-next-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
    .ec-m2 .m2-next-label { font: 700 12px var(--m2-sans); letter-spacing: 0.14em; text-transform: uppercase; color: #FF8A96; }
    .ec-m2 .m2-next-name { font: 700 17px/1.25 var(--m2-sans); }
    .ec-m2 .m2-next-time { font-size: 14px; color: rgba(245, 243, 236, 0.78); }
    .ec-m2 .m2-next-go {
        width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; background: var(--m2-accent); color: #fff;
        display: flex; align-items: center; justify-content: center;
    }

    .ec-m2 .m2-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 16px 0; }
    .ec-m2 .m2-quick-item {
        min-height: 104px; padding: 16px; border-radius: 20px; background: var(--m2-card); border: 1px solid var(--m2-line);
        display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
        color: var(--m2-ink); text-decoration: none; font: 700 16px/1.25 var(--m2-sans);
    }
    .ec-m2 .m2-quick-item svg { color: var(--m2-accent-ink); }

    .ec-m2 .m2-section { display: flex; flex-direction: column; gap: 14px; padding: 36px 16px 0; }
    .ec-m2 .m2-h2 { margin: 0; font: 800 30px/1 var(--m2-display); text-transform: uppercase; color: var(--m2-ink); letter-spacing: 0; }
    .ec-m2 .m2-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .ec-m2 .m2-see-all { padding: 12px 0; font: 700 15px var(--m2-sans); color: var(--m2-accent-ink); text-decoration: underline; text-underline-offset: 3px; }
    .ec-m2 .m2-card { background: var(--m2-card); border: 1px solid var(--m2-line); border-radius: 20px; }

    .ec-m2 .m2-week { display: flex; flex-direction: column; }
    .ec-m2 .m2-week-row {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 16px 18px; border-bottom: 1px solid var(--m2-line-soft);
    }
    .ec-m2 .m2-week-row:last-child { border-bottom: none; }
    .ec-m2 .m2-week-name { display: flex; flex-direction: column; gap: 2px; }
    .ec-m2 .m2-week-name strong { font-size: 16px; }
    .ec-m2 .m2-week-name span { font-size: 14px; color: var(--m2-muted); }
    .ec-m2 .m2-week-time { font-weight: 700; font-size: 15px; white-space: nowrap; }

    .ec-m2 .m2-scroller {
        display: flex; gap: 12px; margin: 0 -16px; padding: 0 16px 4px;
        overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    }
    .ec-m2 .m2-scroller::-webkit-scrollbar { display: none; }
    .ec-m2 .m2-sermon {
        width: 250px; flex-shrink: 0; scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px;
        color: var(--m2-ink); text-decoration: none;
    }
    .ec-m2 .m2-sermon-thumb {
        position: relative; display: block; height: 150px; border-radius: 18px; overflow: hidden; background: #DCD6C8;
    }
    .ec-m2 .m2-sermon-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
    .ec-m2 .m2-play {
        position: absolute; right: 10px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%;
        background: var(--m2-accent); color: #fff; display: flex; align-items: center; justify-content: center;
    }
    .ec-m2 .m2-sermon-title { font: 700 16px/1.3 var(--m2-sans); }
    .ec-m2 .m2-sermon-date { font-size: 14px; color: var(--m2-muted); }

    .ec-m2 .m2-pastor {
        margin: 36px 16px 0; display: flex; overflow: hidden; border-radius: 24px; color: var(--m2-ink); text-decoration: none;
    }
    .ec-m2 .m2-pastor img { width: 130px; min-height: 200px; object-fit: cover; object-position: center 15%; flex-shrink: 0; display: block; }
    .ec-m2 .m2-pastor-text { padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
    .ec-m2 .m2-pastor-name { font: 800 21px/1.05 var(--m2-display); text-transform: uppercase; }
    .ec-m2 .m2-link { padding-top: 8px; font: 700 15px var(--m2-sans); text-decoration: underline; text-underline-offset: 3px; }

    .ec-m2 .m2-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .ec-m2 .m2-gallery a { display: block; }
    .ec-m2 .m2-gallery img { width: 100%; height: 140px; object-fit: cover; border-radius: 12px; display: block; }

    /* ---------- Footer ---------- */
    .ec-m2 .m2-footer {
        flex-direction: column; gap: 18px; padding: 30px 16px 28px; background: var(--m2-ink); color: #F5F3EC;
        font-family: var(--m2-sans);
    }
    .ec-m2 .m2-footer-title { margin: 0; font: 800 24px/1.05 var(--m2-display); text-transform: uppercase; color: #F5F3EC; }
    .ec-m2 .m2-footer-actions { display: flex; gap: 10px; }
    .ec-m2 .m2-news { display: flex; flex-direction: column; gap: 8px; }
    .ec-m2 .m2-news label { font-size: 15px; font-weight: 600; color: rgba(245, 243, 236, 0.85); }
    .ec-m2 .m2-news-row { display: flex; gap: 8px; }
    .ec-m2 .m2-news input[type="email"] {
        flex: 1; min-width: 0; height: 50px; padding: 0 14px; border-radius: 12px;
        border: 1px solid rgba(245, 243, 236, 0.25); background: rgba(245, 243, 236, 0.06); color: #F5F3EC; font: 16px var(--m2-sans);
    }
    .ec-m2 .m2-news input::placeholder { color: rgba(245, 243, 236, 0.6); }
    .ec-m2 .m2-news button {
        height: 50px; padding: 0 16px; border: none; border-radius: 12px; background: #F5F3EC; color: var(--m2-ink);
        font: 700 15px var(--m2-sans); cursor: pointer;
    }
    .ec-m2 .m2-news-note { font-size: 14px; color: #9BE3B0; }
    .ec-m2 .m2-news-error { color: #FF8A96; }
    .ec-m2 .m2-social { display: flex; gap: 10px; flex-wrap: wrap; }
    .ec-m2 .m2-social a {
        width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(245, 243, 236, 0.25);
        display: flex; align-items: center; justify-content: center; color: #F5F3EC; font-size: 17px; text-decoration: none;
    }
    .ec-m2 .m2-footer-meta { margin: 0; font-size: 14px; line-height: 1.6; color: rgba(245, 243, 236, 0.72); }

    /* ---------- Slide-up menu ---------- */
    .ec-m2 .m2-menu {
        position: fixed; left: 0; right: 0; top: 0; bottom: calc(var(--m2-bar-h) + env(safe-area-inset-bottom));
        z-index: 100000; flex-direction: column; background: var(--m2-bg); color: var(--m2-ink); font-family: var(--m2-sans);
        transform: translateY(100%); transition: transform 0.28s ease; overscroll-behavior: contain;
    }
    .ec-m2.m2-menu-open .m2-menu { transform: none; }
    .ec-m2.m2-menu-open { overflow: hidden; }
    .ec-m2 .m2-menu-head {
        height: 72px; flex-shrink: 0; padding: 0 16px; display: flex; align-items: center; justify-content: space-between;
        background: #fff; border-bottom: 1px solid var(--m2-line);
    }
    .ec-m2 .m2-menu-title { font: 800 22px var(--m2-display); text-transform: uppercase; }
    .ec-m2 .m2-menu-body { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 8px; }
    .ec-m2 .m2-menu-group {
        padding: 10px 0 0 4px; font: 700 12px var(--m2-sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--m2-accent-ink);
    }
    .ec-m2 .m2-menu-group:first-child { padding-top: 0; }
    .ec-m2 .m2-menu-list { list-style: none; margin: 0; padding: 0; border-radius: 18px; }
    .ec-m2 .m2-menu-list li { border-bottom: 1px solid var(--m2-line-soft); }
    .ec-m2 .m2-menu-list li:last-child { border-bottom: none; }
    .ec-m2 .m2-menu-list a {
        min-height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 14px;
        color: var(--m2-ink); text-decoration: none; font: 700 16px var(--m2-sans);
    }
    .ec-m2 .m2-menu-list a > svg { color: var(--m2-accent-ink); flex-shrink: 0; }
    .ec-m2 .m2-menu-list a > span:first-of-type { flex: 1; }
    .ec-m2 .m2-menu-list a.is-current { color: var(--m2-accent-ink); }
    .ec-m2 .m2-chev { color: #8A857C; display: flex; }
    .ec-m2 .m2-menu-foot { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
    .ec-m2 .m2-menu-foot .m2-btn { flex: none; }
    .ec-m2 .m2-menu-note { text-align: center; font-size: 14px; color: var(--m2-muted); }

    /* ---------- Bottom button bar ---------- */
    .ec-m2 .m2-bar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 100001;
        height: calc(var(--m2-bar-h) + env(safe-area-inset-bottom));
        padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
        display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
        background: var(--m2-dark); border-top: 1px solid rgba(243, 238, 230, 0.10);
    }
    .ec-m2 .m2-tab {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        min-height: 48px; padding: 0; border: none; background: none; cursor: pointer;
        color: #F3EEE6; text-decoration: none; font: 600 12px var(--m2-sans);
    }
    .ec-m2 .m2-tab.is-on, .ec-m2.m2-menu-open .m2-tab[data-m2-menu-open] { color: #FF6B7A; font-weight: 700; }
    .ec-m2.m2-menu-open .m2-tab.is-on { color: #F3EEE6; font-weight: 600; }
}

/* The WordPress toolbar (shown to logged-in users) is fixed from 601px up and scrolls away below that. */
@media screen and (min-width: 601px) and (max-width: 768px) {
    .ec-m2.admin-bar .m2-header { top: 46px; }
}

@media screen and (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .ec-m2 .m2-menu { transition: none; }
}
