@import 'maplibre-gl/dist/maplibre-gl.css';

:root {
  font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* Sidebar theme variables */
  --sidebar-width: 460px;
  --sidebar-bg: rgba(36, 36, 36, 0.95);
  --sidebar-text: rgba(255, 255, 255, 0.87);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  --header-bg: rgba(30, 30, 30, 0.9);
}

@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
    
    /* Light theme sidebar variables */
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --sidebar-text: #213547;
    --sidebar-border: rgba(0, 0, 0, 0.1);
    --sidebar-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    --header-bg: rgba(245, 245, 245, 0.9);
  }
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}
a:hover {
  color: #535bf2;
}
a.word-link {
  color: var(--sidebar-text);
  display: inline-block;
  border-bottom: 1px solid var(--sidebar-border);
  margin-right: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

a.word-link:hover {
  color: #646cff;
  border-color: #646cff;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Sidebar styles */
.sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: calc(100% - 46px); /* Adjusted for header height */
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
  z-index: 1000;
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 46px;
}

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

.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--sidebar-bg);
  border: none;
  color: var(--sidebar-text);
  font-size: 1.5rem;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.close-btn:hover {
  opacity: 0.8;
}

.sidebar-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  position: relative;
}

/* Content container */
.content-container {
  min-height: 50px; /* Ensure we have at least some height even with empty content */
}

/* Markdown content styles */
.sidebar-content h1 {
  font-size: 1.5rem;
  margin-top: 0;
}

.sidebar-content h2 {
  font-size: 1.3rem;
}

.sidebar-content h3 {
  font-size: 1.2rem;
}

.sidebar-content img {
  max-width: 100%;
  height: auto;
}

.sidebar-content pre {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 8px;
  border-radius: 4px;
  overflow-x: auto;
}

.sidebar-content code {
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 2px;
}

.loading {
  padding: 16px;
  text-align: center;
  color: var(--sidebar-text);
  opacity: 0.7;
}

.simple-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  padding: 20px;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(128, 128, 128, 0.2);
  border-top-color: var(--sidebar-text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.load-error {
  padding: 16px;
  text-align: center;
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  border-radius: 4px;
  margin: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Font size control */
.font-size-control {
  border-top: 1px solid var(--sidebar-border);
  padding: 16px;
  background-color: var(--header-bg);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.font-size-label {
  font-weight: 500;
  opacity: 0.8;
  white-space: nowrap;
}

.font-size-slider {
  flex: 1;
  height: 2px;
  background: var(--sidebar-border);
  border-radius: 1px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.font-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sidebar-text);
  cursor: pointer;
  border: 2px solid var(--sidebar-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.font-size-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  background: var(--sidebar-text);
}

.font-size-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sidebar-text);
  cursor: pointer;
  border: 2px solid var(--sidebar-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.font-size-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
  background: var(--sidebar-text);
}

.font-size-reset {
  background: transparent;
  padding: 4px 8px;
  transition: all 0.2s ease;
  opacity: 0.8;
}

.font-size-reset:hover {
  opacity: 1;
  background: rgba(100, 108, 255, 0.1);
}

/* About modal styles */
.about-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

.about-modal.open {
  opacity: 1;
  visibility: visible;
}

.about-modal-content {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-radius: 8px;
  box-shadow: var(--sidebar-shadow);
  border: 1px solid var(--sidebar-border);
  width: calc(min(600px, 90%));
  max-height: calc(90vh);
  position: relative;
  overflow-y: auto;
  padding: 24px;
}

.about-content {
  padding-right: 20px;
}

.about-content h3 {
  margin-top: 20px;
  margin-bottom: 10px;
}

.about-content p {
  margin-bottom: 16px;
  line-height: 1.5;
}

.about-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-border);
  text-align: center;
}


/* Responsive adjustments */
@media (max-width: 600px) {
  :root {
    --sidebar-width: 100%;
  }
  
  /* Faster transitions on mobile */
  .sidebar, .stats-sidebar {
    transition: transform 0.2s ease-in-out;
  }

  .about-modal {
    display: block;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background-color: var(--sidebar-bg);
  }
  .about-modal .close-btn {
    top: 32px;
    right: 16px;
  }
}

/* Feedback link styles */
.feedback-separator {
  margin: 20px 0;
  border: none;
  border-top: 1px solid rgba(128, 128, 128, 0.2);
  opacity: 0.5;
}

.feedback-link {
  color: rgba(128, 128, 128, 0.9);
}

/* Welcome content styles */
.welcome-content {
  padding: 16px;
  text-align: center;
  line-height: 1.6;
}

.welcome-content h2 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-size: 1.5rem;
  color: var(--sidebar-text);
}

.welcome-content p {
  margin: 12px 0;
}

.welcome-content ul {
  text-align: left;
  margin: 16px auto;
  max-width: 80%;
  padding-left: 20px;
}

button {
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  font-size: 0.8rem;
  padding: 0.6em 1.2em;
  background-color: var(--sidebar-bg);
  cursor: pointer;
  transition: border-color 0.25s;
}
button:hover {
  border-color: #646cff;
}
button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

.control-buttons {
  position: absolute;
  right: 16px;
  bottom: 16px;
}