/*
 * NE Calendar — module styles
 *
 * Sections:
 *   1. Header/hero
 *   2. Filter bar
 *   3. Topline summary
 *   4. Grid layout
 *   5. Day cell
 *   6. Today / muted modifiers
 *   7. Event chip
 *   8. Tooltip / popover
 *   9. Loading skeleton
 *   10. Mobile agenda view
 *   11. Responsive (<= 768px switch)
 *   12. Empty state
 *
 * Uses DS tokens only. No magic numbers without a reason.
 *
 * @see Issue #556
 */

/* ------------------------------------------------------------------
   1. Header / hero
   ------------------------------------------------------------------ */
.ne-cal-header {
	text-align: center;
	margin-bottom: var(--ne-space-6);
}

.ne-cal-eyebrow {
	font-family: var(--ne-font-mono);
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--ne-text-muted);
	margin: 0 0 var(--ne-space-2) 0;
}

.ne-cal-h1 {
	font-family: var(--ne-font-display);
	font-size: clamp(28px, 4vw, 44px);
	color: var(--ne-text);
	margin: 0 0 var(--ne-space-3) 0;
	line-height: 1.1;
}

.ne-cal-sub {
	color: var(--ne-text-muted);
	max-width: 640px;
	margin: 0 auto;
	font-size: 15px;
	line-height: 1.5;
}

/* ------------------------------------------------------------------
   2. Filter bar
   ------------------------------------------------------------------ */
.ne-cal-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--ne-space-4);
	padding: var(--ne-space-4);
	background: var(--ne-surface);
	border: 1px solid var(--ne-border);
	border-radius: var(--ne-radius-md);
	margin-bottom: var(--ne-space-4);
}

.ne-cal-filters__nav {
	display: flex;
	align-items: center;
	gap: var(--ne-space-3);
}

.ne-cal-nav-btn {
	width: 36px;
	min-width: 36px;
	height: 36px;
	padding: 0;
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.ne-cal-title {
	font-family: var(--ne-font-display);
	font-size: 22px;
	color: var(--ne-text);
	margin: 0;
	min-width: 160px;
	text-align: center;
	line-height: 1;
}

.ne-cal-today-btn {
	margin-left: var(--ne-space-2);
}

.ne-cal-filters__group {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ne-space-2);
}

.ne-cal-field {
	display: inline-flex;
	align-items: center;
	flex: 0 1 auto;
}

.ne-cal-field .ne-select {
	min-width: 140px;
	max-width: 180px;
}

.ne-cal-filters__toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--ne-space-2);
	color: var(--ne-text-muted);
	font-size: 14px;
	cursor: pointer;
	user-select: none;
}

.ne-cal-filters__toggle input[type="checkbox"] {
	accent-color: var(--ne-accent);
	width: 16px;
	height: 16px;
}

/* ------------------------------------------------------------------
   3. Topline summary
   ------------------------------------------------------------------ */
.ne-cal-topline {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ne-space-3);
	margin-bottom: var(--ne-space-3);
	padding: var(--ne-space-3) var(--ne-space-4);
	background: var(--ne-bg);
	border: 1px solid var(--ne-border);
	border-radius: var(--ne-radius-md);
	font-size: 13px;
	color: var(--ne-text-muted);
}

.ne-cal-topline__total {
	color: var(--ne-text);
	font-weight: 600;
}

.ne-cal-topline__sep {
	color: var(--ne-text-subtle);
}

/* ------------------------------------------------------------------
   4. Grid layout
   ------------------------------------------------------------------ */
.ne-cal-root {
	position: relative;
}

.ne-cal-body {
	position: relative;
	min-height: 300px;
}

.ne-cal-grid {
	display: grid;
	grid-template-rows: auto 1fr;
	gap: 0;
	background: var(--ne-surface);
	border: 1px solid var(--ne-border);
	border-radius: var(--ne-radius-md);
	overflow: hidden;
}

.ne-cal-grid__headers {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	background: var(--ne-bg);
	border-bottom: 1px solid var(--ne-border);
}

.ne-cal-grid__header {
	padding: var(--ne-space-2) var(--ne-space-3);
	font-size: 11px;
	font-family: var(--ne-font-mono);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ne-text-muted);
	text-align: left;
}

.ne-cal-grid__body {
	display: grid;
	grid-auto-rows: minmax(120px, auto);
}

.ne-cal-grid__week {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
}

/* ------------------------------------------------------------------
   5. Day cell
   ------------------------------------------------------------------ */
.ne-cal-day {
	position: relative;
	padding: var(--ne-space-2) var(--ne-space-2) var(--ne-space-2) var(--ne-space-2);
	min-height: 120px;
	border-right: 1px solid var(--ne-border);
	border-bottom: 1px solid var(--ne-border);
	display: flex;
	flex-direction: column;
	gap: var(--ne-space-2);
	background: var(--ne-surface);
}

.ne-cal-grid__week > .ne-cal-day:last-child {
	border-right: 0;
}

.ne-cal-grid__body .ne-cal-grid__week:last-child .ne-cal-day {
	border-bottom: 0;
}

.ne-cal-day__num {
	font-family: var(--ne-font-mono);
	font-size: 12px;
	color: var(--ne-text-muted);
	align-self: flex-start;
	padding: 2px 6px;
	border-radius: var(--ne-radius-sm);
}

.ne-cal-day__chips {
	display: flex;
	flex-direction: column;
	gap: 4px;
	overflow: hidden;
}

/* ------------------------------------------------------------------
   6. Today / muted modifiers
   ------------------------------------------------------------------ */
.ne-cal-day--today {
	background: color-mix(in srgb, var(--ne-accent-glow) 60%, var(--ne-surface) 40%);
}

.ne-cal-day--today .ne-cal-day__num {
	background: var(--ne-accent);
	color: #fff;
	font-weight: 600;
}

.ne-cal-day--muted {
	background: var(--ne-bg);
}

.ne-cal-day--muted .ne-cal-day__num {
	opacity: 0.4;
}

.ne-cal-day--muted .ne-cal-day__chips {
	opacity: 0.5;
}

/* ------------------------------------------------------------------
   7. Event chip
   ------------------------------------------------------------------ */
.ne-cal-chip {
	display: flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	padding: 4px 8px;
	background: var(--ne-elevated);
	color: var(--ne-text);
	border: 1px solid var(--ne-border);
	border-left: 3px solid var(--ne-accent);
	border-radius: var(--ne-radius-sm);
	font-family: var(--ne-font-body);
	font-size: 12px;
	line-height: 1.2;
	cursor: pointer;
	text-align: left;
	transition: background var(--ne-duration) var(--ne-ease),
				border-color var(--ne-duration) var(--ne-ease),
				transform var(--ne-duration) var(--ne-ease);
	overflow: hidden;
}

.ne-cal-chip:hover {
	background: color-mix(in srgb, var(--ne-elevated) 70%, var(--ne-overlay-s) 30%);
	border-color: var(--ne-border-s);
}

.ne-cal-chip:focus-visible {
	outline: 2px solid var(--ne-accent);
	outline-offset: 2px;
}

.ne-cal-chip[aria-expanded="true"] {
	background: color-mix(in srgb, var(--ne-elevated) 60%, var(--ne-accent-glow) 40%);
}

.ne-cal-chip__logo {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--ne-bg);
}

.ne-cal-chip__logo--placeholder {
	display: inline-block;
	background: var(--ne-border-s);
}

.ne-cal-chip__time {
	flex: 0 0 auto;
	font-family: var(--ne-font-mono);
	font-weight: 600;
	color: var(--ne-text);
	font-size: 11px;
}

.ne-cal-chip__track {
	flex: 1 1 auto;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--ne-text);
}

.ne-cal-chip__fecha {
	flex: 0 0 auto;
	font-size: 10px;
	color: var(--ne-text-muted);
	font-family: var(--ne-font-mono);
	padding: 1px 4px;
	border-radius: var(--ne-radius-sm);
	background: var(--ne-bg);
}

/* ------------------------------------------------------------------
   8. Tooltip / popover
   ------------------------------------------------------------------ */
.ne-cal-tooltip {
	position: fixed;
	top: 0;
	left: 0;
	z-index: var(--ne-z-dropdown);
	max-width: 340px;
	width: max-content;
	background: var(--ne-elevated);
	border: 1px solid var(--ne-border-s);
	border-radius: var(--ne-radius-md);
	box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
	padding: 0;
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, -100%) translateY(-8px);
	transition: opacity var(--ne-duration) var(--ne-ease),
				transform var(--ne-duration) var(--ne-ease);
}

.ne-cal-tooltip.is-open {
	visibility: visible;
	opacity: 1;
	pointer-events: auto;
	transform: translate(-50%, -100%) translateY(-12px);
}

.ne-cal-tooltip.is-open.ne-cal-tooltip--below {
	transform: translate(-50%, 0) translateY(12px);
}

.ne-cal-tooltip__inner {
	position: relative;
	padding: var(--ne-space-4);
}

.ne-cal-tooltip__close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 24px;
	height: 24px;
	background: transparent;
	border: 0;
	color: var(--ne-text-muted);
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	border-radius: var(--ne-radius-sm);
}

.ne-cal-tooltip__close:hover {
	background: var(--ne-overlay);
	color: var(--ne-text);
}

.ne-cal-tooltip__head {
	display: flex;
	align-items: center;
	gap: var(--ne-space-3);
	padding-right: var(--ne-space-5);
	margin-bottom: var(--ne-space-3);
}

.ne-cal-tooltip__logo {
	width: 40px;
	height: 40px;
	border-radius: var(--ne-radius-sm);
	object-fit: cover;
	background: var(--ne-bg);
	border: 1px solid var(--ne-border);
	flex: 0 0 auto;
}

.ne-cal-tooltip__head-text {
	flex: 1 1 auto;
	min-width: 0;
}

.ne-cal-tooltip__title {
	font-family: var(--ne-font-display);
	font-size: 18px;
	color: var(--ne-text);
	margin: 0 0 2px 0;
	line-height: 1.15;
}

.ne-cal-tooltip__fed {
	margin: 0;
	font-size: 12px;
	color: var(--ne-text-muted);
	font-family: var(--ne-font-mono);
	letter-spacing: 0.04em;
}

.ne-cal-tooltip__rows {
	display: grid;
	grid-template-columns: auto 1fr;
	row-gap: var(--ne-space-2);
	column-gap: var(--ne-space-3);
	margin: 0 0 var(--ne-space-4) 0;
	padding: var(--ne-space-3) 0;
	border-top: 1px solid var(--ne-border);
	border-bottom: 1px solid var(--ne-border);
}

.ne-cal-tooltip__row {
	display: contents;
}

.ne-cal-tooltip__row dt {
	font-size: 11px;
	color: var(--ne-text-subtle);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-family: var(--ne-font-mono);
}

.ne-cal-tooltip__row dd {
	margin: 0;
	font-size: 13px;
	color: var(--ne-text);
}

.ne-cal-tooltip__actions {
	display: flex;
	justify-content: flex-end;
}

.ne-cal-tooltip__cta {
	width: 100%;
	text-align: center;
}

/* ------------------------------------------------------------------
   9. Loading skeleton
   ------------------------------------------------------------------ */
.ne-cal-body.is-loading {
	pointer-events: none;
}

.ne-cal-body.is-loading::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: var(--ne-radius-md);
	background: linear-gradient(
		90deg,
		transparent 0%,
		var(--ne-overlay) 50%,
		transparent 100%
	);
	background-size: 200% 100%;
	animation: ne-cal-shimmer 1.2s infinite;
	z-index: 2;
}

@keyframes ne-cal-shimmer {
	0%   { background-position: -100% 0; }
	100% { background-position: 100% 0; }
}

.ne-cal-body.is-loading .ne-cal-grid,
.ne-cal-body.is-loading .ne-cal-agenda {
	opacity: 0.6;
}

/* Empty state inside grid (AJAX error or no events) */
.ne-cal-grid__empty,
.ne-cal-agenda__empty {
	padding: var(--ne-space-7) var(--ne-space-4);
	text-align: center;
	color: var(--ne-text-muted);
	font-size: 14px;
	background: var(--ne-surface);
}

/* ------------------------------------------------------------------
   10. Mobile agenda view
   ------------------------------------------------------------------ */
.ne-cal-agenda {
	background: var(--ne-surface);
	border: 1px solid var(--ne-border);
	border-radius: var(--ne-radius-md);
	overflow: hidden;
}

.ne-cal-agenda__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ne-cal-agenda__day {
	border-bottom: 1px solid var(--ne-border);
	padding: 0;
}

.ne-cal-agenda__day:last-child {
	border-bottom: 0;
}

.ne-cal-agenda__day-header {
	display: flex;
	align-items: center;
	gap: var(--ne-space-2);
	margin: 0;
	padding: var(--ne-space-3) var(--ne-space-4);
	background: var(--ne-bg);
	font-size: 13px;
	font-family: var(--ne-font-mono);
	color: var(--ne-text);
	text-transform: capitalize;
	position: sticky;
	top: 0;
	z-index: 1;
	border-bottom: 1px solid var(--ne-border);
}

.ne-cal-agenda__day--today .ne-cal-agenda__day-header {
	background: color-mix(in srgb, var(--ne-accent-glow) 60%, var(--ne-bg) 40%);
}

.ne-cal-agenda__day-label {
	flex: 1 1 auto;
}

.ne-cal-agenda__day-today {
	flex: 0 0 auto;
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding: 2px 8px;
	background: var(--ne-accent);
	color: #fff;
	border-radius: var(--ne-radius-pill);
}

.ne-cal-agenda__day-count {
	flex: 0 0 auto;
	font-size: 11px;
	color: var(--ne-text-muted);
}

.ne-cal-agenda__chips {
	display: flex;
	flex-direction: column;
	gap: var(--ne-space-2);
	padding: var(--ne-space-3) var(--ne-space-4);
}

.ne-cal-agenda__chips .ne-cal-chip {
	padding: var(--ne-space-3);
	font-size: 13px;
}

.ne-cal-agenda__chips .ne-cal-chip__time {
	font-size: 13px;
}

/* ------------------------------------------------------------------
   11. Responsive — grid <-> agenda switch
   ------------------------------------------------------------------ */
.ne-show-mobile { display: none; }
.ne-show-desktop { display: block; }

/* Tablet / narrow desktop: compact chip — hide track name and fecha pill to keep
   the hour + federation logo visible. Full details live in the tooltip. */
@media (max-width: 900px) {
	.ne-cal-grid .ne-cal-chip__track,
	.ne-cal-grid .ne-cal-chip__fecha {
		display: none;
	}
	.ne-cal-grid .ne-cal-chip {
		padding: 4px 6px;
	}
}

@media (max-width: 767.98px) {
	.ne-show-desktop { display: none; }
	.ne-show-mobile { display: block; }

	.ne-cal-filters {
		flex-direction: column;
		align-items: stretch;
	}

	.ne-cal-filters__nav {
		justify-content: space-between;
	}

	.ne-cal-filters__group {
		flex-direction: column;
		align-items: stretch;
	}

	.ne-cal-field .ne-select {
		width: 100%;
		min-width: 0;
	}

	.ne-cal-title {
		font-size: 18px;
		min-width: 120px;
	}

	.ne-cal-tooltip {
		max-width: calc(100vw - 32px);
		left: 50% !important;
		top: 50% !important;
		transform: translate(-50%, -50%) !important;
	}

	.ne-cal-tooltip.is-open {
		transform: translate(-50%, -50%) !important;
	}
}

/* ------------------------------------------------------------------
   12. Empty state / a11y helpers
   ------------------------------------------------------------------ */
.ne-sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}
