/*!
 * WP Vessel Tracker — front-end map styles
 * Copyright (C) 2026 Marwan Shamaa
 *
 * Licensed under the GNU General Public License, version 2 or later.
 * See the LICENSE file distributed with this plugin, or
 * <https://www.gnu.org/licenses/gpl-2.0.html>.
 */

.vt-app {
	display: flex;
	flex-direction: column;
	gap: 20px;
	max-width: 100%;
}

/*
 * Scoped to the plugin's own subtree so it can't disturb the surrounding
 * theme. Without it, themes that leave inputs on content-box sizing push
 * padded selects past their container and the whole page scrolls sideways
 * on a phone.
 */
.vt-app,
.vt-app *,
.vt-app *::before,
.vt-app *::after {
	box-sizing: border-box;
}

.vt-app img,
.vt-app video,
.vt-app select,
.vt-app input,
.vt-app button {
	max-width: 100%;
}

.vt-view {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.vt-view[hidden] {
	display: none;
}

.vt-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 16px 20px;
}

/*
 * flex-basis rather than a hard min-width: the old min-width:180px couldn't
 * shrink, so two fields plus the gap overflowed a 360px phone viewport
 * instead of wrapping.
 */
.vt-field {
	display: flex;
	flex: 1 1 180px;
	flex-direction: column;
	font-size: 13px;
	gap: 4px;
	min-width: 0;
}

.vt-field select {
	padding: 6px 8px;
	width: 100%;
}

.vt-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.vt-stat {
	background: #f5f5f5;
	border-radius: 6px;
	display: flex;
	flex-direction: column;
	min-width: 100px;
	padding: 8px 12px;
}

.vt-stat span {
	color: #666;
	font-size: 11px;
	text-transform: uppercase;
}

.vt-stat strong {
	font-size: 18px;
}

/*
 * Viewport-relative so the map can't eat a whole phone screen and push the
 * controls and stats out of reach, while staying capped on desktop.
 */
.vt-map {
	border-radius: 6px;
	height: clamp( 280px, 60vh, 520px );
	width: 100%;
}

.vt-popup {
	font-size: 13px;
	line-height: 1.5;
}

.vt-popup-media {
	max-width: 220px;
}

.vt-popup-approx {
	border-top: 1px solid #e5e5e5;
	color: #8a6d1f;
	font-size: 11px;
	line-height: 1.4;
	margin-top: 6px;
	padding-top: 6px;
}

.vt-popup-thumb {
	border-radius: 4px;
	display: block;
	margin-bottom: 6px;
	max-width: 100%;
}

.vt-icon {
	align-items: center;
	border: 2px solid #fff;
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.4 );
	color: #fff;
	display: flex;
	font-size: 13px;
	font-weight: bold;
	height: 28px;
	justify-content: center;
	width: 28px;
}

.vt-icon-start {
	background: #16a34a;
}

.vt-icon-end {
	background: #dc2626;
}

.vt-icon-photo {
	background: #2563eb;
	font-size: 14px;
}

.vt-icon-video {
	background: #7c3aed;
	font-size: 12px;
}

.vt-lightbox {
	align-items: center;
	background: rgba( 0, 0, 0, 0.85 );
	display: flex;
	inset: 0;
	justify-content: center;
	position: fixed;
	z-index: 100000;
}

.vt-lightbox[hidden] {
	display: none;
}

.vt-lightbox-inner {
	max-width: 90vw;
	position: relative;
	text-align: center;
}

.vt-lightbox-content img,
.vt-lightbox-content video {
	max-height: 80vh;
	max-width: 90vw;
}

.vt-lightbox-meta {
	color: #eee;
	font-size: 13px;
	margin-top: 10px;
}

.vt-lightbox-close {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	font-size: 28px;
	line-height: 1;
	position: absolute;
	right: -10px;
	top: -36px;
}

.vt-lightbox-prev,
.vt-lightbox-next {
	background: rgba( 255, 255, 255, 0.15 );
	border: none;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	font-size: 32px;
	height: 48px;
	line-height: 1;
	position: fixed;
	top: 50%;
	transform: translateY( -50% );
	width: 48px;
	z-index: 100001;
}

.vt-lightbox-prev:hover,
.vt-lightbox-next:hover {
	background: rgba( 255, 255, 255, 0.3 );
}

.vt-lightbox-prev {
	left: 24px;
}

.vt-lightbox-next {
	right: 24px;
}

.vt-lightbox-counter {
	color: #ccc;
	font-size: 12px;
	margin-top: 6px;
	text-align: center;
}

/* ---------------------------------------------------------------------
   Landing screen
--------------------------------------------------------------------- */

.vt-landing h2 {
	margin-bottom: 12px;
}

.vt-landing-cards {
	display: grid;
	gap: 16px;
	/* min() so the 240px track collapses on screens narrower than that, rather than overflowing. */
	grid-template-columns: repeat( auto-fit, minmax( min( 240px, 100% ), 1fr ) );
}

.vt-landing-card {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 10px;
	cursor: pointer;
	padding: 20px;
	text-align: left;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.vt-landing-card:hover {
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.12 );
	transform: translateY( -2px );
}

.vt-landing-card h3 {
	margin: 0 0 8px;
}

.vt-landing-card p {
	color: #555;
	font-size: 14px;
	margin: 0;
}

.vt-back-to-landing {
	background: none;
	border: none;
	color: #2563eb;
	cursor: pointer;
	font-size: 13px;
	padding: 0;
}

/* ---------------------------------------------------------------------
   Live Events view
--------------------------------------------------------------------- */

.vt-live-toolbar {
	align-items: flex-end;
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.vt-live-status {
	align-items: center;
	display: flex;
	gap: 6px;
}

.vt-live-dot {
	background: #999;
	border-radius: 50%;
	display: inline-block;
	height: 10px;
	width: 10px;
}

.vt-live-dot-connecting {
	background: #d97706;
}

.vt-live-dot-connected {
	background: #16a34a;
}

.vt-live-dot-error {
	background: #dc2626;
}

.vt-radar-field input[type='range'] {
	width: 140px;
}

.vt-refresh-custom {
	margin-top: 4px;
	padding: 6px 8px;
	width: 100px;
}

.vt-live-layout {
	display: grid;
	gap: 20px;
	grid-template-columns: 240px 1fr;
}

.vt-live-map {
	height: clamp( 300px, 62vh, 560px );
}

.vt-fleet-panel {
	background: #f9f9f9;
	border-radius: 6px;
	max-height: 560px;
	overflow-y: auto;
	padding: 12px;
}

.vt-fleet-panel h3 {
	font-size: 13px;
	margin: 0 0 8px;
	text-transform: uppercase;
}

.vt-fleet-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.vt-fleet-item {
	border-bottom: 1px solid #e5e5e5;
	padding: 6px 0;
}

.vt-fleet-item label {
	align-items: center;
	cursor: pointer;
	display: flex;
	font-size: 13px;
	gap: 6px;
}

.vt-fleet-item-hidden {
	opacity: 0.45;
}

.vt-fleet-swatch {
	border-radius: 50%;
	display: inline-block;
	height: 10px;
	width: 10px;
}

.vt-fleet-rank {
	color: #888;
	font-size: 11px;
}

.vt-fleet-name {
	flex: 1;
}

.vt-fleet-speed {
	color: #666;
	font-variant-numeric: tabular-nums;
}

.vt-fleet-empty {
	color: #888;
	font-size: 13px;
}

/* ---------------------------------------------------------------------
   Trip stats and notes
--------------------------------------------------------------------- */

/*
 * The byline sits among the numbers but is not one: a name gets more room than
 * "12.4 nm" needs, and should not be clipped to fit a stat-sized box.
 */
.vt-stat-byline strong {
	font-weight: 600;
	white-space: normal;
}

/* An explanation for an empty map, not an error: quiet, but present. */
.vt-media-note {
	color: #64748b;
	font-size: 13px;
	margin: 6px 0 0;
}

/* ---------------------------------------------------------------------
   Boat heading icon (Live Events)
--------------------------------------------------------------------- */

.vt-boat-icon {
	background: none;
	border: none;
	box-shadow: none;
}

.vt-boat-icon-rotate {
	transition: transform 0.5s linear;
}

/* ---------------------------------------------------------------------
   Toggle-style buttons (Radar on/off, fleet select all/none)
--------------------------------------------------------------------- */

/*
 * Explicit colour, not inherited: these sit on a light pill background, and
 * themes with a pale default button colour rendered the labels nearly
 * invisible against it.
 */
.vt-radar-toggle,
.vt-radar-animate,
.vt-fleet-select-all-btn,
.vt-fleet-select-none-btn {
	background: #f0f0f0;
	border: 1px solid #ccc;
	border-radius: 999px;
	color: #111;
	cursor: pointer;
	font-size: 12px;
	padding: 6px 14px;
}

/* The pressed radar toggle inverts to a dark fill, so its label goes white. */
.vt-radar-toggle[aria-pressed='true'],
.vt-radar-animate[aria-pressed='true'] {
	background: #2563eb;
	border-color: #2563eb;
	color: #fff;
}

/*
 * The frame clock is fixed-width and tabular: it changes twice a second while
 * the loop runs, and proportional digits made the whole toolbar twitch.
 */
.vt-radar-time {
	color: #475569;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	min-width: 9ch;
}

.vt-radar-time-forecast {
	font-style: italic;
}

.vt-radar-controls {
	align-items: center;
	display: flex;
	gap: 8px;
}

/* ---------------------------------------------------------------------
   Replay bar (Historical Trips)
--------------------------------------------------------------------- */

.vt-replay-bar {
	align-items: center;
	background: #f5f5f5;
	border-radius: 8px;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	padding: 10px 14px;
}

.vt-replay-bar[hidden] {
	display: none;
}

.vt-replay-toggle {
	align-items: center;
	background: linear-gradient( 180deg, #3b82f6 0%, #2563eb 100% );
	border: none;
	border-radius: 50%;
	box-shadow: 0 1px 2px rgba( 15, 23, 42, 0.2 ), 0 4px 10px rgba( 37, 99, 235, 0.35 );
	color: #fff;
	cursor: pointer;
	display: flex;
	flex-shrink: 0;
	height: 42px;
	justify-content: center;
	padding: 0;
	transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
	width: 42px;
}

.vt-replay-toggle svg {
	display: block;
}

.vt-replay-toggle:hover {
	background: linear-gradient( 180deg, #2563eb 0%, #1d4ed8 100% );
	box-shadow: 0 1px 2px rgba( 15, 23, 42, 0.22 ), 0 6px 14px rgba( 37, 99, 235, 0.45 );
}

.vt-replay-toggle:focus-visible {
	outline: 2px solid #1d4ed8;
	outline-offset: 2px;
}

.vt-replay-toggle:active {
	box-shadow: 0 1px 2px rgba( 15, 23, 42, 0.2 );
	transform: scale( 0.94 );
}

.vt-replay-clock {
	color: #444;
	flex-shrink: 0;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	min-width: 90px;
}

.vt-replay-scrubber {
	flex: 1;
	min-width: 100px;
}

.vt-replay-speed-field {
	align-items: center;
	display: flex;
	flex-shrink: 0;
	font-size: 12px;
	gap: 6px;
}

.vt-replay-speed-field input[type='range'] {
	width: 100px;
}

.vt-replay-speed-label {
	font-variant-numeric: tabular-nums;
	min-width: 34px;
}

/* ---------------------------------------------------------------------
   Fleet panel select all/none
--------------------------------------------------------------------- */

.vt-fleet-panel-header {
	align-items: center;
	display: flex;
	justify-content: space-between;
	margin-bottom: 8px;
}

.vt-fleet-panel-header h3 {
	margin: 0;
}

.vt-fleet-select-all {
	display: flex;
	gap: 4px;
}

.vt-fleet-select-all-btn,
.vt-fleet-select-none-btn {
	font-size: 10px;
	padding: 3px 8px;
}

/* ---------------------------------------------------------------------
   Responsive
   Kept together at the end rather than scattered, so the small-screen
   layout can be read as one piece.
--------------------------------------------------------------------- */

/* Tablets and narrow desktop windows: the fleet sidebar no longer fits
   beside the map without squeezing it below a usable width. */
@media ( max-width: 900px ) {
	.vt-live-layout {
		grid-template-columns: 1fr;
	}

	/* Stacked above the map now, so it must not consume the whole screen. */
	.vt-fleet-panel {
		max-height: 260px;
	}
}

/* Phones. */
@media ( max-width: 600px ) {
	.vt-app,
	.vt-view {
		gap: 16px;
	}

	.vt-controls {
		gap: 12px;
	}

	/* Full-width controls: two selects side by side leave neither wide
	   enough to read a boat or trip name on a phone. */
	.vt-field {
		flex-basis: 100%;
	}

	.vt-map,
	.vt-live-map {
		height: clamp( 260px, 55vh, 420px );
	}

	/* Two stats per row instead of one long scroll of them. */
	.vt-stats {
		gap: 8px;
	}

	.vt-stat {
		flex: 1 1 calc( 50% - 8px );
		min-width: 0;
		padding: 8px 10px;
	}

	.vt-stat strong {
		font-size: 16px;
	}

	.vt-fleet-panel {
		max-height: 220px;
	}

	.vt-live-toolbar {
		gap: 12px;
	}

	.vt-landing-card {
		padding: 16px;
	}

	/* Replay bar: give the scrubber its own full-width row underneath the
	   controls — inline, it collapsed to a few unusable pixels. */
	.vt-replay-bar {
		gap: 10px;
		padding: 10px;
	}

	.vt-replay-clock {
		min-width: 0;
	}

	.vt-replay-scrubber {
		flex: 1 1 100%;
		min-width: 0;
		order: 3;
	}

	.vt-replay-speed-field {
		flex: 1 1 auto;
		justify-content: flex-end;
	}

	.vt-replay-speed-field input[type='range'] {
		max-width: 110px;
		width: 100%;
	}

	/* Comfortable touch targets — these are 10-12px text buttons on desktop. */
	.vt-radar-toggle,
	.vt-radar-animate,
	.vt-fleet-select-all-btn,
	.vt-fleet-select-none-btn {
		min-height: 34px;
	}

	.vt-radar-field input[type='range'] {
		width: 100%;
	}

	/* Four controls in one row is too many for a phone; the slider takes its
	   own line under the two buttons and the frame clock. */
	.vt-radar-controls {
		flex-wrap: wrap;
	}

	/* Lightbox: fixed-position arrows at 24px inset overlapped the image,
	   and the close button sat off-screen above tall content. */
	.vt-lightbox-inner {
		max-width: 94vw;
	}

	.vt-lightbox-content img,
	.vt-lightbox-content video {
		max-height: 62vh;
		max-width: 94vw;
	}

	.vt-lightbox-close {
		background: rgba( 0, 0, 0, 0.5 );
		border-radius: 50%;
		height: 40px;
		position: fixed;
		right: 10px;
		top: 10px;
		width: 40px;
	}

	.vt-lightbox-prev,
	.vt-lightbox-next {
		font-size: 24px;
		height: 40px;
		width: 40px;
	}

	.vt-lightbox-prev {
		left: 8px;
	}

	.vt-lightbox-next {
		right: 8px;
	}
}

/* ---------------------------------------------------------------------
   Weather row: summary plus the °F/°C selector
--------------------------------------------------------------------- */

.vt-weather-row {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: space-between;
}

.vt-weather-source {
	display: flex;
	flex-shrink: 0;
	gap: 0;
}

/* The radar selector sits at the end of the row. */
.vt-weather-controls {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.vt-weather-source-btn {
	background: #f0f0f0;
	border: 1px solid #ccc;
	color: #111;
	cursor: pointer;
	font-size: 12px;
	line-height: 1;
	padding: 6px 12px;
}

.vt-weather-source-btn:first-child {
	border-radius: 999px 0 0 999px;
}

.vt-weather-source-btn:last-child {
	border-left: none;
	border-radius: 0 999px 999px 0;
}

.vt-weather-source-btn[aria-pressed='true'] {
	background: #2563eb;
	border-color: #2563eb;
	color: #fff;
}

@media ( max-width: 600px ) {
	.vt-weather-source-btn {
		min-height: 34px;
	}
}

/* ---------------------------------------------------------------------
   Shown in place of the map to a viewer who cannot read the trip data
--------------------------------------------------------------------- */

.vt-restricted {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	margin: 0 auto;
	max-width: 520px;
	padding: 28px 24px;
	text-align: center;
}

.vt-restricted h2 {
	margin-top: 0;
}

.vt-restricted p {
	color: #475569;
}

.vt-restricted-link {
	background: #2563eb;
	border-radius: 999px;
	color: #fff;
	display: inline-block;
	padding: 10px 22px;
	text-decoration: none;
}

/* Shown in place of a clip this browser cannot decode — see the lightbox. */
.vt-media-unplayable {
	margin: 0;
	padding: 24px;
	color: #f8fafc;
	text-align: center;
	font-size: 15px;
	line-height: 1.5;
}

.vt-media-unplayable a {
	color: #93c5fd;
}
