/**
 * Frontend styles for Events & Gatherings Manager.
 * Namespaced with .nj-event-* and .nj-events-* prefixes.
 */

/* Events Listing - Respects Divi's container system */
.nj-events-listing {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: 0 auto;
	padding: 40px 0;
	background: #fff;
	box-sizing: border-box;
	overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Divi compatibility - work within Divi's container system */
.et_pb_row .nj-events-listing,
.et_pb_column .nj-events-listing,
.et_pb_section .nj-events-listing {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: 0 auto;
	padding-left: 0;
	padding-right: 0;
}

/* When inside Divi row that uses CSS variables, respect them */
.et_pb_row:not([class*=et_flex_column]) .nj-events-listing {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: 0 auto;
	position: relative;
}

/* Standard WordPress container compatibility */
.entry-content .nj-events-listing,
.post-content .nj-events-listing,
.content-area .nj-events-listing {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: 0 auto;
}

/* If inside a container with padding, remove our padding */
.container .nj-events-listing,
.et-container .nj-events-listing,
.et_pb_container .nj-events-listing {
	padding-left: 0;
	padding-right: 0;
}

.nj-events-header {
	text-align: center;
	margin-bottom: 50px;
}

.nj-events-title {
	font-size: 3em;
	font-weight: 400;
	margin: 0;
	color: #1a1a1a;
	font-family: Georgia, 'Times New Roman', serif;
	letter-spacing: -0.02em;
}

.nj-events-filters {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 50px;
	gap: 20px;
	flex-wrap: wrap;
	width: 100%;
	max-width: 100%; /* Don't exceed parent */
	box-sizing: border-box;
}

.nj-events-search {
	position: relative;
	flex: 1;
	min-width: 300px;
	max-width: 500px;
}

.nj-search-icon {
	position: absolute;
	left: 15px;
	top: 50%;
	transform: translateY(-50%);
	width: 20px;
	height: 20px;
	color: #999;
	pointer-events: none;
}

.nj-events-search-input {
	width: 100%;
	padding: 12px 15px 12px 45px;
	font-size: 16px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #fff;
	transition: border-color 0.3s;
}

.nj-events-search-input:focus {
	outline: none;
	border-color: #999;
}

.nj-events-category-filters {
	display: flex;
	align-items: center;
	gap: 15px;
	flex-wrap: wrap;
}

.nj-filter-icon {
	width: 20px;
	height: 20px;
	color: #666;
	margin-right: 5px;
}

.nj-category-filter {
	padding: 10px 20px;
	background: #f5f5f5;
	border: none;
	border-radius: 20px;
	cursor: pointer;
	transition: all 0.3s;
	font-size: 15px;
	color: #666;
	font-weight: 400;
}

.nj-category-filter:hover {
	background: #e8e8e8;
}

.nj-category-filter.active {
	background: #8B2635;
	color: #fff;
}

/* Events Grid - Respects parent container */
.nj-events-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 30px;
	margin-bottom: 30px;
	width: 100%;
	max-width: 100%; /* Don't exceed parent */
	box-sizing: border-box;
}

@media (max-width: 1024px) {
	.nj-events-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 25px;
	}
}

@media (max-width: 768px) {
	.nj-events-grid {
		grid-template-columns: 1fr;
		gap: 25px;
	}

	.nj-events-listing {
		padding: 30px 0;
	}

	.nj-events-header {
		margin-bottom: 30px;
	}

	.nj-events-title {
		font-size: 2em;
	}

	.nj-events-filters {
		flex-direction: column;
		align-items: stretch;
		gap: 15px;
		margin-bottom: 30px;
	}

	.nj-events-search {
		min-width: 100%;
		max-width: 100%;
	}
}

/* Event Card */
.nj-event-card {
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
	transition: transform 0.3s, box-shadow 0.3s;
	display: flex;
	flex-direction: column;
	width: 100%;
	box-sizing: border-box;
}

.nj-event-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nj-event-card-image {
	position: relative;
	width: 100%;
	height: 250px;
	overflow: hidden;
}

.nj-event-card-image a {
	display: block;
	width: 100%;
	height: 100%;
}

.nj-event-card-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.nj-event-card-category {
	position: absolute;
	top: 15px;
	right: 15px;
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 500;
	color: #333;
	background: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(4px);
}

.nj-event-card-content {
	padding: 25px;
	flex: 1;
	display: flex;
	flex-direction: column;
	width: 100%;
	box-sizing: border-box;
}

.nj-event-card-date {
	color: #666;
	font-size: 14px;
	margin-bottom: 12px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.nj-icon-calendar {
	width: 16px;
	height: 16px;
	color: #999;
	flex-shrink: 0;
}

.nj-event-card-title {
	margin: 0 0 12px 0;
	font-size: 1.5em;
	font-weight: 600;
	line-height: 1.3;
}

.nj-event-card-title a {
	text-decoration: none;
	color: #1a1a1a;
	transition: color 0.3s;
}

.nj-event-card-title a:hover {
	color: #8B2635;
}

.nj-event-card-excerpt {
	color: #666;
	margin-bottom: 15px;
	line-height: 1.6;
	font-size: 15px;
	flex: 1;
}

.nj-event-card-location {
	color: #666;
	font-size: 14px;
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.nj-icon-location {
	width: 16px;
	height: 16px;
	color: #999;
	flex-shrink: 0;
}

.nj-event-card-actions {
	margin-top: auto;
	display: flex;
	justify-content: flex-end;
}

.nj-event-card-link {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	color: #1a1a1a;
	text-decoration: none;
	font-size: 15px;
	font-weight: 500;
	transition: color 0.3s;
}

.nj-event-card-link:hover {
	color: #8B2635;
}

.nj-icon-arrow {
	width: 16px;
	height: 16px;
	transition: transform 0.3s;
}

.nj-event-card-link:hover .nj-icon-arrow {
	transform: translateX(3px);
}

.nj-events-empty {
	text-align: center;
	padding: 60px 20px;
	grid-column: 1 / -1;
	width: 100%;
	box-sizing: border-box;
}

.nj-events-loading {
	text-align: center;
	padding: 20px;
	width: 100%;
	box-sizing: border-box;
}

/* Event Hero */
.nj-event-hero {
	position: relative;
	min-height: 500px;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	padding: 80px 20px 120px;
}

.nj-event-hero-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.4);
}

.nj-event-hero-back {
	position: absolute;
	top: 30px;
	left: 30px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #fff;
	text-decoration: none;
	font-size: 16px;
	transition: opacity 0.3s;
}

.nj-event-hero-back:hover {
	opacity: 0.8;
}

.nj-event-hero-back svg {
	width: 16px;
	height: 16px;
}

.nj-event-hero-content {
	position: relative;
	z-index: 1;
	text-align: center;
	/* Constrain text width for readability, but respect container */
	max-width: min(900px, var(--content-max-width, 100%));
	width: 100%;
	box-sizing: border-box;
	margin: 0 auto;
}

/* When inside Divi row, respect its width constraints */
.et_pb_row .nj-event-hero-content,
.et_pb_column .nj-event-hero-content {
	max-width: min(900px, var(--content-max-width, 100%));
}

.nj-event-hero-category {
	display: inline-block;
	padding: 8px 16px;
	background: #8B2635;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin-bottom: 25px;
	border-radius: 4px;
}

.nj-event-hero-title {
	font-size: 3.5em;
	font-weight: 400;
	margin: 0 0 30px 0;
	color: #fff;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
	font-family: Georgia, 'Times New Roman', serif;
	line-height: 1.2;
}

.nj-event-hero-meta {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	font-size: 16px;
	color: #fff;
}

.nj-event-hero-date,
.nj-event-hero-location {
	display: flex;
	align-items: center;
	gap: 8px;
	color: #fff;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.nj-event-hero .nj-icon-calendar,
.nj-event-hero .nj-icon-location {
	width: 16px;
	height: 16px;
	color: #fff;
	flex-shrink: 0;
}

@media (max-width: 768px) {
	.nj-event-hero {
		min-height: 400px;
		padding: 60px 20px 100px;
	}

	.nj-event-hero-back {
		top: 20px;
		left: 20px;
	}

	.nj-event-hero-title {
		font-size: 2.2em;
	}

	.nj-event-hero-meta {
		font-size: 14px;
	}
}

/* Event About - Respects Divi's container system */
.nj-event-about {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: -80px auto 60px;
	padding: 0 20px;
	position: relative;
	z-index: 2;
	box-sizing: border-box;
}

/* When inside Divi row, respect its width constraints */
.et_pb_row .nj-event-about,
.et_pb_column .nj-event-about,
.et_pb_section .nj-event-about {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: -80px auto 60px;
}

.nj-event-about-card {
	background: #fff;
	border-radius: 8px;
	padding: 40px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nj-event-about-title {
	font-size: 1.8em;
	font-weight: 600;
	margin: 0 0 20px 0;
	color: #1a1a1a;
}

.nj-event-about-content {
	line-height: 1.8;
	font-size: 16px;
	color: #333;
}

.nj-event-about-content p {
	margin-bottom: 15px;
}

@media (max-width: 768px) {
	.nj-event-about {
		margin: -60px auto 40px;
		padding: 0 15px;
	}

	.nj-event-about-card {
		padding: 30px 20px;
	}

	.nj-event-about-title {
		font-size: 1.5em;
	}
}

/* Event Gallery - Root Section - Respects Divi's container system */
.nj-event-gallery {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: 60px auto;
	padding: 0 20px;
	display: block;
	box-sizing: border-box;
}

/* When inside Divi row, respect its width constraints */
.et_pb_row .nj-event-gallery,
.et_pb_column .nj-event-gallery,
.et_pb_section .nj-event-gallery {
	width: var(--content-width, 100%);
	max-width: var(--content-max-width, 100%);
	margin: 60px auto;
}

/* Gallery Header - Title Area */
.nj-event-gallery-header {
	width: 100%;
	display: block;
	margin-bottom: 30px;
}

.nj-event-gallery-header h2 {
	font-size: 1.8em;
	font-weight: 600;
	margin: 0;
	padding: 0;
	color: #1a1a1a;
}

/* Gallery Groups Container - Vertical Flow */
.nj-event-gallery-groups {
	width: 100%;
	display: block;
}

/* Date Group - Each date is its own section */
.nj-event-gallery-group {
	width: 100%;
	display: block;
	margin-bottom: 50px;
}

.nj-event-gallery-group:last-child {
	margin-bottom: 0;
}

/* Date Heading */
.nj-event-gallery-date {
	font-size: 0.95em;
	font-weight: 500;
	margin: 0 0 15px 0;
	padding: 0;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	width: 100%;
	display: block;
	text-align: left;
}

/* Caption - Under date, above images */
.nj-event-gallery-caption {
	font-size: 14px;
	color: #666;
	line-height: 1.5;
	margin: 0 0 20px 0;
	padding: 0;
	width: 100%;
	display: block;
	text-align: left;
}

/* Gallery Items - ONLY place grid/flex is allowed */
.nj-event-gallery-items {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 30px;
	justify-items: start;
	width: 100%;
	margin: 0;
	padding: 0;
}

/* Tablet - 2 columns */
@media (max-width: 1024px) {
	.nj-event-gallery-items {
		grid-template-columns: repeat(2, 1fr);
		gap: 25px;
	}
}

/* Mobile - 1 column */
@media (max-width: 768px) {
	.nj-event-gallery-items {
		grid-template-columns: 1fr;
		gap: 20px;
	}
}

.nj-event-gallery-item {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 100%;
}

.nj-event-gallery-image-wrapper {
	width: 100%;
	overflow: hidden;
	border-radius: 8px;
}

.nj-event-gallery-image-link {
	display: block;
	width: 100%;
	overflow: hidden;
}

.nj-event-gallery-image {
	width: 100%;
	height: auto;
	display: block;
	transition: transform 0.3s;
	object-fit: cover;
	aspect-ratio: 1;
}

.nj-event-gallery-image-link:hover .nj-event-gallery-image {
	transform: scale(1.05);
}

.nj-event-gallery-youtube {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 */
	height: 0;
	overflow: hidden;
	border-radius: 8px;
	margin-bottom: 12px;
}

.nj-event-gallery-youtube iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border-radius: 8px;
}

.nj-event-gallery-video {
	width: 100%;
	height: auto;
	border-radius: 8px;
	margin-bottom: 12px;
}

.nj-event-gallery-caption {
	font-size: 14px;
	color: #666;
	line-height: 1.5;
	margin-top: 0;
}

.nj-event-gallery-empty {
	text-align: center;
	padding: 40px 20px;
	color: #666;
}

/* Timeline Layout */
.nj-event-gallery-timeline {
	position: relative;
	padding-left: 30px;
}

.nj-event-gallery-timeline-date-group {
	margin-bottom: 50px;
	position: relative;
}

.nj-event-gallery-timeline-date-group::before {
	content: '';
	position: absolute;
	left: -30px;
	top: 0;
	bottom: -50px;
	width: 2px;
	background: #8B2635;
}

.nj-event-gallery-timeline-date-group::after {
	content: '';
	position: absolute;
	left: -36px;
	top: 8px;
	width: 14px;
	height: 14px;
	background: #8B2635;
	border-radius: 50%;
	border: 3px solid #fff;
	box-shadow: 0 0 0 2px #8B2635;
}

.nj-event-gallery-timeline-date {
	font-size: 1.3em;
	font-weight: 600;
	margin: 0 0 25px 0;
	color: #1a1a1a;
}

.nj-event-gallery-timeline-items {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 30px;
}

@media (max-width: 768px) {
	.nj-event-gallery-timeline {
		padding-left: 20px;
	}

	.nj-event-gallery-timeline-date-group::before {
		left: -20px;
	}

	.nj-event-gallery-timeline-date-group::after {
		left: -27px;
	}

	.nj-event-gallery-timeline-items {
		grid-template-columns: 1fr;
	}
}

/* Lightbox */
.nj-lightbox-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.95);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.3s;
}

.nj-lightbox-overlay.active {
	opacity: 1;
}

.nj-lightbox {
	position: relative;
	max-width: 90%;
	max-height: 90%;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
}

.nj-lightbox-content {
	position: relative;
	max-width: 100%;
	max-height: calc(90vh - 120px);
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 0 80px;
}

.nj-lightbox img {
	max-width: 100%;
	max-height: calc(90vh - 120px);
	display: block;
	object-fit: contain;
}

.nj-lightbox-info {
	margin-top: 20px;
	width: 100%;
	max-width: 100%;
	text-align: left;
	padding: 0 20px;
	box-sizing: border-box;
	color: #fff;
}

.nj-lightbox-date {
	font-size: 0.9em;
	font-weight: 500;
	color: #fff;
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.nj-lightbox-caption {
	font-size: 1em;
	font-weight: 400;
	color: #fff;
	line-height: 1.6;
	word-wrap: break-word;
	overflow-wrap: break-word;
	max-width: 100%;
}

.nj-lightbox-close {
	position: absolute;
	top: 20px;
	right: 20px;
	background: transparent;
	border: none;
	color: #fff;
	font-size: 40px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	width: 40px;
	height: 40px;
	transition: opacity 0.3s;
	z-index: 11;
}

.nj-lightbox-close:hover {
	opacity: 0.7;
}

.nj-lightbox-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.2);
	border: 2px solid rgba(255, 255, 255, 0.5);
	border-radius: 50%;
	width: 50px;
	height: 50px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	transition: all 0.3s;
	z-index: 11;
}

.nj-lightbox-nav:hover:not(.disabled) {
	background: rgba(255, 255, 255, 0.3);
	border-color: rgba(255, 255, 255, 0.8);
}

.nj-lightbox-nav.disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

.nj-lightbox-prev {
	left: 20px;
}

.nj-lightbox-next {
	right: 20px;
}

.nj-lightbox-nav svg {
	width: 24px;
	height: 24px;
}

/* Legacy class support - map to new structure */
.nj-event-gallery-date-heading {
	font-size: 0.95em;
	font-weight: 500;
	margin: 0 0 15px 0;
	padding: 0;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	width: 100%;
	display: block;
	text-align: left;
}

@media (max-width: 768px) {
	.nj-lightbox {
		max-width: 95%;
	}

	.nj-lightbox-nav {
		width: 40px;
		height: 40px;
	}

	.nj-lightbox-prev {
		left: 10px;
	}

	.nj-lightbox-next {
		right: 10px;
	}

	.nj-lightbox-close {
		top: 10px;
		right: 10px;
	}
}

