/**
 * Google Calendar Events - front end styles.
 *
 * Everything is scoped under .gce. Colours come in through custom properties
 * set inline by the shortcode, so one stylesheet serves every accent colour.
 *
 * Divi note: the theme sets global bottom margins on p, ul and li, and a
 * global line-height. Those are neutralised locally, never globally.
 */

.gce {
	--gce-ease: cubic-bezier(0.23, 1, 0.32, 1);
	--gce-accent: #4aa8c8;
	--gce-accent-contrast: #ffffff;
	--gce-radius: 8px;
	--gce-columns: 3;

	/* Neutrals are derived from the theme's own text colour rather than being
	   hard-coded, so the widget reads correctly on a light or a dark page
	   without guessing at the visitor's system preference. */
	--gce-line: oklch(0.5 0 0 / 0.22);

	box-sizing: border-box;
	color: inherit;
	font-family: var(--gce-font, inherit);
	font-size: 16px;
	line-height: 1.45;
	max-width: 100%;
}

@supports (color: color-mix(in oklab, currentColor 20%, transparent)) {
	.gce {
		--gce-line: color-mix(in oklab, currentColor 22%, transparent);
	}
}

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

/* Divi and most themes add bottom margins we do not want inside the widget. */
.gce p,
.gce ul,
.gce ol,
.gce li,
.gce h2,
.gce h3,
.gce h4 {
	margin: 0;
	padding: 0;
}

.gce ul,
.gce ol {
	list-style: none;
}

.gce a {
	color: inherit;
}

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

.gce-icon {
	flex: 0 0 auto;
	vertical-align: -0.15em;
}

/* ---------------------------------------------------------------------------
 * Scroll container and month headings
 * ------------------------------------------------------------------------ */

.gce-scroll--capped {
	max-height: var(--gce-height, 420px);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding-right: 4px;
}

.gce-month {
	color: var(--gce-month-color, inherit);
	font-family: var(--gce-month-font, inherit);
	font-size: var(--gce-month-size, 1.5rem);
	font-weight: var(--gce-month-weight, 800);
	letter-spacing: -0.01em;
	text-transform: var(--gce-month-transform, uppercase);
	text-wrap: balance;
	margin: 1.25rem 0 0.75rem;
}

.gce-scroll > .gce-month:first-child,
.gce-cards > .gce-month:first-child {
	margin-top: 0;
}

.gce-empty {
	opacity: 0.7;
	padding: 1rem 0;
}

/* ---------------------------------------------------------------------------
 * Event bar
 * ------------------------------------------------------------------------ */

.gce-event {
	background: var(--gce-accent);
	color: var(--gce-accent-contrast);
	border-radius: var(--gce-radius);
	margin-bottom: 0.65rem;
	overflow: hidden;
}

.gce-event:last-child {
	margin-bottom: 0;
}

.gce-event__main {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.85rem 1.15rem;
}

.gce-event--expandable .gce-event__main {
	cursor: pointer;
}

.gce-date {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: var(--gce-date-color, inherit);
	font-family: var(--gce-date-font, inherit);
	/* One size drives the whole block: the day number and the two small
	   labels are sized in em relative to this. */
	font-size: var(--gce-date-size, clamp(0.78rem, 0.58vw + 0.6rem, 1.02rem));
	line-height: 1;
	min-width: 3.3rem;
	padding-right: 1rem;
	border-right: 1px solid rgba(255, 255, 255, 0.28);
	text-transform: uppercase;
}

.gce-date__weekday,
.gce-date__month {
	font-size: 0.7em;
	font-weight: 700;
	letter-spacing: 0.05em;
	opacity: 0.85;
}

.gce-date__day {
	font-size: 2.05em;
	font-weight: 800;
	letter-spacing: -0.03em;
	margin: 0.09em 0;
}

.gce-event__body {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3rem 0.9rem;
	flex: 1 1 auto;
	min-width: 0;
}

.gce-title {
	flex: 1 0 100%;
	color: var(--gce-title-color, inherit);
	font-family: var(--gce-title-font, inherit);
	font-size: var(--gce-title-size, clamp(1.05rem, 0.85vw + 0.85rem, 1.45rem));
	font-weight: var(--gce-title-weight, 800);
	letter-spacing: -0.01em;
	line-height: 1.2;
	text-transform: var(--gce-title-transform, uppercase);
	text-wrap: balance;
	/* break-word, not anywhere: inside a flex row "anywhere" lets the title
	   shrink below the width of its longest word, which chops names like
	   GOTTESDIENST in half. */
	overflow-wrap: break-word;
}

.gce-meta {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	color: var(--gce-meta-color, inherit);
	font-size: var(--gce-meta-size, 0.94rem);
	min-width: 0;
}

.gce-meta--tz {
	opacity: 0.72;
	font-size: 0.85rem;
}

.gce-meta--location a {
	text-decoration: underline;
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
	overflow-wrap: anywhere;
}

.gce-excerpt {
	flex: 1 0 100%;
	font-size: 0.92rem;
	opacity: 0.9;
}

.gce-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	padding: 0.2em 0.55em;
	border-radius: calc(var(--gce-radius) / 2);
	background: rgba(255, 255, 255, 0.2);
}

.gce-button,
.gce-link {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	font-size: 0.88rem;
	font-weight: 600;
	text-decoration: none;
	border-radius: calc(var(--gce-radius) / 1.5);
	transition: opacity 160ms var(--gce-ease), transform 160ms var(--gce-ease);
}

.gce-button {
	background: rgba(255, 255, 255, 0.2);
	padding: 0.35em 0.75em;
}

.gce-link {
	text-decoration: underline;
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

.gce-button:hover,
.gce-link:hover {
	opacity: 0.82;
}

.gce-button:active,
.gce-link:active {
	transform: scale(0.97);
}

.gce-attachments {
	flex: 1 0 100%;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 0.9rem;
}

.gce-attachments a {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	font-size: 0.88rem;
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

.gce-image {
	flex: 1 0 100%;
	border-radius: calc(var(--gce-radius) / 1.5);
	overflow: hidden;
}

.gce-image img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
}

/* Expand toggle */

.gce-toggle {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	color: inherit;
	cursor: pointer;
	font-size: 1rem;
	transition: transform 200ms var(--gce-ease), background-color 160ms var(--gce-ease);
}

.gce-toggle:hover {
	background: rgba(255, 255, 255, 0.28);
}

.gce-toggle:active {
	transform: scale(0.97);
}

.gce-toggle[aria-expanded="true"] {
	transform: rotate(180deg);
}

.gce-toggle[aria-expanded="true"]:active {
	transform: rotate(180deg) scale(0.97);
}

.gce-event__panel {
	/* Stacked, so the description, the location and any buttons each get
	   their own line instead of running together. */
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.55rem;
	padding: 0 1.15rem 1rem;
	font-size: 0.94rem;
}

.gce-event__panel > .gce-description,
.gce-event__panel > .gce-image,
.gce-event__panel > .gce-attachments {
	width: 100%;
}


.gce-event__panel[hidden] {
	display: none;
}

.gce-event__panel .gce-meta,
.gce-event__panel .gce-link,
.gce-event__panel .gce-button {
	font-size: 0.92rem;
}

.gce-description > p {
	margin-bottom: 0.6em;
}

.gce-description > p:last-child {
	margin-bottom: 0;
}

.gce-event__panel a {
	text-decoration: underline;
	text-underline-offset: 0.18em;
	overflow-wrap: anywhere;
}

.gce-event__panel img {
	max-width: 100%;
	height: auto;
	border-radius: calc(var(--gce-radius) / 1.5);
}

.gce-event--open .gce-event__panel {
	animation: gce-slide-in 220ms var(--gce-ease);
}

@keyframes gce-slide-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ---------------------------------------------------------------------------
 * Compact list
 * ------------------------------------------------------------------------ */

.gce-upcoming__list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.gce-event--compact {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem 0.85rem;
	margin-bottom: 0;
}

.gce-event--compact .gce-title {
	font-size: 1rem;
}

.gce-event--compact .gce-date {
	min-width: 2.6rem;
	padding-right: 0.7rem;
	font-size: var(--gce-date-size, 0.72rem);
}

/* ---------------------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------------------ */

.gce-cards__grid {
	display: grid;
	grid-template-columns: repeat(var(--gce-columns), minmax(0, 1fr));
	gap: 1rem;
}

.gce-card {
	background: var(--gce-accent);
	color: var(--gce-accent-contrast);
	border-radius: var(--gce-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.gce-card .gce-image {
	border-radius: 0;
	aspect-ratio: 16 / 9;
}

.gce-card .gce-image img {
	height: 100%;
	object-fit: cover;
}

.gce-card__inner {
	display: flex;
	align-items: flex-start;
	gap: 0.85rem;
	padding: 0.9rem 1rem;
	flex: 1 1 auto;
}

.gce-card .gce-date {
	border-right: 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.28);
	padding: 0 0 0.4rem;
	min-width: 2.9rem;
}

@media (max-width: 900px) {
	.gce-cards__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

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

.gce-monthnav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.85rem;
}

.gce-monthnav__title {
	color: var(--gce-month-color, inherit);
	font-family: var(--gce-month-font, inherit);
	font-size: var(--gce-month-size, 1.35rem);
	font-weight: var(--gce-month-weight, 800);
	letter-spacing: -0.01em;
	text-transform: var(--gce-month-transform, uppercase);
	text-align: center;
	flex: 1 1 auto;
}

.gce-monthnav__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	border: 1px solid var(--gce-line);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	font-size: 1rem;
	transition: background-color 160ms var(--gce-ease), transform 160ms var(--gce-ease);
}

.gce-monthnav__button:hover {
	background: var(--gce-accent);
	border-color: var(--gce-accent);
	color: var(--gce-accent-contrast);
}

.gce-monthnav__button:active {
	transform: scale(0.97);
}

.gce-grid__head,
.gce-grid__body {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 4px;
}

.gce-grid__weekday {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	opacity: 0.65;
	text-align: center;
	padding-bottom: 0.35rem;
}

.gce-cell {
	min-height: 5.25rem;
	padding: 0.35rem;
	border: 1px solid var(--gce-line);
	border-radius: calc(var(--gce-radius) / 1.5);
	background: transparent;
}

.gce-cell--empty {
	border-color: transparent;
	background: transparent;
}

.gce-cell__day {
	display: block;
	font-size: 0.78rem;
	font-weight: 700;
	opacity: 0.65;
	margin-bottom: 0.25rem;
}

.gce-cell--today .gce-cell__day {
	color: var(--gce-accent-contrast);
	background: var(--gce-accent);
	opacity: 1;
	width: 1.55em;
	height: 1.55em;
	line-height: 1.55em;
	text-align: center;
	border-radius: 50%;
}

.gce-chips {
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.gce-chip {
	display: block;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1.25;
	padding: 0.2rem 0.35rem;
	border-radius: 4px;
	background: var(--gce-accent);
	color: var(--gce-accent-contrast);
	text-decoration: none;
	transition: opacity 160ms var(--gce-ease), transform 160ms var(--gce-ease);
}

.gce-chip:hover {
	opacity: 0.85;
}

.gce-chip:active {
	transform: scale(0.97);
}

.gce-chip__time {
	display: block;
	opacity: 0.85;
	font-size: 0.68rem;
}

.gce-chip__title {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.gce-month-list {
	margin-top: 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
}

.gce-month-list .gce-event {
	margin-bottom: 0;
	scroll-margin-top: 5rem;
}

.gce-event--highlight {
	animation: gce-pulse 600ms var(--gce-ease);
}

@keyframes gce-pulse {
	0% {
		transform: scale(1);
	}
	40% {
		transform: scale(1.015);
	}
	100% {
		transform: scale(1);
	}
}

.gce-is-loading {
	opacity: 0.55;
	transition: opacity 160ms var(--gce-ease);
}

/* ---------------------------------------------------------------------------
 * Small screens
 * ------------------------------------------------------------------------ */

@media (max-width: 640px) {
	.gce-cards__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.gce-event__main {
		padding: 0.65rem 0.75rem;
		gap: 0.7rem;
	}

	.gce-title {
		font-size: var(--gce-title-size, 1rem);
	}

	.gce-date {
		min-width: 2.7rem;
		padding-right: 0.7rem;
		font-size: var(--gce-date-size, 0.74rem);
	}

	.gce-cell {
		min-height: 3.75rem;
		padding: 0.25rem;
	}

	.gce-chip__title {
		display: none;
	}

	.gce-chip {
		text-align: center;
	}
}

/* ---------------------------------------------------------------------------
 * Reduced motion
 * ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.gce *,
	.gce *::before,
	.gce *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.gce-toggle:active,
	.gce-button:active,
	.gce-link:active,
	.gce-chip:active,
	.gce-monthnav__button:active {
		transform: none;
	}

	.gce-toggle[aria-expanded="true"]:active {
		transform: rotate(180deg);
	}
}
