/**
 * @file
 * Calendar component.
 *
 * A view's results on the days of one month, with links to the months
 * before and after. On a wide screen the month is a table of weeks; below
 * 600px the same markup becomes a list of the days that have results, each
 * named with its weekday. Logical properties keep right-to-left layouts in
 * step, and the arrows turn with the reading direction.
 *
 * Contents:
 * 1. Months
 * 2. Table
 * 3. Caption and weekdays
 * 4. Days
 * 5. Results
 * 6. Media queries
 */

/* 1. Months
   ========================================================================== */

.viewspress-calendar-nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.5em 1em;
	margin-block: 0 0.75em;
}

.viewspress-calendar-nav__link {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding-block: 0.25em;
}

.viewspress-calendar-nav__link--next {
	margin-inline-start: auto;
}

.viewspress-calendar-nav__link:focus-visible {
	outline: 2px solid var(--viewspress-accent, var(--wp--custom--viewspress--accent, currentcolor));
	outline-offset: 2px;
}

/* Physical sides: a chevron drawn with two borders, so nothing is read
   aloud. A drawing doesn't turn with logical borders, so each direction
   sets its own. */
.viewspress-calendar-nav__link--previous::before,
.viewspress-calendar-nav__link--next::after {
	content: "";
	flex: none;
	inline-size: 0.5em;
	block-size: 0.5em;
	border-bottom: 2px solid currentcolor;
	border-left: 2px solid currentcolor;
}

.viewspress-calendar-nav__link--previous::before {
	transform: rotate(45deg);
}

.viewspress-calendar-nav__link--next::after {
	transform: rotate(-135deg);
}

.viewspress-calendar-nav__link--previous:dir(rtl)::before {
	transform: rotate(-135deg);
}

.viewspress-calendar-nav__link--next:dir(rtl)::after {
	transform: rotate(45deg);
}

/* End of 1. Months */

/* 2. Table
   ========================================================================== */

.viewspress-calendar {
	inline-size: 100%;
	margin: 0;
	border-collapse: collapse;
	table-layout: fixed;
}

/* End of 2. Table */

/* 3. Caption and weekdays
   ========================================================================== */

.viewspress-calendar__caption {
	padding-block: 0 0.5em;
	font-weight: 600;
	text-align: start;
}

.viewspress-calendar__weekday {
	padding: 0.5em 0.25em;
	font-weight: 600;
	text-align: center;
}

/* End of 3. Caption and weekdays */

/* 4. Days
   ========================================================================== */

.viewspress-calendar__day {
	padding: 0.25em;
	border: var(--viewspress-border-width, var(--wp--custom--viewspress--border-width, 1px)) solid var(--viewspress-border-color, var(--wp--custom--viewspress--border-color, currentcolor));
	vertical-align: top;
	overflow-wrap: anywhere;
}

/* No border at all, so a collapsed edge goes to the day beside it. */
.viewspress-calendar__day--outside {
	border-style: none;
}

.viewspress-calendar__date {
	margin-block: 0 0.25em;
	margin-inline: 0;
	font-weight: 600;
	text-align: end;
}

.viewspress-calendar__day.is-today .viewspress-calendar__date time {
	padding-inline: 0.25em;
	outline: 2px solid var(--viewspress-accent, var(--wp--custom--viewspress--accent, currentcolor));
}

/* End of 4. Days */

/* 5. Results
   ========================================================================== */

.viewspress-calendar__items {
	margin: 0;
	padding: 0;
	list-style: none;
}

.viewspress-calendar .viewspress-calendar__item {
	padding-block: 0.25em;
	border-bottom: 0;
	font-size: 0.875em;
}

/* End of 5. Results */

/* 6. Media queries
   ========================================================================== */

/* A phone shows a list of the days that have results. */
@media (max-width: 599px) {
	.viewspress-calendar,
	.viewspress-calendar tbody,
	.viewspress-calendar__week,
	.viewspress-calendar__day {
		display: block;
		inline-size: 100%;
	}

	.viewspress-calendar thead,
	.viewspress-calendar__day--outside,
	.viewspress-calendar__day--empty {
		display: none;
	}

	.viewspress-calendar__caption {
		display: block;
	}

	.viewspress-calendar__day {
		margin-block-end: 0.75em;
		padding: 0.5em;
	}

	.viewspress-calendar__date {
		text-align: start;
	}

	/* Two classes, so it wins over hidden.css, which loads first. */
	.viewspress-calendar .viewspress-calendar__day-name {
		position: static;
		overflow: visible;
		clip-path: none;
		inline-size: auto;
		block-size: auto;
		margin: 0;
		white-space: normal;
	}
}

/* End of 6. Media queries */
