/* gloop.live: no-WebGL fallback (see js/nogl.js). Self-contained; reuses the
   custom properties from gloop.css (colours, --mono/--font) and the IBM Plex
   faces declared in css/fonts.css (Mono = main UI face); doesn't load fonts.
   CSP-safe: no inline styles/scripts are created by nogl.js.
   Stacking: .nogl-screen (200) sits above intro.css (64/65), egg.css (57-59),
   gloop.css #gl-fallback (60) and a11y.css (45). */

/* When nogl.js is live, show the game UI instead of world.js's plain
   full-screen #gl-fallback card (that card stays as the no-nogl.js fallback). */
html.nogl-live .stage { visibility: visible; }
html.nogl-live #gl-fallback { display: none !important; }

/* ---- flat 2D map over the (blank) 3D canvas -------------------------------- */
.nogl-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none; /* clicks/drag still reach #body underneath */
  z-index: 0;
}
.nogl-map[hidden], .nogl-notice[hidden], .nogl-screen[hidden] { display: none !important; }

/* ---- branded screen --------------------------------------------------------- */
.nogl-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  overflow-y: auto;
  background:
    radial-gradient(90% 70% at 50% 18%, rgba(185, 245, 180, 0.09), transparent 60%),
    radial-gradient(120% 80% at 50% 0%, rgba(13, 19, 28, 0.9) 0%, rgba(6, 8, 11, 0.94) 65%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--ink, #ece6da);
  font-family: "IBM Plex Mono", var(--mono, ui-monospace, monospace);
}
.nogl-bubbles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.nogl-card {
  position: relative;
  width: min(540px, 100%);
  margin: auto;
  padding: 1.3rem 1.5rem 1.2rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(16, 22, 31, 0.9), rgba(8, 11, 16, 0.94));
  border: 1px solid var(--line, rgba(236, 230, 218, 0.1));
  box-shadow: 0 0 0 1px rgba(185, 245, 180, 0.05), 0 28px 70px rgba(0, 0, 0, 0.55), 0 0 60px rgba(185, 245, 180, 0.06);
  text-align: center;
}
.nogl-card.is-shake { animation: nogl-shake 0.45s ease; }
.nogl-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mute, #8f97a3);
}
.nogl-mark b { color: var(--glow, #b9f5b4); font-weight: 600; }
.nogl-mark::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--glow, #b9f5b4);
  box-shadow: 0 0 10px var(--glow, #b9f5b4), 0 0 22px rgba(185, 245, 180, 0.45);
  animation: nogl-pulse 2.6s ease-in-out infinite;
}

/* the mascot: a wobbling gloop blob with blinking eyes */
.nogl-hero { position: relative; height: 118px; margin: 0.6rem auto 0.2rem; width: 140px; }
.nogl-blob {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 92px;
  height: 78px;
  margin-left: -46px;
  background: radial-gradient(circle at 34% 30%, #effff0 0 6%, #c9f9c4 16%, var(--glow, #b9f5b4) 42%, #5fbf6a 100%);
  border-radius: 52% 48% 44% 56% / 60% 58% 42% 40%;
  box-shadow: inset -8px -10px 18px rgba(20, 70, 30, 0.35), 0 0 34px rgba(185, 245, 180, 0.35);
  animation: nogl-wobble 3.2s ease-in-out infinite, nogl-bob 3.2s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.nogl-eye {
  position: absolute;
  top: 30px;
  width: 11px;
  height: 15px;
  border-radius: 50%;
  background: #0b1410;
  animation: nogl-blink 4.6s infinite;
}
.nogl-eye:nth-child(1) { left: 27px; }
.nogl-eye:nth-child(2) { left: 52px; width: 13px; height: 17px; top: 28px; } /* one eye bigger: confused */
.nogl-eye::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
}
.nogl-mouth {
  position: absolute;
  left: 38px;
  top: 52px;
  width: 16px;
  height: 7px;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  border: 2px solid #0b1410;
  border-top: 0;
  transform: rotate(-8deg);
}
.nogl-shadow {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 84px;
  height: 12px;
  margin-left: -42px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), transparent);
  animation: nogl-shadow 3.2s ease-in-out infinite;
}
.nogl-q {
  position: absolute;
  right: 0;
  top: 2px;
  padding: 0.12rem 0.45rem;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #06080b;
  background: var(--hot, #f0c27a);
  border-radius: 10px 10px 10px 2px;
  box-shadow: 0 0 16px rgba(240, 194, 122, 0.4);
  animation: nogl-float 2.4s ease-in-out infinite;
}

.nogl-h {
  margin: 0.4rem 0 0.5rem;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  font-weight: 600;
  line-height: 1.2;
  color: var(--glow, #b9f5b4);
  text-shadow: 0 0 22px rgba(185, 245, 180, 0.25);
}
.nogl-p { margin: 0 auto 0.5rem; max-width: 30rem; font-size: 0.86rem; line-height: 1.6; }
.nogl-sub { margin: 0 auto; max-width: 30rem; font-size: 0.8rem; line-height: 1.5; color: var(--mute, #8f97a3); }

.nogl-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.nogl-btn, .nogl-pill {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink, #ece6da);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  border: 1px solid rgba(236, 230, 218, 0.14);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.08s, box-shadow 0.15s;
}
.nogl-btn:hover, .nogl-pill:hover:not(:disabled) {
  border-color: rgba(185, 245, 180, 0.6);
  color: var(--glow, #b9f5b4);
  box-shadow: 0 0 0 3px rgba(185, 245, 180, 0.08);
}
.nogl-btn:active { transform: translateY(1px) scale(0.98); }
.nogl-btn--go {
  color: #06080b;
  font-weight: 600;
  border-color: transparent;
  background: linear-gradient(180deg, #d4fbd0, var(--glow, #b9f5b4) 55%, #8fdc8f);
  box-shadow: 0 0 22px rgba(185, 245, 180, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.nogl-btn--go:hover { color: #06080b; background: linear-gradient(180deg, #e4ffe0, #c6f8c1 55%, #9fe69e); }
.nogl-btn:focus-visible, .nogl-pill:focus-visible, .nogl-how summary:focus-visible {
  outline: 2px solid var(--glow, #b9f5b4);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(185, 245, 180, 0.18);
}
.nogl-btn--go:focus-visible { outline-color: #fff; }
.nogl-status { min-height: 1.2em; margin: 0.6rem 0 0; font-family: var(--mono, ui-monospace, monospace); font-size: 0.72rem; color: var(--mute, #8f97a3); }
.nogl-status.is-ok { color: var(--glow, #b9f5b4); }
.nogl-status.is-bad { color: var(--hot, #f0c27a); }

/* "How to enable 3D" panel */
.nogl-how {
  margin-top: 0.7rem;
  text-align: left;
  border-top: 1px solid var(--line, rgba(236, 230, 218, 0.1));
  padding-top: 0.6rem;
}
.nogl-how summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--glow, #b9f5b4);
  border-radius: 8px;
}
.nogl-how summary::-webkit-details-marker { display: none; }
.nogl-how > summary { text-align: center; padding: 0.35rem 0; }
.nogl-how > summary::after { content: ' \25BE'; }
.nogl-how[open] > summary::after { content: ' \25B4'; }
.nogl-browser {
  margin-top: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line, rgba(236, 230, 218, 0.1));
}
.nogl-browser > summary { color: var(--ink, #ece6da); text-transform: none; letter-spacing: 0.04em; font-size: 0.8rem; }
.nogl-browser > summary::before { content: '\25B8  '; color: var(--mute, #8f97a3); }
.nogl-browser[open] > summary::before { content: '\25BE  '; }
.nogl-browser ol { margin: 0.45rem 0 0.1rem; padding-left: 1.2rem; font-size: 0.8rem; line-height: 1.5; color: var(--ink, #ece6da); }
.nogl-browser li { margin: 0.2rem 0; }
.nogl-browser li::marker { color: var(--glow, #b9f5b4); }
.nogl-how code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.74rem;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  background: rgba(185, 245, 180, 0.08);
  border: 1px solid rgba(185, 245, 180, 0.18);
  color: var(--glow, #b9f5b4);
  white-space: nowrap;
}
.nogl-foot { margin: 0.6rem 0 0; font-size: 0.72rem; line-height: 1.5; color: var(--mute, #8f97a3); }

/* corner pill inside the field (after "Play in flat 2D", or on context loss) */
.nogl-notice { position: absolute; top: 0.75rem; right: 0.75rem; z-index: 3; max-width: calc(100% - 1.5rem); }
.nogl-pill { border-radius: 999px; padding: 0.4rem 0.8rem; font-size: 0.64rem; background: rgba(12, 16, 22, 0.82); }
.nogl-pill::before { content: '\25CF  '; color: var(--hot, #f0c27a); }
.nogl-pill:disabled { cursor: default; opacity: 0.9; }

@media (max-width: 560px), (max-height: 640px) {
  .nogl-screen { align-items: flex-start; padding: 0.8rem; }
  .nogl-card { padding: 1rem 1rem 0.9rem; }
  .nogl-hero { height: 96px; transform: scale(0.85); margin-top: 0.2rem; }
  .nogl-h { font-size: 1.2rem; }
}

@keyframes nogl-wobble {
  0%, 100% { border-radius: 52% 48% 44% 56% / 60% 58% 42% 40%; }
  25% { border-radius: 58% 42% 52% 48% / 52% 64% 36% 48%; }
  50% { border-radius: 46% 54% 58% 42% / 64% 52% 48% 36%; }
  75% { border-radius: 50% 50% 46% 54% / 56% 60% 40% 44%; }
}
@keyframes nogl-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40% { transform: translateY(-9px) scale(0.96, 1.05); }
  70% { transform: translateY(0) scale(1.06, 0.93); }
}
@keyframes nogl-shadow {
  0%, 100% { transform: scale(1); opacity: 1; }
  40% { transform: scale(0.78); opacity: 0.6; }
  70% { transform: scale(1.08); opacity: 1; }
}
@keyframes nogl-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes nogl-float { 0%, 100% { transform: translateY(0) rotate(4deg); } 50% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes nogl-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.72); opacity: 0.7; } }
@keyframes nogl-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .nogl-screen *, .nogl-screen *::before, .nogl-screen *::after,
  .nogl-notice *, .nogl-notice *::before {
    animation: none !important;
    transition: none !important;
  }
}
/* same, when reduced motion is switched on in the site's own a11y settings */
html.a11y-rm-on .nogl-screen *, html.a11y-rm-on .nogl-screen *::before, html.a11y-rm-on .nogl-screen *::after,
html.a11y-rm-on .nogl-notice *, html.a11y-rm-on .nogl-notice *::before {
  animation: none !important;
  transition: none !important;
}

/* notch / safe-area insets (viewport-fit=cover is set in index.html) */
@supports (padding: max(0px)) {
  .nogl-screen {
    padding: max(1.2rem, env(safe-area-inset-top)) max(1.2rem, env(safe-area-inset-right))
             max(1.2rem, env(safe-area-inset-bottom)) max(1.2rem, env(safe-area-inset-left));
  }
  @media (max-width: 560px), (max-height: 640px) {
    .nogl-screen {
      padding: max(0.8rem, env(safe-area-inset-top)) max(0.8rem, env(safe-area-inset-right))
               max(0.8rem, env(safe-area-inset-bottom)) max(0.8rem, env(safe-area-inset-left));
    }
  }
}
