/* ===== Cityscape Background ===== */
.cityscape {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 332px;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.18;
  transition: opacity 0.5s ease;
}

/* Skyline — repeat horizontally at natural size, bottom-aligned */
.cityscape__skyline {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: auto;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] .cityscape { opacity: 0.25; }

/* Invert black silhouettes to white for dark backgrounds */
[data-theme="dark"] .cityscape__skyline {
  filter: invert(1) brightness(0.7);
}
/* Ensure pseudo-elements (moon, stars) are not affected by skyline filter */
[data-theme="dark"] .cityscape__skyline ~ * {
  filter: none;
}

/* ===== Night Sky ===== */
[data-theme="dark"] .cityscape::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 30%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #ffeebb 0%, rgba(255,238,187,0.2) 50%, transparent 70%);
  box-shadow: 0 0 30px 8px rgba(255, 238, 187, 0.1);
}

[data-theme="dark"] .cityscape::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  background-image:
    radial-gradient(1px 1px at 8% 15%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 18% 8%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 28% 22%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 38% 5%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 48% 18%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 58% 12%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 68% 25%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 78% 8%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 88% 20%, #fff 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 25% 3%, #ffeebb 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 55% 10%, #ffeebb 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 72% 6%, #ffeebb 50%, transparent 50%),
    radial-gradient(2px 2px at 42% 2%, #ffd54f 50%, transparent 50%);
  opacity: 0.5;
  animation: twinkle 3s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.35; }
  100% { opacity: 0.65; }
}

/* ===== Moving Objects ===== */

/* --- Tanker (SG) — PNG image --- */
.cityscape__tanker {
  position: absolute;
  bottom: 6px;
  height: 18px;
  width: auto;
  opacity: 0.5;
}
.cityscape__tanker--ltr {
  left: -120px;
  animation: sailRight linear forwards;
}
.cityscape__tanker--rtl {
  right: -120px;
  transform: scaleX(-1);
  animation: sailLeft linear forwards;
}
[data-theme="dark"] .cityscape__tanker {
  filter: invert(1) brightness(0.7);
  opacity: 0.2;
}

/* --- Plane — PNG image --- */
.cityscape__plane {
  position: absolute;
  height: 22px;
  width: auto;
  opacity: 0.4;
}
/* direction combinations (ascent only) */
.cityscape__plane--rtl {
  right: -60px;
  transform: scaleX(-1);
  animation: flyLeftUp linear forwards;
}
.cityscape__plane--ltr {
  left: -60px;
  animation: flyRightUp linear forwards;
}
[data-theme="dark"] .cityscape__plane {
  filter: invert(1) brightness(0.7);
  opacity: 0.08;
}

/* --- Train (JP) --- */
.cityscape__train {
  position: absolute;
  bottom: 23px;
  right: -50px;
  width: 45px;
  height: 9px;
  background: #e4002b;
  opacity: 0.18;
  border-radius: 2px;
  animation: trainRight linear forwards;
}
.cityscape__train::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: #fff;
  opacity: 0.5;
  border-radius: 2px 2px 0 0;
}
.cityscape__train::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 3px;
  height: 3px;
  background: #ccc;
  opacity: 0.4;
  box-shadow: 7px 0 0 #ccc, 14px 0 0 #ccc, 21px 0 0 #ccc, 28px 0 0 #ccc, 35px 0 0 #ccc;
}
[data-theme="dark"] .cityscape__train { opacity: 0.22; }
[data-theme="dark"] .cityscape__train::after {
  background: #ffd54f;
  box-shadow: 7px 0 0 #ffd54f, 14px 0 0 #ffd54f, 21px 0 0 #ffd54f, 28px 0 0 #ffd54f, 35px 0 0 #ffd54f;
  opacity: 0.5;
}

/* --- Shooting star (dark) --- */
.cityscape__shooting-star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  animation: shoot 1.5s ease-out forwards;
}
.cityscape__shooting-star::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 35px;
  height: 1px;
  background: linear-gradient(to left, transparent, rgba(255,255,255,0.7));
}

/* --- Sakura petals (JP light) --- */
.cityscape__petal {
  position: absolute;
  top: -8px;
  width: 6px;
  height: 6px;
  background: #ffb7c5;
  opacity: 0.35;
  border-radius: 50% 0 50% 0;
  animation: petalFall ease-in-out forwards;
}

/* ===== Animations ===== */
@keyframes sailRight {
  from { left: -120px; }
  to { left: calc(100% + 120px); }
}
@keyframes sailLeft {
  from { right: -120px; }
  to { right: calc(100% + 120px); }
}
@keyframes flyLeftUp {
  from { right: -60px; top: var(--plane-start-top, 30%); }
  to   { right: calc(100% + 60px); top: calc(var(--plane-start-top, 30%) - 36vh); }
}
@keyframes flyRightUp {
  from { left: -60px; top: var(--plane-start-top, 30%); }
  to   { left: calc(100% + 60px); top: calc(var(--plane-start-top, 30%) - 36vh); }
}
@keyframes trainRight {
  from { right: -50px; }
  to { right: calc(100% + 50px); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}
@keyframes shoot {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-70px, 35px) scale(0.2); opacity: 0; }
}
@keyframes petalFall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0.35; }
  50% { transform: translate(15px, 80px) rotate(180deg); opacity: 0.3; }
  100% { transform: translate(-10px, 180px) rotate(360deg); opacity: 0; }
}

/* ===== Scene Crossfade Transition ===== */
.cityscape__skyline {
  transition: opacity 1.5s linear;
}
.cityscape__skyline--fade-out {
  opacity: 0;
}
