:root {
  --bg: #efece5;
  --bg-2: #f6f4ef;
  --ink: #2a2724;
  --ink-soft: #6f6a63;
  --line: rgba(40, 36, 32, 0.14);
  --accent: #9a3b2e;
  --font: "Helvetica Neue", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-amifer: "Amifer", "Helvetica Neue", system-ui, sans-serif;
  --serif: "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 26px 34px;
  pointer-events: auto;
}
.hud--top { top: 0; align-items: flex-start; }

.hud__left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hud__title {
  font-family: var(--font-amifer);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.015em;
  color: var(--ink);
  line-height: 1.1;
}

.hud__filters {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.hud__filter {
  appearance: none;
  border: none;
  background: none;
  padding: 4px 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-amifer);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  opacity: 0.5;
  transform-origin: left center;
  transition: opacity 0.25s ease, color 0.25s ease, transform 0.35s ease;
}

.hud__filter-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: currentColor;
  opacity: 0.85;
}

.hud__filter span {
  font-family: var(--font-amifer);
}

.hud__filter:hover {
  opacity: 0.85;
  color: var(--ink);
}

.hud__filter.is-active {
  opacity: 1;
  color: var(--ink);
}

.hud__filter.is-pulse {
  animation: filterPulse 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes filterPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.hud__right {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 4px;
}

.hud__info-btn {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-amifer);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease;
}
.hud__info-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.hud__info-btn:hover {
  opacity: 1;
  color: var(--ink);
}

.hud__count {
  font-family: var(--font-amifer);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* ---------- Info modal ---------- */
.info {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(239, 236, 229, 0);
  backdrop-filter: blur(0px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease,
    backdrop-filter 0.45s ease, background 0.45s ease;
}
.info.open {
  opacity: 1;
  visibility: visible;
  background: rgba(239, 236, 229, 0.72);
  backdrop-filter: blur(12px);
}

.info__panel {
  position: relative;
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 44px 46px 38px;
  box-shadow: 0 40px 90px -40px rgba(40, 30, 20, 0.5);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.info.open .info__panel {
  transform: translateY(0) scale(1);
}

.info__close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.info__close:hover { opacity: 1; transform: rotate(90deg); }

.info__title {
  font-family: var(--font-amifer);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  color: var(--ink);
}
.info__lead {
  font-family: var(--font-amifer);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 22px;
}
.info__body {
  font-family: var(--font-amifer);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}
.info__body p { margin: 0 0 14px; }
.info__body ul {
  margin: 0 0 14px;
  padding-left: 18px;
  list-style: none;
}
.info__body li {
  position: relative;
  padding: 3px 0;
}
.info__body li::before {
  content: "—";
  position: absolute;
  left: -18px;
  color: var(--accent);
}
.info__body strong { font-weight: 500; }

.info__hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-family: var(--font-amifer);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* ---------- Scroll hint ---------- */
.hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  transition: opacity 0.6s ease;
  mix-blend-mode: multiply;
}
.hint.hide { opacity: 0; }
.hint__mouse {
  width: 22px;
  height: 36px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 12px;
  position: relative;
}
.hint__mouse span {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 3px;
  height: 7px;
  border-radius: 2px;
  background: var(--ink-soft);
  transform: translateX(-50%);
  animation: scrollDot 1.6s ease-in-out infinite;
}
@keyframes scrollDot {
  0% { opacity: 0; transform: translate(-50%, 0); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, 12px); }
}
.hint__text {
  font-family: var(--font-amifer);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

/* ---------- Loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 42%, #f6f3ec 0%, var(--bg) 68%);
  transition: opacity 0.9s ease, visibility 0.9s ease;
  pointer-events: auto;
}
.loader.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  animation: loaderIn 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.loader__mark {
  font-family: var(--font-amifer);
  font-size: 46px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ink);
  animation: loaderPulse 2.4s ease-in-out infinite;
}

.loader__progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(72vw, 320px);
}

.loader__bar {
  position: relative;
  width: 100%;
  height: 3px;
  background: var(--line);
  overflow: hidden;
  border-radius: 2px;
}

.loader__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: loaderShimmer 1.6s ease-in-out infinite;
}

.loader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.loader__pct {
  font-family: var(--font-amifer);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  min-width: 3.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.loader__text {
  font-family: var(--font-amifer);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  animation: loaderText 2s ease-in-out infinite;
}

@keyframes loaderIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes loaderPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.72; transform: scale(0.985); }
}

@keyframes loaderShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes loaderText {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 236, 229, 0.0);
  backdrop-filter: blur(0px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease, backdrop-filter 0.5s ease, background 0.5s ease;
}
.lightbox.open {
  opacity: 1;
  visibility: visible;
  background: rgba(239, 236, 229, 0.92);
  backdrop-filter: blur(14px);
}
.lightbox__close {
  position: absolute;
  top: 22px;
  right: 28px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  font-family: var(--font-amifer);
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.lightbox__close:hover { opacity: 1; transform: rotate(90deg); }

.lightbox__stage {
  display: flex;
  align-items: center;
  gap: 48px;
  max-width: 92vw;
  max-height: 86vh;
  transform: translateY(18px) scale(0.98);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox.open .lightbox__stage { transform: translateY(0) scale(1); }

.lightbox__imgwrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  min-height: 200px;
}
.lightbox__imgwrap img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  background: transparent;
  opacity: 0;
  transition: opacity 0.5s ease;
  image-rendering: auto;
}
.lightbox__imgwrap img.loaded { opacity: 1; }

.lightbox__spinner {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.lightbox__spinner.hide { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox__meta {
  width: 320px;
  max-width: 32vw;
  color: var(--ink);
  font-family: var(--font-amifer);
}
.lightbox__meta h2 {
  font-family: var(--font-amifer);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0.01em;
  margin: 0 0 6px;
}
.lightbox__meta .sub {
  font-family: var(--font-amifer);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 22px;
  letter-spacing: 0.02em;
}
.lightbox__meta dl {
  margin: 0;
  border-top: 1px solid var(--line);
}
.lightbox__meta dl > div {
  display: flex;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.lightbox__meta dt {
  flex: 0 0 92px;
  font-family: var(--font-amifer);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 2px;
}
.lightbox__meta dd {
  margin: 0;
  font-family: var(--font-amifer);
  font-size: 14px;
  line-height: 1.45;
}
.lightbox__meta a {
  font-family: var(--font-amifer);
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.lightbox__meta a:hover { opacity: 0.7; }

@media (max-width: 860px) {
  .hud__title { font-size: 24px; }
  .loader__mark { font-size: 34px; }
  .lightbox__stage { flex-direction: column; gap: 22px; max-height: 90vh; overflow: auto; }
  .lightbox__meta { width: 88vw; max-width: 88vw; }
  .hud { padding: 18px 20px; }
  .hud__filter { font-size: 13px; }
}
