/* cal.css - shared ministry kit: month calendar, event cards, week strip.
   Everything themable reads CSS custom properties set by the site's own
   site.css; every token has a fallback so the kit works un-themed.
   No site-specific colors, fonts, names, or text here. */

/* ---------- layout shell ---------- */

.cal {
  font-family: var(--k-body, system-ui, sans-serif);
  color: var(--k-ink, #241c4a);
  display: grid;
  gap: 28px;
}

@media (min-width: 981px) {
  .cal {
    grid-template-columns: 1.35fr 1fr;
    align-items: start;
  }
}

.cal-main { min-width: 0; }
.cal-side { min-width: 0; }

/* ---------- header bar ---------- */

.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cal-title {
  font-family: var(--k-head, Georgia, serif);
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 0;
  flex: 1 1 auto;
  text-align: center;
  min-width: 9ch;
}

.cal-prev,
.cal-next {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--k-line, rgba(0, 0, 0, .1));
  background: rgba(255, 255, 255, .7);
  color: inherit;
  cursor: pointer;
  transition: background-color .15s ease;
}

.cal-prev:hover,
.cal-next:hover { background: var(--k-tint, rgba(90, 58, 150, .08)); }

.cal-today {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1.5px solid var(--k-line, rgba(0, 0, 0, .1));
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: background-color .15s ease;
}

.cal-today:hover { background: var(--k-tint, rgba(90, 58, 150, .08)); }

/* ---------- kind filter chips ---------- */

.cal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.cal-chip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--k-line, rgba(0, 0, 0, .1));
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background-color .15s ease;
}

.cal-chip:hover { background: var(--k-tint, rgba(90, 58, 150, .08)); }

.cal-chip[aria-pressed="true"] {
  background: var(--k-accent2, #5a3a96);
  border-color: transparent;
  color: #fff;
}

/* ---------- month grid ---------- */

.cal-grid {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.cal-wd,
.cal-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-wd > span {
  text-align: center;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--k-muted, #5b5470);
  padding: 4px 0;
}

.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 48px;
  aspect-ratio: 1;
  padding: 6px 7px;
  border-radius: 12px;
  border: 1px solid var(--k-line, rgba(0, 0, 0, .1));
  background: rgba(255, 255, 255, .7);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease;
}

@media (min-width: 981px) {
  .cal-day {
    aspect-ratio: auto;
    min-height: 84px;
    padding: 8px 9px;
  }
}

.cal-day:hover { background: var(--k-tint, rgba(90, 58, 150, .08)); }

.cal-day.is-out { opacity: .45; }

.cal-day.is-today {
  box-shadow: 0 0 0 2px var(--k-accent, #e8b64a);
}

.cal-day.is-sel,
.cal-day.is-sel:hover {
  background: var(--k-accent2, #5a3a96);
  border-color: transparent;
  color: #fff;
}

.cal-n {
  font-weight: 700;
  font-size: .95rem;
  line-height: 1;
}

.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: auto;
  padding-bottom: 1px;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--k-accent, #e8b64a);
  display: inline-block;
}

.cal-chipline {
  display: none;
}

@media (min-width: 1100px) {
  .cal-chipline {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .68rem;
    font-weight: 600;
    color: var(--k-muted, #5b5470);
  }

  .cal-day.is-sel .cal-chipline { color: rgba(255, 255, 255, .85); }
}

/* ---------- day panel + sidebar ---------- */

.cal-day-panel { margin-top: 20px; }

.cal-day-title {
  font-family: var(--k-head, Georgia, serif);
  font-size: 1.25rem;
  line-height: 1.25;
  margin: 0 0 12px;
}

.cal-side-title {
  font-family: var(--k-head, Georgia, serif);
  font-size: 1.35rem;
  line-height: 1.25;
  margin: 0 0 12px;
}

.cal-all {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border-radius: 999px;
  border: 1.5px solid var(--k-accent2, #5a3a96);
  background: transparent;
  color: var(--k-accent2, #5a3a96);
  font: inherit;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  transition: background-color .15s ease;
}

.cal-all:hover { background: var(--k-tint, rgba(90, 58, 150, .08)); }

/* ---------- event cards ---------- */

.ev-list {
  display: grid;
  gap: 14px;
}

.ev-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 16px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--k-line, rgba(0, 0, 0, .1));
  border-left: 4px solid var(--k-accent, #e8b64a);
  border-radius: var(--k-radius, 18px);
  padding: 14px;
  box-shadow: 0 14px 30px -24px rgba(0, 0, 0, .55);
}

.ev-date {
  align-self: start;
  min-height: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--k-accent, #e8b64a);
  color: var(--k-accent-ink, #1d1646);
  text-align: center;
}

.ev-dow {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .14em;
}

.ev-day {
  font-family: var(--k-head, Georgia, serif);
  font-size: 1.9rem;
  line-height: 1.05;
}

.ev-mon {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
}

.ev-body { min-width: 0; }

.ev-title {
  font-family: var(--k-head, Georgia, serif);
  font-size: 1.15rem;
  line-height: 1.25;
  margin: 0 0 4px;
  color: var(--k-ink, #241c4a);
}

.ev-meta {
  font-weight: 700;
  font-size: .9rem;
  color: var(--k-accent2, #5a3a96);
  margin: 0 0 6px;
}

.ev-sum {
  color: var(--k-muted, #5b5470);
  font-size: .92rem;
  line-height: 1.5;
  margin: 0 0 10px;
}

.ev-empty,
.ev-loading {
  color: var(--k-muted, #5b5470);
  font-size: .95rem;
  line-height: 1.5;
  margin: 8px 0;
}

/* ---------- add-to-calendar menu ---------- */

.ev-add {
  position: relative;
  display: inline-block;
}

.ev-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--k-line, rgba(0, 0, 0, .1));
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background-color .15s ease;
}

.ev-add-btn:hover,
.ev-add-btn[aria-expanded="true"] {
  background: var(--k-tint, rgba(90, 58, 150, .08));
}

.ev-add-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  min-width: 230px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--k-line, rgba(0, 0, 0, .1));
  background: var(--k-bg, #fffaf0);
  box-shadow: var(--k-shadow, 0 30px 80px -30px rgba(20, 12, 60, .45));
}

.ev-add-menu a,
.ev-add-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--k-ink, #241c4a);
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.ev-add-menu a:hover,
.ev-add-menu button:hover {
  background: var(--k-tint, rgba(90, 58, 150, .08));
}

/* ---------- week strip ---------- */

.wk {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.wk-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 6px 0;
  border-radius: 12px;
  border: 1px solid var(--k-line, rgba(0, 0, 0, .1));
  color: inherit;
  text-decoration: none;
  transition: background-color .15s ease;
}

.wk-day:hover { background: var(--k-tint, rgba(90, 58, 150, .08)); }

.wk-dow {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--k-muted, #5b5470);
}

.wk-num {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
}

.wk-day.is-today,
.wk-day.is-today:hover {
  background: var(--k-accent2, #5a3a96);
  border-color: transparent;
  color: #fff;
}

.wk-day.is-today .wk-dow { color: rgba(255, 255, 255, .8); }

.wk-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--k-accent, #e8b64a);
}

.wk-next {
  font-size: .86rem;
  line-height: 1.5;
  color: var(--k-muted, #5b5470);
  margin: 10px 0 0;
}

.wk-next a {
  color: var(--k-accent2, #5a3a96);
  font-weight: 700;
}

/* ---------- focus rings ---------- */

.cal-prev:focus-visible,
.cal-next:focus-visible,
.cal-today:focus-visible,
.cal-chip:focus-visible,
.cal-day:focus-visible,
.cal-all:focus-visible,
.ev-add-btn:focus-visible,
.ev-add-menu a:focus-visible,
.ev-add-menu button:focus-visible,
.wk-day:focus-visible,
.wk-next a:focus-visible {
  outline: 3px solid var(--k-focus, #e8b64a);
  outline-offset: 2px;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .cal-prev,
  .cal-next,
  .cal-today,
  .cal-chip,
  .cal-day,
  .cal-all,
  .ev-add-btn,
  .wk-day {
    transition: none;
  }
}

/* v3 fix: closed add-to-calendar menus stay hidden (display:grid overrode [hidden]) */
.ev-add-menu[hidden]{display:none !important}
