/* Free Time Grid */

.ftg-app {
	--ftg-accent: #2563eb;
	/* Neutral fallbacks: readable on a light or a dark page. */
	--ftg-off: rgba(128, 128, 128, .24);
	--ftg-line: rgba(128, 128, 128, .42);
	--ftg-muted: rgba(128, 128, 128, 1);
	--ftg-cell-h: 22px;
	--ftg-radius: 3px;
	position: relative;
	font-size: 14px;
	line-height: 1.4;
}

/*
 * Tint everything from the inherited text colour, so the grid follows the
 * theme it is dropped into instead of guessing at the visitor's OS setting.
 */
@supports ( background: color-mix( in srgb, currentColor 10%, transparent ) ) {
	.ftg-app {
		--ftg-off: color-mix( in srgb, currentColor 14%, transparent );
		--ftg-line: color-mix( in srgb, currentColor 26%, transparent );
		--ftg-muted: color-mix( in srgb, currentColor 68%, transparent );
	}
}

.ftg-wrap .ftg-heading {
	margin: 0 0 .25em;
}

.ftg-intro {
	margin-bottom: 1em;
}

/* --- bar ---------------------------------------------------------------- */

.ftg-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 12px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.ftg-pager {
	display: flex;
	gap: 4px;
	align-items: center;
}

.ftg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2em;
	padding: .3em .7em;
	border: 1px solid var(--ftg-line);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font-size: 13px;
	line-height: 1.3;
	text-decoration: none;
	cursor: pointer;
}

.ftg-btn:hover,
.ftg-btn:focus {
	border-color: var(--ftg-accent);
	color: var(--ftg-accent);
}

.ftg-btn.is-disabled {
	opacity: .4;
	cursor: default;
	pointer-events: none;
}

.ftg-title {
	flex: 1 1 auto;
	min-width: 8em;
	font-weight: 600;
	text-align: center;
}

.ftg-aux {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 10px;
	align-items: center;
	font-size: 13px;
}

.ftg-aux .ftg-jump {
	max-width: 10.5em;
	padding: .25em .4em;
	border: 1px solid var(--ftg-line);
	border-radius: 4px;
	font-size: 13px;
	background: transparent;
	color: inherit;
}

.ftg-next-free {
	color: var(--ftg-accent);
	text-decoration: none;
	white-space: nowrap;
}

.ftg-next-free:hover {
	text-decoration: underline;
}

/* --- tools (editor) ----------------------------------------------------- */

.ftg-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 10px;
	align-items: center;
	margin-bottom: 10px;
}

.ftg-status {
	font-size: 12px;
	color: var(--ftg-muted);
	min-height: 1.4em;
}

.ftg-status.is-saved {
	color: #1a9456;
}

.ftg-status.is-error {
	color: #d93b3b;
	font-weight: 600;
}

/* --- grid --------------------------------------------------------------- */

.ftg-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.ftg-grid {
	display: grid;
	/* Overridden inline per page; this is only a fallback. */
	grid-template-columns: max-content repeat(7, minmax(0, 1fr));
	gap: 2px;
	align-items: stretch;
	min-width: calc(4em + var(--ftg-cols, 7) * 2.1em);
	transition: opacity .12s ease;
}

.ftg-grid.is-loading,
.ftg.is-loading .ftg-grid {
	opacity: .45;
}

.ftg-corner {
	min-width: 3.4em;
}

.ftg-day {
	-webkit-appearance: none;
	appearance: none;
	padding: 2px 1px 5px;
	border: 0;
	border-bottom: 1px solid var(--ftg-line);
	background: none;
	font: inherit;
	color: inherit;
	text-align: center;
	line-height: 1.15;
}

.ftg-day .ftg-dow {
	display: block;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--ftg-muted);
}

.ftg-day .ftg-dom {
	display: block;
	font-size: 14px;
	font-weight: 600;
}

.ftg-day .ftg-mon {
	display: block;
	font-size: 10px;
	text-transform: uppercase;
	color: var(--ftg-muted);
}

.ftg-day.is-today .ftg-dom {
	display: inline-block;
	min-width: 1.6em;
	border-radius: 999px;
	background: var(--ftg-accent);
	color: #fff;
}

.ftg-day.is-past {
	opacity: .62;
}

.ftg-grid.is-editable .ftg-day,
.ftg-grid.is-editable .ftg-time {
	cursor: pointer;
}

.ftg-grid.is-editable .ftg-day:hover,
.ftg-grid.is-editable .ftg-time:hover {
	color: var(--ftg-accent);
}

.ftg-time {
	-webkit-appearance: none;
	appearance: none;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding: 0 .5em 0 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 11px;
	color: var(--ftg-muted);
	white-space: nowrap;
	text-align: right;
}

.ftg-cell {
	height: var(--ftg-cell-h);
	border-radius: var(--ftg-radius);
	background: var(--ftg-off);
}

.ftg-cell.is-on {
	background: var(--ftg-accent);
}

.ftg-cell.is-past {
	opacity: .5;
}

.ftg-cell.is-on.is-past {
	opacity: .78;
}

.ftg-cell.is-hour,
.ftg-time.is-hour {
	margin-top: 4px;
}

.ftg-time.is-hour {
	font-weight: 600;
	color: inherit;
}

.ftg-grid.is-editable .ftg-cell {
	cursor: cell;
	touch-action: none;
}

.ftg-grid.is-editable .ftg-cell:hover {
	box-shadow: inset 0 0 0 2px var(--ftg-accent);
}

.ftg-grid.is-editable .ftg-cell:focus-visible {
	outline: 2px solid var(--ftg-accent);
	outline-offset: 1px;
}

.ftg-grid.is-painting {
	-webkit-user-select: none;
	user-select: none;
}

.ftg-grid.is-painting .ftg-cell:hover {
	box-shadow: none;
}

/* --- footer ------------------------------------------------------------- */

.ftg-list {
	margin: 12px 0 0;
	padding: 0;
	list-style: none;
	font-size: 13px;
}

.ftg-list li + li {
	margin-top: 2px;
}

.ftg-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	margin: 10px 0 0;
	font-size: 12px;
	color: var(--ftg-muted);
}

.ftg-meta [data-ftg-total] {
	font-weight: 600;
	color: inherit;
}

.ftg-tz::before {
	content: "·";
	margin-right: .6em;
}

/* --- admin tweaks ------------------------------------------------------- */

.ftg-wrap .ftg-help {
	max-width: 44em;
	color: #50575e;
}

.ftg-app--edit {
	max-width: 70em;
	margin: 1em 0;
	padding: 16px;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	background: #fff;
	color: #2c3338;
}

@media ( max-width: 640px ) {
	.ftg-app {
		--ftg-cell-h: 20px;
	}

	.ftg-title {
		order: -1;
		flex-basis: 100%;
		text-align: left;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.ftg-grid {
		transition: none;
	}
}
