/* Jungle mode for the marketing site.
   Vine, firefly, and switch patterns adapted from the Puma AI waitlist.
   Light-mode chrome stays in styles.css. This file only themes and overlays. */

html.jungle {
  color-scheme: dark;
  --bg: #0b1f16;
  --bg-soft: #10281c;
  --ink: #f4eddc;
  --muted: #e6dcc8;
  --muted-2: #d4c9b4;
  --dim: #c3b7a3;
  --accent: #f4eddc;
  --rule: rgba(206, 224, 178, 0.22);
  --glass-fill: rgba(15, 39, 27, 0.62);
  --glass-fill-strong: rgba(8, 28, 19, 0.78);
  --glass-fill-tint: rgba(10, 34, 23, 0.9);
  --glass-edge: rgba(232, 224, 196, 0.3);
  --glass-edge-soft: rgba(232, 224, 196, 0.16);
  --glass-highlight:
    inset 0 1px 0 rgba(255, 248, 230, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28);
  --glass-shadow:
    0 16px 44px rgba(0, 0, 0, 0.38),
    0 2px 10px rgba(0, 0, 0, 0.28);
}

html.jungle,
html.jungle body {
  background-color: #0b1f16;
  background-image: none;
}

html.jungle body::before { opacity: 0; }

html.jungle a {
  text-decoration-color: rgba(244, 237, 220, 0.35);
}

body { position: relative; }

body,
.nav,
.hero-card,
.app-card,
.research-card,
.feature,
.vision-card,
.team-card,
.project-card,
.site-footer,
.jm .knob {
  transition:
    background-color 0.8s ease,
    color 0.8s ease,
    border-color 0.8s ease,
    box-shadow 0.8s ease;
}

/* Full-page canopy. Back foliage sits behind the copy; front vines cross the hero. */
.jungle-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: clip;
  pointer-events: none;
}

.jbg {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
  background:
    radial-gradient(1100px 760px at 72% 18%, #17402c 0%, rgba(23, 64, 44, 0) 62%),
    radial-gradient(900px 700px at 8% 88%, #143424 0%, rgba(20, 52, 36, 0) 60%),
    #0b1f16;
}
html.jungle .jbg { opacity: 1; }

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: clip;
  pointer-events: none;
}
.layer.back { z-index: 0; }
.fireflies {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
}
html.jungle .fireflies { opacity: 1; transition-delay: 1.2s; }
.layer.front { z-index: 4; }

.back .sway {
  transform-origin: 0 0;
  animation: vine-sway 8s ease-in-out infinite alternate;
  animation-play-state: paused;
}
html.jungle .back .sway { animation-play-state: running; }
@keyframes vine-sway {
  from { transform: rotate(-1.8deg); }
  to { transform: rotate(2deg); }
}

.fireflies i {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f2f8b0;
  box-shadow: 0 0 8px 3px rgba(222, 240, 120, 0.5);
  animation:
    firefly-drift var(--d) ease-in-out infinite alternate,
    firefly-glow var(--g) ease-in-out infinite;
  animation-play-state: paused;
}
html.jungle .fireflies i { animation-play-state: running; }
@keyframes firefly-drift {
  from { transform: translate(0, 0); }
  to { transform: translate(var(--x), var(--y)); }
}
@keyframes firefly-glow {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 1; }
}

/* Header switch — leaf + track. Hidden until script.js marks the nav enhanced,
   so the no-JS menu fallback keeps its current layout. */
html:not(.nav-enhanced) .jm { display: none; }

.jm {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  margin: 0;
  padding: 4px 2px 4px 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.jm::before {
  content: "";
  width: 1px;
  height: 22px;
  margin-right: 4px;
  background: var(--rule);
}
.jm:hover { color: var(--ink); }
.jm .leaf {
  width: 18px;
  height: 18px;
  flex: none;
  color: #3f8f45;
  transform-origin: 20% 80%;
}
html.jungle .jm .leaf { color: #9dce86; }
.jm .track {
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: #d6dbe2;
  position: relative;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.06);
  transition: background-color 0.45s ease, box-shadow 0.45s ease;
}
html.jungle .jm .track {
  background: #3d7a47;
  box-shadow: inset 0 0 0 1.5px rgba(244, 237, 220, 0.7);
}
.jm .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.45s cubic-bezier(0.5, 1.6, 0.4, 1), background-color 0.8s ease;
}
html.jungle .jm .knob {
  transform: translateX(18px);
  background: #f5eedd;
}
.jm:focus-visible {
  outline: 2px solid #5f9d57;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  html:not(.jungle) .jm .leaf {
    animation: leaf-nudge 3.2s ease-in-out 2.6s 2;
  }
}
@keyframes leaf-nudge {
  0%, 70%, 100% { transform: rotate(0); }
  78% { transform: rotate(-16deg); }
  88% { transform: rotate(10deg); }
}

/* Raster hero art (#puma and .sticker): no stroke draw-in. One click toggles. */
#puma,
.sticker {
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  z-index: 5;
}
html.jungle .hero-copy {
  text-shadow: 0 1px 18px rgba(6, 22, 14, 0.45);
}
html.jungle .sticker {
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
}

/* Readable glass on the dark canopy. */
html.jungle .hero-card,
html.jungle .app-card,
html.jungle .team-card,
html.jungle .research-card,
html.jungle .feature,
html.jungle .vision-card,
html.jungle .project-card,
html.jungle .platform-card,
html.jungle .about-grid section,
html.jungle .api-list section,
html.jungle .byline-card,
html.jungle .article-body blockquote,
html.jungle .note-box {
  background: rgba(10, 32, 22, 0.9);
  border-color: rgba(206, 224, 178, 0.2);
}
html.jungle .card::before,
html.jungle .hero-card::before,
html.jungle .app-card::before,
html.jungle .research-card::before {
  background: linear-gradient(135deg, rgba(255, 248, 230, 0.14) 0%, rgba(255, 248, 230, 0.04) 30%, transparent 50%);
}
html.jungle .research-card:hover,
html.jungle .feature:hover,
html.jungle .vision-card:hover,
html.jungle .project-card:hover {
  background: rgba(16, 46, 32, 0.94);
  border-color: rgba(232, 224, 196, 0.34);
}
html.jungle .site-footer,
html.jungle .backer-list {
  background: rgba(8, 26, 17, 0.62);
  border-color: rgba(206, 224, 178, 0.16);
}
html.jungle .article-body .backer-list {
  background: transparent;
  border-color: transparent;
}
html.jungle .nav-toggle {
  background: rgba(8, 26, 17, 0.5);
  border-color: rgba(206, 224, 178, 0.24);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 248, 230, 0.08);
}
html.jungle .nav-toggle:hover { background: rgba(16, 42, 29, 0.72); }
html.jungle .lang-switcher {
  background: rgba(8, 26, 17, 0.45);
  border-color: rgba(206, 224, 178, 0.22);
  box-shadow: none;
}
html.jungle .lang-switcher a[aria-current="true"],
html.jungle .lang-switcher a[aria-current="true"]:hover,
html.jungle .lang-switcher a[aria-current="true"]:focus-visible {
  color: #10251a;
  background: #f5eedd;
}
html.jungle .nav-cta,
html.jungle .primary {
  color: #10251a;
  background: #f5eedd;
  border-color: rgba(245, 238, 221, 0.45);
}
html.jungle .nav-cta:hover,
html.jungle .primary:hover {
  color: #10251a;
  background: #fff8ea;
}
html.jungle .ghost {
  color: var(--ink);
  background: var(--glass-fill);
  border-color: var(--glass-edge);
}
html.jungle .ghost:hover {
  color: var(--ink);
  background: rgba(16, 46, 32, 0.8);
  border-color: rgba(232, 224, 196, 0.4);
}
html.jungle .pill,
html.jungle .platform-list li,
html.jungle .title-with-link > a {
  background: rgba(8, 26, 17, 0.4);
  border-color: rgba(206, 224, 178, 0.2);
  color: var(--muted);
  box-shadow: none;
}
html.jungle .title-with-link > a:hover {
  color: #10251a;
  background: #f5eedd;
}
html.jungle .nav-links a:not(.nav-cta):hover,
html.jungle .nav-links a:not(.nav-cta):focus-visible {
  background: rgba(244, 237, 220, 0.08);
}
html.jungle .code-block {
  background: rgba(6, 18, 12, 0.92);
  border-color: rgba(206, 224, 178, 0.2);
}
html.jungle ::selection {
  background: rgba(212, 228, 106, 0.35);
  color: #f4eddc;
}

/* Desktop: switch trails the links. The nav can grow a little so the label fits. */
@media (min-width: 901px) {
  .nav-links,
  .brand-links { flex-wrap: wrap; }
  .nav-links a { white-space: nowrap; }
  .jm { order: 1; margin-left: 4px; flex-shrink: 0; }
}
@media (min-width: 901px) and (max-width: 1280px) {
  .nav-links { gap: 14px; }
}
@media (min-width: 901px) and (max-width: 1400px) {
  html[lang="ja"] .nav-links { gap: 12px; }
  html[lang="ja"] .brand-links { gap: 10px; }
}
@media (min-width: 1360px) {
  .site-header .nav { max-width: 1320px; }
}

@media (max-width: 1359px) {
  .jm .lbl {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .jm::before { display: none; }
}

@media (max-width: 900px) {
  .nav-bar { min-width: 0; }
  .logo {
    flex-shrink: 0;
    min-width: max-content;
  }
  .logo span {
    overflow: visible;
    text-overflow: clip;
  }
  .jm {
    margin-left: 0;
    padding-left: 0;
    gap: 6px;
    min-height: 44px;
    min-width: 44px;
    box-sizing: border-box;
  }
  .jm::before { display: none; }
  .jm .track { width: 40px; height: 24px; }
  .jm .knob { width: 18px; height: 18px; }
  html.jungle .jm .knob { transform: translateX(16px); }
}

@media (max-width: 600px) {
  #puma.sticker,
  .sticker { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .jbg,
  .fireflies,
  .jm .knob,
  body,
  .nav,
  .hero-card,
  .app-card,
  .research-card,
  .feature,
  .vision-card,
  .team-card,
  .project-card,
  .site-footer {
    transition: none !important;
  }
  .back .sway,
  .fireflies i,
  .jm .leaf {
    animation: none !important;
  }
  html.jungle .fireflies { transition-delay: 0s; }
  .fireflies i { opacity: 0.45; }
}
