/* Phase 4 of the "Interactive Itinerary Map" project - see
   InteractiveItineraryMapPlan.docx and widgets/itinerary-map-widget.php.
   Accordion + map side by side on desktop, stacked (accordion first, map
   second) below the same breakpoint the rest of this plugin's search/filter
   layouts collapse at - see assets/css/custom-post-widget.css. */

.caguide_itinerary_wrap {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 24px;
	align-items: start;
	margin-bottom: 30px;
}

.caguide_itinerary_map {
	position: sticky;
	top: 20px;
	width: 100%;
	height: 520px;
	border-radius: 16px;
	overflow: hidden;
	background-color: #f7f7f9;
	border: 1px solid #ececec;
}

@media (max-width: 992px) {
	.caguide_itinerary_wrap {
		grid-template-columns: 1fr;
	}
	.caguide_itinerary_map {
		position: static;
		height: 360px;
		order: -1;
	}
}

/* ----- Accordion ----- */

.caguide_itinerary_accordion {
	display: flex;
	flex-direction: column;
	/* Tight on purpose: a long tour (15-18 days) is a long stack of closed rows. */
	gap: 6px;
}

.caguide_itinerary_day {
	border: 1px solid #ececec;
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Hovering a leg on the map (see updateActiveHighlight() in
   itinerary-map.js) previews that day here without opening/scrolling to
   it - a lighter tint than .is-open below, and never both at once on the
   same day (hover always wins visually while the mouse is over a leg, per
   updateActiveHighlight()'s own precedence). */
.caguide_itinerary_day.is-hover-preview {
	background-color: #fdeef2;
}

.caguide_itinerary_day.is-open {
	border-color: #fb2056;
}

.caguide_itinerary_day_header {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	/* One compact line per closed day (about 42px, down from about 60px) - the
	   side padding matches .caguide_itinerary_day_body so the text lines up. */
	padding: 10px 16px;
	background: none;
	border: none;
	cursor: pointer;
	text-align: left;
	font: inherit;
	font-size: 15px;
	line-height: 1.3;
}

/* The theme styles every <button> on hover/focus/press (a coloured, rounded
   fill with light text), which turned an open day's header into a red pill
   with unreadable text. The header is a plain row - pin it to its own look in
   those states too. Higher specificity than the theme's button:hover rules. */
.caguide_itinerary_wrap .caguide_itinerary_day_header,
.caguide_itinerary_wrap .caguide_itinerary_day_header:hover,
.caguide_itinerary_wrap .caguide_itinerary_day_header:focus,
.caguide_itinerary_wrap .caguide_itinerary_day_header:active {
	background: transparent !important;
	color: inherit !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}

.caguide_itinerary_wrap .caguide_itinerary_day_header:focus-visible {
	outline: 2px solid #fb2056;
	outline-offset: -2px;
}

.caguide_itinerary_day_number {
	font-weight: 700;
	color: #151515;
	white-space: nowrap;
}

.caguide_itinerary_day_headline {
	flex: 1;
	min-width: 0;
	color: #6b6b6b;
}

/* A closed day stays on one line: a longer headline ("Riding into the high
   pastures") is cut with an ellipsis (the full text is in the button's title
   tooltip) rather than wrapping to a second line. An open day shows it whole. */
.caguide_itinerary_day:not(.is-open) .caguide_itinerary_day_headline {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.caguide_itinerary_day_chevron {
	flex-shrink: 0;
	transition: transform 0.15s ease;
}

.caguide_itinerary_day.is-open .caguide_itinerary_day_chevron {
	transform: rotate(180deg);
}

.caguide_itinerary_day_body {
	display: none;
	padding: 0 16px 16px;
	color: #444;
	font-size: 14px;
	line-height: 1.5;
}

.caguide_itinerary_day.is-open .caguide_itinerary_day_body {
	display: block;
}

.caguide_itinerary_day_description {
	margin: 0 0 10px;
	color: #151515;
	/* Preserves the line breaks an editor typed in the admin textarea
	   (admin/tour-itinerary-metabox.php) without needing nl2br()/raw HTML
	   output - collapses runs of regular whitespace like normal text still
	   does, just keeps actual newlines as line breaks. */
	white-space: pre-line;
}

.caguide_itinerary_day_sights {
	margin: 0 0 8px;
	color: #6b6b6b;
}

.caguide_itinerary_day_legs {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.caguide_itinerary_leg {
	color: #6b6b6b;
}

.caguide_itinerary_leg_km {
	color: #9b9b9b;
}

.caguide_itinerary_day_overnight_row {
	margin: 10px 0 0;
	padding-top: 8px;
	border-top: 1px solid #ececec;
}

.caguide_itinerary_day_overnight_row strong {
	color: #151515;
}

/* ----- Map markers ----- */

.caguide_itinerary_marker {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fb2056;
	border: 2px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Glows to match the highlighted route markings (see the 'caguide-itinerary-
   legs-glow-*' layers in itinerary-map.js). */
.caguide_itinerary_marker.is-active {
	transform: scale(1.4);
	box-shadow: 0 0 0 3px rgba(251, 32, 86, 0.3), 0 0 14px 5px rgba(251, 32, 86, 0.65);
}

/* ----- Hover tooltip (desktop only - see CAN_HOVER in itinerary-map.js) ----- */

.caguide_itinerary_tooltip {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 600;
	color: #151515;
}

.caguide_itinerary_tooltip img {
	width: 32px;
	height: 32px;
	border-radius: 6px;
	object-fit: cover;
}

/* ----- Info-card overlay (marker click) -----
   A page-level overlay rather than a popup anchored inside the map, built
   by buildCardOverlay()/openCardOverlay() in itinerary-map.js - room for a
   real photo and the full excerpt, not boxed in or clipped by the map's own
   small footprint. Same dark-backdrop/centred-panel mechanism as
   .create_announcement_popup_wrap (widgets/custom-post-widget.php) and
   .announcement_popup_wrap, but its own class names throughout - all three
   overlays are independent and could in principle be open on the same
   page. */

.caguide_itinerary_card_overlay_wrap.show {
	display: flex;
}

.caguide_itinerary_card_overlay_wrap {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, .8);
	z-index: 99999999999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
}

.caguide_itinerary_card_overlay {
	background-color: #fff;
	border-radius: 12px;
	width: 100%;
	max-width: 420px;
	max-height: 90vh;
	overflow-y: auto;
	position: relative;
	box-sizing: border-box;
}

.caguide_itinerary_card_overlay_close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 30px;
	height: 30px;
	padding: 0;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1;
}

.caguide_itinerary_card_overlay_close svg {
	width: 16px;
	height: 16px;
}

.caguide_itinerary_card_overlay_close:hover svg {
	fill: #fb2056;
}

.caguide_itinerary_card_overlay_image {
	width: 100%;
	height: 220px;
	object-fit: cover;
	display: block;
	border-radius: 12px 12px 0 0;
}

.caguide_itinerary_card_overlay_body {
	padding: 20px;
}

.caguide_itinerary_card_overlay_name {
	margin: 0 0 8px;
	font-size: 20px;
	color: #151515;
}

.caguide_itinerary_card_overlay_excerpt {
	font-size: 14px;
	color: #444;
	line-height: 1.5;
	margin: 0 0 16px;
}

.caguide_itinerary_card_overlay_link {
	display: inline-block;
	margin-bottom: 16px;
}

.caguide_itinerary_card_overlay_days {
	padding-top: 14px;
	border-top: 1px solid #ececec;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
}

.caguide_itinerary_card_overlay_days_label {
	font-size: 13px;
	color: #6b6b6b;
	margin-right: 4px;
}

.caguide_itinerary_card_overlay_day_pill {
	background: #f7f7f9;
	border: 1px solid #ececec;
	border-radius: 20px;
	padding: 4px 12px;
	font-size: 13px;
	font-weight: 600;
	color: #151515;
	cursor: pointer;
}

.caguide_itinerary_card_overlay_day_pill:hover {
	background: #fb2056;
	border-color: #fb2056;
	color: #fff;
}

@media (max-width: 480px) {
	.caguide_itinerary_card_overlay_image {
		height: 160px;
	}
}

/* MapLibre's own popup chrome, restyled to match the rest of this plugin's
   soft-shadow/rounded-corner cards instead of its square default. */
.maplibregl-popup-content {
	border-radius: 10px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
	padding: 10px;
}

.caguide_itinerary_admin_notice {
	background: #fff8e1;
	border: 1px solid #f0d98a;
	border-radius: 8px;
	padding: 12px 16px;
	color: #6b5b1e;
}

/* ----- Phone layout ----- lives in itinerary-map-mobile.css, loaded only with a
   (max-width: 768px) media query. Just the default it overrides stays here. */

.caguide_itinerary_day_chips {
	display: none;
}

/* Touch screens: the marker dot is only 16px, too small to hit reliably with
   a finger - an invisible ring extends its tap area to about 40px. */
@media (pointer: coarse) {
	.caguide_itinerary_marker::after {
		content: '';
		position: absolute;
		top: -12px;
		right: -12px;
		bottom: -12px;
		left: -12px;
	}
}

/* ----- Map load states (see loadMapLibre()/initOne() in itinerary-map.js) -----
   MapLibre is fetched only when the widget nears the viewport, so the map box
   is briefly empty: a slow pulse marks it as loading rather than broken.
   .is-ready is set on the wrap once the map exists. If MapLibre can't be
   fetched at all (CDN down, blocked), .is-map-failed drops the map and shows
   every day's text expanded instead - the accordion is server-rendered, so
   the itinerary is still fully readable without the map. */
.caguide_itinerary_map:not(.is-ready) {
	animation: caguide-map-pulse 1.4s ease-in-out infinite;
}

@keyframes caguide-map-pulse {
	0%, 100% {
		background-color: #f7f7f9;
	}
	50% {
		background-color: #eeeef2;
	}
}

.caguide_itinerary_wrap.is-map-failed {
	grid-template-columns: 1fr;
}

.caguide_itinerary_wrap.is-map-failed .caguide_itinerary_map,
.caguide_itinerary_wrap.is-map-failed .caguide_itinerary_day_chips {
	display: none;
}

.caguide_itinerary_wrap.is-map-failed .caguide_itinerary_day_body {
	display: block;
}

/* ----- Accommodation details and meals (widgets/itinerary-map-widget.php) ----- */

.caguide_itinerary_day_acc_type {
	color: #6b6b6b;
}

.caguide_itinerary_day_facilities {
	list-style: none;
	margin: 6px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 2px 18px;
	color: #6b6b6b;
}

.caguide_itinerary_day_facility_label {
	color: #151515;
	font-weight: 600;
}

.caguide_itinerary_day_meals {
	margin: 6px 0 0;
	color: #6b6b6b;
}

.caguide_itinerary_day_meals strong {
	color: #151515;
}

/* "Next day" button under a day's text - phone layout only (shown by
   itinerary-map-mobile.css); the desktop accordion doesn't need it. */
.caguide_itinerary_day_next {
	display: none;
}

/* ----- Start, end and border-crossing markers -----
   Tour start / end are simply where the first leg begins and the last leg ends
   (see tourStart / tourEnd in itinerary-map.js) - a green marker with a play
   arrow for the start, a dark one with a flag for the end, both with a small
   "Start" / "End" tag under them; one place that is both (a round trip) is
   split green / dark. A border crossing (Schema Manager > Custom Places) is an
   amber marker with a barrier. All icons are inline SVG, so nothing extra loads. */

.caguide_itinerary_marker.is-start,
.caguide_itinerary_marker.is-end,
.caguide_itinerary_marker.is-border {
	background-repeat: no-repeat;
	background-position: center;
	background-size: 62%;
}

.caguide_itinerary_marker.is-start,
.caguide_itinerary_marker.is-end {
	width: 22px;
	height: 22px;
}

.caguide_itinerary_marker.is-border {
	width: 20px;
	height: 20px;
	background-color: #f59e0b;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M5 20V5'/%3E%3Cpath d='M5 10h15'/%3E%3Cpath d='M10 10v4M14 10v4M18 10v4'/%3E%3C/svg%3E");
}

.caguide_itinerary_marker.is-start {
	background-color: #16a34a;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.caguide_itinerary_marker.is-end {
	background-color: #151515;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 3v18' stroke='white' stroke-width='2.4' stroke-linecap='round'/%3E%3Cpath d='M6 4h13l-2.5 4 2.5 4H6z' fill='white'/%3E%3C/svg%3E");
}

.caguide_itinerary_marker.is-start.is-end {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 3v18' stroke='white' stroke-width='2.4' stroke-linecap='round'/%3E%3Cpath d='M6 4h13l-2.5 4 2.5 4H6z' fill='white'/%3E%3C/svg%3E"), linear-gradient(90deg, #16a34a 50%, #151515 50%);
	background-size: 62%, 100%;
	background-position: center, center;
}

.caguide_itinerary_marker_tag {
	position: absolute;
	top: 100%;
	left: 50%;
	margin-top: 5px;
	padding: 1px 7px;
	transform: translateX(-50%);
	border-radius: 10px;
	background: #151515;
	color: #fff;
	font: 600 10px/1.5 sans-serif;
	letter-spacing: 0.02em;
	white-space: nowrap;
	pointer-events: none;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.caguide_itinerary_marker.is-start:not(.is-end) .caguide_itinerary_marker_tag {
	background: #16a34a;
}

/* What a place is on the tour, shown on its card. */
.caguide_itinerary_card_overlay_roles {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 10px;
}

.caguide_itinerary_card_overlay_role {
	padding: 2px 10px;
	border-radius: 12px;
	background: #f7f7f9;
	border: 1px solid #ececec;
	font-size: 12px;
	font-weight: 600;
	color: #151515;
}

/* The headline above the map - the theme's own heading style applies (it is a
   real h2), this only keeps a steady gap before the map / accordion below it. */
.caguide_itinerary_headline {
	margin: 0 0 20px;
}
