/**
 * BODS Bus Data - front-end display styles.
 *
 * Shared stylesheet for the [bus_routes], [bus_timetable], [bus_disruptions]
 * and [bus_route_disruptions] shortcodes.
 *
 * Design notes:
 * - Mobile-first: base rules target small screens, media queries layer on
 *   tablet/desktop enhancements.
 * - Colours are chosen to meet WCAG 2.2 AA contrast (>= 4.5:1 for text) against
 *   a white background. Status colours are darkened accordingly.
 * - All interactive elements get a visible :focus-visible outline.
 *
 * @package Bus_Bods_Data
 */

/* -------------------------------------------------------------------------- */
/* Design tokens                                                              */
/* -------------------------------------------------------------------------- */

.wnc-bus-routes,
.wnc-bus-timetable,
.wnc-bus-disruptions {
	--bus-border: #6f777b;          /* AA against white for non-text UI       */
	--bus-border-light: #b1b4b6;
	--bus-text: #0b0c0c;            /* near-black body text                    */
	--bus-text-muted: #505a5f;      /* 7:1 on white, safe for small grey text  */
	--bus-surface: #ffffff;
	--bus-surface-alt: #f3f2f1;
	--bus-focus: #ffdd00;           /* GDS-style focus yellow                  */
	--bus-focus-text: #0b0c0c;
	--bus-link: #1d70b8;            /* AA link blue                            */
	--bus-link-hover: #003078;

	/* Status / severity colours (all AA as text or 3:1 as UI borders). */
	--bus-severe: #b10e1e;
	--bus-noservice: #7a1420;
	--bus-slight: #a8630a;
	--bus-normal: #1d70b8;

	color: var(--bus-text);
	font-size: 1rem;
	line-height: 1.5;
}

/* Shared, consistent focus indicator for every interactive element. */
.wnc-bus-routes a:focus-visible,
.wnc-bus-disruptions a:focus-visible,
.wnc-bus-disruptions summary:focus-visible,
.wnc-bus-timetable a:focus-visible,
.wnc-bus-timetable button:focus-visible,
.wnc-bus-timetable select:focus-visible {
	outline: 3px solid var(--bus-focus);
	outline-offset: 0;
	box-shadow: 0 2px 0 var(--bus-focus-text);
	background-color: var(--bus-focus);
	color: var(--bus-focus-text);
	text-decoration: none;
}

/* -------------------------------------------------------------------------- */
/* [bus_routes]                                                               */
/* -------------------------------------------------------------------------- */

.wnc-bus-routes__list {
	display: grid;
	grid-template-columns: 1fr;   /* 1 column on mobile */
	gap: 1rem;
	margin: 0;
	padding: 0;
}

@media (min-width: 48em) {         /* tablet: 2 columns */
	.wnc-bus-routes__list {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 64em) {         /* desktop: 3 columns */
	.wnc-bus-routes__list {
		grid-template-columns: repeat(3, 1fr);
	}
}

.wnc-bus-routes__item {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	border: 1px solid var(--bus-border);
	border-top: 4px solid var(--bus-link);
	border-radius: 4px;
	padding: 1rem 1.25rem;
	background-color: var(--bus-surface);
	transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.wnc-bus-routes__item:hover,
.wnc-bus-routes__item:focus-within {
	box-shadow: 0 4px 12px rgba(11, 12, 12, 0.18);
	transform: translateY(-2px);
}

.wnc-bus-routes__line-name {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.2;
}

.wnc-bus-routes__line-name a {
	color: var(--bus-link);
	text-decoration: none;
}

.wnc-bus-routes__line-name a:hover {
	color: var(--bus-link-hover);
	text-decoration: underline;
}

.wnc-bus-routes__operator {
	display: inline-block;
	align-self: flex-start;
	padding: 0.125rem 0.5rem;
	border-radius: 3px;
	background-color: var(--bus-surface-alt);
	color: var(--bus-text);
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.wnc-bus-routes__description {
	margin: 0;
	color: var(--bus-text);
}

.wnc-bus-routes__disruption-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	align-self: flex-start;
	padding: 0.125rem 0.625rem;
	border-radius: 999px;
	background-color: var(--bus-severe);
	color: #ffffff;
	font-size: 0.8125rem;
	font-weight: 700;
}

.wnc-bus-routes__empty {
	margin: 0;
	padding: 1rem;
	border: 1px dashed var(--bus-border);
	border-radius: 4px;
	background-color: var(--bus-surface-alt);
	color: var(--bus-text-muted);
}

/* -------------------------------------------------------------------------- */
/* [bus_timetable]                                                            */
/* -------------------------------------------------------------------------- */

.wnc-bus-timetable {
	margin: 0 0 1.5rem;
}

.wnc-bus-timetable__tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	margin-bottom: 1rem;
}

.wnc-bus-timetable__tabgroup {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	border-bottom: 2px solid var(--bus-border-light);
}

.wnc-bus-timetable__tab {
	appearance: none;
	border: 1px solid transparent;
	border-bottom: none;
	margin: 0;
	padding: 0.5rem 1rem;
	background: none;
	color: var(--bus-link);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	border-radius: 4px 4px 0 0;
}

.wnc-bus-timetable__tab:hover {
	background-color: var(--bus-surface-alt);
	color: var(--bus-link-hover);
}

.wnc-bus-timetable__tab[aria-selected="true"],
.wnc-bus-timetable__tab.is-active {
	color: var(--bus-text);
	background-color: var(--bus-surface);
	border-color: var(--bus-border-light);
	border-bottom: 3px solid var(--bus-link);
	margin-bottom: -2px;
}

/* Horizontal-scroll container for the grid on desktop. */
.wnc-bus-timetable__grid-wrapper {
	display: block;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--bus-border-light);
	border-radius: 4px;
}

.wnc-bus-timetable__grid {
	border-collapse: collapse;
	width: 100%;
	min-width: 100%;
}

.wnc-bus-timetable__grid caption {
	text-align: left;
	padding: 0.5rem 0.75rem;
	font-weight: 700;
}

.wnc-bus-timetable__grid th,
.wnc-bus-timetable__grid td {
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--bus-border-light);
	white-space: nowrap;
}

.wnc-bus-timetable__grid thead th {
	background-color: var(--bus-surface-alt);
	font-size: 0.9375rem;
	font-weight: 400;
	text-align: center;
	border-bottom: 2px solid var(--bus-border);
}

/* The "Stop" column header stays emphasised; journey-column labels are light. */
.wnc-bus-timetable__grid thead th:first-child {
	font-weight: 600;
}

.wnc-bus-timetable__grid tbody td {
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* First column holds the stop names: sticky to the left while scrolling. */
.wnc-bus-timetable__grid th[scope="row"],
.wnc-bus-timetable__grid thead th:first-child {
	position: sticky;
	left: 0;
	z-index: 2;
	min-width: 200px;
	text-align: left;
	background-color: var(--bus-surface);
	border-right: 2px solid var(--bus-border);
}

.wnc-bus-timetable__grid thead th:first-child {
	z-index: 3;
	background-color: var(--bus-surface-alt);
}

.wnc-bus-timetable__grid tbody tr:nth-child(even) th[scope="row"],
.wnc-bus-timetable__grid tbody tr:nth-child(even) td {
	background-color: var(--bus-surface-alt);
}

/* Mobile stop-picker view: hidden on desktop, shown on small screens. */
.wnc-bus-timetable__mobile {
	display: none;
}

.wnc-bus-timetable__mobile-label {
	display: block;
	margin-bottom: 0.25rem;
	font-weight: 600;
}

.wnc-bus-timetable__stop-select {
	width: 100%;
	padding: 0.5rem;
	font: inherit;
	border: 2px solid var(--bus-border);
	border-radius: 4px;
	background-color: var(--bus-surface);
	color: var(--bus-text);
}

.wnc-bus-timetable__departures {
	margin-top: 1rem;
}

.wnc-bus-timetable__stop-departures ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.wnc-bus-timetable__stop-departures li {
	padding: 0.375rem 0.625rem;
	border: 1px solid var(--bus-border-light);
	border-radius: 4px;
	background-color: var(--bus-surface-alt);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.wnc-bus-timetable__no-data {
	padding: 1rem;
	color: var(--bus-text-muted);
}

/* Below 768px: swap the scrolling grid for the stop-picker view. */
@media (max-width: 47.99em) {
	.wnc-bus-timetable__grid-wrapper {
		display: none;
	}

	.wnc-bus-timetable__mobile {
		display: block;
	}
}

/*
 * Progressive enhancement for the mobile stop picker.
 *
 * By default (no JavaScript) the <select> is pointless, so it is hidden and
 * every stop's departures are shown, keeping the data fully accessible. Once
 * the script runs it adds the `wnc-bus-js` class to <html>, which flips this: the
 * picker appears and the [hidden] attribute is honoured so one stop shows at a
 * time.
 */
.wnc-bus-timetable__stop-departures[hidden] {
	display: block;
}

.wnc-bus-timetable__mobile-label,
.wnc-bus-timetable__stop-select {
	display: none;
}

.wnc-bus-js .wnc-bus-timetable__stop-departures[hidden] {
	display: none;
}

.wnc-bus-js .wnc-bus-timetable__mobile-label {
	display: block;
}

.wnc-bus-js .wnc-bus-timetable__stop-select {
	display: block;
}

/* -------------------------------------------------------------------------- */
/* [bus_disruptions] / [bus_route_disruptions]                                */
/* -------------------------------------------------------------------------- */

/* Responsive vertical rhythm for the alert cards. Each step scales smoothly
   between a small-screen minimum and a desktop maximum, so spacing tightens on
   phones without any breakpoints. */
.wnc-bus-disruptions {
	--wnc-alert-space-xs: clamp(0.125rem, 0.1rem + 0.15vw, 0.1875rem);
	--wnc-alert-space-s: clamp(0.25rem, 0.15rem + 0.35vw, 0.375rem);
	--wnc-alert-space-m: clamp(0.375rem, 0.25rem + 0.6vw, 0.625rem);
	--wnc-alert-space-l: clamp(0.5rem, 0.3rem + 0.9vw, 0.875rem);
	--wnc-alert-space-inline: clamp(0.75rem, 0.5rem + 1.2vw, 1.25rem);
}

.wnc-bus-disruptions__list {
	display: flex;
	flex-direction: column;
	gap: var(--wnc-alert-space-m);
}

.wnc-bus-disruptions__item {
	border: 1px solid var(--bus-border-light);
	border-left: 4px solid var(--bus-normal);
	border-radius: 4px;
	padding: var(--wnc-alert-space-l) var(--wnc-alert-space-inline);
	margin-bottom: 0;
	background-color: var(--bus-surface);
}

.wnc-bus-disruptions__item--severe {
	border-left-color: var(--bus-severe);
}

.wnc-bus-disruptions__item--slight {
	border-left-color: var(--bus-slight);
}

.wnc-bus-disruptions__item--normal {
	border-left-color: var(--bus-normal);
}

.wnc-bus-disruptions__item--noService {
	border-left-color: var(--bus-noservice);
}

/* Grouped single-journey alerts: one neutral card per route, detail in an
   expandable list. No severity badge - one skipped stop is not an emergency.
   The side border colour comes from the Journey Alerts setting. */
.wnc-bus-disruptions__item--journeys {
	border-left-color: var(--wnc-alert-accent, var(--bus-normal));
}

.wnc-bus-disruptions__journeys {
	margin: 0;
}

.wnc-bus-disruptions__journeys-toggle {
	cursor: pointer;
	font-weight: 700;
	color: var(--bus-link);
	/* Keeps the clickable area comfortably above the 24px WCAG 2.2 minimum. */
	padding: var(--wnc-alert-space-xs) 0;
}

.wnc-bus-disruptions__journey-list {
	margin: var(--wnc-alert-space-s) 0 0;
	padding-left: 1.25rem;
}

.wnc-bus-disruptions__journey-list li {
	margin: 0 0 var(--wnc-alert-space-xs);
}

.wnc-bus-disruptions__journey-list li:last-child {
	margin-bottom: 0;
}

.wnc-bus-disruptions__actions {
	margin: var(--wnc-alert-space-m) 0 0;
}

/* The "View route" button. Colours come from the Journey Alerts settings.
   Kept at lower specificity than the shared :focus-visible rule above, so the
   keyboard focus indicator always wins. */
.wnc-bus-disruptions .wnc-bus-disruptions__button {
	display: inline-block;
	padding: clamp(0.375rem, 0.3rem + 0.4vw, 0.5rem) clamp(0.75rem, 0.6rem + 0.8vw, 1.125rem);
	/* A transparent border stays visible in Windows High Contrast mode. */
	border: 2px solid transparent;
	border-radius: 4px;
	background-color: var(--wnc-alert-btn-bg, var(--bus-link));
	color: var(--wnc-alert-btn-text, #ffffff);
	font-weight: 700;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
}

.wnc-bus-disruptions .wnc-bus-disruptions__button:hover:not(:focus-visible) {
	filter: brightness(0.9);
	text-decoration: underline;
}

.wnc-bus-disruptions__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	margin-bottom: var(--wnc-alert-space-s);
}

.wnc-bus-disruptions__summary {
	margin: 0;
	padding-bottom: 0;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.3;
}

.wnc-bus-disruptions__severity-badge {
	display: inline-block;
	padding: 0.125rem 0.625rem;
	border-radius: 999px;
	background-color: var(--bus-normal);
	color: #ffffff;
	font-size: 0.8125rem;
	font-weight: 700;
	white-space: nowrap;
}

.wnc-bus-disruptions__severity-badge--severe {
	background-color: var(--bus-severe);
}

.wnc-bus-disruptions__severity-badge--slight {
	background-color: var(--bus-slight);
}

.wnc-bus-disruptions__severity-badge--normal {
	background-color: var(--bus-normal);
}

.wnc-bus-disruptions__severity-badge--noService {
	background-color: var(--bus-noservice);
}

.wnc-bus-disruptions__dates,
.wnc-bus-disruptions__intro {
	margin: 0 0 var(--wnc-alert-space-s);
	/* Themes such as Divi add bottom padding to every paragraph; cancel it so
	   the spacing here is only what we set. */
	padding-bottom: 0;
	font-size: 0.875rem;
	color: var(--bus-text-muted);
}

.wnc-bus-disruptions__description {
	margin: 0 0 var(--wnc-alert-space-s);
	padding-bottom: 0;
}

.wnc-bus-disruptions__routes {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0.5rem 0 0;
	padding: 0;
}

.wnc-bus-disruptions__routes li a {
	display: inline-block;
	padding: 0.125rem 0.5rem;
	border: 1px solid var(--bus-link);
	border-radius: 3px;
	color: var(--bus-link);
	font-size: 0.8125rem;
	font-weight: 600;
	text-decoration: none;
}

.wnc-bus-disruptions__routes li a:hover {
	background-color: var(--bus-link);
	color: #ffffff;
}

/* -------------------------------------------------------------------------- */
/* Clickable stop links (timetable -> map)                                    */
/* -------------------------------------------------------------------------- */

/*
 * The stop name in the desktop timetable's row header becomes a button that
 * focuses the matching pin on the route map further down the page. It is
 * styled to read as a link (so the affordance is obvious) while remaining a
 * real <button> for keyboard and screen-reader users.
 */
.wnc-bus-timetable__stop-link {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	text-align: left;
	color: var(--bus-link);
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.wnc-bus-timetable__stop-link:hover {
	color: var(--bus-link-hover);
}

/* Clear, high-contrast focus state (GDS-style yellow) for WCAG 2.2 AA. */
.wnc-bus-timetable__stop-link:focus-visible {
	outline: 3px solid var(--bus-focus);
	outline-offset: 0;
	background-color: var(--bus-focus);
	color: var(--bus-focus-text);
	text-decoration: none;
	box-shadow: 0 2px 0 var(--bus-focus-text);
}

/*
 * The mobile variant is a full-width tappable button shown within each stop's
 * departures block, with a comfortable touch target (>= 44px tall).
 */
.wnc-bus-timetable__stop-link--mobile {
	display: inline-block;
	margin-bottom: 0.75rem;
	padding: 0.5rem 0.75rem;
	min-height: 44px;
	border: 2px solid var(--bus-link);
	border-radius: 4px;
	text-decoration: none;
}

.wnc-bus-timetable__stop-link--mobile:hover {
	background-color: var(--bus-link);
	color: #ffffff;
}

/* -------------------------------------------------------------------------- */
/* Print styles: show the whole timetable, no horizontal scrolling.           */
/* -------------------------------------------------------------------------- */

@media print {
	.wnc-bus-timetable__tabs,
	.wnc-bus-timetable__mobile {
		display: none;
	}

	.wnc-bus-timetable__grid-wrapper {
		display: block;
		overflow: visible;
		border: none;
	}

	.wnc-bus-timetable__panel[hidden] {
		display: block !important;
	}

	.wnc-bus-timetable__grid th[scope="row"],
	.wnc-bus-timetable__grid thead th:first-child {
		position: static;
	}

	.wnc-bus-routes__item,
	.wnc-bus-disruptions__item {
		break-inside: avoid;
	}
}



/* ---------------------------------------------------------------------------
   Route map (Leaflet)
   --------------------------------------------------------------------------- */

.wnc-bus-map-wrapper {
	margin: 1.5rem 0;
}

.wnc-bus-map {
	width: 100%;
	min-height: 300px;
	border: 1px solid #d0d0d0;
	border-radius: 4px;
}

/* Ensure the Leaflet container sizes correctly inside Divi rows. */
.wnc-bus-map .leaflet-container {
	height: 100%;
	width: 100%;
	font: inherit;
}

/* Ring / hoop stop markers (divIcon). The coloured border comes inline from
   JS (per the configured node colour); this gives it the hoop shape, white
   centre, and a subtle outer halo so it stays visible on any map background. */
.wnc-bus-map-node-wrap {
	background: none;
	border: 0;
}

.wnc-bus-map-node {
	display: block;
	box-sizing: border-box;
	border-style: solid;
	border-width: 3px;
	border-radius: 50%;
	background-color: #ffffff;
	box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.25 );
}

/* Emphasised first/last stop: thicker ring for extra prominence. */
.wnc-bus-map-node--end {
	border-width: 4px;
	box-shadow: 0 0 0 2px rgba( 0, 0, 0, 0.3 );
}

/* Directional ring markers: a ring centred on the stop with a small arrow on
   its outer edge, placed at and pointing along the direction of travel. The
   ring never moves (so the marker stays anchored on the stop); the arrow layer
   is rotated to the bearing by JS. */
.wnc-bus-map-ringdir {
	position: relative;
	display: block;
}

/* Centre the ring within the padded box. */
.wnc-bus-map-ringdir .wnc-bus-map-node {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
}

/* Full-box layer that JS rotates to the travel bearing. */
.wnc-bus-map-dir {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transform-origin: center center;
}

/* The arrow: an upward triangle pinned to the top-centre of the rotated layer
   (i.e. on the ring's outer edge), pointing outward. Nudged down slightly so
   its base overlaps the ring border and the two read as a single shape. */
.wnc-bus-map-dir__arrow {
	position: absolute;
	top: 0;
	left: 50%;
	width: 0;
	height: 0;
	transform: translateX( -50% );
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-bottom-width: 7px;
	border-bottom-style: solid;
	/* border-bottom-color set inline (node colour). */
}

/* Live bus markers. A round badge containing an upright bus glyph, with a small
   arrow that orbits the badge to show the direction of travel. The badge stays
   upright for legibility; only the arrow rotates. Distinct colour so buses are
   clearly different from the (pink) stop markers. */
.wnc-bus-live-wrap {
	background: none;
	border: 0;
}

.wnc-bus-live {
	position: relative;
	display: block;
	width: 34px;
	height: 34px;
}

/* The circular badge holding the bus glyph. */
.wnc-bus-live__badge {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 24px;
	height: 24px;
	transform: translate( -50%, -50% );
	background-color: #1d70b8;       /* distinct blue vs pink stop markers */
	border: 2px solid #ffffff;
	border-radius: 50%;
	box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.4 );
	display: flex;
	align-items: center;
	justify-content: center;
}

.wnc-bus-live__glyph {
	width: 15px;
	height: 15px;
	fill: #ffffff;
}

/* Rotating layer that carries the direction arrow; JS rotates this to the
   bearing. The arrow is pinned to the top (front) and points outward. */
.wnc-bus-live__dir {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transform-origin: center center;
}

.wnc-bus-live__arrow {
	position: absolute;
	top: -1px;
	left: 50%;
	width: 0;
	height: 0;
	transform: translateX( -50% );
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-bottom: 8px solid #1d70b8;
}

/* ---------------------------------------------------------------------------
   Downloadable files
   --------------------------------------------------------------------------- */

.wnc-bus-files {
	margin: 1.5rem 0;
}

.wnc-bus-files__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.wnc-bus-files__item {
	margin: 0;
}

.wnc-bus-files__link {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.6rem 1rem;
	background: #7b1a3b;
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	font-weight: 600;
}

.wnc-bus-files__link::before {
	content: "\2193"; /* Down arrow to signal a download. */
	font-weight: 700;
}

.wnc-bus-files__link:hover,
.wnc-bus-files__link:focus {
	background: #5e142e;
}

.wnc-bus-files__link:focus-visible {
	outline: 3px solid #ffbf47; /* GDS-style focus highlight. */
	outline-offset: 2px;
}
