/* Gallery – Full-screen 3D experience */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  overflow: hidden;
  height: 100%;
  background: #111;
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Monaco, "Courier New", monospace;
  color: #fff;
}

html.gallery-2d-mode,
html.gallery-2d-mode body {
  overflow: auto;
  height: auto;
  min-height: 100%;
}

/* ── Canvas Container ────────────────────────────── */

#gallery-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#gallery-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Loading Screen ──────────────────────────────── */

#gallery-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.loading-text {
  font-size: 13px;
  color: #666;
  letter-spacing: 0.05em;
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: #333;
  border-radius: 1px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: #0057B7;
  transition: width 0.3s ease;
}

/* ── Welcome / Intro Overlay ─────────────────────── */

#gallery-welcome {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 10, 10, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 32px;
  opacity: 0;
  animation: fadeIn 0.8s ease forwards;
}

#gallery-welcome::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #0057B7 0%, #0057B7 50%, #FFD700 50%, #FFD700 100%);
  z-index: 1;
}

#gallery-welcome::after {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(196, 92, 62, 0.25);
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 18px,
      rgba(196, 92, 62, 0.06) 18px 19px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0 18px,
      rgba(0, 87, 183, 0.05) 18px 19px
    );
}

@keyframes fadeIn {
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #gallery-welcome,
  #artwork-modal {
    animation: none;
    opacity: 1;
  }
}

.welcome-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.welcome-label {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 16px;
}

.welcome-title {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: #fff;
}

.welcome-subtitle {
  font-size: 14px;
  color: #999;
  max-width: 440px;
  line-height: 1.7;
  margin-bottom: 20px;
}

.welcome-intro {
  font-size: 13px;
  color: #888;
  max-width: 440px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.welcome-spaces {
  list-style: none;
  text-align: left;
  max-width: 400px;
  margin: 0 auto 32px;
  padding: 0;
}

.welcome-spaces li {
  font-size: 12px;
  color: #777;
  line-height: 1.8;
  padding: 6px 0;
  border-bottom: 1px solid #222;
}

.welcome-spaces li:last-child {
  border-bottom: none;
}

.welcome-spaces strong {
  color: #ccc;
  font-weight: 500;
}

.welcome-enter {
  display: inline-block;
  padding: 12px 32px;
  font-size: 13px;
  font-family: inherit;
  background: #0040FF;
  color: #fff;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s;
}

.welcome-enter:hover {
  background: #0033cc;
}

.welcome-2d {
  display: block;
  margin: 12px auto 0;
  padding: 8px 16px;
  font-size: 12px;
  font-family: inherit;
  background: transparent;
  color: #666;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.welcome-2d:hover {
  color: #fff;
}

.welcome-hint {
  font-size: 11px;
  color: #555;
  margin-top: 16px;
}

/* ── Welcome footer (donate CTA, nav, lang) ──────── */

.welcome-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
}

.welcome-donate {
  display: inline-block;
  padding: 10px 24px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: border-color 0.2s, background 0.2s;
}

.welcome-donate:hover {
  border-color: #0040FF;
  background: #0040FF;
  color: #fff;
}

.welcome-links {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.welcome-links a {
  color: #666;
  text-decoration: none;
  transition: color 0.2s;
}

.welcome-links a:hover {
  color: #fff;
}

.welcome-sep {
  color: #333;
}

/* ── HUD (in-gallery overlay) ────────────────────── */

#gallery-hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: none;
}

body.gallery-cursor-free {
  cursor: default;
}

body.gallery-cursor-free .hud-crosshair {
  display: none;
}

body.gallery-cursor-free .hud-map-btn {
  cursor: pointer;
}

.hud-space {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.05em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.hud-top-right {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-map-btn {
  pointer-events: auto;
  padding: 6px 14px;
  font-size: 11px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s, color 0.2s;
}

.hud-map-btn:hover {
  background: #0040FF;
  color: #fff;
  border-color: #0040FF;
}

.hud-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  mix-blend-mode: difference;
}

.hud-hint {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform: translate(-50%, 40px);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.05em;
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.hud-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  line-height: 1.8;
  text-align: center;
}

/* ── Artwork Detail Modal ────────────────────────── */

#artwork-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 10, 10, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.modal-image {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  margin-bottom: 24px;
  border: 1px solid #333;
}

.modal-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #fff;
}

.modal-artist {
  font-size: 13px;
  color: #999;
  margin-bottom: 16px;
}

.modal-story {
  font-size: 14px;
  color: #bbb;
  line-height: 1.7;
  margin-bottom: 24px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.modal-space {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0040FF;
  margin-bottom: 12px;
}

.modal-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.modal-nav-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-family: inherit;
  background: transparent;
  color: #999;
  border: 1px solid #333;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.2s, border-color 0.2s;
}

.modal-nav-btn:hover:not(:disabled) {
  color: #fff;
  border-color: #666;
}

.modal-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.modal-share {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.modal-share-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-family: inherit;
  background: transparent;
  color: #bbb;
  border: 1px solid #444;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.modal-share-btn:hover {
  color: #fff;
  border-color: #0040FF;
  background: rgba(0, 64, 255, 0.12);
}

.modal-share-status {
  flex-basis: 100%;
  min-height: 1.2em;
  font-size: 11px;
  color: #6a9fff;
  letter-spacing: 0.02em;
}

/* ── Space Map Overlay ───────────────────────────── */

#space-map {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(10, 10, 10, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.map-panel {
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.map-title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #fff;
}

.map-subtitle {
  font-size: 12px;
  color: #666;
  margin-bottom: 24px;
}

.map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.map-space-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 12px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.map-space-btn:hover {
  border-color: #0040FF;
  background: #1e1e2e;
}

.map-space-title {
  font-size: 13px;
  font-weight: 500;
}

.map-space-prompt {
  font-size: 11px;
  color: #777;
  line-height: 1.4;
}

.map-space-count {
  font-size: 10px;
  color: #555;
  margin-top: 4px;
}

.map-close {
  padding: 10px 24px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: #999;
  border: 1px solid #333;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.map-close:hover {
  color: #fff;
  border-color: #666;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.modal-donate {
  display: inline-block;
  padding: 10px 24px;
  font-size: 13px;
  font-family: inherit;
  background: #0040FF;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background 0.2s;
}

.modal-donate:hover {
  background: #0033cc;
}

.modal-close {
  display: inline-block;
  padding: 10px 24px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: #999;
  border: 1px solid #333;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.2s, border-color 0.2s;
}

.modal-close:hover {
  color: #fff;
  border-color: #666;
}

/* ── Mobile Controls ─────────────────────────────── */

#mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px;
  pointer-events: none;
}

.mobile-joystick {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.joystick-knob {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.05s;
}

.mobile-btn-group {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.mobile-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.4);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

/* ── 2D Fallback Gallery ─────────────────────────── */

#gallery-2d {
  display: none;
  min-height: 100vh;
  background: #111;
  padding: 0;
  overflow-y: auto;
}

.fallback-header {
  text-align: center;
  padding: 48px 24px 32px;
}

.fallback-header h1 {
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #fff;
}

.fallback-header p {
  font-size: 13px;
  color: #999;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
}

.fallback-3d-unavailable {
  margin-top: 12px !important;
  font-size: 12px !important;
  color: #c9a227 !important;
}

.fallback-space-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 0 24px 24px;
  max-width: 960px;
  margin: 0 auto;
}

.fallback-space-nav a {
  font-size: 12px;
  color: #666;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid #2a2a2a;
  transition: color 0.2s, border-color 0.2s;
}

.fallback-space-nav a:hover {
  color: #fff;
  border-color: #0040FF;
}

.fallback-section {
  margin-bottom: 48px;
}

.fallback-section-title {
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  text-align: center;
  margin-bottom: 4px;
}

.fallback-section-prompt {
  font-size: 12px;
  color: #666;
  text-align: center;
  margin-bottom: 20px;
  font-style: italic;
}

.fallback-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.fallback-grid {
  padding-bottom: 48px;
}

.fallback-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  transition: border-color 0.2s;
}

.fallback-card:hover {
  border-color: #444;
}

.fallback-card-highlight {
  border-color: #0040FF;
  box-shadow: 0 0 0 1px #0040FF;
}

.fallback-card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.fallback-card-body {
  padding: 16px;
}

.fallback-card-title {
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 4px;
}

.fallback-card-meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.fallback-card-story {
  font-size: 13px;
  color: #999;
  line-height: 1.6;
}

.fallback-footer {
  text-align: center;
  padding: 32px 24px 48px;
  border-top: 1px solid #222;
  max-width: 960px;
  margin: 0 auto;
}

.fallback-footer p {
  font-size: 14px;
  color: #999;
  margin-bottom: 16px;
  line-height: 1.7;
}

.fallback-footer a.fallback-donate {
  display: inline-block;
  padding: 10px 24px;
  font-size: 13px;
  font-family: inherit;
  background: #0040FF;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.fallback-nav {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 960px;
  margin: 0 auto;
}

.fallback-nav a {
  font-size: 13px;
  color: #666;
  text-decoration: none;
}

.fallback-nav a:hover {
  color: #fff;
}

.fallback-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.fallback-back {
  color: #0040FF !important;
}

.fallback-back:hover {
  color: #fff !important;
}

.fallback-nav .fn-logo {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 600px) {
  .welcome-title { font-size: 22px; }
  .welcome-subtitle { font-size: 13px; padding: 0 8px; }
  .welcome-footer { padding-top: 16px; }
  .modal-content { padding: 0 8px; }
  .modal-title { font-size: 17px; }
  .modal-story { font-size: 13px; }
  .hud-controls { display: none; }
  .map-grid { grid-template-columns: 1fr; }
  .fallback-grid-inner { grid-template-columns: 1fr; gap: 16px; padding: 0 16px; }
}
