/* ==========================================================
   MỘC · Thiên nhiên + nút nhạc (tiền tố nt-)
   ========================================================== */

/* ---------- Lá rơi ---------- */
.nt-leaves {
  position: fixed; inset: 0; z-index: 80;
  width: 100vw; height: 100vh;
  pointer-events: none;
}

/* ---------- Bướm ---------- */
.nt-bf {
  --s: 26px;
  position: fixed; left: 0; top: 0; z-index: 80;
  width: var(--s); height: calc(var(--s) * .72);
  margin: calc(var(--s) * -.36) 0 0 calc(var(--s) * -.5);
  pointer-events: none;
  perspective: 140px;
  opacity: .95;
  will-change: transform;
}
.nt-bf-wing { position: absolute; top: 0; width: 50%; height: 100%; }
.nt-bf-wing svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1.5px 2px rgba(12, 46, 27, .22)); }
.nt-bf-wing--r { left: 50%; transform-origin: 0 50%; }
.nt-bf-wing--l { right: 50%; transform-origin: 100% 50%; }
.nt-bf-wing--l svg { transform: scaleX(-1); }
.nt-bf-body {
  position: absolute; left: 50%; top: -14%;
  width: calc(var(--s) * .22); height: 112%;
  transform: translateX(-50%);
  overflow: visible;
}

/* ---------- Chim ---------- */
.nt-flock { position: fixed; left: 0; top: 0; z-index: 80; width: 0; height: 0; pointer-events: none; }
.nt-bird {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 10px; margin: -5px 0 0 -11px;
  color: #0F5C30;
  will-change: transform;
}
.nt-bird svg {
  display: block; width: 100%; height: 100%; fill: currentColor; opacity: .82; overflow: visible;
  /* quầng sáng rất mảnh: chim xanh đậm vẫn đọc được trên ảnh tối ở hero */
  filter: drop-shadow(0 0 .7px rgba(255, 255, 255, .6));
}
/* nhịp vỗ / lượn do JS điều khiển (scaleY) */
.nt-bird-wings { transform-box: fill-box; transform-origin: 50% 55%; }

/* ---------- Chim sẻ đậu trên chữ MỘC ---------- */
.nt-sb {
  position: fixed; left: 0; top: 0; z-index: 81;
  width: 0; height: 0;
  pointer-events: none;
  visibility: hidden;
  transform-origin: 0 -10px;
  will-change: transform;
}
.nt-sb.is-on { visibility: visible; }
.nt-sb svg {
  position: absolute; left: -24px; top: -34px;
  width: 44px; height: 40px; overflow: visible;
  /* viền sáng mảnh + bóng nhẹ để chim nổi trên nền ảnh tối */
  filter: drop-shadow(0 0 .8px rgba(255, 255, 255, .55)) drop-shadow(0 1.5px 1.5px rgba(6, 30, 16, .45));
}
/* vùng bấm rất nhỏ quanh thân, chỉ bật khi chim đang đậu */
.nt-sb-hit {
  position: absolute; left: -9px; top: -21px;
  width: 18px; height: 16px; border-radius: 50%;
  pointer-events: none; cursor: pointer;
}
.nt-sb.is-perched .nt-sb-hit { pointer-events: auto; }

/* ---------- Dải cỏ (tranh grass.jpg, mép trên lượn sóng) ---------- */
.nt-host { isolation: isolate; }
.nt-grass {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: -1;
  height: clamp(56px, 6.5vw, 96px);
  pointer-events: none;
  background: url('/resources/book/grass.jpg') 50% 62% / cover no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 100' preserveAspectRatio='none'%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='1.4'/%3E%3C/filter%3E%3Cpath filter='url(%23b)' d='M-40 44 L0 44 C34 30 70 26 104 33 C128 38 140 30 166 24 C206 15 238 30 262 38 C286 46 308 34 336 27 C372 18 404 22 430 33 C452 42 470 44 496 34 C528 22 566 18 600 30 C616 36 628 42 640 44 L680 44 L680 100 L-40 100 Z'/%3E%3C/svg%3E") 0 0 / 640px 100% repeat-x;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 100' preserveAspectRatio='none'%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='1.4'/%3E%3C/filter%3E%3Cpath filter='url(%23b)' d='M-40 44 L0 44 C34 30 70 26 104 33 C128 38 140 30 166 24 C206 15 238 30 262 38 C286 46 308 34 336 27 C372 18 404 22 430 33 C452 42 470 44 496 34 C528 22 566 18 600 30 C616 36 628 42 640 44 L680 44 L680 100 L-40 100 Z'/%3E%3C/svg%3E") 0 0 / 640px 100% repeat-x;
}

/* ---------- Nút nhạc ---------- */
.nt-music {
  position: fixed; right: var(--gutter, 20px); bottom: 20px; z-index: 110;
  display: grid; place-items: center;
  width: 50px; height: 50px; padding: 0;
  border: 0; border-radius: 50%;
  background: #0F5C30; color: #FFFFFF;
  box-shadow: 0 10px 24px -10px rgba(12, 46, 27, .6), inset 0 0 0 1px rgba(255, 255, 255, .16);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: bottom .25s, background-color .3s, transform .3s cubic-bezier(.2, .7, .1, 1);
}
.nt-music:hover { background: #139E49; }
.nt-music:active { transform: scale(.93); }
.nt-music:focus-visible { outline: 3px solid #7CC242; outline-offset: 3px; }
.nt-music.is-playing { background: #139E49; }
.nt-music.is-playing:hover { background: #0F5C30; }
.nt-music svg { width: 24px; height: 24px; overflow: visible; }
.nt-music-speaker { fill: currentColor; }
.nt-music-waves { display: none; }
.nt-music.is-playing .nt-music-waves { display: inline; }
.nt-music.is-playing .nt-music-mute { display: none; }
.nt-music.is-playing .nt-music-w1 { animation: nt-wave 1.6s ease-in-out infinite; }
.nt-music.is-playing .nt-music-w2 { animation: nt-wave 1.6s ease-in-out -.4s infinite; }
@keyframes nt-wave { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.nt-music::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(19, 158, 73, .45);
  opacity: 0; pointer-events: none;
}
.nt-music.is-playing::after { animation: nt-ring 2.4s ease-out infinite; }
@keyframes nt-ring { 0% { opacity: .9; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.4); } }

@media (min-width: 900px) {
  .nt-music.is-near-back-top { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 767px) {
  .nt-grass { height: clamp(40px, 12vw, 60px); }
  .nt-music { right: 12px; bottom: 12px; width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .nt-music.is-playing::after,
  .nt-music.is-playing .nt-music-w1,
  .nt-music.is-playing .nt-music-w2 { animation: none; }
}
