/**
 * ACF Calendar — month view styles.
 * Colors via CSS custom properties from ACF Calendar → Colors settings.
 */

#nfo_calendar {
	overflow: visible;
	--nfo-titlebar-bg: #1b1b1b;
	--nfo-titlebar-fg: #ffffff;
	--nfo-btn-bg: #ffffff;
	--nfo-btn-fg: #1b1b1b;
	--nfo-btn-hover-bg: #1b1b1b;
	--nfo-btn-hover-fg: #ffffff;
	--nfo-cal-bg: #ffffff;
	--nfo-cal-fg: #1b1b1b;
	--nfo-border: #d9d9d9;
	--nfo-outside-bg: #f7f7f7;
	--nfo-number-bg: transparent;
	--nfo-active-border: #c0392b;
	--nfo-active-num-bg: #c0392b;
	--nfo-active-num-fg: #ffffff;
	--ev-bg: #333333;
	--ev-fg: #ffffff;
	--ev-hbg: #555555;
	--ev-hfg: #ffffff;

	font-size: 18px;
	background: var(--nfo-cal-bg);
	color: var(--nfo-cal-fg);
	border: 1px solid var(--nfo-border);
	border-radius: 8px;
	font-family: inherit;
	line-height: 1.4;
	box-sizing: border-box;
	position: relative;
}

#nfo_calendar *,
#nfo_calendar *::before,
#nfo_calendar *::after {
	box-sizing: border-box;
}

/* Kill theme-injected empty paragraphs / breaks inside the calendar shell */
#nfo_calendar > p,
#nfo_calendar .nfo-calendar-body > p,
#nfo_calendar > br,
#nfo_calendar .nfo-calendar-body > br,
#nfo_calendar .row + p,
#nfo_calendar .row > br,
#nfo_calendar p:empty {
	display: none !important;
	margin: 0 !important;
	padding: 0 !important;
	height: 0 !important;
	line-height: 0 !important;
}

/* Theme/wpautop often wraps titlebar children in <p>; don't let that break flex layout */
#nfo_calendar .row.titlebar > p {
	display: contents;
}

/* ---------- Titlebar ---------- */

#nfo_calendar .row.titlebar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 12px;
	background: var(--nfo-titlebar-bg);
	color: var(--nfo-titlebar-fg);
	margin: 0;
}

#nfo_calendar .nfo-title {
	font-size: 1.25em;
	font-weight: 700;
	text-align: center;
}

#nfo_calendar .nfo-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--nfo-btn-bg);
	color: var(--nfo-btn-fg);
	border: 1px solid var(--nfo-border);
	border-radius: 4px;
	padding: 6px 12px;
	font: inherit;
	font-size: 0.9em;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

#nfo_calendar .nfo-btn:hover,
#nfo_calendar .nfo-btn:focus-visible {
	background: var(--nfo-btn-hover-bg);
	color: var(--nfo-btn-hover-fg);
	outline: 0;
}

#nfo_calendar .nfo-btn:disabled {
	opacity: 0.6;
	cursor: wait;
}

/* ---------- Headings ---------- */

#nfo_calendar .row.headings {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	margin: 0;
}

#nfo_calendar .row.headings .heading {
	padding: 8px 4px;
	text-align: center;
	font-weight: 700;
	font-size: 0.85em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	border-bottom: 1px solid var(--nfo-border);
}

/* ---------- Weeks / Days ---------- */

#nfo_calendar .row.week {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	margin: 0;
}

#nfo_calendar .day {
	position: relative;
	min-width: 0;
	min-height: 138px;
	padding: 26px 6px 6px;
	border: 1px solid var(--nfo-border);
	background: var(--nfo-cal-bg);
	color: var(--nfo-cal-fg);
	overflow: visible; /* stickers may overlap adjacent days */
	z-index: 1;
}

#nfo_calendar .day.outside {
	background: var(--nfo-outside-bg);
}

#nfo_calendar .day.today {
	border: 2px solid var(--nfo-active-border);
}

/* Day number: fixed 20x20 square, top-right */
#nfo_calendar .overlay.number {
	position: absolute;
	top: 0;
	right: 0;
	left: unset;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 12px;
	line-height: 1;
	z-index: 2;
	padding: 0;
	margin: 0;
	border-radius: 0;
	background: var(--nfo-number-bg);
	color: inherit;
	border-left: 1px solid var(--nfo-border);
	border-bottom: 1px solid var(--nfo-border);
}

#nfo_calendar .day.today .overlay.number {
	background: var(--nfo-active-num-bg);
	color: var(--nfo-active-num-fg);
	border-radius: 0;
	padding: 0;
}

/* ---------- Events ---------- */

#nfo_calendar .eventsbox {
	display: flex;
	flex-direction: column;
	gap: 4px;
	position: relative;
	z-index: 1;
	min-width: 0;
	max-width: 100%;
}

#nfo_calendar .itembox.event {
	border: 1px solid transparent;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	background: var(--ev-bg);
	color: var(--ev-fg);
	padding: 4px 7px;
	border-radius: 3px;
	cursor: pointer;
	font-size: 0.85em;
	min-width: 0;
	max-width: 100%;
	box-sizing: border-box;
	overflow: hidden;
	transition: background 0.15s ease, color 0.15s ease;
}

#nfo_calendar .itembox.event:hover,
#nfo_calendar .itembox.event:focus-visible {
	background: var(--ev-hbg);
	color: var(--ev-hfg);
	outline: 0;
}

#nfo_calendar .event-title {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 80%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: clip;
	/* Fade out on the right when the title is longer than the box */
	-webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 20px), transparent 100%);
	mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 20px), transparent 100%);
}

#nfo_calendar .event-time {
	white-space: nowrap;
	opacity: 0;
	transition: opacity 0.15s ease;
	flex: none;
}

#nfo_calendar .itembox.event:hover .event-time,
#nfo_calendar .itembox.event:focus-visible .event-time {
	opacity: 1;
}

/* ---------- Single Event View ---------- */

#nfo_calendar .nfo-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

#nfo_calendar .nfo-overlay[hidden] {
	display: none !important;
}

#nfo_calendar .nfo-overlay-inner {
	position: relative;
	background: var(--nfo-cal-bg);
	color: var(--nfo-cal-fg);
	max-width: 640px;
	width: 100%;
	max-height: 85vh;
	overflow-y: auto;
	border-radius: 8px;
	padding: 24px;
}

#nfo_calendar .nfo-close {
	position: absolute;
	top: 10px;
	right: 10px;
	background: transparent;
	color: inherit;
	border: none;
	font-size: 1.6em;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
}

#nfo_calendar .nfo-event-title {
	margin: 0 0 6px;
	padding-right: 30px;
}

#nfo_calendar .nfo-event-meta {
	font-size: 0.9em;
	opacity: 0.8;
	margin-bottom: 10px;
}

#nfo_calendar .nfo-event-categories {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 12px;
}

#nfo_calendar .nfo-cat-chip {
	background: var(--ev-bg, #333333);
	color: var(--ev-fg, #ffffff);
	font-size: 0.75em;
	padding: 3px 10px;
	border-radius: 12px;
}

#nfo_calendar .nfo-event-image img {
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	border-radius: 6px;
	margin-bottom: 12px;
}

#nfo_calendar .nfo-event-short,
#nfo_calendar .nfo-event-full {
	margin-top: 10px;
}

#nfo_calendar .nfo-event-full img {
	max-width: 100%;
	height: auto;
}


/* Never use outlines for focus/hover — borders only */
#nfo_calendar button,
#nfo_calendar .nfo-btn,
#nfo_calendar .nfo-close,
#nfo_calendar .itembox.event,
#nfo_calendar .itembox.event:hover,
#nfo_calendar .itembox.event:focus,
#nfo_calendar .itembox.event:focus-visible,
#nfo_calendar .nfo-btn:hover,
#nfo_calendar .nfo-btn:focus,
#nfo_calendar .nfo-btn:focus-visible {
	outline: 0;
}

#nfo_calendar .itembox.event:focus-visible {
	border: 1px solid var(--ev-hfg, #ffffff);
}

#nfo_calendar .nfo-btn:focus-visible {
	border: 1px solid var(--nfo-btn-hover-fg);
}

/* Pro: day background images */
#nfo_calendar .day.has-bg {
	background-image: var(--nfo-day-bg);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

#nfo_calendar .day.has-bg.outside {
	background-image: var(--nfo-day-bg);
	opacity: 0.85;
}

/* Pro: stickers — 40% of day width; center anchored on 9 points (may overlap neighbors) */

/* Days with stickers must paint above later siblings so edge stickers are not covered */
#nfo_calendar .day.has-sticker {
	z-index: 5;
}

#nfo_calendar .day.has-sticker .nfo-stickers {
	z-index: 6;
}

#nfo_calendar .nfo-stickers {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 4;
	overflow: visible;
}

#nfo_calendar .nfo-sticker {
	position: absolute;
	width: 40%;
	height: auto;
	max-width: 40%;
	object-fit: contain;
	display: block;
	transform: translate(-50%, -50%);
}

#nfo_calendar .nfo-sticker-top-left { top: 0; left: 0; }
#nfo_calendar .nfo-sticker-top { top: 0; left: 50%; }
#nfo_calendar .nfo-sticker-top-right { top: 0; left: 100%; }
#nfo_calendar .nfo-sticker-left { top: 50%; left: 0; }
#nfo_calendar .nfo-sticker-center { top: 50%; left: 50%; }
#nfo_calendar .nfo-sticker-right { top: 50%; left: 100%; }
#nfo_calendar .nfo-sticker-bottom-left { top: 100%; left: 0; }
#nfo_calendar .nfo-sticker-bottom { top: 100%; left: 50%; }
#nfo_calendar .nfo-sticker-bottom-right { top: 100%; left: 100%; }

#nfo_calendar .overlay.number {
	z-index: 3;
}

/* Pro: event title icons */
#nfo_calendar .nfo-event-icon {
	font-size: 1em;
	width: 1em;
	height: 1em;
	line-height: 1;
	vertical-align: -0.1em;
	margin-right: 0.2em;
}

#nfo_calendar .event-title .nfo-event-icon {
	font-size: 1.3em;
}

#nfo_calendar .nfo-event-title .nfo-event-icon {
	margin-right: 0.35em;
}


/* Pro: ensure Dashicons glyph renders (font from wp-includes dashicons.css) */
#nfo_calendar .dashicons,
#nfo_calendar .nfo-event-icon {
	font-family: dashicons !important;
	display: inline-block;
	speak: never;
	font-style: normal;
	font-weight: normal;
	font-variant: normal;
	text-transform: none;
	line-height: 1;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-decoration: none !important;
	vertical-align: middle;
}

#nfo_calendar .dashicons:before,
#nfo_calendar .nfo-event-icon:before {
	font-family: dashicons !important;
}
@media (max-width: 600px) {
	#nfo_calendar .nfo-title {
		font-size: 1em;
	}

	#nfo_calendar .nfo-btn span {
		display: none;
	}

	#nfo_calendar .day {
		min-height: 72px;
	}

	#nfo_calendar .event-title {
		font-size: 0.75em;
	}
}
