/* =========================
   Custom Scrollbar Styles
   ========================= */
/* For Webkit browsers */
::-webkit-scrollbar {
    width: 12px;
    background: #e5d6b3;
}
::-webkit-scrollbar-thumb {
    background: #bfa14a;
    border-radius: 6px;
    border: 2px solid #f6ecd6;
}
::-webkit-scrollbar-thumb:hover {
    background: #a13a2f;
}
::-webkit-scrollbar-corner {
    background: #f6ecd6;
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #bfa14a #e5d6b3;
}

/* =========================
   Link Colors (Fantasy Theme)
   ========================= */
a, a:visited {
    color: #bfa14a;
    text-decoration: underline;
    transition: color 0.2s;
}
a:hover, a:focus {
    color: #a13a2f;
    text-decoration: underline;
}
a:active {
    color: #7c4a1e;
}

a[target="_blank"]::after {
    content: " \2197"; /* Unicode "↗" */
    display: inline-block;
    margin-left: 0.3em;
    font-size: 0.95em;
    color: #888;
}

/* =========================
   General Layout
   ========================= */
html {
    height: 100%;
}

body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
    background-color: #222;
    color: #3a2c13;
}

/* =========================
   Sidebar
   ========================= */
.map-sidebar {
    width: 270px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #f6ecd6;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(-220px);
    transition: transform 0.3s ease;
}

.map-sidebar--open {
    transform: translateX(0);
}

/* Sidebar Header */
.map-sidebar__header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    padding: 0 10px;
    box-sizing: border-box;
    background: #f6ecd6;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 2;
    flex-shrink: 0;
}

/* Sidebar Content */
.map-sidebar__content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    padding: 0;
    box-sizing: border-box;
    transition: opacity 0.2s;
}

.map-sidebar:not(.map-sidebar--open) .map-sidebar__content,
.map-sidebar__content:not(.map-sidebar__content--visible) {
    display: none;
}

/* Sidebar Details Section */
.map-sidebar__section-details {
    flex-shrink: 0;
    padding: 10px;
    margin-bottom: 0;
    border-bottom: 1px solid #eee;
}

.map-sidebar__section-details h2 {
    margin-top: 0;
}

/* Related Maps Section */
.map-sidebar__related-maps-container {
    flex: 1 1 0%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-sidebar__related-maps-title {
    padding: 10px;
    font-size: 1.1em;
    font-weight: bold;
    flex-shrink: 0;
}

.map-sidebar__related-maps {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    margin: 0 0 10px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 10px 10px 10px;
}

.map-sidebar__related-maps-thumb-wrapper {
  position: relative;
  display: inline-block;
  margin: 0 8px 8px 0;
  vertical-align: top;
}

.map-sidebar__related-maps-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #f6ecd6;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: relative;
  z-index: 1;
  cursor: pointer;
}

.map-sidebar__related-maps-encounter-flag {
    position: absolute;
    top: 0px;
    right: 6px;
    z-index: 2;
    pointer-events: none;
    background: #ffe066;
    clip-path: polygon(0 0, 100% 0, 100% 80%, 50% 100%, 0 80%);
    padding: 2px 4px 6px 4px;
}

/* Sidebar Buttons */
.map-sidebar__toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    position: relative;
    right: 0;
    top: 0;
    padding: 0;
    margin: 0;
}

.map-sidebar__back {
    width: 32px;
    height: 32px;
    visibility: hidden;
    display: flex;
    justify-content: center;
    cursor: pointer;
}

.map-sidebar__back--visible {
    visibility: visible;
}

.map-sidebar__back-arrow {
    font-size: 24px;
    line-height: 1;
    color: #3a2c13; /* Match body font color */
}

.map-sidebar__burger {
    display: inline-block;
    width: 24px;
    height: 18px;
    position: relative;
}

.map-sidebar__burger span {
    display: block;
    height: 3px;
    width: 100%;
    background: #3a2c13;
    border-radius: 2px;
    margin: 3px 0;
    transition: 0.3s;
}

.map-sidebar__buttons-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
}

/* Sidebar Footer */
.map-sidebar__footer {
    width: 100%;
    background: #f6ecd6;
    border-top: 1px solid #ddd;
    padding: 12px 16px;
    box-sizing: border-box;
    position: absolute;
    left: 0;
    bottom: 0;
    text-align: center;
    z-index: 2;
    font-size: 0.95em;
    flex-shrink: 0;
}

/* =========================
   Map Wrapper
   ========================= */
.map-canvas-wrapper {
    height: 100%;
}

.map-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
}

/* =========================
   Sidebar Section Separator & Description
   ========================= */
.map-sidebar__section-separator {
    border: none;
    border-top: 1px solid #bbb;
    margin: 18px auto;
    width: 30%;
    align-self: center;
    opacity: 0.7;
}

.map-sidebar__section-description {
    line-height: 1.4;
}

/* =========================
   Modal
   ========================= */
.map-modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    display: none;
}

.map-modal__overlay.modal--open {
    display: flex;
}

.map-modal__content {
    background: #f6ecd6;
    padding: 24px 32px;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    width: 90vw;
    height: auto;
    box-shadow: 0 2px 16px rgba(0,0,0,0.2);
    position: relative;
    overflow-y: auto;
}

.map-modal__close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
}

.map-modal__header {
    margin-bottom: 4px;
}

.map-modal__title {
  display: inline;
}

/* =========================
   Map Modal Image Wrapper Height
   ========================= */
.map-modal__image-wrapper {
  max-height: 80vh;
  margin-bottom: 16px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  padding-bottom: 4px;
  cursor: zoom-in;
}

.map-modal__image-wrapper.full-width {
    overflow: auto;
    display: block;
    padding-bottom: 0;
    cursor: zoom-out;
}

.map-modal--gallery-visible .map-modal__image-wrapper {
    max-height: 60vh;
}

.map-modal__image-wrapper img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: scale-down;
}
.map-modal--gallery-visible .map-modal__image-wrapper img {
    max-height: 60vh;
  }

.map-modal__image-wrapper.full-width img {
    width: 100%;
    max-height: none;
}

/* =========================
   Gallery and Loading Placeholder
   ========================= */
.map-modal__gallery {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 10px;
  margin-top: 16px;
  max-height: 170px;
}

.map-modal__gallery-thumb {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border: 1px solid #ccc;
  background: #f6ecd6;
  cursor: pointer;
}

.map-modal__gallery-thumb:hover {
  border-color: #bfa14a;
}

.map-modal__gallery-thumb-wrapper {
  position: relative;
  display: inline-block;
}

.map-modal__gallery-thumb-icon {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 2px;
  font-size: 14px;
  pointer-events: none;
  z-index: 2;
}

.loading-placeholder {
    width: 100%;
    min-height: 200px;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    display: block;
    background: #f6ecd6;
}

.loading-placeholder::before {
    content: '';
    display: block;
    position: absolute;
    left: -40%;
    top: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, transparent, #f3e6c1 60%, transparent);
    animation: loading-placeholder-shimmer 1.2s infinite ease-out;
}

@keyframes loading-placeholder-shimmer {
    0% { left: 100%; }
    100% { left: -40%; }
}

/* =========================
   Map Preview
   ========================= */
.map-sidebar__related-maps-preview {
    cursor: pointer;
}

/* =========================
   Map Legend
   ========================= */
.map-sidebar__legend h3 {
  margin: 16px 0 8px 0;
}

.map-sidebar__legend-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.map-sidebar__legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.map-sidebar__legend-shape {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid;
}

.map-sidebar__legend-square {
  border-radius: 2px;
}

.map-sidebar__legend-circle {
  border-radius: 50%;
}

.map-sidebar__legend-yellow {
  background: #ffe066;
  border-color: #bfa600;
}

.map-sidebar__legend-blue {
  background: #4dabf7;
  border-color: #1864ab;
}

.map-sidebar__legend-white {
  background: #fff;
  border-color: #bbb;
}

.map-sidebar__legend-section {
  margin-bottom: 10px;
}

.map-sidebar__legend-section-title {
  font-size: 0.98em;
  font-weight: bold;
  margin-bottom: 6px;
}

.map-sidebar__legend-shape.collection {
  border-style: dashed;
}

.map-sidebar__legend-shape--sword {
  background: none;
  border: none;
  font-size: 1em;
  display: inline-flex;
  align-items: center;
  height: 1em;
}