/* Shared chrome injected into every world under /world/*.
   The shell sweeps all top-level body chrome on load (see _shell.js
   sweepLegacyChrome). This stylesheet styles the shell's own pills and keeps
   the #controls panel (worlds' slider wrappers) in place with a transition. */

html, body {
  cursor: crosshair;
}

/* Shell chrome defaults to the normal cursor; interactive buttons/links
   inside shell chrome use the pointer (finger) cursor. */
[data-world-ui],
[data-world-ui] * {
  cursor: default;
}
[data-world-ui] a,
[data-world-ui] button {
  cursor: pointer;
}
/* SVG icons inside buttons/links shouldn't swallow pointer events — let the
   cursor resolve to the parent's pointer rule. */
[data-world-ui] a svg,
[data-world-ui] button svg {
  pointer-events: none;
}
[data-world-ui] a.is-disabled,
[data-world-ui] button:disabled,
[data-world-ui] button[aria-disabled="true"] {
  cursor: default;
}

/* Defensive hide for the most common legacy IDs/classes — in case the DOM
   sweep misses something edge-case (dynamic injection post-sweep). */
#title,
#title-block,
#title-box,
#title-card,
#title-panel,
.title-block,
.title-box,
.title-card,
.title-panel,
#hud,
.hud,
[data-shell-swept="true"] {
  display: none !important;
}

/* Unified slider-panel style applied to every world. Worlds emit the
   canonical shape (enforced by scripts/autoresearch/validate-panel.mjs):
     <div id="controls">
       <div class="slider">
         <label><span class="name">…</span><span class="value" id="…">…</span></label>
         <input type="range" id="…" min max value step>
       </div>
       …
     </div>
   Selectors target #controls directly so styling applies at CSS parse time
   (no flash of unstyled panel before _shell.js runs). The shell only sets
   data-world-collapsed at runtime to drive the collapse animation. */
#controls {
  position: fixed !important;
  right: 10px !important;
  bottom: 60px !important;
  left: auto !important;
  top: auto !important;
  z-index: 50 !important;
  display: block !important;
  box-sizing: border-box !important;
  width: clamp(200px, 22vw, 280px);
  padding: 10px 14px !important;
  border-radius: 10px !important;
  background: rgba(24, 24, 27, 0.7) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1px solid rgba(63, 63, 70, 0.5) !important;
  box-shadow: none !important;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  accent-color: #5eead4;
  pointer-events: auto !important;
  transition: opacity 240ms ease, transform 240ms ease;
}
#controls[data-world-collapsed="true"] {
  opacity: 0 !important;
  transform: translateY(12px) !important;
  pointer-events: none !important;
}
#controls label {
  display: flex !important;
  justify-content: space-between !important;
  align-items: baseline;
  font-size: 10px !important;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
  font-weight: 500;
  margin-bottom: 3px !important;
}
#controls label .name {
  color: #a1a1aa !important;
  text-transform: uppercase !important;
  letter-spacing: 0.08em !important;
}
#controls label .value {
  color: #fafafa !important;
  font-variant-numeric: tabular-nums;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-family: "SF Mono", Menlo, Consolas, ui-monospace, monospace !important;
  font-size: 10px !important;
}
#controls input[type="range"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 100% !important;
  height: 2px !important;
  margin: 0 !important;
  padding: 0 !important;
  background: rgba(113, 113, 122, 0.4) !important;
  border: 0 !important;
  border-radius: 1px !important;
  outline: none !important;
}
#controls input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: transparent;
  border-radius: 1px;
  border: 0;
}
#controls input[type="range"]::-moz-range-track {
  height: 2px;
  background: transparent;
  border-radius: 1px;
  border: 0;
}
#controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: #5eead4 !important;
  cursor: pointer !important;
  border: 0 !important;
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(94, 234, 212, 0.4) !important;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
#controls input[type="range"]::-moz-range-thumb {
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: #5eead4 !important;
  cursor: pointer !important;
  border: 0 !important;
  box-shadow: 0 0 6px rgba(94, 234, 212, 0.4) !important;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
#controls input[type="range"]:active::-webkit-slider-thumb,
#controls input[type="range"]:focus-visible::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.7) !important;
}
#controls input[type="range"]:active::-moz-range-thumb,
#controls input[type="range"]:focus-visible::-moz-range-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.7) !important;
}
#controls > .slider {
  margin: 6px 0 !important;
  padding: 0 !important;
  display: block !important;
}
#controls > .slider:first-child {
  margin-top: 0 !important;
}
#controls > .slider:last-child {
  margin-bottom: 0 !important;
}

/* --- Unified shell footer --------------------------------------------- */

.shell-footer {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 50;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px 6px 14px;
  margin-bottom: env(safe-area-inset-bottom);
  background: rgba(24, 24, 27, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(63, 63, 70, 0.5);
  border-radius: 999px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  color: #a1a1aa;
}

.shell-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.shell-footer-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.shell-title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #fafafa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}
/* Thin divider between title and HUD */
.shell-title + .shell-hud::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 10px;
  background: rgba(113, 113, 122, 0.5);
  margin-right: 2px;
}
/* Tagline: fixed pill above the footer on the left, mirroring the
   parameters panel on the right. Hidden by default; revealed on title
   hover via the .is-shown class (JS toggles on mouseenter/leave). */
.shell-tagline {
  position: fixed;
  left: 14px;
  bottom: 60px;
  z-index: 45;
  max-width: min(72vw, 420px);
  padding: 7px 14px;
  border-radius: 10px;
  background: rgba(24, 24, 27, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(63, 63, 70, 0.5);
  color: #d4d4d8;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-style: italic;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: break-word;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
.shell-tagline.is-shown {
  opacity: 1;
  transform: translateY(0);
  /* pointer-events stay off so hovering the pill doesn't eat canvas
     interactions; the title itself keeps the hover alive. */
}
/* Subtle hover cue on the title to hint the tagline reveal. */
.shell-title {
  cursor: help;
}

.shell-hud {
  display: flex;
  gap: 10px;
  align-items: baseline;
  min-width: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.shell-hud:empty { display: none; }
.shell-hud:empty::before { display: none; }
.shell-hud .stat {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}
.shell-hud .stat-label {
  color: #71717a;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.shell-hud .stat-value {
  color: #d4d4d8;
}

.shell-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.shell-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: #a1a1aa;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease;
  padding: 0;
}
.shell-nav-btn:hover {
  color: #fafafa;
  background: rgba(63, 63, 70, 0.5);
}
.shell-nav-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}
.shell-nav-btn.is-disabled {
  opacity: 0.3;
  pointer-events: none;
}
.shell-nav-btn[hidden] {
  display: none !important;
}
.shell-nav-home {
  color: #5eead4;
}
.shell-nav-home:hover {
  color: #99f6e4;
}
.shell-nav-shuffle.is-active {
  color: #5eead4;
  background: rgba(45, 212, 191, 0.15);
}
.shell-nav-shuffle.is-active:hover {
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.25);
}
/* Disabled gear: lighter dim than prev/next and overlaid with a
   diagonal strike so "no parameters available" reads at a glance. */
.shell-nav-gear.is-disabled {
  position: relative;
  opacity: 0.55;
}
.shell-nav-gear.is-disabled::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 18%;
  right: 18%;
  height: 1.5px;
  background: currentColor;
  transform: rotate(-45deg);
  transform-origin: center;
  pointer-events: none;
  border-radius: 1px;
}

.shell-toast {
  position: fixed;
  top: 14%;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 60;
  max-width: min(82vw, 420px);
  padding: 10px 14px;
  background: rgba(24, 24, 27, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(63, 63, 70, 0.6);
  border-radius: 10px;
  color: #e4e4e7;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}
.shell-toast[data-shown="true"] {
  opacity: 1;
}

/* Small-screen tweaks — keep the footer on ONE row so HUD / nav / gear
   never stack vertically. Shrink controls and drop the less-critical
   HUD stats (pop, gen) to reserve space. */
@media (max-width: 520px) {
  .shell-footer {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 4px 6px 4px 12px;
    gap: 6px;
  }
  .shell-title { font-size: 12px; }
  .shell-hud { gap: 8px; font-size: 10px; }
  .shell-hud .stat:not(:last-child) { display: none; }
  .shell-nav-btn { width: 28px; height: 28px; }
  .shell-nav-btn svg { width: 14px; height: 14px; }
  .shell-tagline {
    left: 8px;
    right: 8px;
    bottom: 52px;
    max-width: none;
    font-size: 11px;
    padding: 6px 12px;
  }
  #controls { bottom: 52px !important; }
}

/* Very narrow screens — hide HUD entirely to keep title + nav legible. */
@media (max-width: 360px) {
  .shell-hud { display: none; }
  .shell-title + .shell-hud::before { display: none; }
}
