/* ====== Base Layout ====== */
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Inter;
  padding: 0;
}

#map-container {
  height: 100%;
  width: 100%;
  min-width: 320px;
  margin: 0 auto;
  overflow: hidden;
}

#map-container:focus {
  outline: 2px solid #cc4400; 
}

#map-wrapper {
  position: relative;
  width: 100%;
  height: 100vh;
}

/* ====== Unified Header ====== */
#unified-header {
  position: absolute;
  top: 20px;
  left: 20px;
  background-color: rgba(0, 0, 0, 0.85);
  color: white;
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#unified-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

#button-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.header-button {
  background: none;
  border: none;
  padding: 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 40px;
  height: 40px;
}

.header-button:hover,
.header-button:focus {
  background-color: #993300;
  outline: none;
}

.header-button.active {
  background-color: #cc4400;
}

/* Standardize ALL icon sizes */
.header-button img {
  display: block;
  width: 20px !important;
  height: 20px !important;
  object-fit: contain;
}

#time-toggle img,
#about-button img {
  filter: invert(1);
}

.zoom-button {
  width: 40px;
  height: 40px;
  color: white;
  font-size: 20px;
  font-weight: bold;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-button::after {
  font-size: 12px !important;
  font-weight: normal !important;
}

/* Tooltip for header buttons */
.header-button::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10000;
}

.header-button:hover::after,
.header-button:focus::after {
  opacity: 1;
}

/* Hide tooltip when button is active (popup is open) */
.header-button.active::after {
  display: none !important;
}

#time-dropdown {
  width: 280px !important;
  padding: 1em !important;
  background: rgba(0, 0, 0, 0.85) !important;
  border: none;
  border-radius: 20px !important;
}

/* Time dropdown header - match .popup-header */
.time-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5em;
}

/* Time dropdown heading - match .popup-heading */
.time-dropdown-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-dropdown-heading img {
  width: 16px;
  height: 16px;
  filter: invert(1);
  flex-shrink: 0;
}

.time-dropdown-heading h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
}

/* Info and close button container */
.time-dropdown-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Time info button - match .info-button */
.time-info-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
}

.time-info-button:hover {
  opacity: 1;
}

.time-info-button img {
  filter: invert(1);
  width: 14px;
  height: 14px;
}

/* Close button - match .popup-header .close-popup */
.time-dropdown-header .close-popup {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.time-dropdown-header .close-popup img {
  display: block;
  width: 16px;
  height: 16px;
}

/* Time dropdown items container */
.time-dropdown-items {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.75em;
}

/* Adjust dropdown items */
#time-dropdown .dropdown-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid #333;
  font-family: 'Inter', sans-serif;
}

#time-dropdown .dropdown-item:hover,
#time-dropdown .dropdown-item:focus {
  background-color: #444;
  outline: none;
}

#time-dropdown .dropdown-item:last-child {
  border-bottom: none;
}

/* ====== Popup Wrappers  ====== */
.button-popup-wrapper {
  position: fixed !important;
  top: 130px !important;
  left: 20px !important;
  z-index: 10000 !important;
}

/* ====== Popups ====== */
.popup {
  display: none;  
  font-size: 0.95em;
  position: relative;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 1em;
  border-radius: 20px;
  width: 250px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

/* When popup is visible */
.popup[style*="display: block"] {
  display: block !important;
}

/* Specific popup adjustments if needed */
#poi-popup {
  width: 240px;
}

#layers-popup,
#sonification-popup {
  width: 250px;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5em;
}

.popup-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  padding: 0;
}

.popup-header .close-popup {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-header .close-popup img {
  display: block;
  width: 16px;
  height: 16px;
}

.popup-content {
  margin-top: 0.75em;
}

/* ====== POI Popup Specific ====== */
#poi-popup {
  width: 240px;
}

#poi-popup .popup-content p {
  margin-top: 0;
  margin-bottom: 0.5em;
  font-size: 0.9em;
}

#location-input {
  width: 100%;
  padding: 0.5em 0.75em;
  font-size: 0.9em;
  border: none;
  border-radius: 20px;
  margin-bottom: 0.75em;
  margin-top: 0.75em;
  box-sizing: border-box;
}

#current-location,
#add-location {
  background: none;
  border: none;
  color: white;
  text-decoration: underline;
  font-size: 0.85em;
  margin: 0.25em;
  cursor: pointer;
}

#current-location:hover,
#add-location:hover {
  text-decoration: none;
}

.location-list {
  list-style: none;
  padding: 0;
  margin-top: 10px;
}

.location-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9em;
  color: white;
  margin-bottom: 6px;
}

.remove-location {
  background: none;
  border: none;
  color: white;
  font-weight: bold;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.remove-location:hover {
  background: rgba(255, 255, 255, 0.15);
}

#message {
  font-size: 12px;
  margin-top: 0.5em;
}

/* ====== About/Info Modals ====== */
#about-popup {
  width: 500px !important;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}

#about-popup .popup-content {
  padding-right: 8px;
}

#about-popup .popup-content h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-size: 1.1em;
  color: #ffb38a;
}

#about-popup .popup-content h3:first-child {
  margin-top: 0;
}

#about-popup .popup-content p {
  margin-bottom: 0.75em;
  line-height: 1.5;
}

#about-popup .popup-content ul {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

#about-popup .popup-content li {
  margin-bottom: 0.5em;
  line-height: 1.4;
}

#about-popup::-webkit-scrollbar { width: 8px; }
#about-popup::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
#about-popup::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 4px; }
#about-popup::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }
#about-popup { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1); }

#about-popup-wrapper { width: auto !important; }

/* Sonification info modal */
#sonification-info-modal {
  width: 500px !important;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}

#sonification-info-modal-wrapper {
  left: 50% !important;
  transform: translateX(-50%);
  width: auto !important;
}

#sonification-info-modal .popup-content { padding-right: 8px; }

#sonification-info-modal .popup-content h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-size: 1.1em;
  color: #ffb38a;
}

#sonification-info-modal .popup-content h3:first-child { margin-top: 0; }
#sonification-info-modal .popup-content p { margin-bottom: 0.8em; line-height: 1.5; }
#sonification-info-modal .popup-content ul { margin-bottom: 1em; padding-left: 1.5em; }
#sonification-info-modal .popup-content li { margin-bottom: 0.4em; }
#sonification-info-modal::-webkit-scrollbar { width: 8px; }
#sonification-info-modal::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
#sonification-info-modal::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 4px; }
#sonification-info-modal::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }
#sonification-info-modal { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1); }

/* ====== Layer Legend Popup ====== */
.layer-popup {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 10px;
  background: rgba(25, 25, 25, 0.95);
  color: white;
  padding: 8px 16px;
  border-radius: 10px;
  z-index: 999;
  width: fit-content;
}

#popup-markers .legend-container {
  display: grid;
  grid-template-columns: repeat(2, auto);
  column-gap: 20px;
  row-gap: 6px;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

#popup-markers span.symbol {
  display: inline-block;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  font-size: 20px;
  -webkit-text-stroke: 1px white;
}

#popup-markers span.circle {
  transform: scale(1.5);
}

#popup-markers span.square {
  transform: scale(1.7);
}

#popup-markers span.triangle,
#popup-markers span.pentagon {
  transform: scale(0.8);
}

/* Colored polygon swatch for tornado severity legend */
#popup-markers span.swatch {
  display: inline-block;
  width: 20px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  vertical-align: middle;
  -webkit-text-stroke: 0;
  transform: none;
}

/* Small descriptive note beneath the legend items */
.legend-note {
  margin: 6px 0 0 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
  font-style: italic;
}

#layer-info-popup {
  position: absolute;
  background: rgba(35, 35, 35, 0.92) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
  backdrop-filter: blur(10px) brightness(1.05);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), 0 0 8px rgba(255, 255, 255, 0.08);
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 240px;
  line-height: 1.45;
  transition: opacity 0.2s ease, transform 0.15s ease;
  z-index: 10001 !important;
}

#layer-info-popup.show {
  transform: scale(1.03);
  opacity: 1;
}

/* ====== Info Buttons ====== */
.info-button {
  background: none;
  border: none;
  padding: 0;
  margin-left: 6px;
  cursor: pointer;
  vertical-align: middle;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.info-button:hover {
  opacity: 1;
}

.info-button img {
  filter: invert(1);
}

/* ====== Accessibility ====== */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* ====== Sonification ====== */
#sonification-info-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

#sonification-info-button:hover {
  opacity: 1;
}

#sonification-info-button img {
  filter: invert(1);
  width: 18px;
  height: 18px;
}

/* ====== POI Marker Animation ====== */
.pulse-marker {
  width: 16px;
  height: 16px;
  background: #0384fc;
  border-radius: 50%;
  border: 2px solid white;
  position: absolute;
  transform: translate(-50%, -50%);
  animation: pulse 1.5s infinite;
  z-index: 10;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(3, 132, 252, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(3, 132, 252, 0); }
  100% { box-shadow: 0 0 0 0 rgba(3, 132, 252, 0); }
}

#map-wrapper {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
}

#map-container {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  min-width: 320px;
  margin: 0;
  overflow: hidden;
}

/* ====== Explanation Popup ====== */
#explain-popup-wrapper {
  position: absolute;
  top: 80px;
  left: 20px;
  z-index: 999;
  pointer-events: none;
}

#explain-popup {
  width: 400px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  pointer-events: auto;
}

#explain-popup .popup-content {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Regenerate button styling */
.explain-regenerate-button {
  background: none;
  border: none;
  border-radius: 8px;
  color: white;
  padding: 4px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-family: 'Inter', sans-serif;
}

.explain-regenerate-button:hover:not(:disabled) {
  background-color: #993300;
}

.explain-regenerate-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Loading State */
.explain-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  gap: 12px;
}

.explain-loading p {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #cc4400;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Explanation Content Sections */
.explain-section {
  margin-bottom: 16px;
}

.explain-section:last-child {
  margin-bottom: 0;
}

.explain-headline h3 {
  margin: 0 0 8px 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffb38a;
  line-height: 1.3;
}

.explain-summary {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
}

.explain-section h4 {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.explain-bullets {
  margin: 0;
  padding-left: 18px;
  list-style-type: disc;
}

.explain-bullets li {
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
}

.explain-bullets li:last-child {
  margin-bottom: 0;
}

.explain-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

/* Error State */
.explain-error {
  padding: 20px;
  text-align: center;
}

.explain-error p {
  margin: 0 0 14px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

/* Placeholder State */
.explain-placeholder {
  padding: 30px 20px;
  text-align: center;
}

.explain-placeholder p {
  margin: 0 0 10px 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

.explain-placeholder p:first-child {
  font-size: 15px;
  margin-bottom: 14px;
  color: rgba(255, 255, 255, 0.95);
}

.explain-placeholder strong {
  color: white;
  font-weight: 600;
}

/* ====== Warning Details Panel ====== */
.warning-details-panel {
  position: fixed;
  top: 160px;
  left: 20px;
  width: 300px;
  max-height: 60vh;
  background-color: rgba(0, 0, 0, 0.85);
  color: white;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 990;
  display: none;
  flex-direction: column;
  gap: 12px;
  font-size: 0.95em;
}

.warning-details-panel.visible {
  display: flex;
}

.warning-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.warning-details-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
}

.close-details-panel {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.close-details-panel:hover {
  opacity: 1;
}

.close-details-panel img {
  display: block;
  width: 16px;
  height: 16px;
  /* force a bright white appearance for the close icon */
  filter: brightness(0) saturate(100%) invert(100%) !important;
  opacity: 1;
}

.warning-details-content {
  overflow-y: auto;
  flex: 1;
  padding-right: 8px;
}

.warning-details-content::-webkit-scrollbar {
  width: 6px;
}

.warning-details-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.warning-details-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.warning-details-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.warning-details-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1);
}

.warning-details-headline {
  margin: 0 0 12px 0;
  font-size: 1.05em;
  font-weight: 700;
  color: #ffb38a;
  line-height: 1.4;
}

.warning-details-description {
  margin: 0;
  font-size: 0.9em;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.explain-retry-button {
  background: #cc4400;
  border: none;
  border-radius: 8px;
  color: white;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.explain-retry-button:hover {
  background: #993300;
}

/* Responsive Design */
@media (max-width: 768px) {
  #explain-popup {
    width: calc(100vw - 40px);
    max-width: 400px;
  }
  
  #explain-popup-wrapper {
    left: 20px;
    right: 20px;
  }
}

/* ====== Tornado Warning Polygon Tooltip overrides ====== */
.highcharts-tooltip-container {
  z-index: 9999 !important;
}
