/* ==========================================================================
   Planet Zakzak (js/planet.js): the map of the whole game. One world that a
   finger drags; doors on the road, places and books beside them. The admin
   panel's "الخريطة" tab draws the same world (.pl-world.is-edit).
   ========================================================================== */

.planet {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #2d2a6e, #141238 70%);
  touch-action: none;
}
.modal.planet { display: block; padding: 0; }
.planet.is-leaving { opacity: 0; transition: opacity .32s ease-in; pointer-events: none; }
.pl-view { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.pl-view:active { cursor: grabbing; }

.pl-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 3000px;
  height: 3000px;
  transform-origin: 0 0;
  will-change: transform;
}
.pl-ground { position: absolute; left: 0; top: 0; display: block; }

/* ---------- Ground (one SVG) ---------- */
.pl-star { fill: #fff; opacity: .75; }
.pl-twinkle { animation: pl-twinkle 3s ease-in-out infinite; }
@keyframes pl-twinkle { 50% { opacity: .15; } }
.pl-air { fill: rgba(150, 210, 255, .2); }
.pl-wave { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; opacity: .5; }
.pl-land { fill: none; stroke-linecap: butt; stroke-linejoin: round; }
.pl-road-edge { fill: none; stroke-width: 50; stroke-linecap: round; stroke-linejoin: round; }
.pl-road { fill: none; stroke: #fbecc4; stroke-width: 36; stroke-linecap: round; stroke-linejoin: round; }
.pl-steps { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 0 24; opacity: .9; }
.pl-bridge-rail { fill: none; stroke: #7a4f2c; stroke-width: 58; }
.pl-bridge { fill: none; stroke: #c98a4f; stroke-width: 46; stroke-dasharray: 11 5; }

/* ---------- Things on the ground: placed by their middle ---------- */
.pl-world > button, .pl-world > span, .pl-world > img {
  position: absolute;
  translate: -50% -50%;
}
.pl-world > button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--zk-line, #4a3f7a);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pl-deco { z-index: 1; object-fit: contain; pointer-events: none; }
.pl-swim { width: 64px; height: 64px; animation: pl-swim 4s ease-in-out infinite; }
.pl-swim:nth-of-type(2n) { animation-delay: -2s; }
@keyframes pl-swim { 50% { transform: translateY(-8px) rotate(4deg); } }
.pl-rocket { width: 120px; height: 120px; rotate: -18deg; }
.pl-end { z-index: 2; width: 92px; height: 92px; pointer-events: none; animation: pl-spin 6s linear infinite; }
.pl-end svg { display: block; width: 100%; height: 100%; fill: #ffd84d; stroke: #e59a00; stroke-width: 1; }
@keyframes pl-spin { to { rotate: 360deg; } }

/* A level starts here: a flag with its number */
.pl-flag { z-index: 2; width: 52px; height: 76px; pointer-events: none; }
.pl-flag::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 7px;
  height: 76px;
  border-radius: 4px;
  background: #6b4a2b;
}
.pl-flag b {
  position: absolute;
  left: 10px;
  top: 4px;
  width: 42px;
  height: 32px;
  border-radius: 2px 16px 16px 2px;
  background: var(--tier);
  box-shadow: 0 3px 0 rgba(40, 34, 70, .25);
  color: #fff;
  font: 800 22px/32px system-ui, sans-serif;
  text-align: center;
  text-shadow: 0 1px 0 rgba(40, 34, 70, .35);
  animation: pl-wave-flag 2.4s ease-in-out infinite;
  transform-origin: 0 50%;
}
@keyframes pl-wave-flag { 50% { transform: skewY(-6deg) scaleX(.94); } }

/* ---------- Places (rooms) ---------- */
.pl-world > .pl-place {
  z-index: 3;
  width: 126px;
  height: 126px;
  border: 7px solid var(--tier);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 0 rgba(40, 34, 70, .3);
}
.pl-place img { display: block; width: 74%; height: 74%; margin: 13%; pointer-events: none; }
.pl-num {
  position: absolute;
  top: -8px;
  right: -8px;
  box-sizing: border-box;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border: 3px solid var(--tier);
  border-radius: 18px;
  background: #fff;
  font: 800 20px/30px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 2px 0 rgba(40, 34, 70, .25);
}
.pl-place.is-locked img { filter: grayscale(.85); opacity: .6; }
.pl-place.is-locked::after, .pl-place.is-done::after,
.pl-door.is-locked::after, .pl-door.is-done::after, .pl-book.is-done::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 38px;
  height: 38px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #ffd84d url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a5 5 0 0 0-5 5v1H6a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1h-1V7a5 5 0 0 0-5-5Z' fill='%23b89a10'/%3E%3Ccircle cx='12' cy='14' r='2.2' fill='%23fff'/%3E%3C/svg%3E") center / 62% no-repeat;
  pointer-events: none;
}
.pl-place.is-done::after, .pl-door.is-done::after, .pl-book.is-done::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3 6.5 7 .8-5.2 4.8 1.4 7L12 17.6 5.8 21.1l1.4-7L2 9.3l7-.8Z' fill='%23fff' stroke='%23b89a10' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.pl-door.is-locked::after, .pl-door.is-done::after, .pl-book.is-done::after { width: 30px; height: 30px; right: -4px; bottom: 2px; }
.pl-door.is-done::after { top: -6px; bottom: auto; right: 50%; translate: 50% 0; }

/* ---------- Books (stories) ---------- */
.pl-world > .pl-book {
  z-index: 4;
  width: 70px;
  height: 80px;
  border: 5px solid var(--tier);
  border-left-width: 13px;
  border-radius: 7px 14px 14px 7px;
  background: #fffaf0;
  box-shadow: 0 5px 0 rgba(40, 34, 70, .3);
}
.pl-book img { display: block; width: 80%; height: auto; margin: 10% auto 0; pointer-events: none; }
.pl-book.is-open { animation: door-glow 1.6s ease-in-out infinite; }
.pl-book.is-locked img { filter: grayscale(.9); opacity: .55; }
.pl-world > .pl-book.is-locked { border-color: #c9c4d8; }

/* ---------- Doors (lessons) ---------- */
.pl-door { z-index: 5; width: 72px; height: 77px; }
.pl-door svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pd-base { fill: rgba(40, 34, 70, .25); }
.pd-frame { fill: var(--tier); stroke: var(--zk-line, #4a3f7a); stroke-width: 3; stroke-linejoin: round; }
.pd-in { fill: #ffe27a; }
.pd-leaf {
  fill: #fff4dc;
  stroke: rgba(74, 63, 122, .4);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: 0 50%;
  transition: transform .45s cubic-bezier(.4, 1.4, .6, 1);
}
.pd-knob { fill: var(--zk-line, #4a3f7a); }
.pl-door.is-done .pd-leaf { fill: #ffeaa0; }
.pl-door.is-locked .pd-frame { fill: #c9c4d8; }
.pl-door.is-locked .pd-leaf { fill: #ece9f4; }
.pl-door.is-next svg { animation: door-glow 1.6s ease-in-out infinite; }
.pl-door.is-next::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 34px;
  height: 30px;
  translate: -50% -100%;
  background: url("../assets/scene/pointer.svg") center / contain no-repeat;
  animation: door-pointer 1s ease-in-out infinite;
  pointer-events: none;
}
.pl-door.is-opening .pd-leaf { transform: scaleX(.1); }
.pl-door.is-opening::before { display: none; }
.pl-door.is-shake, .pl-place.is-shake, .pl-book.is-shake { animation: opt-wiggle .4s ease-in-out; }
.pl-place.is-hop, .pl-book.is-hop { animation: pl-hop .45s ease-out; }
@keyframes pl-hop { 40% { transform: translateY(-14px) scale(1.08); } }
.pl-world > .is-press { scale: .93; }

/* ---------- Stars on the road: Zakzak picks them up ---------- */
.pl-gem { z-index: 6; width: 44px; height: 44px; pointer-events: none; animation: pl-gem 1.4s ease-in-out infinite; }
.pl-gem svg { display: block; width: 100%; height: 100%; fill: #ffd84d; stroke: #e59a00; stroke-width: 1.2; }
@keyframes pl-gem { 50% { transform: translateY(-7px) rotate(12deg); } }
.pl-gem.is-got { animation: pl-got .55s ease-out forwards; }
@keyframes pl-got {
  40% { transform: translateY(-40px) scale(1.6); opacity: 1; }
  100% { transform: translateY(-70px) scale(.4); opacity: 0; }
}

/* ---------- Zakzak on the map (a copy of the house drawing) ---------- */
.pl-world > .pl-zak { z-index: 8; width: 104px; height: 116px; translate: -50% -100%; }
.pl-zak::before {
  content: "";
  position: absolute;
  left: 18%;
  bottom: -4px;
  width: 64%;
  height: 16px;
  border-radius: 50%;
  background: rgba(40, 34, 70, .28);
}
.pl-zak-body { display: block; width: 100%; transform-origin: 50% 100%; }
.pl-zak-body svg { display: block; width: 100%; height: auto; overflow: visible; }
.pl-zak .zk-fill { fill: url(#zk-grad); }
.pl-zak .zk-leg { fill: url(#zk-limb-grad); }
.pl-zak .zk-horn { fill: url(#zk-horn-grad); }
.pl-zak .zk-cheek { fill: url(#zk-cheek-grad); opacity: .85; }
.pl-zak .zk-talk { display: none; }
.pl-zak.is-walking .zk-eye, .pl-zak.is-walking .zk-mouth--idle,
.pl-zak.is-happy .zk-eye, .pl-zak.is-happy .zk-mouth--idle { display: none; }
.pl-zak.is-walking .zk-happy-eye, .pl-zak.is-walking .zk-mouth--right,
.pl-zak.is-happy .zk-happy-eye, .pl-zak.is-happy .zk-mouth--right { display: inline; }
.pl-zak.is-happy svg { animation: zk-jump .9s ease-out; }

/* ---------- The child's buttons on the planet ---------- */
.pl-btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 0 rgba(20, 18, 56, .45);
  cursor: pointer;
}
.pl-btn svg { width: 58%; height: 58%; }
.pl-close {
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  width: 78px;
  height: 78px;
  border: 5px solid #ffd84d;
}
.pl-close svg { fill: var(--zk-line, #4a3f7a); }
.pl-globe {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  width: 64px;
  height: 64px;
  border: 5px solid #6ec6ff;
}
.pl-globe svg { fill: #bfe8ff; stroke: #2f86c8; stroke-width: 1.6; }
.pl-btn.is-press { scale: .93; }

/* ---------- Admin layout page ---------- */
.pl-world.is-edit .pl-place, .pl-world.is-edit .pl-door, .pl-world.is-edit .pl-book { cursor: move; }
.pl-world.is-edit .is-sel { outline: 5px solid #ff5fa2; outline-offset: 6px; border-radius: 14px; }
.pl-world.is-edit .pl-place.is-sel { border-radius: 50%; }
.pl-world.is-edit .is-set { box-shadow: 0 0 0 4px #ff5fa2; }
.pl-name {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 10px;
  padding: 2px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  font: 700 18px/1.4 system-ui, sans-serif;
  white-space: nowrap;
}
.pl-door-n {
  position: absolute;
  left: 50%;
  bottom: -6px;
  translate: -50% 0;
  min-width: 30px;
  padding: 0 5px;
  border-radius: 10px;
  background: #fff;
  font: 800 16px/22px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 1px 0 rgba(40, 34, 70, .3);
}

@media (prefers-reduced-motion: reduce) {
  .planet *, .planet *::before, .planet *::after { animation: none !important; transition: none !important; }
}
