/* ============================================================
   CORSA 812 V12 — Interactive 3D Italian Supercar Studio
   ============================================================ */

:root {
  --bg: #050507;
  --panel: rgba(11, 11, 14, 0.8);
  --border: rgba(255, 255, 255, 0.11);
  --border-hi: rgba(255, 255, 255, 0.24);
  --text: #f4f2ee;
  --muted: rgba(244, 242, 238, 0.56);
  --rosso: #d9142b;
  --gold: #eab308;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#hero-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  cursor: grab;
}

#hero-canvas:active {
  cursor: grabbing;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 48%, rgba(4, 4, 6, 0.72) 100%);
  transition: opacity 0.4s ease;
}

body.light-studio .vignette {
  opacity: 0.14;
}

body.light-studio .bottom-hint {
  color: rgba(20, 20, 26, 0.62);
}

body.light-studio .bottom-hint strong {
  color: #111116;
}

/* ============================================================
   LEFT ENGINEERING INSPECTOR PANEL
   ============================================================ */
.inspector-panel {
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  width: 268px;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(22px);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.crest-badge {
  width: 34px;
  height: 38px;
  border-radius: 6px 6px 16px 16px;
  background: linear-gradient(160deg, #facc15 0%, #ca8a04 100%);
  color: #111;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.1;
}

.brand-title em {
  font-style: italic;
  color: var(--rosso);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 2px;
}

.panel-group {
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.panel-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.group-label {
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  color: var(--muted);
  font-weight: 600;
}

.btn-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.ui-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.48rem 0.45rem;
  font-size: 0.67rem;
  letter-spacing: 0.04em;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.ui-btn:hover {
  border-color: var(--border-hi);
  background: rgba(255, 255, 255, 0.09);
}

.ui-btn.active {
  background: rgba(217, 20, 43, 0.24);
  border-color: var(--rosso);
  color: #fff;
  box-shadow: 0 0 14px rgba(217, 20, 43, 0.3);
}

.ui-btn.accent {
  background: linear-gradient(135deg, #d9142b 0%, #991b1b 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}

.ui-btn.accent:hover {
  filter: brightness(1.12);
}

.ui-btn.accent.revving {
  background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.55);
}

.slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.slider-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.slider-meta strong {
  color: var(--gold);
}

.slider-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rosso);
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(217, 20, 43, 0.7);
}

.swatch-row {
  display: flex;
  gap: 0.55rem;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.swatch:hover,
.swatch.active {
  border-color: #fff;
  transform: scale(1.14);
  box-shadow: 0 0 12px var(--c);
}

/* ============================================================
   RIGHT TACHOMETER TELEMETRY CARD
   ============================================================ */
.tach-card {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 215px;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(22px);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.tach-ring {
  position: relative;
  width: 126px;
  height: 126px;
}

.tach-svg {
  width: 100%;
  height: 100%;
  transform: rotate(135deg);
}

.tach-track,
.tach-arc {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}

.tach-track {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-dasharray: 273 365;
}

.tach-arc {
  stroke: var(--rosso);
  stroke-dasharray: 40 365;
  filter: drop-shadow(0 0 6px rgba(217, 20, 43, 0.7));
  transition: stroke-dasharray 0.08s linear, stroke 0.2s ease;
}

.tach-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tach-rpm {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
}

.tach-unit {
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.spec-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  text-align: center;
  padding: 0.55rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.spec-grid span {
  display: block;
  font-size: 0.5rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.spec-grid strong {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: #fff;
}

.firing-order {
  width: 100%;
  text-align: center;
}

.firing-order > span {
  display: block;
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.cyl-dots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.cyl-dots i {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.56rem;
  padding: 3px 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  transition: background 0.06s ease, color 0.06s ease;
}

.cyl-dots i.fire {
  background: var(--rosso);
  color: #fff;
  box-shadow: 0 0 8px var(--rosso);
}

/* ============================================================
   EXPLODED LEGEND & BOTTOM HINT
   ============================================================ */
.explode-legend {
  position: fixed;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  z-index: 18;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
  background: var(--panel);
  border: 1px solid rgba(217, 20, 43, 0.35);
  backdrop-filter: blur(18px);
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  white-space: nowrap;
}

.explode-legend.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.explode-legend strong {
  font-family: var(--mono);
  color: var(--gold);
  margin-right: 0.25rem;
}

.bottom-hint {
  position: fixed;
  bottom: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(11, 11, 14, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  padding: 0.36rem 0.95rem;
  border-radius: 999px;
}

.bottom-hint a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(234, 179, 8, 0.45);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.bottom-hint a:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.bottom-hint strong {
  color: inherit;
  font-weight: 600;
}

/* ============================================================
   MACHINED-ALUMINUM RACING ACCELERATOR FOOT PEDAL (BOTTOM-RIGHT)
   ============================================================ */
.pedal-rig {
  position: fixed;
  bottom: 1.35rem;
  right: 1.4rem;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  background: rgba(11, 11, 15, 0.72);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  border-radius: 18px;
  padding: 0.75rem 0.95rem 0.65rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.pedal-label {
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  color: var(--gold);
  font-weight: 600;
}

.pedal-stage {
  perspective: 360px;
  padding: 4px 10px 6px;
}

.gas-pedal {
  position: relative;
  width: 68px;
  height: 124px;
  background: transparent;
  border: none;
  cursor: pointer;
  transform-style: preserve-3d;
  transform-origin: 50% 88%;
  transform: rotateX(10deg);
  transition: transform 0.09s cubic-bezier(0.22, 1, 0.36, 1), filter 0.12s ease;
  outline: none;
}

.gas-pedal:hover {
  filter: brightness(1.08);
}

.gas-pedal.pressed {
  transform: rotateX(34deg) translateY(5px) scale(0.97);
}

.pedal-arm {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 22px;
  border-radius: 3px;
  background: linear-gradient(90deg, #3f4450 0%, #9ca3af 48%, #2d313a 100%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.45);
}

.pedal-plate {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 12px 10px 10px;
  border-radius: 10px 10px 16px 16px;
  /* Brushed CNC billet aluminum metallic finish */
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px,
      transparent 3px
    ),
    linear-gradient(155deg, #e5e8ef 0%, #9da4b2 32%, #d8dde6 52%, #6d7482 82%, #adb4c2 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.8),
    inset 0 -4px 8px rgba(0, 0, 0, 0.45),
    0 12px 22px rgba(0, 0, 0, 0.72),
    0 2px 0 #444954,
    0 4px 0 #262930;
  transition: box-shadow 0.1s ease;
}

.gas-pedal.pressed .pedal-plate {
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.7),
    inset 0 -3px 6px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(217, 20, 43, 0.65),
    0 0 22px rgba(249, 115, 22, 0.45);
}

.pedal-screw {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f3f4f6, #4b5563);
  border: 1px solid rgba(0, 0, 0, 0.55);
}

.pedal-screw.tl { top: 6px; left: 6px; }
.pedal-screw.tr { top: 6px; right: 6px; }
.pedal-screw.bl { bottom: 7px; left: 8px; }
.pedal-screw.br { bottom: 7px; right: 8px; }

.pedal-grips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 78%;
  margin-top: 8px;
}

.pedal-grips i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #111216 0%, #272a33 100%);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.9),
    0 1px 0 rgba(255, 255, 255, 0.55);
}

.pedal-stamp {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(18, 20, 26, 0.75);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  margin-bottom: 2px;
}

.pedal-sub {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

@media (max-width: 1000px) {
  .tach-card,
  .explode-legend {
    display: none;
  }
}

/* ============================================================
   COMPACT LAYOUT (phones + the blog embed)
   The inspector panel covered most of the car on small screens,
   so it tucks behind a Controls button and the pedal shrinks.
   ============================================================ */
.panel-toggle {
  display: none;
}

@media (max-width: 900px), (max-height: 620px) {
  .panel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 30;
    background: var(--panel);
    border: 1px solid var(--border);
    backdrop-filter: blur(18px);
    color: var(--text);
    font: 600 0.68rem/1 var(--sans);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 0.62rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
  .panel-toggle-icon {
    width: 12px;
    height: 9px;
    border-top: 2px solid var(--rosso);
    border-bottom: 2px solid var(--rosso);
    position: relative;
  }
  .panel-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: var(--rosso);
  }
  .inspector-panel {
    top: 3.5rem;
    left: 0.75rem;
    width: min(268px, calc(100vw - 1.5rem));
    max-height: calc(100vh - 4.5rem);
    transform: translateX(calc(-100% - 1.5rem));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s ease, opacity 0.32s ease;
  }
  body.panel-open .inspector-panel {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
  .pedal-rig {
    bottom: 3.4rem;
    right: 0.75rem;
    padding: 0.5rem 0.6rem 0.5rem;
    gap: 0.3rem;
    border-radius: 14px;
  }
  .pedal-stage {
    padding: 2px 6px 4px;
  }
  .gas-pedal {
    width: 44px;
    height: 80px;
  }
  .pedal-plate {
    padding: 9px 7px 7px;
  }
  .pedal-grips {
    gap: 5px;
    margin-top: 4px;
  }
  .pedal-grips i {
    height: 5px;
  }
  .pedal-label {
    font-size: 0.5rem;
  }
  .pedal-sub {
    display: none;
  }
  .bottom-hint {
    width: calc(100vw - 1.5rem);
    white-space: normal;
    text-align: center;
    font-size: 0.56rem;
    line-height: 1.55;
    bottom: 0.6rem;
    border-radius: 12px;
  }
}
