/* BoatLink demo UI — the boatlink.fi identity, worn by an application.
 *
 * One deliberate theme. The marketing site is night-watch dark with brass, and
 * an app that shares its name should feel like the same room - so every colour
 * is painted explicitly and there is no light variant to drift out of step.
 *
 * Type does the talking: Georgia for names and numerals (the same face as the
 * BL monogram), the system face for prose, and the platform mono for data,
 * because a bilge voltage is data and should look like it.
 */

:root {
	--ground: #07090b;
	--panel: #0e1216;
	--raised: #141a1f;
	--sunken: #0a0d10;
	--line: #1d252c;
	--brass-line: rgba(201, 149, 72, .22);
	--ink: #eae5da;
	--dim: #8fa0aa;
	--faint: #5b6a73;
	--brass: #c99548;
	--brass-bright: #e3b878;
	--ok: #46c896;
	--warn: #e0a33d;
	--crit: #ef8078;
	--crit-wash: rgba(239, 128, 120, .1);
	--ok-wash: rgba(70, 200, 150, .08);
	--shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .45);

	--serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
	--sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	--mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { scrollbar-color: #2a343c var(--ground); }

body {
	background:
		radial-gradient(1200px 500px at 70% -10%, rgba(201, 149, 72, .05), transparent 60%),
		var(--ground);
	color: var(--ink);
	font: 15px/1.55 var(--sans);
	-webkit-font-smoothing: antialiased;
}

a { color: var(--brass); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, a:focus-visible, input:focus-visible {
	outline: 2px solid var(--brass);
	outline-offset: 2px;
	border-radius: 4px;
}

/* ---- the recurring voices ---- */

.kicker {
	font: 600 10.5px/1 var(--mono);
	letter-spacing: .22em;
	text-transform: uppercase;
	color: var(--brass);
}
.kicker .n { color: var(--faint); }

.microlabel {
	font: 600 10px/1.3 var(--mono);
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--faint);
}

.serif { font-family: var(--serif); }

/* ---- boot ---- */

.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 18px; }
.boot-word { color: var(--faint); font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; }

.monogram {
	width: 54px; height: 54px;
	border: 1px solid var(--brass-line);
	border-radius: 14px;
	display: grid; place-content: center;
	font: 24px var(--serif);
	color: var(--brass);
	background: linear-gradient(180deg, rgba(201,149,72,.08), transparent);
}
.monogram.sm { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }

/* ---- login ---- */

.login {
	min-height: 100dvh;
	display: grid; place-content: center; justify-items: center;
	gap: 26px;
	padding: 24px;
}
.login-card {
	width: min(94vw, 380px);
	background: var(--panel);
	border: 1px solid var(--brass-line);
	border-radius: 16px;
	padding: 30px 28px 26px;
	box-shadow: var(--shadow);
	display: grid; gap: 16px;
}
.login h1 {
	margin: 0;
	font: 400 30px/1.1 var(--serif);
	letter-spacing: -.01em;
	text-wrap: balance;
}
.login .sub { margin: -6px 0 6px; color: var(--dim); font-size: 13.5px; }
.field { display: grid; gap: 6px; }
.field input {
	background: var(--sunken);
	border: 1px solid var(--line);
	border-radius: 9px;
	color: var(--ink);
	padding: 11px 13px;
	font-size: 15px;
}
.field input:focus { border-color: var(--brass); outline: none; }
.login-err { color: var(--crit); font-size: 13px; min-height: 18px; margin: 0; }

.btn-brass {
	background: linear-gradient(180deg, var(--brass-bright), var(--brass));
	color: #14100a;
	font-weight: 650;
	border-radius: 10px;
	padding: 12px 16px;
	text-align: center;
	letter-spacing: .02em;
}
.btn-brass:disabled { opacity: .55; cursor: default; }
.btn-quiet {
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 9px 14px;
	color: var(--dim);
}
.btn-quiet:hover { border-color: var(--brass-line); color: var(--ink); }

/* ---- app frame: rail on desktop, bars on mobile ---- */

.frame { min-height: 100dvh; display: grid; grid-template-columns: 218px 1fr; }

.rail {
	border-right: 1px solid var(--line);
	padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
	display: flex; flex-direction: column; gap: 26px;
	position: sticky; top: 0; height: 100dvh;
	background: linear-gradient(180deg, rgba(201,149,72,.03), transparent 30%);
}
.rail-brand { display: flex; align-items: center; gap: 12px; }
.rail-brand .word { font: 600 13px/1.2 var(--mono); letter-spacing: .3em; }
.rail-brand .word small { display: block; color: var(--faint); font-size: 8.5px; letter-spacing: .28em; font-weight: 500; }

.rail nav { display: grid; gap: 4px; }
.rail nav a {
	display: flex; align-items: center; gap: 11px;
	padding: 10px 12px;
	border-radius: 9px;
	color: var(--dim);
	font-size: 14px;
}
.rail nav a svg { width: 17px; height: 17px; flex: none; }
.rail nav a.on { color: var(--ink); background: var(--raised); box-shadow: inset 2px 0 0 var(--brass); }
.rail nav a:hover { color: var(--ink); }
.rail .foot { margin-top: auto; display: grid; gap: 10px; }
.rail .foot .btn-quiet { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.rail .foot svg { width: 15px; height: 15px; flex: none; }
.rail .who { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; padding: 26px clamp(16px, 4vw, 44px) 90px; }
.main-inner { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; }

.appbar, .tabbar { display: none; }

@media (max-width: 880px) {
	.frame { grid-template-columns: 1fr; }
	.rail { display: none; }
	.main { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }

	.appbar {
		display: flex; align-items: center; gap: 12px;
		position: sticky; top: 0; z-index: 60;
		margin: -14px -14px 12px;
		padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
		background: rgba(7, 9, 11, .88);
		backdrop-filter: blur(14px);
		border-bottom: 1px solid var(--line);
	}
	.appbar .title { font: 400 17px var(--serif); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.appbar .back { color: var(--brass); font-size: 20px; padding: 4px 8px 4px 0; }

	.tabbar {
		display: grid; grid-auto-flow: column; justify-content: space-around;
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
		padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
		background: rgba(10, 13, 16, .92);
		backdrop-filter: blur(14px);
		border-top: 1px solid var(--line);
	}
	.tabbar a { display: grid; justify-items: center; gap: 3px; color: var(--faint); font: 600 9.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; padding: 2px 14px; }
	.tabbar a svg { width: 20px; height: 20px; }
	.tabbar a.on { color: var(--brass); }
}

/* ---- page headers ---- */

.pagehead { display: grid; gap: 8px; }
.pagehead h1 {
	margin: 0;
	font: 400 clamp(30px, 5vw, 44px)/1.04 var(--serif);
	letter-spacing: -.015em;
	text-wrap: balance;
}
.pagehead .under { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--dim); font-size: 13.5px; }

.pill {
	display: inline-flex; align-items: center; gap: 6px;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 3px 11px;
	font: 600 10.5px var(--mono);
	letter-spacing: .12em; text-transform: uppercase;
	color: var(--dim);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.ok { color: var(--ok); border-color: rgba(70,200,150,.35); } .pill.ok .dot { background: var(--ok); box-shadow: 0 0 8px rgba(70,200,150,.7); }
.pill.warn { color: var(--warn); border-color: rgba(224,163,61,.4); } .pill.warn .dot { background: var(--warn); }
.pill.crit { color: var(--crit); border-color: rgba(239,128,120,.45); } .pill.crit .dot { background: var(--crit); box-shadow: 0 0 8px rgba(239,128,120,.6); }
.pill.quiet { color: var(--faint); }

/* ---- cards ---- */

.card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 14px;
	padding: 18px 20px;
	box-shadow: var(--shadow);
	min-width: 0;
}
.card > .kicker { display: block; margin-bottom: 12px; }

/* ---- fleet ---- */

.fleet-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
@media (max-width: 880px) { .fleet-grid { grid-template-columns: 1fr; } }

.boat-card {
	display: grid; gap: 14px;
	text-align: left;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 16px;
	padding: 20px;
	box-shadow: var(--shadow);
	transition: border-color .18s, transform .18s;
}
.boat-card:hover { border-color: var(--brass-line); transform: translateY(-2px); }
.boat-card .top { display: flex; align-items: baseline; gap: 12px; }
.boat-card h2 { margin: 0; font: 400 25px/1.1 var(--serif); flex: 1; min-width: 0; }
.boat-card .where { color: var(--dim); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.boat-card .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 10px; border-top: 1px solid var(--line); padding-top: 13px; }
.metric .v { font: 400 22px/1 var(--serif); font-variant-numeric: tabular-nums; }
.metric .v small { font-size: 12px; color: var(--dim); font-family: var(--mono); margin-left: 2px; }
.metric .k { margin-top: 4px; }
.boat-card .alertline { color: var(--crit); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.boat-card .alertline.none { color: var(--faint); }

/* ---- boat page ---- */

.subtabs {
	display: flex; gap: 4px;
	border-bottom: 1px solid var(--line);
	overflow-x: auto; scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button {
	flex: none;
	padding: 10px 16px 12px;
	color: var(--dim);
	font: 600 11px var(--mono); letter-spacing: .16em; text-transform: uppercase;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
}
.subtabs button.on { color: var(--brass); border-bottom-color: var(--brass); }

.stat-strip { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat {
	background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
	padding: 15px 17px 12px; box-shadow: var(--shadow);
	display: grid; gap: 2px; min-width: 0;
}
.stat .v { font: 400 32px/1.05 var(--serif); font-variant-numeric: tabular-nums; }
.stat .v small { font: 500 13px var(--mono); color: var(--dim); margin-left: 3px; }
.stat .k { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stat svg.spark { width: 100%; height: 34px; margin-top: 6px; display: block; }
.spark .line { fill: none; stroke: var(--brass); stroke-width: 1.6; }
.spark .fill { fill: url(#sparkfill); stroke: none; opacity: .5; }
.spark .end { fill: var(--brass-bright); }

.compartments { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); align-items: start; }
@media (max-width: 880px) { .compartments { grid-template-columns: 1fr; } }

.rooms h3, .card h3 { margin: 0 0 4px; font: 400 18px var(--serif); }
.readingrow {
	display: flex; align-items: baseline; gap: 10px;
	padding: 7px 0;
	border-top: 1px solid var(--line);
	font-size: 13.5px;
}
.readingrow:first-of-type { border-top: 0; }
.readingrow .nm { color: var(--dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.readingrow .val { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.readingrow .val .u { color: var(--faint); margin-left: 3px; }
.devhead { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; }
.devhead:first-child { margin-top: 2px; }
.devhead .microlabel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devdot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.devdot.online { background: var(--ok); box-shadow: 0 0 7px rgba(70,200,150,.8); }
.devdot.late { background: var(--warn); }
.devdot.offline, .devdot.silent { background: var(--crit); }
.devdot.off { background: var(--faint); }

/* ---- the vessel stage ---- */

.stage-wrap {
	position: relative;
	border: 1px solid var(--brass-line);
	border-radius: 16px;
	overflow: hidden;
	background:
		radial-gradient(900px 420px at 50% 110%, rgba(201, 149, 72, .07), transparent 65%),
		radial-gradient(700px 300px at 80% -10%, rgba(70, 120, 160, .06), transparent 60%),
		var(--sunken);
	box-shadow: var(--shadow);
}
.stage { height: min(58dvh, 560px); cursor: grab; }
.stage:active { cursor: grabbing; }
.stage canvas { display: block; }
@media (max-width: 880px) { .stage { height: 52dvh; } }

.stage-hint {
	position: absolute; left: 0; right: 0; bottom: 10px;
	text-align: center; pointer-events: none;
	letter-spacing: .14em;
}

.b3d-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.b3d-label {
	position: absolute; top: 0; left: 0;
	pointer-events: auto;
	transform: translate(-200px, -200px);
	translate: -50% -100%;
	background: rgba(10, 13, 16, .82);
	backdrop-filter: blur(6px);
	border: 1px solid var(--brass-line);
	border-radius: 999px;
	padding: 3px 11px;
	font: 600 10px var(--mono);
	letter-spacing: .14em; text-transform: uppercase;
	color: var(--brass-bright);
	white-space: nowrap;
	transition: opacity .15s;
}
.b3d-label.on { background: rgba(201, 149, 72, .22); border-color: var(--brass); color: #fff; }
.b3d-label.crit { color: var(--crit); border-color: rgba(239, 128, 120, .5); }

.drawer {
	position: absolute; z-index: 10;
	top: 12px; right: 12px; bottom: 12px;
	width: min(360px, calc(100% - 24px));
	background: rgba(12, 16, 20, .92);
	backdrop-filter: blur(14px);
	border: 1px solid var(--brass-line);
	border-radius: 14px;
	padding: 16px 18px;
	overflow-y: auto;
	box-shadow: var(--shadow);
	animation: drawerin .22s ease;
}
@keyframes drawerin { from { opacity: 0; transform: translateX(14px); } }
@media (max-width: 880px) {
	.drawer {
		top: auto; left: 8px; right: 8px; bottom: 8px;
		width: auto; max-height: 62%;
		animation-name: drawerup;
	}
	@keyframes drawerup { from { opacity: 0; transform: translateY(16px); } }
}
.drawer-head { display: flex; align-items: flex-start; gap: 10px; }
.drawer-head > div { flex: 1; min-width: 0; }
.drawer-head h3 { font-size: 21px; }
.drawer-close {
	flex: none; width: 30px; height: 30px;
	border: 1px solid var(--line); border-radius: 8px;
	color: var(--dim); font-size: 17px; line-height: 1;
}
.drawer-close:hover { color: var(--ink); border-color: var(--brass-line); }
.drawer .alertcard { margin: 10px 0 4px; }

/* ---- switches ---- */

.switchrow { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.switchrow:first-of-type { border-top: 0; }
.switchrow .nm { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle {
	width: 46px; height: 26px; flex: none;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--sunken);
	position: relative;
	transition: background .18s, border-color .18s;
}
.toggle::after {
	content: '';
	position: absolute; top: 3px; left: 3px;
	width: 18px; height: 18px; border-radius: 50%;
	background: var(--dim);
	transition: transform .18s, background .18s;
}
.toggle.on { background: rgba(201,149,72,.25); border-color: var(--brass); }
.toggle.on::after { transform: translateX(20px); background: var(--brass-bright); }
.toggle.busy { opacity: .5; }
.toggle:disabled { cursor: default; opacity: .45; }
.feedline { color: var(--faint); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.feedline .devdot { width: 6px; height: 6px; }

.modes { display: flex; gap: 6px; flex-wrap: wrap; }
.modes button {
	border: 1px solid var(--line); border-radius: 999px;
	padding: 5px 13px; font-size: 12.5px; color: var(--dim);
}
.modes button.on { border-color: var(--brass); color: var(--brass-bright); background: rgba(201,149,72,.1); }

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

.mapwrap { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.mapwrap .map { height: min(66dvh, 620px); background: #0a0e11; }
@media (max-width: 880px) { .mapwrap .map { height: 58dvh; } }
.maptools {
	position: absolute; z-index: 500; top: 10px; left: 10px; right: 10px;
	display: flex; gap: 6px; justify-content: flex-start; pointer-events: none;
}
.maptools button {
	pointer-events: auto;
	background: rgba(10, 13, 16, .88); backdrop-filter: blur(8px);
	border: 1px solid var(--line); border-radius: 999px;
	padding: 5px 13px; font: 600 10.5px var(--mono); letter-spacing: .1em; color: var(--dim);
}
.maptools button.on { color: var(--brass-bright); border-color: var(--brass); }
.mapfoot { padding: 10px 14px; display: flex; gap: 14px; flex-wrap: wrap; color: var(--faint); font-size: 12px; background: var(--panel); border-top: 1px solid var(--line); }
/* Night chart: darken the tiles, keep the vectors bright. */
.map .leaflet-tile-pane { filter: invert(1) hue-rotate(190deg) saturate(.32) brightness(.75) contrast(.9); }
.map .leaflet-container { background: #0a0e11; font: inherit; }

/* ---- alerts ---- */

.alertcard { display: grid; gap: 2px; padding: 13px 16px; border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 10px; background: var(--panel); }
.alertcard.critical { border-left-color: var(--crit); background: linear-gradient(90deg, var(--crit-wash), var(--panel) 40%); }
.alertcard .t { font-weight: 650; font-size: 14.5px; }
.alertcard .d { color: var(--dim); font-size: 13px; }
.alertlist { display: grid; gap: 10px; }
.allclear { display: grid; justify-items: center; gap: 10px; padding: 40px 20px; color: var(--faint); text-align: center; }
.allclear .big { font: 400 22px var(--serif); color: var(--dim); }

/* ---- toasts ---- */

#toasts { position: fixed; z-index: 90; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; max-width: min(92vw, 360px); }
@media (max-width: 880px) { #toasts { bottom: calc(78px + env(safe-area-inset-bottom)); } }
.toast {
	background: var(--raised); border: 1px solid var(--line); border-radius: 10px;
	padding: 11px 14px; font-size: 13.5px; box-shadow: var(--shadow);
	animation: toastin .22s ease;
}
.toast.ok { border-color: rgba(70,200,150,.4); }
.toast.err { border-color: rgba(239,128,120,.5); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

.skeleton { border-radius: 10px; background: linear-gradient(100deg, var(--panel) 40%, var(--raised) 50%, var(--panel) 60%) 0 0/300% 100%; animation: shimmer 1.4s infinite linear; min-height: 90px; }
@keyframes shimmer { to { background-position: -300% 0; } }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

.errorbox { text-align: center; padding: 46px 18px; color: var(--dim); display: grid; gap: 12px; justify-items: center; }
.errorbox .big { font: 400 24px var(--serif); color: var(--ink); }
