/* ============================================================
   CBI Events Calendar (C4) — native /events/ page styling.
   Ported from the POC reference (drawer variant only). Every class is
   prefixed `ec-` and all custom properties are scoped to
   `.events-calendar-app` so nothing collides with the site's global
   SCSS (which also uses .card/.btn/.title/.grid/.banner). Fonts are
   inherited from the site; --ec-navy is CBI brand navy.
   ============================================================ */
.events-calendar-app {
  --ec-navy: #00275B;          /* CBI brand navy */
  --ec-ink: #0F1A2E;
  --ec-muted: #5B6478;
  --ec-line: #E5E7EB;
  --ec-line-2: #EEF0F3;
  --ec-bg: #F7F8FA;
  --ec-card: #FFFFFF;
  --ec-black: #0A0A0A;
  --ec-focus: #2563EB;

  --ec-pill-purple-bg: #6B2FB3;  --ec-pill-teal-bg: #14B8A6;  --ec-pill-amber-bg: #F5B100;
  --ec-pill-emerald-bg: #10B981; --ec-pill-magenta-bg: #D946A6; --ec-pill-blue-bg: #2563EB;
  --ec-pill-rose-bg: #E11D74;    --ec-pill-slate-bg: #475569;

  --ec-tile-1: linear-gradient(135deg, #5b21b6 0%, #2563eb 50%, #14b8a6 100%);
  --ec-tile-2: linear-gradient(135deg, #14b8a6 0%, #84cc16 50%, #f59e0b 100%);
  --ec-tile-3: linear-gradient(135deg, #ec4899 0%, #f59e0b 100%);
  --ec-tile-4: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --ec-tile-5: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  --ec-tile-6: linear-gradient(135deg, #f43f5e 0%, #f59e0b 50%, #fde047 100%);
  --ec-tile-7: linear-gradient(135deg, #1e293b 0%, #475569 100%);
  --ec-tile-8: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);

  color: var(--ec-ink);
}
.events-calendar-app *, .ec-drawer * { box-sizing: border-box; }

/* ---------- TESTING DISCLAIMER (C5/PoC — remove when filters finalised) ---------- */
.ec-disclaimer {
  margin: 0 0 24px;
  padding: 12px 16px;
  border: 1px solid #e11d48;
  border-left: 4px solid #e11d48;
  border-radius: 6px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 14px;
  line-height: 1.45;
}
.ec-disclaimer strong { color: #991b1b; }

/* ---------- TOPBAR ---------- */
.ec-topbar { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: end; margin-bottom: 28px; }
.ec-field { display: flex; flex-direction: column; gap: 6px; }
.ec-field label { font-size: 13px; color: var(--ec-muted); font-weight: 500; }
.ec-input, .ec-date-input {
  height: 44px; border: 1px solid var(--ec-line); border-radius: 999px; padding: 0 18px;
  font: inherit; color: var(--ec-ink); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ec-input:focus, .ec-date-input:focus { border-color: var(--ec-focus); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.ec-input-wrap { position: relative; }
.ec-input { width: 100%; padding-right: 42px; }
.ec-input-wrap svg.ec-icon-search { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ec-muted); }
.ec-dates { display: grid; grid-template-columns: 1fr 12px 1fr; gap: 8px; align-items: end; }
.ec-dash { height: 44px; display: grid; place-items: center; color: var(--ec-muted); font-weight: 500; }
.ec-date-input { width: 170px; padding-right: 18px; }

.ec-view-toggle { display: inline-flex; border: 1px solid var(--ec-line); border-radius: 12px; padding: 4px; background: #fff; height: 44px; }
.ec-view-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 100%; padding: 0 16px; border: none;
  background: transparent; border-radius: 9px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ec-ink); cursor: pointer;
}
.ec-view-btn[aria-pressed="true"] { background: var(--ec-black); color: #fff; }
.ec-view-btn svg { width: 16px; height: 16px; }

/* ---------- LAYOUT + FILTERS ---------- */
.ec-layout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; align-items: start; }
.ec-filters { position: sticky; top: 16px; }
.ec-filter-section { border-bottom: 1px solid var(--ec-line); padding: 18px 0; }
.ec-filter-section:first-child { padding-top: 8px; }
.ec-filter-section:last-child { border-bottom: none; }
.ec-filter-head { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--ec-ink); cursor: pointer; }
.ec-filter-head .ec-chev { width: 18px; height: 18px; transition: transform .2s; }
.ec-filter-section.ec-collapsed .ec-chev { transform: rotate(-90deg); }
.ec-filter-section.ec-collapsed .ec-filter-body { display: none; }
.ec-filter-body { padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.ec-filter-body .ec-empty-note { font-size: 13px; color: var(--ec-muted); }
.ec-check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ec-ink); cursor: pointer; user-select: none; }
.ec-check input { display: none; }
.ec-check .ec-box { width: 16px; height: 16px; border: 1.5px solid #C8CCD4; border-radius: 4px; display: grid; place-items: center; background: #fff; transition: all .15s; flex-shrink: 0; }
.ec-check input:checked + .ec-box { background: var(--ec-navy); border-color: var(--ec-navy); }
.ec-check .ec-box svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.ec-check input:checked + .ec-box svg { opacity: 1; }
.ec-check:hover .ec-box { border-color: var(--ec-navy); }

.ec-results-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ec-count { font-size: 14px; color: var(--ec-muted); }
.ec-count strong { color: var(--ec-ink); font-weight: 600; }
.ec-clear-all { background: none; border: 1px solid var(--ec-line); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 500; color: var(--ec-ink); cursor: pointer; }
.ec-clear-all:hover { background: #fff; border-color: var(--ec-ink); }

/* ---------- CARDS ---------- */
.ec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.ec-grid.ec-list { grid-template-columns: 1fr; }
.ec-card { background: var(--ec-card); border: 1px solid var(--ec-line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; display: flex; flex-direction: column; position: relative; }
.ec-grid.ec-list .ec-card { flex-direction: row; }
.ec-grid.ec-list .ec-tile { width: 240px; flex-shrink: 0; aspect-ratio: 16/10; }
.ec-grid.ec-list .ec-body { flex: 1; }
.ec-card:hover { border-color: #D5DAE2; box-shadow: 0 8px 24px -8px rgba(15,26,46,.12); transform: translateY(-2px); }
.ec-card:focus-visible { outline: 2px solid var(--ec-focus); outline-offset: 2px; }

.ec-tile { aspect-ratio: 16/10; position: relative; display: grid; place-items: center; padding: 24px; color: #fff; overflow: hidden; background-size: cover; background-position: center; }
.ec-tile-1 { background: var(--ec-tile-1); } .ec-tile-2 { background: var(--ec-tile-2); }
.ec-tile-3 { background: var(--ec-tile-3); } .ec-tile-4 { background: var(--ec-tile-4); }
.ec-tile-5 { background: var(--ec-tile-5); } .ec-tile-6 { background: var(--ec-tile-6); }
.ec-tile-7 { background: var(--ec-tile-7); } .ec-tile-8 { background: var(--ec-tile-8); }
.ec-tile.ec-has-image .ec-tile-inner { display: none; }
.ec-tile-inner { background: #fff; color: var(--ec-navy); padding: 18px 22px; border-left: 4px solid var(--ec-navy); font-weight: 700; font-size: 22px; line-height: 1.1; letter-spacing: -0.01em; max-width: 80%; text-transform: uppercase; text-align: left; }

.ec-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ec-meta { font-size: 13px; color: var(--ec-muted); line-height: 1.45; }
.ec-meta .ec-date { color: var(--ec-ink); font-weight: 500; }
.ec-title { font-weight: 600; color: var(--ec-ink); font-size: 16px; line-height: 1.3; margin: 4px 0 0; }
.ec-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ec-pill { display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.2; white-space: nowrap; color: #fff; }
.ec-pill.ec-purple { background: var(--ec-pill-purple-bg); } .ec-pill.ec-teal { background: var(--ec-pill-teal-bg); }
.ec-pill.ec-amber { background: var(--ec-pill-amber-bg); color: #1b1b1b; } .ec-pill.ec-emerald { background: var(--ec-pill-emerald-bg); }
.ec-pill.ec-magenta { background: var(--ec-pill-magenta-bg); } .ec-pill.ec-blue { background: var(--ec-pill-blue-bg); }
.ec-pill.ec-rose { background: var(--ec-pill-rose-bg); } .ec-pill.ec-slate { background: var(--ec-pill-slate-bg); }
.ec-pill.ec-cbi-only { background: #fff; color: var(--ec-navy); border: 1.5px solid var(--ec-navy); padding: 3.5px 10.5px; }

.ec-empty { grid-column: 1 / -1; text-align: center; padding: 64px 24px; color: var(--ec-muted); background: #fff; border: 1px dashed var(--ec-line); border-radius: 14px; }
.ec-empty h3 { color: var(--ec-ink); margin: 0 0 6px; font-size: 18px; }

/* ---------- DRAWER ---------- */
.ec-drawer-backdrop { position: fixed; inset: 0; background: rgba(15,26,46,.35); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1000; }
.ec-drawer-backdrop.ec-open { opacity: 1; pointer-events: auto; }
.ec-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100vw; background: #fff; box-shadow: -16px 0 48px -12px rgba(15,26,46,.25); transform: translateX(100%); transition: transform .25s ease-out; z-index: 1001; display: flex; flex-direction: column; overflow-y: auto; }
.ec-drawer.ec-open { transform: translateX(0); }
.ec-drawer-tile { aspect-ratio: 16/8; position: relative; display: grid; place-items: center; padding: 28px; flex-shrink: 0; background-size: cover; background-position: center; }
.ec-drawer-tile .ec-tile-inner { font-size: 26px; max-width: 75%; padding: 20px 24px; }
.ec-drawer-tile.ec-has-image .ec-tile-inner { display: none; }
.ec-drawer-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 999px; border: none; background: rgba(255,255,255,.95); cursor: pointer; display: grid; place-items: center; color: var(--ec-ink); }
.ec-drawer-close:hover { background: #fff; }
.ec-drawer-close svg { width: 18px; height: 18px; }
.ec-drawer-body { padding: 28px 32px; flex: 1; }
.ec-drawer-body h2 { margin: 0 0 12px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; color: var(--ec-ink); }
.ec-drawer-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin: 16px 0 20px; font-size: 14px; }
.ec-drawer-meta .ec-label { color: var(--ec-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-bottom: 2px; }
.ec-drawer-meta .ec-value { color: var(--ec-ink); font-weight: 500; }
.ec-drawer-desc { color: var(--ec-ink); line-height: 1.6; font-size: 14px; white-space: pre-line; }
.ec-drawer-footer { padding: 18px 32px; border-top: 1px solid var(--ec-line-2); background: #FAFBFC; display: flex; gap: 12px; justify-content: flex-end; position: sticky; bottom: 0; }

/* ---------- BUTTONS ---------- */
.ec-btn { height: 44px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--ec-line); background: #fff; font: inherit; font-weight: 600; font-size: 14px; color: var(--ec-ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.ec-btn:hover { border-color: var(--ec-ink); }
.ec-btn-primary { background: var(--ec-navy); color: #fff; border-color: var(--ec-navy); }
.ec-btn-primary:hover { background: #001b40; border-color: #001b40; }
.ec-btn-primary svg { width: 14px; height: 14px; }

.ec-loading { grid-column: 1 / -1; text-align: center; padding: 48px 24px; color: var(--ec-muted); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) { .ec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .ec-topbar { grid-template-columns: 1fr; }
  .ec-layout { grid-template-columns: 1fr; }
  .ec-filters { position: static; border: 1px solid var(--ec-line); border-radius: 14px; background: #fff; padding: 8px 16px; margin-bottom: 20px; }
  .ec-grid, .ec-grid.ec-list { grid-template-columns: 1fr; }
  .ec-grid.ec-list .ec-card { flex-direction: column; }
  .ec-grid.ec-list .ec-tile { width: 100%; }
  .ec-drawer { width: 100%; top: auto; bottom: 0; max-height: 90vh; transform: translateY(100%); border-radius: 16px 16px 0 0; }
  .ec-drawer.ec-open { transform: translateY(0); }
  .ec-drawer-meta { grid-template-columns: 1fr; }
}
@keyframes ec-fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.ec-card { animation: ec-fadeUp .28s ease-out both; }
