/* The 3D world map: a full-window view under the site's bar (the landing page's header and nav), with
   the site's cream panels floating over it. Builds on /style.css (fonts, colours, buttons, the bar).
   Panels over the 3D view are the site's "ink sticker" pieces (2px ink edge, hard --shadow-ink); their
   small labels use the site's kicker type (display face, uppercase, sky ink). */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.map-page { background: #9fd3f2; overflow: hidden; height: 100svh; overscroll-behavior: none; }
.map-bar { position: fixed; inset: 0 0 auto 0; }
.map-bar .bar-nav a[aria-current="page"] { background: var(--sky-100); color: var(--sky-700); }
/* the small panel and card labels, set like the site's .kicker */
.seed-label, .time-label, .layers legend, .card-kind {
  font-family: var(--font-display); font-weight: 800; font-size: 0.78rem; line-height: 1.2;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--sky-700);
}

.map { position: fixed; inset: 0; overflow: hidden; }
.view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
.view:active { cursor: grabbing; }
.view:focus-visible { box-shadow: inset 0 0 0 3px var(--sky-700); }

/* ---------------- markers ---------------- */
.markers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; contain: strict; }
.mk {
  position: absolute; left: 0; top: 0; margin: -0.8rem 0 0 -0.8rem;
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto;
  font: 800 0.82rem/1 var(--font-body); color: var(--ink);
  transform-origin: 0.8rem 50%; will-change: transform;
}
.mk[hidden] { display: none; }
.mk-icon {
  width: 1.6rem; height: 1.6rem; flex: none; padding: 0.2rem; border-radius: 50%;
  background: rgba(255, 250, 240, 0.94); box-shadow: 0 0.12rem 0 rgba(30, 52, 80, 0.35), 0 0.3rem 0.8rem -0.2rem rgba(30, 52, 80, 0.4);
  border: 1.5px solid var(--ink);
}
.mk-label {
  background: rgba(255, 250, 240, 0.9); border-radius: 999px; padding: 0.25rem 0.55rem 0.2rem;
  white-space: nowrap; box-shadow: 0 0.2rem 0.6rem -0.2rem rgba(30, 52, 80, 0.45);
}
.mk-nolabel .mk-label { display: none; }
.mk-big { font-size: 1rem; margin: -1.05rem 0 0 -1.05rem; transform-origin: 1.05rem 50%; }
.mk-big .mk-icon { width: 2.1rem; height: 2.1rem; background: var(--sun); border-width: 2px; }
.mk-big .mk-label { font-family: var(--font-display); font-size: 1.12rem; padding: 0.3rem 0.75rem 0.15rem; background: #fff; border: 2px solid var(--ink); box-shadow: 0 0.2rem 0 var(--ink); }
.mk-camp .mk-icon { background: var(--blossom-50); }
.mk-dungeon .mk-icon, .mk-dungeons .mk-icon { background: #efe8ff; }
.mk-landmarks .mk-icon { background: #fff4d6; }
.mk-sites .mk-icon { width: 1.35rem; height: 1.35rem; }
.mk-sites .mk-label { font-weight: 700; font-size: 0.76rem; }
.mk-relief .mk-icon { background: var(--sky-100); }
.mk-relief .mk-label { font-style: italic; font-weight: 700; color: var(--sky-700); }
.mk:hover .mk-icon, .mk:focus-visible .mk-icon { transform: scale(1.12); }

/* ---------------- card ---------------- */
.card {
  position: absolute; left: 0; top: 0; z-index: 20; width: min(17rem, calc(100vw - 2rem));
  background: rgba(255, 250, 240, 0.97); border: 2px solid var(--ink); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-ink), var(--shadow); padding: 0.9rem 1rem 1rem; will-change: transform;
}
.card[hidden] { display: none; }
.card-kind { padding-right: 2rem; }
.card-title { font-size: 1.45rem; font-weight: 800; margin-top: 0.2rem; padding-right: 1.5rem; }
.card-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0.7rem 0 0.9rem; font-size: 0.9rem; }
.card-facts dt { color: var(--ink-soft); font-weight: 700; }
.card-facts dd { margin: 0; font-weight: 700; }
.card-close {
  position: absolute; top: 0.5rem; right: 0.5rem; width: 2rem; height: 2rem; border-radius: 50%;
  border: 2px solid var(--line); background: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink);
}
.card-close:hover { border-color: var(--ink); }
.card.card-docked { left: 1rem; right: 1rem; top: auto; bottom: calc(1rem + env(safe-area-inset-bottom)); width: auto; transform: none !important; }

/* ---------------- control panel ---------------- */
.panel {
  position: absolute; z-index: 10; top: calc(var(--bar-h) + 1rem); left: 1rem; width: 19.5rem; max-width: calc(100vw - 2rem);
  background: rgba(255, 250, 240, 0.9); backdrop-filter: saturate(1.3) blur(10px); -webkit-backdrop-filter: saturate(1.3) blur(10px);
  border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-ink), var(--shadow);
  padding: 0.8rem 0.9rem 0.9rem;
}
.panel-head { display: flex; align-items: center; gap: 0.5rem; }
.seed { display: flex; flex-direction: column; line-height: 1.05; margin-inline-end: auto; }
.seed-label { margin-bottom: 0.1rem; }
.seed-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--sky-700); }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; font: 800 0.85rem/1 var(--font-body); color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 0.45rem 0.7rem; cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip .icon { width: 1.1em; height: 1.1em; stroke-width: 2.4; }
.chip.icon-only { padding: 0.4rem; }
.chip.icon-only .icon { transition: transform 0.2s; }
.panel.collapsed .chip.icon-only .icon { transform: rotate(180deg); }
.panel.collapsed .panel-body { display: none; }
.share-state { font-size: 0.82rem; font-weight: 700; color: var(--meadow-700); min-height: 0; }
.share-state:empty { display: none; }
.panel-body { margin-top: 0.7rem; display: grid; gap: 0.85rem; }

.search { position: relative; }
.search input {
  width: 100%; font: 700 0.95rem/1.2 var(--font-body); color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 999px; padding: 0.55rem 0.9rem 0.5rem 2.2rem;
}
.search input:focus { border-color: var(--sky-500); outline: none; box-shadow: 0 0 0 3px rgba(63, 169, 236, 0.25); }
.search-icon { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); width: 1.05rem; height: 1.05rem; color: var(--ink-soft); stroke-width: 2.4; }
.search-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 0.3rem); margin: 0; padding: 0.3rem; list-style: none;
  background: #fff; border: 2px solid var(--ink); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 16rem; overflow: auto;
}
.search-results li { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 0.6rem; cursor: pointer; font-weight: 700; font-size: 0.92rem; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--sky-100); }
.search-results svg { width: 1.3rem; height: 1.3rem; flex: none; }
.search-results small { margin-inline-start: auto; color: var(--ink-soft); font-weight: 700; }
[dir="rtl"] .search input { padding: 0.55rem 2.2rem 0.5rem 0.9rem; }
[dir="rtl"] .search-icon { left: auto; right: 0.7rem; }

.time-label { display: block; }
.time input[type="range"] {
  width: 100%; margin: 0.35rem 0 0.1rem; appearance: none; -webkit-appearance: none; height: 0.7rem; border-radius: 999px; cursor: pointer;
  background: linear-gradient(90deg, #8fd0fa, #ffe39a 40%, #ffb27a 60%, #ff8fb1 80%, #6b5fa8);
  border: 2px solid var(--ink);
}
.time input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); box-shadow: 0 0.15rem 0 var(--ink); }
.time input[type="range"]::-moz-range-thumb { width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); box-shadow: 0 0.15rem 0 var(--ink); }
.time-marks { display: flex; justify-content: space-between; font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); }

.layers { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.6rem; }
.layers legend { padding: 0; margin-bottom: 0.4rem; }
.layers label { display: flex; align-items: center; gap: 0.4rem; font-weight: 700; font-size: 0.88rem; cursor: pointer; }
.layers input { width: 1rem; height: 1rem; accent-color: var(--sky-700); margin: 0; }
.swatch { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 1.5px solid var(--ink); flex: none; }
.sw-town { background: var(--sun); } .sw-landmark { background: #fff4d6; } .sw-dungeon { background: #b89cff; } .sw-site { background: var(--meadow-300); } .sw-relief { background: var(--sky-300); } .sw-island { background: #8fd67a; } .sw-realm { background: #5a1f3d; }
.hint { font-size: 0.78rem; line-height: 1.4; color: var(--ink-soft); font-weight: 600; }

/* ---------------- minimap, status, provenance ---------------- */
.minimap {
  position: absolute; z-index: 10; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); width: 13.75rem; aspect-ratio: 1;
  border: 2px solid var(--ink); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-ink), var(--shadow); background: #7fb66c;
}
.minimap img, .minimap canvas, .minimap-hit { position: absolute; inset: 0; width: 100%; height: 100%; }
.minimap-hit { background: none; border: 0; cursor: crosshair; padding: 0; }
.status {
  position: absolute; z-index: 10; right: 15.75rem; bottom: calc(1.1rem + env(safe-area-inset-bottom));
  font-weight: 800; font-size: 0.85rem; background: rgba(255, 250, 240, 0.9); border-radius: 999px; padding: 0.35rem 0.8rem 0.3rem;
  box-shadow: var(--shadow-soft); pointer-events: none;
}
.status:empty { display: none; }
.provenance {
  position: absolute; z-index: 5; left: 1rem; bottom: calc(0.8rem + env(safe-area-inset-bottom)); max-width: 26rem;
  font-size: 0.74rem; font-weight: 700; color: rgba(30, 52, 80, 0.85); background: rgba(255, 250, 240, 0.72); border-radius: 0.6rem; padding: 0.3rem 0.6rem;
}
.provenance:empty { display: none; }

/* ---------------- intro ---------------- */
/* While the camera flies in, only the world, its cities and the camp: the controls wait. */
.panel, .minimap, .provenance { transition: opacity 0.8s ease, transform 0.8s ease; }
.intro-playing .panel { opacity: 0; transform: translateX(-1rem); pointer-events: none; }
.intro-playing .minimap { opacity: 0; transform: translateY(1rem); pointer-events: none; }
.intro-playing .provenance { opacity: 0; }
.intro-playing .mk:not(.mk-big) { opacity: 0; pointer-events: none; }
.mk { transition: opacity 0.6s ease; }
.intro {
  position: absolute; z-index: 15; left: 50%; bottom: calc(12vh + env(safe-area-inset-bottom)); transform: translateX(-50%);
  text-align: center; color: #fff; pointer-events: none; width: min(40rem, calc(100vw - 2rem));
  text-shadow: 0 0.15rem 0 rgba(20, 50, 90, 0.35), 0 0.3rem 1.4rem rgba(20, 50, 90, 0.55);
  animation: intro-in 1.6s ease both;
}
.intro[hidden] { display: none; }
.intro.leaving { animation: intro-out 0.8s ease both; }
.intro-kicker { font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.9rem; }
.intro-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 1; margin-top: 0.3rem; }
.intro-title strong { color: var(--sun); }
.intro-lead { font-weight: 700; font-size: 1.1rem; margin-top: 0.6rem; }
.intro .button { margin-top: 1.1rem; pointer-events: auto; text-shadow: none; }
@keyframes intro-in { from { opacity: 0; transform: translate(-50%, 1rem); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes intro-out { to { opacity: 0; transform: translate(-50%, -0.5rem); } }

/* ---------------- loading and fallback ---------------- */
.loading { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: linear-gradient(#5aa7dc, #bfe4fc); transition: opacity 0.9s ease; }
.loading.done { opacity: 0; pointer-events: none; }
.loading-art { position: absolute; inset: -5%; width: 110%; height: 110%; object-fit: cover; filter: blur(14px) saturate(1.15); opacity: 0.75; transform: scale(1.05); }
.loading-box { position: relative; text-align: center; background: rgba(255, 250, 240, 0.92); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-ink), var(--shadow); padding: 1.4rem 2rem 1.2rem; width: min(22rem, calc(100vw - 2rem)); }
.loading-logo { margin: 0 auto; animation: bob 2.4s ease-in-out infinite; }
.loading-title { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; margin-top: 0.4rem; }
.progress { height: 0.8rem; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; margin-top: 0.8rem; background: #fff; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--meadow-500), var(--sun)); transition: width 0.3s ease; }
.loading-detail { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); margin-top: 0.5rem; min-height: 1.2em; }
@keyframes bob { 50% { transform: translateY(-0.4rem) rotate(-4deg); } }

.fallback { position: absolute; inset: 0; z-index: 45; overflow: auto; background: var(--cream); padding: calc(var(--bar-h) + 1.5rem) 1rem 2rem; }
.fallback[hidden] { display: none; }
.fallback-box { width: min(48rem, 100%); margin: 0 auto; display: grid; gap: 1rem; justify-items: start; }
.fallback-box h2 { font-size: clamp(2rem, 4.2vw, 3rem); font-weight: 800; }
.fallback-box p { font-size: clamp(1.05rem, 0.6vw + 0.9rem, 1.2rem); color: var(--ink-soft); max-width: 42rem; }
.fallback-box img { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.fallback-box img[hidden] { display: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------- small screens ---------------- */
@media (max-width: 40rem) {
  .panel { top: calc(var(--bar-h) + 0.6rem); left: 0.6rem; right: 0.6rem; width: auto; padding: 0.6rem 0.7rem; }
  .panel-body { gap: 0.7rem; }
  .hint { display: none; }
  .minimap { width: 7.5rem; right: 0.6rem; bottom: calc(0.6rem + env(safe-area-inset-bottom)); }
  .status { right: auto; left: 0.6rem; bottom: calc(3.2rem + env(safe-area-inset-bottom)); font-size: 0.78rem; }
  .provenance { left: 0.6rem; right: 8.8rem; bottom: calc(0.6rem + env(safe-area-inset-bottom)); font-size: 0.68rem; }
  .intro { bottom: 30vh; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-logo, .intro { animation: none; }
}
