/**
 * Booking UI — availability calendar and reservation form.
 *
 * Owned by the plugin, not the theme, because this is business logic made
 * visible and it has to survive a theme change (spec §43.7). It reads the
 * theme's custom properties where they exist and falls back to the brand
 * values sampled from the logo, so it inherits the design system without
 * requiring it.
 *
 * Colour is never the only signal: every calendar state also carries a word,
 * a shape, or both (WCAG 1.4.1). Motion is limited to transform and opacity,
 * and removed entirely under prefers-reduced-motion.
 */

.dharmasetu-calendar,
.dharmasetu-booking-form {
	--ds-saffron: var(--wp--preset--color--saffron, #e67e22);
	--ds-deep-saffron: var(--wp--preset--color--deep-saffron, #c85a16);
	--ds-navy: var(--wp--preset--color--navy, #0a1450);
	--ds-gold: var(--wp--preset--color--gold, #c99a2e);
	--ds-cream: var(--wp--preset--color--cream, #fff8e7);
	--ds-ivory: var(--wp--preset--color--ivory, #fffdf7);

	--ds-ink: #26262b;
	--ds-muted: #6b6b73;
	--ds-line: #e4ded1;

	--ds-open: #1f7a4d;
	--ds-open-bg: #e8f6ee;
	--ds-partial: #9a6206;
	--ds-partial-bg: #fdf2dc;
	--ds-full: #8d2230;
	--ds-full-bg: #fbe9eb;

	--ds-radius: 10px;
	--ds-gap: clamp(0.5rem, 1.4vw, 0.9rem);
	--ds-ease: cubic-bezier(0.16, 1, 0.3, 1);

	color: var(--ds-ink);
	font-family: inherit;
}

.dharmasetu-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------- Calendar */

.dharmasetu-calendar {
	margin-block-end: clamp(1.75rem, 4vw, 2.75rem);
}

.dharmasetu-calendar__head {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: baseline;
	justify-content: space-between;
	margin-block-end: 0.75rem;
}

.dharmasetu-calendar__title {
	margin: 0;
	font-size: clamp(1.25rem, 0.9rem + 1.1vw, 1.6rem);
	line-height: 1.2;
	color: var(--ds-navy);
}

.dharmasetu-calendar__nav-group {
	display: flex;
	gap: 0.35rem;
	align-items: center;
}

.dharmasetu-calendar__month {
	min-width: 10ch;
	font-weight: 600;
	text-align: center;
	color: var(--ds-navy);
}

.dharmasetu-calendar__nav {
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	font-size: 1.35rem;
	line-height: 1;
	color: var(--ds-deep-saffron);
	text-decoration: none;
	background: var(--ds-ivory);
	border: 1px solid var(--ds-line);
	border-radius: 50%;
	transition: background 160ms var(--ds-ease), transform 160ms var(--ds-ease);
}

.dharmasetu-calendar__nav:hover:not(.is-disabled) {
	background: var(--ds-cream);
	transform: translateY(-1px);
}

.dharmasetu-calendar__nav.is-disabled {
	color: var(--ds-line);
	cursor: default;
}

/* Legend ------------------------------------------------------------------ */

.dharmasetu-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1.1rem;
	padding: 0;
	margin: 0 0 0.9rem;
	font-size: 0.85rem;
	color: var(--ds-muted);
	list-style: none;
}

.dharmasetu-legend__item {
	display: flex;
	gap: 0.4rem;
	align-items: center;
}

.dharmasetu-swatch {
	width: 0.85rem;
	height: 0.85rem;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 3px;
}

.dharmasetu-swatch--open {
	background: var(--ds-open-bg);
	border-color: var(--ds-open);
}

.dharmasetu-swatch--partial {
	background: var(--ds-partial-bg);
	border-color: var(--ds-partial);
}

.dharmasetu-swatch--full {
	background: var(--ds-full-bg);
	border-color: var(--ds-full);
}

.dharmasetu-swatch--unavailable {
	background: repeating-linear-gradient(
		45deg,
		#f2f2f2,
		#f2f2f2 3px,
		#e2e2e2 3px,
		#e2e2e2 6px
	);
}

/* Grid -------------------------------------------------------------------- */

.dharmasetu-calendar__grid-wrap {
	overflow-x: auto;
}

.dharmasetu-calendar__grid {
	width: 100%;
	border-collapse: separate;
	border-spacing: 4px;
	table-layout: fixed;
}

.dharmasetu-calendar__grid th {
	padding-block: 0.35rem;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ds-muted);
}

.dharmasetu-calendar__grid th abbr {
	text-decoration: none;
	border: 0;
}

.dharmasetu-day {
	padding: 0;
	vertical-align: top;
}

.dharmasetu-day__inner {
	display: flex;
	flex-direction: column;
	gap: 1px;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 3.1rem;
	padding: 0.35rem 0.2rem;
	font: inherit;
	color: inherit;
	background: none;
	border: 1px solid transparent;
	border-radius: var(--ds-radius);
}

.dharmasetu-day__num {
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1;
}

.dharmasetu-day__free {
	font-size: 0.65rem;
	line-height: 1;
	letter-spacing: 0.02em;
	opacity: 0.85;
}

/* A day you can act on is a button, and looks like one you can press. */
button.dharmasetu-day__inner {
	cursor: pointer;
	transition:
		transform 160ms var(--ds-ease),
		box-shadow 160ms var(--ds-ease),
		background 160ms var(--ds-ease);
}

button.dharmasetu-day__inner:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(10, 20, 80, 0.13);
}

button.dharmasetu-day__inner:active {
	transform: translateY(0);
}

.dharmasetu-day--open .dharmasetu-day__inner {
	color: var(--ds-open);
	background: var(--ds-open-bg);
	border-color: rgba(31, 122, 77, 0.28);
}

.dharmasetu-day--partial .dharmasetu-day__inner {
	color: var(--ds-partial);
	background: var(--ds-partial-bg);
	border-color: rgba(154, 98, 6, 0.3);
}

.dharmasetu-day--full .dharmasetu-day__inner {
	color: var(--ds-full);
	background: var(--ds-full-bg);
	border-color: rgba(141, 34, 48, 0.25);
}

.dharmasetu-day--unavailable .dharmasetu-day__inner {
	color: #9b9b9b;
	background: repeating-linear-gradient(
		45deg,
		#fafafa,
		#fafafa 4px,
		#f0f0f0 4px,
		#f0f0f0 8px
	);
}

.dharmasetu-day--empty {
	background: none;
}

.dharmasetu-day.is-today .dharmasetu-day__inner {
	outline: 2px dotted var(--ds-gold);
	outline-offset: -3px;
}

/* The chosen day is marked by weight and a ring, not by colour alone. */
.dharmasetu-day.is-selected .dharmasetu-day__inner {
	color: #fff;
	background: var(--ds-navy);
	border-color: var(--ds-navy);
	box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.45);
}

.dharmasetu-calendar.is-loading {
	opacity: 0.55;
}

/* -------------------------------------------------------------------- Form */

.dharmasetu-booking-form {
	max-width: 46rem;
}

.dharmasetu-fieldset {
	padding: clamp(1rem, 2.5vw, 1.6rem);
	margin: 0 0 var(--ds-gap);
	background: var(--ds-ivory);
	border: 1px solid var(--ds-line);
	border-radius: var(--ds-radius);
}

.dharmasetu-fieldset > legend {
	padding-inline: 0.5rem;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--ds-navy);
}

.dharmasetu-field {
	margin-block: 0 1rem;
}

/* `:where()` contributes NO specificity, so this whole selector weighs the
   same as a bare `label` — and every class-based rule below beats it without
   anyone having to think about it.

   This started as `.dharmasetu-field label`, which silently out-specified
   `.dharmasetu-block-option { display: grid }` and flattened the time-period
   cards. The first fix was `:not(.dharmasetu-block-option)` — which made the
   selector *heavier* and promptly broke the policies checkbox the same way.
   Adding exceptions to an over-specific base rule just moves the trap around;
   making the base rule weightless removes it. */
:where( .dharmasetu-field, .dharmasetu-date-input ) label {
	display: block;
	margin-block-end: 0.3rem;
	font-size: 0.9rem;
	font-weight: 600;
}

.dharmasetu-field input[type="text"],
.dharmasetu-field input[type="email"],
.dharmasetu-field input[type="tel"],
.dharmasetu-field input[type="number"],
.dharmasetu-field input[type="date"],
.dharmasetu-field select,
.dharmasetu-field textarea,
.dharmasetu-date-input input {
	width: 100%;
	padding: 0.55rem 0.7rem;
	font: inherit;
	color: inherit;
	background: #fff;
	border: 1px solid var(--ds-line);
	border-radius: 7px;
}

.dharmasetu-field input:focus-visible,
.dharmasetu-field select:focus-visible,
.dharmasetu-field textarea:focus-visible,
.dharmasetu-day__inner:focus-visible,
.dharmasetu-calendar__nav:focus-visible,
.dharmasetu-check-button:focus-visible {
	outline: 3px solid var(--ds-saffron);
	outline-offset: 2px;
}

.dharmasetu-date-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	align-items: flex-end;
}

.dharmasetu-date-input {
	flex: 1 1 12rem;
}

.dharmasetu-check-button {
	padding: 0.55rem 1rem;
	font: inherit;
	font-weight: 600;
	color: var(--ds-deep-saffron);
	cursor: pointer;
	background: var(--ds-cream);
	border: 1px solid var(--ds-line);
	border-radius: 7px;
}

.dharmasetu-check-button:hover {
	background: #fdf0d8;
}

/* Time periods ------------------------------------------------------------ */

.dharmasetu-blocks {
	padding: 0;
	margin-block-start: 0.25rem;
	border: 0;
}

.dharmasetu-blocks > legend {
	margin-block-end: 0.4rem;
	font-size: 0.9rem;
	font-weight: 600;
}

.dharmasetu-blocks__hint {
	margin: 0 0 0.6rem;
	font-size: 0.88rem;
	color: var(--ds-muted);
}

.dharmasetu-blocks__hint--warn {
	padding: 0.5rem 0.7rem;
	color: var(--ds-partial);
	background: var(--ds-partial-bg);
	border-radius: 7px;
}

.dharmasetu-block-list {
	display: grid;
	gap: 0.5rem;
	grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}

.dharmasetu-block-option {
	display: grid;
	grid-template-areas:
		"radio label price"
		"radio time  price"
		"radio state state";
	grid-template-columns: auto 1fr auto;
	gap: 0 0.6rem;
	align-items: center;
	padding: 0.7rem 0.8rem;
	cursor: pointer;
	background: #fff;
	border: 1px solid var(--ds-line);
	border-radius: var(--ds-radius);
	transition: border-color 160ms var(--ds-ease), box-shadow 160ms var(--ds-ease);
}

.dharmasetu-block-option label,
.dharmasetu-block-option > * {
	margin: 0;
}

.dharmasetu-block-option input {
	grid-area: radio;
	width: 1.05rem;
	height: 1.05rem;
	accent-color: var(--ds-deep-saffron);
}

.dharmasetu-block-label {
	grid-area: label;
	font-weight: 600;
}

.dharmasetu-block-time {
	grid-area: time;
	font-size: 0.82rem;
	color: var(--ds-muted);
	font-variant-numeric: tabular-nums;
}

.dharmasetu-block-price {
	grid-area: price;
	font-weight: 600;
	color: var(--ds-navy);
}

.dharmasetu-block-state {
	grid-area: state;
	margin-block-start: 0.3rem;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--ds-full);
}

/* The whole-day option covers the periods listed above it, so it spans them
   rather than sitting alongside as a fourth peer. */
.dharmasetu-block-option--span {
	grid-column: 1 / -1;
	background: linear-gradient(180deg, var(--ds-cream), #fff 60%);
}

.dharmasetu-block-option:hover:not(.is-unavailable) {
	border-color: var(--ds-saffron);
}

.dharmasetu-block-option:has(input:checked) {
	border-color: var(--ds-deep-saffron);
	box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.28);
}

/* Struck through as well as faded — "greyed out" alone is easy to miss and
   fails contrast for exactly the people most likely to need the cue. */
.dharmasetu-block-option.is-unavailable {
	cursor: not-allowed;
	background: #fafafa;
	border-style: dashed;
}

.dharmasetu-block-option.is-unavailable .dharmasetu-block-label,
.dharmasetu-block-option.is-unavailable .dharmasetu-block-price {
	color: var(--ds-muted);
	text-decoration: line-through;
}

/* Contact form ------------------------------------------------------------ */

.dharmasetu-contact-form {
	max-width: 42rem;
}

.dharmasetu-optional {
	font-weight: 400;
	color: var(--ds-muted);
}

/*
 * The payment note beside the reservation reference. Muted, but it must still
 * be readable prose rather than fine print — it is the only place a family is
 * told that nobody will send them a payment link (D-030).
 */
.dharmasetu-payment-note {
	display: inline-block;
	font-size: 0.9375em;
	line-height: 1.5;
}

/* Notices and errors ------------------------------------------------------ */

.dharmasetu-field-error {
	margin: 0.35rem 0 0;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--ds-full);
}

.dharmasetu-notice {
	padding: 0.9rem 1.1rem;
	margin-block-end: 1rem;
	border-left: 4px solid;
	border-radius: 7px;
}

.dharmasetu-notice--error {
	color: var(--ds-full);
	background: var(--ds-full-bg);
	border-color: var(--ds-full);
}

.dharmasetu-notice--success {
	color: var(--ds-open);
	background: var(--ds-open-bg);
	border-color: var(--ds-open);
}

.dharmasetu-notice--success h2 {
	margin-block: 0 0.5rem;
	font-size: 1.25rem;
	color: inherit;
}

.dharmasetu-field--check label {
	display: flex;
	gap: 0.55rem;
	align-items: flex-start;
	font-weight: 400;
}

.dharmasetu-field--check input {
	margin-block-start: 0.2rem;
	accent-color: var(--ds-deep-saffron);
}

.dharmasetu-submit button {
	padding: 0.8rem 1.75rem;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
	background: var(--ds-saffron);
	border: 0;
	border-radius: 8px;
	transition: background 160ms var(--ds-ease), transform 160ms var(--ds-ease);
}

.dharmasetu-submit button:hover {
	background: var(--ds-deep-saffron);
	transform: translateY(-1px);
}

.dharmasetu-help {
	font-size: 0.86rem;
	color: var(--ds-muted);
}

/* The honeypot must be unreachable, not merely invisible: `display:none`
   alone is a well-known tell, and tab focus would trap a keyboard user in a
   field they cannot see. */
.dharmasetu-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.dharmasetu-calendar *,
	.dharmasetu-booking-form * {
		transition: none !important;
	}

	button.dharmasetu-day__inner:hover,
	.dharmasetu-submit button:hover,
	.dharmasetu-calendar__nav:hover:not(.is-disabled) {
		transform: none;
	}
}

@media (forced-colors: active) {
	.dharmasetu-day__inner,
	.dharmasetu-block-option {
		border: 1px solid CanvasText;
	}

	.dharmasetu-day.is-selected .dharmasetu-day__inner {
		outline: 3px solid Highlight;
	}
}

/* ==========================================================================
   Events list
   --------------------------------------------------------------------------
   Same tokens, same fallbacks, same rules as the booking UI above: read the
   theme's custom properties where they exist, fall back to the brand values,
   never let colour be the only signal, and keep motion to transform/opacity.

   The list is an editorial row rather than a card grid — a temple runs a
   handful of events at a time, and four identical cards in a row is the
   generic-plugin look this was written to avoid. Date first, in saffron: the
   question people arrive with is "when", not "what".
   ========================================================================== */

.dharmasetu-events {
	--ds-saffron: var(--wp--preset--color--saffron, #e67e22);
	--ds-deep-saffron: var(--wp--preset--color--deep-saffron, #c85a16);
	--ds-navy: var(--wp--preset--color--navy, #0a1450);
	--ds-cream: var(--wp--preset--color--cream, #fff8e7);
	--ds-ink: #26262b;
	--ds-muted: #6b6b73;
	--ds-line: #e4ded1;
	--ds-radius: 10px;
	--ds-ease: cubic-bezier(0.16, 1, 0.3, 1);

	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: clamp(1.25rem, 3vw, 2rem);
	color: var(--ds-ink);
}

.dharmasetu-events__item {
	display: grid;
	grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
	gap: clamp(1rem, 2.5vw, 1.75rem);
	align-items: start;
	padding-bottom: clamp(1.25rem, 3vw, 2rem);
	border-bottom: 1px solid var(--ds-line);
}

.dharmasetu-events__item:last-child {
	padding-bottom: 0;
	border-bottom: 0;
}

/* No image is a legitimate state, not a broken one — collapse to one column
   rather than leaving a gap where a picture was expected. */
.dharmasetu-events__item:not(:has(.dharmasetu-events__media)) {
	grid-template-columns: minmax(0, 1fr);
}

.dharmasetu-events__media {
	display: block;
	overflow: hidden;
	border-radius: var(--ds-radius);
	background: var(--ds-cream);
}

.dharmasetu-events__media img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	transition: transform 400ms var(--ds-ease);
}

.dharmasetu-events__item:hover .dharmasetu-events__media img,
.dharmasetu-events__media:focus-visible img {
	transform: scale(1.03);
}

.dharmasetu-events__when {
	margin: 0 0 0.35rem;
	color: var(--ds-deep-saffron);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.dharmasetu-events__title {
	margin: 0;
	font-size: clamp(1.15rem, 2.2vw, 1.5rem);
	line-height: 1.25;
}

.dharmasetu-events__title a {
	color: var(--ds-navy);
	text-decoration: none;
	background-image: linear-gradient(var(--ds-saffron), var(--ds-saffron));
	background-repeat: no-repeat;
	background-position: 0 100%;
	background-size: 0 2px;
	transition: background-size 300ms var(--ds-ease);
}

.dharmasetu-events__title a:hover,
.dharmasetu-events__title a:focus-visible {
	background-size: 100% 2px;
}

.dharmasetu-events__where {
	margin: 0.5rem 0 0;
	color: var(--ds-muted);
	font-size: 0.875rem;
}

.dharmasetu-events__where::before {
	content: "";
	display: inline-block;
	width: 0.45rem;
	height: 0.45rem;
	margin-right: 0.5rem;
	border-radius: 50%;
	background: var(--ds-saffron);
	vertical-align: 0.1em;
}

.dharmasetu-events__excerpt {
	margin: 0.6rem 0 0;
	max-width: 58ch;
	line-height: 1.65;
}

.dharmasetu-events__empty {
	margin: 0;
	padding: clamp(1.25rem, 3vw, 2rem);
	border-radius: var(--ds-radius);
	background: var(--wp--preset--color--cream, #fff8e7);
	color: #6b6b73;
}

/* Single event page — the date and place, above the description. */
.dharmasetu-event-details {
	margin: 0 0 clamp(1.25rem, 3vw, 1.75rem);
	padding: 0 0 clamp(0.75rem, 2vw, 1rem);
	border-bottom: 1px solid var(--wp--preset--color--rule, #e4ded1);
}

.dharmasetu-event-details__when {
	margin: 0;
	color: var(--wp--preset--color--deep-saffron, #c85a16);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.dharmasetu-event-details__where {
	margin: 0.35rem 0 0;
	color: #6b6b73;
	font-size: 0.9375rem;
}

@media (max-width: 600px) {
	.dharmasetu-events__item {
		grid-template-columns: minmax(0, 1fr);
	}

	.dharmasetu-events__media img {
		aspect-ratio: 16 / 9;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dharmasetu-events__media img,
	.dharmasetu-events__title a {
		transition: none;
	}

	.dharmasetu-events__item:hover .dharmasetu-events__media img {
		transform: none;
	}
}
