/**
 * Kopny Events Calendar - frontend styles.
 *
 * Everything is scoped under .kec so the plugin never restyles the theme.
 * Colours come from custom properties, so a theme can rebrand the calendar
 * by redefining them.
 */

.kec {
	--kec-accent: #4f46e5;
	--kec-accent-soft: #eef2ff;
	--kec-accent-strong: #4338ca;
	--kec-text: #1b2030;
	--kec-muted: #667085;
	--kec-border: #e4e7ee;
	--kec-surface: #ffffff;
	--kec-surface-alt: #f7f8fc;
	--kec-today: #4f46e5;
	--kec-radius: 14px;
	--kec-radius-sm: 9px;
	--kec-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);

	box-sizing: border-box;
	color: var(--kec-text);
	font-size: 16px;
	line-height: 1.6;

}

/* Themes drop the calendar straight under a page banner, so the calendar
   views bring their own breathing room. Padding rather than margin: themes
   routinely zero the first child's top margin, and padding cannot collapse
   into the surrounding content.

   This deliberately excludes .kec-single: there the block is followed by
   the event description, so a large bottom padding would open a gap in the
   middle of the page rather than at the end of it. */
.kec--month,
.kec--list,
.kec--past {
	padding-top: 32px;
	padding-bottom: 48px;
}

.kec *,
.kec *::before,
.kec *::after {
	box-sizing: inherit;
}

.kec .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.kec svg {
	width: 1em;
	height: 1em;
	flex: none;
}

/* ---------- Buttons ---------- */

.kec-btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 9px 16px;
	border: 1px solid transparent;
	border-radius: var(--kec-radius-sm);
	background: var(--kec-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.kec-btn:hover,
.kec-btn:focus {
	background: var(--kec-accent-strong);
	color: #fff;
}

.kec-btn--ghost {
	background: var(--kec-surface);
	border-color: var(--kec-border);
	color: var(--kec-text);
}

.kec-btn--ghost:hover,
.kec-btn--ghost:focus {
	background: var(--kec-surface-alt);
	border-color: #ccd2e0;
	color: var(--kec-text);
}

.kec :is(a, button, input, select):focus-visible {
	outline: 2px solid var(--kec-accent);
	outline-offset: 2px;
}

/* ---------- Toolbar: search + view switch ---------- */

.kec-toolbar {
	display: flex;
	align-items: stretch;
	gap: 14px;
	flex-wrap: wrap;
	padding: 10px;
	border: 1px solid var(--kec-border);
	border-radius: var(--kec-radius);
	background: var(--kec-surface);
	box-shadow: var(--kec-shadow);
}

.kec-toolbar__search {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 320px;
	min-width: 0;
	margin: 0;
	padding-left: 12px;
}

.kec-toolbar__icon {
	display: flex;
	color: var(--kec-muted);
	font-size: 18px;
}

.kec-toolbar__input {
	flex: 1;
	min-width: 0;
	padding: 10px 0;
	border: 0;
	outline: none;
	background: transparent;
	font-size: 15px;
	color: inherit;
}

.kec-toolbar__input::-webkit-search-cancel-button { display: none; }

.kec-btn--find { text-transform: uppercase; letter-spacing: .03em; font-size: 13px; }

.kec-viewswitch {
	display: flex;
	align-items: center;
	gap: 4px;
	padding-right: 8px;
}

.kec-viewswitch__item {
	position: relative;
	padding: 10px 12px;
	border-radius: var(--kec-radius-sm);
	color: var(--kec-muted);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.kec-viewswitch__item:hover { color: var(--kec-text); }

.kec-viewswitch__item.is-active { color: var(--kec-text); }

.kec-viewswitch__item.is-active::after {
	content: "";
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: 2px;
	height: 2px;
	border-radius: 2px;
	background: var(--kec-text);
}

/* ---------- Live search results ---------- */

.kec-searchbar__status {
	margin: 8px 2px 0;
	font-size: 13px;
	color: var(--kec-muted);
	min-height: 1.2em;
}

.kec-search-results {
	margin-top: 10px;
	border: 1px solid var(--kec-border);
	border-radius: var(--kec-radius);
	background: var(--kec-surface);
	box-shadow: var(--kec-shadow);
	overflow: hidden;
}

.kec-searchresults {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kec-searchresult {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid #f1f2f7;
}

.kec-searchresult:last-child { border-bottom: 0; }
.kec-searchresult:hover { background: var(--kec-surface-alt); }

.kec-searchresult__link {
	display: flex;
	flex-direction: column;
	gap: 2px;
	text-decoration: none;
	color: inherit;
	min-width: 0;
}

.kec-searchresult__title { font-weight: 600; color: var(--kec-accent); }

.kec-searchresult__meta {
	font-size: 13px;
	color: var(--kec-muted);
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

.kec-searchresult__cta {
	font-size: 13px;
	font-weight: 600;
	color: var(--kec-muted);
	white-space: nowrap;
}

.kec-searchresult--past .kec-searchresult__title { color: var(--kec-muted); }

.kec-searchresults__empty,
.kec-searchresults__more {
	margin: 0;
	padding: 16px;
	font-size: 14px;
	color: var(--kec-muted);
}

.kec-searchresults__more {
	border-top: 1px solid #f1f2f7;
	background: var(--kec-surface-alt);
}

/* ---------- Nav bar shared by month and list ---------- */

.kec-navbar {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 30px 0 22px;
}

.kec-navbar__arrows { display: flex; gap: 6px; }

.kec-navbar__title {
	margin: 0;
	font-size: 24px;
	font-weight: 650;
	letter-spacing: -0.01em;
	line-height: 1.2;
}

.kec-navbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--kec-radius-sm);
	background: transparent;
	color: var(--kec-text);
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}

.kec-navbtn svg { width: 20px; height: 20px; }

.kec-navbtn:hover {
	background: var(--kec-accent-soft);
	color: var(--kec-accent);
}

.kec-navbtn.is-disabled {
	color: #c3c8d4;
	cursor: default;
	pointer-events: none;
}

.kec-btn--today { padding: 7px 14px; font-size: 13px; }

/* ---------- Month grid ---------- */

.kec-calendar__body {
	position: relative;
	border: 1px solid var(--kec-border);
	border-radius: var(--kec-radius);
	background: var(--kec-surface);
	overflow: hidden;
	transition: opacity .18s ease;
}

.kec-calendar__body.is-loading {
	opacity: .45;
	pointer-events: none;
}

.kec-grid__head,
.kec-grid__week {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
}

.kec-grid__weekday {
	padding: 12px 8px;
	text-align: center;
	font-size: 12px;
	font-weight: 650;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--kec-muted);
	background: var(--kec-surface-alt);
	border-bottom: 1px solid var(--kec-border);
}

.kec-day {
	position: relative;
	min-height: 128px;
	padding: 10px;
	border-right: 1px solid #f0f1f6;
	border-bottom: 1px solid #f0f1f6;
	background: var(--kec-surface);
}

.kec-grid__week > .kec-day:last-child { border-right: 0; }
.kec-grid__week:last-child .kec-day { border-bottom: 0; }

.kec-day--outside { background: #fbfcfe; }
.kec-day--outside .kec-day__num { color: #b9bfcd; }

.kec-day__num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	margin-bottom: 7px;
	border-radius: 50%;
	font-size: 13px;
	font-weight: 600;
	color: #3b4253;
}

.kec-day--today .kec-day__num {
	background: var(--kec-today);
	color: #fff;
}

.kec-day__events {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.kec-chipevent {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 5px 8px;
	border-radius: 6px;
	background: var(--kec-accent-soft);
	border-left: 3px solid var(--kec-accent);
	color: var(--kec-accent-strong);
	font-size: 12px;
	line-height: 1.3;
	text-decoration: none;
	overflow: hidden;
}

/* The title wraps to at most two lines; narrow month cells would otherwise
   clip every event name down to a few characters. */
.kec-chipevent__title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	overflow-wrap: anywhere;
	font-weight: 550;
}

.kec-chipevent:hover {
	background: #e3e8ff;
	color: var(--kec-accent-strong);
}

.kec-chipevent__time {
	font-size: 11px;
	font-weight: 650;
	letter-spacing: .01em;
	opacity: .8;
	white-space: nowrap;
}

.kec-chipevent--allday {
	background: #fff4e6;
	border-left-color: #f59e0b;
	color: #92400e;
}

.kec-chipevent--allday:hover { background: #ffeacc; color: #92400e; }

.kec-chipevent--span:not(.kec-chipevent--start) { border-left-style: dashed; }

.kec-grid__empty {
	margin: 0;
	padding: 18px 16px;
	border-top: 1px solid var(--kec-border);
	text-align: center;
	color: var(--kec-muted);
	font-size: 14px;
}

.kec-note {
	margin: 0;
	padding: 14px 16px;
	font-size: 14px;
	color: var(--kec-muted);
}

/* ---------- List view ---------- */

.kec-list__searchnote {
	margin: -4px 0 18px;
	font-size: 14px;
	color: var(--kec-muted);
}

.kec-list__searchnote a { margin-left: 8px; color: var(--kec-accent); }

.kec-list__group { margin-bottom: 14px; }
.kec-list__group + .kec-list__group { margin-top: 18px; }

.kec-list__month {
	margin: 0 0 6px;
	padding: 12px 0;
	border-bottom: 1px solid var(--kec-border);
	font-size: 15px;
	font-weight: 650;
	letter-spacing: .01em;
	color: var(--kec-muted);
}

.kec-row {
	display: grid;
	grid-template-columns: 64px 1fr;
	gap: 0 22px;
	padding: 26px 0;
	border-bottom: 1px solid #f1f2f7;
}

.kec-row:last-child { border-bottom: 0; }

.kec-row:has(.kec-row__media) { grid-template-columns: 62px 132px 1fr; }

.kec-row__date {
	display: flex;
	flex-direction: column;
	align-items: center;
	line-height: 1.1;
	padding-top: 2px;
}

.kec-row__dow {
	font-size: 11px;
	font-weight: 650;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--kec-muted);
}

.kec-row__day {
	font-size: 28px;
	font-weight: 700;
	line-height: 1.15;
	color: var(--kec-text);
}

.kec-row__media {
	display: block;
	border-radius: var(--kec-radius-sm);
	overflow: hidden;
	background: var(--kec-surface-alt);
	align-self: start;
}

.kec-row__media img {
	display: block;
	width: 100%;
	height: 92px;
	object-fit: cover;
}

.kec-row__body { min-width: 0; }

.kec-row__when {
	margin: 0 0 6px;
	font-size: 13.5px;
	color: var(--kec-muted);
}

.kec-row__title {
	margin: 0 0 8px;
	font-size: 22px;
	line-height: 1.3;
	font-weight: 650;
}

.kec-row__title a {
	color: var(--kec-text);
	text-decoration: none;
}

.kec-row__title a:hover { color: var(--kec-accent); }

.kec-row__venue {
	margin: 0 0 8px;
	font-size: 13.5px;
	font-weight: 600;
	color: #4b5262;
}

.kec-row__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 8px;
}

.kec-row__excerpt {
	margin: 0;
	font-size: 15px;
	line-height: 1.65;
	color: #4b5262;
}

.kec-row--past .kec-row__day,
.kec-row--past .kec-row__title a { color: #51586a; }

.kec-tagchip {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--kec-accent-soft);
	color: var(--kec-accent-strong);
	font-size: 12px;
	font-weight: 600;
}

.kec-tagchip--past { background: #f1f2f7; color: var(--kec-muted); }

/* ---------- Pager ---------- */

.kec-pager {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-top: 34px;
	padding-top: 24px;
	border-top: 1px solid var(--kec-border);
}

.kec-pager__link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--kec-text);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}

.kec-pager__link:hover { color: var(--kec-accent); }

.kec-viewlinks {
	margin: 22px 0 0;
	font-size: 14px;
}

.kec-viewlinks a {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	color: var(--kec-accent);
	font-weight: 600;
	text-decoration: none;
}

.kec-viewlinks a:hover { color: var(--kec-accent-strong); }

.kec-empty {
	padding: 40px 20px;
	text-align: center;
	border: 1px dashed var(--kec-border);
	border-radius: var(--kec-radius);
	background: var(--kec-surface-alt);
}

.kec-empty__title {
	margin: 0 0 4px;
	font-size: 16px;
	font-weight: 650;
}

.kec-empty__text { margin: 0; color: var(--kec-muted); font-size: 14px; }

/* ---------- Single event ---------- */

.kec-single {
	margin-top: 24px;
	margin-bottom: 26px;
}

/* The description that follows the facts panel. */
.kec-event-description { margin-bottom: 8px; }

.kec-backlink { margin: 0 0 14px; font-size: 14px; }

.kec-backlink a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--kec-accent);
	font-weight: 600;
	text-decoration: none;
}

.kec-backlink a:hover { color: var(--kec-accent-strong); }

.kec-notice {
	margin: 0 0 16px;
	padding: 10px 14px;
	border-radius: var(--kec-radius-sm);
	font-size: 14px;
	font-weight: 600;
}

.kec-notice--past { background: var(--kec-surface-alt); color: var(--kec-muted); }
.kec-notice--live { background: #e7f8ee; color: #15803d; }

.kec-single__media {
	margin: 0 0 18px;
	border-radius: var(--kec-radius);
	overflow: hidden;
}

.kec-single__media img { display: block; width: 100%; height: auto; }

.kec-single__facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 14px;
	margin: 0 0 22px;
	padding: 18px;
	list-style: none;
	border: 1px solid var(--kec-border);
	border-radius: var(--kec-radius);
	background: var(--kec-surface-alt);
}

.kec-fact {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.kec-fact__label {
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--kec-muted);
}

.kec-fact__value {
	font-size: 15px;
	font-weight: 600;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
	.kec-day { min-height: 102px; }
	.kec-row:has(.kec-row__media) { grid-template-columns: 56px 104px 1fr; }
}

@media (max-width: 720px) {
	.kec-toolbar { padding: 10px; gap: 10px; }

	/* Let the search field keep a usable width: the buttons drop to their
	   own row rather than squeezing the input down to a few characters. */
	.kec-toolbar__search {
		flex: 1 1 100%;
		flex-wrap: wrap;
		justify-content: flex-end;
		row-gap: 10px;
		padding-left: 6px;
	}

	/* The input grows to own the first line; Clear and Find Events sit
	   together on the second, aligned right. */
	.kec-toolbar__input { flex: 1 1 150px; min-width: 150px; }

	.kec-viewswitch { width: 100%; justify-content: flex-end; padding-right: 0; }

	.kec-navbar { flex-wrap: wrap; }
	.kec-navbar__title { order: 3; width: 100%; font-size: 20px; }

	/* A seven column grid cannot stay readable on a phone, so each day
	   becomes a full width row and empty days are dropped. */
	.kec-grid__head { display: none; }
	.kec-grid__week { display: block; }

	.kec-day {
		display: flex;
		gap: 12px;
		align-items: flex-start;
		min-height: 0;
		padding: 10px 14px;
		border-right: 0;
	}

	.kec-day:not(.kec-day--has-events) { display: none; }
	.kec-day--outside.kec-day--has-events { background: var(--kec-surface); }

	.kec-day__num { margin-bottom: 0; flex: none; }
	.kec-day__events { flex: 1; min-width: 0; gap: 5px; }

	.kec-chipevent {
		flex-direction: row;
		gap: 8px;
		align-items: baseline;
		padding: 7px 10px;
		font-size: 13.5px;
	}

	.kec-chipevent__title { -webkit-line-clamp: 3; line-clamp: 3; }

	.kec-grid__week:last-child .kec-day { border-bottom: 1px solid #f0f1f6; }

	.kec-row,
	.kec-row:has(.kec-row__media) {
		grid-template-columns: 48px 1fr;
		gap: 0 14px;
	}

	.kec-row__media {
		grid-column: 1 / -1;
		margin-top: 12px;
	}

	.kec-row__media img { height: 170px; }

	.kec-row__title { font-size: 18px; }
	.kec-row__day { font-size: 22px; }

	.kec-searchresult { flex-direction: column; align-items: flex-start; gap: 4px; }
	.kec-searchresult__cta { display: none; }

	.kec-pager { flex-direction: column; align-items: stretch; gap: 10px; }
	.kec-pager__link--next { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
	.kec * {
		transition: none !important;
		animation: none !important;
	}
}

/* Clear button inside the toolbar search field. */
.kec-toolbar__clear {
	padding: 7px 12px;
	border: 0;
	border-radius: 999px;
	background: var(--kec-surface-alt);
	color: var(--kec-muted);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
}

.kec-toolbar__clear:hover { background: #edeff6; color: var(--kec-text); }

/* ---------- Month / year picker ---------- */

.kec-picker { position: relative; }

.kec-picker__toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 6px 2px 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
	border-radius: var(--kec-radius-sm);
}

.kec-picker__toggle:hover .kec-navbar__title { color: var(--kec-accent); }

.kec-picker__caret {
	width: 20px;
	height: 20px;
	color: var(--kec-muted);
	transition: transform .15s ease;
}

.kec-picker.is-open .kec-picker__caret { transform: rotate(180deg); }

.kec-picker__panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	z-index: 30;
	width: 268px;
	padding: 12px;
	border: 1px solid var(--kec-border);
	border-radius: var(--kec-radius);
	background: var(--kec-surface);
	box-shadow: 0 8px 28px rgba(16, 24, 40, .14);
}

.kec-picker__panel[hidden] { display: none; }

.kec-picker__year {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 8px;
}

.kec-picker__yearlabel {
	font-size: 15px;
	font-weight: 650;
}

.kec-navbtn--sm {
	width: 28px;
	height: 28px;
}

.kec-navbtn--sm svg { width: 16px; height: 16px; }

.kec-picker__months {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 4px;
}

.kec-picker__month {
	padding: 9px 4px;
	border: 1px solid transparent;
	border-radius: var(--kec-radius-sm);
	background: transparent;
	color: var(--kec-text);
	font-size: 12.5px;
	font-weight: 600;
	letter-spacing: .03em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background .12s ease, color .12s ease;
}

.kec-picker__month:hover {
	background: var(--kec-accent-soft);
	color: var(--kec-accent-strong);
}

.kec-picker__month.is-current {
	background: var(--kec-accent);
	border-color: var(--kec-accent);
	color: #fff;
}

@media (max-width: 720px) {
	.kec-picker { width: 100%; }
	.kec-picker__panel { width: min(100%, 300px); }
}

/* ---------- Theme interference guards ----------
   Themes commonly uppercase headings and restyle every button on the page.
   These rules keep the calendar's own typography intact without using
   !important anywhere outside this block. */

.kec .kec-navbar__title,
.kec .kec-btn,
.kec .kec-viewswitch__item,
.kec .kec-row__title,
.kec .kec-list__month,
.kec .kec-picker__yearlabel,
.kec .kec-pager__link {
	text-transform: none !important;
	letter-spacing: normal;
}

.kec .kec-btn--find { text-transform: uppercase !important; letter-spacing: .03em; }

.kec .kec-picker__month,
.kec .kec-grid__weekday,
.kec .kec-row__dow,
.kec .kec-fact__label {
	text-transform: uppercase !important;
}

/* Buttons the theme would otherwise paint over. */
.kec button.kec-navbtn,
.kec button.kec-picker__toggle,
.kec button.kec-picker__month,
.kec button.kec-toolbar__clear {
	box-shadow: none;
	text-shadow: none;
	min-height: 0;
	line-height: 1.2;
}

.kec .kec-picker__toggle { font: inherit; }

/* Woodmart sets order: 3 on elements matching our title class, which flips
   the caret in front of the month label. Pin the order explicitly. */
.kec .kec-picker__toggle .kec-navbar__title { order: 0 !important; }
.kec .kec-picker__toggle .kec-picker__caret { order: 1 !important; }

.kec .kec-navbar__title { font-weight: 650; }

/* Some themes force list markers and padding onto every ul. */
.kec .kec-day__events,
.kec .kec-searchresults,
.kec .kec-single__facts,
.kec .kec-meta {
	list-style: none;
	padding-left: 0;
	margin-left: 0;
}

.kec .kec-pagination ul { list-style: none; padding-left: 0; }
