/* ============================================================
   Visual Reality — Future City Simulator styles
   ============================================================ */

/* ---------- Page hero ---------- */
.city-hero {
  padding: clamp(2.8rem, 5vw, 4rem) 0 1.4rem;
}

.city-lead {
  max-width: 46rem;
  font-size: 1.08rem;
  color: var(--ink-soft);
}

.howto {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.howto li {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 1rem 0.5rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}

.howto-ico {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  background: var(--mint);
  color: var(--brand-deep);
}

/* ---------- Simulator shell ---------- */
.simulator {
  padding: 1.6rem 0 clamp(3rem, 6vw, 5rem);
}

.sim-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.92fr);
  gap: 1.4rem;
  align-items: start;
}

.sim-controls-col {
  display: grid;
  gap: 1.1rem;
}

/* ---------- Scene ---------- */
.scene-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: #dff1e7;
}

.scene {
  display: block;
  width: 100%;
  height: auto;
}

.bld {
  cursor: pointer;
}

.bld .hit {
  fill: transparent;
  pointer-events: all;
}

.bld:hover {
  filter: brightness(1.07);
}

.bld:focus {
  outline: none;
}

.bld:focus-visible,
.bld.selected {
  filter: drop-shadow(0 0 5px rgba(14, 159, 110, 0.95))
    drop-shadow(0 0 16px rgba(14, 159, 110, 0.55));
}

/* --- sky phases --- */
#skyGrad stop {
  transition: stop-color 1.1s ease;
}

.phase-day #skyGrad stop:nth-child(1) { stop-color: #79c2f5; }
.phase-day #skyGrad stop:nth-child(2) { stop-color: #b7e3fb; }
.phase-day #skyGrad stop:nth-child(3) { stop-color: #e8f7f0; }

.phase-dawn #skyGrad stop:nth-child(1) { stop-color: #5a74c4; }
.phase-dawn #skyGrad stop:nth-child(2) { stop-color: #f09a76; }
.phase-dawn #skyGrad stop:nth-child(3) { stop-color: #ffe3b3; }

.phase-dusk #skyGrad stop:nth-child(1) { stop-color: #3f568f; }
.phase-dusk #skyGrad stop:nth-child(2) { stop-color: #e88a6a; }
.phase-dusk #skyGrad stop:nth-child(3) { stop-color: #ffc98a; }

.phase-night #skyGrad stop:nth-child(1) { stop-color: #0b1730; }
.phase-night #skyGrad stop:nth-child(2) { stop-color: #14284d; }
.phase-night #skyGrad stop:nth-child(3) { stop-color: #1d3a5f; }

#sun, #moon {
  transition: opacity 0.9s ease, transform 0.25s linear;
}

#skyline-far {
  fill: #bfd9cc;
  opacity: 0.6;
  transition: fill 1.1s ease;
}

.phase-dawn #skyline-far { fill: #a98cb0; }
.phase-dusk #skyline-far { fill: #8a76a0; }
.phase-night #skyline-far { fill: #10233c; }

#hillL {
  fill: #8fbf8f;
  transition: fill 1.1s ease;
}

.phase-dawn #hillL { fill: #86a585; }
.phase-dusk #hillL { fill: #5f7a6a; }
.phase-night #hillL { fill: #1d3a2c; }

#grass {
  fill: #9ccf9f;
  transition: fill 1.1s ease;
}

.phase-night #grass { fill: #2a4d38; }
.phase-dusk #grass { fill: #6ba274; }
.phase-dawn #grass { fill: #83bd88; }

#sidewalk {
  fill: #cdd9d0;
  transition: fill 1.1s ease;
}

.phase-night #sidewalk { fill: #46545f; }
.phase-dusk #sidewalk { fill: #a08d85; }
.phase-dawn #sidewalk { fill: #b3a89a; }

#road {
  fill: #46525c;
  transition: fill 1.1s ease;
}

.phase-night #road { fill: #202b34; }

#lane {
  stroke: #e8eee9;
  opacity: 0.7;
  transition: stroke 1.1s ease;
}

.phase-night #lane { stroke: #7f93a3; }

#nightTint {
  transition: opacity 1.2s ease;
}

.phase-dawn #nightTint { opacity: 0.13; }
.phase-dusk #nightTint { opacity: 0.17; }
.phase-night #nightTint { opacity: 0.34; }

/* --- stars --- */
.star {
  fill: #ffffff;
  opacity: 0;
  transition: opacity 1.2s ease;
  animation: twinkle 3.2s ease-in-out infinite;
}

.phase-night .star { opacity: 0.9; }
.phase-dawn .star, .phase-dusk .star { opacity: 0.3; }

/* --- clouds --- */
.cloud {
  transition: fill 1.1s ease;
  animation: cloud-drift 26s ease-in-out infinite alternate;
}

.cloud-b { animation-duration: 34s; animation-delay: -12s; }
.cloud-c { animation-duration: 30s; animation-delay: -20s; }

.phase-dawn .cloud, .phase-dusk .cloud { fill: #f3c6a4; }
.phase-night .cloud { fill: #24385c; }

/* --- turbines --- */
.blades {
  transform-box: fill-box;
  transform-origin: center;
  animation: blade-spin 9s linear infinite;
}

.y2040 .blades { animation-duration: 6.2s; }
.y2060 .blades { animation-duration: 4.6s; }
.mini-tur .blades { animation-duration: 5s; }

/* --- tech & policy visibility --- */
#cityScene .t2040,
#cityScene .t2060 {
  opacity: 0;
  transition: opacity 0.7s ease;
}

#cityScene.y2040 .t2040,
#cityScene.y2060 .t2040 {
  opacity: 1;
}

#cityScene.y2060 .t2060 {
  opacity: 1;
}

#cityScene .p-solar-tech,
#cityScene .tree-x,
#cityScene .p-transit-only {
  opacity: 0;
  transition: opacity 0.6s ease;
}

#cityScene.p-solar .p-solar-tech { opacity: 1; }
#cityScene.p-forest .tree-x { opacity: 1; }
#cityScene.p-transit .p-transit-only { opacity: 1; }

#cityScene.p-transit .car-a,
#cityScene.p-transit .car-b,
#cityScene.p-transit .bus {
  opacity: 0;
}

.car-a, .car-b, .bus, .tram, .p-solar-tech, .tree-x, .p-transit-only {
  transition: opacity 0.6s ease;
}

/* --- traffic --- */
.car-a { animation: drive-r 26s linear infinite; }
.car-b { animation: drive-l 34s linear infinite; animation-delay: -15s; }
.bus   { animation: drive-r 44s linear infinite; animation-delay: -22s; }
.tram  { animation: drive-l 30s linear infinite; animation-delay: -6s; }

/* --- windows & lighting --- */
.win {
  fill: #f2f8fa;
  transition: fill 0.9s ease, opacity 0.9s ease;
}

.phase-dusk .win, .phase-dawn .win, .phase-night .win { fill: #22334a; }

.phase-dusk .win-lit,
.phase-dawn .win-lit {
  fill: #ffd98a;
  opacity: 0.65;
}

.phase-night .win-lit {
  fill: #ffd98a;
  filter: drop-shadow(0 0 3px rgba(255, 208, 112, 0.95));
}

/* adaptive lighting in 2060 — fewer windows stay lit */
.phase-night.y2060 .win-lit-x { fill: #22334a; filter: none; }
.phase-night.y2060 .win-lit { fill: #eec87e; }

.lamp-head {
  fill: #cfd9df;
  transition: fill 0.9s ease;
}

.lamp-cone {
  fill: url(#coneG);
  opacity: 0;
  transition: opacity 0.9s ease;
}

.phase-night .lamp-head { fill: #ffd98a; }
.phase-night .lamp-cone { opacity: 0.5; }
.phase-dusk .lamp-cone, .phase-dawn .lamp-cone { opacity: 0.28; }

.beacon { animation: batt-pulse 2.4s ease-in-out infinite; }

.phase-night .batt-light,
.phase-night .beacon {
  filter: drop-shadow(0 0 4px rgba(124, 240, 178, 0.95));
}

/* --- funding badge --- */
.fund-badge {
  opacity: 0;
  transform: scale(0.4);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bld.funded .fund-badge {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Toast & caption ---------- */
.scene-toast {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(80%, 420px);
  padding: 0.6rem 1rem;
  background: rgba(11, 31, 22, 0.92);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.scene-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.scene-caption {
  margin: 0.9rem 0.2rem 0;
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 1.5em;
}

/* ---------- Control cards ---------- */
.control-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem 1.35rem 1.3rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s ease;
}

.control-title {
  font-family: var(--font-head);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.9rem;
}

.control-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 0;
}

/* --- year toggle --- */
.year-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.year-btn {
  padding: 0.62rem 0.4rem;
  border: 1.6px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink-soft);
  transition: all 0.25s ease;
}

.year-btn:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.year-btn.is-on {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.3);
}

/* --- time --- */
.time-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.time-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--brand-deep);
}

#time-slider {
  flex: 1;
  accent-color: var(--brand);
  min-width: 0;
}

.time-readout {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  min-width: 5.6rem;
  text-align: right;
}

.auto-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.62rem;
  border: 1.6px solid var(--line);
  border-radius: 999px;
  background: #fbfdfc;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
  transition: all 0.25s ease;
}

.auto-btn:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.auto-btn.is-on {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.3);
}

/* --- gauge --- */
.gauge-wrap {
  position: relative;
  width: min(240px, 100%);
  margin: 0 auto;
}

.gauge {
  display: block;
  width: 100%;
  height: auto;
}

#needle {
  transition: transform 0.7s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.gauge-read {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
}

.aqi-num {
  display: block;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.9rem;
  line-height: 1.1;
  color: var(--ink);
}

.aqi-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.aqi-label.ok { color: var(--brand-deep); }
.aqi-label.warn { color: #b45309; }
.aqi-label.bad { color: var(--danger); }

/* --- policy chips --- */
.policy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.5rem;
  border: 1.6px solid var(--line);
  border-radius: 999px;
  background: #fbfdfc;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.22s ease;
}

.chip:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.chip[aria-pressed="true"] {
  background: var(--mint);
  border-color: var(--brand);
  color: var(--brand-deep);
}

.reset-btn {
  display: block;
  margin: 0.9rem auto 0;
  padding: 0;
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.reset-btn:hover {
  color: var(--danger);
}

/* --- energy mix --- */
.mix-row {
  display: grid;
  grid-template-columns: 56px 1fr 42px;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
}

.mix-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.mix-track {
  height: 9px;
  border-radius: 999px;
  background: #edf4ef;
  overflow: hidden;
}

.mix-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.mix-solar { background: #f2b53a; }
.mix-wind { background: #2ea8a0; }
.mix-batt { background: #0ea672; }
.mix-fossil { background: #d95f4c; }

.mix-pct {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

.grid-status {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-deep);
  min-height: 2.5em;
}

/* --- building panel --- */
.building-panel.has-sel {
  border-color: rgba(14, 159, 110, 0.45);
}

.panel-hint {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}

.panel-hint svg { flex: none; margin-top: 0.15rem; }

.panel-hint p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.bp-name {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}

.bp-tag {
  display: inline-block;
  margin: 0.35rem 0 0.7rem;
  padding: 0.22rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--teal);
  background: rgba(13, 148, 136, 0.09);
  border-radius: 999px;
}

.bp-desc {
  font-size: 0.93rem;
  color: var(--ink-soft);
  margin: 0 0 0.8rem;
}

.bp-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.bp-tech li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-deep);
  background: var(--mint);
  border-radius: 999px;
}

.fund-btn {
  width: 100%;
  justify-content: center;
}

.funded-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.62rem;
  border-radius: 999px;
  background: var(--mint);
  color: var(--brand-deep);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ---------- Explainers & footer ---------- */
.back-home {
  text-align: center;
  margin-top: 2.6rem;
}

.city-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.4rem;
  padding-bottom: 2.2rem;
  border-bottom: 1px solid rgba(183, 214, 197, 0.16);
}

.city-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
}

.city-footer-links a {
  color: #9fc4b0;
  font-weight: 600;
  font-size: 0.95rem;
}

.city-footer-links a:hover {
  color: #5eead4;
}

/* ---------- Keyframes ---------- */
@keyframes blade-spin {
  to { transform: rotate(360deg); }
}

@keyframes cloud-drift {
  from { transform: translateX(-22px); }
  to { transform: translateX(26px); }
}

@keyframes drive-r {
  from { transform: translateX(-140px); }
  to { transform: translateX(1160px); }
}

@keyframes drive-l {
  from { transform: translateX(1160px); }
  to { transform: translateX(-160px); }
}

@keyframes batt-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .sim-shell {
    grid-template-columns: 1fr;
  }

  .sim-controls-col {
    grid-template-columns: repeat(2, 1fr);
    align-items: start;
  }

  .building-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .sim-controls-col {
    grid-template-columns: 1fr;
  }

  .building-panel {
    grid-column: auto;
  }

  .time-readout {
    min-width: 4.6rem;
    font-size: 0.88rem;
  }

  .howto li {
    font-size: 0.82rem;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .blades,
  .cloud,
  .car-a,
  .car-b,
  .bus,
  .tram,
  .star,
  .beacon,
  .batt-light {
    animation: none !important;
  }

  #sun, #moon, #needle {
    transition: none !important;
  }
}
