/* ==========================================================
   ar.css — Vektor-AR-View
   ========================================================== */

.ar-view {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  background: #1A1410;
  color: #FFF;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.ar-view.hidden { display: none; }

/* Himmel-Hintergrund mit Tag/Dämmerungs-Gradient */
.ar-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    #5A7A95 0%,
    #8FA9C3 35%,
    #C8B89F 65%,
    #5C5142 78%,
    #2E2620 100%
  );
  transition: opacity 0.3s ease;
}

/* Kamera-Live-Video (im Camera-Mode aktiv) */
.ar-camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  background: #000;
}
.ar-camera-video.hidden { display: none; }

/* Im Camera-Mode: Sky + Mountains ausblenden, Pins drüberlegen */
.ar-view[data-mode="camera"] .ar-sky { opacity: 0; }
.ar-view[data-mode="camera"] .ar-mountains-layer { opacity: 0.18; }
.ar-view[data-mode="camera"] .ar-poi-label {
  background: rgba(0, 0, 0, 0.78);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Bergsilhouetten-Layer */
.ar-mountains-layer {
  position: absolute;
  bottom: 18%;
  left: 0;
  right: 0;
  height: 38%;
  pointer-events: none;
  overflow: hidden;
}
.ar-mountains-fallback {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
}
.ar-mountain {
  position: absolute;
  bottom: 0;
  width: 380px;
  height: 100%;
  transform-origin: bottom center;
  fill: rgba(40, 50, 65, 0.88);
  transition: opacity 0.3s ease, transform 0.10s linear, left 0.10s linear;
  will-change: transform, left, opacity;
}
.ar-mountain[data-known="0"] {
  fill: rgba(60, 70, 85, 0.7);
}

/* POI-Layer */
.ar-poi-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* POI-Marker */
.ar-poi {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, -100%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.25s ease, transform 0.18s ease-out, left 0.12s linear, top 0.18s linear;
  will-change: left, top, transform, opacity;
}
.ar-poi.hidden { display: none; }

.ar-poi-pin {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  background: #C9925E;
  border: 2px solid #FFF;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.ar-poi-pin svg {
  transform: rotate(45deg);
  width: 16px;
  height: 16px;
  color: #FFF;
}

.ar-poi-label {
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #FFF;
  padding: 4px 10px;
  border-radius: var(--radius-pill, 12px);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.ar-poi-distance {
  display: block;
  font-weight: 400;
  font-size: 10px;
  opacity: 0.75;
  margin-top: 1px;
}

/* POI nach Typ einfärben */
.ar-poi[data-type="peak"]      .ar-poi-pin { background: #7A5C45; }
.ar-poi[data-type="lake"]      .ar-poi-pin { background: #4A6F8A; }
.ar-poi[data-type="sculpture"] .ar-poi-pin { background: #C9925E; }
.ar-poi[data-type="ruin"]      .ar-poi-pin { background: #6B5A50; }
.ar-poi[data-type="viewpoint"] .ar-poi-pin { background: #8A7050; }
.ar-poi[data-type="village"]   .ar-poi-pin { background: #9B8060; }
.ar-poi[data-type="cave"],
.ar-poi[data-type="mine"]      .ar-poi-pin { background: #444; }

/* POIs außerhalb des FOV: am Rand als kleiner Pfeil-Hinweis */
.ar-poi.peripheral {
  opacity: 0.55;
}
.ar-poi.peripheral .ar-poi-label {
  font-size: 10px;
  padding: 2px 6px;
}

/* Kopfzeile */
.ar-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}

.ar-close {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.ar-close:active { background: rgba(0, 0, 0, 0.7); }
.ar-close svg { width: 22px; height: 22px; }

.ar-compass {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFF;
  padding: 8px 14px;
  border-radius: var(--radius-card, 20px);
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.ar-compass-dir {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}
.ar-compass-deg {
  font-size: 12px;
  opacity: 0.7;
}

/* Statusleiste */
.ar-statusbar {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.85);
  padding: 8px 16px;
  border-radius: var(--radius-card, 18px);
  font-size: 12px;
  text-align: center;
  max-width: 80%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 4;
}

/* Permission-Prompt */
.ar-permission-prompt {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ar-permission-prompt.hidden { display: none; }
.ar-permission-card {
  background: #FFF;
  color: #2A1810;
  border-radius: var(--radius-card, 18px);
  padding: 24px;
  max-width: 320px;
  text-align: center;
}
.ar-permission-card h3 { margin: 0 0 8px; font-size: 18px; }
.ar-permission-card p { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: rgba(42, 24, 16, 0.75); }
.ar-perm-btn {
  background: #C9925E;
  color: #FFF;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-pill, 24px);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.ar-perm-btn:active { background: #B98850; }

/* ==========================================================
   Topic-Sheet (Bottom-Sheet für Topic-Auswahl + Antwort)
   ========================================================== */

.topic-sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}
.topic-sheet.hidden { display: none; }
.topic-sheet:not(.hidden) { pointer-events: auto; }

.topic-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s;
}
.topic-sheet:not(.hidden) .topic-sheet-backdrop { opacity: 1; }

.topic-sheet-card {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #F5EFE6;
  color: #2A1810;
  border-radius: var(--radius-card, 22px) var(--radius-card, 22px) 0 0;
  padding: 18px 20px max(28px, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.28, 1);
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.topic-sheet:not(.hidden) .topic-sheet-card { transform: translateY(0); }

.topic-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 4px;
}
.topic-sheet-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}
.topic-sheet-close {
  background: rgba(45, 25, 10, 0.08);
  border: none;
  color: #2A1810;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.topic-sheet-close svg { width: 18px; height: 18px; }
.topic-sheet-meta {
  font-size: 13px;
  color: rgba(42, 24, 16, 0.65);
  margin-bottom: 14px;
}

.topic-sheet-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.topic-btn {
  background: #FFF;
  border: 1px solid rgba(45, 25, 10, 0.12);
  color: #2A1810;
  padding: 12px 14px;
  border-radius: var(--radius-pill, 12px);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.12s;
}
.topic-btn:active {
  background: #FAF4EA;
  transform: scale(0.98);
}
.topic-btn[data-loading="1"] {
  opacity: 0.6;
  cursor: wait;
}
.topic-btn[data-cached="1"]::after {
  content: "⚡";
  margin-left: auto;
  opacity: 0.5;
  font-size: 12px;
}
.topic-btn-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.topic-sheet-answer {
  background: #FFF;
  border: 1px solid rgba(45, 25, 10, 0.1);
  border-radius: var(--radius-msg, 14px);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: #2A1810;
  min-height: 60px;
  display: none;
}
.topic-sheet-answer.show { display: block; }
.topic-sheet-answer.loading {
  display: block;
  color: rgba(42, 24, 16, 0.5);
  font-style: italic;
  text-align: center;
}

/* ==========================================================
   AR-Karte auf Skulpturen-Auswahl-Screen
   ========================================================== */

.sculpture-card.ar-card {
  background: linear-gradient(135deg, #4A6F8A 0%, #7A5C45 100%);
}
.sculpture-card.ar-card .sculpture-img-wrap {
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sculpture-card.ar-card .sculpture-img-wrap::before {
  content: "🏔️";
  font-size: 44px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* ==========================================================
   Mode-Toggle (Vektor ↔ Kamera)
   ========================================================== */
.ar-mode-toggle {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.ar-mode-toggle:active { background: rgba(0, 0, 0, 0.7); }
.ar-mode-toggle span { display: none; align-items: center; justify-content: center; width: 100%; height: 100%; }
.ar-mode-toggle span svg { width: 22px; height: 22px; }
/* Aktueller Modus: zeige das ANDERE Symbol als Toggle-Hint */
.ar-mode-toggle[data-mode="vector"] .ar-mode-camera { display: flex; }
.ar-mode-toggle[data-mode="camera"] .ar-mode-vector { display: flex; }

/* ==========================================================
   Radar-Widget (Vogelperspektive)
   ========================================================== */
.ar-radar {
  position: absolute;
  bottom: max(60px, calc(env(safe-area-inset-bottom) + 50px));
  right: 14px;
  width: 110px;
  height: 110px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  z-index: 6;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.ar-radar-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.ar-radar-poi {
  cursor: pointer;
  pointer-events: auto;
  transition: r 0.15s ease;
}
.ar-radar-poi[data-type="peak"]      { fill: #C8A883; }
.ar-radar-poi[data-type="lake"]      { fill: #6FA0B8; }
.ar-radar-poi[data-type="sculpture"] { fill: #E9B47C; }
.ar-radar-poi[data-type="ruin"]      { fill: #9C8A7E; }
.ar-radar-poi[data-type="viewpoint"] { fill: #B89770; }
.ar-radar-poi[data-type="village"]   { fill: #C9B093; }

/* Im Camera-Mode kann Radar etwas dunkler sein */
.ar-view[data-mode="camera"] .ar-radar {
  background: rgba(0, 0, 0, 0.65);
}
