/*
 * Schedule Sync — default styles.
 *
 * Deliberately plain: everything inherits your theme's fonts and colours.
 * Every selector is wrapped in :where() so it has zero specificity, which means
 * any rule you add in Appearance → Customise → Additional CSS wins automatically.
 *
 * Override these variables to restyle everything at once, e.g.
 *   :root { --ss-accent: #b45309; --ss-radius: 0; }
 *
 * Blocks can also be styled per block in the editor (Styles panel), and a
 * theme can replace this whole file with your-theme/schedule-sync/schedule-sync.css.
 *
 * Opening hours columns (the block's Day names / Times / Hours colours settings
 * set these on the table, which always win over the theme; you can also set
 * them yourself in CSS):
 *   --ss-day-weight, --ss-day-style, --ss-day-align, --ss-day-color
 *   --ss-time-weight, --ss-time-style, --ss-time-align, --ss-time-color
 *   --ss-today (today's background), --ss-today-color (today's text)
 *
 * Events in the Events block (and single event pages) carry
 * .schedule-sync-event-past, -ongoing or -upcoming, e.g. to fade past events:
 *   .schedule-sync-event-past { opacity: .55; filter: grayscale(1); }
 *
 * An Events block set to "Slide as a carousel" gets .is-ss-carousel; its row
 * layout and controls are in events-carousel.css, which always loads with it.
 */

:root {
	--ss-accent: currentColor;
	--ss-border: rgba(127, 127, 127, 0.25);
	--ss-muted: rgba(127, 127, 127, 0.08);
	--ss-gap: 1rem;
	--ss-radius: 8px;
	--ss-padding: 1rem;
	--ss-today: rgba(127, 127, 127, 0.12);
	--ss-open: #15803d;
	--ss-closed: #b91c1c;
	--ss-badge-bg: var(--ss-muted);
}

/* Opening times ------------------------------------------------------- */

:where(.schedule-sync-hours) {
	width: 100%;
	border-collapse: collapse;
}

:where(.schedule-sync-hours th, .schedule-sync-hours td) {
	padding: 0.4em 0;
	vertical-align: top;
	border-bottom: 1px solid var(--ss-border);
}

:where(.schedule-sync-hours th) {
	padding-right: var(--ss-gap);
	font-weight: var(--ss-day-weight, 600);
	font-style: var(--ss-day-style, normal);
	text-align: var(--ss-day-align, left);
	color: var(--ss-day-color, inherit);
}

:where(.schedule-sync-hours td) {
	font-weight: var(--ss-time-weight, inherit);
	font-style: var(--ss-time-style, normal);
	text-align: var(--ss-time-align, left);
	color: var(--ss-time-color, inherit);
}

:where(.schedule-sync-hours tr:last-child th, .schedule-sync-hours tr:last-child td) {
	border-bottom: 0;
}

:where(.schedule-sync-override-label) {
	display: block;
	font-size: 0.85em;
	opacity: 0.75;
}

:where(.schedule-sync-hours tr.is-today) {
	background: var(--ss-today);
	font-weight: 600;
}

/* Settings chosen in the block. Each applies only when chosen (the has-ss-* class),
   and is specific enough to beat a theme's own table styles. */
.schedule-sync-hours.has-ss-day-weight th { font-weight: var(--ss-day-weight); }
.schedule-sync-hours.has-ss-day-style th { font-style: var(--ss-day-style); }
.schedule-sync-hours.has-ss-day-align th { text-align: var(--ss-day-align); }
.schedule-sync-hours.has-ss-day-color th { color: var(--ss-day-color); }
.schedule-sync-hours.has-ss-time-weight td { font-weight: var(--ss-time-weight); }
.schedule-sync-hours.has-ss-time-style td { font-style: var(--ss-time-style); }
.schedule-sync-hours.has-ss-time-align td { text-align: var(--ss-time-align); }
.schedule-sync-hours.has-ss-time-color td { color: var(--ss-time-color); }
.schedule-sync-hours.has-ss-today tr.is-today { background: var(--ss-today); }
.schedule-sync-hours.has-ss-today-color tr.is-today > * { color: var(--ss-today-color); }

/* Today's text colour wins over the column colours. */
:where(.schedule-sync-hours tr.is-today th) {
	color: var(--ss-today-color, var(--ss-day-color, inherit));
}

:where(.schedule-sync-hours tr.is-today td) {
	color: var(--ss-today-color, var(--ss-time-color, inherit));
}

:where(.schedule-sync-hours tr.is-today th, .schedule-sync-hours tr.is-today td) {
	padding-left: 0.5em;
	padding-right: 0.5em;
}

/* Open / closed status ------------------------------------------------ */

:where(.schedule-sync-status) {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	font-weight: 600;
}

:where(.schedule-sync-status-dot) {
	width: 0.6em;
	height: 0.6em;
	border-radius: 50%;
	background: var(--ss-closed);
	flex: none;
}

:where(.schedule-sync-status.is-open .schedule-sync-status-dot) {
	background: var(--ss-open);
}

/* A coloured tag gets a little breathing room (the Styles panel's padding overrides it). */
:where(.schedule-sync-status.has-background) {
	padding: 0.35em 0.75em;
	border-radius: var(--ss-radius);
}

/* Width: fit the text (default) or fill the column. Alignment applies to both. */
:where(.is-width-full .schedule-sync-status) {
	display: flex;
}

:where(.is-width-full.has-text-align-center .schedule-sync-status) {
	justify-content: center;
}

:where(.is-width-full.has-text-align-right .schedule-sync-status) {
	justify-content: flex-end;
}

:where(.wp-block-schedule-sync-open-status.has-text-align-left, .schedule-sync-status-wrap.has-text-align-left) {
	text-align: left;
}

:where(.wp-block-schedule-sync-open-status.has-text-align-center, .schedule-sync-status-wrap.has-text-align-center) {
	text-align: center;
}

:where(.wp-block-schedule-sync-open-status.has-text-align-right, .schedule-sync-status-wrap.has-text-align-right) {
	text-align: right;
}

/* Special dates + note ------------------------------------------------ */

:where(.schedule-sync-special-dates) {
	list-style: none;
	margin: 0;
	padding: 0;
}

:where(.schedule-sync-special-dates li) {
	padding: 0.3em 0;
}

:where(.schedule-sync-special-label) {
	font-weight: 600;
}

:where(.schedule-sync-special-dates.is-justify-center) {
	text-align: center;
}

:where(.schedule-sync-special-dates.is-justify-right) {
	text-align: right;
}

/* Spread: name and date on the left, times on the right. */
:where(.schedule-sync-special-dates.is-justify-space-between li:not(.schedule-sync-special-dates-heading-item)) {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0 var(--ss-gap);
}

:where(.schedule-sync-special-dates.is-justify-space-between .schedule-sync-special-sep) {
	display: none;
}

:where(.schedule-sync-heading) {
	margin: 0 0 0.5em;
	font-weight: 600;
}

:where(.schedule-sync-note) {
	padding: var(--ss-padding);
	background: var(--ss-muted);
	border-radius: var(--ss-radius);
}

:where(.schedule-sync-note p) {
	margin: 0;
}

:where(.schedule-sync-note.has-text-align-left) {
	text-align: left;
}

:where(.schedule-sync-note.has-text-align-center) {
	text-align: center;
}

:where(.schedule-sync-note.has-text-align-right) {
	text-align: right;
}

/* Event listing ------------------------------------------------------- */

:where(.schedule-sync-events--grid) {
	display: grid;
	gap: var(--ss-gap);
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

:where(.schedule-sync-events--list) {
	display: flex;
	flex-direction: column;
	gap: var(--ss-gap);
}

:where(.schedule-sync-event-card) {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--ss-border);
	border-radius: var(--ss-radius);
}

:where(.schedule-sync-event-card.is-past) {
	opacity: 0.55;
	filter: grayscale(1);
}

:where(.schedule-sync-event-media) {
	position: relative;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: var(--ss-muted);
}

:where(.schedule-sync-event-media img) {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

:where(.schedule-sync-event-media-link) {
	position: absolute;
	inset: 0;
}

:where(.schedule-sync-event-badge) {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 1.1;
	text-align: center;
}

:where(.schedule-sync-event-badge.is-filled) {
	position: absolute;
	inset: 0;
}

:where(.schedule-sync-event-badge.is-overlay) {
	position: absolute;
	top: 8px;
	left: 8px;
	padding: 4px 8px;
	border-radius: calc(var(--ss-radius) / 2);
	background: rgba(255, 255, 255, 0.9);
	color: #111;
}

:where(.schedule-sync-event-badge .ss-badge-day) {
	font-size: 1.6em;
	font-weight: 700;
}

:where(.schedule-sync-event-badge .ss-badge-month, .schedule-sync-event-badge .ss-badge-year) {
	font-size: 0.75em;
	letter-spacing: 0.06em;
}

:where(.schedule-sync-event-body) {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 0.5em;
	padding: var(--ss-padding);
}

:where(.schedule-sync-event-title) {
	margin: 0;
	font-size: 1.1em;
}

:where(.schedule-sync-event-title a) {
	color: inherit;
	text-decoration: none;
}

:where(.schedule-sync-event-meta, .schedule-sync-event-excerpt) {
	margin: 0;
	font-size: 0.9em;
}

:where(.schedule-sync-event-actions) {
	margin-top: auto;
}

@media (min-width: 641px) {
	:where(.schedule-sync-events--list .schedule-sync-event-card) {
		flex-direction: row;
	}

	:where(.schedule-sync-events--list .schedule-sync-event-media) {
		flex: 0 0 160px;
	}
}

/* Event detail shortcodes --------------------------------------------- */

:where(.schedule-sync-event-meta-block) {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25em var(--ss-gap);
}

:where(.schedule-sync-event-meta-block.is-stacked) {
	flex-direction: column;
}

/* Justification: in a row it spaces the items; stacked, it aligns them. */
:where(.schedule-sync-event-meta-block.is-justify-center) {
	justify-content: center;
}

:where(.schedule-sync-event-meta-block.is-justify-right) {
	justify-content: flex-end;
}

:where(.schedule-sync-event-meta-block.is-justify-space-between) {
	justify-content: space-between;
}

:where(.schedule-sync-event-meta-block.is-stacked.is-justify-center) {
	align-items: center;
	text-align: center;
}

:where(.schedule-sync-event-meta-block.is-stacked.is-justify-right) {
	align-items: flex-end;
	text-align: right;
}

:where(.schedule-sync-meta-label) {
	font-weight: 600;
	margin-right: 0.25em;
}

/* Event Image: the featured image, or a date tile when there isn't one */

:where(.schedule-sync-event-figure) {
	position: relative;
	overflow: hidden;
}

:where(.schedule-sync-event-figure img) {
	display: block;
	max-width: 100%;
	height: auto;
}

:where(.schedule-sync-event-figure.has-aspect-ratio img) {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

:where(.schedule-sync-event-figure.has-no-image) {
	aspect-ratio: 16 / 10;
	background: var(--ss-badge-bg, var(--ss-muted));
	color: var(--ss-badge-text, inherit);
	border-radius: var(--ss-radius);
}

/* As a block, its own radius and spacing settings take over (its colours go on the date). */
:where(.wp-block-schedule-sync-event-image) {
	overflow: hidden;
}

:where(.wp-block-schedule-sync-event-image .schedule-sync-event-figure) {
	border-radius: inherit;
}

:where(.schedule-sync-event-figure-link) {
	display: block;
	height: 100%;
	color: inherit;
	text-decoration: none;
}

:where(.schedule-sync-event-figure-link:hover, .schedule-sync-event-figure-link:focus-visible) {
	opacity: 0.9;
}

/* Full events archive ------------------------------------------------- */

:where(.schedule-sync-archive-pagination) {
	margin-top: calc(var(--ss-gap) * 1.5);
}

:where(.schedule-sync-events-archive .nav-links) {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5em;
}

/* Editor-only hints (sample details, empty states) ----------------------- */

:where(.schedule-sync-editor-hint) {
	margin: 0.5em 0 0;
	font-size: 0.8em;
	opacity: 0.7;
}
