/* ── Community Bulletin (சங்கமம்) ─────────────────────────────
   Section identity colour: village green #2E7D32 → #1B5E20
   (matches the raised centre nav button in nav.css)          */

/* ── Header ─────────────────────────────────────────────── */
.bl-header {
  position: relative;
  background: linear-gradient(135deg, #2E7D32, #1B5E20);
  color: #fff;
  padding: 18px 16px 16px;
  text-align: center;
}
.bl-header-ta {
  font-family: var(--font-tamil);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}
.bl-header-en {
  font-size: 0.72rem;
  opacity: 0.85;
  margin: 3px 0 0;
  letter-spacing: 0.02em;
}
.bl-refresh-btn {
  position: absolute;
  top: 12px; right: 12px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  border: none;
}
.bl-refresh-btn:active { background: rgba(255,255,255,0.32); }

/* ── Panels (register + compose) ────────────────────────── */
.bl-panel {
  background: #fff;
  margin: 12px;
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}
.bl-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.bl-panel-ic { font-size: 1.5rem; }
.bl-panel-titles { display: flex; flex-direction: column; }
.bl-panel-ta {
  font-family: var(--font-tamil);
  font-size: 1rem;
  font-weight: 700;
  color: #1B5E20;
}
.bl-panel-en { font-size: 0.7rem; color: var(--color-muted); }
.bl-panel-note {
  font-family: var(--font-tamil);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--color-muted);
  margin: 0 0 12px;
}

/* ── Forms ──────────────────────────────────────────────── */
.bl-form { display: flex; flex-direction: column; }
.bl-label {
  font-family: var(--font-tamil);
  font-size: 0.85rem;
  font-weight: 600;
  color: #37474F;
  margin: 10px 0 4px;
}
.bl-req { color: #C62828; }
.bl-req-hint { font-size: 0.72rem; font-weight: 400; color: var(--color-muted); }
.bl-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 1rem;               /* 16px — stops iOS zoom-on-focus */
  font-family: inherit;
  color: #263238;
  background: #F7F9FA;
  border: 1px solid #CFD8DC;
  border-radius: 8px;
  min-height: 48px;
}
.bl-input:focus {
  outline: none;
  border-color: #2E7D32;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(46,125,50,0.15);
}
.bl-textarea {
  font-family: var(--font-tamil);
  line-height: 1.5;
  resize: vertical;
  min-height: 84px;
}
.bl-file { padding: 9px 12px; background: #fff; }
.bl-field-err {
  font-family: var(--font-tamil);
  font-size: 0.78rem;
  color: #C62828;
  margin: 4px 0 0;
}
.bl-btn {
  margin-top: 16px;
  padding: 13px 16px;
  min-height: 48px;
  font-family: var(--font-tamil);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2E7D32, #1B5E20);
  border: none;
  border-radius: 10px;
}
.bl-btn:active { transform: translateY(1px); }
.bl-btn:disabled { opacity: 0.6; }
.bl-result {
  font-family: var(--font-tamil);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
}
.bl-result.is-ok  { background: #E8F5E9; color: #1B5E20; border-left: 4px solid #2E7D32; }
.bl-result.is-err { background: #FFEBEE; color: #B71C1C; border-left: 4px solid #C62828; }

/* ── Who am I / switch account ──────────────────────────── */
.bl-whoami {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-tamil);
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-bottom: 10px;
}
.bl-signout {
  background: none;
  border: none;
  color: #2E7D32;
  font-family: var(--font-tamil);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: underline;
  padding: 6px;
}

/* ── Composer — collapsed prompt box, expands on tap ─────────
   Closed it reads as a single tappable line (Facebook / LinkedIn
   "what's on your mind"); open it becomes a titled form header. */
.bl-compose { border-top: 1px solid var(--color-border); padding-top: 10px; }
.bl-compose-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  cursor: pointer;
  list-style: none;
}
.bl-compose-cta::-webkit-details-marker { display: none; }

.bl-compose-avatar {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2E7D32, #1B5E20);
  color: #fff;
  font-family: var(--font-tamil);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The fake "input" — looks tappable, is not a real field */
.bl-compose-pill {
  flex: 1;
  min-width: 0;
  padding: 11px 16px;
  border-radius: 22px;
  background: #F1F3F4;
  border: 1px solid #E0E3E5;
  font-family: var(--font-tamil);
  font-size: 0.92rem;
  color: #6B7378;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bl-compose-cta:active .bl-compose-pill { background: #E7EAEC; }
.bl-compose-cam { font-size: 1.25rem; flex: 0 0 auto; }

/* Header shown only once the composer is open */
.bl-compose-open-title { display: none; flex-direction: column; flex: 1; }
.bl-compose-ta {
  font-family: var(--font-tamil);
  font-size: 1rem;
  font-weight: 700;
  color: #1B5E20;
}
.bl-compose-en { font-size: 0.68rem; color: var(--color-muted); }
.bl-compose-close {
  display: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #F1F3F4;
  color: #5F6368;
  font-size: 0.9rem;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.bl-compose[open] .bl-compose-pill,
.bl-compose[open] .bl-compose-cam { display: none; }
.bl-compose[open] .bl-compose-open-title { display: flex; }
.bl-compose[open] .bl-compose-close { display: flex; }
.bl-compose[open] .bl-compose-cta {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 10px;
  margin-bottom: 4px;
}

.bl-img-preview { margin-top: 8px; position: relative; }
.bl-img-preview img {
  /* contain — same reasoning as .bl-img. A cropped preview would let
     someone post a photo without ever seeing what actually got cut off. */
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 8px;
  background: #ECEFF1;
}
.bl-img-kb {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.68rem;
  padding: 3px 7px;
  border-radius: 10px;
}
/* Shown only when editing an existing post's photo (see startEdit) — the
   only way to detach it, since re-picking a file is the only other option. */
.bl-img-remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.bl-img-remove:active { background: rgba(0,0,0,0.8); }
.bl-img-wait {
  font-family: var(--font-tamil);
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* The bottom nav is position:fixed — without this the last post's like
   button sits underneath it and cannot be tapped. */
#section-bulletin {
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + var(--space-lg));
}

/* ── Feed ───────────────────────────────────────────────── */
.bl-feed { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 12px; }

.bl-loading, .bl-empty {
  text-align: center;
  padding: 32px 16px;
  background: #fff;
  border-radius: 12px;
  font-family: var(--font-tamil);
  color: var(--color-muted);
}
.bl-empty-ic { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.bl-empty-ta { font-size: 0.95rem; font-weight: 600; margin: 0; color: #455A64; }
.bl-empty-en { font-size: 0.72rem; margin: 4px 0 0; }

.bl-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  border-left: 4px solid #1B5E20;
}
.bl-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bl-avatar {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2E7D32, #1B5E20);
  color: #fff;
  font-family: var(--font-tamil);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bl-who { display: flex; flex-direction: column; min-width: 0; }
.bl-name {
  font-family: var(--font-tamil);
  font-size: 0.92rem;
  font-weight: 700;
  color: #263238;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Badges sit on their own line under the name — see postCard() */
.bl-trust {
  align-self: flex-start;
  font-family: var(--font-tamil);
  font-size: 0.64rem;
  font-weight: 700;
  color: #1B5E20;
  background: #E8F5E9;
  padding: 1px 6px;
  border-radius: 9px;
  margin: 2px 0;
}

/* Official village account — visually distinct from any villager post */
.bl-card.is-official {
  border-left-color: #E65100;
  background: linear-gradient(180deg, #FFF8E1 0%, #fff 56px);
}
.bl-avatar.is-official {
  background: linear-gradient(135deg, #FB8C00, #E65100);
  font-size: 1.15rem;
}
.bl-official {
  align-self: flex-start;
  font-family: var(--font-tamil);
  font-size: 0.64rem;
  font-weight: 700;
  color: #fff;
  background: #E65100;
  padding: 2px 8px;
  border-radius: 10px;
  margin: 2px 0;
  white-space: nowrap;
}
.bl-time { font-family: var(--font-tamil); font-size: 0.72rem; color: var(--color-muted); }

.bl-title {
  font-family: var(--font-tamil);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.4;
  color: #1A2327;
  margin: 0 0 2px;
}
.bl-title-en { font-size: 0.75rem; color: var(--color-muted); margin: 0 0 6px; }
.bl-body {
  font-family: var(--font-tamil);
  font-size: 0.94rem;
  line-height: 1.6;
  color: #37474F;
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bl-body-en {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--color-muted);
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bl-img {
  /* contain, not cover: a villager posting a photo of a burst pipe or a
     torn road wants the WHOLE photo seen, not a fixed box cropping out
     whatever "cover" decided didn't fit. max-height only caps runaway
     panoramas — it never crops, it letterboxes on the grey background. */
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 8px;
  margin-top: 10px;
  background: #ECEFF1;
}

/* ── Link chip ───────────────────────────────────────────────
   A full-width tappable row, not an inline underlined link: on a phone
   the whole point is that it is impossible to miss and impossible to
   mis-tap. 52px tall clears the 48dp minimum target with room to spare. */
.bl-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid #C8E6C9;
  border-left: 4px solid #2E7D32;
  border-radius: 10px;
  background: #F1F8F2;
  text-decoration: none;
  color: inherit;
}
.bl-link:active { background: #DCEDDE; }
.bl-link-ic { font-size: 1.25rem; flex: 0 0 auto; }
.bl-link-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.bl-link-ta {
  font-family: var(--font-tamil);
  font-size: 0.92rem;
  font-weight: 700;
  color: #1B5E20;
}
.bl-link-host {
  font-size: 0.72rem;
  color: var(--color-muted);
  /* A long URL host must never widen the card and force sideways scroll */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bl-link-go { font-size: 0.95rem; color: #2E7D32; flex: 0 0 auto; }

/* Hint under an optional composer field */
.bl-field-hint {
  font-family: var(--font-tamil);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--color-muted);
  margin: 4px 0 0;
}

.bl-card-foot {
  display: flex;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.bl-like {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px 6px 6px;
  background: none;
  border: none;
  border-radius: 22px;
  color: var(--color-muted);
  transition: background var(--trans-fast);
}
.bl-like:active { background: #F1F5F6; }
.bl-like-ic { font-size: 1.25rem; line-height: 1; }
.bl-like-n { font-size: 0.85rem; font-weight: 700; }
.bl-like.liked .bl-like-n { color: #C2185B; }

/* ── Wide screens — feed becomes a readable centred column ── */
@media (min-width: 700px) {
  html body .bl-panel,
  html body .bl-feed { max-width: 640px; margin-left: auto; margin-right: auto; }
}

/* ── Own-post controls (edit / delete) ────────────────────────────
   Only rendered on posts belonging to this device's registered poster.
   Deliberately quiet — secondary to the like button, which is the action
   everyone else uses. */
.bl-own {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 var(--space-md) var(--space-md);
  border-top: 1px dashed var(--color-border);
  margin-top: 2px;
  padding-top: var(--space-sm);
}
.bl-own-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: #37474F;
  cursor: pointer;
}
.bl-own-btn:active { background: #ECEFF1; }
.bl-own-btn.is-del { color: #C62828; border-color: #FFCDD2; }
.bl-own-btn.is-del:active { background: #FFEBEE; }

/* "Waiting for the admin" — shown to the AUTHOR only, so their post never
   looks like it silently vanished after submitting or editing. */
.bl-pending {
  font-size: 0.8rem;
  font-weight: 700;
  color: #E65100;
  background: #FFF3E0;
  border-radius: 999px;
  padding: 5px 10px;
  margin-right: auto;
}
.bl-card.is-pending { border-left: 4px solid #FFB74D; }

.bl-btn-cancel {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  min-height: 48px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #fff;
  color: #546E7A;
  cursor: pointer;
}
.bl-btn-cancel:active { background: #ECEFF1; }
