/* ============================================================
   Het Vivarium — page styles (world, sky, lake, fauna, HUD)
   and the editor panel shown with ?edit
   ============================================================ */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body::before { display: none; }                      /* the world paints its own ground */
.header__brand { opacity: 1; transform: none; }       /* no hero here: wordmark from the start */

.viv {
  position: fixed; inset: 0;
  overflow: hidden;
  background: #0a1a12;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  cursor: grab; outline: none;
}
.viv.is-dragging { cursor: grabbing; }

.viv-world  { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.viv-ground { position: absolute; left: 0; top: 0; display: block; }
.viv-layer  { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---- sky ---- */
.star {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #eef3ff; box-shadow: 0 0 6px 1px rgba(220,230,255,0.6);
  animation: twinkle var(--d, 4s) ease-in-out infinite; animation-delay: var(--dl, 0s);
}
@keyframes twinkle { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }
#sky { animation: skydrift 240s ease-in-out infinite alternate; }          /* the whole sky turns, slowly */
@keyframes skydrift { to { transform: translateX(-160px); } }
.shoot {                                                                   /* a falling star: bright head, fading tail */
  position: absolute; width: 150px; height: 1.5px; border-radius: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(230,238,255,0.9) 80%, #fff);
  transform-origin: right center; pointer-events: none; opacity: 0;
  filter: drop-shadow(0 0 4px rgba(200,220,255,0.9));
}

/* ---- lake ---- */
.lake { position: absolute; overflow: hidden; }
.lake__sheen {
  position: absolute; inset: -20%;
  background:
    repeating-linear-gradient(100deg, transparent 0 90px, rgba(190,215,255,0.016) 120px, transparent 150px 200px),
    radial-gradient(60% 45% at 45% 25%, rgba(190,215,255,0.05), transparent 70%);
  animation: drift 22s linear infinite;
}
@keyframes drift { to { transform: translateX(90px); } }
.lake__waves  { position: absolute; inset: 0; width: 100%; height: 100%; }   /* wrinkles, drawn each frame */
.lake__mirror { position: absolute; inset: 0; }
.mirror {
  position: absolute; width: 4px; height: 7px; border-radius: 50%;
  background: #d8f29a; filter: blur(1.2px);
  box-shadow: 0 0 8px 3px rgba(216,242,154,0.35);
  will-change: transform, opacity;
}

/* ---- fireflies & fx ---- */
.fly {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: #e9ffb0; box-shadow: 0 0 7px 2px rgba(216,242,154,0.65), 0 0 18px 6px rgba(190,230,120,0.18);
  will-change: transform, opacity;
}
.ripple {
  position: absolute; width: 10px; height: 6px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(220,245,200,0.55); border-radius: 50%;
  pointer-events: none;
}
.ripple--water { border-color: rgba(190,225,255,0.7); }

/* ---- nature & fauna (one layer, sorted by ground point) ---- */
.animal { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; }
.animal img, .animal video { display: block; height: auto; }
.animal .sprite { background-repeat: no-repeat; }
.nature { position: absolute; transform: translate(-50%, -100%); pointer-events: none; }
.nature img { display: block; height: auto; }
.nature--baked { transform: none; }                        /* a slice of the compiled atlas */
.fringe { position: absolute; pointer-events: none; }      /* grass in front of a standing object's base */
.shadow {                                                  /* soft ellipse on the ground under a creature */
  position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none;
  border-radius: 50%; background: radial-gradient(ellipse at center, rgba(0,0,0,0.5), rgba(0,0,0,0) 70%);
  will-change: transform, opacity;
}

/* ---- fixed overlays ---- */
.viv-scrim {
  position: absolute; left: 0; right: 0; top: 0; height: calc(var(--header-h) + 40px);
  background: linear-gradient(180deg, rgba(3,5,10,0.7), transparent);
  pointer-events: none; z-index: 10;
}
.viv-vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 10;
  background: radial-gradient(90% 80% at 50% 50%, transparent 55%, rgba(3,8,6,0.6) 100%);
}
.viv-hud {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: clamp(20px, 4vh, 40px);
  z-index: 20; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  pointer-events: none; opacity: 0; animation: fade-up 1.2s var(--ease-out) 0.5s forwards;
}
.viv-hud > * { pointer-events: auto; }
.viv-title__name { font-family: "Great Vibes", cursive; font-weight: 400; font-size: clamp(3.2rem, 7vw, 6.4rem); line-height: 1; letter-spacing: 0.01em; text-shadow: 0 2px 24px rgba(0,0,0,0.5); }
.viv-title__hint { margin-top: 6px; font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--ink-soft); max-width: 36ch; }
.viv-map {
  position: relative; border: 1px solid var(--line); border-radius: 6px; padding: 6px;
  background: rgba(4,10,8,0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.viv-map canvas { display: block; width: 150px; height: auto; border-radius: 3px; }
.viv-map__label { position: absolute; left: 8px; top: -18px; font-size: var(--t-micro); letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-mute); }

@media (max-width: 760px) {
  .viv-title__hint { display: none; }
  .viv-map canvas { width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .star, .lake__sheen, #sky { animation: none; }
}

/* ============================================================
   EDITOR (?edit) — panel on the right, selection marks in the world
   ============================================================ */
.ed {
  position: fixed; top: calc(var(--header-h) + 12px); right: 16px; bottom: 16px; width: 312px; z-index: 60;
  display: flex; flex-direction: column; padding: 16px 0 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(6,10,8,0.86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 400; font-size: 13px; line-height: 1.4; color: var(--ink-soft);
}
.ed button, .ed select { font: inherit; }
.ed__tabs { padding: 0 18px; }
.ed__body { flex: 1; min-height: 0; overflow: auto; padding: 0 18px 18px; }
.ed__bar { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.ed__bar .ed__pos { flex: 1; text-align: center; }
.ed__ib, .ed__zoom { border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink-soft); cursor: pointer; padding: 4px 7px; min-width: 28px; }
.ed__ib:hover, .ed__zoom:hover { border-color: var(--line); color: var(--ink); }
.ed__zoom { min-width: 48px; }
.ed__count { color: var(--ink-mute); font-weight: 400; letter-spacing: 0; text-transform: none; }
.ed__list { display: grid; gap: 3px; max-height: 164px; overflow: auto; padding-right: 2px; }
.ed__li { display: flex; align-items: baseline; gap: 8px; padding: 6px 9px; border: 1px solid transparent; border-radius: 6px; background: rgba(255,255,255,0.03); color: var(--ink-soft); text-align: left; cursor: pointer; }
.ed__li:hover { border-color: var(--line); }
.ed__li.is-on { border-color: var(--accent); color: var(--ink); background: rgba(210,160,110,0.08); }
.ed__li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed__li small, .ed__li em { font-size: 11px; color: var(--ink-mute); white-space: nowrap; font-style: normal; }
.ed__li em, .ed__tag { padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; font-size: 10px; font-style: normal; color: var(--ink-mute); }
.ed__kinds { display: flex; gap: 6px; }
.ed__kind { flex: 1; padding: 7px 4px; border: 1px solid var(--line); border-radius: 6px; background: none; color: var(--ink-mute); cursor: pointer; }
.ed__kind.is-on { color: var(--ink); border-color: var(--accent); background: rgba(210,160,110,0.08); }
.ed__recent { display: flex; gap: 4px; flex-wrap: wrap; }
.ed__chip { width: 18px; height: 18px; border: 1px solid rgba(255,255,255,0.2); border-radius: 50%; cursor: pointer; padding: 0; }
.ed__chip:hover { border-color: var(--ink); }
.ed__row input[type=color] { width: 36px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.ed-marks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5000; }
.ed-handle { position: absolute; transform: translate(-50%, -50%); background: var(--accent); border: 1px solid #fff; border-radius: 2px; pointer-events: none; }
.ed-cursor { position: absolute; transform: translate(-50%, -50%); border: 1px solid rgba(255,255,255,0.85); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.5); pointer-events: none; z-index: 30; }
.ed-help { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 70; width: min(520px, 90vw); padding: 20px 24px 24px; border: 1px solid var(--line); border-radius: 10px; background: rgba(6,10,8,0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 13px; color: var(--ink-soft); }
.ed-help .ed__h { margin-top: 0; }
.ed-help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.ed-help dt { color: var(--ink); font-variant-numeric: tabular-nums; }
.ed-help dd { margin: 0; color: var(--ink-mute); }
.viv-map canvas { cursor: pointer; }
.ed__tabs { display: flex; gap: 6px; }
.ed__tab, .ed__mat, .ed__btn, .ed__item, .ed__tools button {
  border: 1px solid var(--line); border-radius: 6px; background: none; color: var(--ink-soft);
  cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.ed__tab { flex: 1; padding: 8px; font-weight: 500; color: var(--ink-mute); }
.ed__tab.is-on, .ed__mat.is-on, .ed__tools button.is-on { color: var(--ink); border-color: var(--accent); background: rgba(210,160,110,0.08); }
.ed__h { margin: 18px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.ed__lib { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ed__item { padding: 6px; background: rgba(255,255,255,0.03); text-align: center; }
.ed__item:hover { border-color: var(--accent); }
.ed__item img { width: 100%; height: 54px; object-fit: contain; display: block; }
.ed__item span { display: block; margin-top: 4px; font-size: 11px; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed__tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ed__tools button { padding: 8px 4px; }
.ed__tools button:hover { border-color: var(--accent); }
.ed__mats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed__mat { display: flex; align-items: center; gap: 8px; padding: 7px 9px; text-align: left; }
.ed__mat:hover { border-color: var(--accent); }
.ed__mat i { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.18); }
.ed__row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
.ed__row label { flex: none; width: 76px; font-size: 12px; color: var(--ink-mute); white-space: nowrap; }
.ed__row input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.ed__row output { min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.ed__row select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,0.04); color: var(--ink); }
.ed__btn { width: 100%; margin-top: 8px; padding: 9px; color: var(--ink); }
.ed__btn:hover { border-color: var(--accent); }
.ed__btn--primary { border-color: var(--ink); font-weight: 500; }
.ed__btn--danger { color: #e0a08a; }
.ed__btn.is-on { border-color: var(--accent); color: var(--accent); }
.ed__pair { display: flex; gap: 6px; }
.ed__pair .ed__btn { min-width: 0; }
.ed__swatch { width: 100%; height: 28px; margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; }
.ed__help { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--ink-mute); }
.ed__status { margin-top: 8px; font-size: 12px; line-height: 1.5; color: var(--ink-soft); min-height: 1.2em; }
.ed__file { display: none; }
.ed-sel  { position: absolute; border: 1px dashed rgba(210,160,110,0.9); pointer-events: none; }
.ed-foot { position: absolute; border: 1px solid rgba(210,160,110,0.8); border-radius: 50%; background: rgba(210,160,110,0.12); transform: translate(-50%, -50%); pointer-events: none; }
.ed-lines { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 6000; }   /* barriers and cliff edges, editor only */
.editing .viv-title { display: none; }
.editing .viv { cursor: default; }
.editing.painting .viv { cursor: crosshair; }
.editing .viv.is-dragging { cursor: grabbing; }

/* the way back from the editor to the admin area */
.viv-admin { position: fixed; top: calc(var(--header-h, 72px) + 10px); right: 18px; z-index: 40; padding: 8px 14px; border: 1px solid rgba(255,255,255,0.25); border-radius: 999px; background: rgba(5,4,3,0.55); color: #fff; font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; text-decoration: none; backdrop-filter: blur(8px); }
.viv-admin:hover { border-color: #fff; }
.editing .viv-admin { right: 358px; }
