:root {
  --bg: #101111;
  --panel: #171817;
  --panel-2: #20221f;
  --text: #f4f0e8;
  --muted: #b6aea2;
  --line: rgba(244, 240, 232, .16);
  --accent: #c8a66a;
  --accent-2: #876e48;
  --shadow: 0 30px 90px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(200, 166, 106, .12), transparent 34rem),
    linear-gradient(135deg, #0c0d0d 0%, #171817 48%, #0d0e0e 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.no-scroll { overflow: hidden; }

button, a { font: inherit; }

.app-shell {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #f4f0e8;
  color: #151512;
}

.brand-text { font-size: 14px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.nav-links a:hover { color: var(--text); }

.tour-layout {
  min-height: calc(100svh - 100px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.viewer-card,
.project-panel,
.gallery-section {
  border: 1px solid var(--line);
  background: rgba(23, 24, 23, .88);
  box-shadow: var(--shadow);
}

.viewer-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  overflow: hidden;
}

.viewer-card:fullscreen,
.viewer-card.is-pseudo-fullscreen {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  border: 0;
  z-index: 1000;
  background: var(--panel);
}

.viewer-card.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
}

.viewer-card:fullscreen .viewport,
.viewer-card.is-pseudo-fullscreen .viewport {
  min-height: 0;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.project-label,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3.2vw, 54px);
  line-height: .95;
  font-weight: 500;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  line-height: 1;
  font-weight: 500;
}

.toolbar-actions,
.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.panel-actions a {
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 0 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

button:hover,
.panel-actions a:hover,
button[aria-pressed="true"] {
  border-color: rgba(200, 166, 106, .65);
  background: rgba(200, 166, 106, .16);
}

.viewport {
  position: relative;
  overflow: hidden;
  min-height: 56vh;
  outline: none;
  perspective: 900px;
  cursor: grab;
  background: #080909;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.viewport:active { cursor: grabbing; }

.scene {
  position: absolute;
  inset: -6%;
  transform-style: preserve-3d;
  transition: transform .24s ease;
}

.photo-plane {
  position: absolute;
  inset: 0;
  background-image: var(--active-image);
  background-size: cover;
  background-position: var(--focus-x, 50%) var(--focus-y, 50%);
  transform: translateZ(-90px) scale(1.1);
  filter: saturate(1.02) contrast(1.04);
}

.photo-plane::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(8, 9, 9, .68), transparent 26%, transparent 70%, rgba(8, 9, 9, .72)),
    linear-gradient(0deg, rgba(8, 9, 9, .82), transparent 34%, rgba(8, 9, 9, .18));
}

.floor-grid {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -30%;
  height: 48%;
  transform: rotateX(74deg) translateZ(50px);
  transform-origin: 50% 100%;
  background:
    linear-gradient(rgba(200, 166, 106, .18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 166, 106, .12) 1px, transparent 1px),
    linear-gradient(180deg, rgba(16, 17, 17, 0), rgba(16, 17, 17, .92));
  background-size: 90px 90px, 90px 90px, 100% 100%;
  opacity: .75;
}

.hotspot {
  position: absolute;
  z-index: 4;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(200, 166, 106, .78);
  box-shadow: 0 0 0 12px rgba(200, 166, 106, .18);
  touch-action: manipulation;
}

.hotspot::before {
  content: "";
  width: 12px;
  height: 12px;
  display: block;
  margin: auto;
  border-top: 2px solid #171817;
  border-right: 2px solid #171817;
  transform: rotate(45deg);
}

.hotspot-prev::before { transform: rotate(225deg); }
.hotspot-next::before { transform: rotate(45deg); }
.hotspot-forward::before { transform: rotate(135deg); }

.hotspot-a { left: 12%; top: 52%; }
.hotspot-b { left: 74%; top: 52%; }
.hotspot-c { left: 49%; top: 64%; }

.view-hud {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.view-hud span {
  border: 1px solid var(--line);
  background: rgba(12, 13, 13, .7);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
}

.minimap {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(260px, calc(100% - 36px));
  border: 1px solid var(--line);
  background: rgba(12, 13, 13, .72);
  backdrop-filter: blur(14px);
  padding: 10px;
  z-index: 2;
}

.plan-shell {
  fill: rgba(244, 240, 232, .08);
  stroke: rgba(244, 240, 232, .7);
  stroke-width: 4;
}

.plan-wall {
  fill: none;
  stroke: rgba(244, 240, 232, .32);
  stroke-width: 3;
}

.pin {
  cursor: pointer;
}

.pin circle {
  fill: rgba(200, 166, 106, .92);
  stroke: #f4f0e8;
  stroke-width: 2;
}

.pin.is-active circle { fill: #f4f0e8; stroke: var(--accent); }

.step-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(128px, 1fr);
  gap: 1px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.step-button {
  height: 112px;
  border: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
  justify-content: flex-start;
  align-items: flex-end;
}

.step-button img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .72;
  transition: transform .24s ease, opacity .24s ease;
}

.step-button span {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 36px 10px 10px;
  text-align: left;
  background: linear-gradient(0deg, rgba(0, 0, 0, .82), transparent);
}

.step-button.is-active img,
.step-button:hover img {
  opacity: 1;
  transform: scale(1.05);
}

.project-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 24px;
}

.project-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.stats {
  display: grid;
  gap: 12px;
  margin: 0;
}

.stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
}

.stats dd {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.panel-actions {
  justify-content: stretch;
}

.panel-actions a { flex: 1; }

.gallery-section {
  margin-top: 18px;
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 { margin: 0; }
.section-heading p { margin: 0; color: var(--muted); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.gallery-tile {
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 1px solid var(--line);
  overflow: hidden;
}

.gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

.gallery-tile:hover img { transform: scale(1.04); }

/* ---- Gaussian-splat world section ---- */
/* `hidden` is overridden by any explicit display (grid/flex); enforce it so the
   loader/dock/hud actually hide and don't intercept the poster click. */
[hidden] { display: none !important; }

.world-section {
  margin-top: 18px;
  padding: 24px;
}

.world-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 120% at 50% 0%, #15161a, #080909 70%);
  touch-action: none;
}

.world-stage:fullscreen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100dvh;
  border: 0;
  background: #080909;
}

.world-canvas {
  position: absolute;
  inset: 0;
}

.world-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

/* poster / click-to-load */
.world-poster {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(8, 9, 9, .55), rgba(8, 9, 9, .82)),
    var(--poster-image, none);
  background-size: cover;
  background-position: center;
}

.world-poster-inner {
  position: absolute;
  left: 50%;
  bottom: clamp(22px, 6%, 44px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px 14px 14px;
  border: 1px solid rgba(200, 166, 106, .5);
  background: rgba(12, 13, 13, .66);
  backdrop-filter: blur(10px);
  text-align: left;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.world-poster:hover .world-poster-inner {
  border-color: rgba(200, 166, 106, .9);
  background: rgba(200, 166, 106, .14);
  transform: translateX(-50%) translateY(-2px);
}

.world-play {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 10px rgba(200, 166, 106, .14);
}

.world-play::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 4px;
  border-left: 14px solid #151512;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.world-poster-copy { display: flex; flex-direction: column; gap: 3px; }
.world-poster-copy strong { font-size: 15px; font-weight: 800; }
.world-poster-copy small { color: var(--muted); font-size: 12px; }

/* loader */
.world-loader {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(120% 100% at 50% 0%, #14161c, #080909);
  text-align: center;
  padding: 2rem;
}

.world-loader p { margin: 0; color: var(--muted); font-size: 13px; }
.world-loader p.is-error { color: oklch(72% 0.17 25); }

.world-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(244, 240, 232, .14);
  border-top-color: var(--accent);
  animation: world-spin 900ms linear infinite;
}

@keyframes world-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .world-ring { animation-duration: 2.4s; } }

/* on-canvas instructions */
.world-hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: rgba(12, 13, 13, .72);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  transition: opacity .5s ease, transform .5s ease;
}

.world-hud.is-faded { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }

/* controls dock */
.world-dock {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  background: rgba(12, 13, 13, .72);
  backdrop-filter: blur(12px);
}

.world-dock button { min-height: 34px; }

@media (max-width: 1080px) {
  .tour-layout { grid-template-columns: 1fr; }
  .project-panel { min-height: 0; }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .world-stage { aspect-ratio: 3 / 4; }
  .world-poster-inner { gap: 12px; padding: 12px; }
  .world-poster-copy small { display: none; }
}

@media (max-width: 720px) {
  .app-shell { padding: 10px; }
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 0 14px;
  }
  .nav-links {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .viewer-toolbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }
  h1 { font-size: 34px; }
  .viewport { min-height: 62svh; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions button { flex: 1; }
  .view-hud { flex-direction: column; }
  .minimap { display: none; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
