/* ===== CSS VARIABLES ===== */
:root {
  --bar-h: 60px;        /* filter bar height */
  --yearbar-h: 100px;   /* colonizer + year controls (now two rows) */
}

/* ===== GLOBAL STYLES ===== */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, sans-serif;
  background: #1e1e1e;
}

#wrapper {
  height: calc(100dvh * 2);
  transition: transform 0.6s ease;
}

.slice {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== SHARED CONTROLS ===== */
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.controls select,
.controls input[type="text"] {
  background: #2c2c2c;
  color: #f0f0f0;
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 16px;
  width: 140px;
  min-height: 40px;
  box-sizing: border-box;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #444;
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
}

.btn.inactive {
  background: #444;
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

#year-toggle:not(.inactive) {
  background: #1a73e8;
  color: #fff;
}

#year-toggle {
  width: 60px;
  white-space: normal;
  text-align: center;
  line-height: 0.9;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  min-height: 40px;
  transition: all 0.2s ease;
}

/* ===== SHARED FILTER BAR ===== */
#filterbar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 1300;
  height: var(--bar-h);
  background: #1e1e1e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  justify-content: center;
  transition: all 0.6s ease;
}

#filterbar input {
  background: #2c2c2c;
  color: #f0f0f0;
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 16px;
  width: 220px;
  flex: 1;
  min-height: 40px;
  box-sizing: border-box;
}

#filterbar.in-posts {
  top: 10px;
}

#filterbar.in-map {
  bottom: 0;
}

/* ===== YEAR & COLONIZER BAR ===== */
#yearbar {
  height: var(--yearbar-h);
  flex-direction: column;
  gap: 6px;
  background: #181818;
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  padding: 8px 12px;
}

.bar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 10px;
}

#year-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

#year-slider {
  flex: 1;
  height: 8px;
  background: #555;
  border-radius: 4px;
  min-height: 44px;
}

#year-slider::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f0f0f0;
  border: 2px solid #333;
  cursor: pointer;
  -webkit-appearance: none;
}

#year-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f0f0f0;
  border: 2px solid #333;
  cursor: pointer;
}

#year-label {
  cursor: default;
  background: #222;
}

/* ===== MAP SECTION ===== */
#map {
  flex: 1 1 auto;
  height: calc(100dvh - var(--yearbar-h) - var(--bar-h));
}

/* ===== POSTS SECTION ===== */
#posts-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 18px;
  padding-top: calc(var(--bar-h) - 20px);
  margin-top: var(--bar-h);
}

details.entry {
  border-radius: 8px;
  background: #2a2a2a;
  margin: 16px 0;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}

details.entry summary {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 16px 20px 16px 28px;
  cursor: pointer;
  position: relative;
}

details.entry summary::-webkit-details-marker,
details.entry summary::marker {
  display: none;
}

.color-indicator {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
}

.entry-start {
  font-weight: 700;
  color: #aaa;
  margin-right: 10px;
  white-space: nowrap;
  font-size: 15px;
}

.entry-title {
  flex: 1;
  color: #eee;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-body {
  padding: 14px 22px 18px 28px;
  color: #ddd;
  background: #2d2d2d;
  border-top: 1px solid #444;
  max-height: 50vh;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.5;
}

/* ===== MODALS ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal.hidden {
  display: none;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.modal-content {
  background: #1e1e1e;
  padding: 24px 28px;
  border-radius: 12px;
  max-width: 600px;
  width: 85%;
  color: #eee;
  position: relative;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ===== LEAFLET COMPONENTS ===== */
.country-tip {
  background: rgba(42, 42, 42, 0.9);
  border: none;
  color: #fff;
  font-size: 14px;
  padding: 6px 10px;
}

.leaflet-bottom.leaflet-left .legend {
  margin-bottom: 100px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .modal-content {
    width: 85%;
    max-width: none;
    padding: 16px 12px;
    margin: 20px auto;
    max-height: 70vh;
    border-radius: 8px;
  }
  
  .modal-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 6px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 88%;
    margin: 16px auto;
    max-height: 65vh;
    padding: 12px 10px;
  }
}

/* ===== LINK STYLES ===== */
a {
  color: #64b5f6;  /* Light blue for better contrast */
  text-decoration: none;
}

a:hover {
  color: #90caf9;  /* Lighter blue on hover */
  text-decoration: underline;
}

a:focus {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}