/* ===========================================================
   Leonardo da Vinci — Virtual Gallery
   Palette: deep gallery charcoal + warm brass gold + parchment cream
   Display: Cormorant Garamond (Latin wordmark) / Vazirmatn (Farsi)
   =========================================================== */

:root {
  --bg-deep: #16120e;
  --bg-panel: rgba(24, 19, 14, 0.92);
  --gold: #c9a24a;
  --gold-soft: #e0c17a;
  --cream: #f3ecd9;
  --muted: #c9bd9e;
  --line: rgba(201, 162, 74, 0.35);
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--cream);
  font-family: "Vazirmatn", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------------- Landing ---------------- */
#landing {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.landing-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(201,162,74,0.16), transparent 55%),
    linear-gradient(180deg, #1c160f 0%, #100d09 70%, #0a0806 100%);
}
.landing-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 68px);
  opacity: 0.5;
}
.landing-content {
  position: relative;
  z-index: 1;
  max-width: 640px;
  padding: 0 24px;
}
.landing-eyebrow {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  letter-spacing: 0.18em;
  color: var(--gold-soft);
  font-size: 15px;
  margin: 0 0 18px;
  direction: ltr;
}
.landing-title {
  font-family: "Vazirmatn", sans-serif;
  font-weight: 700;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.35;
  margin: 0 0 20px;
  color: var(--cream);
  text-shadow: 0 2px 24px rgba(201,162,74,0.25);
}
.landing-sub {
  font-size: 17px;
  color: var(--muted);
  margin: 0 0 40px;
}
.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1a1409;
  border: none;
  padding: 15px 46px;
  font-size: 17px;
  font-weight: 700;
  border-radius: 2px;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 30px rgba(201,162,74,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(201,162,74,0.45); }
.btn-primary:active { transform: translateY(0); }
.landing-hint {
  margin-top: 26px;
  font-size: 12.5px;
  color: rgba(201,189,158,0.6);
}

/* ---------------- Loading / WebGL error ---------------- */
#loading-screen, #webgl-error {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}
.loading-inner { text-align: center; max-width: 420px; padding: 0 24px; }
.loading-title {
  font-family: "Cormorant Garamond", serif;
  letter-spacing: 0.22em;
  font-size: 20px;
  color: var(--gold-soft);
  margin: 0 0 22px;
  direction: ltr;
}
.loading-track {
  width: 260px;
  height: 3px;
  background: rgba(201,162,74,0.18);
  margin: 0 auto 18px;
  border-radius: 2px;
  overflow: hidden;
}
#loading-bar {
  height: 100%;
  width: 6%;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
  transition: width 0.3s ease;
}
#loading-label { font-size: 13px; color: var(--muted); }

/* ---------------- Canvas ---------------- */
#canvas-wrap { position: fixed; inset: 0; z-index: 1; }
#canvas-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10,8,6,0.55), transparent);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; direction: ltr; text-align: left; }
.brand-line1 { font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 18px; letter-spacing: 0.12em; color: var(--cream); }
.brand-line2 { font-family: "Cormorant Garamond", serif; font-size: 11px; letter-spacing: 0.32em; color: var(--gold-soft); }

.icon-btn {
  pointer-events: auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(20,16,11,0.55);
  color: var(--gold-soft);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.icon-btn:hover { background: rgba(201,162,74,0.16); }

#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(243,236,217,0.75);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

/* info icons projected onto paintings */
#info-icons { position: absolute; inset: 0; }
.info-icon {
  position: absolute;
  width: 88px;
  height: 88px;
  margin: -44px 0 0 -44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(201,162,74,0.9);
  background: rgba(20,16,11,0.82);
  overflow: hidden;
  pointer-events: auto;
  backdrop-filter: blur(4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.22);
  animation: pulse-icon 2.4s ease-in-out infinite;
}
.info-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 11px;
}
@keyframes pulse-icon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,162,74,0.35); }
  50% { box-shadow: 0 0 0 10px rgba(201,162,74,0); }
}

/* info panel */
#info-panel {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  width: min(560px, 92vw);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#info-panel.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.info-panel-inner {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
}
#info-title { margin: 0 0 4px; font-size: 20px; color: var(--gold-soft); font-weight: 700; }
.info-meta { margin: 0; font-size: 13px; color: var(--muted); }
.info-location { margin: 2px 0 10px; font-size: 12.5px; color: rgba(201,189,158,0.75); font-style: italic; }
#info-desc { margin: 0 0 14px; font-size: 14px; line-height: 1.8; color: var(--cream); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--gold-soft);
  color: var(--gold-soft);
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-secondary:hover { background: var(--gold-soft); color: #1a1409; }

/* ---------------- Overlays: controls help + modal ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8,6,4,0.72);
  backdrop-filter: blur(4px);
}
.overlay-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  max-width: 420px;
  width: 90vw;
}
.overlay-card h3 { margin: 0 0 14px; color: var(--gold-soft); font-size: 18px; }
.overlay-card ul { margin: 0 0 20px; padding-inline-start: 20px; font-size: 14px; line-height: 2; color: var(--cream); }

.modal-card {
  position: relative;
  max-width: 88vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
#modal-img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border: 1px solid var(--line);
}
#modal-caption { margin: 14px 0 4px; font-size: 14px; color: var(--cream); text-align: center; }
#modal-source { font-size: 12px; color: var(--gold-soft); text-decoration: none; }
#modal-source:hover { text-decoration: underline; }
.modal-close {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 18px;
}

/* ---------------- Mobile controls ---------------- */
#mobile-controls { position: fixed; inset: 0; pointer-events: none; }
#joystick-base {
  position: absolute;
  left: 26px;
  bottom: 30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(24,19,14,0.5);
  border: 1px solid var(--line);
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
#joystick-knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 50px; height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: rgba(201,162,74,0.55);
  border: 1px solid var(--gold-soft);
  transition: transform 0.05s linear;
}
#look-pad {
  position: absolute;
  top: 0;
  right: 0;
  width: 55%;
  height: 100%;
  pointer-events: auto;
}
#gyro-btn {
  position: absolute;
  top: 70px;
  right: 16px;
  pointer-events: auto;
  background: rgba(24,19,14,0.6);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}
#gyro-btn.active { color: #1a1409; background: var(--gold-soft); border-color: var(--gold-soft); }

/* Only show mobile controls / hide desktop crosshair appropriately */
body.is-mobile #crosshair { display: none; }

/* ---------------- Responsive tweaks ---------------- */
@media (max-width: 560px) {
  .landing-title { font-size: 30px; }
  .info-panel-inner { padding: 14px 16px; }
  #info-desc { font-size: 13px; }
  .brand-line1 { font-size: 15px; }
  #joystick-base { width: 96px; height: 96px; left: 18px; bottom: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .info-icon { animation: none; }
  .btn-primary { transition: none; }
}
