:root {
  --tesla-red: #4d93dd;
  --tesla-gold: #d6b56b;
  --tesla-silver: #d5dbe4;
  --tesla-blue-deep: #102542;
  --tesla-bg: #09111d;
  --tesla-panel: #111d2c;
}

html, body {
  background: var(--tesla-bg);
}

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(77, 147, 221, 0.22), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(214, 181, 107, 0.13), transparent 50%),
    linear-gradient(180deg, #102542 0%, #09111d 42%, #09111d 100%);
  min-height: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.38;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

.bg-tesla-red { background-color: var(--tesla-red); }
.text-tesla-red { color: var(--tesla-red); }
.hover\:bg-red-600:hover { background-color: #2d6fb4; }
.border-tesla-red\/50 { border-color: rgba(77, 147, 221, 0.5); }

/* Keep existing utility names compatible while applying the new palette. */
.border-red-500\/30 { border-color: rgba(214, 181, 107, 0.38) !important; }
.bg-red-500\/10 { background-color: rgba(214, 181, 107, 0.1) !important; }
.text-red-100 { color: #f6edda !important; }
.hover\:border-tesla-red\/60:hover { border-color: rgba(214, 181, 107, 0.68) !important; }

#sidebar {
  background: linear-gradient(180deg, #13233a 0%, #0b1522 100%);
  box-shadow: 18px 0 60px rgba(0, 0, 0, 0.18);
}

/* On home, the visual hero is the page heading; keep only the language control. */
#content > header.home-header {
  justify-content: flex-end;
  min-height: 0;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

#content > header.home-header .min-w-0 {
  display: none;
}

@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.45);
  }
  #sidebar.nav-open {
    transform: translateX(0);
  }
}

.menu-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  margin-bottom: 0.4rem;
  border-radius: 0.65rem;
  color: #d4d4d8;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.menu-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: translateX(3px);
}

.menu-button.active {
  background: linear-gradient(90deg, rgba(77, 147, 221, 0.2), rgba(214, 181, 107, 0.07));
  border-color: rgba(214, 181, 107, 0.48);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--tesla-red);
}

.menu-button i {
  width: 1.25rem;
  text-align: center;
  color: var(--tesla-red);
}

.field {
  width: 100%;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 0.7rem 0.9rem;
  outline: none;
}

.field:focus {
  border-color: rgba(77, 147, 221, 0.82);
  box-shadow: 0 0 0 3px rgba(77, 147, 221, 0.18);
}

.city-chip,
.resource-tab {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #d4d4d8;
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
}

.city-chip.active,
.resource-tab.active {
  background: rgba(77, 147, 221, 0.2);
  border-color: rgba(214, 181, 107, 0.6);
  color: #fff;
}

.northbound-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 1.25rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.northbound-btn:hover {
  border-color: rgba(214, 181, 107, 0.58);
  background: rgba(77, 147, 221, 0.1);
  transform: translateY(-2px);
}

.platform-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.24s ease, border-color 0.24s ease, background 0.24s ease, box-shadow 0.24s ease;
}

.platform-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: auto -20% -75% 35%;
  height: 130px;
  background: radial-gradient(ellipse, rgba(77, 147, 221, 0.3), transparent 70%);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.platform-card:hover {
  transform: translateY(-5px);
  background: rgba(117, 164, 215, 0.12);
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.26);
}

.platform-card:hover::before {
  opacity: 1;
}

.platform-btn {
  transition: transform 0.2s ease;
}

.platform-card:hover .platform-btn {
  transform: translateX(2px);
}

/* Homepage visual system */
.home-experience {
  max-width: 1260px;
  margin: 0;
  animation: content-enter 0.62s ease both;
}

.home-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: clamp(310px, 34vw, 420px);
  padding: clamp(1.45rem, 3.1vw, 3rem);
  display: flex;
  align-items: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.35rem;
  background: #10213a;
  box-shadow: 0 28px 65px rgba(0, 0, 0, 0.34);
}

.home-hero-image,
.home-hero-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.home-hero-image {
  z-index: -3;
  background:
    linear-gradient(90deg, rgba(7, 11, 16, 0.96) 0%, rgba(7, 11, 16, 0.73) 31%, rgba(7, 11, 16, 0.12) 71%, rgba(7, 11, 16, 0.28)),
    linear-gradient(0deg, rgba(6, 8, 12, 0.62), transparent 48%),
    url("../img/model-x-journey-hero.png") center/cover no-repeat;
  transform: scale(1.02);
  animation: hero-drift 18s ease-in-out infinite alternate;
}

.home-hero-scanlines {
  z-index: -2;
  opacity: 0.22;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.045) 4px);
  mix-blend-mode: overlay;
}

.home-hero-content {
  max-width: 620px;
}

.hero-eyebrow,
.home-panel-kicker {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 0.85rem;
  color: #e7e7e7;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.hero-pulse {
  display: inline-block;
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: var(--tesla-gold);
  box-shadow: 0 0 0 rgba(214, 181, 107, 0.75);
  animation: live-pulse 1.8s infinite;
}

.home-hero h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(2rem, 4.15vw, 3.85rem);
  font-weight: 700;
  line-height: 0.99;
  letter-spacing: -0.065em;
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.32);
}

.home-hero h2 span {
  color: var(--tesla-gold);
}

.home-hero p {
  max-width: 560px;
  margin: 1.25rem 0 0;
  color: #e3e5e8;
  font-size: clamp(0.96rem, 1.45vw, 1.12rem);
  line-height: 1.72;
  text-wrap: balance;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.hero-primary,
.hero-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.78rem 1rem;
  border-radius: 0.72rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.hero-primary {
  background: linear-gradient(135deg, #4d93dd, #2d6fb4);
  color: #fff;
  box-shadow: 0 10px 22px rgba(45, 111, 180, 0.31);
}

.hero-secondary {
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.26);
  color: #fff;
  backdrop-filter: blur(6px);
}

.hero-primary:hover,
.hero-secondary:hover {
  transform: translateY(-2px);
}

.hero-primary:hover {
  box-shadow: 0 15px 28px rgba(77, 147, 221, 0.46);
}

.hero-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.hero-status {
  position: absolute;
  right: 1.1rem;
  bottom: 1rem;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-status span {
  color: var(--tesla-gold);
  font-weight: 700;
}

.home-command-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0.85rem 0 2.2rem;
}

.home-command-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  text-align: left;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.home-command-card:hover {
  transform: translateY(-3px);
  border-color: rgba(77, 147, 221, 0.62);
  background: rgba(77, 147, 221, 0.11);
}

.home-command-card--lock {
  border-color: rgba(214, 181, 107, 0.5);
  background: linear-gradient(120deg, rgba(214, 181, 107, 0.17), rgba(77, 147, 221, 0.07));
}

.command-icon {
  display: grid;
  flex: 0 0 auto;
  width: 2.7rem;
  height: 2.7rem;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 0.78rem;
  color: var(--tesla-gold);
  background: rgba(0, 0, 0, 0.22);
}

.home-command-card strong,
.home-command-card small {
  display: block;
}

.home-command-card strong {
  font-size: 0.99rem;
}

.home-command-card small {
  margin-top: 0.12rem;
  color: #a7abb4;
  font-size: 0.74rem;
  line-height: 1.35;
}

.command-arrow {
  margin-left: auto;
  color: #777d88;
  font-size: 0.78rem;
}

.home-content-panel {
  position: relative;
  overflow: hidden;
  max-width: none;
  padding: clamp(1.25rem, 3vw, 2.2rem);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.35rem;
  background:
    linear-gradient(115deg, rgba(16, 37, 66, 0.96), rgba(11, 21, 34, 0.9)),
    linear-gradient(135deg, rgba(77, 147, 221, 0.1), rgba(214, 181, 107, 0.05));
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.24);
}

.home-content-panel::after {
  content: "";
  position: absolute;
  top: -85px;
  right: -95px;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(214, 181, 107, 0.32);
  border-radius: 50%;
  box-shadow: 0 0 0 32px rgba(77, 147, 221, 0.06), 0 0 0 64px rgba(214, 181, 107, 0.025);
  pointer-events: none;
}

@keyframes hero-drift {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to { transform: scale(1.08) translate3d(-1.3%, -0.8%, 0); }
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(214, 181, 107, 0.72); }
  70% { box-shadow: 0 0 0 8px rgba(214, 181, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(214, 181, 107, 0); }
}

@keyframes content-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#platform-iframe-container {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0b0d10;
  display: flex;
  flex-direction: column;
}

#platform-iframe-container.hidden {
  display: none;
}

#platform-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.platform-iframe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #14181f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

#notification {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 70;
  background: rgba(20, 24, 31, 0.95);
  border: 1px solid rgba(214, 181, 107, 0.55);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s;
  max-width: min(92vw, 420px);
  text-align: center;
}

/* Charging stations: 3 per row desktop, 2 tablet, 1 mobile (match old layout) */
.tesla-stations-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

@media (max-width: 1024px) {
  .tesla-stations-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .tesla-stations-grid {
    grid-template-columns: 1fr;
  }
}

.tesla-station-card {
  min-width: 0;
  word-break: break-word;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.tesla-station-card:hover {
  transform: translateY(-3px);
  border-color: rgba(214, 181, 107, 0.58);
  background: rgba(77, 147, 221, 0.1);
}

#back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #d6b56b, #a9843e);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  box-shadow: 0 8px 20px rgba(214, 181, 107, 0.35);
}

@media (max-width: 860px) {
  .home-command-grid {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: 370px;
  }

  .home-hero-image {
    background:
      linear-gradient(0deg, rgba(7, 11, 16, 0.9) 0%, rgba(7, 11, 16, 0.36) 72%),
      url("../img/model-x-journey-hero.png") 62% center/cover no-repeat;
  }
}

@media (max-width: 560px) {
  .home-hero {
    min-height: 390px;
    padding: 1.35rem;
    border-radius: 1.05rem;
  }

  .home-hero h2 {
    font-size: clamp(2.25rem, 12vw, 3.3rem);
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-primary,
  .hero-secondary {
    justify-content: center;
  }

  .hero-status {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
