/* Sources side panel: the "Sources" tab and the slide-out list of citations.
   Used by pages with a <div id="sources-container"> (rtic, udo and their research pages).
   Markup stays on each page (its own source list); behavior is in assets/js/sources-panel.js.
   Desktop: a tab on the right edge opens a side panel. Phones: a bottom bar opens a sheet. */

#sources-tab {
  position: fixed;
  right: 16px;
  /* Corrected positioning */
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: right center;
  background: #3E624B;
  color: white;
  padding: 15px 40px;
  /* Wider and taller */
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  /* Larger text */
  letter-spacing: 2px;
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  border: 0;
  font-family: inherit;
}

#sources-tab:hover {
  background: #4B7358;
}

#sources-container.open #sources-tab {
  opacity: 0;
  pointer-events: none;
}

#sources-panel {
  position: fixed;
  right: -350px;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  width: 350px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
  padding: 24px;
  z-index: 1000;
  /* Closed: off screen and out of the tab order. */
  visibility: hidden;
  transition: right 0.3s ease, visibility 0.3s;
}

#sources-container.open #sources-panel {
  right: 0;
  /* Visible at once on open, so focus can move into the panel. */
  visibility: visible;
  transition: right 0.3s ease, visibility 0s;
}

.sources-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #3E624B;
}

.sources-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #374151;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.sources-close:hover {
  background: #F5F5F5;
}

.source-category {
  margin-bottom: 24px;
}

.source-category-title {
  font-weight: 700;
  color: #2E5339;
  font-size: 13px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 6px;
  border-bottom: 1px solid #E5E7EB;
}

.source-item {
  margin-bottom: 14px;
}

.source-item-title a {
  font-weight: 600;
  color: #3E624B;
  font-size: 14px;
  text-decoration: none;
  line-height: 1.4;
  transition: color 0.2s;
}

.source-item-title a:hover {
  color: #476D38;
  text-decoration: underline;
}

.source-item-meta {
  font-size: 12px;
  color: #6B7280;
  margin-top: 2px;
}

.source-item-desc {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  margin-top: 3px;
}

@media (max-width: 768px) {
  #sources-tab {
    position: fixed;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    transform-origin: center center;
    border-radius: 12px 12px 0 0;
    width: 100%;
    text-align: center;
    padding: 12px 20px;
    font-size: 14px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
  }

  #sources-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    top: auto;
    left: 0;
    transform: translateY(100%);
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, visibility 0.3s;
  }

  #sources-container.open #sources-panel {
    right: 0;
    transform: translateY(0);
    transition: transform 0.3s ease, visibility 0s;
  }
}
