/* ============================================================================
   world.css — the persistent project "world" shell (Verdant Hollow)

   Scoped entirely under the three world layers (#world-shell / #world-nav /
   #world-onboard) and the body.world-* state classes, so nothing here touches
   any existing page. Local design tokens reference the shared design-system
   tokens where an exact match exists; only genuinely world-specific values
   (steel, gold, surfaces, the dark ground) stay local.

   Stacking: #world-shell (z -1, behind page content) · #world-nav (z 150,
   above content, below the top nav at z 200) · #world-onboard (z 300, modal).
   Silkscreen is used ONLY for diegetic in-canvas labels (drawn in JS); all DOM
   chrome uses Fraunces / DM Sans / JetBrains Mono.
   ========================================================================== */

#world-shell,
#world-nav,
#world-onboard {
  --ember: var(--color-accent-primary);
  --pink: var(--color-pillar-core);
  --teal: var(--color-pillar-persona);
  --lav: var(--color-pillar-mcp);
  --gold: #e7c07a;
  --steel: #9fb0c3;
  --ink: var(--color-text-primary);
  --ink-dim: var(--color-text-secondary);
  --ink-faint: var(--color-text-tertiary);
  --line: rgba(236, 230, 220, 0.10);
  --line-2: rgba(236, 230, 220, 0.18);
  --surface: #14161b;
  --surface-2: #191c22;
  --serif: var(--font-display);
  --mono: var(--font-mono);
  --sans: var(--font-sans);
}

/* ---- stacking + page transparency while the world is the home ------------ */
#world-shell {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 38%, #15181f 0%, #0c0d10 70%, #07080a 100%);
  transition: opacity 0.3s ease, filter 0.3s ease;
}
body.world-home #main-content,
body.world-overlay #main-content {
  background: transparent;
}
/* world-home: page is empty — let clicks reach the canvas behind it */
body.world-home #main-content {
  pointer-events: none;
}
/* world-overlay: a zone page floats over the dimmed world */
#world-shell.is-dim {
  opacity: 0.32;
  filter: blur(3px) saturate(0.7);
  pointer-events: none;
}

/* ---- the canvas + atmospherics ------------------------------------------- */
.world-canvas {
  image-rendering: pixelated;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: crosshair;
}
.world-canvas.clickable {
  cursor: pointer;
}
.world-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.world-vignette {
  background: radial-gradient(115% 115% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
.world-grain {
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- title HUD + hint ----------------------------------------------------- */
.world-title {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.world-title .name {
  font-family: var(--pixel, "Silkscreen", monospace);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 18px rgba(0, 0, 0, 0.5);
}
.world-title .tag {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--ink-dim);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.world-hint {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  background: rgba(14, 16, 21, 0.86);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-dim);
  pointer-events: none;
  transition: opacity 0.6s;
}
.world-hint .key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  font-size: 11px;
  color: var(--ink);
  font-weight: 600;
}
.world-hint .mouse {
  color: var(--teal);
}

/* ---- control layer (always interactive) ---------------------------------- */
#world-nav {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
}
#world-nav > * {
  pointer-events: auto;
}
.world-btn {
  position: fixed;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 20, 26, 0.82);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.world-btn:hover {
  border-color: var(--ember);
  transform: translateY(-1px);
  background: rgba(28, 22, 18, 0.9);
}
.world-btn:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}
.world-btn svg {
  width: 22px;
  height: 22px;
}
#world-menu {
  top: calc(var(--nav-height) + 16px);
  left: 18px;
}
.world-info {
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 30px;
  height: 64px;
  border-radius: 10px 0 0 10px;
  color: var(--teal);
}
.world-info:hover {
  transform: translateY(-50%) translateX(-1px);
}
.world-return {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  left: 80px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 16px;
  background: rgba(18, 20, 26, 0.92);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.4px;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, color 0.2s;
}
.world-return:hover {
  border-color: var(--ember);
  color: var(--ember);
}
.world-return svg {
  width: 16px;
  height: 16px;
}

/* ---- fast-travel drawer (the accessible + mobile nav) -------------------- */
.world-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 86vw;
  background: rgba(11, 12, 15, 0.97);
  border-right: 1px solid var(--line-2);
  backdrop-filter: blur(10px);
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.25, 1);
  padding: calc(var(--nav-height) + 18px) 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.world-drawer.open {
  transform: none;
}
.world-drawer h2 {
  font-family: var(--pixel, "Silkscreen", monospace);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--ink-faint);
  margin: 0 0 6px;
  padding-left: 4px;
}
.world-filter {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
}
.world-filter:focus {
  outline: none;
  border-color: var(--ember);
}
.world-filter::placeholder {
  color: var(--ink-faint);
}
.world-ft-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.world-ft-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.world-ft-item:hover,
.world-ft-item:focus-visible {
  background: var(--surface);
  border-color: var(--line-2);
  transform: translateX(2px);
  outline: none;
}
.world-ft-item .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 10px currentColor;
}
.world-ft-item .meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.world-ft-item .name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
}
.world-ft-item .tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 1px;
}
.world-ft-item .kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 2px 6px;
}

/* ---- onboarding / help ---------------------------------------------------- */
#world-onboard {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 7, 9, 0.72);
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#world-onboard.open {
  opacity: 1;
  pointer-events: auto;
}
.world-ob-card {
  width: 580px;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #13161c, #0c0d10);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 32px 34px 26px;
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.6);
  transform: translateY(12px) scale(0.99);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.25, 1);
}
#world-onboard.open .world-ob-card {
  transform: none;
}
.world-ob-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--ember);
}
.world-ob-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 29px;
  line-height: 1.08;
  margin: 10px 0 6px;
  letter-spacing: -0.01em;
}
.world-ob-title span {
  color: var(--gold);
}
.world-ob-sub {
  color: var(--ink-dim);
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 22px;
}
.world-ob-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.world-ob-ctl {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.world-ob-ctl .keys {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
  padding-top: 1px;
}
.world-ob-ctl .kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
}
.world-ob-ctl .click {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 6px;
  padding: 3px 7px;
}
.world-ob-ctl .t {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.world-ob-ctl .t b {
  font-size: 13px;
}
.world-ob-ctl .t span {
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.4;
}
.world-ob-legend-h {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink-faint);
  margin-bottom: 11px;
}
.world-ob-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.world-ob-li {
  display: flex;
  gap: 11px;
  align-items: baseline;
  font-size: 13px;
}
.world-ob-li .d {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
  position: relative;
  top: 1px;
}
.world-ob-li b {
  font-family: var(--serif);
  font-weight: 600;
  min-width: 112px;
  flex-shrink: 0;
}
.world-ob-li span {
  color: var(--ink-dim);
}
.world-ob-go {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--ember);
  color: #1b1006;
  border: none;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(224, 120, 80, 0.3);
}
.world-ob-go:hover {
  filter: brightness(1.05);
}
.world-ob-foot {
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 14px;
}

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 640px) {
  /* On phones the map is decoration — the focusable drawer is the real menu. */
  .world-hint { display: none; }
  .world-return { left: 76px; padding: 0 12px; font-size: 11px; }
  .world-drawer { width: 88vw; }
  .world-ob-controls { grid-template-columns: 1fr; }
  .world-ob-li b { min-width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  #world-shell,
  .world-title,
  .world-hint,
  .world-drawer,
  #world-onboard,
  .world-ob-card {
    transition: none;
  }
}
