/**
 * The tour card, once.
 *
 * Drawn by includes/card.php and shared by the landing page, the destination
 * hub and the activity page. Its own grid comes with it, because a card that
 * relies on the surrounding module for its columns is a card that lays out
 * differently in each of the three places it appears.
 *
 * Scoped to .wptm-card and .wptm-cards throughout. Tokens come from
 * tokens.css, which every module already depends on.
 */

/*
 * min() inside the track, not a bare pixel minimum.
 *
 * repeat( auto-fill, minmax( 280px, 1fr ) ) lays a 280px track whatever the
 * container is, so at 320px with 20px of padding each side the grid is wider
 * than the page and the whole document scrolls sideways. Wrapping the minimum
 * in min( 280px, 100% ) says "280 unless that is more than I have", which
 * cannot overflow at any width and changes nothing above 280.
 */
.wptm-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
	gap: clamp(16px, 2vw, 26px);
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * The list item is a bare slot.
 *
 * tour.css also has a .wptm-card: it is the sidebar card on a tour page,
 * with 22px of padding, a border and a shadow. A destination hub renders
 * inside the archive, so both stylesheets are on that page and the listing
 * item was being drawn as a sidebar card around a card — a second border and
 * a band of padding. Two classes rather than one specify the slot, so this
 * wins whichever file the browser read last — and nothing here reaches a
 * .wptm-card that is not inside a listing, so the sidebar card keeps its own.
 */
.wptm-cards .wptm-card {
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	list-style: none;
	min-width: 0;
}

.wptm-cards .wptm-card::marker {
	content: "";
}

.wptm-card__inner {
	height: 100%;
	overflow: hidden;
	border: 1px solid var(--wptm-line);
	border-radius: var(--wptm-radius);
	background: #fff;
	transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.wptm-card__inner:hover,
.wptm-card__inner:focus-within {
	transform: translateY(-4px);
	border-color: rgba(0, 30, 83, 0.18);
	box-shadow: 0 18px 40px rgba(0, 30, 83, 0.1);
}

.wptm-card__link {
	display: flex;
	flex-direction: column;
	height: 100%;
	text-decoration: none;
	color: inherit;
}

.wptm-card__link:focus-visible {
	outline: 2px solid var(--wptm-gold);
	outline-offset: 3px;
}

/* --- The photograph ------------------------------------------------------- */

.wptm-card__media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	background: rgba(0, 30, 83, 0.06);
}

.wptm-card__img {
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
	display: block;
	transition: transform 0.7s ease;
}

.wptm-card__inner:hover .wptm-card__img,
.wptm-card__inner:focus-within .wptm-card__img {
	transform: scale(1.045);
}

/*
 * A tour with no photograph yet.
 *
 * A blank rectangle reads as an image that failed to load. A faint compass in
 * the middle of it reads as a place a photograph will go, which is what it is.
 */
.wptm-card__media--empty {
	display: grid;
	place-items: center;
	background:
		radial-gradient(circle at 50% 50%, rgba(0, 30, 83, 0.04), transparent 70%),
		rgba(0, 30, 83, 0.06);
}

.wptm-card__blank {
	position: relative;
	line-height: 0;
	color: rgba(0, 30, 83, 0.28);
}

/* The zellige ground behind the compass, in the navy at a fraction. */
.wptm-card__pattern {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	color: var(--wptm-navy);
	pointer-events: none;
}

/*
 * The two chips over the picture.
 *
 * The duration sits at the foot, where a caption goes, in the page colour so
 * it reads as a label rather than a button. The badge sits at the head in the
 * accent, because it is the one thing on the card the agency chose to shout.
 * Both are kept off the corner by the same twelve pixels.
 */
.wptm-card__days,
.wptm-card__badge {
	position: absolute;
	inset-inline-start: 12px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	max-width: calc(100% - 24px);
	padding: 5px 11px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.02em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wptm-card__days {
	inset-block-end: 12px;
	background: rgba(255, 255, 255, 0.92);
	color: var(--wptm-navy);
	box-shadow: 0 1px 2px rgba(0, 30, 83, 0.12);
}

.wptm-card__days span {
	line-height: 0;
	color: var(--wptm-gold);
}

.wptm-card__badge {
	inset-block-start: 12px;
	background: var(--wptm-gold);
	color: var(--wptm-navy);
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.wptm-card__days {
		background: rgba(255, 255, 255, 0.8);
		-webkit-backdrop-filter: blur(6px);
		backdrop-filter: blur(6px);
	}
}

/* --- The body ------------------------------------------------------------- */

.wptm-card__body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	gap: 8px;
	padding: 16px 18px 18px;
}

/*
 * The line above the title: where the tour goes, and what guests thought.
 *
 * Both are small and both are quiet, so the title underneath stays the
 * heaviest thing on the card. They are pushed to the two ends of the line;
 * when only one is present it keeps its end.
 */
.wptm-card__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	min-width: 0;
}

/* The place gives way before the rating does: a name can be cut short
   with an ellipsis and still be read, a number cannot. */
/* A block rather than a flex row: the ellipsis only works on inline
   content, and a flex item is not that. */
.wptm-card__place {
	display: block;
	flex: 1 1 auto;
	min-width: 0;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--wptm-gold);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wptm-card__place span {
	display: inline-block;
	margin-inline-end: 4px;
	line-height: 0;
	vertical-align: -2px;
}

.wptm-card__rating {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	flex: 0 0 auto;
	margin-inline-start: auto;
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--wptm-navy);
	font-variant-numeric: tabular-nums;
}

.wptm-card__rating-icon {
	line-height: 0;
	color: var(--wptm-gold);
}

.wptm-card__rating-icon svg {
	fill: currentColor;
}

.wptm-card__rating-count {
	font-weight: 500;
	color: var(--wptm-faint);
}

/* The sentence a screen reader hears in place of the number. */
.wptm-card__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.wptm-card__title {
	margin: 0;
	font-family: inherit;
	font-size: 1.02rem;
	font-weight: 600;
	line-height: 1.42;
	color: var(--wptm-navy);
	transition: color 0.25s ease;
}

.wptm-card__inner:hover .wptm-card__title,
.wptm-card__inner:focus-within .wptm-card__title {
	color: color-mix(in srgb, var(--wptm-navy) 72%, var(--wptm-gold));
}

/*
 * The excerpt is held to two lines.
 *
 * A grid of cards is read across as much as down, and the foot of each one
 * should sit on the same line as its neighbours'. An excerpt of one line
 * beside an excerpt of four is what breaks that, so the text is cut at two
 * and the foot is pushed to the bottom regardless.
 */
.wptm-card__lead {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	margin: 0;
	overflow: hidden;
	font-size: 0.88rem;
	line-height: 1.6;
	color: var(--wptm-muted);
}

/* The next scheduled departure, one small line above the foot. */
.wptm-card__next {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--wptm-navy);
}

.wptm-card__next span {
	line-height: 0;
	color: var(--wptm-gold);
}

.wptm-card__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 8px;
	margin-block-start: auto;
	padding-block-start: 12px;
	border-block-start: 1px solid var(--wptm-line);
}

/*
 * The price is three words stacked into one figure: the small "from" over
 * the amount, and the basis after it. The amount is the largest type on the
 * card below the title, because it is the second thing a reader looks for.
 */
.wptm-card__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 5px;
	min-width: 0;
	font-size: 0.96rem;
	color: var(--wptm-navy);
}

.wptm-card__price strong {
	font-size: 1.1rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
}

.wptm-card__from {
	flex: 0 0 100%;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--wptm-faint);
}

.wptm-card__basis {
	font-size: 0.76rem;
	font-weight: 500;
	color: var(--wptm-muted);
}

/* No price listed: said in words, in the muted weight, so the slot is not
   simply empty. Nothing is invented — the tour is booked on request. */
.wptm-card__price--quote {
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--wptm-muted);
}

.wptm-card__cta {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 0.84rem;
	font-weight: 600;
	color: var(--wptm-navy);
	white-space: nowrap;
	transition: gap 0.2s ease;
}

.wptm-card__inner:hover .wptm-card__cta,
.wptm-card__inner:focus-within .wptm-card__cta {
	gap: 9px;
}

/* An arrow points along the reading direction, so it turns with it. */
.wptm-arrow {
	display: inline-block;
}

[dir="rtl"] .wptm-arrow {
	transform: scaleX(-1);
}

/* A grid that asked for a column count gets it where there is room, and
   the automatic fit where there is not. */
@media (min-width: 900px) {
	.wptm-cards--1 { grid-template-columns: minmax(0, 1fr); }
	.wptm-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.wptm-cards--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.wptm-cards--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.wptm-cards-empty {
	padding: 14px 16px;
	border: 1px dashed var(--wptm-line, rgba(0, 0, 0, .15));
	border-radius: 10px;
	color: var(--wptm-muted, #5b6472);
}

@media (max-width: 600px) {
	.wptm-cards {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wptm-card__inner,
	.wptm-card__img,
	.wptm-card__title,
	.wptm-card__cta {
		transition-duration: 0.01ms !important;
	}

	.wptm-card__inner:hover,
	.wptm-card__inner:focus-within,
	.wptm-card__inner:hover .wptm-card__img,
	.wptm-card__inner:focus-within .wptm-card__img {
		transform: none;
	}
}

/*
 * Touch.
 *
 * Anything a finger lands on gets forty-four pixels, which is the WCAG target
 * size and the figure every platform's own guidance sits within a pixel of. On
 * a cursor these keep the tighter proportions they were drawn with.
 *
 * Keyed on pointer as well as width: a tablet is wide and touched, and a
 * desktop window dragged narrow is neither, so the width test alone answers
 * the wrong half of the question.
 */
@media (max-width: 600px), (pointer: coarse) {
	/* The whole card is the target, so it is already far larger than any
	   minimum; what needs the room is the line of text at the foot of it. */
	.wptm-card__foot {
		min-height: 44px;
		align-items: center;
	}
}

/* --- Ask on WhatsApp, from the card ------------------------------------- */

/*
 * A sibling of the card link, laid over the corner of the photograph
 * opposite the badge. The card keeps its whole-surface link; this is one
 * more thing on it, not a second copy of it. See the archive card for the
 * same control in the same place.
 */
.wptm-card__inner {
	position: relative;
}

.wptm-card__ask {
	position: absolute;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: #1f9d55;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
	text-decoration: none;
	line-height: 0;
	transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.wptm-card__ask svg {
	width: 18px;
	height: 18px;
}

.wptm-card__ask:hover,
.wptm-card__ask:focus-visible {
	background: #25d366;
	color: #fff;
	transform: scale(1.06);
}

.wptm-card__ask:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.55);
}

@media (prefers-reduced-motion: reduce) {
	.wptm-card__ask,
	.wptm-card__ask:hover {
		transform: none;
	}
}

/* A long badge stops short of the ask button instead of running under it. */
.wptm-card:has(.wptm-card__ask) .wptm-card__badge,
.wptm-card__inner:has(.wptm-card__ask) .wptm-card__badge {
	max-width: calc(100% - 66px);
}
