/* =====================================================================
   CIVIC THEME  —  Step 5: events calendar
   ---------------------------------------------------------------------
   Additive. Loads AFTER civic-theme-step4-profile.css, and after
   calendar.css (the EventCalendar v4 stylesheet) so it can retint it.

   Reskins the month grid, toolbar, agenda/list view and legend to the
   redesign. Topic chips are tinted in JS (TOPIC_CHIP in tappet.js) and
   tagged `ec-topic-<slug>`; the left rule per topic lives here.
   ===================================================================== */

/* ---- Card wrapper around the whole calendar -------------------------
   The legend below is welded to the bottom of the same card, so this half
   is square-bottomed and unshadowed; .calendar-legend closes it off. */
#calendar {
    background: #ffffff;
    border: 1px solid #e6e8ec;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    overflow: hidden;
    padding: 0;
    margin-bottom: 0;
}

/* EventCalendar's own tokens, retuned to the civic palette. */
#calendar .ec {
    --ec-border-color: #f1f2f5;
    --ec-today-bg-color: #eef2f7;
    --ec-highlight-color: rgba(86, 98, 119, .08);
    --ec-button-bg-color: #ffffff;
    --ec-button-border-color: #e0e3e9;
    --ec-button-text-color: #6b727e;
    --ec-button-active-bg-color: #566277;
    --ec-button-active-border-color: #566277;
    --ec-button-active-text-color: #ffffff;
    --ec-now-indicator-color: #c0392b;
    font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    color: #1b1f26;
}

/* ---- Toolbar --------------------------------------------------------- */
#calendar .ec-toolbar {
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 16px 20px;
    border-bottom: 1px solid #eceef2;
}
#calendar .ec-title {
    font-family: obida, Georgia, serif;
    font-size: 1.4em;
    line-height: 1.1;
    color: #1b1f26;
}
#calendar .ec-button {
    font-size: .8em;
    font-weight: 600;
    line-height: 1.2;
    padding: 7px 13px;
    border-radius: 8px;
    color: #6b727e;
}
#calendar .ec-button:not(:disabled):hover {
    background: #eef1f7;
    border-color: #d3d9e6;
    color: #566277;
}
#calendar .ec-button.ec-active,
#calendar .ec-button.ec-active:hover {
    background: #566277;
    border-color: #566277;
    color: #ffffff;
}
/* prev / next read as compact square steppers */
#calendar .ec-button-group .ec-button {
    padding: 7px 11px;
}
#calendar .ec-button-group {
    border-radius: 8px;
    overflow: hidden;
}

/* ---- Weekday header -------------------------------------------------- */
#calendar .ec-header {
    border: none;
    border-bottom: 1px solid #eceef2;
}
#calendar .ec-header .ec-day {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .66em;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #9aa0ab;
    padding: 9px 10px;
    text-align: left;
    border: none;
}

/* ---- Month grid ------------------------------------------------------ */
#calendar .ec-body {
    border: none;
}
/* Body cells only — the weekday header is also .ec-day-grid .ec-day. */
#calendar .ec-day-grid .ec-body .ec-day {
    min-height: 92px;
    border-left: 1px solid #f1f2f5;
}
#calendar .ec-day-grid .ec-days {
    border-bottom: 1px solid #f1f2f5;
}
#calendar .ec-day-grid .ec-day-head {
    text-align: right;
    padding: 6px 8px;
    font-size: .78em;
    color: #5a616e;
    border: none;
}
#calendar .ec-day.ec-other-month .ec-day-head {
    color: #c3c7ce;
}
#calendar .ec-day.ec-other-month .ec-day-head time {
    opacity: 1;          /* the muted tone above already says "other month" */
}
#calendar .ec-day.ec-today .ec-day-head {
    font-weight: 700;
    color: #566277;
}

/* ---- Event chips ----------------------------------------------------- */
#calendar .ec-event {
    border-radius: 4px;
    box-shadow: none;
    font-size: .72em;
    line-height: 1.45;
    padding: 2px 5px;
    border-left: 3px solid #64748B;   /* per-topic rule set below */
    overflow: hidden;
}
/* In the grid the topic reads from the chip's left rule, so the library's
   own tag bar would just double it up. */
#calendar .ec-day-grid .ec-event-tag,
#calendar .ec-all-day .ec-event-tag {
    display: none;
}
#calendar .ec-event-time,
#calendar .ec-event-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#calendar .ec-day-grid .ec-event-time {
    margin-right: 4px;
}

#calendar .ec-event.ec-topic-general             { border-left-color: #64748B; }
#calendar .ec-event.ec-topic-economic-stability  { border-left-color: #2563EB; }
#calendar .ec-event.ec-topic-education           { border-left-color: #9333EA; }
#calendar .ec-event.ec-topic-environment         { border-left-color: #16A34A; }
#calendar .ec-event.ec-topic-health-care         { border-left-color: #DC2626; }
#calendar .ec-event.ec-topic-food-security       { border-left-color: #F59E0B; }
#calendar .ec-event.ec-topic-housing             { border-left-color: #0D9488; }

#calendar .ec-day-grid .ec-day-foot a {
    font-size: .72em;
    font-weight: 600;
    color: #566277;
}

/* ---- Agenda / list view (the mobile default) ------------------------- */
#calendar .ec-list .ec-day-head {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .66em;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #9aa0ab;
    background: #ffffff;
    border-color: #eceef2;
    padding: 12px 18px 6px;
}
#calendar .ec-list .ec-event {
    align-items: flex-start;
    gap: 11px;
    padding: 10px 18px;
    font-size: .88em;
    border-left: 0;
    border-top: 1px solid #eceef2;
    background: #ffffff !important;   /* list rows stay white; the tag carries the color */
    color: #1b1f26 !important;
}
/* The tag's fill is set inline from the event's backgroundColor (the pale
   chip tint), so the solid topic color has to win with !important here. */
#calendar .ec-list .ec-event-tag {
    width: 3px;
    border-radius: 2px;
    align-self: stretch;
    background: #64748B !important;
}
#calendar .ec-list .ec-topic-general            .ec-event-tag { background: #64748B !important; }
#calendar .ec-list .ec-topic-economic-stability .ec-event-tag { background: #2563EB !important; }
#calendar .ec-list .ec-topic-education          .ec-event-tag { background: #9333EA !important; }
#calendar .ec-list .ec-topic-environment        .ec-event-tag { background: #16A34A !important; }
#calendar .ec-list .ec-topic-health-care        .ec-event-tag { background: #DC2626 !important; }
#calendar .ec-list .ec-topic-food-security      .ec-event-tag { background: #F59E0B !important; }
#calendar .ec-list .ec-topic-housing            .ec-event-tag { background: #0D9488 !important; }
#calendar .ec-list .ec-event-title {
    font-weight: 600;
    white-space: normal;
}
#calendar .ec-list .ec-event-time {
    color: #6b727e;
    font-weight: 400;
}
#calendar .ec-list .ec-no-events {
    padding: 3.5em 0;
    color: #9aa0ab;
    font-size: .9em;
}

/* ---- Popup (the "+N more" day list) ---------------------------------- */
#calendar .ec-popup {
    border-radius: 12px;
    border: 1px solid #e6e8ec;
    box-shadow: 0 18px 40px -22px rgba(30, 40, 60, .5);
}

/* ---- Legend ---------------------------------------------------------- */
.calendar-legend {
    margin: 0 0 1.6em;
    padding: 14px 20px;
    background: #ffffff;
    border: 1px solid #e6e8ec;
    border-top: 1px solid #eceef2;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 6px 18px -10px rgba(30, 40, 60, .22);
    gap: 9px 16px;
    font-size: .78em;
    color: #5a616e;
}
.legend-dot {
    width: 9px;
    height: 9px;
}

@media (max-width: 720px) {
    #calendar .ec-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px 16px;
    }
    #calendar .ec-title {
        font-size: 1.2em;
    }
}
