/* Isla Nublar - interface styling.
 *
 * Dark, low-chroma, and deliberately out of the way: the scene is the subject
 * and the panels are instruments around it. Everything is sized in rem off a
 * 15px root so the whole HUD scales with one number, and the layout collapses
 * to a phone at 900px because the same URL is what someone opens on a handset
 * before they put a headset on.
 */

:root {
  --bg: #0a0e12;
  --panel: rgba(12, 17, 22, 0.82);
  --panel-solid: #0c1116;
  --line: rgba(255, 255, 255, 0.10);
  --ink: #dfe8f0;
  --ink-dim: #8ea1b3;
  --ink-faint: #5d6f80;
  --accent: #ffd479;
  --accent-dim: rgba(255, 212, 121, 0.28);
  --good: #6fd08c;
  --bad: #e2705f;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- loading */

#loading {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 12%, #16202a 0%, #070a0d 70%);
  transition: opacity .8s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.load-inner { width: min(560px, 88vw); text-align: left; }
.load-mark {
  font-size: 1.9rem; letter-spacing: .38em; font-weight: 700;
  color: var(--accent); margin-bottom: .35rem;
}
.load-sub { color: var(--ink-dim); font-size: .92rem; margin-bottom: 1.6rem; }
.load-track {
  height: 4px; background: rgba(255, 255, 255, .08); border-radius: 3px; overflow: hidden;
}
#load-bar {
  height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, #4e8f6a, var(--accent));
  transition: width .35s ease;
}
#load-text { margin-top: .7rem; font-size: .95rem; }
#load-detail, .load-detail {
  margin-top: .2rem; color: var(--ink-faint); font-size: .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap;
}
.load-legend {
  margin-top: 2.2rem; display: grid; gap: .6rem;
  color: var(--ink-faint); font-size: .8rem; line-height: 1.5;
}
.load-legend b { color: var(--ink-dim); font-weight: 600; }
.jp-fatal {
  margin-top: 1.5rem; padding: .8rem; max-height: 40vh; overflow: auto;
  background: rgba(226, 112, 95, .10); border: 1px solid rgba(226, 112, 95, .35);
  color: #f0b7ac; font-size: .75rem; white-space: pre-wrap;
}

/* -------------------------------------------------------------------- HUD */

.jp-ui { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.jp-ui.hidden { display: none; }
.jp-ui button, .jp-ui .jp-card, .jp-ui .jp-inspector,
.jp-ui .jp-top, .jp-ui .jp-bottom, .jp-ui canvas { pointer-events: auto; }

.jp-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 1.4rem;
  padding: .5rem 1rem;
  background: linear-gradient(180deg, rgba(8, 12, 16, .88), rgba(8, 12, 16, 0));
}
.jp-title { display: flex; flex-direction: column; line-height: 1.1; margin-right: .8rem; }
.jp-title strong { letter-spacing: .22em; font-size: .82rem; color: var(--accent); }
.jp-sub { font-size: .68rem; color: var(--ink-faint); letter-spacing: .06em; }
.jp-stat { display: flex; flex-direction: column; line-height: 1.15; }
.jp-stat-label { font-size: .58rem; letter-spacing: .16em; color: var(--ink-faint); }
.jp-stat-value {
  font-size: .88rem; font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ------------------------------------------------------------------- dock */

.jp-dock {
  position: absolute; top: 3.4rem; left: .75rem; bottom: 4.4rem;
  width: 252px; display: flex; flex-direction: column; gap: .55rem;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.jp-dock::-webkit-scrollbar { width: 6px; }
.jp-dock::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 3px; }

.jp-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: .5rem .55rem .6rem; backdrop-filter: blur(9px);
}
.jp-card-title {
  font-size: .58rem; letter-spacing: .18em; color: var(--ink-faint);
  margin: .15rem 0 .4rem;
}
.jp-map, .jp-chart {
  display: block; width: 100%; height: auto; border-radius: 6px;
  background: #0b1015; image-rendering: auto;
}
.jp-map { cursor: crosshair; }
.jp-chart { margin-bottom: .35rem; }
.jp-hint { font-size: .64rem; color: var(--ink-faint); margin-top: .25rem; }

.jp-census { display: flex; flex-direction: column; gap: 1px; }
.jp-crow {
  display: grid; grid-template-columns: 10px 1fr auto 12px;
  align-items: center; gap: .4rem;
  padding: .16rem .2rem; border-radius: 4px; cursor: pointer; font-size: .76rem;
}
.jp-crow:hover { background: rgba(255, 255, 255, .07); }
.jp-crow.extinct { opacity: .34; text-decoration: line-through; }
.jp-dot { width: 8px; height: 8px; border-radius: 50%; }
.jp-cname { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jp-cnum { font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.jp-ctrend { font-size: .5rem; }
.jp-ctrend.up { color: var(--good); }
.jp-ctrend.down { color: var(--bad); }

.jp-events { display: flex; flex-direction: column; gap: 1px; max-height: 190px; overflow-y: auto; }
.jp-event {
  display: grid; grid-template-columns: 2.4rem 1fr; gap: .35rem;
  font-size: .7rem; padding: .12rem .2rem; border-radius: 3px; color: var(--ink-dim);
}
.jp-event.clickable { cursor: pointer; }
.jp-event.clickable:hover { background: rgba(255, 255, 255, .07); }
.jp-eday { color: var(--ink-faint); font-family: ui-monospace, monospace; }
.jp-event.kill .jp-etext { color: #eaa08e; }
.jp-event.birth .jp-etext { color: #9fd8a8; }
.jp-event.extinction .jp-etext { color: var(--bad); font-weight: 600; }
.jp-event.nest .jp-etext { color: #d8c78e; }

/* -------------------------------------------------------------- inspector */

.jp-inspector {
  position: absolute; top: 3.4rem; right: .75rem; width: 296px;
  max-height: calc(100vh - 8.2rem); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(9px);
}
.jp-insp-head { padding: .6rem .7rem .45rem; border-bottom: 1px solid var(--line); position: relative; }
.jp-insp-name { font-size: .95rem; font-weight: 600; }
.jp-insp-latin { font-size: .68rem; color: var(--ink-faint); font-style: italic; }
.jp-close {
  position: absolute; top: .35rem; right: .4rem;
  background: none; border: none; color: var(--ink-faint);
  font-size: 1.15rem; line-height: 1; cursor: pointer; padding: .15rem .3rem;
}
.jp-close:hover { color: var(--ink); }
.jp-insp-body { padding: .5rem .7rem; }
.jp-irow { display: flex; justify-content: space-between; gap: .6rem; font-size: .74rem; padding: .1rem 0; }
.jp-ik { color: var(--ink-faint); }
.jp-iv { text-align: right; font-family: ui-monospace, monospace; }
.jp-isep {
  font-size: .55rem; letter-spacing: .18em; color: var(--ink-faint);
  margin: .55rem 0 .25rem; border-top: 1px solid var(--line); padding-top: .4rem;
}
.jp-ibar {
  display: grid; grid-template-columns: 5.6rem 1fr 2rem;
  align-items: center; gap: .4rem; font-size: .72rem; padding: .09rem 0;
}
.jp-track { height: 6px; background: rgba(255, 255, 255, .10); border-radius: 3px; overflow: hidden; }
.jp-fill { display: block; height: 100%; border-radius: 3px; transition: width .3s ease; }
.jp-inum { text-align: right; font-family: ui-monospace, monospace; color: var(--ink-dim); font-size: .68rem; }
.jp-insp-actions { display: flex; gap: .35rem; padding: .5rem .7rem .7rem; }

/* ----------------------------------------------------------- bottom bar */

.jp-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .9rem;
  padding: .5rem 1rem .6rem;
  background: linear-gradient(0deg, rgba(8, 12, 16, .92), rgba(8, 12, 16, 0));
}
.jp-group { display: flex; align-items: center; gap: .25rem; }
.jp-glabel {
  font-size: .55rem; letter-spacing: .16em; color: var(--ink-faint);
  margin-right: .25rem; align-self: center;
}
.jp-btn {
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: .28rem .6rem; font-size: .76rem; cursor: pointer;
  font-family: inherit; transition: background .12s ease, border-color .12s ease;
}
.jp-btn:hover { background: rgba(255, 255, 255, .14); }
.jp-btn.on { background: var(--accent-dim); border-color: rgba(255, 212, 121, .55); color: #ffe6b0; }
.jp-btn:disabled { opacity: .4; cursor: default; }
.jp-btn.jp-xr { background: rgba(110, 200, 150, .18); border-color: rgba(110, 200, 150, .45); }

/* ------------------------------------------------------------------ codex */

.jp-modal {
  position: fixed; inset: 0; z-index: 60; pointer-events: auto;
  background: rgba(4, 7, 10, .68); display: grid; place-items: center; padding: 2rem 1rem;
  backdrop-filter: blur(3px);
}
.jp-modal-panel {
  width: min(720px, 94vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px;
}
.jp-modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: baseline; gap: .7rem;
  padding: .9rem 1.1rem .7rem; border-bottom: 1px solid var(--line);
  background: var(--panel-solid);
}
.jp-modal-title { font-size: 1.25rem; font-weight: 600; display: flex; gap: .6rem; align-items: baseline; }
.jp-latin { font-size: .8rem; color: var(--ink-faint); font-weight: 400; }
.jp-modal-body { padding: 1rem 1.1rem 1.4rem; }
.jp-portrait {
  width: 100%; max-width: 340px; border-radius: 8px; float: right;
  margin: 0 0 .8rem .9rem; border: 1px solid var(--line);
}
.jp-lead { font-size: .92rem; line-height: 1.55; color: var(--ink); margin: 0 0 1rem; }
.jp-modal-body h4 {
  font-size: .6rem; letter-spacing: .18em; color: var(--ink-faint);
  margin: 1.3rem 0 .5rem; text-transform: uppercase; clear: none;
}
.jp-facts, .jp-live {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .2rem .9rem;
}
.jp-fact { display: flex; justify-content: space-between; gap: .5rem; font-size: .78rem; padding: .16rem 0; border-bottom: 1px dotted rgba(255,255,255,.07); }
.jp-fk { color: var(--ink-faint); }
.jp-fv { font-family: ui-monospace, monospace; text-align: right; }
.jp-caveat { font-size: .74rem; color: var(--ink-faint); margin: -.2rem 0 .6rem; line-height: 1.45; }
.jp-simbars { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
.jp-habitat { display: flex; flex-direction: column; gap: .18rem; }
.jp-hrow { display: grid; grid-template-columns: 10px 9.5rem 1fr; align-items: center; gap: .45rem; font-size: .76rem; }
.jp-swatch { width: 9px; height: 9px; border-radius: 2px; }
.jp-hname { color: var(--ink-dim); }
.jp-facts-list { margin: 0; padding-left: 1.1rem; }
.jp-facts-list li { font-size: .84rem; line-height: 1.55; margin-bottom: .45rem; color: var(--ink); }

/* ----------------------------------------------------------------- misc */

.jp-labels { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.jp-label {
  position: absolute; transform: translate(-50%, -100%);
  font-size: .68rem; letter-spacing: .04em; white-space: nowrap;
  color: #eaf2f8; text-shadow: 0 1px 3px rgba(0, 0, 0, .95), 0 0 8px rgba(0, 0, 0, .7);
  padding: 1px 5px; border-radius: 3px; background: rgba(8, 12, 16, .42);
}
.jp-label.sel { color: var(--accent); border: 1px solid var(--accent-dim); }
.jp-label.dead { color: #b9a89a; font-style: italic; }

.jp-toast {
  position: fixed; left: 50%; bottom: 5.2rem; transform: translateX(-50%);
  background: var(--panel-solid); border: 1px solid var(--accent-dim);
  color: var(--ink); padding: .45rem .9rem; border-radius: 7px; font-size: .82rem;
  z-index: 80; pointer-events: none;
}

/* Small screens: the dock becomes a strip and the inspector a sheet. A phone
 * is the device people check the link on before reaching for a headset. */
@media (max-width: 900px) {
  :root { font-size: 14px; }
  .jp-dock { width: 190px; bottom: 5.6rem; }
  .jp-inspector { width: min(300px, 60vw); }
  .jp-top { gap: .8rem; overflow-x: auto; }
  .jp-bottom { gap: .5rem; }
}
@media (max-width: 620px) {
  .jp-dock { display: none; }
  .jp-inspector { left: .5rem; right: .5rem; width: auto; top: auto; bottom: 5.4rem; max-height: 46vh; }
  .jp-glabel { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #load-bar, .jp-fill { transition: none; }
}
