/*
 * /jours-ouvres/, /jours-feries/ and /numero-de-semaine/: loaded by
 * inc/assets.php on these three pages, after checker.css, which brings the
 * panel, the field and the error. The pages carry sp-reading
 * (inc/setup.php): every colour comes from the theme.css variables, which
 * follow the system dark scheme. Errors in raspberry (--sp-error). No red:
 * the pages have no contact button. No blue.
 */

/* What the script shows and hides: hidden wins over any display. */
.sp-dates [hidden] {
	display: none !important;
}

.sp-dates-nojs {
	padding: var(--wp--preset--spacing--md) var(--wp--preset--spacing--lg);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--preset--border-radius--sm);
}

/* ---------- The tools: the zone, then one card each, two columns from 960 px ---------- */

.sp-dates-tool {
	display: grid;
	gap: var(--wp--preset--spacing--lg);
	margin-top: var(--wp--preset--spacing--lg);
}

.sp-dates-zone,
.sp-dates-card {
	gap: var(--wp--preset--spacing--md);
	min-width: 0;
	scroll-margin-top: 6rem;
}

.sp-dates-zone > *,
.sp-dates-card > * {
	margin: 0;
}

.sp-dates-cards {
	display: grid;
	gap: var(--wp--preset--spacing--lg);
}

@media (min-width: 960px) {
	.sp-dates-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		align-items: start;
	}
}

.sp-dates-title {
	font-size: var(--wp--preset--font-size--title, 1.35rem);
}

.sp-dates-fields {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--md);
}

.sp-dates-input {
	flex: 1 1 10rem;
	min-width: 0;
}

/* Scoped to the tools to outweigh the field rule of theme.css (width 100 %). */
.sp-dates .sp-dates-field,
.sp-dates .sp-dates-select {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-height: 2.75rem;
	padding: 0.35rem 0.6rem;
	border: 1.5px solid var(--wp--preset--color--line);
	border-radius: var(--wp--preset--border-radius--sm);
	background: var(--wp--preset--color--paper);
	color: var(--wp--preset--color--ink);
	font-family: inherit;
	font-size: 1.05rem;
	line-height: 1.4;
	color-scheme: light dark;
}

.sp-dates .sp-dates-field--number {
	font-family: var(--wp--preset--font-family--mono);
	font-variant-numeric: tabular-nums;
}

.sp-dates :is(.sp-dates-field, .sp-dates-select):not([aria-invalid="true"]):hover {
	border-color: var(--wp--preset--color--ink-muted);
}

.sp-dates-field:focus-visible,
.sp-dates-select:focus-visible {
	outline: 3px solid var(--sp-focus);
	outline-offset: 1px;
}

.sp-dates-field[aria-invalid="true"],
.sp-dates-select[aria-invalid="true"] {
	border-color: var(--sp-error);
}

.sp-dates-zone-note {
	color: var(--wp--preset--color--ink-muted);
	font-size: var(--wp--preset--font-size--small);
}

/* ---------- The result ---------- */

.sp-dates-result {
	display: grid;
	gap: var(--wp--preset--spacing--sm);
	padding-top: var(--wp--preset--spacing--md);
	border-top: 1px solid var(--wp--preset--color--line);
}

.sp-dates-result > * {
	margin: 0;
}

/* The last result kept while a field is wrong (spec, "Erreurs"). */
.sp-dates-result[data-stale] {
	opacity: 0.45;
}

.sp-dates-out {
	display: grid;
	gap: var(--wp--preset--spacing--xs);
	margin: 0;
}

.sp-dates-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 var(--wp--preset--spacing--sm);
}

.sp-dates-row dt {
	color: var(--wp--preset--color--ink-muted);
	font-size: 0.95rem;
	font-weight: 650;
}

.sp-dates-row dd {
	margin: 0;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.sp-dates-row--main dd {
	font-size: 1.6rem;
	font-weight: 700;
	line-height: 1.2;
}

.sp-dates-list-title {
	font-weight: 650;
}

/* A long period can hold hundreds of holidays: the list scrolls inside itself. */
.sp-dates-list {
	max-height: 16rem;
	margin: 0;
	padding-left: 1.2em;
	overflow-y: auto;
	font-size: var(--wp--preset--font-size--small);
}

.sp-dates-list li + li {
	margin-top: 0.2rem;
}

/* ---------- /jours-feries/: the next holiday and the years ---------- */

.sp-dates-next {
	margin: 0;
	padding: var(--wp--preset--spacing--md) var(--wp--preset--spacing--lg);
	border-left: 4px solid var(--wp--preset--color--line);
	background: var(--wp--preset--color--paper);
	font-size: 1.15rem;
	font-weight: 650;
}

.sp-dates-years {
	display: grid;
	gap: var(--wp--preset--spacing--lg);
}

@media (min-width: 960px) {
	.sp-dates-years {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		align-items: start;
	}
}

.sp-dates-year {
	min-width: 0;
}

.sp-dates-year__title {
	margin: 0 0 var(--wp--preset--spacing--sm);
	font-size: var(--wp--preset--font-size--title, 1.35rem);
}

/* ---------- /numero-de-semaine/: the current week ---------- */

.sp-dates-now {
	gap: var(--wp--preset--spacing--xs);
	margin-top: var(--wp--preset--spacing--lg);
}

.sp-dates-now > * {
	margin: 0;
}

.sp-dates-now__label {
	color: var(--wp--preset--color--ink-muted);
	font-size: 0.95rem;
	font-weight: 650;
}

.sp-dates-now__week {
	font-size: clamp(2.25rem, 6vw, 3.5rem);
	font-weight: 700;
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
}

.sp-dates-now__days {
	font-size: 1.15rem;
	font-weight: 650;
}

.sp-dates-now__today {
	color: var(--wp--preset--color--ink-muted);
	font-size: var(--wp--preset--font-size--small);
}

/* ---------- Reading sections ---------- */

.sp-dates-read h2,
.sp-dates-faq h2 {
	margin-block: 0;
}

.sp-dates-read__body > * {
	margin-block: 0;
}

.sp-dates-read__body > * + * {
	margin-top: var(--wp--preset--spacing--md);
}

.sp-dates-steps {
	padding-left: 1.4em;
}

.sp-dates-steps li + li {
	margin-top: var(--wp--preset--spacing--sm);
}

.sp-dates-tables {
	display: grid;
	gap: var(--wp--preset--spacing--lg);
}

@media (min-width: 720px) {
	.sp-dates-tables {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		align-items: start;
	}
}

/* The tables scroll inside themselves, never the page (375 px); relative, so the
   screen-reader-only caption stays inside them too. */
.sp-dates-table {
	position: relative;
	min-width: 0;
	overflow-x: auto;
}

.sp-dates-table table {
	width: 100%;
	min-width: 16rem;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

.sp-dates-table caption {
	padding-bottom: var(--wp--preset--spacing--xs);
	font-weight: 650;
	text-align: left;
}

.sp-dates-table th,
.sp-dates-table td {
	padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--sm);
	border-top: 1px solid var(--wp--preset--color--line);
	text-align: left;
	vertical-align: top;
}

.sp-dates-table thead th {
	color: var(--wp--preset--color--ink-muted);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 650;
}

.sp-dates-table tbody th,
.sp-dates-table tfoot th,
.sp-dates-table tfoot td {
	font-weight: 650;
}

.sp-dates-now-row {
	background: var(--wp--preset--color--paper);
	box-shadow: inset 4px 0 0 var(--wp--preset--color--ink);
}

.sp-dates-source {
	color: var(--wp--preset--color--ink-muted);
	font-size: var(--wp--preset--font-size--small);
}

/* Read by screen readers only: the caption of the rules and the result read out. */
.sp-dates-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}
