/*
 * Copyright (c) Autodesk, Inc. All rights reserved
 *
 * Permission to use, copy, modify, and distribute this software in
 * object code form for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appears in all copies and
 * that both that copyright notice and the limited warranty and
 * restricted rights notice below appear in all supporting
 * documentation.
 *
 * AUTODESK PROVIDES THIS PROGRAM 'AS IS' AND WITH ALL FAULTS.
 * AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
 * DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
 * UNINTERRUPTED OR ERROR FREE.
 */


/*
 * Calendrier public. Couleurs pleines (pas de dégradé) ; surchargeables par le thème :
 * .tybc-calendar { --tybc-booked: #b91c1c; }
 */
.tybc-calendar {
	--tybc-available: #dcfce7;
	--tybc-available-text: #075522;
	--tybc-booked: #c0392b;
	--tybc-booked-text: #fff;
	--tybc-closed: #f0a03c;
	--tybc-closed-text: #553207;
	--tybc-unknown: #eef0f2;
	--tybc-unknown-text: #6b7280;
	--tybc-border: #e3e6ea;
	--tybc-text: #1f2937;
	--tybc-muted: #6b7280;
	--tybc-accent: #1f2937;
	--tybc-surface: #fff;
	--tybc-surface-hover: #f6f7f8;
	--tybc-past-opacity: 0.38;
	--tybc-radius: 14px;
	--tybc-gap: 20px;

	box-sizing: border-box;
	width: 100%;
	max-width: 960px;
	margin: 0 auto;
	color: var(--tybc-text);
	font-size: 15px;
	line-height: 1.4;
}

/*
 * Palette sombre : appliquée par le script (classe tybc-dark) quand le fond du site est sombre,
 * ou forcée par theme="dark". Mêmes variables, surchargeables par le thème.
 * Valeurs par défaut ; les couleurs choisies dans Réglages > Couleurs sont imprimées après ce fichier.
 */
.tybc-calendar.tybc-dark {
	--tybc-available: #dcfce7;
	--tybc-available-text: #075522;
	--tybc-booked: #b53a32;
	--tybc-booked-text: #fff;
	--tybc-closed: #e0913a;
	--tybc-closed-text: #4f300c;
	--tybc-unknown: #2c3137;
	--tybc-unknown-text: #b3bac2;
	--tybc-border: #3d434a;
	--tybc-text: #f2f4f6;
	--tybc-muted: #b6bdc5;
	--tybc-accent: #f2f4f6;
	--tybc-surface: #1e2226;
	--tybc-surface-hover: #2b3036;
	--tybc-past-opacity: 0.45;

	color-scheme: dark;
}

.tybc-calendar *,
.tybc-calendar *::before {
	box-sizing: border-box;
}

.tybc-calendar .tybc-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.tybc-calendar .tybc-range {
	margin: 0;
	font-size: 1.05em;
	font-weight: 600;
	text-align: center;
}

.tybc-calendar .tybc-nav-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--tybc-border);
	border-radius: 50%;
	background-color: var(--tybc-surface);
	color: var(--tybc-accent);
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tybc-calendar .tybc-nav-button svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
}

.tybc-calendar .tybc-nav-button:hover:not(:disabled) {
	border-color: var(--tybc-accent);
	background: var(--tybc-surface-hover);
}

.tybc-calendar .tybc-nav-button:focus-visible,
.tybc-calendar .tybc-day:focus-visible {
	outline: 3px solid #2563eb;
	outline-offset: 2px;
}

.tybc-calendar .tybc-nav-button:disabled {
	opacity: 0.35;
	cursor: default;
}

.tybc-calendar .tybc-months {
	display: grid;
	grid-template-columns: repeat(var(--tybc-visible, 1), minmax(0, 1fr));
	gap: var(--tybc-gap);
	touch-action: pan-y;
}

.tybc-calendar .tybc-month {
	padding: 16px 16px 12px;
	border: 1px solid var(--tybc-border);
	border-radius: var(--tybc-radius);
	background: var(--tybc-surface);
}

.tybc-calendar .tybc-month-title {
	margin: 0 0 10px;
	font-size: 1em;
	font-weight: 600;
	text-align: center;
}

/* Tableau sémantique (rôles ARIA explicites), mis en page en grille : cases toutes identiques. */
.tybc-calendar .tybc-grid {
	display: block;
	width: 100%;
	margin: 0;
	border: 0;
}

.tybc-calendar .tybc-grid thead,
.tybc-calendar .tybc-grid tbody {
	display: block;
}

.tybc-calendar .tybc-grid tr {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: var(--tybc-cell-gap, 4px);
	margin-bottom: var(--tybc-cell-gap, 4px);
}

.tybc-calendar .tybc-grid th,
.tybc-calendar .tybc-grid td {
	display: block;
	padding: 0;
	border: 0;
	background: none;
	text-align: center;
}

.tybc-calendar .tybc-grid th {
	padding-bottom: 4px;
	color: var(--tybc-muted);
	font-size: 0.75em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.tybc-calendar .tybc-day {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: 8px;
	font-size: 0.9em;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	cursor: default;
}

.tybc-calendar .tybc-day-number {
	position: relative;
	z-index: 1;
}

.tybc-calendar .tybc-available {
	background-color: var(--tybc-available);
	color: var(--tybc-available-text);
}

.tybc-calendar .tybc-booked {
	background-color: var(--tybc-booked);
	color: var(--tybc-booked-text);
}

.tybc-calendar .tybc-closed {
	background-color: var(--tybc-closed);
	color: var(--tybc-closed-text);
}

.tybc-calendar .tybc-unknown {
	background-color: var(--tybc-unknown);
	color: var(--tybc-unknown-text);
}

/* Jour d'arrivée / de départ : triangle haut-gauche = état de la veille. */
.tybc-calendar .tybc-changeover::before {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	content: "";
	clip-path: polygon(0 0, 100% 0, 0 100%);
}

.tybc-calendar .tybc-from-available::before {
	background-color: var(--tybc-available);
}

.tybc-calendar .tybc-from-booked::before {
	background-color: var(--tybc-booked);
}

.tybc-calendar .tybc-from-closed::before {
	background-color: var(--tybc-closed);
}

.tybc-calendar .tybc-changeover .tybc-day-number {
	color: var(--tybc-text);
	text-shadow: 0 0 3px var(--tybc-surface), 0 0 3px var(--tybc-surface);
}

.tybc-calendar .tybc-past {
	opacity: var(--tybc-past-opacity);
}

.tybc-calendar .tybc-today {
	box-shadow: inset 0 0 0 2px var(--tybc-accent);
}

.tybc-calendar .tybc-legend {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 20px;
	margin: 16px 0 0;
	padding: 0;
	list-style: none;
	font-size: 0.9em;
}

.tybc-calendar .tybc-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
}

.tybc-calendar .tybc-swatch {
	position: relative;
	display: inline-block;
	width: 18px;
	height: 18px;
	overflow: hidden;
	border-radius: 5px;
}

.tybc-calendar .tybc-updated,
.tybc-calendar .tybc-empty {
	margin: 10px 0 0;
	color: var(--tybc-muted);
	font-size: 0.85em;
	text-align: center;
}

@media (max-width: 480px) {
	.tybc-calendar {
		font-size: 14px;
	}

	.tybc-calendar .tybc-month {
		padding: 12px 8px 8px;
	}

	.tybc-calendar {
		--tybc-cell-gap: 3px;
	}
}

/* Apparence forcée (theme="light|dark") : fond propre, lisible quel que soit le fond du site. */
.tybc-calendar.tybc-forced {
	padding: 16px;
	border-radius: var(--tybc-radius);
	background-color: var(--tybc-surface);
}

/* Isolation vis-à-vis du thème (styles de tableaux, titres et boutons, éditeur de blocs). */
.tybc-calendar .tybc-range,
.tybc-calendar .tybc-month-title,
.tybc-calendar .tybc-legend-item {
	color: var(--tybc-text);
}

.tybc-calendar .tybc-grid th,
.tybc-calendar .tybc-updated,
.tybc-calendar .tybc-empty {
	color: var(--tybc-muted);
}

.tybc-calendar .tybc-month-title {
	font-family: inherit;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
}

.tybc-calendar .tybc-grid,
.tybc-calendar .tybc-grid th,
.tybc-calendar .tybc-grid td {
	width: auto;
	min-width: 0;
	height: auto;
	font-family: inherit;
	line-height: 1.2;
	word-break: normal;
	overflow-wrap: normal;
	white-space: nowrap;
	vertical-align: middle;
}

.tybc-calendar .tybc-nav-button {
	min-width: 0;
	min-height: 0;
	box-shadow: none;
	font-size: inherit;
	line-height: 1;
	text-decoration: none;
	text-shadow: none;
}

.tybc-calendar .tybc-nav-button:focus {
	outline: none;
}

/*
 * Certains thèmes (ex. Twenty Twenty-One : .site button:not(:hover):not(:active)...) imposent
 * fond et couleur des boutons avec une spécificité plus forte : !important limité à ces 3 propriétés.
 */
.tybc-calendar .tybc-nav-button,
.tybc-calendar .tybc-nav-button:disabled,
.tybc-calendar .tybc-nav-button:disabled:hover {
	border-color: var(--tybc-border) !important;
	background-color: var(--tybc-surface) !important;
	color: var(--tybc-accent) !important;
}

.tybc-calendar .tybc-nav-button:hover:not(:disabled) {
	border-color: var(--tybc-accent) !important;
	background-color: var(--tybc-surface-hover) !important;
}

/* Navigateurs sans aspect-ratio (ex. Safari 14) : case carrée par padding. */
@supports not (aspect-ratio: 1 / 1) {
	.tybc-calendar .tybc-day {
		height: 0;
		padding-top: 100%;
	}

	.tybc-calendar .tybc-day-number {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.tybc-calendar .tybc-nav-button {
		transition: none;
	}
}
