/*
	Live departures: the stop board (Figma 3913:9653, mobile 3913:10437 / 3913:10825) and
	one journey from it (3913:9910, mobile 3913:10572). Both pages are built by
	live-departures.js from jpapi; this file styles what it renders.

	The breadcrumbs are timetables.css's .tt-breadcrumbs, loaded alongside.
*/

.dep {
	display: flex;
	flex-direction: column;
	gap: var(--sypn-space-xs);
	padding: var(--sypn-space-sm) var(--sypn-gutter) var(--sypn-space-lg);
	font-family: var(--sypn-font);
	color: var(--sypn-ink);
}

.dep h1,
.dep h2,
.dep p {
	margin: 0;
}

.dep img {
	flex-shrink: 0;
}

/* ---------------------------------------------------------------- head */

.dep-head {
	display: flex;
	align-items: flex-start;
	gap: var(--sypn-space-xs);
}

.dep-mode {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: var(--sypn-radius-md);
	background: var(--sypn-ink);
}

/* The tram icon is the dark homepage one; the box wants it white. */
.dep-mode img {
	width: 24px;
	height: 24px;
	filter: brightness(0) invert(1);
}

.dep-head__text {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.dep-head h1 {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	font-size: 32px;
	font-weight: 700;
	line-height: 40px;
}

.dep-head__lede {
	font-size: 16px;
	line-height: 24px;
	color: #505051;
}

.dep[data-live-journey] .dep-head__lede {
	font-size: 20px;
	line-height: 32px;
}

.dep-head__meta {
	font-size: 12px;
	color: #505051;
}

.dep a.dep-head__again,
.dep-head__meta a {
	color: var(--sypn-ink);
	font-weight: 700;
	text-decoration: underline;
}

.dep a.dep-head__again {
	align-self: center;
	font-size: 16px;
}

.dep-head__meta a {
	font-weight: 400;
}

/* ---------------------------------------------------------------- tabs */

.dep-tabs {
	display: flex;
	border-bottom: 1px solid var(--sypn-charcoal-25);
}

.dep-tab {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	border: 0;
	border-bottom: 2px solid transparent;
	background: none;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	color: var(--sypn-ink);
	cursor: pointer;
}

.dep-tab[aria-selected="true"] {
	border-bottom-color: var(--sypn-orange);
}

.dep-tab img {
	width: 20px;
	height: 20px;
}

/* ---------------------------------------------------------------- board controls */

.dep-panel {
	display: flex;
	flex-direction: column;
	gap: var(--sypn-space-xs);
	padding-top: var(--sypn-space-xxs);
}

.dep-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 8px var(--sypn-space-xs);
}

.dep h2 {
	font-size: 24px;
	font-weight: 700;
	line-height: 32px;
}

.dep-hint {
	font-size: 14px;
	line-height: 20px;
}

.dep-updated {
	display: flex;
	align-items: center;
	gap: var(--sypn-space-xs);
	font-size: 14px;
	line-height: 20px;
}

.dep-refresh {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 16px;
	font-weight: 700;
	color: var(--sypn-ink);
	text-decoration: underline;
	cursor: pointer;
}

.dep-refresh img {
	width: 16px;
	height: 16px;
}

.dep-refresh[aria-busy="true"] {
	cursor: progress;
}

@media (prefers-reduced-motion: no-preference) {
	.dep-refresh[aria-busy="true"] img {
		animation: dep-spin 0.8s linear infinite;
	}
}

@keyframes dep-spin {
	to { transform: rotate(360deg); }
}

.dep-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.dep-routes {
	position: relative;
}

.dep-routes summary {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 12px 0 16px;
	border: 1px solid var(--sypn-grey-25);
	border-radius: var(--sypn-radius-md);
	font-size: 14px;
	list-style: none;
	cursor: pointer;
}

.dep-routes summary::-webkit-details-marker {
	display: none;
}

.dep-routes summary img {
	width: 20px;
	height: 20px;
}

.dep-routes[open] summary img:last-child {
	transform: rotate(180deg);
}

.dep-routes__list {
	position: absolute;
	z-index: 5;
	top: calc(100% + 4px);
	left: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 100%;
	max-height: 320px;
	overflow-y: auto;
	padding: 8px 0;
	border: 1px solid var(--sypn-grey-25);
	border-radius: var(--sypn-radius-md);
	background: var(--sypn-white);
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.dep-routes__list label {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 16px;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
}

.dep-chips {
	display: contents;
}

.dep-chips li {
	list-style: none;
}

.dep-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 32px;
	padding: 0 12px;
	border: 0;
	border-radius: 100px;
	background: var(--sypn-ink);
	color: var(--sypn-white);
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

.dep-chip img {
	width: 16px;
	height: 16px;
	filter: brightness(0) invert(1);
}

.dep-clear {
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	color: var(--sypn-ink);
	text-decoration: underline;
	cursor: pointer;
}

.dep-view {
	display: flex;
	border: 1px solid var(--sypn-grey-25);
	border-radius: var(--sypn-radius-md);
	overflow: hidden;
}

.dep-view button {
	flex: 1;
	height: 44px;
	border: 0;
	background: var(--sypn-white);
	font: inherit;
	font-weight: 700;
	color: var(--sypn-ink);
	cursor: pointer;
}

.dep-view button[aria-pressed="true"] {
	background: var(--sypn-orange-mid);
}

.dep-message {
	padding: var(--sypn-space-xs);
	border-radius: var(--sypn-radius-md);
	background: #f3f4f6;
}

/* ---------------------------------------------------------------- map */

.dep-map {
	height: 300px;
	border-radius: var(--sypn-radius-md);
	overflow: hidden;
	background: var(--sypn-charcoal-25);
}

.dep-map.is-error {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--sypn-grey);
}

.dep-vehicle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: 2px solid #3b82f6;
	border-radius: 4px;
	background: var(--sypn-white);
	box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}

.dep-vehicle img {
	width: 28px;
	height: 28px;
}

.dep-stop-pin {
	width: 16px;
	height: 16px;
	border: 3px solid var(--sypn-white);
	border-radius: 50%;
	background: var(--sypn-ink);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------------- departure rows */

.dep-table__head,
.dep-row {
	display: grid;
	grid-template-columns: 104px minmax(0, 1fr) 260px 120px 56px;
	align-items: center;
}

.dep-table__head {
	padding: 12px 0;
	font-size: 16px;
	color: var(--sypn-grey);
}

.dep-table__head span:first-child {
	padding-left: 8px;
}

.dep-table__head span:nth-child(4),
/* Clear of the chevron column's rule, in the heading and the rows alike */
.dep-row__due {
	padding-right: var(--sypn-space-xs);
	text-align: right;
}

.dep-rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.dep-row {
	min-height: 72px;
	border: 1px solid var(--sypn-charcoal-25);
	border-radius: var(--sypn-radius-md);
	color: var(--sypn-ink);
	text-decoration: none;
}

.dep-row:hover,
.dep-row:focus-visible {
	border-color: var(--sypn-ink);
	color: var(--sypn-ink);
}

.dep-row__time {
	align-self: stretch;
	display: flex;
	align-items: center;
	justify-content: center;
	border-right: 1px solid var(--sypn-charcoal-25);
	font-size: 20px;
	font-weight: 700;
}

.dep-row__service {
	display: flex;
	align-items: center;
	gap: 16px;
	min-width: 0;
	padding: 0 16px;
}

.dep-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 32px;
	padding: 0 12px;
	border-radius: var(--sypn-radius-md);
	background: var(--sypn-charcoal-25);
	font-size: 16px;
	font-weight: 700;
	line-height: 24px;
}

.dep-row__to {
	font-size: 16px;
	font-weight: 700;
}

.dep-row__status {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 14px;
}

.dep-state {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-weight: 500;
}

.dep-state img {
	width: 16px;
	height: 16px;
}

.is-ontime {
	color: var(--sypn-info);
}

.is-late {
	color: var(--sypn-error-dark);
}

.dep-live {
	font-weight: 700;
}

.dep-row__due {
	font-size: 20px;
	font-weight: 700;
}

.dep-row__due.is-due {
	color: var(--sypn-info);
}

.dep-row__go {
	align-self: stretch;
	display: flex;
	align-items: center;
	justify-content: center;
	border-left: 1px solid var(--sypn-charcoal-25);
}

.dep-row__go img {
	width: 24px;
	height: 24px;
}

.dep-more {
	height: 48px;
	border: 0;
	border-radius: var(--sypn-radius-md);
	background: var(--sypn-charcoal-25);
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	color: var(--sypn-ink);
	cursor: pointer;
}

/* ---------------------------------------------------------------- stop details tab */

.dep-details {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: var(--sypn-space-xs);
	margin: 0;
}

.dep-details div {
	padding: var(--sypn-space-xs);
	border: 1px solid var(--sypn-charcoal-25);
	border-radius: var(--sypn-radius-md);
}

.dep-details dt {
	font-size: 14px;
	font-weight: 400;
	color: #505051;
}

.dep-details dd {
	margin: 4px 0 0;
	font-size: 16px;
	font-weight: 700;
}

/* ---------------------------------------------------------------- one journey */

.dep-siblings {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.dep .dep-siblings h2 {
	font-size: 16px;
	line-height: 24px;
}

.dep-siblings ul {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.dep a.dep-time-chip {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 16px;
	border-radius: var(--sypn-radius-md);
	background: var(--sypn-charcoal-25);
	font-weight: 700;
	color: var(--sypn-ink);
	text-decoration: none;
}

.dep a.dep-time-chip.is-current {
	background: var(--sypn-ink);
	color: var(--sypn-white);
}

.dep-cards {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	border: 1px solid var(--sypn-charcoal-25);
	border-radius: var(--sypn-radius-md);
	overflow: hidden;
}

.dep-card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 22px 24px;
	font-size: 14px;
	line-height: 20px;
}

.dep-card + .dep-card {
	border-left: 1px solid var(--sypn-charcoal-25);
}

.dep .dep-card__value {
	font-size: 20px;
	font-weight: 700;
	line-height: 32px;
}

.dep-journey {
	display: flex;
	align-items: flex-start;
	gap: var(--sypn-space-md);
	padding-top: var(--sypn-space-xs);
}

.dep-journey__stops {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: var(--sypn-space-sm);
	min-width: 0;
	padding-left: 8px;
}

.dep-journey__map {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: min(700px, 55%);
}

.dep-journey__map .dep-bar {
	justify-content: space-between;
}

.dep-journey__map .dep-map {
	height: 600px;
}

/* Timeline: a dot per stop on a line that is grey where the vehicle has been. */
.dep-stops {
	margin: 0;
	padding: 0;
	list-style: none;
}

.dep-stops li {
	position: relative;
	padding: 0 0 21px 42px;
}

.dep-stops li:not(:last-child)::after {
	content: "";
	position: absolute;
	top: 8px;
	bottom: -8px;
	left: 7px;
	width: 2px;
	background: var(--sypn-ink);
}

.dep-stops li.is-passed::after {
	background: var(--sypn-grey-50);
}

.dep-stop {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas: "name time" "sub time";
	column-gap: var(--sypn-space-sm);
	row-gap: 2px;
}

.dep-stop::before {
	content: "";
	position: absolute;
	z-index: 1;
	top: 6px;
	left: 2px;
	width: 12px;
	height: 12px;
	border: 2px solid var(--sypn-ink);
	border-radius: 50%;
	background: var(--sypn-white);
}

.dep-stop.is-passed::before {
	border-color: var(--sypn-grey-50);
	background: var(--sypn-grey-50);
}

.dep-stop.is-yours::before {
	top: 4px;
	left: 0;
	width: 16px;
	height: 16px;
	border-color: var(--sypn-ink);
	background: var(--sypn-ink);
}

.dep-stop__name {
	grid-area: name;
	font-size: 16px;
	font-weight: 700;
	line-height: 24px;
}

.dep-stop.is-passed .dep-stop__name {
	font-weight: 400;
}

.dep-stop__sub {
	grid-area: sub;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 12px;
	font-size: 14px;
	line-height: 20px;
}

.dep-stop__time {
	grid-area: time;
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 14px;
	line-height: 20px;
	text-align: right;
}

.dep-stop__time strong {
	font-size: 16px;
	line-height: 24px;
}

.dep-stop.is-passed .dep-stop__time strong {
	font-weight: 400;
}

.dep-tag {
	display: inline-flex;
	align-items: center;
	height: 24px;
	padding: 0 8px;
	border-radius: var(--sypn-radius-md);
	background: var(--sypn-charcoal-25);
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
}

.dep-stops__more button {
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 14px;
	color: var(--sypn-ink);
	text-decoration: underline;
	cursor: pointer;
}

/* ---------------------------------------------------------------- below desktop */

@media (max-width: 991.98px) {
	.dep-mode {
		width: 40px;
		height: 40px;
	}

	.dep-head h1 {
		font-size: 20px;
		line-height: 28px;
	}

	.dep[data-live-journey] .dep-head__lede {
		font-size: 16px;
		line-height: 24px;
	}

	.dep-tab {
		flex: 1;
		justify-content: center;
		padding: 12px 8px;
		font-size: 16px;
		white-space: nowrap;
	}

	.dep h2 {
		font-size: 20px;
		line-height: 28px;
	}

	.dep-routes {
		flex: 1;
	}

	.dep-routes summary {
		justify-content: center;
		height: 48px;
		font-size: 16px;
	}

	/* The design swaps the list for the map rather than stacking them. */
	.dep[data-live-board]:not(.is-map-view) .dep-map,
	.dep[data-live-board].is-map-view .dep-table,
	.dep[data-live-board].is-map-view .dep-more {
		display: none;
	}

	.dep-table__head {
		display: none;
	}

	.dep-row {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas: "service due" "status time";
		gap: 8px 12px;
		padding: 12px;
	}

	.dep-row__time {
		grid-area: time;
		border: 0;
		justify-content: flex-end;
		font-size: 16px;
		font-weight: 400;
	}

	.dep-row__service {
		grid-area: service;
		gap: 12px;
		padding: 0;
	}

	.dep-row__status {
		grid-area: status;
	}

	.dep-row__due {
		grid-area: due;
		padding-right: 0;
	}

	.dep-row__go,
	.dep-live {
		display: none;
	}

	.dep-cards {
		grid-template-columns: 1fr 1fr;
	}

	.dep-card {
		padding: 16px;
	}

	.dep-card + .dep-card {
		border-left: 0;
	}

	.dep-card:nth-child(even) {
		border-left: 1px solid var(--sypn-charcoal-25);
	}

	.dep-card:nth-child(n + 3) {
		border-top: 1px solid var(--sypn-charcoal-25);
	}

	.dep-journey {
		flex-direction: column-reverse;
		align-items: stretch;
	}

	.dep-journey__map {
		width: auto;
	}

	.dep-journey__map .dep-map {
		height: 320px;
	}

	.dep-journey__stops {
		padding-left: 0;
	}
}
