/* ═════════════════════ CATERPILLAR AUDIO TOGGLE ═════════════════════
   Shared by the Stays and Village pages (same look as the home page).
   OFF = segments rest, dim. ON = segments wriggle in sequence and glow,
   antennae perk up, and the sound-wave bars dance. */
.cat {
  --cat-seg: #b7bf7b;         /* sage body */
  --cat-seg-on: #f3f59c;      /* butter when active */
  --cat-ease: cubic-bezier(0.22, 1, 0.36, 1);
  position: fixed;
  left: clamp(14px, 3vw, 28px);
  top: clamp(14px, 3vh, 24px);
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 12px;
  border: 1px solid rgba(245, 242, 216, 0.16);
  border-radius: 999px;
  background: rgba(23, 35, 26, 0.5);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  color: var(--cream);
  cursor: var(--cursor-butterfly), pointer;
  transition: transform 0.5s var(--cat-ease), box-shadow 0.5s, border-color 0.5s, background 0.5s, opacity 0.5s;
}
.cat:hover { transform: translateY(-3px); border-color: rgba(243, 245, 156, 0.4); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34); }
.cat:focus-visible { outline: 2px solid var(--butter); outline-offset: 3px; }

/* The body — a chain of segments on a slight arch */
.cat__body { display: inline-flex; align-items: center; gap: 3px; height: 26px; }
.cat__seg {
  position: relative;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--cat-seg) 75%, #fff), var(--cat-seg) 70%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.22);
  opacity: 0.6;
  transition: background 0.5s, opacity 0.5s, box-shadow 0.5s;
}
/* graduate the segments so the body tapers toward the tail */
.cat__seg:nth-child(2) { width: 14px; height: 14px; }
.cat__seg:nth-child(3) { width: 13px; height: 13px; }
.cat__seg:nth-child(4) { width: 12px; height: 12px; }
.cat__seg--tail { width: 9px !important; height: 9px !important; }

/* Head: bigger, with eyes + antennae */
.cat__seg--head {
  width: 19px;
  height: 19px;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--cat-seg) 70%, #fff), var(--cat-seg) 72%);
}
.cat__eye {
  position: absolute;
  top: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #17231a;
}
.cat__eye:nth-child(1) { left: 5px; }
.cat__eye:nth-child(2) { left: 11px; }
.cat__antenna {
  position: absolute;
  bottom: 13px;
  width: 1.5px;
  height: 7px;
  background: currentColor;
  border-radius: 2px;
  transform-origin: bottom center;
  opacity: 0.7;
  transition: transform 0.5s var(--cat-ease), opacity 0.5s;
}
.cat__antenna::after { content: ""; position: absolute; top: -3px; left: -1.5px; width: 4.5px; height: 4.5px; border-radius: 50%; background: var(--cat-seg-on); }
.cat__antenna:nth-child(3) { left: 4px; transform: rotate(-22deg); }
.cat__antenna:nth-child(4) { left: 13px; transform: rotate(22deg); }

/* Label + sound-wave bars */
.cat__label { display: inline-flex; align-items: center; gap: 9px; }
.cat__text {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(245, 242, 216, 0.72);
  transition: color 0.4s;
}
.cat__wave { display: inline-flex; align-items: center; gap: 2px; height: 16px; }
.cat__wave i {
  width: 2.5px;
  height: 5px;
  border-radius: 2px;
  background: rgba(245, 242, 216, 0.5);
  transition: background 0.4s;
}

/* ── ON state ─────────────────────────────────────────────── */
.cat.is-on { border-color: rgba(243, 245, 156, 0.4); }
.cat.is-on .cat__seg { background: radial-gradient(circle at 35% 30%, #fff, var(--cat-seg-on) 70%); opacity: 1; box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.18), 0 0 8px color-mix(in srgb, var(--cat-seg-on) 70%, transparent); }
.cat.is-on .cat__text { color: var(--butter); }
.cat.is-on .cat__wave i { background: var(--butter); }

/* wriggle: each segment bobs a touch after the one before it */
.cat.is-on .cat__seg { animation: catWriggle 1.1s ease-in-out infinite; }
.cat.is-on .cat__seg:nth-child(1) { animation-delay: 0s; }
.cat.is-on .cat__seg:nth-child(2) { animation-delay: 0.09s; }
.cat.is-on .cat__seg:nth-child(3) { animation-delay: 0.18s; }
.cat.is-on .cat__seg:nth-child(4) { animation-delay: 0.27s; }
.cat.is-on .cat__seg:nth-child(5) { animation-delay: 0.36s; }
.cat.is-on .cat__seg:nth-child(6) { animation-delay: 0.45s; }
@keyframes catWriggle { 50% { transform: translateY(-5px); } }

/* antennae perk up and wobble */
.cat.is-on .cat__antenna { opacity: 1; }
.cat.is-on .cat__antenna:nth-child(3) { animation: catAntL 1.1s ease-in-out infinite; }
.cat.is-on .cat__antenna:nth-child(4) { animation: catAntR 1.1s ease-in-out infinite; }
@keyframes catAntL { 50% { transform: rotate(-34deg); } }
@keyframes catAntR { 50% { transform: rotate(34deg); } }

/* sound-wave bars dance */
.cat.is-on .cat__wave i:nth-child(1) { animation: catBar 0.7s ease-in-out infinite; }
.cat.is-on .cat__wave i:nth-child(2) { animation: catBar 0.7s ease-in-out infinite 0.12s; }
.cat.is-on .cat__wave i:nth-child(3) { animation: catBar 0.7s ease-in-out infinite 0.24s; }
.cat.is-on .cat__wave i:nth-child(4) { animation: catBar 0.7s ease-in-out infinite 0.36s; }
@keyframes catBar { 0%, 100% { height: 4px; } 50% { height: 14px; } }

/* Hidden until the page has loaded; fades out again once the hero scrolls away */
.cat { opacity: 0; transform: translateY(-16px); pointer-events: none; }
.is-ready .cat { opacity: 1; transform: none; pointer-events: auto; }
.is-ready .cat:hover { transform: translateY(-3px); }
.is-ready .cat.cat--hidden { opacity: 0; transform: translateY(-16px); pointer-events: none; }

/* ── Phones / tablets: smaller, sits just below the nav, on the left ── */
@media (max-width: 860px) {
  .cat { top: 66px; left: 10px; right: auto; bottom: auto; gap: 8px; padding: 7px 12px 7px 9px; }
  .cat__body { gap: 2px; height: 20px; }
  .cat__body .cat__seg { width: 12px; height: 12px; }
  .cat__body .cat__seg:nth-child(2) { width: 11px; height: 11px; }
  .cat__body .cat__seg:nth-child(3) { width: 10px; height: 10px; }
  .cat__body .cat__seg:nth-child(4) { width: 10px; height: 10px; }
  .cat__body .cat__seg--head { width: 14px; height: 14px; }
  .cat__eye { top: 5px; width: 2.5px; height: 2.5px; }
  .cat__eye:nth-child(1) { left: 4px; }
  .cat__eye:nth-child(2) { left: 8px; }
  .cat__antenna { height: 6px; bottom: 10px; }
  .cat__label { gap: 6px; }
  .cat__text { font-size: 10px; letter-spacing: 0.14em; }
  .cat__wave { height: 12px; }
  .cat__wave i { width: 2px; }
}
@media (max-width: 560px) {
  .cat { top: 62px; left: 10px; right: auto; gap: 6px; padding: 6px 10px 6px 8px; }
  .cat__body { height: 17px; gap: 2px; }
  .cat__body .cat__seg { width: 10px; height: 10px; }
  .cat__body .cat__seg:nth-child(2) { width: 9px; height: 9px; }
  .cat__body .cat__seg:nth-child(3) { width: 9px; height: 9px; }
  .cat__body .cat__seg:nth-child(4) { width: 8px; height: 8px; }
  .cat__body .cat__seg--head { width: 12px; height: 12px; }
  .cat__text { font-size: 9px; letter-spacing: 0.12em; }
  .cat__wave { height: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .cat, .cat__seg, .cat__antenna, .cat__wave i { transition: none; animation: none !important; }
}
