/* Club app fun layer (js/fun.js): Today's 3, streak, December calendar,
   sticker book, level celebration, certificates, parents week panel.
   Loaded by app.html only. Same look as site.css: ink borders, offset shadows. */

/* ---------- Today's 3 + streak ---------- */
.daily-box {
  background: #fff; border: 3px solid var(--ink); border-radius: 24px; box-shadow: 6px 7px 0 var(--ink);
  padding: 18px; margin-bottom: 26px;
}
.daily-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.daily-head h2 { margin: 0; font-size: 1.5rem; text-align: left; }
.daily-head p { margin: 2px 0 0; color: var(--ink-soft); font-weight: 700; }
.streak-pill {
  background: var(--ink); color: #fff; font-weight: 800; border-radius: 999px; padding: 8px 14px;
  white-space: nowrap; font-size: 0.95rem;
}
.streak-pill.quiet { background: var(--purple-soft); color: var(--purple-dark); white-space: normal; }
.daily-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.daily-card {
  position: relative; display: flex; flex-direction: column; text-align: left; cursor: pointer;
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 18px; padding: 0; overflow: hidden;
  box-shadow: 4px 5px 0 var(--ink); font: inherit; color: var(--ink); min-height: 44px;
  transition: transform 0.12s ease;
}
.daily-card:nth-child(2) { background: var(--mint); }
.daily-card:nth-child(3) { background: #ffd2b8; }
.daily-card:hover { transform: translateY(-2px); }
.daily-card img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; display: block; border-bottom: 3px solid var(--ink); }
.daily-title { font-family: "Baloo 2", sans-serif; font-weight: 700; padding: 8px 10px; line-height: 1.15; font-size: 1rem; }
.daily-card.done img { filter: saturate(0.5); }
.daily-tick {
  position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--green); color: #fff; font-weight: 900; font-size: 1.3rem; border: 3px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- December calendar ---------- */
.cal-soon {
  display: flex; gap: 12px; align-items: center; background: #0f3d2e; color: #fff;
  border: 3px solid var(--ink); border-radius: 20px; padding: 14px 16px; margin-bottom: 22px;
  box-shadow: 6px 7px 0 var(--ink); font-weight: 600;
}
.cal-soon span { font-size: 2rem; }
.cal-box {
  background: radial-gradient(circle at 20% 0%, #1f6b50 0%, #0f3d2e 60%); color: #fff;
  border: 3px solid var(--ink); border-radius: 26px; padding: 18px; margin-bottom: 26px;
  box-shadow: 6px 7px 0 var(--ink); position: relative; overflow: hidden;
}
.cal-box::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: radial-gradient(#fff 1.2px, transparent 1.6px); background-size: 26px 26px;
}
.cal-head { position: relative; }
.cal-head h2 { color: #fff; margin: 0; font-size: 1.6rem; text-align: left; }
.cal-head p { margin: 2px 0 12px; font-weight: 700; color: #ffe9a8; }
.cal-grid { position: relative; display: grid; grid-template-columns: repeat(13, 1fr); gap: 8px; }
/* Door 25 is the big one: two columns on wide screens, a full row on phones. */
.cal-grid .door:last-child { grid-column: span 2; aspect-ratio: auto; background: linear-gradient(135deg, #ffc93c, #ff6b26); color: var(--ink); }
.cal-grid .door:last-child .door-num { text-shadow: none; }
.door {
  position: relative; aspect-ratio: 1; border-radius: 14px; border: 3px solid var(--ink);
  font: inherit; cursor: pointer; overflow: hidden; padding: 0; min-height: 44px;
  background: #c8332b; color: #fff; box-shadow: 3px 4px 0 var(--ink);
}
.door:nth-child(3n) { background: #e7a51a; }
.door:nth-child(4n) { background: #2a7de1; }
.door.shut { opacity: 0.55; cursor: default; box-shadow: none; }
.door.ready { animation: door-glow 1.6s ease-in-out infinite; }
.door.today { outline: 4px solid var(--gold); outline-offset: 2px; }
.door.open { background: #fff; }
.door img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.door-num {
  position: relative; font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.5rem;
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}
.door.open .door-num {
  position: absolute; top: 4px; left: 4px; font-size: 0.9rem; background: var(--ink); color: #fff;
  border-radius: 999px; padding: 0 7px; text-shadow: none;
}
@keyframes door-glow {
  0%, 100% { transform: translateY(0); box-shadow: 3px 4px 0 var(--ink), 0 0 0 0 rgba(255,201,60,0.8); }
  50% { transform: translateY(-3px); box-shadow: 3px 6px 0 var(--ink), 0 0 0 6px rgba(255,201,60,0); }
}

/* ---------- celebration ---------- */
.celebrate { position: fixed; inset: 0; z-index: 350; pointer-events: none; display: none; overflow: hidden; }
.celebrate.show { display: block; }
.celebrate i {
  position: absolute; top: -24px; border-radius: 3px; animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(.25,.6,.4,1); animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  from { transform: translateY(0) rotate(0deg); opacity: 1; }
  to { transform: translateY(105vh) rotate(var(--r)); opacity: 0.9; }
}
.cheer {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff;
  border: 3px solid var(--gold); border-radius: 26px; padding: 6px 20px 6px 6px; width: max-content;
  font-weight: 800; font-size: 1.05rem; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  max-width: calc(100vw - 32px); animation: cheer-pop 0.45s cubic-bezier(.2,1.6,.4,1) both;
}
.cheer-line { display: block; line-height: 1.25; }
.cheer img { width: 56px; height: 56px; border-radius: 50%; background: #fff; flex: none; }
.cheer.big { font-size: 1.2rem; padding-right: 24px; }
.cheer.big img { width: 72px; height: 72px; }
@keyframes cheer-pop { from { transform: translateX(-50%) scale(0.4); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ---------- sticker book ---------- */
.sticker-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sticker-hero h2 { text-align: left; margin-bottom: 4px; }
.sticker-hero p { margin: 0; color: var(--ink-soft); font-weight: 700; }
.sticker-count {
  flex: none; width: 104px; height: 104px; border-radius: 50%; background: var(--gold);
  border: 3px solid var(--ink); box-shadow: 4px 5px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.sticker-count b { font-family: "Baloo 2", sans-serif; font-size: 2.2rem; }
.sticker-count span { font-weight: 800; font-size: 0.85rem; }
.sticker-trail { margin: 26px 0 10px; font-size: 1.25rem; }
.sticker-trail small { color: var(--ink-soft); font-weight: 700; font-size: 0.95rem; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px; }
.sticker {
  background: none; border: none; padding: 4px; cursor: pointer; font: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 6px; border-radius: 16px;
}
.sticker .disc {
  position: relative; width: 92px; height: 92px; border-radius: 50%; overflow: hidden;
  border: 4px dashed #b9a8cc; background: #f3eefa; display: block;
}
.sticker .disc img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) opacity(0.35); }
.sticker .q {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 2rem; color: var(--purple-dark);
}
.sticker.got .disc {
  border: 4px solid #fff; box-shadow: 0 0 0 3px var(--ink), 3px 5px 0 3px var(--ink);
  transform: rotate(-4deg);
}
.sticker.got:nth-child(even) .disc { transform: rotate(5deg); }
.sticker.got .disc img { filter: none; }
.sticker .name { font-size: 0.8rem; font-weight: 700; text-align: center; line-height: 1.15; color: var(--ink-soft); }
.sticker.got .name { color: var(--ink); }

/* ---------- parents: this week, certificates ---------- */
.week-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.week-stat { background: var(--purple-soft); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; }
.week-stat b { font-family: "Baloo 2", sans-serif; font-size: 1.6rem; line-height: 1.1; }
.week-stat span { color: var(--ink-soft); font-weight: 700; font-size: 0.9rem; }
.cert-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 2px solid var(--purple-soft); }
.cert-row b { flex: 1; }
.cert-row.soon { color: var(--ink-soft); }
.cert-row small { font-weight: 800; }

/* ---------- small modal (calendar door) ---------- */
.fun-modal {
  position: fixed; inset: 0; z-index: 420; display: none; align-items: center; justify-content: center;
  background: rgba(26,16,51,0.7); padding: 16px;
}
.fun-modal.show { display: flex; }
.fun-modal .box {
  background: #fff; border: 3px solid var(--ink); border-radius: 28px; box-shadow: 8px 10px 0 var(--ink);
  padding: 24px; max-width: 420px; width: 100%; text-align: center;
}
.fun-modal h2 { margin: 10px 0 4px; }
.fun-kicker { margin: 0; font-weight: 800; color: var(--orange-dark); text-transform: uppercase; letter-spacing: 0.06em; }
.fun-modal-cover { width: 100%; height: auto; border-radius: 16px; border: 3px solid var(--ink); }
.fun-modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- certificate (print only) ---------- */
.print-area { display: none; }
@media print {
  @page { size: landscape; margin: 0.4in; }
  body > *:not(#printArea) { display: none !important; }
  body { background: #fff !important; }
  .print-area { display: block; }
  .cert {
    border: 10px solid #4b1f82; border-radius: 24px; padding: 10px; height: 7.2in; box-sizing: border-box;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .cert-inner {
    border: 4px solid #ffc93c; border-radius: 16px; height: 100%; box-sizing: border-box;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    position: relative; background: #fffaf0;
  }
  .cert-cat { width: 1.7in; height: 1.7in; border-radius: 50%; border: 4px solid #4b1f82; background: #fff; }
  .cert-kicker { font-family: "Baloo 2", sans-serif; font-size: 30pt; font-weight: 800; color: #4b1f82; margin: 10px 0 0; }
  .cert-small { font-size: 13pt; margin: 6px 0 0; color: #3a2b4a; }
  .cert-name { font-family: "Baloo 2", sans-serif; font-size: 46pt; margin: 4px 0; color: #cf4410; border-bottom: 3px solid #ffc93c; padding: 0 30px; }
  .cert-line { font-size: 16pt; font-weight: 700; margin: 8px 40px 0; color: #291840; }
  .cert-date { font-size: 12pt; margin: 14px 0 0; color: #3a2b4a; }
  .cert-club { font-family: "Baloo 2", sans-serif; font-size: 14pt; font-weight: 800; color: #4b1f82; margin: 2px 0 0; }
}

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .daily-grid { gap: 8px; }
  .daily-title { font-size: 0.85rem; padding: 6px 7px; }
  .daily-head h2, .cal-head h2 { font-size: 1.3rem; }
  .cal-grid { gap: 7px; grid-template-columns: repeat(6, 1fr); }
  .cal-grid .door:last-child { grid-column: 1 / -1; min-height: 52px; }
  .door-num { font-size: 1.2rem; }
  .sticker-count { width: 84px; height: 84px; }
  .sticker-count b { font-size: 1.7rem; }
  .sticker-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
  .sticker .disc { width: 78px; height: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  .door.ready { animation: none; }
  .cheer { animation: none; }
  .daily-card { transition: none; }
}

/* Five tabs (Stickers added) on the smallest phones: tighter tabs and star pill. */
@media (max-width: 420px) {
  .app-top .wrap { gap: 4px; }
  .tabs button { padding: 10px 3px; font-size: 0.74rem; min-height: 44px; }
  .kid-switch { gap: 4px; }
  .kid-switch img { width: 32px; height: 32px; }
  .star-balance { padding: 6px 7px; font-size: 0.84rem; }
}
@media (max-width: 350px) {
  .tabs button { white-space: normal; line-height: 1.1; padding: 6px 2px; font-size: 0.7rem; }
  .star-balance { padding: 5px 5px; font-size: 0.78rem; }
}
@media (max-width: 700px) {
  .skill-bar .top { flex-wrap: wrap; column-gap: 8px; }
  .skill-bar .top span:last-child { font-size: 0.85rem; color: var(--ink-soft); }
}
@media print {
  .cert-inner::before, .cert-inner::after {
    content: "★ ★ ★"; position: absolute; top: 18px; font-size: 22pt; color: #ffc93c; letter-spacing: 6px;
  }
  .cert-inner::before { left: 26px; }
  .cert-inner::after { right: 26px; }
}

/* ---------- free play: the grown-ups note ---------- */
.fun-modal-cat { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--ink); background: #f0e6ff; margin: 8px auto 0; display: block; }
.fun-small { font-size: 0.9rem; color: var(--ink-soft); font-weight: 700; margin: 6px 0 0; }

/* ---------- kids' home: grown-ups bar, cat goal (2026-11-16) ---------- */
.grownup-bar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #fff; border: 2px dashed var(--purple); border-radius: 16px;
  padding: 8px 10px 8px 14px; margin-bottom: 18px;
}
.grownup-bar p { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); line-height: 1.3; }
.grownup-bar b { color: var(--purple-dark); }
.grownup-bar .btn { flex: none; padding: 10px 16px; font-size: 0.9rem; min-height: 44px; box-shadow: none; background: var(--purple); color: #fff; border: 2px solid var(--ink); }
.cat-goal {
  display: flex; align-items: center; gap: 14px; background: var(--purple-soft);
  border: 3px solid var(--ink); border-radius: 22px; box-shadow: 6px 7px 0 var(--ink);
  padding: 12px 16px; margin-bottom: 26px;
}
.cat-goal img { width: 84px; height: 84px; flex: none; border-radius: 50%; background: #fff; border: 3px solid var(--ink); object-fit: cover; }
.cat-goal.ready { background: var(--yellow); }
.cat-goal-body { flex: 1; min-width: 0; }
.cat-goal-line { margin: 0 0 6px; font-family: "Baloo 2", sans-serif; font-size: 1.15rem; line-height: 1.2; color: var(--ink); }
.cat-goal-bar { height: 16px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; overflow: hidden; }
.cat-goal-bar span { display: block; height: 100%; background: var(--gold); }
.cat-goal-small { margin: 4px 0 0; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
.cat-goal .btn { min-height: 48px; }

/* ---------- tabs with pictures; a bottom bar on phones and tablets in portrait ---------- */
.tabs button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.tab-ico { font-size: 1.15rem; line-height: 1; }
.tabs .tab-parents { margin-left: 10px; opacity: 0.6; font-size: 0.9rem; }
@media (max-width: 700px) {
  body:has(.app-top) { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .app-top .brand { display: flex; align-items: center; gap: 8px; font-family: "Baloo 2", sans-serif; font-weight: 800; }
  .app-top .brand img { width: 40px; height: 40px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; margin: 0;
    display: grid; grid-template-columns: repeat(4, 1fr) 0.8fr; gap: 0;
    background: linear-gradient(160deg, #7130c4, #8a3ee0); border-top: 4px solid var(--gold);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tabs button, .tabs .tab-parents {
    flex-direction: column; justify-content: center; gap: 2px; min-height: 64px;
    padding: 4px 2px; margin: 0; border-radius: 16px; white-space: nowrap;
    font-size: 0.8rem; line-height: 1.1; opacity: 0.85;
  }
  .tab-ico { font-size: 1.7rem; }
  .tabs .tab-parents { opacity: 0.6; font-size: 0.72rem; }
  .tabs .tab-parents .tab-ico { font-size: 1.2rem; }
  .tabs button.active { opacity: 1; background: rgba(255,255,255,0.24); }
  .grownup-bar { padding: 6px 6px 6px 12px; gap: 8px; margin-bottom: 14px; }
  .grownup-bar p { font-size: 0.82rem; }
  .grownup-bar .btn { padding: 8px 12px; font-size: 0.82rem; }
  .cat-goal img { width: 68px; height: 68px; }
  .cat-goal-line { font-size: 1.02rem; }
}
@media (max-width: 380px) {
  .app-top .brand span { display: none; }
  .tabs button, .tabs .tab-parents { font-size: 0.72rem; }
}

/* ---------- gift boxes, rewards panel (2026-11-16) ---------- */
.gift-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  background: linear-gradient(135deg, #ffc93c, #ff9a3c); border: 3px solid var(--ink); border-radius: 22px;
  box-shadow: 6px 7px 0 var(--ink); padding: 12px 18px; margin-bottom: 22px; font: inherit; color: var(--ink); min-height: 72px;
}
.gift-card b { display: block; font-family: "Baloo 2", sans-serif; font-size: 1.3rem; line-height: 1.15; }
.gift-card span span { font-weight: 700; }
.gift-box { font-size: 2.8rem; line-height: 1; animation: gift-wiggle 1.6s ease-in-out infinite; }
.gift-open { font-size: 4.5rem; line-height: 1; margin: 6px 0; animation: gift-pop 0.5s ease-out; }
@keyframes gift-wiggle { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-12deg); } 84% { transform: rotate(12deg); } 92% { transform: rotate(-6deg); } }
@keyframes gift-pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .gift-box, .gift-open { animation: none; } }
.reward-cats { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; }
.reward-cats figure { margin: 0; text-align: center; width: 76px; }
.reward-cats img { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--ink); background: var(--purple-soft); object-fit: cover; }
.reward-cats figcaption { font-size: 0.78rem; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.reward-list { margin: 0 0 8px; padding-left: 20px; }
.reward-list li { margin: 3px 0; }
.reward-sfx { display: flex; align-items: center; gap: 10px; margin: 6px 0 0; font-weight: 700; }
.reward-sfx .small-btn { min-height: 44px; min-width: 64px; }
