/*
  SV Internet — kitten language mascot v2 (prototype).
  The kitten lives ON the page: transparent sprites, no plate or frame, a soft
  painted contact shadow, bottom-LEFT home with gentle wandering. Brand tokens
  mirror public-page-shell.css: dark oklch(0.17 0.015 50), gold oklch(0.80
  0.11 82), cream oklch(0.95 0.02 85).
*/

/* Tokens are declared on both roots: the panel is a sibling of the anchor. */
.rm-anchor,
.rm-banner {
  --rm-gold: oklch(0.80 0.11 82);
  --rm-gold-line: oklch(0.80 0.11 82 / 28%);
  --rm-gold-soft: oklch(0.80 0.11 82 / 12%);
  --rm-cream: oklch(0.95 0.02 85);
  --rm-muted: oklch(0.72 0.03 75);
  --rm-dark: oklch(0.17 0.015 50);
  --rm-warm-ink: oklch(0.42 0.07 45);
  --rm-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --rm-ease-spring: cubic-bezier(0.34, 1.45, 0.5, 1);
  --rm-safe-l: env(safe-area-inset-left, 0px);
  --rm-safe-b: env(safe-area-inset-bottom, 0px);
  font: 14px/1.4 Jost, "Segoe UI", Arial, sans-serif;
  color: var(--rm-cream);
}

.rm-anchor {
  position: fixed;
  /* Physical left on purpose: she must stay bottom-LEFT even under dir=rtl. */
  left: 0;
  bottom: calc(4px + var(--rm-safe-b));
  z-index: 70;
  pointer-events: none;
  opacity: 1;
  animation: rm-enter 0.7s var(--rm-ease-out) 0.35s both;
}

/* The rover is the wandering layer: JS translateX()s it along the floor. */
.rm-rover {
  position: relative;
  width: 158px;
  height: 196px;
  margin-left: calc(14px + var(--rm-safe-l));
  will-change: transform;
}
/* Walking glides linearly at step cadence; duration == GAIT_MS in the JS so
   each step completes exactly when the next gait frame swaps in. */
.rm-rover.rm-roaming { transition: transform 0.32s linear; }

/* ---------- Kitten button / scene ---------- */

.rm-robot-btn {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rm-robot-btn:focus-visible {
  outline: 2px solid var(--rm-gold);
  outline-offset: 5px;
  border-radius: 22px;
}

/* Painted contact shadow: soft ellipse that breathes with the poses. */
.rm-shadow {
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 62%;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0.16) 55%, transparent 72%);
  filter: blur(1.5px);
  transform: translateX(-50%);
  transition: width 0.45s var(--rm-ease-out), opacity 0.45s ease;
  pointer-events: none;
}
.rm-state-walk .rm-shadow { width: 52%; opacity: 0.78; }
.rm-state-sleep .rm-shadow {
  width: 82%;
  bottom: 10px;
  opacity: 0.55;
}

.rm-scene {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.rm-art {
  position: absolute;
  left: 50%;
  bottom: 12px;
  height: 158px;
  width: auto;
  max-width: none;
  opacity: 0;
  transform: translateX(-50%);
  /* Poses swap instantly, spritesheet-style: the breathe/bob animations and
     the rover glide carry the motion; cross-faded gait frames read as ghosts. */
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
  will-change: opacity;
}

/* Walk sprites face right by default; .rm-face-l mirrors them for the
   return leg. Sleep is a loaf and never flips. */
.rm-state-walk .rm-scene { transform-origin: 50% 100%; }
.rm-scene.rm-face-l .rm-art-walk1,
.rm-scene.rm-face-l .rm-art-walk2 { transform: translateX(-50%) scaleX(-1); }

/* The visible pose cross-fades in. */
.rm-state-sleep .rm-art-sleep,
.rm-state-sit   .rm-art-sit,
.rm-state-alert .rm-art-alert,
.rm-state-happy .rm-art-happy { opacity: 1; }

/* Walking: one gait frame per class, with a gentle step bob. */
.rm-state-walk.rm-gait-1 .rm-art-walk1,
.rm-state-walk.rm-gait-2 .rm-art-walk2 { opacity: 1; }
.rm-state-walk.rm-gait-1 .rm-scene { animation: rm-step-bob 0.36s ease-in-out; }
.rm-state-walk.rm-gait-2 .rm-scene { animation: rm-step-bob-b 0.36s ease-in-out; }

/* Pose geometry: loaf sits on the shadow; upright poses rise a touch. */
.rm-art-sleep { bottom: 18px; height: 104px; }
.rm-art-sit,
.rm-art-alert,
.rm-art-happy { height: 168px; }
.rm-art-walk1,
.rm-art-walk2 { height: 126px; bottom: 16px; }

.rm-state-sleep .rm-art-sleep { animation: rm-sleep-breathe 4.6s ease-in-out infinite; }
.rm-state-sit .rm-art-sit { animation: rm-idle-breathe 4.2s ease-in-out infinite; }
.rm-state-alert .rm-art-alert { animation: rm-alert-peek 2.4s ease-in-out infinite; }
.rm-state-happy .rm-art-happy { animation: rm-happy-hop 0.6s var(--rm-ease-spring); }

/* Sleeping "z z z" */
.rm-zzz { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.rm-z {
  position: absolute;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  color: var(--rm-warm-ink);
  opacity: 0;
}
/* The loaf's head rests on the right side of the curl. */
.rm-z1 { right: 26px; top: 30px; font-size: 15px; }
.rm-z2 { right: 42px; top: 20px; font-size: 19px; }
.rm-z3 { right: 58px; top: 10px; font-size: 23px; }
.rm-state-sleep .rm-z { animation: rm-z-float 3.4s ease-out infinite; }
.rm-state-sleep .rm-z2 { animation-delay: 1.1s; }
.rm-state-sleep .rm-z3 { animation-delay: 2.2s; }

/* "typing…" bubble shown right after a click */
.rm-typing {
  position: absolute;
  left: 10px;
  top: 6px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(6px) scale(0.8);
  transform-origin: 25% 100%;
  pointer-events: none;
  transition: opacity 0.22s var(--rm-ease-out), transform 0.22s var(--rm-ease-spring);
}
.rm-typing::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -6px;
  width: 13px;
  height: 13px;
  background: rgba(255, 255, 255, 0.96);
  transform: rotate(45deg);
  border-bottom-left-radius: 3px;
}
.rm-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: oklch(0.55 0.05 50);
}
.rm-typing.rm-on {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.rm-typing.rm-on .rm-typing-dot { animation: rm-typing-bounce 1s ease-in-out infinite; }
.rm-typing.rm-on .rm-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.rm-typing.rm-on .rm-typing-dot:nth-child(3) { animation-delay: 0.3s; }

/* Small "Languages" affordance on hover/focus (hidden while open). */
.rm-hint {
  position: absolute;
  left: 50%;
  top: -6px;
  z-index: 6;
  transform: translateX(-50%) translateY(4px);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--rm-gold-line);
  background: oklch(0.17 0.015 50 / 92%);
  color: var(--rm-gold);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s var(--rm-ease-out);
}
.rm-robot-btn:hover .rm-hint,
.rm-robot-btn:focus-visible .rm-hint,
.rm-state-alert .rm-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.rm-robot-btn.rm-open .rm-hint { opacity: 0; }

/* ---------- Language panel ---------- */

.rm-banner {
  pointer-events: auto;
  position: fixed;
  z-index: 71;
  left: 12px;
  bottom: 190px;
  width: min(300px, calc(100vw - 20px));
  padding: 16px 16px 14px;
  border: 1px solid var(--rm-gold-line);
  border-radius: 16px;
  background: linear-gradient(180deg, oklch(0.215 0.02 50), var(--rm-dark) 70%);
  color: var(--rm-cream);
  box-shadow:
    inset 0 1px 0 oklch(0.80 0.11 82 / 0.12),
    0 24px 60px -20px rgba(0, 0, 0, 0.8);
  overflow: visible;
  animation: rm-banner-in 0.28s var(--rm-ease-out) both;
}

.rm-banner.rm-closing { animation: rm-banner-out 0.18s ease-in both; }
.rm-banner[hidden] { display: none; }

/* Tail arrow tracks the kitten wherever she wandered (JS sets its left). */
.rm-banner-arrow {
  position: absolute;
  left: 60px;
  bottom: -7px;
  width: 13px;
  height: 13px;
  border-left: 1px solid var(--rm-gold-line);
  border-bottom: 1px solid var(--rm-gold-line);
  background: var(--rm-dark);
  transform: rotate(-45deg);
}

.rm-banner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.rm-banner-eyebrow {
  margin: 0 0 3px;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--rm-gold);
}

.rm-banner-title {
  margin: 0;
  font: 600 16.5px/1.25 Jost, "Segoe UI", Arial, sans-serif;
  color: var(--rm-cream);
}

.rm-banner-close {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin: -4px -4px 0 0;
  border: 1px solid var(--rm-gold-line);
  border-radius: 10px;
  background: transparent;
  color: var(--rm-cream);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s var(--rm-ease-spring);
}
.rm-banner-close:hover { background: var(--rm-gold-soft); color: var(--rm-gold); }
.rm-banner-close:active { transform: scale(0.92); }
.rm-banner-close:focus-visible,
.rm-lang-label:focus-within {
  outline: 2px solid var(--rm-gold);
  outline-offset: 2px;
}

/* Only the list region scrolls on short viewports, never the whole panel. */
.rm-banner-body {
  max-height: calc(100dvh - 280px - var(--rm-safe-b));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: oklch(0.8 0.11 82 / 0.45) transparent;
}
.rm-banner-body::-webkit-scrollbar { width: 8px; }
.rm-banner-body::-webkit-scrollbar-thumb {
  background: oklch(0.8 0.11 82 / 0.35);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.rm-lang-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-inline-size: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}

.rm-lang-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid oklch(0.8 0.11 82 / 18%);
  border-radius: 11px;
  background: transparent;
  color: var(--rm-cream);
  font-size: 14px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.18s var(--rm-ease-spring);
}
.rm-lang-label:hover { background: var(--rm-gold-soft); border-color: var(--rm-gold-line); }
.rm-lang-label:active { transform: scale(0.98); }

.rm-lang-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.rm-lang-dot {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--rm-gold-line);
  border-radius: 50%;
  transition: border-width 0.15s ease, border-color 0.2s ease;
}
.rm-lang-label input:checked + .rm-lang-dot { border: 4px solid var(--rm-gold); }
.rm-lang-label input:focus-visible ~ .rm-lang-dot { box-shadow: 0 0 0 2px var(--rm-dark), 0 0 0 4px var(--rm-gold); }
.rm-lang-label:has(input:checked) {
  border-color: var(--rm-gold);
  background: var(--rm-gold-soft);
}
.rm-lang-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.rm-banner-note {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid oklch(0.8 0.11 82 / 14%);
  font-size: 12px;
  line-height: 1.5;
  color: var(--rm-muted);
}

@keyframes rm-enter {
  from { opacity: 0; transform: translateY(14px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rm-sleep-breathe {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.025); }
}
@keyframes rm-idle-breathe {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(-1.5px) scale(1.015); }
}
@keyframes rm-alert-peek {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  45% { transform: translateX(-50%) translateY(-3px) rotate(-0.6deg); }
}
@keyframes rm-happy-hop {
  0% { transform: translateX(-50%) scale(0.94); }
  55% { transform: translateX(-50%) translateY(-7px) scale(1.05); }
  100% { transform: translateX(-50%) scale(1.01); }
}
@keyframes rm-step-bob {
  0% { transform: translateY(0); }
  40% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}
@keyframes rm-step-bob-b {
  0% { transform: translateY(0); }
  40% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}
@keyframes rm-z-float {
  0% { opacity: 0; transform: translate(0, 6px) scale(0.7) rotate(-8deg); }
  25% { opacity: 0.85; }
  100% { opacity: 0; transform: translate(-12px, -26px) scale(1.15) rotate(6deg); }
}
@keyframes rm-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@keyframes rm-banner-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rm-banner-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

@media (max-width: 480px) {
  .rm-rover {
    width: 126px;
    height: 158px;
    margin-left: calc(8px + var(--rm-safe-l));
  }
  .rm-art { height: 128px; bottom: 10px; }
  .rm-art-sleep { height: 84px; bottom: 14px; }
  .rm-art-sit,
  .rm-art-alert,
  .rm-art-happy { height: 136px; }
  .rm-art-walk1,
  .rm-art-walk2 { height: 102px; bottom: 14px; }
  .rm-shadow { height: 12px; }
  .rm-z1 { right: 20px; top: 26px; }
  .rm-z2 { right: 34px; top: 17px; }
  .rm-z3 { right: 48px; top: 8px; }
  .rm-banner { bottom: 160px; }
  .rm-banner-body { max-height: calc(100dvh - 250px - var(--rm-safe-b)); }
}

/*
  Editorial hero docking (mobile only).
  Her fixed bottom-left resting spot sits on top of the stacked call-to-action
  controls of tall editorial heroes at phone widths (homepage hero buttons,
  the SV Letter hero/join buttons). While those actions are inside her zone
  robot-mascot.js slides her just below the viewport and back to the resting
  spot once they scroll away (or the panel opens). Scoped to the listed body
  classes: other inner pages keep the bottom-left spot.
*/
@media (max-width: 600px) {
  body.home-v3 .rm-anchor,
  body.newsletter-page .rm-anchor {
    transition: bottom 0.45s var(--rm-ease-out);
  }
  body.home-v3 .rm-anchor.rm-dock-hidden,
  body.newsletter-page .rm-anchor.rm-dock-hidden {
    bottom: calc(-224px + var(--rm-safe-b));
    visibility: hidden;
    transition:
      bottom 0.45s var(--rm-ease-out),
      visibility 0s linear 0.45s;
  }
  body.home-v3 .rm-anchor.rm-dock-hidden .rm-robot-btn,
  body.newsletter-page .rm-anchor.rm-dock-hidden .rm-robot-btn {
    pointer-events: none;
  }
  /* The fixed right-edge contact dock shares her viewport stage; slide it
     out of the SV Letter's CTA zone with the same hot-state body class. */
  body.newsletter-page.rm-cta-zone .sv-support-launcher-dock {
    transform: translate(calc(100% + 20px), -50%);
    opacity: 0;
    pointer-events: none;
    transition:
      transform 0.45s var(--rm-ease-out),
      opacity 0.35s ease;
  }
}

@media (max-width: 600px) and (prefers-reduced-motion: reduce) {
  body.home-v3 .rm-anchor,
  body.home-v3 .rm-anchor.rm-dock-hidden,
  body.newsletter-page .rm-anchor,
  body.newsletter-page .rm-anchor.rm-dock-hidden {
    transition: none;
  }
  body.newsletter-page.rm-cta-zone .sv-support-launcher-dock {
    transition: none;
  }
}

/*
  Footer clearance (ALL pages, ALL widths). Once the footer scrolls into her
  bottom-left corner robot-mascot.js tags the body rm-footer-zone: she slides
  just below the viewport and the fixed right-edge contact dock slides off the
  right edge, so the footer columns and fine print stay fully readable.
  Scrolling away — or opening her panel — brings them straight back.
*/
.rm-anchor {
  transition: bottom 0.45s var(--rm-ease-out);
}
body.rm-footer-zone .rm-anchor {
  bottom: calc(-224px + var(--rm-safe-b));
  visibility: hidden;
  transition:
    bottom 0.45s var(--rm-ease-out),
    visibility 0s linear 0.45s;
}
body.rm-footer-zone .rm-anchor .rm-robot-btn {
  pointer-events: none;
}
body.rm-footer-zone .sv-support-launcher-dock {
  transform: translate(calc(100% + 20px), -50%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.45s var(--rm-ease-out),
    opacity 0.35s ease;
}
@media (prefers-reduced-motion: reduce) {
  .rm-anchor,
  body.rm-footer-zone .rm-anchor,
  body.rm-footer-zone .sv-support-launcher-dock {
    transition: none;
  }
}

/* Short, wide viewports (landscape phones): keep the widget compact. */
@media (max-height: 560px) and (min-width: 700px) {
  .rm-rover { width: 124px; height: 150px; }
  .rm-art { height: 120px; }
  .rm-art-sleep { height: 80px; }
  .rm-art-sit,
  .rm-art-alert,
  .rm-art-happy { height: 128px; }
  .rm-art-walk1,
  .rm-art-walk2 { height: 98px; }
  .rm-banner { bottom: 148px; }
  .rm-banner-body { max-height: calc(100dvh - 230px - var(--rm-safe-b)); }
}

@media (prefers-reduced-motion: reduce) {
  .rm-anchor { animation: none; }
  .rm-rover,
  .rm-rover.rm-roaming { transition: none; }
  .rm-state-sleep .rm-art-sleep,
  .rm-state-sit .rm-art-sit,
  .rm-state-alert .rm-art-alert,
  .rm-state-happy .rm-art-happy,
  .rm-state-walk.rm-gait-1 .rm-scene,
  .rm-state-walk.rm-gait-2 .rm-scene { animation: none; }
  .rm-z, .rm-typing-dot { animation: none; }
  .rm-banner,
  .rm-banner.rm-closing { animation: none; }
  .rm-robot-btn,
  .rm-art,
  .rm-typing,
  .rm-hint,
  .rm-lang-label,
  .rm-banner-close,
  .rm-lang-dot,
  .rm-shadow { transition: none; }
  .rm-z { display: none; }
}
