/* coin-gift.css — 🎁 the kid's gift box of DralyDirhams (js/coin-gift.js; 2026-10-27, his ask: «give coins to students…
   like a surprise… they will really like it»). Phone first (390×844, 360×640), a laptop too: a full-screen night sky over
   Dubai, a Dralingo-blue box with a gold ribbon that wobbles, Dralingo beside it («¡wow!»); a tap: the lid flies, gold
   rays, the coins fly into the DralyDirhams pill, then the amount, the reason and two big buttons. Every tap target 48 px
   or more; reduced motion = nothing moves (the lid fades, the number is there at once). Above every overlay of /homework
   (the teacher's animation is 99999). */
.cg-ov {
  --cg-gold: #ffd86b; --cg-gold-2: #f5c542; --cg-gold-deep: #b88b2c; --cg-gold-ink: #85631d; --cg-rojo: #5a1010;
  --cg-blue: #3b8cff; --cg-blue-2: #1f63d6; --cg-blue-3: #174fb0; --cg-blue-edge: #0e3a86;
  --cg-ease: cubic-bezier(.23, 1, .32, 1);
  position: fixed; inset: 0; z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  /* (the top keeps room for the coins pill the coins fly into, over the home's own pill: never on the title) */
  padding: max(84px, calc(env(safe-area-inset-top) + 70px)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(120% 90% at 50% 36%, #2f6fe0 0%, #163f9c 46%, #0b1f55 100%);
  color: #fff; font-family: 'Nunito', 'Noto Sans', system-ui, sans-serif; text-align: center;
  opacity: 0; transition: opacity .25s ease;
  -webkit-tap-highlight-color: transparent;
}
.cg-ov.is-in { opacity: 1; }
.cg-ov.is-out { opacity: 0; transition-duration: .2s; }
html.cg-lock, html.cg-lock body { overflow: hidden !important; }

.cg-sky { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cg-sky img {
  position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 30vh; object-fit: cover; object-position: center bottom; opacity: .32; filter: brightness(.7) saturate(1.2);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 45%); mask-image: linear-gradient(to bottom, transparent 0%, #000 45%);   /* (no hard edge where the skyline starts) */
}
.cg-sky::before {   /* a few gold stars */
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(2px 2px at 12% 18%, var(--cg-gold) 50%, transparent 51%), radial-gradient(2px 2px at 82% 12%, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 70% 30%, var(--cg-gold) 50%, transparent 51%), radial-gradient(2px 2px at 24% 42%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 90% 48%, var(--cg-gold) 50%, transparent 51%), radial-gradient(3px 3px at 8% 62%, #fff 50%, transparent 51%);
  opacity: .8;
}
.cg-rays {
  position: absolute; left: 50%; top: 44%; width: 170vmax; height: 170vmax; translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 216, 107, .22) 0deg 9deg, rgba(255, 216, 107, 0) 9deg 24deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, .6) 22%, transparent 48%); mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, .6) 22%, transparent 48%);
  opacity: 0; transition: opacity .5s ease;
}
.cg-ov.is-open .cg-rays { opacity: 1; animation: cg-spin 18s linear infinite; }

.cg-x {
  position: absolute; z-index: 3; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff;
  font: 800 22px/1 'Baloo 2', 'Noto Sans', sans-serif; cursor: pointer;
}
.cg-x:hover { background: rgba(255, 255, 255, .26); }

.cg-stage { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; max-width: 440px; margin: auto; }
/* (the dialog's first focus is its title: read by a screen reader, never a frame on screen; /homework's pastel layer
   frames every [tabindex] with a higher specificity, so these win with !important; the box and the buttons keep a
   gold frame for the keyboard) */
body .cg-ov .cg-title:focus, body .cg-ov .cg-title:focus-visible { outline: none !important; box-shadow: none !important; }
body .cg-ov .cg-box:focus-visible { outline: 4px solid var(--cg-gold) !important; outline-offset: 10px; border-radius: 22px; }
body .cg-ov .cg-thanks:focus-visible, body .cg-ov .cg-souk:focus-visible, body .cg-ov .cg-x:focus-visible { outline: 3px solid #fff !important; outline-offset: 3px; }
.cg-title { margin: 0; padding: 0 44px; font: 800 clamp(26px, 7.4vw, 38px)/1.08 'Baloo 2', 'Noto Sans', sans-serif; color: var(--cg-gold); text-shadow: 0 3px 0 rgba(0, 0, 0, .28); overflow-wrap: anywhere; }
.cg-hint { margin: 2px 0 0; font: 800 18px/1.25 'Baloo 2', 'Noto Sans', sans-serif; color: #e8f0ff; }

/* ── the scene: Dralingo beside the box ── */
.cg-scene { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 4px; width: 100%; height: 236px; margin-top: 6px; }
.cg-dra { width: 132px; height: auto; max-height: 150px; object-fit: contain; margin-right: -14px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .3)); align-self: flex-end; }

.cg-box {
  position: relative; flex: none; width: 176px; height: 186px; margin: 0 0 6px; padding: 0; border: 0; background: none; cursor: pointer;
  transform-origin: 50% 92%; animation: cg-wobble 1.7s ease-in-out infinite; -webkit-tap-highlight-color: transparent;
}
.cg-box:focus-visible { outline: 4px solid var(--cg-gold); outline-offset: 10px; border-radius: 22px; }
.cg-glow { position: absolute; inset: -34px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 216, 107, .62), rgba(255, 216, 107, 0) 64%); animation: cg-pulse 1.7s ease-in-out infinite; pointer-events: none; }
.cg-body {
  position: absolute; left: 12px; right: 12px; bottom: 0; height: 116px; border-radius: 14px 14px 20px 20px;
  background: linear-gradient(180deg, var(--cg-blue) 0%, var(--cg-blue-2) 58%, var(--cg-blue-3) 100%);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .14), inset 0 7px 0 rgba(255, 255, 255, .2), 0 9px 0 var(--cg-blue-edge), 0 18px 26px rgba(0, 0, 0, .38);
}
.cg-body::before { content: ''; position: absolute; left: 12px; top: 14px; width: 18px; height: 44px; border-radius: 10px; background: rgba(255, 255, 255, .22); }   /* the glossy shine */
.cg-lid {
  position: absolute; left: 0; right: 0; top: 32px; z-index: 2; height: 46px; border-radius: 13px;
  background: linear-gradient(180deg, #67adff 0%, #2e78ea 100%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 5px 0 rgba(255, 255, 255, .26), 0 6px 0 #154aa8;
  transition: transform .62s var(--cg-ease), opacity .45s ease .12s;
}
.cg-rib { position: absolute; left: 50%; top: 0; bottom: 0; width: 28px; translate: -50% 0; background: linear-gradient(90deg, #c8901a 0%, var(--cg-gold) 42%, var(--cg-gold-2) 60%, #c8901a 100%); box-shadow: inset 0 0 0 2px rgba(133, 99, 29, .32); }
.cg-lid .cg-rib { border-radius: 4px; }
.cg-bow { position: absolute; left: 50%; bottom: 100%; width: 0; height: 0; z-index: 3; }
.cg-bow::before, .cg-bow::after {
  content: ''; position: absolute; bottom: -8px; width: 58px; height: 40px; box-sizing: border-box;
  border: 11px solid var(--cg-gold-2); border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), 0 3px 0 #c8901a;
}
.cg-bow::before { right: 4px; transform: rotate(-22deg); }
.cg-bow::after { left: 4px; transform: rotate(22deg); }
.cg-lid::after {   /* the knot */
  content: ''; position: absolute; left: 50%; top: -10px; width: 24px; height: 20px; translate: -50% 0; z-index: 4; border-radius: 9px;
  background: linear-gradient(180deg, var(--cg-gold) 0%, #d9a521 100%); box-shadow: 0 2px 0 #b88b2c;
}

/* ── opened ── */
.cg-ov.is-open .cg-box { animation: cg-pop .5s var(--cg-ease) both; cursor: default; }
.cg-ov.is-open .cg-glow { animation: none; opacity: 1; transform: scale(1.25); transition: transform .5s var(--cg-ease); }
.cg-ov.is-open .cg-lid { transform: translate(46px, -170px) rotate(36deg); opacity: 0; }
.cg-ov.is-open .cg-hint { display: none; }
.cg-ov.is-open .cg-scene { height: 200px; }
.cg-got { display: none; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.cg-ov.is-open .cg-got { display: flex; animation: cg-up .45s var(--cg-ease) .4s both; }
.cg-amt { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; }
.cg-amt img { width: 46px; height: 46px; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .2)); }
.cg-amt b { font: 800 clamp(46px, 13vw, 66px)/1 'Baloo 2', 'Noto Sans', sans-serif; color: #fff; text-shadow: 0 4px 0 var(--cg-gold-deep), 0 8px 18px rgba(0, 0, 0, .3); }
.cg-word { margin: 0; font: 800 20px/1 'Baloo 2', 'Noto Sans', sans-serif; color: #ffe8a3; letter-spacing: .01em; }
.cg-why { margin: 6px 0 2px; padding: 8px 18px; border-radius: 16px; background: rgba(255, 255, 255, .14); font: 800 21px/1.25 'Baloo 2', 'Noto Sans', sans-serif; color: #fff; }
.cg-acts { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(320px, 100%); margin-top: 10px; }
.cg-thanks, .cg-souk {
  display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 22px; border-radius: 999px; cursor: pointer;
  font: 800 22px/1 'Baloo 2', 'Noto Sans', sans-serif; text-decoration: none; transition: transform .12s var(--cg-ease);
}
.cg-thanks { border: 0; background: var(--cg-gold); color: var(--cg-rojo); box-shadow: 0 5px 0 var(--cg-gold-deep), 0 10px 20px rgba(0, 0, 0, .25); }
.cg-souk { min-height: 52px; border: 2px solid rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .08); color: #fff; font-size: 19px; }
.cg-thanks:active, .cg-souk:active, .cg-x:active { transform: scale(.96); }
.cg-thanks:focus-visible, .cg-souk:focus-visible, .cg-x:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ── the coins pill above the box, and the flying coins ── */
.cg-pill {
  position: fixed; z-index: 100002; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 8px; border-radius: 999px;
  background: #fffdf8; color: #5a1010; box-shadow: 0 3px 0 #b88b2c, 0 10px 22px rgba(0, 0, 0, .3);
  font: 800 20px/1 'Baloo 2', 'Noto Sans', sans-serif; pointer-events: none; white-space: nowrap;
  transform: scale(.6); opacity: 0; transition: transform .3s var(--cg-ease, cubic-bezier(.23, 1, .32, 1)), opacity .2s ease;
}
.cg-pill.is-in { transform: scale(1); opacity: 1; }
.cg-pill.is-top { left: 50%; top: max(14px, env(safe-area-inset-top)); translate: -50% 0; }
.cg-pill img { width: 28px; height: 28px; }
.cg-pill.is-bump { animation: cg-bump .32s cubic-bezier(.23, 1, .32, 1); }
.cg-coin { position: fixed; z-index: 100003; width: 34px; height: 34px; pointer-events: none; will-change: transform, opacity; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }

@keyframes cg-wobble {
  0%, 46%, 100% { transform: rotate(0) scale(1); }
  8% { transform: rotate(-7deg) scale(1.03); } 16% { transform: rotate(6deg) scale(1.03); } 24% { transform: rotate(-4deg); } 32% { transform: rotate(3deg); } 40% { transform: rotate(-1deg); }
}
@keyframes cg-pulse { 0%, 100% { opacity: .55; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes cg-pop { 0% { transform: scale(1); } 30% { transform: scale(1.14, .88); } 60% { transform: scale(.94, 1.06); } 100% { transform: scale(.9); } }
@keyframes cg-up { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cg-bump { 0% { transform: scale(1); } 40% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes cg-spin { to { rotate: 360deg; } }

/* a small phone (360×640): everything a little smaller, still one screen */
@media (max-width: 370px), (max-height: 680px) {
  .cg-scene { height: 206px; }
  .cg-ov.is-open .cg-scene { height: 168px; }
  .cg-box { width: 152px; height: 164px; }
  .cg-dra { width: 110px; max-height: 126px; }
  .cg-body { height: 100px; }
  .cg-lid { top: 28px; height: 40px; }
  .cg-thanks { min-height: 52px; font-size: 20px; }
  .cg-souk { min-height: 48px; font-size: 18px; }
  .cg-why { font-size: 19px; }
}

/* reduced motion: nothing wobbles, spins or flies (js/coin-gift.js shows the number at once) */
.cg-ov.is-calm, .cg-ov.is-calm * { animation: none !important; }
.cg-ov.is-calm .cg-lid { transition: opacity .2s ease; }
.cg-ov.is-calm.is-open .cg-lid { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .cg-ov, .cg-ov *, .cg-pill { animation: none !important; transition-duration: .01s !important; }
}

/* ── 🎁 2026-10-29 the parents' chest (js/coin-gift.js `is-chest`): the same box, opened the same way, drawn as a wooden
   treasure chest with gold bands and a clasp (no bow): the kid's homework opened it ── */
.cg-ov.is-chest .cg-body {
  background: linear-gradient(180deg, #b06c2e 0%, #8a4a1c 60%, #6b3612 100%);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .16), inset 0 7px 0 rgba(255, 255, 255, .14), 0 9px 0 #4e260b, 0 18px 26px rgba(0, 0, 0, .38);
}
.cg-ov.is-chest .cg-lid {
  border-radius: 40px 40px 10px 10px; height: 54px; top: 26px;
  background: linear-gradient(180deg, #c98140 0%, #93501f 100%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .16), inset 0 5px 0 rgba(255, 255, 255, .2), 0 6px 0 #4e260b;
}
.cg-ov.is-chest .cg-lid::after { display: none; }
.cg-ov.is-chest .cg-band, .cg-ov.is-chest .cg-lid::before {
  content: ''; position: absolute; left: 0; right: 0; height: 12px; background: linear-gradient(180deg, var(--cg-gold-2), #c8901a);
  box-shadow: inset 0 0 0 2px rgba(133, 99, 29, .35);
}
.cg-ov.is-chest .cg-band { top: 26px; }
.cg-ov.is-chest .cg-lid::before { bottom: 6px; }
.cg-ov.is-chest .cg-clasp {
  position: absolute; left: 50%; bottom: -14px; z-index: 3; width: 30px; height: 30px; translate: -50% 0; border-radius: 8px;
  background: linear-gradient(180deg, var(--cg-gold) 0%, #d9a521 100%); box-shadow: 0 3px 0 #85631d, inset 0 0 0 3px rgba(255, 255, 255, .25);
}
.cg-ov.is-chest .cg-clasp::after { content: ''; position: absolute; left: 50%; top: 9px; width: 8px; height: 12px; translate: -50% 0; border-radius: 4px; background: #5a3a08; }
