/* ============================================================
   THE DRIVER TESTER — Setup + Simulator styling
   Palette: asphalt, road-line yellow, safety green / caution red
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root{
	--asphalt:      #2B2F33;
	--asphalt-dark: #1E2124;
	--road-yellow:  #F2C94C;
	--road-yellow-dark: #C79E2E;
	--safety-green: #2ECC71;
	--caution-red:  #E74C3C;
	--cream:        #F6F3EC;
	--ink:          #1F2A33;
	--ink-dim:      #5B6B76;
	--white:        #FFFFFF;
}

* {
	margin: 0; padding: 0; text-decoration: none; border: none; outline: none;
	font-size: 100%; -webkit-text-size-adjust: 100%; box-sizing: border-box;
	line-height: 1.4em;
}
body { font-family: 'Inter', "Helvetica Neue", Helvetica, Arial, sans-serif; color: var(--ink); }
body, html { height: 100%; background: var(--asphalt); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-weight: 600; font-family: 'Oswald', "Helvetica Neue", sans-serif; }

#wrapper { min-height: 100%; display: flex; justify-content: center; }
#content { width: 100%; max-width: 720px; padding: 32px 20px 60px; }

header#hero { text-align: center; margin-bottom: 24px; }
header#hero h1 {
	color: var(--road-yellow);
	font-size: 34px;
	letter-spacing: 0.5px;
}
header#hero p#hero-tag {
	color: var(--cream);
	opacity: 0.75;
	margin-top: 6px;
	font-size: 14.5px;
}

.settings-group {
	background: var(--asphalt-dark);
	border: 1px solid rgba(255,255,255,0.08);
	border-radius: 10px;
	padding: 20px 22px;
	margin-bottom: 18px;
}
.settings-group legend {
	color: var(--road-yellow);
	font-family: 'Oswald', sans-serif;
	font-size: 15px;
	margin-bottom: 4px;
	display: flex;
	align-items: center;
	gap: 8px;
}
.group-index {
	background: var(--road-yellow);
	color: var(--asphalt-dark);
	font-size: 11px;
	font-weight: 700;
	border-radius: 4px;
	padding: 2px 6px;
}
.group-hint { color: var(--ink-dim); color: #9AA6AC; font-size: 12.5px; margin-bottom: 14px; }

.field { margin-bottom: 10px; }
.field label {
	display: block;
	color: var(--cream);
	font-size: 12.5px;
	font-weight: 600;
	margin-bottom: 6px;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}
.field select {
	width: 100%;
	background: var(--asphalt);
	color: var(--cream);
	border: 1px solid rgba(255,255,255,0.15);
	border-radius: 6px;
	padding: 10px 12px;
	font-size: 14.5px;
	font-family: 'Inter', sans-serif;
	cursor: pointer;
}
.field select:disabled { opacity: 0.4; cursor: not-allowed; }

.scenario-card {
	display: block;
	border: 2px solid rgba(255,255,255,0.1);
	border-radius: 8px;
	padding: 12px 14px;
	margin-bottom: 8px;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}
.scenario-card input { display: none; }
.scenario-card .scenario-title { color: var(--cream); font-weight: 600; font-size: 14.5px; }
.scenario-card .scenario-sub { color: #8B979D; font-size: 12px; margin-top: 2px; }
.scenario-card.selected { border-color: var(--road-yellow); background: rgba(242,201,76,0.08); }
.scenario-card.disabled { opacity: 0.45; cursor: not-allowed; }

#cta-row { margin-top: 22px; text-align: center; }
#run-btn {
	background: var(--road-yellow);
	color: var(--asphalt-dark);
	font-family: 'Oswald', sans-serif;
	font-weight: 700;
	font-size: 16px;
	letter-spacing: 0.4px;
	border-radius: 8px;
	padding: 14px 30px;
	cursor: pointer;
	transition: transform 0.1s ease;
}
#run-btn:hover { transform: translateY(-1px); }
#run-btn:disabled { background: #555; color: #999; cursor: not-allowed; transform: none; }

/* ---------------- FOOTER LINK CARDS ----------------
   Ported from The Boat Docker / The Trailer Parker's own welcome page. */
#footer-links {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 16px;
	margin-top: 20px;
}
.footer-card {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 18px 20px;
	background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
	border: 1px solid rgba(242,201,76,.35);
	border-radius: 10px;
	color: var(--white);
	transition: transform .15s, border-color .15s, background .15s;
}
.footer-card:hover {
	transform: translateY(-2px);
	border-color: var(--road-yellow);
	background: linear-gradient(180deg, rgba(255,255,255,.13), rgba(255,255,255,.05));
}
.footer-card-icon {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	color: var(--road-yellow);
}
.footer-card-icon svg { width: 100%; height: 100%; }
.footer-card-body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.footer-card-title {
	font-family: 'Oswald', sans-serif;
	font-size: 14px;
	letter-spacing: .02em;
	color: var(--white);
}
.footer-card-sub {
	font-size: 12.5px;
	color: rgba(255,255,255,.65);
}
.footer-card-arrow {
	flex: 0 0 auto;
	font-size: 18px;
	color: var(--road-yellow);
	transition: transform .15s;
}
.footer-card:hover .footer-card-arrow {
	transform: translateX(3px);
}

/* ---------------- GOOGLE ADSENSE UNIT ----------------
   Below the Start Test button. data-full-width-responsive fills the
   card's own width and picks its own height, so no fixed height is set
   here -- min-height just reserves space before the ad script fills the
   slot in. Ported from The Boat Docker / The Trailer Parker's own
   welcome.html/style.css. */
.google-ad-unit {
	/* AdSense's own sizing script needs an *explicit* width on this
	   container to calculate the ad's size against -- max-width alone
	   isn't enough for it and data-full-width-responsive="true" then
	   falls back to the full page width instead of staying inside this
	   box. width + max-width:100% keeps it narrow AND still responsive
	   on viewports under 322px. */
	width: 322px;
	max-width: 100%;
	margin: 20px auto 0;
	text-align: center;
}
.google-ad-unit .adsbygoogle {
	min-height: 250px;
}
.ad-label {
	font-family: 'Oswald', sans-serif;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: rgba(255,255,255,.5);
	margin: 8px 0;
}

/* ---------------- CONFIG ROW / FLANKING SIDE ADS ----------------
   #config-row wraps #form-holder together with the three sibling-app
   ads (Boat Docker + Trailer Parker on the left, Drag Car Racer on the
   right). Hidden below the wide-screen breakpoint -- there's no
   narrow-screen fallback banner, the ads just don't show on small
   viewports. Only on wide viewports (see the 1200px breakpoint below)
   does #content widen and the side ads appear. Ported from The Boat
   Docker / The Trailer Parker's own welcome.html/style.css. */
#config-row {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	gap: 24px;
}
#config-row #form-holder { flex: 1 1 720px; max-width: 720px; min-width: 0; }

.ad-side { display: none; }
.ad-side img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 10px;
	box-shadow: 0 6px 0 rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.08);
	transition: transform .12s, box-shadow .12s;
}
.ad-side a:hover img {
	transform: translateY(-2px);
	box-shadow: 0 8px 0 rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.08);
}

@media screen and (max-width: 720px) {
	#footer-links { grid-template-columns: 1fr; }
}

@media screen and (min-width: 1200px) {
	#content { max-width: 1200px; }
	header#hero, #footer-links, #cta-row { max-width: 720px; margin-left: auto; margin-right: auto; }

	.ad-side { display: flex; flex-direction: column; gap: 16px; flex: 1 1 200px; max-width: 240px; min-width: 0; align-self: stretch; }
}

/* ---------------- Simulator page ---------------- */

body.sim-body { background: var(--asphalt-dark); overflow: hidden; }
#sim-wrapper { position: relative; width: 100%; height: 100vh; display: flex; flex-direction: column; }

#sim-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 18px;
	background: var(--asphalt);
	border-bottom: 2px solid var(--road-yellow-dark);
	flex-shrink: 0;
	flex-wrap: wrap;
	gap: 10px;
}
#sim-topbar .title { color: var(--road-yellow); font-family: 'Oswald', sans-serif; font-size: 16px; }
#sim-topbar .title .sub { color: var(--cream); opacity: 0.7; font-size: 12px; font-weight: 400; font-family: 'Inter', sans-serif; margin-left: 8px; }

#hud-stats { display: flex; gap: 16px; align-items: center; }
.hud-chip {
	background: var(--asphalt-dark);
	border-radius: 6px;
	padding: 6px 12px;
	color: var(--cream);
	font-size: 13px;
	font-weight: 600;
	min-width: 74px;
	text-align: center;
}
.hud-chip .hud-label { display: block; font-size: 9.5px; color: #8B979D; text-transform: uppercase; font-weight: 700; letter-spacing: 0.4px; }
.hud-chip.timer-warn { color: var(--caution-red); }
.hud-chip.score-chip { color: var(--road-yellow); }

/* Practice Mode (Timer & Scoring off, chosen at Setup) -- #sim-wrapper gets
   this class from each scenario's own startAttempt(). Swaps the Time/Score
   chips for a single "Mode: Practice" chip; #practice-mode-chip is hidden
   by default (below) since a normal timed/scored session never needs it.
   Ported from The Boat Docker / The Trailer Parker. */
#practice-mode-chip { display: none; color: var(--road-yellow); }
#sim-wrapper.practice-mode #hud-time-chip,
#sim-wrapper.practice-mode .score-chip { display: none; }
#sim-wrapper.practice-mode #practice-mode-chip { display: block; }

#sim-main { flex: 1; display: flex; overflow: hidden; }
#sim-canvas-holder { flex: 1; display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, #24272A, #24272A 12px, #202225 12px, #202225 24px); overflow: auto; padding: 10px; }
#canvas-stack { display: flex; flex-direction: column; box-shadow: 0 0 0 2px rgba(255,255,255,0.06); border-radius: 4px; overflow: hidden; }
canvas#simCanvas { background: var(--asphalt); display: block; }
canvas#dashCanvas { background: var(--asphalt-dark); display: block; border-top: 2px solid var(--road-yellow-dark); cursor: default; }

#sim-sidebar {
	width: 260px;
	background: var(--asphalt);
	border-left: 1px solid rgba(255,255,255,0.08);
	padding: 16px;
	overflow: hidden;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
}
#sim-sidebar h3 { color: var(--road-yellow); font-size: 13px; margin-bottom: 10px; letter-spacing: 0.4px; flex-shrink: 0; }
/* flex: 1 1 auto + min-height: 0 makes this list -- not the sidebar as a
   whole -- the thing that scrolls, so a long log never grows past the
   reserved #controls-diagram-space band below it; it just scrolls its own
   content internally instead. */
#fault-log { list-style: none; font-size: 12.5px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#fault-log li { padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.06); color: var(--cream); display: flex; justify-content: space-between; }
#fault-log li .pts.fault { color: var(--caution-red); font-weight: 700; }
#fault-log li .pts.bonus { color: var(--safety-green); font-weight: 700; }
#fault-log .empty { color: #6E7A80; font-style: italic; }

/* Reserved space + divider bar for the controls-diagram overlay, which is
   position:fixed (so it can render at its own full size regardless of the
   sidebar's width -- see the comment on #controls-diagram below) and would
   otherwise just float in front of whatever the sidebar's last element
   happens to be. This sits as the sidebar's last flex child so #fault-log's
   own flex-basis shrinks to make room above it instead of running underneath
   it. Height matches #controls-diagram's height so the bar sits right at the
   diagram's top edge. Hidden by default; toggled alongside the diagram's own
   visibility in positionControlsDiagram() in dashboard.js. */
#controls-diagram-space {
	display: none;
	flex: 0 0 260px;
	margin-top: 10px;
	border-top: 1px solid rgba(199,158,46,0.4);
}
#controls-diagram-space.visible { display: block; }

.sim-action-btn {
	width: 100%;
	padding: 12px 0;
	border-radius: 7px;
	font-family: 'Oswald', sans-serif;
	font-weight: 700;
	font-size: 14px;
	cursor: pointer;
	margin-bottom: 8px;
}
#finish-btn { background: var(--safety-green); color: #103319; }
#reset-btn { background: var(--asphalt-dark); color: var(--cream); border: 1px solid rgba(255,255,255,0.15); }

/* Turns in Traffic: #finish-btn is one button doing three jobs -- "Start
   this Turn" (starts the five-minute clock) before state.sessionStarted,
   then "Pause this Turn" / "Continue this Turn" (freezes/resumes the whole
   session) after -- its label and this class are kept in sync with that
   live in updateHUD() in turns-in-traffic.js. Turn scoring itself is
   fully automatic now (see checkTurnCompletion() there) and isn't routed
   through this button at all. The class is on any time a click would do
   something, which is the whole time the session isn't over -- the pulsing
   glow makes that state easy to spot without being so different from the
   button's resting state that it reads as a new/separate control. */
@keyframes finish-btn-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0.65); }
	50% { box-shadow: 0 0 0 9px rgba(46,204,113,0); }
}
#finish-btn.ready-pulse { animation: finish-btn-pulse 1.3s ease-out infinite; }

#result-overlay {
	position: fixed; inset: 0;
	background: rgba(10,12,14,0.88);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 50;
}
#result-card {
	background: var(--asphalt);
	border-radius: 14px;
	padding: 32px 36px;
	width: 380px;
	text-align: center;
	border: 2px solid var(--road-yellow-dark);
}
#result-card.pass { border-color: var(--safety-green); }
#result-card.fail { border-color: var(--caution-red); }
#result-card h2 { font-size: 26px; margin-bottom: 4px; }
#result-card.pass h2 { color: var(--safety-green); }
#result-card.fail h2 { color: var(--caution-red); }
#result-score { color: var(--cream); font-size: 15px; margin-bottom: 14px; }
#result-breakdown { text-align: left; font-size: 12.5px; max-height: 220px; overflow-y: auto; margin-bottom: 18px; }
#result-breakdown div { display: flex; justify-content: space-between; padding: 4px 0; color: var(--cream); border-bottom: 1px solid rgba(255,255,255,0.06); }
#result-actions { display: flex; gap: 8px; }
#result-actions button { flex: 1; }

/* All four scenarios: each sidebar's old #control-hint block (the full set
   of instructions) got long enough that it pushed the action buttons below
   the fold, so all four moved it into this on-demand modal instead --
   opened by the sidebar's Instructions button, closed by its own dismiss
   button. See openInstructions()/closeInstructions() in session-ui.js
   (shared by all four scenario files) for how opening it pauses a running
   session and closing it resumes only if opening it is what paused things.
   Same overlay/card pattern as #result-overlay above, just scrollable
   (instructions run longer than a result breakdown) and stacked one
   z-index above it, though the two are never open at the same time in
   practice. */
#instructions-overlay {
	position: fixed; inset: 0;
	background: rgba(10,12,14,0.88);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 60;
}
#instructions-card {
	background: var(--asphalt);
	border-radius: 14px;
	padding: 28px 32px;
	width: 460px;
	max-width: 90vw;
	max-height: 82vh;
	overflow-y: auto;
	border: 2px solid var(--road-yellow-dark);
}
#instructions-card h2 { color: var(--road-yellow); font-size: 20px; margin-bottom: 14px; }
#instructions-body { font-size: 12.5px; color: #C7CDD1; line-height: 1.7em; text-align: left; margin-bottom: 22px; }
#instructions-body b { color: var(--cream); }

/* ---------------- Controller diagram overlay ---------------- */
/* Hidden by default; dashboard.js's positionControlsDiagram() just toggles
   visibility (only when GamePad mode is on) -- anchored to a fixed viewport
   corner, docked visually into the #controls-diagram-space band reserved at
   the bottom of #sim-sidebar, rather than floating in front of the dashboard
   canvas the way an earlier version of this file docked it next to the Time
   Remaining panel.

   `right` is set to center the diagram on the 260px-wide #sim-sidebar
   column, not to flush it against the viewport edge. At height:260px this
   image's own 680:560 intrinsic ratio renders it at ~315.7px wide -- wider
   than the sidebar itself -- so it can never be fully contained AND
   centered at the same time; centering the two midpoints is the closest
   fit, and it leaves a small, symmetric ~27.9px overlap into the canvas on
   the left with the same amount clipped off the right past the true
   viewport edge (.sim-body has overflow:hidden). Centering math: sidebar
   spans the outer 260px of the viewport, so its midpoint sits 130px in
   from the right edge; half the diagram's own rendered width is ~157.9px;
   130 - 157.9 = -27.9, i.e. the diagram's right edge sits ~27.9px *past*
   the viewport's right edge.

   `bottom` matches #sim-sidebar's own 16px padding, so the diagram's
   bottom edge lines up with the bottom of the reserved
   #controls-diagram-space band beneath it -- both are measured from the
   same viewport-bottom origin, so this works regardless of the diagram's
   own height. */
#controls-diagram {
	position: fixed;
	right: -28px;
	bottom: 16px;
	height: 260px;
	z-index: 60;
	visibility: hidden;
	pointer-events: none;
	filter: drop-shadow(0 6px 18px rgba(0,0,0,0.45));
}
