/* ============================================================
   DIREÇÃO CERTA – Autoescola Virtual
   style.css – Cockpit Visual Realista
   ============================================================ */

/* ---------- Reset & Variáveis ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --dash-bg:        #1a1209;
  --dash-surface:   #231a0d;
  --dash-border:    #3a2a10;
  --dash-accent:    #c0392b;
  --dash-accent2:   #e67e22;
  --dash-green:     #27ae60;
  --dash-text:      #d4b483;
  --dash-dim:       #7a6040;
  --glass-bg:       rgba(30,60,100,0.18);
  --sky-top:        #87ceeb;
  --sky-bot:        #c8e6f5;
  --road-col:       #3a3a3a;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #111;
  user-select: none;
}

.hidden { display: none !important; }

/* ============================================================
   TELA DE INÍCIO
   ============================================================ */
#start-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0d1b2a 0%, #1a3a5c 50%, #0d1b2a 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 28px; z-index: 100;
}

.start-logo {
  text-align: center;
}
.logo-icon {
  font-size: 64px; margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(192,57,43,0.7));
  animation: floatLogo 3s ease-in-out infinite;
}
@keyframes floatLogo {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.start-logo h1 {
  font-size: 2.8rem; font-weight: 900; letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 30px rgba(192,57,43,0.9), 0 2px 4px rgba(0,0,0,0.8);
}
.tagline {
  color: var(--dash-text); font-size: 1rem; letter-spacing: 3px;
  margin-top: 4px; text-transform: uppercase;
}

.start-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px; padding: 28px 36px;
  max-width: 520px; width: 90%;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.start-card h2 {
  color: #fff; font-size: 1.3rem; margin-bottom: 10px;
}
.start-card p {
  color: #aaa; font-size: 0.9rem; line-height: 1.6; margin-bottom: 20px;
}

.controls-preview {
  display: flex; gap: 16px; flex-wrap: wrap;
  background: rgba(0,0,0,0.3); border-radius: 10px;
  padding: 14px; margin-bottom: 22px;
}
.ctrl-group {
  display: grid; grid-template-columns: auto 1fr;
  gap: 4px 10px; align-items: center; flex: 1; min-width: 180px;
}
.ctrl-label {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px; padding: 2px 7px;
  font-size: 0.75rem; font-family: monospace;
  color: var(--dash-accent2); white-space: nowrap;
  text-align: center;
}
.ctrl-group span:not(.ctrl-label) {
  color: #ccc; font-size: 0.8rem;
}

.btn-primary {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--dash-accent), #922b21);
  color: #fff; font-size: 1.1rem; font-weight: 700;
  border: none; border-radius: 10px; cursor: pointer;
  letter-spacing: 2px; text-transform: uppercase;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(192,57,43,0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(192,57,43,0.6);
}
.btn-primary:active { transform: translateY(0); }

/* ============================================================
   TELA DO JOGO
   ============================================================ */
#game-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--dash-bg);
}

/* ---------- Área do Para-brisa ---------- */
#windshield-area {
  flex: 1 1 0; position: relative; overflow: hidden;
  min-height: 0;
}

.windshield-frame {
  position: absolute; inset: 0;
  border-radius: 0 0 30% 30% / 0 0 12% 12%;
  overflow: hidden;
  background: var(--sky-top);
}

#road-canvas {
  width: 100%; height: 100%;
  display: block;
}

/* Pilares do para-brisa */
.windshield-pillar-left,
.windshield-pillar-right {
  position: absolute; top: 0; bottom: 0;
  width: 52px;
  background: linear-gradient(to right, #1a1209, #2a1f0e 60%, transparent);
  z-index: 5;
}
.windshield-pillar-left  { left: 0; }
.windshield-pillar-right {
  right: 0;
  background: linear-gradient(to left, #1a1209, #2a1f0e 60%, transparent);
}
.windshield-border-top {
  position: absolute; top: 0; left: 0; right: 0; height: 14px;
  background: #1a1209; z-index: 5;
}

/* Limpadores */
.wiper-left, .wiper-right {
  position: absolute; bottom: 0; width: 3px; height: 40%;
  background: #555; border-radius: 2px; transform-origin: bottom center;
  z-index: 6; opacity: 0.6;
}
.wiper-left  { left: 30%; transform: rotate(-30deg); }
.wiper-right { right: 30%; transform: rotate(30deg); }

/* HUD */
#hud {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 20px; z-index: 10;
  pointer-events: none;
}
.hud-item {
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 4px 14px;
  display: flex; flex-direction: column; align-items: center;
  backdrop-filter: blur(6px);
}
.hud-label { font-size: 0.6rem; color: #aaa; letter-spacing: 1px; }
.hud-value { font-size: 1.4rem; font-weight: 700; color: #fff; line-height: 1.2; }
#hud-infraction { background: transparent; border: none; }
#infraction-msg {
  color: #f39c12; font-weight: 700; font-size: 0.9rem;
  text-shadow: 0 0 8px rgba(243,156,18,0.8);
}

/* Notificação flutuante */
.notification {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.82); color: #fff;
  padding: 10px 22px; border-radius: 30px;
  font-size: 0.9rem; font-weight: 600; z-index: 200;
  border: 1px solid rgba(255,255,255,0.2);
  pointer-events: none; letter-spacing: 0.5px;
  transition: opacity 0.4s;
}
.notification.warn  { border-color: #f39c12; color: #f39c12; }
.notification.error { border-color: var(--dash-accent); color: #e74c3c; }
.notification.ok    { border-color: var(--dash-green); color: #2ecc71; }

/* ============================================================
   PAINEL INFERIOR (Dashboard)
   ============================================================ */
#dashboard {
  height: 260px;
  background: linear-gradient(to bottom, #1a1209, #110d06);
  border-top: 3px solid var(--dash-border);
  display: flex; align-items: stretch;
  position: relative; z-index: 10;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.dash-section {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 10px 8px; gap: 6px;
  border-right: 1px solid var(--dash-border);
}
.dash-section:last-child { border-right: none; }

.dash-left  { width: 200px; flex-shrink: 0; }
.dash-center { flex: 1; min-width: 0; }
.dash-right { width: 200px; flex-shrink: 0; }

.section-label {
  font-size: 0.62rem; letter-spacing: 2px; color: var(--dash-dim);
  text-transform: uppercase; font-weight: 600;
  border-bottom: 1px solid var(--dash-border);
  width: 100%; text-align: center; padding-bottom: 4px;
  margin-bottom: 2px;
}

/* ---------- Câmbio ---------- */
#gear-shifter {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 100%;
}
#gear-svg {
  width: 100px; height: 140px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px; border: 1px solid var(--dash-border);
  padding: 4px;
}
.gear-pos { cursor: pointer; transition: fill 0.2s; }
.gear-pos:hover { fill: #555; }
.gear-pos.active { fill: var(--dash-accent) !important; }
.gear-label.active { fill: #fff !important; font-weight: bold; }

.gear-buttons {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 3px; width: 100%;
}
.gbtn {
  padding: 4px 0; font-size: 0.72rem; font-weight: 700;
  background: #2a1f0e; color: var(--dash-text);
  border: 1px solid var(--dash-border); border-radius: 5px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  letter-spacing: 0.5px;
}
.gbtn:hover  { background: #3a2a10; }
.gbtn:active { background: var(--dash-accent); color: #fff; }
.gbtn.active { background: var(--dash-accent); color: #fff; }
.gbtn-r { background: #2a1209; color: #e74c3c; }
.gbtn-r:hover { background: #3d1a0e; }
.gbtn-n { background: #0d1a12; color: var(--dash-green); }
.gbtn-n:hover { background: #142610; }

/* ---------- Gauges (Tacômetro / Velocímetro) ---------- */
.gauges-row {
  display: flex; gap: 12px; align-items: center; justify-content: center;
}
.gauge-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#tach-canvas, #speed-canvas {
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(0,0,0,0.7), inset 0 0 20px rgba(0,0,0,0.5);
  background: #0d0d0d;
}
.gauge-label {
  font-size: 0.62rem; color: var(--dash-dim); letter-spacing: 1px;
}

/* ---------- Volante ---------- */
#steering-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 4px;
}
#steering-wheel {
  width: 120px; height: 120px; position: relative;
  cursor: grab; touch-action: none;
}
#steering-wheel:active { cursor: grabbing; }
#wheel-svg {
  width: 100%; height: 100%;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.7));
  transition: transform 0.05s ease-out;
}
#wheel-hint {
  font-size: 0.58rem; color: var(--dash-dim); letter-spacing: 0.5px;
}

/* ---------- Pedais ---------- */
#pedals-area {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 4px 4px 0;
}
.pedal-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.pedal-label {
  font-size: 0.6rem; color: var(--dash-dim); letter-spacing: 1px; font-weight: 600;
}
.pedal-track {
  width: 38px; height: 90px;
  background: rgba(0,0,0,0.4); border-radius: 8px;
  border: 1px solid var(--dash-border);
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end;
}
.pedal-fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 0%; transition: height 0.05s linear;
  background: #c0392b; opacity: 0.5; border-radius: 0 0 7px 7px;
}
.pedal {
  position: relative; z-index: 2;
  width: 100%; height: 40px;
  background: linear-gradient(to bottom, #3a3a3a, #222);
  border: 1px solid #555; border-radius: 6px 6px 0 0;
  color: #fff; font-size: 0.7rem; font-weight: 700;
  cursor: pointer; transition: background 0.1s;
  letter-spacing: 1px;
}
.pedal:active, .pedal.pressed {
  background: linear-gradient(to bottom, #555, #3a3a3a);
  transform: translateY(2px);
}
.pedal-key {
  font-size: 0.55rem; color: #555; font-family: monospace;
}

/* ---------- Status Panel ---------- */
#status-panel {
  background: rgba(0,0,0,0.3); border-radius: 8px;
  border: 1px solid var(--dash-border);
  padding: 8px 10px; width: 100%; margin-top: 4px;
}
.status-row {
  display: flex; justify-content: space-between;
  font-size: 0.72rem; color: var(--dash-dim);
  padding: 2px 0;
}
.st-val { font-weight: 700; font-family: monospace; }
.st-ok   { color: var(--dash-green); }
.st-warn { color: var(--dash-accent2); }
.st-err  { color: var(--dash-accent); }

/* ---------- Botão Menu ---------- */
#btn-menu {
  position: fixed; top: 10px; right: 14px;
  background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; font-size: 1.2rem; border-radius: 8px;
  width: 38px; height: 38px; cursor: pointer; z-index: 50;
  transition: background 0.2s;
}
#btn-menu:hover { background: rgba(192,57,43,0.5); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 680px) {
  #dashboard { height: auto; flex-wrap: wrap; }
  .dash-left  { width: 50%; order: 2; border-right: none; border-top: 1px solid var(--dash-border); }
  .dash-center { width: 100%; order: 1; }
  .dash-right { width: 50%; order: 3; border-top: 1px solid var(--dash-border); }
  .gauges-row { gap: 6px; }
  #tach-canvas, #speed-canvas { width: 120px; height: 120px; }
  #steering-wheel { width: 90px; height: 90px; }
  .start-card { padding: 20px; }
  .start-logo h1 { font-size: 2rem; }
}

@media (max-height: 600px) {
  #dashboard { height: 200px; }
  .gauge-wrap canvas { width: 110px; height: 110px; }
  #steering-wheel { width: 90px; height: 90px; }
  .pedal-track { height: 70px; }
}

/* ============================================================
   ANIMAÇÕES / EFEITOS
   ============================================================ */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-4px) rotate(-0.5deg); }
  40%      { transform: translateX(4px) rotate(0.5deg); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}
.shake { animation: shake 0.35s ease; }

@keyframes redFlash {
  0%,100% { background-color: transparent; }
  50%      { background-color: rgba(192,57,43,0.25); }
}
.red-flash { animation: redFlash 0.3s ease 2; }

/* Estilo extra: Reflexo no para-brisa */
.windshield-frame::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.06) 0%,
    transparent 40%,
    rgba(255,255,255,0.03) 80%,
    transparent 100%
  );
  pointer-events: none; z-index: 4;
}

/* Textura do painel */
#dashboard::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent, transparent 3px,
    rgba(0,0,0,0.15) 3px, rgba(0,0,0,0.15) 4px
  );
  pointer-events: none; opacity: 0.3;
}
