/* Legend / User Guide modal - styled to match the app's own dark,
   glassy UI (icon buttons, Imperial-blue accents) instead of a plain
   default light card. */

.legend-modal {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2200;
  align-items: center;
  justify-content: center;
  padding: 18px;
  box-sizing: border-box;
}
.legend-modal[aria-hidden="true"] { display: none; }

.legend-modal-content {
  background: linear-gradient(180deg, #202124 0%, #17181a 100%);
  color: #eef0f2;
  border-radius: 16px;
  max-width: 720px;
  width: 92%;
  max-height: 82vh;
  max-height: calc(var(--vh, 1vh) * 82);
  overflow-y: auto;
  padding: 0;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  font-family: inherit;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-modal-content::-webkit-scrollbar { width: 10px; }
.legend-modal-content::-webkit-scrollbar-track { background: transparent; }
.legend-modal-content::-webkit-scrollbar-thumb { background: #46474a; border-radius: 10px; }
.legend-modal-content::-webkit-scrollbar-thumb:hover { background: #5a5b5f; }

.legend-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(135deg, #003e74 0%, #002147 100%);
  padding: 22px 56px 18px 24px;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.legend-header-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.legend-header-title i { font-size: 20px; opacity: 0.95; }
.legend-subtitle {
  margin: 5px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.legend-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  transition: background 0.15s, transform 0.15s;
}
.legend-close:hover { background: rgba(0, 0, 0, 0.4); transform: scale(1.05); }

.legend-body { padding: 6px 24px 26px; }

.legend-section { margin-top: 22px; }
.legend-section:first-child { margin-top: 20px; }

.legend-section h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #4fc3f7;
  margin: 0 0 10px;
  font-weight: 700;
}
.legend-section h4 i { font-size: 14px; }

.legend-section p {
  margin: 0 0 10px;
  font-size: 14.5px;
  line-height: 1.55;
  color: #d6d8db;
}

/* Controls list - each item is its own small card with an icon bubble,
   mirroring the app's circular .icon-btn treatment. */
.legend-controls {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-controls li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 10px 12px;
  transition: background 0.15s, border-color 0.15s;
}
.legend-controls li:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}
.legend-controls .legend-icon {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 152, 218, 0.18);
  color: #4fc3f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.legend-controls .legend-control-text { font-size: 13.5px; line-height: 1.5; color: #d6d8db; }
.legend-controls .legend-control-text strong { color: #fff; }

.legend-list { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-direction: column; gap: 8px; }
.legend-list li {
  font-size: 14px;
  line-height: 1.5;
  color: #d6d8db;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 9px 12px;
}
.legend-list li strong { color: #fff; }

.legend-color { display: inline-block; width: 16px; height: 16px; border-radius: 5px; flex: 0 0 16px; margin-top: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15); }

/* Small color-swatch strip illustrating the per-class box colors used in
   the photo gallery - purely decorative/informational, not a status key. */
.legend-swatches {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
}
.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--sw-color);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  flex: 0 0 auto;
}
.legend-swatch-label { font-size: 12px; color: #9ea1a6; line-height: 1.4; margin-left: 4px; }

.legend-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: #b7bac0;
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  background: rgba(0, 152, 218, 0.08);
  border-left: 3px solid #0098da;
  padding: 10px 12px;
  border-radius: 6px;
}
.legend-note i { flex: 0 0 auto; margin-top: 2px; color: #4fc3f7; }

.no-scroll { overflow: hidden; height: 100%; }

@media (max-width: 600px) {
  .legend-modal-content { width: 96%; max-height: 88vh; max-height: calc(var(--vh, 1vh) * 88); }
  .legend-header { padding: 18px 50px 16px 18px; }
  .legend-header-title { font-size: 18px; }
  .legend-body { padding: 4px 16px 20px; }
  .legend-color { width: 14px; height: 14px; }
  .legend-close { font-size: 18px; width: 30px; height: 30px; top: 12px; right: 12px; }
}
