/* The Code Nights pet's play styles, shared by /code/nights and the /code landing page
   (code-pet.js). Plain CSS, no Tailwind rebuild. Colours fall back when a page does not
   define the night palette. */
.cn, .cp-corner, .cn-adopt { --cn-ink: #f4f1ff; --cn-soft: #c9c3ec; --cn-muted: #9a93c7; --cn-line: rgba(196, 186, 255, 0.18); --cn-gold: #ffd166; --cn-pink: #ff8fb1; }
@keyframes cn-wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-6deg); } 86% { transform: rotate(6deg); } 94% { transform: rotate(-3deg); } }

/* Playing with the pet: the canvas sits in a button (tap = pat); actions animate the
   wrapper so they never fight the mood animation on the canvas itself. */
.cn-pet-body { display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 1.2rem; background: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cn-pet-body:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.cn-pet-body.do-hop { animation: cn-hop .6s ease-out; }
.cn-pet-body.do-wobble { animation: cn-wobble 0.9s ease-in-out; transform-origin: 50% 90%; }
.cn-pet-body.do-shake { animation: cn-shake .7s ease-in-out; }
.cn-pet-body.do-chomp { animation: cn-chomp .7s ease-in-out; }
.cn-pet-body.do-dizzy { animation: cn-dizzy 1.6s ease-in-out; }
.cn-pet-body.do-wave { animation: cn-wave 1.2s ease-in-out; transform-origin: 50% 90%; }
.cn-pet-body.do-jump { animation: cn-jump3 1.2s ease-in-out; }
.cn-pet-body.do-spin { animation: cn-spin 1.2s ease-in-out; }
.cn-pet-body.do-dance { animation: cn-dance 1.8s ease-in-out; transform-origin: 50% 90%; }
.cn-pet-body.do-star { animation: cn-star 1.8s ease-in-out; }
@keyframes cn-hop { 0% { transform: translateY(0) scale(1, 1); } 25% { transform: translateY(0) scale(1.1, .9); } 55% { transform: translateY(-22px) scale(.95, 1.05); } 100% { transform: translateY(0) scale(1, 1); } }
@keyframes cn-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes cn-chomp { 0%, 100% { transform: scale(1, 1); } 25%, 75% { transform: scale(1.08, .92); } 50% { transform: scale(.96, 1.04); } }
@keyframes cn-dizzy { 0% { transform: rotate(0); } 25% { transform: rotate(14deg) translateX(6px); } 50% { transform: rotate(-14deg) translateX(-6px); } 75% { transform: rotate(8deg); } 100% { transform: rotate(0); } }
@keyframes cn-wave { 0%, 100% { transform: rotate(0); } 15%, 45%, 75% { transform: rotate(-10deg); } 30%, 60%, 90% { transform: rotate(10deg); } }
@keyframes cn-jump3 { 0%, 33%, 66%, 100% { transform: translateY(0); } 16%, 50%, 83% { transform: translateY(-26px); } }
@keyframes cn-spin { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }
@keyframes cn-dance { 0%, 100% { transform: translateX(0) rotate(0); } 20% { transform: translateX(-16px) rotate(-10deg); } 40% { transform: translateX(16px) rotate(10deg); } 60% { transform: translateX(-16px) rotate(-10deg) translateY(-10px); } 80% { transform: translateX(16px) rotate(10deg); } }
@keyframes cn-star { 0% { transform: translateY(0) scale(1); filter: none; } 40% { transform: translateY(-34px) scale(1.12); filter: drop-shadow(0 0 22px rgba(255, 209, 102, .9)); } 100% { transform: translateY(0) scale(1); filter: none; } }
.cn-fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.cn-fx span { position: absolute; bottom: 45%; color: var(--cn-pink); font-size: 1.4rem; font-weight: 800; opacity: 0; animation: cn-float 1.3s ease-out forwards; }
@keyframes cn-float { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--drift, 0), -90px) scale(1.15); } }
.cn-fx .cn-treat { left: calc(50% - 1rem); bottom: auto; top: -1rem; color: inherit; font-size: 2rem; animation: cn-drop .7s cubic-bezier(.5, 0, .9, .6) forwards; }
@keyframes cn-drop { 0% { opacity: 0; transform: translateY(0) rotate(0); } 15% { opacity: 1; } 85% { opacity: 1; transform: translateY(5.5rem) rotate(240deg) scale(.8); } 100% { opacity: 0; transform: translateY(6rem) rotate(260deg) scale(.3); } }
.cn-bubble.is-pop, .cp-say.is-pop { animation: cn-pop .3s ease-out; }
@keyframes cn-pop { 0% { transform: scale(.85); } 70% { transform: scale(1.05); } 100% { transform: scale(1); } }
.cn-hearts { display: flex; justify-content: center; gap: .2rem; margin: .1rem 0 .4rem; font-size: 1.25rem; line-height: 1; }
.cn-hearts span { color: rgba(255, 255, 255, .18); transition: color .3s; }
.cn-hearts span.is-full { color: var(--cn-pink); }
.cn-hearts span.is-new { animation: cn-hop .6s ease-out; }
.cn-play { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin: 0 0 .7rem; }
.cn-play button {
  display: inline-flex; align-items: center; gap: .3rem; min-height: 2.5rem; padding: .4rem .7rem; border: 1px solid var(--cn-line);
  border-radius: 999px; background: rgba(255, 255, 255, .06); color: var(--cn-ink); font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.cn-play button:hover { border-color: rgba(255, 209, 102, .6); background: rgba(255, 209, 102, .1); }
.cn-play button:active { transform: scale(.95); }
.cn-play button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.cn-play small { padding: 0 .4rem; border-radius: 999px; background: rgba(255, 209, 102, .2); color: var(--cn-gold); font-size: .75rem; }
@media (prefers-reduced-motion: reduce) { .cn-pet-body, .cn-fx span, .cn-bubble.is-pop, .cp-say.is-pop, .cn-hearts span { animation: none !important; } }

/* /code landing: the same pet in its own little night-sky habitat (moon, stars, a hill to
   stand on) beside its words and the 30-night path; stays a night card in the light theme too. */
.cp-corner {
  position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 1.4rem; align-items: center;
  margin: 0 0 2rem; padding: 1.1rem 1.5rem 1.1rem 1.1rem; border: 1px solid rgba(255, 209, 102, .32); border-radius: 1.25rem;
  background:
    radial-gradient(1.5px 1.5px at 58% 18%, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1px 1px at 74% 82%, rgba(255, 255, 255, .5), transparent),
    radial-gradient(1.5px 1.5px at 92% 12%, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1px 1px at 40% 90%, rgba(255, 255, 255, .4), transparent),
    radial-gradient(90% 140% at 100% 0%, rgba(255, 143, 177, .14), transparent 60%),
    linear-gradient(125deg, #0b0b26 0%, #1b1550 55%, #3a1d63 100%);
  box-shadow: 0 18px 40px -26px rgba(124, 92, 255, .7), inset 0 1px rgba(255, 255, 255, .07);
  color: var(--cn-ink);
}
/* The habitat: a framed sky with a crescent moon, and a hill the pet stands on. */
.cp-pet {
  position: relative; isolation: isolate; overflow: hidden; display: grid; place-items: end center; aspect-ratio: 1; width: 100%; padding-bottom: 1.1rem;
  border: 1px solid rgba(196, 181, 253, .28); border-radius: 1rem;
  background:
    radial-gradient(1.5px 1.5px at 18% 22%, #fff, transparent), radial-gradient(1px 1px at 34% 12%, rgba(255, 255, 255, .8), transparent),
    radial-gradient(1px 1px at 62% 30%, rgba(255, 255, 255, .7), transparent), radial-gradient(1.5px 1.5px at 12% 48%, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1px 1px at 88% 52%, rgba(255, 255, 255, .6), transparent),
    radial-gradient(70% 55% at 50% 62%, rgba(167, 139, 250, .3), transparent 70%),
    linear-gradient(180deg, #0a0a2a 0%, #241a5e 70%, #3b2470 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04), 0 10px 24px -14px rgba(0, 0, 0, .8);
}
.cp-pet::before {   /* crescent moon */
  content: ""; position: absolute; z-index: -1; top: .7rem; right: .8rem; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  box-shadow: inset -.5rem .3rem 0 0 #ffe7a8; filter: drop-shadow(0 0 8px rgba(255, 209, 102, .55)); transform: rotate(-12deg); pointer-events: none;
}
.cp-pet::after {    /* the hill */
  content: ""; position: absolute; z-index: -1; left: -15%; right: -15%; bottom: -38%; height: 62%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 0%, #6a54b8 0%, #3a2a7a 40%, #1d1648 75%); box-shadow: 0 -2px 0 rgba(196, 181, 253, .6), 0 -10px 22px -8px rgba(167, 139, 250, .45); pointer-events: none;
}
.cp-pet .cn-pet-body { position: relative; z-index: 1; }
.cp-pet .cn-pet-canvas { width: 150px; height: 150px; image-rendering: pixelated; }
.cp-pet .cn-fx { inset: 0; z-index: 2; }
.cp-pet .cn-fx .cn-treat { top: .2rem; }
.cp-side { display: grid; gap: .75rem; min-width: 0; }
.cp-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; margin: 0; }
.cp-head strong { font-size: 1.4rem; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; color: #fff; }
.cp-head span {
  padding: .12rem .6rem; border: 1px solid rgba(255, 209, 102, .4); border-radius: 999px; background: rgba(255, 209, 102, .1);
  color: #ffe7a8; font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.cp-say {
  position: relative; justify-self: start; max-width: 38rem; margin: 0; padding: .6rem .95rem; border-radius: 1rem;
  background: #fff; color: #24133f; font-size: .95rem; font-weight: 600; line-height: 1.45; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .7);
}
.cp-say::before { content: ""; position: absolute; left: -7px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-left: 0; border-right-color: #fff; }
/* The 30-night path: one pip per night, finished ones gold, the next one glowing. */
.cp-track { display: grid; gap: .35rem; max-width: 38rem; }
.cp-track-head { display: flex; justify-content: space-between; margin: 0; color: #cbd5e1; font-size: .8rem; font-weight: 700; }
.cp-track-head b { color: #ffe7a8; font-variant-numeric: tabular-nums; }
.cp-pips { display: flex; gap: 3px; margin: 0; padding: 0; list-style: none; }
.cp-pips li { flex: 1; height: .55rem; border-radius: 999px; background: rgba(255, 255, 255, .13); }
.cp-pips li:nth-child(10n) { margin-right: 4px; }
.cp-pips li:last-child { margin-right: 0; }
.cp-pips li.is-done { background: linear-gradient(180deg, #ffe08a, #ffb347); }
.cp-pips li.is-next { background: rgba(255, 209, 102, .35); box-shadow: 0 0 0 1.5px #ffd166, 0 0 10px rgba(255, 209, 102, .7); animation: cp-glow 1.8s ease-in-out 4; }   /* plays on arrival, then rests (motion budget) */
@keyframes cp-glow { 50% { box-shadow: 0 0 0 1.5px #ffd166, 0 0 2px rgba(255, 209, 102, .2); } }
.cp-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.cp-row .cn-hearts { margin: 0; font-size: 1.05rem; }
.cp-row .cn-play { margin: 0; justify-content: flex-start; }
.cp-row .cn-play button { min-height: 2.2rem; padding: .3rem .7rem; font-size: .82rem; }
.cp-cta {
  justify-self: start; display: inline-flex; align-items: center; gap: .4rem; min-height: 2.75rem; padding: .55rem 1.2rem; border-radius: .85rem;
  background: linear-gradient(135deg, var(--cn-gold), #ffb347); color: #24133f; font-size: .98rem; font-weight: 800; text-decoration: none;
  box-shadow: 0 6px 22px rgba(255, 179, 71, .3); transition: transform .15s, box-shadow .15s;
}
.cp-cta:hover, .cp-cta:focus-visible { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(255, 179, 71, .45); outline: none; }
.cp-cta:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.cp-corner[data-mood="sleepy"] .cn-pet-canvas { opacity: .8; }
.cp-corner.is-unadopted .cp-row { display: none; }
@media (prefers-reduced-motion: reduce) { .cp-cta { transition: none; } .cp-cta:hover { transform: none; } .cp-pips li.is-next { animation: none; } }
/* Phones: the habitat beside the heading; bubble, path and buttons full width below. */
@media (max-width: 560px) {
  .cp-corner { grid-template-columns: 8rem minmax(0, 1fr); gap: .8rem .9rem; padding: .9rem 1rem 1rem; }
  .cp-side { display: contents; }
  .cp-pet { grid-row: 1; padding-bottom: .55rem; }
  .cp-pet::before { top: .45rem; right: .5rem; width: 1.2rem; height: 1.2rem; box-shadow: inset -.32rem .2rem 0 0 #ffe7a8; }
  .cp-pet .cn-pet-canvas { width: 96px; height: 96px; }
  .cp-head { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-start; }
  .cp-head strong { font-size: 1.2rem; }
  .cp-say, .cp-track, .cp-row, .cp-cta, .cp-class { grid-column: 1 / -1; }
  .cp-say { justify-self: stretch; max-width: none; }
  .cp-say::before { left: 3.6rem; top: -7px; margin-top: 0; border: 7px solid transparent; border-top: 0; border-bottom-color: #fff; }
  .cp-pips { gap: 2px; }
  .cp-pips li:nth-child(10n) { margin-right: 3px; }
  .cp-cta { justify-self: stretch; justify-content: center; }
}
/* Right-to-left pages: the habitat's moon and the bubble's tail swap sides. */
[dir="rtl"] .cp-corner { padding: 1.1rem 1.1rem 1.1rem 1.5rem; }
[dir="rtl"] .cp-pet::before { right: auto; left: .8rem; transform: scaleX(-1) rotate(-12deg); }
[dir="rtl"] .cp-say::before { left: auto; right: -7px; border: 7px solid transparent; border-right: 0; border-left-color: #fff; }
[dir="rtl"] .cp-pips li:nth-child(10n) { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .cp-pips li:last-child { margin-left: 0; }
@media (max-width: 560px) {
  [dir="rtl"] .cp-corner { padding: .9rem 1rem 1rem; }
  [dir="rtl"] .cp-pet::before { left: .5rem; }
  [dir="rtl"] .cp-say::before { right: 3.6rem; left: auto; border: 7px solid transparent; border-top: 0; border-bottom-color: #fff; }
}

/* Class pet (code-pet.js mountClassPets): counts for the learner's teacher group, no names. */
.cp-class { display: grid; gap: .5rem; width: 100%; margin-top: .75rem; }
.cp-class[hidden] { display: none; }
.cp-class-card { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: .9rem; border: 1px solid rgba(255, 209, 102, .3); background: rgba(255, 209, 102, .07); text-align: left; }
.cp-class-card canvas { width: 56px; height: 56px; flex: none; image-rendering: pixelated; }
.cp-class-card p { margin: 0; }
.cp-class-title { color: #ffd166; font-size: .78rem; font-weight: 700; letter-spacing: .02em; }
.cp-class-week { color: #f8fafc; font-weight: 700; font-size: .95rem; }
.cp-class-meta { color: #cbd5e1; font-size: .82rem; }
html[data-theme="light"] .cp-class-card { background: rgba(180, 130, 20, .08); border-color: rgba(180, 130, 20, .35); }
html[data-theme="light"] .cp-class-title { color: #8a5a00; }
html[data-theme="light"] .cp-class-week { color: #1e1b4b; }
html[data-theme="light"] .cp-class-meta { color: #334155; }

/* Choose or change the pet (shared dialog, code/_pet_adopt.html): /code/nights and the /code corner. */
.cn-start {
  display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.25rem; border: 0; border-radius: .85rem;
  background: linear-gradient(135deg, var(--cn-gold), #ffb347); color: #24133f; font-weight: 800; font-size: 1rem;
  text-decoration: none; cursor: pointer; box-shadow: 0 6px 22px rgba(255, 179, 71, .3); transition: transform .15s, box-shadow .15s;
}
.cn-start:hover, .cn-start:focus-visible { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(255, 179, 71, .45); outline: none; }
.cn-start:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.cn-link { margin-left: .35rem; padding: 0; border: 0; background: none; color: var(--cn-muted); font-size: .8rem; font-weight: 600; text-decoration: underline; cursor: pointer; }
.cn-link:hover { color: var(--cn-ink); }
.cn-adopt { width: min(34rem, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--cn-line, rgba(196,186,255,.18)); border-radius: 1.25rem; background: linear-gradient(170deg, #14123a, #2a1a55); color: #f4f1ff; }
.cn-adopt::backdrop { background: rgba(6, 6, 20, .7); }
.cn-adopt-form { display: grid; gap: .9rem; padding: 1.4rem; text-align: center; }
.cn-adopt h2 { margin: 0; font-size: 1.4rem; font-weight: 800; color: #f4f1ff; }
.cn-adopt p { margin: 0; color: #c9c3ec; }
.cn-adopt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.cn-adopt-card { display: grid; justify-items: center; gap: .2rem; padding: .7rem .4rem; border: 2px solid rgba(196,186,255,.18); border-radius: 1rem; background: rgba(255,255,255,.04); cursor: pointer; }
.cn-adopt-card input { position: absolute; opacity: 0; pointer-events: none; }
.cn-adopt-card:has(input:checked) { border-color: #ffd166; background: rgba(255, 209, 102, .1); }
.cn-adopt-card:has(input:focus-visible) { box-shadow: 0 0 0 3px #fff; }
.cn-adopt-card canvas { width: 84px; height: 84px; image-rendering: pixelated; }
.cn-adopt-card strong { font-size: 1rem; }
.cn-adopt-card span { color: #9a93c7; font-size: .76rem; line-height: 1.3; }
.cn-adopt-name { display: grid; gap: .3rem; color: #c9c3ec; font-size: .9rem; text-align: left; }
.cn-adopt-name input { padding: .55rem .75rem; border: 1px solid rgba(196,186,255,.3); border-radius: .7rem; background: rgba(0,0,0,.25); color: #fff; font-size: 1rem; }
.cn-adopt .cn-start { justify-self: center; }
.cp-head .cn-link { margin-left: 0; }
