/* CYBER BALL key page (key.ball8.store). Same family as get.ball8.store: no web fonts, no libraries,
   transform/opacity animations only. Everything shows without JavaScript; app.js only adds the step progress. */
:root, :host {
  --bg: #00070d;
  --bg2: #001420;
  --panel: rgba(0, 30, 46, .62);
  --line: rgba(111, 243, 255, .16);
  --cyan: #00e1ff;
  --cyan2: #6ff3ff;
  --ice: #c8faff;
  --text: #e7f6ff;
  --muted: #96b8c8;
  --violet: #8b5cff;
  --gold: #ffd166;
  --ok: #34ffba;
  --r: 20px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, .kx-page {
  margin: 0; min-height: 100vh; min-height: 100svh;
  background: radial-gradient(120% 70% at 50% -10%, #002a3c 0%, var(--bg2) 38%, var(--bg) 75%) fixed, var(--bg);
  color: var(--text); font: 16px/1.65 var(--font);
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
img { display: block; max-width: 100%; }

/* ---------- background ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.grid {
  position: absolute; inset: -20% -10% auto; height: 140%;
  background-image: linear-gradient(rgba(0, 225, 255, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 225, 255, .07) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(70% 55% at 50% 25%, #000 0%, transparent 72%);
          mask-image: radial-gradient(70% 55% at 50% 25%, #000 0%, transparent 72%);
  transform: perspective(600px) rotateX(58deg) translateY(-8%); transform-origin: 50% 0;
  animation: drift 14s linear infinite;
}
@keyframes drift { to { background-position: 0 46px, 0 0; } }
.glow { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; will-change: transform; }
.g1 { width: 360px; height: 360px; top: -120px; inset-inline-end: -120px; background: #0090b0; animation: float 16s ease-in-out infinite; }
.g2 { width: 320px; height: 320px; top: 55%; inset-inline-start: -150px; background: #4c2bb8; opacity: .35; animation: float 19s ease-in-out infinite reverse; }
@keyframes float { 50% { transform: translate3d(40px, 50px, 0) scale(1.08); } }

/* reading progress (filled by app.js) */
.bar { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 5; background: rgba(0, 225, 255, .08); }
.bar i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: right; background: linear-gradient(90deg, var(--violet), var(--cyan), var(--ok)); box-shadow: 0 0 12px var(--cyan); transition: transform .25s ease; }

/* ---------- top ---------- */
.top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 0; }
.brand { display: flex; align-items: center; gap: 8px; direction: ltr; }
.brand img { border-radius: 8px; box-shadow: 0 0 14px rgba(0, 225, 255, .35); }
.brand span { font-weight: 800; letter-spacing: .14em; font-size: 13px; color: var(--ice); }
.brand b { color: var(--cyan); margin-inline-start: 4px; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--ok); background: rgba(52, 255, 186, .08); border: 1px solid rgba(52, 255, 186, .25); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: ping 2s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(52, 255, 186, .6); } 70%, 100% { box-shadow: 0 0 0 8px rgba(52, 255, 186, 0); } }

/* ---------- layout ---------- */
.wrap { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }
.hero { text-align: center; padding-top: 10px; }

/* the key orb */
.orb { position: relative; width: 150px; height: 150px; margin: 14px auto 0; }
.ring { position: absolute; inset: 0; border-radius: 50%; }
.r1 { border: 1.5px dashed rgba(0, 225, 255, .4); animation: turn 24s linear infinite; }
.r2 { inset: 18px; border: 1px solid rgba(139, 92, 255, .4); background: radial-gradient(circle, rgba(0, 225, 255, .16), rgba(0, 20, 32, .2) 70%); box-shadow: inset 0 0 26px rgba(0, 225, 255, .14), 0 0 40px rgba(0, 225, 255, .12); animation: turn 36s linear infinite reverse; }
.spin { position: absolute; inset: 0; animation: turn 6s linear infinite; }
.spin i { position: absolute; top: -6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--cyan2) 35%, #0083a3 80%); box-shadow: 0 0 14px var(--cyan), 0 0 28px rgba(0, 225, 255, .5); }
.key { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; fill: none; stroke: var(--gold); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 10px rgba(255, 209, 102, .55)); animation: bob 5s ease-in-out infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: translate3d(0, -5px, 0) rotate(-6deg); } }

.title {
  margin: 16px 0 4px; font-size: clamp(27px, 8vw, 38px); line-height: 1.25; font-weight: 900;
  background: linear-gradient(100deg, #ffffff 0%, var(--ice) 35%, var(--cyan2) 55%, #ffffff 70%, #c9b8ff 100%);
  background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(0, 225, 255, .22)); animation: shine 7s ease-in-out infinite;
  overflow-wrap: anywhere;
}
@keyframes shine { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.intro { margin: 6px auto 0; max-width: 420px; color: #cfe9f4; font-size: 15.5px; overflow-wrap: anywhere; }
.count { display: inline-block; margin: 14px 0 0; padding: 5px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.count b { color: var(--cyan2); }

/* ---------- the path of steps ---------- */
.path { position: relative; list-style: none; margin: 26px 0 0; padding: 0; }
.path::before { content: ""; position: absolute; top: 18px; bottom: 18px; inset-inline-start: 19px; width: 2px; border-radius: 2px; background: linear-gradient(180deg, rgba(0, 225, 255, .55), rgba(139, 92, 255, .4) 70%, rgba(52, 255, 186, .5)); }
.step { position: relative; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.node {
  position: relative; z-index: 1; flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #00121c; border: 2px solid rgba(0, 225, 255, .6); color: var(--cyan2); font-weight: 900; font-size: 16px;
  box-shadow: 0 0 14px rgba(0, 225, 255, .3), inset 0 0 10px rgba(0, 225, 255, .15);
  transition: background .3s ease, color .3s ease, border-color .3s ease, transform .3s ease;
}
.card { flex: 1; min-width: 0; padding: 14px 15px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: border-color .3s ease; }
.card h2 { margin: 0 0 4px; font-size: 16.5px; line-height: 1.45; color: var(--ice); overflow-wrap: anywhere; }
.card p { margin: 0; color: #cfe9f4; font-size: 15px; overflow-wrap: anywhere; }
.card figure { margin: 12px 0 2px; border-radius: 14px; overflow: hidden; border: 1px solid rgba(111, 243, 255, .22); background: #00101a; }
.card figure img { width: 100%; height: auto; cursor: zoom-in; }
.card h2:only-child, .card p:only-child { margin: 0; }
.card figure:first-child { margin-top: 0; }

/* steps rise in once on load (pure CSS, never hidden); app.js only lights up the ones already read */
.step { animation: rise .55s ease both; }
.step:nth-child(2) { animation-delay: .08s; } .step:nth-child(3) { animation-delay: .16s; } .step:nth-child(4) { animation-delay: .24s; }
.step:nth-child(5) { animation-delay: .32s; } .step:nth-child(n+6) { animation-delay: .4s; }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } }
.step.seen .node { background: linear-gradient(135deg, #00d6f5, #0087c0); border-color: transparent; color: #00121b; transform: scale(1.06); }
.step.seen .card { border-color: rgba(0, 225, 255, .32); }

/* ---------- finish ---------- */
.finish { position: relative; display: flex; align-items: center; gap: 14px; margin-top: 8px; padding: 16px; border-radius: var(--r); background: linear-gradient(135deg, rgba(52, 255, 186, .1), rgba(0, 225, 255, .06)); border: 1px solid rgba(52, 255, 186, .35); box-shadow: 0 0 30px rgba(52, 255, 186, .08); }
.tick { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(52, 255, 186, .14); border: 2px solid var(--ok); box-shadow: 0 0 18px rgba(52, 255, 186, .35); animation: beat 2.4s ease-in-out infinite; }
.tick svg { width: 24px; height: 24px; fill: none; stroke: var(--ok); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes beat { 50% { transform: scale(1.08); } }
.finish div { display: flex; flex-direction: column; min-width: 0; }
.finish b { font-size: 15.5px; color: #eafff6; overflow-wrap: anywhere; }
.finish small { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.finish.done { border-color: var(--ok); box-shadow: 0 0 34px rgba(52, 255, 186, .22); }

.foot { position: relative; z-index: 1; display: flex; justify-content: center; padding: 4px 16px max(20px, env(safe-area-inset-bottom)); color: #6f8f9e; font-size: 12.5px; }

/* image viewer (app.js) */
.zoom { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; padding: 16px; background: rgba(0, 6, 12, .92); cursor: zoom-out; animation: fade .2s ease; }
.zoom img { max-height: 92vh; width: auto; border-radius: 12px; box-shadow: 0 0 40px rgba(0, 225, 255, .25); }
@keyframes fade { from { opacity: 0; } }
[hidden] { display: none !important; }

/* ---------- the task button (hero) ---------- */
.cta {
  position: relative; display: block; max-width: 380px; margin: 20px auto 0; padding: 2px; border-radius: 22px;
  overflow: hidden; isolation: isolate; text-decoration: none; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 14px 40px rgba(255, 170, 60, .28), 0 0 0 1px rgba(255, 209, 102, .25);
  animation: breathe 2.6s ease-in-out infinite; transition: transform .15s ease;
}
.cta::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: 140%; aspect-ratio: 1; margin: -70% 0 0 -70%;
  background: conic-gradient(from 0deg, transparent 0 50%, #fff3c4 64%, var(--gold) 72%, #ff7a3d 82%, transparent 94%);
  animation: turn 2.8s linear infinite;
}
.cta-face {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 20px; border-radius: 20px;
  background: linear-gradient(135deg, #ffe08a 0%, #ffb547 50%, #ff8a3d 100%); color: #1c0d00; overflow: hidden;
}
.cta-face::after { content: ""; position: absolute; inset: 0 auto 0 -60%; width: 45%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent); transform: skewX(-18deg); animation: sweep 3.2s ease-in-out infinite; }
.cta-face svg { width: 30px; height: 30px; flex: none; padding: 6px; border-radius: 50%; fill: #fff; background: rgba(28, 13, 0, .85); box-shadow: 0 0 0 3px rgba(28, 13, 0, .15); }
.cta-face b { font-size: 20px; font-weight: 900; letter-spacing: .01em; }
.cta:active { transform: scale(.97); }
.cta:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
@keyframes breathe { 50% { box-shadow: 0 18px 54px rgba(255, 170, 60, .45), 0 0 0 1px rgba(255, 209, 102, .45); } }
@keyframes sweep { 0%, 55% { left: -60%; } 100% { left: 130%; } }

/* ---------- the task popup ---------- */
.pop-open, .pop-open body { overflow: hidden; }
.pop { position: fixed; inset: 0; z-index: 20; display: flex; padding: 18px; background: rgba(0, 4, 10, .78); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); animation: fade .25s ease; overflow-y: auto; }
.pop-card {
  position: relative; width: min(420px, 100%); margin: auto; padding: 26px 20px 20px; border-radius: 28px; text-align: center;
  overflow: hidden; isolation: isolate; box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 60px rgba(0, 225, 255, .18);
  animation: popIn .45s cubic-bezier(.2, 1.3, .4, 1);
}
.pop-card::before {
  content: ""; position: absolute; z-index: -2; left: 50%; top: 50%; width: 200%; aspect-ratio: 1; margin: -100% 0 0 -100%;
  background: conic-gradient(from 0deg, var(--cyan) 0%, var(--violet) 25%, var(--gold) 50%, var(--cyan2) 75%, var(--cyan) 100%);
  animation: turn 5s linear infinite;
}
.pop-card::after { content: ""; position: absolute; z-index: -1; inset: 2px; border-radius: 26px; background: radial-gradient(120% 55% at 50% 0%, #00364a 0%, #021521 55%, #010b12 100%); }
@keyframes popIn { from { opacity: 0; transform: translate3d(0, 24px, 0) scale(.9); } }
.pop-x { position: absolute; top: 14px; inset-inline-end: 14px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ice); font: 700 15px/1 var(--font); cursor: pointer; }
.pop-orb { position: relative; width: 96px; height: 96px; margin: 2px auto 0; display: grid; place-items: center; }
.pop-orb .r2 { inset: 14px; }
.pop-orb svg { position: relative; width: 38px; height: 38px; fill: var(--gold); filter: drop-shadow(0 0 12px rgba(255, 209, 102, .7)); animation: bob 3s ease-in-out infinite; margin-inline-start: 4px; }
.pop-chip { display: inline-block; margin-top: 10px; padding: 5px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 800; color: var(--gold); background: rgba(255, 209, 102, .1); border: 1px solid rgba(255, 209, 102, .35); }
.pop-card h2 {
  margin: 12px 0 6px; font-size: clamp(21px, 6vw, 25px); line-height: 1.4; font-weight: 900; overflow-wrap: anywhere;
  background: linear-gradient(100deg, #fff 0%, var(--ice) 40%, #ffe7a6 70%, #fff 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pop-text { margin: 0 auto; max-width: 340px; color: #cfe9f4; font-size: 15px; overflow-wrap: anywhere; }
.pop-steps { display: flex; justify-content: center; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
.pop-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px; border-radius: 14px; font-size: 12.5px; font-weight: 700; color: var(--ice); background: rgba(0, 225, 255, .06); border: 1px solid var(--line); }
.pop-steps i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-style: normal; font-weight: 900; font-size: 12px; color: #00121b; background: linear-gradient(135deg, var(--cyan2), var(--cyan)); box-shadow: 0 0 10px rgba(0, 225, 255, .45); }
.pop-go {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; padding: 16px 18px;
  border-radius: 18px; text-decoration: none; color: #1c0d00; overflow: hidden;
  background: linear-gradient(135deg, #ffe08a 0%, #ffb547 50%, #ff8a3d 100%); box-shadow: 0 12px 34px rgba(255, 150, 60, .35);
  transition: transform .15s ease;
}
.pop-go::after { content: ""; position: absolute; inset: 0 auto 0 -60%; width: 45%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .6), transparent); transform: skewX(-18deg); animation: sweep 2.6s ease-in-out infinite; }
.pop-go b { font-size: 19px; font-weight: 900; }
.pop-go svg { width: 22px; height: 22px; fill: currentColor; transform: scaleX(-1); }
.pop-go:active { transform: scale(.97); }
.pop-auto { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 0; font-size: 13.5px; color: var(--muted); }
.pop-ring { --p: 100%; position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: conic-gradient(var(--gold) var(--p), rgba(255, 255, 255, .08) 0); }
.pop-ring::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: #021521; }
.pop-ring b { position: relative; color: var(--gold); font-size: 15px; font-weight: 900; }
.pop-auto button { border: 0; background: none; color: var(--cyan2); font: 700 13.5px var(--font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px; }
.pop-auto.off .pop-ring, .pop-auto.off span, .pop-auto.off button { display: none; }
.pop-auto.done::before { content: "✓ فتحنا المهمة — أكملها وارجع للتطبيق"; color: var(--ok); font-weight: 700; }
.pop-x:focus-visible, .pop-go:focus-visible, .pop-auto button:focus-visible { outline: 3px solid var(--cyan2); outline-offset: 3px; }

/* the task opened inside the popup: a small neon browser window */
.pop-card.web { width: min(560px, 100%); min-height: min(84vh, 780px); }
.pop-web { position: absolute; inset: 2px; z-index: 2; display: flex; flex-direction: column; border-radius: 26px; overflow: hidden; background: #010b12; text-align: start; animation: webIn .35s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes webIn { from { opacity: 0; transform: scale(.95); } }
.pop-web-bar { display: flex; align-items: center; gap: 8px; padding: 10px; background: linear-gradient(180deg, rgba(0, 225, 255, .12), rgba(0, 225, 255, .03)); border-bottom: 1px solid var(--line); }
.pop-web-x { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ice); font: 700 16px/1 var(--font); cursor: pointer; }
.pop-web-host { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); font-size: 12.5px; color: var(--ice); white-space: nowrap; overflow: hidden; }
.pop-web-host .ltr { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pop-web-out { flex: none; padding: 8px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #1c0d00; text-decoration: none; background: linear-gradient(135deg, #ffe08a, #ff8a3d); box-shadow: 0 6px 18px rgba(255, 150, 60, .3); }
.pop-web-frame { position: relative; flex: 1; min-height: 320px; background: #fff; }
.pop-web-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.pop-web-load { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 14px; color: var(--muted); background: radial-gradient(circle at 50% 40%, #00364a, #021521 70%); transition: opacity .35s ease; }
.pop-web-load i { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(0, 225, 255, .18); border-top-color: var(--cyan); box-shadow: 0 0 18px rgba(0, 225, 255, .3); animation: turn .8s linear infinite; }
.pop-web.ready .pop-web-load { opacity: 0; pointer-events: none; }
.pop-web-hint { margin: 0; padding: 10px 12px; font-size: 12.5px; font-weight: 700; text-align: center; color: var(--ok); background: rgba(52, 255, 186, .06); border-top: 1px solid rgba(52, 255, 186, .2); }
.pop-web-x:focus-visible, .pop-web-out:focus-visible { outline: 3px solid var(--cyan2); outline-offset: 2px; }

@media (max-width: 360px) {
  .path::before { inset-inline-start: 16px; }
  .node { width: 34px; height: 34px; font-size: 14px; }
  .card { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.paused *, .paused *::before, .paused *::after { animation-play-state: paused !important; }
.lite .glow, .lite .grid { display: none; }
