/* Slemani Map kiosk viewer */
:root {
  --bg: #161412;
  --bg-soft: #1f1c19;
  --ink: #f3eee6;
  --muted: rgba(243, 238, 230, 0.62);
  --gold: #c4a574;
  --gold-soft: rgba(196, 165, 116, 0.35);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --touch: 64px;
  --rail-h: 108px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
}

img, svg { -webkit-user-drag: none; }

#app {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 50% 40%, #241f1b 0%, var(--bg) 70%);
}

#stage {
  position: absolute;
  inset: 0 0 var(--rail-h) 0;
  perspective: 2000px;
  overflow: hidden;
  touch-action: none;
  background: var(--bg);
}

.osd-pane {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform, opacity;
  transition: transform 0.52s var(--ease), opacity 0.42s ease;
  background: var(--bg);
}

.osd-pane.is-front { z-index: 2; }
.osd-pane.no-anim { transition: none !important; }

/* Forward: current page curls away to the left */
.osd-pane.is-leave-next {
  transform: perspective(1600px) translateX(-14%) rotateY(-42deg) scaleX(0.78);
  opacity: 0;
  z-index: 3;
}
/* Forward: new page enters from the right */
.osd-pane.is-enter-next {
  transform: perspective(1600px) translateX(42%) rotateY(32deg) scaleX(0.82);
  opacity: 0;
  z-index: 4;
}
/* Backward: current page curls away to the right */
.osd-pane.is-leave-prev {
  transform: perspective(1600px) translateX(14%) rotateY(42deg) scaleX(0.78);
  opacity: 0;
  z-index: 3;
}
/* Backward: new page enters from the left */
.osd-pane.is-enter-prev {
  transform: perspective(1600px) translateX(-42%) rotateY(-32deg) scaleX(0.82);
  opacity: 0;
  z-index: 4;
}

/* Thumbnail placeholder — covers progressive tile squares during animation */
.pane-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 5;
  background: var(--bg);
  transition: opacity 0.7s ease 0.1s;
}
.pane-thumb.is-loaded { opacity: 0; }

/* Respect prefers-reduced-motion — simple crossfade only */
@media (prefers-reduced-motion: reduce) {
  .osd-pane,
  .osd-pane.is-leave-next,
  .osd-pane.is-leave-prev,
  .osd-pane.is-enter-next,
  .osd-pane.is-enter-prev {
    transform: none !important;
    transition: opacity 0.3s ease !important;
  }
}

.nav-arrow {
  position: absolute;
  top: calc(50% - var(--rail-h) / 2);
  transform: translateY(-50%);
  width: var(--touch);
  height: var(--touch);
  border: 0;
  border-radius: 50%;
  background: rgba(22, 20, 18, 0.62);
  color: var(--ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 20;
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}
.nav-arrow svg { width: 28px; height: 28px; }
.nav-arrow.prev { left: max(12px, env(safe-area-inset-left)); }
.nav-arrow.next { right: max(12px, env(safe-area-inset-right)); }
.nav-arrow:hover, .nav-arrow:focus-visible { background: rgba(22, 20, 18, 0.88); outline: none; }
.nav-arrow:active { transform: translateY(-50%) scale(0.96); }
.nav-arrow[disabled] { opacity: 0.28; pointer-events: none; }

#toolbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 20;
}
#toolbar button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(22, 20, 18, 0.62);
  color: var(--ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
}
#toolbar button svg { width: 22px; height: 22px; }
#toolbar button:hover, #toolbar button:focus-visible { background: rgba(22, 20, 18, 0.88); outline: none; }
body.is-fullscreen #btn-fullscreen .icon-enter { display: none; }
body:not(.is-fullscreen) #btn-fullscreen .icon-exit { display: none; }

#rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--rail-h);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #100e0c 70%, rgba(16, 14, 12, 0.85));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 20;
}

.thumbs {
  display: flex;
  gap: 10px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.thumbs::-webkit-scrollbar { height: 0; }

.thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  background: #2a2622;
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.thumb[aria-current="true"],
.thumb.is-current {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-soft), 0 2px 8px rgba(0, 0, 0, 0.35);
}
.thumb:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.page-indicator {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.hotspot {
  pointer-events: auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 6px var(--gold-soft), 0 4px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transform: translate(-50%, -50%);
  padding: 0;
}
.hotspot::after {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: 10px auto;
  border-radius: 50%;
  background: #161412;
}
.hotspot:focus-visible { outline: 2px solid #fff; }

#card-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 30;
}
#card-backdrop[hidden] { display: none; }

.card {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 40px));
  max-height: min(70vh, 640px);
  overflow: auto;
  background: #f7f3ec;
  color: #1c1916;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
  z-index: 31;
  -webkit-user-select: text;
  user-select: text;
}
.card[hidden] { display: none; }
.card-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: #1c1916;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.card-image {
  display: none;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 14px;
}
.card-image.is-on { display: block; }
.card-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
  padding-right: 28px;
}
.card-text {
  font-size: 16px;
  line-height: 1.5;
  color: #3a342e;
}

body.is-busy .osd-pane { pointer-events: none; }

@media (max-width: 640px) {
  :root { --rail-h: 100px; --touch: 56px; }
  .thumb { width: 64px; height: 50px; }
  .nav-arrow { opacity: 0.92; }
}
