/*
 * ART DATE PICKER — appearance. One visual language for every calendar in the
 * product (input picker + fleet availability viewer + console). Built entirely
 * from the shared --art-* token layer: no hardcoded colour, spacing or timing.
 * Light (editorial) by default; .art-cal--dark carries the Atelier surface used
 * on the fleet band and in the console.
 *
 * Sizing is deliberate (the brief: the old control read as far too small). Day
 * cells are >=46px, numbers 15-16px, the month name is the serif display face at
 * ~27px. The grid never densifies to fit — on a narrow viewport the panel
 * becomes a full-width bottom sheet instead (see the max-width query).
 */

.art-cal {
	--_cell: 46px;
	--_green: var( --art-color-primary, #0e6b62 );
	--_green-contrast: var( --art-color-primary-contrast, #fff );
	--_amber: var( --art-color-accent, #e08a2c );
	--_ink: var( --art-color-heading, #15181b );
	--_muted: var( --art-color-text-muted, #484e55 );
	--_line: var( --art-color-border, #dcd8cf );
	--_surface: var( --art-color-surface, #fff );
	box-sizing: border-box;
	width: calc( var( --_cell ) * 7 + 0.5rem * 6 + 2.5rem );
	max-width: calc( 100vw - 1rem );
	padding: 1.25rem 1.25rem 1rem;
	background: var( --_surface );
	color: var( --_ink );
	border: 1px solid var( --_line );
	border-radius: var( --art-radius-panel, 1rem );
	box-shadow: var( --art-shadow-floating, 0 16px 40px rgba( 15, 18, 20, 0.18 ) );
	font-family: var( --art-font-primary, "Inter", sans-serif );
}
.art-cal *,
.art-cal *::before,
.art-cal *::after { box-sizing: border-box; }

/* the input picker floats above the page */
.art-cal--input { position: absolute; z-index: 1000; }
/* the display viewer sits inline inside the fleet card: it must fit the card,
   so (unlike the input picker) its cells fill the available width fluidly. The
   "never densify" rule protects the premium INPUT picker (which becomes a sheet
   when tight); an inline availability read-out that overflowed its card would be
   worse than one whose cells scale with the card. */
.art-cal--display {
	position: relative;
	width: 100%;
	max-width: 100%;
	box-shadow: var( --art-shadow-card, 0 2px 8px rgba( 15, 18, 20, 0.08 ) );
	padding: 0.875rem 0.875rem 0.5rem;
}
.art-cal--display .art-cal__day { min-height: 0; font-size: 0.8125rem; }
.art-cal--display .art-cal__num { line-height: 1; }

/* ---- header: serif month + mono year, restrained chevrons ---------------- */
.art-cal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}
.art-cal__title {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	flex: 1 1 auto;
	min-width: 0;
}
.art-cal__month {
	font-family: var( --art-font-primary, sans-serif );
	font-size: 1.7rem;
	line-height: 1.05;
	font-weight: 500;
	color: var( --_ink );
	letter-spacing: -0.01em;
}
.art-cal--display .art-cal__month { font-size: 1.1rem; }
.art-cal__year {
	font-family: var( --art-font-primary, sans-serif );
	font-size: 0.9rem;
	color: var( --_muted );
	letter-spacing: 0.02em;
}
.art-cal__nav {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var( --art-radius-button, 0.375rem );
	background: transparent;
	color: var( --_muted );
	cursor: pointer;
	transition: background var( --art-hover-duration, 170ms ) var( --art-ease-out, ease ),
		color var( --art-hover-duration, 170ms ) var( --art-ease-out, ease ),
		border-color var( --art-hover-duration, 170ms ) var( --art-ease-out, ease );
}
.art-cal__nav:hover:not( :disabled ) { color: var( --_ink ); background: color-mix( in srgb, var( --_ink ) 6%, transparent ); }
.art-cal__nav:focus-visible { outline: 2px solid var( --art-color-focus, var( --_amber ) ); outline-offset: 2px; }
.art-cal__nav:disabled { opacity: 0.32; cursor: default; }
.art-cal__chev { display: block; }

/* ---- weekday eyebrow row (mono, letterspaced, muted) --------------------- */
.art-cal__weekdays,
.art-cal__days {
	display: grid;
	grid-template-columns: repeat( 7, 1fr );
}
.art-cal__weekdays { margin-bottom: 0.375rem; }
.art-cal__wd {
	text-align: center;
	font-family: var( --art-font-primary, sans-serif );
	font-size: 0.6875rem;
	line-height: 1.6;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: color-mix( in srgb, var( --_muted ) 82%, transparent );
}

/* ---- day cells: generous, tokened, comfortable target -------------------- */
.art-cal__days { gap: 2px; }
.art-cal__day {
	position: relative;
	appearance: none;
	-webkit-appearance: none;
	min-height: var( --_cell );
	aspect-ratio: 1 / 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var( --_ink );
	font-family: inherit;
	font-size: 0.9375rem;
	font-variant-numeric: tabular-nums;
	border-radius: var( --art-radius-pill, 999px );
	cursor: pointer;
	transition: background var( --art-hover-duration, 170ms ) var( --art-ease-out, ease ),
		color var( --art-hover-duration, 170ms ) var( --art-ease-out, ease );
}
/* The number is a plain inline-block whose colour is governed ONLY by the
   day-state rules (base ink / selected white). The today treatment is a SIBLING
   on the cell (see .art-cal__today-dot) — never a child of the number and never
   touching its colour or stacking — so today+selected composes cleanly: green
   pill, white number, amber dot. (It previously lived INSIDE the number as an
   absolutely-positioned child of an inline, z-indexed span — a construct WebKit
   paints unreliably, which dropped the digit on a today+selected pill.) The cell
   background paints behind cell content by default, so the digit needs no
   z-index to sit above the pill. */
.art-cal__num { display: inline-block; line-height: 1; }
.art-cal__day.is-outside { visibility: hidden; }             /* keep the grid rhythm, hide the number */
/* Hover tint applies ONLY to plain available days — never to a filled pill or the
   band. The hover selector is more specific than the pill rule, so without these
   guards, hovering an endpoint (which you always do while picking the end) lightened
   its fill and left the white number at ~1.2:1 — invisible. */
button.art-cal__day:hover:not( :disabled ):not( .is-selected ):not( .is-range-start ):not( .is-range-end ):not( .is-in-range ) { background: color-mix( in srgb, var( --_green ) 12%, transparent ); }
.art-cal__day:focus-visible { outline: 2px solid var( --art-color-focus, var( --_amber ) ); outline-offset: -2px; }

/* today — a small amber dot BENEATH the number, never a filled block. The dot
   is a child of .art-cal__num and is anchored to the number's bottom edge
   (top:100%), NOT to the cell — so it always sits clear of the digit whether the
   cell is a 46px input cell or a ~28px inline availability cell (the earlier
   fixed cell offset struck through the number in the smaller cells). */
.art-cal__today-dot {
	position: absolute;
	bottom: 6px;
	left: 50%;
	transform: translateX( -50% );
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var( --_amber );
	pointer-events: none;
}
.art-cal--display .art-cal__today-dot { bottom: 3px; width: 3px; height: 3px; }

/* range band — soft green between endpoints (a real element background, so the
   contrast auditor measures the actual pairing, not a pseudo it can't see) */
.art-cal__day.is-in-range { background: color-mix( in srgb, var( --_green ) 20%, transparent ); border-radius: 0; color: var( --_ink ); }

/* selection + endpoints — filled brand green pill, stronger than the band.
   Also element backgrounds (auditable). Endpoints keep the pill radius; the
   adjacent band reads up to them. */
.art-cal__day.is-selected,
.art-cal__day.is-range-start,
.art-cal__day.is-range-end {
	background: var( --_green );
	color: var( --_green-contrast );
	border-radius: var( --art-radius-pill, 999px );
}
/* today-while-selected: the amber today dot STAYS amber on the green pill (the
   two signals coexist — a green pill says "selected", the amber dot says "today")
   and the number, being centred with the dot anchored below it, is never
   obscured. It was previously recoloured to the pill's contrast colour, which
   erased the today signal whenever today was the chosen date. */

/* unavailable / taken — dimmed and struck with a thin diagonal rule */
.art-cal__day.is-unavailable {
	color: color-mix( in srgb, var( --_muted ) 62%, transparent );
	cursor: not-allowed;
	background-image: linear-gradient( 135deg, transparent calc( 50% - 0.6px ), color-mix( in srgb, var( --_muted ) 55%, transparent ) calc( 50% - 0.6px ), color-mix( in srgb, var( --_muted ) 55%, transparent ) calc( 50% + 0.6px ), transparent calc( 50% + 0.6px ) );
}
.art-cal__day.is-disabled:not( .is-unavailable ) { color: color-mix( in srgb, var( --_muted ) 42%, transparent ); cursor: default; }
.art-cal__day:disabled { pointer-events: none; }

/* ---- footer: legend + night count ---------------------------------------- */
.art-cal__foot {
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px solid var( --_line );
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}
.art-cal__legend { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.75rem; color: var( --_muted ); }
.art-cal__leg { display: inline-flex; align-items: center; gap: 0.3rem; }
.art-cal__leg-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: 0 0 auto; }
.art-cal__leg-dot--sel { background: var( --_green ); }
.art-cal__leg-dot--off {
	background:
		linear-gradient( 135deg, transparent 44%, color-mix( in srgb, var( --_muted ) 70%, transparent ) 44%, color-mix( in srgb, var( --_muted ) 70%, transparent ) 56%, transparent 56% ),
		color-mix( in srgb, var( --_muted ) 22%, transparent );
}
.art-cal__leg-dot--today { background: var( --_amber ); }
.art-cal__nights {
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 600;
	color: var( --_green );
}
.art-cal__nights[hidden] { display: none; }

/* ---- PERIOD control: one field + a range calendar (start→end) -------------- */
.art-period-orig-hidden { display: none !important; } /* the two native fields (kept as no-JS carriers) + their labels */
.art-period-field { display: flex; flex-direction: column; gap: 0.35rem; }
.art-period-label {
	font-family: var( --art-font-primary, "Inter", sans-serif );
	font-size: var( --art-font-size-small, 0.875rem );
	font-weight: 600;
	color: var( --art-color-heading, #15181b );
}
.art-period-field--dark .art-period-label { color: var( --art-color-text-inverse, #f2efe9 ); }
.art-period-req { color: var( --art-color-accent-text, #9a5713 ); }
.art-period__field {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	width: 100%;
	min-height: 3rem;
	padding: 0.6rem 0.85rem;
	background: var( --art-color-surface, #fff );
	color: var( --art-color-heading, #15181b );
	border: 1px solid var( --art-color-border, #d3d1c7 );
	border-radius: var( --art-radius-button, 0.5rem );
	font: 400 var( --art-font-size-base, 1rem ) / 1.2 var( --art-font-primary, "Inter", sans-serif );
	text-align: left;
	cursor: pointer;
	transition: border-color var( --art-hover-duration, 170ms ) var( --art-ease-out, ease );
}
.art-period__field:hover { border-color: color-mix( in srgb, var( --art-color-primary, #0e6b62 ) 55%, var( --art-color-border, #d3d1c7 ) ); }
.art-period__field:focus-visible { outline: 2px solid var( --art-color-focus, var( --art-color-accent, #e08a2c ) ); outline-offset: 2px; }
.art-period__field.is-empty .art-period__text { color: var( --art-color-text-muted, #5f5e5a ); }
.art-period__ico { flex: 0 0 auto; color: var( --art-color-text-muted, #5f5e5a ); }
/* dark surface (the fleet period band) */
.art-period-field--dark .art-period__field {
	background: color-mix( in srgb, var( --art-color-text-inverse, #f2efe9 ) 7%, transparent );
	color: var( --art-color-text-inverse, #f2efe9 );
	border-color: color-mix( in srgb, var( --art-color-text-inverse, #f2efe9 ) 24%, transparent );
}
.art-period-field--dark .art-period__field.is-empty .art-period__text,
.art-period-field--dark .art-period__ico { color: color-mix( in srgb, var( --art-color-text-inverse, #f2efe9 ) 62%, transparent ); }

/* the range panel: up to two months side by side */
.art-cal--period { width: auto; }
.art-cal__head--period { align-items: center; }
.art-cal__titles { flex: 1 1 auto; display: flex; justify-content: space-around; gap: 1.25rem; min-width: 0; }
.art-cal__titles .art-cal__title { flex: 1 1 0; justify-content: center; }
.art-cal__months { display: flex; gap: 1.25rem; justify-content: center; }
.art-cal--period .art-cal__monthblock { width: calc( var( --_cell ) * 7 + 12px ); flex: 0 0 auto; }
.art-cal--period { --_cell: 44px; }
.art-cal__actions { display: flex; gap: 0.75rem; margin-top: 0.15rem; }
.art-cal__action {
	appearance: none; border: 0; background: transparent; cursor: pointer;
	font: 600 0.8125rem / 1 var( --art-font-primary, "Inter", sans-serif );
	padding: 0.35rem 0; color: var( --_muted );
	border-bottom: 1px solid transparent;
}
.art-cal__action--confirm { color: var( --_green ); }
.art-cal__action:hover { border-bottom-color: currentColor; }
.art-cal__action:focus-visible { outline: 2px solid var( --art-color-focus, var( --_amber ) ); outline-offset: 2px; }
.art-cal__action[hidden] { display: none; }
/* one month on the mobile sheet */
.art-cal--period.art-cal--sheet .art-cal__monthblock { width: 100%; }
.art-cal--period.art-cal--sheet .art-cal__titles { justify-content: center; }

/* ---- fleet-card availability: a FLOATING panel over the grid ---------------
   The availability calendar must not grow its card (an inline <details> that
   expanded pushed the card from ~250px to >600px and stretched every sibling in
   the grid row, stranding their price blocks). It now opens as a floating panel
   anchored to its trigger — exactly like the input picker — so the card keeps
   its size and the row stays aligned. It rides the dark Atelier surface (the
   fleet band) and its inner calendar fills the panel width (bigger cells than
   the cramped in-card view it replaces). Never taller than the viewport. */
.art-cal-float {
	position: absolute;
	z-index: 1000;
	box-sizing: border-box;
	/* Read-only "which days are taken" view. It is anchored to ITS OWN CARD and
	   takes the card's width (ArtAnchor matchWidth), so it reads as belonging to
	   that card rather than floating loose. ~16.5rem is the READABLE FLOOR (32px
	   cells × 7); when a card is narrower than that (e.g. a dense grid), the panel
	   stays at the floor and ArtAnchor centres it symmetrically on the card and
	   keeps it within the grid — never lopsided. JS sets an explicit width to the
	   card's; this floor is the fallback + the min. */
	width: min( 16.5rem, calc( 100vw - 1rem ) );
	min-width: min( 16.5rem, calc( 100vw - 1rem ) );
	/* READABLE CAP. matchWidth (ArtAnchor) reads this max-width and never stretches
	   the panel past it — a card wider than the cap (or a trigger sitting in a wide
	   column, e.g. the vehicle detail page) is capped here and centred on the
	   trigger instead of ballooning to the column width (which also blew the height
	   past the viewport). The month grid's natural height fits well under
	   max-height, so `overflow:auto` only ever scrolls when the sizing is wrong. */
	max-width: min( 18rem, calc( 100vw - 1rem ) );
	max-height: calc( 100vh - 1rem );
	overflow: auto;
	padding: 0.75rem;
	background: var( --art-color-surface-inverse, #15181b );
	color: var( --art-color-text-inverse, #f7f5f1 );
	border: 1px solid color-mix( in srgb, var( --art-color-text-inverse, #f7f5f1 ) 16%, transparent );
	border-radius: var( --art-radius-panel, 1rem );
	box-shadow: 0 16px 40px rgba( 0, 0, 0, 0.55 );
	font-family: var( --art-font-primary, "Inter", sans-serif );
}
.art-cal-float[hidden] { display: none; }
.art-cal-float * { box-sizing: border-box; }
/* the moved body already had its own top padding + centering for the in-card
   layout — inside the panel the panel owns the padding, and the calendar fills */
.art-cal-float .art-fleet__cal-body { padding-top: 0; }
.art-cal-float .art-cal--display { box-shadow: none; padding: 0; border: 0; }
.art-cal-float .art-fleet__cal-view { display: block; }

/* ---- reveal motion (matches the site; zeroed under reduced-motion) -------- */
.art-cal--input,
.art-cal-float { transition: opacity var( --art-reveal-duration, 320ms ) var( --art-reveal-ease, ease ), transform var( --art-reveal-duration, 320ms ) var( --art-reveal-ease, ease ); }
.art-cal--input.is-opening,
.art-cal-float.is-opening { opacity: 0; transform: translateY( -6px ); }

/* ---- dark (Atelier) surface: fleet band + console ------------------------ */
.art-cal--dark {
	--_ink: var( --art-color-text-inverse, #f7f5f1 );
	--_muted: color-mix( in srgb, var( --art-color-text-inverse, #f7f5f1 ) 66%, transparent );
	--_line: color-mix( in srgb, var( --art-color-text-inverse, #f7f5f1 ) 16%, transparent );
	--_surface: var( --art-color-surface-inverse, #15181b );
	--_green: var( --art-color-primary-on-dark, #4bbfae );
	color-scheme: dark;
}
.art-cal--dark.art-cal--input { box-shadow: 0 16px 40px rgba( 0, 0, 0, 0.55 ); }
.art-cal--dark .art-cal__day.is-selected,
.art-cal--dark .art-cal__day.is-range-start,
.art-cal--dark .art-cal__day.is-range-end { color: var( --art-color-surface-inverse, #15181b ); }
.art-cal--dark .art-cal__nights { color: var( --_green ); }

/* ---- mobile bottom sheet: near-full width, cells fill, grid never densifies.
   The card availability float uses the SAME sheet as the input picker. -------- */
@media ( max-width: 480px ) {
	.art-cal--input.art-cal--sheet,
	.art-cal-float.art-cal--sheet {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		width: 100%;
		max-width: 100%;
		border-radius: var( --art-radius-panel, 1rem ) var( --art-radius-panel, 1rem ) 0 0;
		padding: 1.25rem 1rem calc( 1rem + env( safe-area-inset-bottom, 0px ) );
		animation: art-cal-sheet-in var( --art-reveal-duration, 320ms ) var( --art-reveal-ease, ease );
	}
	.art-cal-float.art-cal--sheet { max-height: 85vh; overflow: auto; }
	.art-cal-float.art-cal--sheet { max-height: 85dvh; }
	.art-cal--input.art-cal--sheet .art-cal__days { gap: 3px; }
	.art-cal--input.art-cal--sheet .art-cal__day { font-size: 1rem; }
	.art-cal--input.art-cal--sheet .art-cal__nav { width: 44px; height: 44px; }
}

@media ( max-width: 48em ) {
	.art-cal__day { min-height: 44px; }
	.art-cal__nav { min-width: 44px; min-height: 44px; }
}
@keyframes art-cal-sheet-in { from { transform: translateY( 100% ); } to { transform: translateY( 0 ); } }

@media ( prefers-reduced-motion: reduce ) {
	.art-cal--input,
	.art-cal-float,
	.art-cal__day,
	.art-cal__nav { transition: none; }
	.art-cal--input.art-cal--sheet,
	.art-cal-float.art-cal--sheet { animation: none; }
	.art-cal--input.is-opening,
	.art-cal-float.is-opening { opacity: 1; transform: none; }
}

/* a translucent scrim behind the mobile sheet so the page reads as dimmed */
.art-cal-scrim {
	position: fixed;
	inset: 0;
	z-index: 999;
	background: color-mix( in srgb, var( --art-color-heading, #15181b ) 44%, transparent );
	border: 0;
}
@media ( min-width: 481px ) { .art-cal-scrim { display: none; } }
