/* Naqsh — Animated Geographic Map & Transparent Specimen HUD */
:root {
  --paper: #eee9dd;
  --paper-warm: #f4efe5;
  --paper-land: #eee7d8;
  --sea-bg: #e7e8e4;
  --border-line: rgba(45, 39, 29, 0.48);
  --coast-line: rgba(36, 31, 23, 0.72);
  --graticule-line: rgba(66, 60, 45, 0.14);
  --ink: #181713;
  --ink-soft: #383730;
  --indigo: #101b36;
  --indigo-dark: #090e1d;
  --indigo-card: rgba(15, 24, 46, 0.95);
  --madder: #7c251f;
  --gold: #b99646;
  --gold-glow: #f2d17d;
  --line: rgba(24, 23, 19, 0.18);
  --line-gold: rgba(242, 209, 125, 0.25);
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-persian: "Gulzar", serif;
}

* {
  box-sizing: border-box;
}

body.map-body {
  margin: 0;
  padding: 0;
  background-color: var(--sea-bg);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow: hidden;
  height: 100svh;
}

/* Minimalist Home Link (Top Right, Identical to Landing Page Map Button) */
.home-link {
  position: fixed;
  z-index: 40;
  top: 28px;
  right: 4vw;
  color: var(--indigo);
  font-family: var(--font-sans);
  font-size: clamp(0.78rem, 1.15vw, 0.92rem);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.72rem 1rem 0.68rem;
  transition: color 0.2s;
}

.home-link:hover {
  color: var(--madder);
}

/* Map Stage Container (Edge-to-Edge Fullscreen) */
main.map-stage-container {
  height: 100svh;
  width: 100vw;
  position: relative;
  overflow: hidden;
  padding: 0;
  margin: 0;
  background: var(--sea-bg);
}

#world-map {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#world-map:active {
  cursor: grabbing;
}

.static-mosaic-image {
  pointer-events: none;
}

.mosaic-render .home-link,
.mosaic-render .map-controls,
.mosaic-render .map-source-count,
.mosaic-render .map-tooltip,
.mosaic-render .map-borders,
.mosaic-render .map-labels,
.mosaic-render .mosaic-country-outlines,
.mosaic-render .motif-cursor {
  display: none !important;
}

.static-map .map-controls {
  display: flex;
}

/* Geographic Shading & Boundaries (Antique Ink & Parchment, NO GRID) */
.map-land {
  fill: var(--paper-land);
  stroke: var(--coast-line);
  stroke-width: 1.05;
  vector-effect: non-scaling-stroke;
}

.map-borders {
  fill: none;
  stroke: #181510;
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.92;
}

.map-labels {
  pointer-events: none;
}

.map-label-group {
  pointer-events: none;
}

.map-label-bg {
  fill: rgba(254, 251, 244, 0.95);
  stroke: rgba(42, 36, 27, 0.28);
  stroke-width: 1px;
  filter: drop-shadow(0 2px 5px rgba(20, 17, 12, 0.25));
}

.map-label-text {
  fill: #16140f;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.map-label-featured .map-label-bg {
  fill: rgba(254, 251, 244, 0.97);
  stroke: #c89b3c;
  stroke-width: 1.5px;
  filter: drop-shadow(0 3px 8px rgba(20, 17, 12, 0.32));
}

.map-label-featured .map-label-text {
  fill: #7c251f;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.26em;
}

.country-mosaic {
  opacity: 0.85;
}

.mosaic-country-outlines path {
  fill: none;
  stroke: #c89b3c;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(20, 17, 12, 0.7));
}

.specimen-cell {
  stroke: rgba(20, 17, 12, 0.42);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  outline: none;
  transition: opacity 0.16s ease, filter 0.16s ease;
}

.specimen-cell:hover,
.specimen-cell:focus {
  opacity: 0.88;
  filter: saturate(1.08) brightness(1.08);
}

.specimen-cell.active {
  opacity: 1;
  stroke: #f0c76e;
  stroke-width: 1.25;
  filter: saturate(1.16) brightness(1.12) drop-shadow(0 0 3px rgba(240, 199, 110, 0.72));
}

/* Specimen Image Preview Markers on Map (30% smaller, crisp, high performance) */
.specimen-marker {
  cursor: pointer;
  outline: none;
}

.specimen-card {
  opacity: 0;
  animation: specimenFadeIn 0.25s ease-out forwards;
}

@keyframes specimenFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.specimen-marker image {
  transition: opacity 0.15s ease;
  opacity: 0.95;
}

.specimen-marker:hover image,
.specimen-marker:focus image,
.specimen-marker.active image {
  opacity: 1;
}

.specimen-marker.active .specimen-circle-base {
  fill: #d1ab58;
  stroke: #f4ddb0;
  stroke-width: 0.65;
}

.specimen-marker.active .specimen-card {
  filter: drop-shadow(0 0 3px rgba(232, 190, 99, 0.9));
}

/* Map Controls (+ / - / Reset) */
.map-controls {
  position: absolute;
  left: 2.5vw;
  bottom: 4vh;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(246, 241, 231, 0.86);
  backdrop-filter: blur(10px);
  padding: 6px;
  border: 1px solid rgba(42, 36, 27, 0.22);
  border-radius: 6px;
}

.map-control-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(42, 36, 27, 0.22);
  background: transparent;
  color: rgba(42, 36, 27, 0.78);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.map-control-btn:hover,
.map-control-btn:focus {
  background: rgba(42, 36, 27, 0.9);
  color: var(--paper);
  border-color: rgba(42, 36, 27, 0.9);
}

/* Bottom Right Source Verification Counter & Curation Status */
.map-source-count {
  position: fixed;
  z-index: 30;
  bottom: 28px;
  right: 4vw;
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(42, 36, 27, 0.58);
  pointer-events: none;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.map-source-count #source-number {
  font-weight: 500;
  color: rgba(24, 23, 19, 0.88);
}

.map-source-count .source-review-note {
  color: rgba(42, 36, 27, 0.52);
  letter-spacing: 0.12em;
}

/* Fixed editorial specimen inspector — Light Parchment Theme */
.map-tooltip {
  position: fixed;
  z-index: 30;
  left: clamp(18px, 3vw, 44px);
  top: clamp(18px, 4vh, 44px);
  width: min(280px, calc(100vw - 36px));
  padding: 14px 14px 14px;
  background: rgba(253, 250, 243, 0.96);
  border: 1px solid rgba(42, 36, 27, 0.16);
  border-radius: 6px;
  box-shadow: 0 16px 45px rgba(35, 28, 16, 0.16), 0 2px 8px rgba(35, 28, 16, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tooltip-close {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(42, 36, 27, 0.08);
  color: rgba(42, 36, 27, 0.72);
  font: 300 18px/1 var(--font-sans);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.tooltip-close:hover {
  background: rgba(42, 36, 27, 0.16);
  color: var(--ink);
}

.map-tooltip.is-pinned .tooltip-close {
  opacity: 1;
  pointer-events: auto;
}

.tooltip-header {
  width: 100%;
  padding-right: 28px;
  margin-bottom: 10px;
}

.tooltip-place {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
  text-shadow: none;
}

.tooltip-image-frame {
  width: 100%;
  height: 175px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
  background: rgba(42, 36, 27, 0.05);
  border-radius: 4px;
  border: 1px solid rgba(42, 36, 27, 0.08);
}

.tooltip-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  filter: saturate(1.05) contrast(1.02);
  opacity: 0;
  transform: scale(1.1);
  transition: opacity 0.3s ease, transform 0.4s ease;
}

.tooltip-image.loaded {
  opacity: 1;
  transform: scale(1.15);
}

.tooltip-image-loader {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(56, 55, 48, 0.48);
  background: transparent !important;
  padding: 4px 0;
}

.tooltip-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.tooltip-title {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink-soft);
  margin: 0;
  letter-spacing: 0.02em;
  text-shadow: none;
}

/* Full-bleed Transparent/Frosted Museum Object Dialog Viewer */
.object-view {
  width: 100vw;
  max-width: none;
  height: 100svh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  background: rgba(236, 229, 214, 0.4);
  color: var(--ink);
  overflow: hidden;
}

.object-view::backdrop {
  background: rgba(22, 19, 14, 0.32);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.object-view[open] {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
}

/* Minimalist Elegant Close Button */
.object-close {
  position: fixed;
  z-index: 60;
  right: 4vw;
  top: 28px;
  min-height: 40px;
  background: rgba(251, 247, 239, 0.92);
  border: 1px solid rgba(24, 23, 19, 0.28);
  color: var(--ink);
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.object-close .close-label {
  font-family: var(--font-sans);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.object-close .close-symbol {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1;
  color: var(--ink);
}

.object-close:hover,
.object-close:focus {
  opacity: 0.6;
}

.object-image-stage {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 4vw;
  background: transparent;
  position: relative;
  overflow: hidden;
}

.object-image-stage img {
  max-width: 90%;
  max-height: 84vh;
  object-fit: contain;
  filter: drop-shadow(0 20px 45px rgba(24, 20, 14, 0.35));
  transition: transform 0.3s ease;
}

.object-image-stage span {
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.object-meta {
  padding: 6vw 4vw 4vw;
  align-self: center;
  overflow-y: auto;
  max-height: 100svh;
  background: rgba(251, 247, 239, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(24, 23, 19, 0.12);
  box-shadow: -10px 0 35px rgba(24, 20, 14, 0.08);
}

.object-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--madder);
  margin-bottom: 0.75rem;
}

.object-meta h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 3.5vw, 4rem);
  line-height: 0.95;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 2.2rem;
  color: var(--ink);
}

.object-meta dl {
  margin: 0;
  border-top: 1px solid var(--line);
}

.object-meta dl div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.object-meta dt {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.object-meta dd {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink);
}

.object-actions {
  margin-top: 2.5rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.object-source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--madder);
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 500;
}

/* Persian Motif Cursor - High z-index to stay visible over dialog */
.motif-cursor {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 42px;
  height: 42px;
  pointer-events: none;
  background: url("assets/persian-motif-cursor.svg") center/contain no-repeat;
  filter: drop-shadow(0 0 5px var(--gold)) drop-shadow(0 0 14px rgba(242, 209, 125, 0.8));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.motif-cursor.visible {
  opacity: 1;
}

@media (pointer: fine) {
  .motif-cursor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .specimen-card { animation: none; opacity: 1; }
  .map-tooltip, .tooltip-image, .object-image-stage img { transition: none; }
}

@media (max-width: 900px) {
  .map-legend {
    display: none;
  }
}

@media (max-width: 768px) {
  .map-tooltip {
    top: auto;
    bottom: 18px;
    width: min(300px, calc(100vw - 36px));
  }

  .tooltip-image-frame { height: 112px; }
  .tooltip-image { max-height: 112px; }

  .map-tools {
    gap: 0.75rem;
  }

  .object-view[open] {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .object-image-stage {
    min-height: 55svh;
  }

  .object-meta {
    padding: 2rem 5vw 4rem;
  }
}
