/* ==========================================================
   Bolmic social UI — composer card, create-post sheet,
   toasts, photo viewer, refined post cards.
   Load AFTER style.css. Uses the site's colour variables.
   ========================================================== */

:root {
    --bm-shadow: 0 1px 2px rgba(31, 42, 36, .08), 0 2px 10px rgba(31, 42, 36, .05);
    --bm-radius: 16px;
    --bm-hover: rgba(47, 107, 79, .09);
}
html.bm-lock, html.cm-lock { overflow: hidden; }

.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }

/* ---------- Collapsed composer card ---------- */
.fb-composer {
    background: var(--card);
    border-radius: var(--bm-radius);
    box-shadow: var(--bm-shadow);
    padding: 12px 14px 6px;
    margin-bottom: 14px;
}
.fb-composer-top { display: flex; align-items: center; gap: 10px; }
.fb-prompt {
    flex: 1; min-width: 0;
    text-align: left;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 11px 16px;
    font-family: inherit; font-size: .95rem;
    color: var(--ink-soft);
    cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .15s;
}
.fb-prompt:hover { background: #e9e7d8; }
.fb-composer-actions {
    display: flex; margin-top: 10px; padding-top: 6px;
    border-top: 1px solid var(--line);
}
.fb-composer-actions button {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
    background: none; border: none; border-radius: 10px;
    padding: 9px 4px; margin: 2px;
    font-family: inherit; font-size: .88rem; font-weight: 600; color: var(--ink-soft);
    cursor: pointer; transition: background .15s;
}
.fb-composer-actions button:hover { background: var(--bm-hover); }
.fb-composer-actions .ci { font-size: 1.25rem; line-height: 1; }

/* ---------- Create-post sheet ---------- */
.cm-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(20, 30, 25, .55);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; transition: opacity .18s ease;
}
.cm-overlay[hidden] { display: none; }
.cm-overlay.open { opacity: 1; }
.cm-sheet {
    position: relative;
    background: var(--card);
    width: 100%; max-width: 560px;
    max-height: 94vh; max-height: 94dvh;
    border-radius: 20px 20px 0 0;
    display: flex; flex-direction: column;
    transform: translateY(24px); transition: transform .2s ease;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
}
.cm-overlay.open .cm-sheet { transform: none; }
.cm-sheet.drag::after {
    content: "Drop to add"; position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    background: rgba(47, 107, 79, .88); color: #fff;
    font-weight: 700; font-size: 1.2rem; border-radius: inherit;
}
.cm-sheet.busy .cm-body, .cm-sheet.busy .cm-add { opacity: .6; pointer-events: none; }
@media (min-width: 640px) {
    .cm-overlay { align-items: center; }
    .cm-sheet { border-radius: 18px; max-height: 88vh; transform: translateY(10px) scale(.98); }
    .cm-overlay.open .cm-sheet { transform: none; }
}

.cm-head {
    position: relative; text-align: center;
    padding: 14px 52px; border-bottom: 1px solid var(--line);
}
.cm-head h2 { margin: 0; font-size: 1.08rem; font-weight: 700; }
.cm-x {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border-radius: 50%;
    border: none; background: #ecebe0; color: var(--ink-soft);
    font-size: .95rem; cursor: pointer;
}
.cm-x:hover { background: #dedccd; }

.cm-body { padding: 14px 16px 6px; overflow-y: auto; flex: 1; }
.cm-who { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cm-who b { display: block; font-size: .95rem; }
.cm-chip-wrap { position: relative; margin-top: 2px; }
.cm-chip {
    background: #ecebe0; border: none; border-radius: 8px;
    padding: 3px 10px; font-family: inherit; font-size: .76rem; font-weight: 600;
    color: var(--ink); cursor: pointer;
}
.cm-pop {
    position: absolute; top: 30px; left: 0; z-index: 8; min-width: 250px;
    background: var(--card); border-radius: 12px; padding: 6px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, .22); border: 1px solid var(--line);
}
.cm-pop[hidden] { display: none; }
.cm-pop-item {
    display: block; width: 100%; text-align: left;
    background: none; border: none; border-radius: 8px; padding: 10px 12px;
    font-family: inherit; font-size: .88rem; cursor: pointer; color: var(--ink);
}
.cm-pop-item:hover { background: var(--bm-hover); }
.cm-pop-item.on { background: var(--bm-hover); color: var(--jol-green-dark); font-weight: 700; }

.cm-text {
    width: 100%; min-height: 96px; border: none; outline: none; resize: none;
    font-family: inherit; font-size: 1.18rem; line-height: 1.45;
    color: var(--ink); background: transparent; padding: 4px 0;
}
.cm-text::placeholder { color: #9aa39d; }
.cm-count { text-align: right; font-size: .75rem; color: var(--kadam-gold); font-weight: 600; }

.cm-media {
    position: relative; margin: 8px 0;
    border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #111;
}
.cm-media[hidden] { display: none; }
.cm-media-view img, .cm-media-view video { display: block; width: 100%; max-height: 46vh; object-fit: contain; background: #111; }
.cm-optimising { padding: 36px 12px; text-align: center; color: #cfd6d1; font-size: .88rem; }
.cm-media-info { background: var(--paper); padding: 6px 12px; font-size: .74rem; color: var(--ink-soft); }
.cm-media-x {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    width: 32px; height: 32px; border-radius: 50%;
    border: none; background: rgba(255, 255, 255, .92); color: #222;
    font-size: .9rem; cursor: pointer; box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
}
.cm-drop {
    margin: 8px 0; padding: 18px 12px; text-align: center; cursor: pointer;
    border: 2px dashed #cfcdbd; border-radius: 14px;
    color: var(--ink-soft); font-size: .86rem; transition: border-color .15s, background .15s;
}
.cm-drop[hidden] { display: none; }
.cm-drop:hover { border-color: var(--jol-green); background: var(--bm-hover); }
.cm-drop span { font-size: 1.3rem; vertical-align: middle; }

.cm-notice {
    margin: 8px 0; padding: 9px 12px; border-radius: 10px;
    background: #fbebea; color: #8f2a20; font-size: .85rem;
}
.cm-notice.info { background: #e8f3ec; color: var(--jol-green-dark); }
.cm-notice[hidden] { display: none; }

.cm-progress { margin: 10px 0 4px; }
.cm-progress[hidden] { display: none; }
.cm-bar { height: 8px; background: #e3e1d2; border-radius: 6px; overflow: hidden; }
.cm-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--jol-green), #4f9b76); transition: width .15s linear; }
.cm-progress-row { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; font-size: .78rem; color: var(--ink-soft); }
.cm-cancel { background: none; border: none; color: var(--sindoor); font-family: inherit; font-weight: 600; font-size: .78rem; cursor: pointer; }

.cm-add {
    display: flex; align-items: center; justify-content: space-between;
    margin: 6px 16px 0; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 12px; font-size: .88rem; font-weight: 600;
}
.cm-add-btns { display: flex; gap: 4px; }
.cm-add-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none; background: none;
    font-size: 1.35rem; cursor: pointer; transition: background .15s;
}
.cm-add-btn:hover { background: var(--bm-hover); }

.cm-foot { padding: 12px 16px 14px; }
.cm-post {
    width: 100%; border: none; border-radius: 12px; padding: 13px;
    background: var(--jol-green); color: #fff;
    font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: background .15s, opacity .15s;
}
.cm-post:hover:not(:disabled) { background: var(--jol-green-dark); }
.cm-post:disabled { background: #d8d6c8; color: #8d9189; cursor: not-allowed; }

/* ---------- Toast ---------- */
.bm-toast {
    position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 1200;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    max-width: min(92vw, 440px);
    background: #1f2a24; color: #fff; padding: 11px 18px; border-radius: 24px;
    font-size: .9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
    transition: opacity .2s, transform .2s;
}
.bm-toast.show { opacity: 1; transform: translate(-50%, 0); }
.bm-toast.info { background: var(--nilkantha); }
.bm-toast.error { background: var(--sindoor); }

/* ---------- Photo viewer ---------- */
.bm-viewer {
    position: fixed; inset: 0; z-index: 1100; display: none;
    align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .92);
}
.bm-viewer.open { display: flex; }
.bm-viewer img { max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain; }
.bm-viewer-x {
    position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px;
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: rgba(255, 255, 255, .18); color: #fff; font-size: 1.1rem; cursor: pointer;
}

/* ---------- Refined post cards ---------- */
.post {
    border: none;
    border-radius: var(--bm-radius);
    box-shadow: var(--bm-shadow);
    padding: 14px 14px 6px;
    margin-bottom: 14px;
}
.post .avatar { width: 42px; height: 42px; font-size: .95rem; }
.post-name { font-size: .96rem; }
.post-time { font-size: .76rem; margin-top: 1px; }
.post-more {
    width: 34px; height: 34px; border-radius: 50%; font-size: 1.2rem; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.post-more:hover { background: var(--bm-hover); }
.post-body { font-size: 1rem; line-height: 1.55; margin: 10px 0 8px; }
.post-body.big { font-size: 1.45rem; line-height: 1.35; font-weight: 500; padding: 14px 2px 10px; }

/* media runs edge to edge inside the card */
.post-media { margin: 8px -14px 0; background: #111; }
.post-media .post-image {
    width: 100%; margin: 0; border-radius: 0; display: block;
    max-height: 640px; object-fit: cover; cursor: zoom-in; background: #111;
}
.post-media video.post-image { object-fit: contain; cursor: auto; max-height: 560px; }

.post-actions { border-top: 1px solid var(--line); margin-top: 10px; padding: 3px 0 4px; gap: 2px; }
.action-btn {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    font-weight: 600; font-size: .86rem; padding: 9px 4px; border-radius: 10px;
    transition: background .15s, color .15s;
}
.action-btn:hover { background: var(--bm-hover); }
.action-btn .ico { flex-shrink: 0; }
.action-btn.active { color: var(--sindoor); }
.action-btn.active .ico-heart path { fill: currentColor; }
.action-btn:active .ico { transform: scale(1.25); transition: transform .12s; }

@media (prefers-reduced-motion: reduce) {
    .cm-overlay, .cm-sheet, .bm-toast, .cm-bar i { transition: none; }
}


/* ---------- Like state + counts ---------- */
.post-stats {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .8rem; color: var(--ink-soft); padding: 9px 2px 0;
}
.post-stats[hidden], .post-stats [hidden] { display: none; }
.stat-likes { display: inline-flex; align-items: center; gap: 5px; }
.stat-likes .stat-heart { color: var(--sindoor); font-size: .95rem; line-height: 1; }
.stat-comments { background: none; border: none; font: inherit; color: inherit; cursor: pointer; padding: 0; margin-left: auto; }
.stat-comments:hover { text-decoration: underline; }
.like-btn.active .like-label { font-weight: 700; }
.like-btn.pop .ico { animation: bmPop .32s ease; }
@keyframes bmPop { 0% { transform: scale(1); } 45% { transform: scale(1.45); } 100% { transform: scale(1); } }
.action-btn[data-busy] { opacity: .75; }
@media (prefers-reduced-motion: reduce) { .like-btn.pop .ico { animation: none; } }


/* ---------- "real posts only" notice in the composer ---------- */
.cm-rules { margin: 4px 0 8px; font-size: .76rem; color: var(--ink-soft); line-height: 1.4; }


/* =====================================================================
   Share sheet, "posted → tell your neighbours" bar, invite nudge/page
   ===================================================================== */
.bs-overlay { position: fixed; inset: 0; z-index: 1300; background: rgba(20, 28, 24, .5); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.bs-overlay[hidden] { display: none; }
.bs-overlay.open { opacity: 1; }
.bs-sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
            transform: translateY(24px); transition: transform .2s; max-height: 92vh; overflow-y: auto; }
.bs-overlay.open .bs-sheet { transform: none; }
.bs-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.bs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bs-head h3 { margin: 0; font-size: 1.05rem; }
.bs-lang { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; flex-shrink: 0; }
.bs-lang button { border: 0; background: none; padding: 5px 11px; font: inherit; font-size: .8rem; cursor: pointer; color: var(--ink-soft); }
.bs-lang button.on { background: var(--jol-green); color: #fff; }
.bs-preview { margin: 12px 0; padding: 10px 12px; background: var(--paper); border-left: 3px solid var(--kadam-gold); border-radius: 8px; font-size: .86rem; line-height: 1.45; color: var(--ink-soft); white-space: pre-line; max-height: 140px; overflow: auto; }
.bs-wa { display: flex; align-items: center; justify-content: center; gap: 6px; background: #1FA855; color: #fff; text-decoration: none; font-weight: 700; font-size: 1rem; padding: 13px; border-radius: 14px; }
.bs-wa:active { transform: scale(.99); }
.bs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 4px; margin: 12px 0 4px; }
.bs-grid > * { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 2px; background: none; border: 0; border-radius: 12px; font: inherit; font-size: .75rem; color: var(--ink); text-decoration: none; cursor: pointer; }
.bs-grid > *:hover { background: var(--bm-hover); }
.bs-grid > *[hidden] { display: none; }
.bs-grid i { font-style: normal; width: 44px; height: 44px; border-radius: 50%; background: var(--paper); display: flex; align-items: center; justify-content: center; font-size: 1.15rem; font-weight: 700; color: var(--nilkantha); }
.bs-repost { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.bs-repost[hidden] { display: none; }
.bs-repost-toggle { background: none; border: 0; font: inherit; font-weight: 600; color: var(--jol-green-dark); padding: 8px 2px; cursor: pointer; }
.bs-repost-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px; font: inherit; margin: 6px 0 8px; resize: vertical; }
.bs-foot { margin: 10px 0 0; font-size: .76rem; color: var(--ink-soft); text-align: center; line-height: 1.4; }

.bs-after { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 24px); opacity: 0; z-index: 1250; transition: all .22s;
            display: flex; align-items: center; gap: 10px; background: #1f2a24; color: #fff; padding: 9px 10px 9px 16px; border-radius: 28px; box-shadow: 0 6px 24px rgba(0,0,0,.3); max-width: 94vw; font-size: .88rem; }
.bs-after.in { opacity: 1; transform: translate(-50%, 0); }
.bs-after .go { background: #1FA855; color: #fff; border: 0; border-radius: 20px; padding: 8px 14px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.bs-after .x { background: none; border: 0; color: #fff; opacity: .7; font-size: 1rem; cursor: pointer; padding: 4px 6px; }

/* Feed nudge + welcome banner */
.inv-nudge { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, var(--jol-green), var(--jol-green-dark)); color: var(--paper);
             border-radius: var(--bm-radius); padding: 13px 14px; margin-bottom: 14px; box-shadow: var(--bm-shadow); }
.inv-nudge .t { flex: 1; font-size: .9rem; line-height: 1.35; }
.inv-nudge .t b { display: block; font-size: 1rem; }
.inv-nudge a.go { background: var(--paper); color: var(--jol-green-dark); text-decoration: none; font-weight: 700; padding: 9px 16px; border-radius: 20px; font-size: .86rem; white-space: nowrap; }
.inv-nudge button.x { background: none; border: 0; color: var(--paper); opacity: .7; font-size: 1rem; cursor: pointer; }
.inv-welcome { background: #EAF4EE; border: 1px solid #cfe5d7; color: var(--jol-green-dark); border-radius: var(--bm-radius); padding: 12px 14px; margin-bottom: 14px; font-size: .9rem; line-height: 1.4; }

/* Invite page */
.iv-card { background: var(--card); border-radius: var(--bm-radius); box-shadow: var(--bm-shadow); padding: 16px; margin-bottom: 14px; }
.iv-card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.iv-card .sub { color: var(--ink-soft); font-size: .86rem; margin: 0 0 12px; line-height: 1.45; }
.iv-hero { background: linear-gradient(135deg, var(--jol-green), var(--jol-green-dark)); color: var(--paper); }
.iv-hero .sub { color: rgba(255,255,255,.88); }
.iv-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 14px; padding: 13px; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none; margin-top: 8px; }
.iv-btn.wa { background: #1FA855; color: #fff; }
.iv-btn.alt { background: var(--paper); color: var(--jol-green-dark); }
.iv-link { display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,.15); border-radius: 12px; padding: 9px 12px; margin-top: 10px; font-size: .88rem; word-break: break-all; }
.iv-link button { flex-shrink: 0; background: var(--paper); color: var(--jol-green-dark); border: 0; border-radius: 16px; padding: 6px 12px; font: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; }
.iv-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.iv-stats div { background: var(--paper); border-radius: 12px; padding: 10px 4px; }
.iv-stats b { display: block; font-size: 1.5rem; color: var(--jol-green-dark); }
.iv-stats span { font-size: .72rem; color: var(--ink-soft); }
.iv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.iv-chips span { background: var(--paper); border-radius: 14px; padding: 4px 10px; font-size: .78rem; color: var(--ink-soft); }
.iv-badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.iv-badge { text-align: center; padding: 10px 2px; border-radius: 12px; background: var(--paper); opacity: .45; filter: grayscale(1); }
.iv-badge.on { opacity: 1; filter: none; background: #FBF1DC; }
.iv-badge i { font-style: normal; font-size: 1.7rem; display: block; }
.iv-badge b { display: block; font-size: .72rem; line-height: 1.2; margin-top: 4px; }
.iv-badge small { font-size: .66rem; color: var(--ink-soft); }
.iv-bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0 4px; }
.iv-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--kadam-gold), var(--jol-green)); border-radius: 6px; }
.iv-race { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: r; }
.iv-race li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .9rem; counter-increment: r; }
.iv-race li::before { content: counter(r); font-weight: 700; color: var(--kadam-gold); width: 22px; }
.iv-race li span:nth-child(1) { flex: 1; }
.iv-people { display: flex; flex-direction: column; gap: 8px; }
.iv-people a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: .9rem; }
.iv-fine { font-size: .76rem; color: var(--ink-soft); line-height: 1.5; }
#posterPrint { display: none; }
@media print {
    body > *:not(#posterPrint) { display: none !important; }
    #posterPrint { display: block !important; text-align: center; padding: 18mm 14mm; font-family: 'Hind Siliguri', sans-serif; color: #111; }
    #posterPrint h1 { font-size: 40pt; margin: 0 0 4mm; color: #234F3B; }
    #posterPrint h2 { font-size: 22pt; margin: 0 0 10mm; font-weight: 500; }
    #posterPrint .qr svg { width: 105mm; height: 105mm; }
    #posterPrint .url { font-size: 20pt; font-weight: 700; margin: 6mm 0; }
    #posterPrint ul { list-style: none; padding: 0; font-size: 16pt; line-height: 1.7; }
    #posterPrint .small { font-size: 12pt; color: #555; margin-top: 10mm; }
}
@media (prefers-reduced-motion: reduce) { .bs-overlay, .bs-sheet, .bs-after { transition: none; } }
