/* Calendario Chiesa Gospel - public views. Scoped under .cgev-cal; reuses the theme tokens when present. */
.cgev-cal {
	--cgev-ink: var(--cg-ink, #101010);
	--cgev-paper: var(--cg-paper, #f4f4f4);
	--cgev-blue: var(--cg-blue, #0038ff);
	--cgev-navy: var(--cg-navy, #0a1a4f);
	--cgev-ice: var(--cg-ice, #dbe7ff);
	--cgev-muted: #4a4a4a;
	--cgev-line: #d6d6d6;
	--cgev-sans: var(--cg-sans, "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif);
	--cgev-serif: var(--cg-serif, "Instrument Serif", "Times New Roman", serif);
	--cgev-ease: var(--cg-ease, cubic-bezier(.22, .7, .2, 1));
	box-sizing: border-box;
	color: var(--cgev-ink);
	font-family: var(--cgev-sans);
	font-size: 1.0625rem;
	line-height: 1.4;
	max-width: 1264px;
	margin-inline: auto;
	transition: opacity .2s var(--cgev-ease);
}
/* Block themes cap page content at the narrow "content" width: the calendar uses the wide one. */
:where(.is-layout-constrained, .entry-content) > .cgev-cal.cgev-cal {
	max-width: var(--wp--style--global--wide-size, 1264px);
	width: 100%;
}
.cgev-cal *, .cgev-cal *::before, .cgev-cal *::after { box-sizing: border-box; }
.cgev-cal.is-loading { opacity: .55; }
.cgev-cal :where(p, ul, h2, h3) { margin: 0; padding: 0; }
.cgev-cal ul { list-style: none; }
.cgev-cal .screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.cgev-cal :focus-visible {
	outline: 3px solid var(--cgev-blue);
	outline-offset: 3px;
	box-shadow: 0 0 0 6px #fff;
}

/* Headings: condensed uppercase sans, like the theme. */
.cgev-title {
	font-family: var(--cgev-sans);
	font-weight: 800;
	font-stretch: 62%;
	font-variation-settings: "wdth" 62;
	text-transform: uppercase;
	line-height: .95;
	letter-spacing: -.01em;
	font-size: clamp(2rem, 6vw, 3.25rem);
	margin: 0;
}
.cgev-title--plain { margin-bottom: 16px; }
.cgev-title:focus { outline: none; }
.cgev-title:focus-visible { outline: 3px solid var(--cgev-blue); }

/* Buttons (theme pills). */
.cgev-cal .cgev-btn,
.cgev-cal select {
	min-height: 48px;
	padding: 0 20px;
	border: 2px solid var(--cgev-ink);
	border-radius: 999px;
	background: #fff;
	color: var(--cgev-ink);
	font: 700 .875rem/1 var(--cgev-sans);
	letter-spacing: .06em;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background .25s var(--cgev-ease), color .25s var(--cgev-ease), transform .25s var(--cgev-ease);
}
.cgev-cal select { padding-right: 36px; text-transform: none; letter-spacing: 0; font-size: 1rem; font-weight: 600; }
.cgev-cal .cgev-btn:hover { background: var(--cgev-ink); color: #fff; }
.cgev-cal .cgev-btn:active { transform: scale(.97); }
.cgev-cal .cgev-btn--primary { background: var(--cgev-blue); border-color: var(--cgev-blue); color: #fff; }
.cgev-cal .cgev-btn--primary:hover { background: var(--cgev-ink); border-color: var(--cgev-ink); }
.cgev-cal .cgev-btn--small { min-height: 40px; padding: 0 16px; border-width: 1px; border-color: var(--cgev-line); font-size: .8125rem; }

/* Top bar: search + Lista / Mese tabs. */
.cgev-toolbar {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
	border: 1px solid var(--cgev-line); background: #fff; padding: 12px 16px; margin-bottom: 24px;
}
.cgev-search { display: flex; flex: 1 1 22rem; align-items: center; gap: 12px; min-width: 0; }
.cgev-search__field { position: relative; display: block; flex: 1 1 auto; min-width: 0; }
.cgev-search__field .cgev-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--cgev-muted); pointer-events: none; }
.cgev-cal input[type="search"] {
	-webkit-appearance: none; appearance: none; width: 100%; min-height: 48px; padding: 0 14px 0 44px;
	border: 1px solid var(--cgev-line); border-radius: 4px; background: #fff; color: var(--cgev-ink); font: 500 1rem/1.2 var(--cgev-sans);
}
.cgev-cal input[type="search"]::placeholder { color: #595959; opacity: 1; }
.cgev-views { display: flex; gap: 24px; }
.cgev-cal .cgev-tab {
	padding: 8px 2px; border-bottom: 2px solid transparent; color: var(--cgev-muted); font-weight: 600; font-size: 1.0625rem;
	text-decoration: none;
}
.cgev-cal .cgev-tab:hover { color: var(--cgev-ink); border-bottom-color: var(--cgev-line); }
.cgev-cal .cgev-tab.is-active { color: var(--cgev-ink); font-weight: 800; border-bottom-color: var(--cgev-ink); }

/* Nav row: arrows, "today", title with popover. */
.cgev-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 24px; }
.cgev-nav__ctrl { display: flex; align-items: center; gap: 8px; }
.cgev-cal .cgev-arrow {
	display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
	border: 1px solid var(--cgev-line); border-radius: 999px; background: #fff; color: var(--cgev-ink); text-decoration: none;
	transition: background .2s var(--cgev-ease), color .2s var(--cgev-ease);
}
.cgev-cal a.cgev-arrow:hover { background: var(--cgev-ink); color: #fff; }
.cgev-cal .cgev-arrow.is-disabled { color: #8a8a8a; background: #f4f4f4; cursor: not-allowed; }
.cgev-pop { position: relative; }
.cgev-pop__toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; border-radius: 8px; }
.cgev-pop__toggle::-webkit-details-marker { display: none; }
.cgev-pop__toggle .cgev-icon { width: 28px; height: 28px; color: var(--cgev-blue); transition: transform .2s var(--cgev-ease); }
.cgev-pop[open] .cgev-pop__toggle .cgev-icon { transform: rotate(180deg); }
.cgev-pop__panel {
	position: absolute; z-index: 20; left: 0; top: calc(100% + 8px); padding: 16px; background: #fff;
	border: 1px solid var(--cgev-line); border-radius: 8px; box-shadow: 0 12px 32px -8px rgba(10, 26, 79, .25);
}
.cgev-jump { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; min-width: min(20rem, 80vw); }
.cgev-jump label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.cgev-jump select { min-height: 44px; flex: 1 1 8rem; }
/* With JavaScript the selects apply by themselves: the button stays for the keyboard only. */
.cgev-cal.cgev-js .cgev-jump__submit {
	position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.cgev-cal.cgev-js .cgev-jump__submit:focus { position: static; width: auto; height: 44px; margin: 0; padding: 0 20px; clip: auto; border: 2px solid var(--cgev-blue); }

.cgev-back { margin-bottom: 20px; font-weight: 700; }
.cgev-back a { color: var(--cgev-blue); }
.cgev-empty { font-family: var(--cgev-serif); font-size: 1.75rem; line-height: 1.15; padding: 32px 0; }
.cgev-empty__link { font-family: var(--cgev-sans); font-size: 1rem; font-weight: 700; margin-top: 12px; }
.cgev-empty__link a { color: var(--cgev-blue); }
.cgev-empty--grid { padding: 8px 0 24px; }

/* List: grouped by month. */
.cgev-month { margin-bottom: 24px; }
.cgev-month__title {
	display: flex; align-items: center; gap: 16px; margin: 8px 0 0; font-size: 1.125rem; font-weight: 800; line-height: 1.2;
}
.cgev-month__title::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--cgev-line); }
.cgev-day { margin-bottom: 32px; }
.cgev-day__title {
	font-weight: 800; font-size: 1.125rem; line-height: 1.2; padding-bottom: 10px;
	border-bottom: 1px solid var(--cgev-line); margin-bottom: 4px;
}
.cgev-item { display: grid; grid-template-columns: 5rem 1fr; gap: 4px 24px; padding: 24px 0; }
.cgev-item--nodate { grid-template-columns: 1fr; padding: 16px 0; border-bottom: 1px solid rgba(16, 16, 16, .12); }
.cgev-item:focus { outline: none; }
.cgev-item:focus-visible { outline: 3px solid var(--cgev-blue); border-radius: 12px; }
.cgev-item__date { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1; }
.cgev-item__dow { font-size: .8125rem; font-weight: 700; letter-spacing: .1em; color: var(--cgev-muted); margin-bottom: 4px; }
.cgev-item__dnum { font-size: 2.5rem; font-weight: 800; }
.cgev-item__time { font-size: .9375rem; font-weight: 600; color: var(--cgev-muted); font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.cgev-item__title {
	font-family: var(--cgev-sans); font-weight: 800; font-stretch: 62%; font-variation-settings: "wdth" 62;
	text-transform: uppercase; font-size: 2rem; line-height: .95; letter-spacing: -.005em;
}
.cgev-item__link { color: var(--cgev-ink); text-decoration: none; }
.cgev-item__link:hover { color: var(--cgev-blue); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cgev-item__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cgev-item__head .cgev-pills { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.cgev-item__desc { margin-top: 8px; max-width: 64ch; }
.cgev-item__loc { font-weight: 700; margin-top: 8px; }
.cgev-item__note { font-weight: 600; margin-top: 8px; }
.cgev-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cgev-pill {
	display: inline-block; padding: 3px 12px; border-radius: 999px; border: 1px solid rgba(16, 16, 16, .5);
	font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; line-height: 1.3;
}
.cgev-pill--cancelled { background: #b00020 !important; border-color: #b00020; color: #fff !important; }
.cgev-item.is-cancelled .cgev-item__link,
.cgev-item.is-cancelled .cgev-item__title { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: currentColor; }
.cgev-item.is-cancelled .cgev-item__title { color: var(--cgev-muted); }
.cgev-more-wrap { margin-top: 8px; text-align: center; }

/* Month grid: flat, thin lines. */
.cgev-table-wrap { display: block; }
.cgev-month-agenda { display: none; }
.cgev-table { width: 100%; border-collapse: collapse; table-layout: fixed; border: 1px solid var(--cgev-line); background: #fff; }
.cgev-table th {
	background: #fff; color: var(--cgev-ink); padding: 12px 8px; font-size: .9375rem; font-weight: 800;
	text-align: left; border: 1px solid var(--cgev-line);
}
.cgev-table abbr { text-decoration: none; cursor: help; }
.cgev-cell { vertical-align: top; height: 150px; padding: 8px; border: 1px solid var(--cgev-line); min-width: 0; }
.cgev-cell.is-outside { background: #f6f6f6; }
.cgev-cell.is-outside .cgev-daynum { color: #595959; font-weight: 600; }
.cgev-cell.is-today { background: var(--cgev-ice); }
.cgev-daynum { font-weight: 800; font-size: 1.375rem; line-height: 1; margin-bottom: 8px; }
.cgev-cell.is-today .cgev-daynum { display: inline-block; background: var(--cgev-blue); color: #fff; border-radius: 999px; padding: 4px 9px; }
.cgev-cal .cgev-chips { display: flex; flex-direction: column; align-items: stretch; gap: 3px; margin: 0; padding: 0; }
.cgev-chips > li { width: 100%; min-width: 0; margin: 0; }
.cgev-chip {
	display: block; width: 100%; max-width: 100%; padding: 3px 8px; border-radius: 6px; font-size: .8125rem; font-weight: 600; line-height: 1.3;
	text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgba(16, 16, 16, .3);
}
.cgev-cal a.cgev-chip { text-decoration: none; }
.cgev-cal a.cgev-chip:hover { text-decoration: underline; }
.cgev-chip__time { font-weight: 800; font-size: .75rem; font-variant-numeric: tabular-nums; }
.cgev-chip.is-cancelled { text-decoration: line-through; opacity: .75; }
.cgev-more-day { display: inline-block; padding: 4px 4px; font-size: .8125rem; font-weight: 800; color: var(--cgev-blue); text-decoration: underline; text-underline-offset: 3px; }

.cgev-download { margin-top: 24px; text-align: center; }
/* Phone-only parts of the grid (dots, day button, empty message) are hidden by default. */
.cgev-dots, .cgev-daybtn { display: none; }
.cgev-day[hidden], .cgev-day-empty[hidden] { display: none; }

/* Small screens: show the agenda instead of the table; the bar stacks. */
@media (max-width: 699px) {
	.cgev-month-agenda { display: block; margin-top: 20px; }
	.cgev-cal .cgev-table th { padding: 8px 0; text-align: center; font-size: .8125rem; }
	.cgev-cal .cgev-table td.cgev-cell { position: relative; height: 56px; padding: 6px 2px; text-align: center; }
	.cgev-cell .cgev-daynum { font-size: 1rem; font-weight: 700; margin: 0 0 6px; }
	.cgev-cell .cgev-chips, .cgev-cell .screen-reader-text { display: none; }
	.cgev-cal .cgev-table td.cgev-cell.is-today .cgev-daynum { background: none; color: inherit; padding: 0; border-radius: 0; }
	.cgev-cal .cgev-table td.cgev-cell.is-today { background: #fff; box-shadow: inset 0 0 0 2px var(--cgev-blue); }
	.cgev-dots { display: flex; justify-content: center; gap: 3px; min-height: 8px; }
	.cgev-dot { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--cgev-blue); }
	.cgev-dot--cancelled { background: transparent; border: 1.5px solid #8a8a8a; }
	.cgev-cal.cgev-js .cgev-daybtn {
		display: block; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0;
		border: 0; border-radius: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
	}
	.cgev-cal.cgev-js .cgev-daybtn:focus-visible { outline-offset: -3px; box-shadow: none; }
	.cgev-cal .cgev-table td.cgev-cell.is-selected { background: var(--cgev-blue); box-shadow: none; color: #fff; }
	.cgev-cal .cgev-table td.cgev-cell.is-selected .cgev-daynum { color: #fff; }
	.cgev-cal .cgev-table td.cgev-cell.is-selected .cgev-dot--cancelled { border-color: #fff; }
	.cgev-cal.cgev-js .cgev-empty--month { display: none; }
	.cgev-day-empty { font-family: var(--cgev-sans); font-size: 1rem; font-weight: 600; padding: 16px 0; }
	.cgev-toolbar { flex-direction: column; align-items: stretch; padding: 12px; }
	.cgev-search { flex: 1 1 auto; }
	.cgev-views { justify-content: flex-start; }
	.cgev-item { grid-template-columns: 3.5rem 1fr; gap: 4px 16px; }
	.cgev-item--nodate { grid-template-columns: 1fr; }
	.cgev-item__dnum { font-size: 1.875rem; }
	.cgev-item__title { font-size: 1.75rem; }
	.cgev-more-wrap .cgev-btn { width: 100%; }
	.cgev-pop__panel { left: 0; right: auto; max-width: calc(100vw - 2 * var(--cg-gutter, 16px)); }
}
@media (min-width: 700px) and (max-width: 899px) {
	.cgev-cell { padding: 5px; height: 120px; }
	.cgev-chip__time { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.cgev-cal, .cgev-cal * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
	.cgev-cal .cgev-btn:active { transform: none; }
}

/* Theme overrides: the theme styles every input and heading globally (thick border, large top
   margin). Inside the calendar bar and nav row they must stay flat and aligned, like TEC. */
.cgev-cal .cgev-search__field input[name="cerca"] {
	width: 100%; height: 48px; margin: 0; padding: 0 12px 0 46px;
	border: 0 !important; border-radius: 0; background: transparent; box-shadow: none;
	font: inherit; font-size: 1rem; color: var(--cgev-ink);
}
.cgev-cal .cgev-search__field input[name="cerca"]:focus-visible { outline: 3px solid var(--cgev-blue); outline-offset: 2px; border-radius: 6px; }
.cgev-cal .cgev-pop__toggle .cgev-title,
.cgev-cal h2.cgev-title { margin: 0 !important; padding: 0; line-height: 1; }
.cgev-cal .cgev-nav { align-items: center; }
/* List titles like TEC: ink, no underline (underline on hover/focus only). */
.cgev-cal a.cgev-item__link { color: var(--cgev-ink); text-decoration: none; }
.cgev-cal a.cgev-item__link:hover, .cgev-cal a.cgev-item__link:focus-visible { color: var(--cgev-blue); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cgev-cal .cgev-item.is-cancelled a.cgev-item__link { text-decoration: line-through; }
/* The theme styles all tables (black header, 2px ink borders): keep the grid flat and light. */
.cgev-cal .cgev-table th,
.cgev-cal .cgev-table td.cgev-cell { border: 1px solid var(--cgev-line) !important; }
.cgev-cal .cgev-table th { background: #fafafa !important; color: var(--cgev-ink) !important; font-weight: 600; text-align: left; padding: 10px 12px; }
.cgev-cal .cgev-table td.cgev-cell { background: #fff; }
.cgev-cal .cgev-table td.cgev-cell.is-outside { background: #f6f6f6; }
.cgev-cal .cgev-table td.cgev-cell.is-today { background: var(--cgev-ice); }
/* Phones: search field on its own row, full-width button below (TEC-like, no wrapped label). */
@media (max-width: 599px) {
	.cgev-cal .cgev-search { flex-wrap: wrap; }
	.cgev-cal .cgev-search__field { flex: 1 1 100%; }
	.cgev-cal .cgev-search button { flex: 1 1 100%; white-space: nowrap; }
}
/* Calendar page: the page title is hidden (screen readers still hear it); remove the space
   the theme reserves for it (.cg-page-head in the Chiesa Gospel theme). */
.cgev-calendar-page .cg-page-head { padding-top: 0; padding-bottom: 0; }
.cgev-calendar-page .cgev-cal { margin-top: 24px; }
/* Themes cap page content at the narrow width (e.g. ".cg-prose > * { max-width: 800px }" in the
   Chiesa Gospel theme): the calendar, whether inserted as block (outer wrapper) or shortcode,
   always uses the wide width and stays centred. */
.entry-content > .wp-block-cg-calendario-calendario,
.wp-block-post-content > .wp-block-cg-calendario-calendario,
.is-layout-constrained > .wp-block-cg-calendario-calendario,
.entry-content > .cgev-cal,
.wp-block-post-content > .cgev-cal {
	width: 100%;
	max-width: var(--wp--style--global--wide-size, 1264px) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}
.wp-block-cg-calendario-calendario > .cgev-cal { max-width: none; margin-inline: 0; }
/* The theme highlights every link inside page text with a blue background on hover
   (".cg-prose a:hover"): inside the calendar that hides the titles. Buttons and the coloured
   event bars keep their own colours. */
.cgev-cal a:not(.cgev-btn):not(.cgev-chip):hover,
.cgev-cal a:not(.cgev-btn):not(.cgev-chip):focus { background: transparent !important; }
.cgev-cal a.cgev-chip:hover, .cgev-cal a.cgev-chip:focus { filter: brightness(.92); }
/* Phones: the selected day wins over "today" and "outside month" backgrounds. */
@media (max-width: 699px) {
	.cgev-cal .cgev-table td.cgev-cell.cgev-cell.is-selected { background: var(--cgev-blue) !important; }
	.cgev-cal .cgev-table td.cgev-cell.cgev-cell.is-selected .cgev-daynum { color: #fff !important; background: transparent; }
	.cgev-cal .cgev-table td.cgev-cell.is-selected .cgev-dot { box-shadow: 0 0 0 1.5px #fff; }
}
