/*
 * Church Calendar for Tithe.ly
 *
 * Branding lives in one place: the --tc-accent variable, which the plugin
 * writes inline on .tc-wrap from the setting in Settings > Church Calendar.
 * Everything below is derived from it, so there is normally nothing to edit
 * in this file.
 */

.tc-wrap {
	/* Set inline by PHP. These are only the fallbacks. */
	--tc-accent: #2f5d62;
	--tc-accent-text: #ffffff;

	/* Map the brand colour onto FullCalendar's own variables. */
	--fc-button-bg-color: var(--tc-accent);
	--fc-button-border-color: var(--tc-accent);
	--fc-button-text-color: var(--tc-accent-text);
	--fc-button-hover-bg-color: var(--tc-accent);
	--fc-button-hover-border-color: var(--tc-accent);
	--fc-button-active-bg-color: var(--tc-accent);
	--fc-button-active-border-color: var(--tc-accent);

	--fc-event-bg-color: var(--tc-accent);
	--fc-event-border-color: var(--tc-accent);
	--fc-event-text-color: var(--tc-accent-text);

	--fc-now-indicator-color: #c0392b;
	--fc-border-color: rgba(0, 0, 0, 0.12);
	--fc-today-bg-color: rgba(0, 0, 0, 0.04);
	--fc-highlight-color: rgba(0, 0, 0, 0.06);
	--fc-list-event-hover-bg-color: rgba(0, 0, 0, 0.04);
	--fc-small-font-size: 0.8em;

	font-family: inherit;
	position: relative;
}

/* Progressive enhancement: derive proper hover and tint shades where the
   browser supports colour mixing. Older browsers keep the flat fallbacks. */
@supports (color: color-mix(in srgb, red 50%, blue)) {
	.tc-wrap {
		--fc-button-hover-bg-color: color-mix(in srgb, var(--tc-accent) 84%, #000);
		--fc-button-hover-border-color: color-mix(in srgb, var(--tc-accent) 84%, #000);
		--fc-button-active-bg-color: color-mix(in srgb, var(--tc-accent) 72%, #000);
		--fc-button-active-border-color: color-mix(in srgb, var(--tc-accent) 72%, #000);
		--fc-today-bg-color: color-mix(in srgb, var(--tc-accent) 9%, transparent);
		--fc-highlight-color: color-mix(in srgb, var(--tc-accent) 14%, transparent);
		--fc-list-event-hover-bg-color: color-mix(in srgb, var(--tc-accent) 7%, transparent);
	}
}

/* ------------------------------------------------------------------
 * Neutralise the table and button styling most WordPress themes apply
 * ---------------------------------------------------------------- */

.tc-wrap .fc table {
	margin: 0;
	border: 0;
	font-size: inherit;
}

.tc-wrap .fc th,
.tc-wrap .fc td {
	background-image: none;
	vertical-align: top;
}

.tc-wrap .fc tbody tr:nth-child(odd) td,
.tc-wrap .fc tbody tr:nth-child(even) td,
.tc-wrap .fc tbody tr:nth-child(odd) th,
.tc-wrap .fc tbody tr:nth-child(even) th {
	background-color: transparent;
}

/* Put the highlights back after that reset. */
.tc-wrap .fc tbody tr td.fc-day-today,
.tc-wrap .fc tbody tr th.fc-day-today,
.tc-wrap .fc .fc-daygrid-day.fc-day-today,
.tc-wrap .fc .fc-timegrid-col.fc-day-today {
	background-color: var(--fc-today-bg-color);
}

.tc-wrap .fc a {
	box-shadow: none;
	text-decoration: none;
}

.tc-wrap .fc a:hover {
	text-decoration: none;
}

.tc-wrap .fc .fc-col-header-cell-cushion,
.tc-wrap .fc .fc-daygrid-day-number,
.tc-wrap .fc .fc-list-day-text,
.tc-wrap .fc .fc-list-day-side-text {
	color: inherit;
}

/* ------------------------------------------------------------------
 * Toolbar
 * ---------------------------------------------------------------- */

.tc-wrap .fc .fc-toolbar {
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 1em;
}

.tc-wrap .fc .fc-toolbar-title {
	font-family: inherit;
	font-size: 1.35rem;
	font-weight: 600;
	line-height: 1.25;
	margin: 0;
}

.tc-wrap .fc .fc-button {
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	border-radius: 6px;
	padding: 0.45em 0.85em;
	line-height: 1.45;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tc-wrap .fc .fc-button:focus,
.tc-wrap .fc .fc-button:focus-visible {
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.18);
	outline: 2px solid transparent;
	outline-offset: 2px;
}

.tc-wrap .fc .fc-button-primary:disabled {
	opacity: 0.5;
}

.tc-wrap .fc .fc-button-group > .fc-button:not(:first-child) {
	margin-left: -1px;
}

/* ------------------------------------------------------------------
 * Events
 * ---------------------------------------------------------------- */

.tc-wrap .fc .fc-event {
	border-radius: 4px;
	cursor: pointer;
	font-size: 0.8125rem;
}

.tc-wrap .fc .fc-event:focus-visible {
	outline: 2px solid var(--tc-accent);
	outline-offset: 2px;
}

/*
 * Month cells are narrow. Titles must stay on one line and trail off with an
 * ellipsis rather than breaking mid-word, which is unreadable.
 */
.tc-wrap .fc .fc-daygrid-event {
	padding: 2px 4px;
	white-space: nowrap;
	overflow: hidden;
	border-radius: 3px;
}

.tc-wrap .fc .fc-daygrid-event .fc-event-title,
.tc-wrap .fc .fc-daygrid-event .fc-event-title-container {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
	word-break: normal;
	overflow-wrap: normal;
	hyphens: none;
}

.tc-wrap .fc .fc-event-title {
	font-weight: 400;
}

/* Timed events: coloured dot, bold compact time, then the title. */
.tc-wrap .fc .fc-daygrid-dot-event {
	align-items: baseline;
	background: transparent;
	border: 0;
	padding: 2px 4px;
	gap: 5px;
}

.tc-wrap .fc .fc-daygrid-dot-event:hover,
.tc-wrap .fc .fc-daygrid-dot-event.fc-event-mirror {
	background: rgba(0, 0, 0, 0.05);
}

.tc-wrap .fc .fc-daygrid-dot-event .fc-event-time {
	font-weight: 700;
	flex: 0 0 auto;
	opacity: 0.85;
}

.tc-wrap .fc .fc-daygrid-dot-event .fc-event-title {
	font-weight: 400;
	flex: 1 1 auto;
}

.tc-wrap .fc .fc-daygrid-event-dot {
	border-width: 4px;
	margin: 0 1px 0 0;
	flex: 0 0 auto;
}

/* All-day and multi-day items sit as soft tinted bars, not solid blocks. */
.tc-wrap .fc .fc-daygrid-block-event {
	background: rgba(0, 0, 0, 0.055);
	color: inherit;
	border-left: 3px solid var(--fc-event-border-color);
	border-top: 0;
	border-right: 0;
	border-bottom: 0;
	border-radius: 2px;
	margin-bottom: 1px;
}

.tc-wrap .fc .fc-daygrid-block-event .fc-event-main,
.tc-wrap .fc .fc-daygrid-block-event .fc-event-title,
.tc-wrap .fc .fc-daygrid-block-event .fc-event-time {
	color: inherit;
	font-weight: 500;
	padding: 1px 5px;
}

.tc-wrap .fc .fc-daygrid-day-frame {
	min-height: 96px;
}

.tc-wrap .fc .fc-daygrid-day-events {
	margin-bottom: 2px;
}

.tc-wrap .fc .fc-list-event-title a {
	font-weight: 500;
}

.tc-wrap .fc .fc-list-event:hover td {
	background-color: var(--fc-list-event-hover-bg-color);
}

.tc-wrap .fc .fc-list-day-cushion {
	background-color: rgba(0, 0, 0, 0.035);
}

.tc-wrap .fc .fc-list-empty {
	background-color: transparent;
	padding: 2.5em 1em;
	color: inherit;
	opacity: 0.7;
}

/* Multi-month (year) view breathing room. */
.tc-wrap .fc .fc-multimonth-title {
	font-family: inherit;
	font-weight: 600;
}

.tc-wrap .fc .fc-multimonth {
	border: 0;
}

/* Calendar legend, shown when more than one feed is configured. */
.tc-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 14px;
}

.tc-legend__item {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	background: transparent;
	border: 1px solid var(--fc-border-color);
	border-radius: 999px;
	padding: 6px 14px 6px 11px;
	font: inherit;
	font-size: 0.85rem;
	line-height: 1.3;
	color: inherit;
	cursor: pointer;
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	min-height: 36px;
	transition: opacity 0.15s ease, border-color 0.15s ease;
}

.tc-legend__item:not(.is-on) {
	opacity: 0.45;
	text-decoration: line-through;
}

.tc-legend__item:focus-visible {
	outline: 2px solid var(--tc-accent);
	outline-offset: 2px;
}

.tc-legend__dot {
	width: 11px;
	height: 11px;
	border-radius: 50%;
	flex: 0 0 auto;
}

@media (max-width: 782px) {
	.tc-legend__item {
		min-height: 40px;
		font-size: 0.8rem;
	}
}

/* Server-rendered list, shown only when the calendar script cannot run. */
.tc-fallback__title {
	font-family: inherit;
	font-size: 1.15rem;
	margin: 0 0 12px;
}

.tc-fallback__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tc-fallback__item {
	padding: 12px 0;
	border-bottom: 1px solid var(--fc-border-color);
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tc-fallback__when {
	font-weight: 600;
	color: var(--tc-accent);
	font-size: 0.9rem;
}

.tc-fallback__what {
	font-size: 1rem;
}

.tc-fallback__where {
	font-size: 0.88rem;
	opacity: 0.75;
}

/* Administrator-only feed warning. */
.tc-admin-notice {
	background: #fff6e5;
	border-left: 4px solid #d99b1c;
	padding: 10px 14px;
	margin: 0 0 1em;
	font-size: 0.9rem;
}

/* ------------------------------------------------------------------
 * Mobile
 * ---------------------------------------------------------------- */

@media (max-width: 782px) {

	.tc-wrap .fc .fc-toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}

	.tc-wrap .fc .fc-toolbar-chunk {
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
		gap: 6px;
	}

	/* Title reads first, then navigation, then the view switcher. */
	.tc-wrap .fc .fc-toolbar-chunk:nth-child(2) {
		order: -1;
	}

	.tc-wrap .fc .fc-toolbar-title {
		font-size: 1.2rem;
		text-align: center;
	}

	.tc-wrap .fc .fc-button {
		min-height: 42px;
		padding: 0.5em 0.75em;
		font-size: 0.8125rem;
	}

	.tc-wrap .fc .fc-daygrid-day-number {
		font-size: 0.8125rem;
		padding: 3px 4px;
	}

	.tc-wrap .fc .fc-col-header-cell-cushion {
		font-size: 0.75rem;
		padding: 6px 2px;
	}

	.tc-wrap .fc .fc-event {
		font-size: 0.75rem;
	}

	.tc-wrap .fc .fc-daygrid-day-frame {
		min-height: 52px;
	}

	/*
	 * Seven columns on a phone leaves about 50px per day, which is not enough
	 * for a title. Month view becomes a dot overview: tap a dot for the event,
	 * or tap the date number to open that day. Agenda view carries the detail.
	 */
	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-dot-event .fc-event-time,
	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-dot-event .fc-event-title,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-dot-event .fc-event-time,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-dot-event .fc-event-title {
		display: none;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-dot-event,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-dot-event {
		padding: 3px;
		justify-content: center;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-day-events,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-day-events {
		text-align: center;
		min-height: 0;
	}

	/*
	 * Only the inline dot harnesses become inline-block. All-day bars use
	 * .fc-daygrid-event-harness-abs and are positioned absolutely across the
	 * week row, so changing their display makes them spill into the
	 * neighbouring days.
	 */
	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-event-harness:not(.fc-daygrid-event-harness-abs),
	.tc-wrap .fc .fc-multimonth .fc-daygrid-event-harness:not(.fc-daygrid-event-harness-abs) {
		display: inline-block;
		vertical-align: middle;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-event-harness-abs,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-event-harness-abs {
		text-align: left;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-event-dot,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-event-dot {
		margin: 0;
		border-width: 4px;
	}

	/* All-day bars stay as bars, but must not spill out of a 50px cell. */
	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-block-event,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-block-event {
		max-width: 100%;
		overflow: hidden;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-block-event .fc-event-main,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-block-event .fc-event-main {
		overflow: hidden;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-block-event .fc-event-title,
	.tc-wrap .fc .fc-multimonth .fc-daygrid-block-event .fc-event-title {
		font-size: 0.62rem;
		padding: 0 3px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		display: block;
		max-width: 100%;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-day-top {
		justify-content: center;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-day-number {
		float: none;
		text-align: center;
		padding: 4px 2px 2px;
	}

	.tc-wrap .fc .fc-dayGridMonth-view .fc-daygrid-more-link {
		font-size: 0.65rem;
	}

	/* Keep "10:00am - 11:30am" on one line instead of breaking at the dash. */
	.tc-wrap .fc .fc-list-event-time {
		white-space: nowrap;
		font-size: 0.78rem;
		padding-right: 10px;
	}

	.tc-wrap .fc .fc-list-event-title {
		font-size: 0.88rem;
	}

	.tc-wrap .fc .fc-list-day-cushion {
		padding: 8px 10px;
	}
}

@media (max-width: 420px) {
	.tc-wrap .fc .fc-toolbar-title {
		font-size: 1.05rem;
	}
	.tc-wrap .fc .fc-button {
		font-size: 0.75rem;
		padding: 0.5em 0.6em;
	}
}

/* ------------------------------------------------------------------
 * Event details panel
 * ---------------------------------------------------------------- */

.tc-modal[hidden] {
	display: none;
}

.tc-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: rgba(17, 17, 17, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

body.tc-modal-open {
	overflow: hidden;
}

.tc-modal__dialog {
	background: #fff;
	color: #1c1c1c;
	border-radius: 10px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
	max-width: 520px;
	width: 100%;
	max-height: 85vh;
	overflow-y: auto;
	padding: 26px 26px 24px;
	position: relative;
	font-family: inherit;
}

@media (prefers-reduced-motion: no-preference) {
	.tc-modal__dialog {
		animation: tc-modal-in 0.16s ease-out;
	}
}

@keyframes tc-modal-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Themes style every button and link on the page. Keep them out of here. */
.tc-modal button,
.tc-modal a {
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	text-decoration: none;
	font-family: inherit;
}

.tc-modal__close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: transparent;
	border: 0;
	font-size: 26px;
	line-height: 1;
	padding: 6px 10px;
	cursor: pointer;
	color: #666;
	border-radius: 6px;
}

.tc-modal__close:hover {
	color: #111;
	background: rgba(0, 0, 0, 0.06);
}

.tc-modal__close:focus-visible {
	outline: 2px solid var(--tc-accent, #2f5d62);
	outline-offset: 2px;
}

.tc-modal__title {
	margin: 0 34px 8px 0;
	font-size: 1.3rem;
	line-height: 1.3;
	font-weight: 600;
	color: inherit;
}

.tc-modal__when {
	margin: 0 0 4px;
	font-weight: 600;
	color: var(--tc-accent, #2f5d62);
	font-size: 0.95rem;
}

.tc-modal__where {
	margin: 0 0 12px;
	color: #555;
	font-size: 0.92rem;
}

.tc-modal__body {
	margin: 0 0 16px;
	white-space: pre-wrap;
	line-height: 1.6;
	font-size: 0.95rem;
	color: #333;
	word-break: break-word;
}

.tc-modal__link {
	display: inline-block;
	background: var(--tc-accent, #2f5d62);
	color: var(--tc-accent-text, #fff);
	padding: 10px 18px;
	border-radius: 6px;
	font-weight: 500;
	text-decoration: none;
	font-size: 0.9rem;
}

.tc-modal__link:hover,
.tc-modal__link:focus {
	color: var(--tc-accent-text, #fff);
	text-decoration: none;
	opacity: 0.9;
}

/* ------------------------------------------------------------------
 * Print
 * ---------------------------------------------------------------- */

@media print {

	.tc-wrap .fc .fc-toolbar .fc-button-group,
	.tc-wrap .fc .fc-today-button {
		display: none !important;
	}

	.tc-wrap {
		--fc-border-color: #999;
		--fc-event-bg-color: #fff;
		--fc-event-border-color: #333;
		--fc-event-text-color: #000;
		--fc-today-bg-color: transparent;
	}

	.tc-wrap .fc .fc-event {
		border: 1px solid #333;
	}

	.tc-modal {
		display: none !important;
	}
}
