@import url("https://use.typekit.net/dwb1ved.css");

/* ================================================================
   Reset & custom properties
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	color-scheme: dark;
	--bg:          #08080e;
	--surface:     #0f0f18;
	--surface2:    #141420;
	--border:      #1c1c2e;
	--border2:     #252538;
	--accent:      #00c8ff;
	--accent-glow: rgba(0, 200, 255, 0.18);
	--green:       #00e676;
	--green-glow:  rgba(0, 230, 118, 0.15);
	--orange:      #ff9100;
	--red:         #ff3355;
	--text:        #dde2f2;
	--text-dim:    #5c6080;
	--text-mid:    #909ab8;
	--font-body:   "helvetica-neue-lt-pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
	--font-num:    "helvetica-neue-lt-pro-cond", "Helvetica Neue Condensed", "HelveticaNeue-CondensedBold", "Arial Narrow", sans-serif;
	--font-mono:   "Menlo", "SF Mono", "Consolas", monospace;
	--gap:         2px;
	--r:           8px;
	--r-sm:        4px;
	--r-panel:     2px;
	--dur:         150ms;
}

html { scroll-behavior: smooth; }

body {
	font-family: var(--font-body);
	background: var(--bg);
	color: var(--text);
	font-size: 13px;
	line-height: 1.5;
	min-height: 100vh;
}

/* ================================================================
   Shared panel + page column
   ================================================================ */
.page {
	max-width: 1280px;
	margin: 0 auto;
	padding: 20px 24px 40px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.panel {
	background: var(--surface);
	border-radius: var(--r-panel);
}

/* ================================================================
   Setup banner
   ================================================================ */
.banner {
	display: flex;
	flex-direction: column;
	gap: var(--gap);
}

.banner-top {
	display: flex;
	align-items: stretch;
	flex-wrap: wrap;
	gap: var(--gap);
}

.banner-title-panel {
	flex: 1 1 200px;
	display: flex;
	align-items: center;
	padding: 12px 18px;
}

.banner-title {
	font-size: 17px;
	font-weight: 700;
	color: var(--text);
	letter-spacing: -0.01em;
}

.status-panel {
	display: flex;
	align-items: center;
	padding: 6px 10px;
	flex-shrink: 0;
}

.banner-body {
	display: flex;
	flex-direction: column;
	gap: var(--gap);
}

.banner-fields {
	display: flex;
	flex-wrap: wrap;
	gap: var(--gap);
}

.setup-field-panel {
	flex: 1 1 240px;
	padding: 14px 18px;
}

/* Connection status pill */
.status-pill {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 14px;
	border-radius: 20px;
	background: rgba(255,255,255,0.04);
	border: 1px solid var(--border2);
	font-size: 12px;
	color: var(--text-mid);
	white-space: nowrap;
}

.status-pill.connected {
	background: var(--green-glow);
	border-color: var(--green);
	color: var(--green);
}

.status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--text-dim);
	transition: background 0.3s, box-shadow 0.3s;
}

.status-pill.connected .status-dot {
	background: var(--green);
	box-shadow: 0 0 8px var(--green);
	animation: blink 2.4s ease-in-out infinite;
}

@keyframes blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0.4; }
}

.listener-btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 14px;
	border-radius: var(--r-sm);
	font-size: 12px;
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
	font-family: var(--font-body);
	align-self: stretch;
}

.listener-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--text-dim);
	transition: background 0.3s, box-shadow 0.3s;
}

.listener-btn.on .listener-dot {
	background: var(--accent);
	box-shadow: 0 0 8px var(--accent);
}

/* Setup instruction path */
.setup-path-panel {
	padding: 10px 14px;
}

.setup-path {
	font-size: 12px;
	color: var(--text-mid);
	padding: 7px 12px;
	background: rgba(255,255,255,0.025);
	border-left: 3px solid var(--accent);
	border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.setup-path strong { color: var(--accent); font-weight: 600; }

/* IP + port display */
.setup-field {
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.field-label {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--text-dim);
}

.field-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.iface-select {
	background: var(--surface2);
	border: 1px solid var(--border2);
	border-radius: var(--r-sm);
	color: var(--text-mid);
	padding: 4px 8px;
	font-size: 12px;
	font-family: var(--font-body);
	cursor: pointer;
	outline: none;
}

.iface-select:focus { border-color: var(--accent); }

.mono-value {
	font-family: var(--font-num);
	font-size: 26px;
	font-weight: 700;
	color: var(--accent);
	letter-spacing: 0.01em;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

/* ================================================================
   Main layout
   ================================================================ */
main {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.card {
	display: flex;
	flex-direction: column;
	gap: var(--gap);
}

.card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 18px;
}

.card-title {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--text-dim);
}

.lap-badge {
	font-family: var(--font-num);
	font-size: 12px;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

/* Card identity area (left side of header) */
.card-identity {
	display: flex;
	flex-direction: column;
	gap: 5px;
	justify-content: center;
}

.card-identity-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--text);
	line-height: 1;
}

.card-identity-row {
	display: flex;
	align-items: center;
	gap: 7px;
}

/* Forza-style class + PI badge */
.car-badge {
	display: inline-flex;
	align-items: stretch;
	border-radius: 1.5px;
	overflow: hidden;
	border: 1.5px solid var(--badge-color, #888);
	flex-shrink: 0;
	line-height: 1;
}

.car-badge-class {
	background: var(--badge-color, #888);
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	font-family: var(--font-body);
	letter-spacing: -0.02em;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 18px;
}

.car-badge-pi {
	background: #000;
	color: #fff;
	font-size: 13px;
	font-family: var(--font-num);
	font-weight: 700;
	letter-spacing: 0.02em;
	font-variant-numeric: tabular-nums;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 18px;
}

.car-badge-meta {
	font-size: 11px;
	opacity: .6;
	font-family: var(--font-num);
	font-variant-numeric: tabular-nums;
}

/* ================================================================
   Live grid
   ================================================================ */
.live-grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--gap);
}

.live-cell {
	padding: 16px 18px;
}

/* Speed */
.speed-cell { flex: 0 0 130px; }

.big-num {
	font-family: var(--font-num);
	font-size: 52px;
	font-weight: 700;
	color: var(--accent);
	line-height: 1;
	margin-bottom: 2px;
	font-variant-numeric: tabular-nums;
}

.big-unit {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--text-dim);
}

.sub-num {
	font-family: var(--font-num);
	font-size: 12px;
	color: var(--text-dim);
	margin-top: 4px;
	font-variant-numeric: tabular-nums;
}

/* Gear */
.gear-cell {
	flex: 0 0 88px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.gear-num {
	font-family: var(--font-num);
	font-size: 62px;
	font-weight: 700;
	color: var(--text);
	line-height: 1;
	margin-bottom: 4px;
	font-variant-numeric: tabular-nums;
}

/* RPM + Inputs column */
.rpm-inputs-cell {
	flex: 1 1 200px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	justify-content: center;
}

.gauge-label {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--text-dim);
	margin-bottom: 2px;
}

.gauge-sub {
	font-family: var(--font-num);
	font-size: 11px;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

.spacer { height: 10px; }

/* Generic bar */
.bar-track {
	height: 10px;
	background: rgba(255,255,255,0.055);
	border-radius: 5px;
	overflow: hidden;
	position: relative;
}

.bar-fill {
	height: 100%;
	border-radius: 5px;
	transition: width var(--dur) linear;
	width: 0%;
}

/* RPM bar: gradient spans the full track width via background-size (set in JS).
   The fill element reveals a left-anchored slice of the gradient as RPM rises. */
.rpm-track { height: 12px; }

.rpm-fill {
	background: linear-gradient(90deg, var(--green) 0%, var(--accent) 75%, var(--orange) 90%, var(--red) 100%);
	background-repeat: no-repeat;
	background-position: left center;
	/* background-size width is set per-frame in JS to match the track's pixel width */
}

/* Input rows */
.input-row {
	display: flex;
	align-items: center;
	gap: 7px;
}

.inp-lbl {
	font-size: 9px;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--text-dim);
	width: 24px;
	flex-shrink: 0;
}

.inp-track { flex: 1; height: 7px; }

.thr-fill { background: var(--green); }
.brk-fill { background: var(--red); }

.inp-val {
	font-family: var(--font-num);
	font-size: 10px;
	color: var(--text-dim);
	width: 30px;
	text-align: right;
	flex-shrink: 0;
	font-variant-numeric: tabular-nums;
}

/* Steering bar (center-out) */
.steer-track {
	flex: 1;
	height: 7px;
	background: rgba(255,255,255,0.055);
	border-radius: 4px;
	position: relative;
	overflow: hidden;
}

.steer-center {
	position: absolute;
	left: 50%;
	top: 0;
	width: 2px;
	height: 100%;
	background: rgba(255,255,255,0.18);
	transform: translateX(-50%);
}

.steer-fill {
	position: absolute;
	top: 0;
	height: 100%;
	background: var(--accent);
	border-radius: 4px;
	transition: left var(--dur) linear, width var(--dur) linear;
}

/* Tire temps + Suspension */
.tires-cell { flex: 0 0 210px; }

.tire-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
	margin-top: 6px;
}

.tire-chip {
	background: rgba(255,255,255,0.03);
	border: 1px solid var(--border2);
	border-radius: var(--r-sm);
	padding: 8px 6px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	transition: border-color 0.3s, background 0.3s;
}

.tire-val {
	font-family: var(--font-num);
	font-size: 20px;
	font-weight: 700;
	color: var(--text);
	font-variant-numeric: tabular-nums;
}

.tire-pos {
	font-size: 9px;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--text-dim);
	letter-spacing: 0.05em;
}

/* Temperature colour states */
.t-cold    { border-color: #3d7eff; background: rgba(61,126,255,0.08); }
.t-cool    { border-color: #40c0ff; background: rgba(64,192,255,0.08); }
.t-opt     { border-color: var(--green); background: var(--green-glow); }
.t-warm    { border-color: var(--orange); background: rgba(255,145,0,0.08); }
.t-hot     { border-color: var(--red); background: rgba(255,51,85,0.08); }

.tire-slip {
	font-size: .7rem;
	opacity: .65;
	font-variant-numeric: tabular-nums;
	font-family: var(--font-num);
}

/* Engine tile */
.engine-cell {
	display: flex;
	flex-direction: column;
	gap: .35rem;
	flex: 0 0 150px;
}

.engine-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-size: 1rem;
	gap: 4px;
}

.eng-lbl {
	opacity: .6;
	font-size: .7rem;
	letter-spacing: .05em;
	text-transform: uppercase;
	flex: 0 0 38px;
}

.eng-val {
	font-family: var(--font-num);
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	flex: 1;
	text-align: right;
}

.eng-unit {
	opacity: .5;
	font-size: .7rem;
	flex: 0 0 28px;
	text-align: right;
}

/* G-Force tile */
.gforce-cell {
	display: flex;
	flex-direction: column;
	gap: .35rem;
	flex: 0 0 130px;
}

/* Suspension bar embedded inside each tire chip */
.tire-susp-track {
	width: 100%;
	height: 20px;
	background: rgba(255,255,255,0.055);
	border-radius: 3px;
	overflow: hidden;
	display: flex;
	align-items: flex-end;
	margin-top: 2px;
}

.susp-fill {
	width: 100%;
	background: var(--accent);
	border-radius: 3px;
	transition: height var(--dur) linear;
	height: 0%;
}

.susp-fill.warn { background: var(--orange); }
.susp-fill.crit { background: var(--red); }

/* ================================================================
   Capture controls
   ================================================================ */
.capture-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	align-items: stretch;
	gap: var(--gap);
}

.capture-pane {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
}

.capture-pane-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--text);
}

.capture-pane-desc {
	font-size: 12px;
	color: var(--text-dim);
	margin-top: -4px;
}

.capture-stat {
	font-family: var(--font-num);
	font-size: 12px;
	color: var(--text-mid);
	font-variant-numeric: tabular-nums;
}

.lap-counter {
	font-family: var(--font-num);
	font-size: 20px;
	font-weight: 700;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

.rec-pill {
	padding: 3px 12px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 700;
	font-family: var(--font-num);
	background: rgba(255,255,255,0.04);
	border: 1px solid var(--border2);
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

.rec-pill.recording {
	background: rgba(255,51,85,0.12);
	border-color: var(--red);
	color: var(--red);
}

/* ================================================================
   Buttons (FH6 white + double-border hover)
   ================================================================ */
.btn,
.copy-btn,
.listener-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	color: #000;
	border: 0;
	cursor: pointer;
	font-family: var(--font-body);
	font-weight: 600;
	box-shadow:
		0 0 0 0 #000,
		0 0 0 0 #d5fd51;
	transition: transform var(--dur) ease, box-shadow var(--dur) ease;
}

.btn {
	padding: 8px 18px;
	border-radius: var(--r-sm);
	font-size: 13px;
}

.copy-btn {
	padding: 5px 12px;
	border-radius: var(--r-sm);
	font-size: 11px;
}

.btn:hover,
.copy-btn:hover,
.listener-btn:hover {
	transform: scale(1.03);
	box-shadow:
		0 0 0 2px #000,
		0 0 0 4px #d5fd51;
}

.btn:active,
.copy-btn:active,
.listener-btn:active {
	transform: scale(0.99);
}

/* Variant classes — layout only; colors come from shared button rule */
.btn-start,
.btn-start.stop,
.btn-copy,
.btn-ghost {
	background: #fff;
	color: #000;
	border: 0;
}

/* ================================================================
   Summary output area
   ================================================================ */
.summary-wrap {
	padding: 18px 20px;
}

.summary-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
	gap: 12px;
	flex-wrap: wrap;
}

.tab-group {
	display: flex;
	gap: 3px;
	background: rgba(255,255,255,0.04);
	border-radius: var(--r-sm);
	padding: 3px;
}

.tab {
	padding: 5px 16px;
	border: none;
	border-radius: 3px;
	font-size: 12px;
	font-weight: 600;
	font-family: var(--font-body);
	cursor: pointer;
	background: transparent;
	color: var(--text-dim);
	transition: background var(--dur), color var(--dur);
}

.tab.active {
	background: var(--surface2);
	color: var(--text);
	box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.tab:disabled { opacity: 0.35; cursor: default; }

.summary-actions { display: flex; gap: 8px; }

.summary-pre {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--r-sm);
	padding: 16px;
	font-family: var(--font-mono);
	font-size: 12px;
	line-height: 1.65;
	color: var(--text);
	white-space: pre-wrap;
	word-break: break-word;
	max-height: 380px;
	overflow-y: auto;
}

/* ================================================================
   Rewind debug panel (DEBUG env only)
   ================================================================ */
.debug-hint {
	font-size: 10px;
	color: var(--text-dim);
	font-weight: 400;
	text-transform: none;
	letter-spacing: 0;
}

.debug-body {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.debug-state {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--text-mid);
	padding: 8px 10px;
	background: rgba(255, 255, 255, 0.03);
	border-radius: var(--r-sm);
	border: 1px solid var(--border);
}

.debug-log {
	max-height: 220px;
	overflow-y: auto;
	font-family: var(--mono);
	font-size: 11px;
	line-height: 1.45;
	border: 1px solid var(--border);
	border-radius: var(--r-sm);
	background: var(--bg);
}

.debug-row {
	display: grid;
	grid-template-columns: 4.5rem 7.5rem 1fr;
	gap: 8px;
	padding: 5px 8px;
	border-bottom: 1px solid var(--border);
}

.debug-row:last-child {
	border-bottom: none;
}

.debug-time {
	color: var(--text-dim);
}

.debug-kind {
	font-weight: 600;
}

.debug-row.kind-lapRollback .debug-kind,
.debug-row.kind-clockRollback .debug-kind {
	color: var(--red);
}

.debug-row.kind-bufferClear .debug-kind {
	color: var(--orange);
}

.debug-row.kind-gapStart .debug-kind,
.debug-row.kind-gapEnd .debug-kind {
	color: var(--accent);
}

.debug-row.kind-packetDropped .debug-kind {
	color: var(--text-dim);
}

.debug-detail {
	color: var(--text);
	word-break: break-word;
}

.debug-actions {
	display: flex;
	gap: 8px;
}

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 960px) {
	.live-grid { flex-direction: column; }
	.live-cell { flex: 1 1 auto !important; width: 100%; }
}

@media (max-width: 680px) {
	.page { padding: 14px 12px 32px; }
	.capture-row { grid-template-columns: 1fr; }
	.banner-top { flex-direction: column; align-items: stretch; }
	.listener-btn { align-self: auto; }
	.banner-fields { flex-direction: column; }
	.mono-value { font-size: 20px; }
}
