/* === Mapa Henio — style === */
/* Mobile-first. Pergamin + atrament + złoto. Cormorant + EB Garamond. */

:root {
  /* Pergamin */
  --parchment-light: #f5e9d3;
  --parchment: #ede0c4;
  --parchment-dark: #d8c8a3;

  /* Atrament */
  --ink: #2a1a08;
  --ink-soft: #3a2d1d;
  --ink-faint: #6b5638;

  /* Złoto */
  --gold: #c9a961;
  --gold-deep: #b8924a;
  --gold-dim: #8b6f47;

  /* Akcenty */
  --bronze: #4a2d12;
  --shadow: rgba(26, 14, 4, 0.35);
  --shadow-deep: rgba(26, 14, 4, 0.55);

  /* Type */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;

  /* Layout */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Map container === */
#map {
  position: fixed;
  inset: 0;
  background: #1a0f06;
  cursor: grab;
}

#map:active {
  cursor: grabbing;
}

/* Leaflet image overlay: subtle warm cast */
.leaflet-container {
  background: #1a0f06;
  font-family: var(--font-body);
}

/* Zoom control — only desktop */
.leaflet-control-zoom {
  display: none;
  border: none !important;
  box-shadow: 0 4px 12px var(--shadow-deep) !important;
}

.leaflet-control-zoom a {
  background: var(--parchment-light) !important;
  color: var(--ink) !important;
  border: 1px solid var(--gold-dim) !important;
  font-family: var(--font-display) !important;
  font-weight: 600 !important;
}

.leaflet-control-zoom a:hover {
  background: var(--gold) !important;
}

.leaflet-control-attribution {
  background: rgba(245, 233, 211, 0.85) !important;
  font-family: var(--font-body) !important;
  font-size: 10px !important;
  font-style: italic;
  color: var(--ink-faint) !important;
  padding: 2px 8px !important;
  border-top-left-radius: 4px;
}

.leaflet-control-attribution a {
  color: var(--gold-deep) !important;
}

/* === Header (decorative, non-interactive) === */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  padding: calc(12px + var(--safe-top)) 16px 24px;
  background: linear-gradient(
    180deg,
    rgba(26, 14, 4, 0.6) 0%,
    rgba(26, 14, 4, 0) 100%
  );
  pointer-events: none;
  text-align: center;
}

.app-header h1 {
  display: inline-block;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--parchment-light);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

.header-flourish {
  display: block;
  color: var(--gold);
  font-size: 16px;
  margin-top: -4px;
  opacity: 0.8;
}

@media (min-width: 768px) {
  .app-header h1 {
    font-size: 28px;
  }
  .leaflet-control-zoom {
    display: block;
  }
}

/* === Custom markers === */
.map-marker-wrapper {
  /* Leaflet sets position; we control appearance only */
  cursor: pointer;
  user-select: none;
}

.map-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Anchor at bottom-center of pin */
  transform: translate(-50%, -100%);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.map-marker:hover,
.map-marker.is-active {
  transform: translate(-50%, -105%) scale(1.08);
}

.marker-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold) 0%, var(--gold-deep) 70%);
  border: 2px solid var(--bronze);
  box-shadow:
    0 2px 6px var(--shadow-deep),
    inset 0 1px 2px rgba(255, 240, 200, 0.4);
  position: relative;
}

.marker-pin::after {
  /* Ink dot in center */
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: var(--ink);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Marker types — different sizes */
.marker-pin--city {
  width: 30px;
  height: 30px;
}
.marker-pin--city::after {
  width: 8px;
  height: 8px;
}

.marker-pin--town {
  width: 22px;
  height: 22px;
}
.marker-pin--town::after {
  width: 5px;
  height: 5px;
}

.marker-pin--ruins {
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 30% 30%, var(--parchment-dark) 0%, var(--gold-dim) 70%);
  opacity: 0.85;
}

.marker-pin--secret {
  background: radial-gradient(circle at 30% 30%, #d9534f 0%, #8b2f2a 70%);
}

.marker-label {
  margin-top: 6px;
  padding: 2px 8px;
  background: rgba(245, 233, 211, 0.92);
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 1px 3px var(--shadow);
  letter-spacing: 0.02em;
}

@media (min-width: 768px) {
  .marker-label {
    font-size: 15px;
  }
}

/* === Bottom sheet (mobile) / Sidebar (desktop) === */
.location-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 75vh;
  background: var(--parchment-light);
  background-image:
    radial-gradient(circle at 20% 0%, rgba(184, 146, 74, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(74, 45, 18, 0.05) 0%, transparent 50%);
  border-top: 2px solid var(--gold-deep);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px var(--shadow-deep);
  z-index: 1001;
  transform: translateY(0);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(24px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.location-sheet.hidden {
  transform: translateY(100%);
}

.sheet-handle {
  width: 44px;
  height: 4px;
  background: var(--gold-dim);
  border-radius: 2px;
  margin: 10px auto 6px;
  opacity: 0.6;
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--gold-dim);
  background: var(--parchment);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}

.sheet-close:hover,
.sheet-close:focus-visible {
  background: var(--gold);
  outline: none;
}

.sheet-content {
  padding: 16px 24px 8px;
}

.location-type {
  display: inline-block;
  padding: 3px 12px;
  background: var(--gold);
  color: var(--ink);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

#sheet-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 32px;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}

@media (min-width: 768px) {
  #sheet-title {
    font-size: 38px;
  }
}

.hairline {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--gold-dim) 20%,
    var(--gold-deep) 50%,
    var(--gold-dim) 80%,
    transparent 100%
  );
  margin: 14px 0 18px;
  opacity: 0.6;
}

.location-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: rgba(74, 45, 18, 0.05);
  border: 1px dashed var(--gold-dim);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  margin-bottom: 18px;
  overflow: hidden;
  text-align: center;
  padding: 16px;
}

.location-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.placeholder-message {
  opacity: 0.7;
  max-width: 240px;
  line-height: 1.4;
}

.location-desc {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.location-desc:empty::before {
  content: 'Brak opisu.';
  font-style: italic;
  opacity: 0.5;
}

/* Sheet backdrop (mobile only) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 14, 4, 0.3);
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s;
}

.sheet-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* === Desktop: sheet → sidebar === */
@media (min-width: 768px) {
  .location-sheet {
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 420px;
    max-height: 100vh;
    border-radius: 0;
    border-top: none;
    border-left: 2px solid var(--gold-deep);
    box-shadow: -8px 0 32px var(--shadow-deep);
    padding-bottom: 24px;
  }

  .location-sheet.hidden {
    transform: translateX(100%);
  }

  .sheet-handle {
    display: none;
  }

  .sheet-content {
    padding-top: 56px;
  }

  .sheet-backdrop {
    display: none;
  }
}

/* === Debug coordinate overlay === */
.coord-debug {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  z-index: 999;
  padding: 6px 12px;
  background: rgba(26, 14, 4, 0.85);
  color: var(--parchment-light);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  border-radius: 3px;
  pointer-events: none;
  border: 1px solid var(--gold-dim);
}

.hidden {
  /* Visibility hidden via class for sheet (transform-based) and debug (display) */
}

.coord-debug.hidden {
  display: none;
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
