html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}
h1, h2 {
  font-weight: 600;
}

strong {
  font-weight: 600;
}

.container {
  display: flex;
  height: 100vh;
}

.mobile-legend-toggle {
  display: none; /* hidden by default */
}

/* ============== Off-canvas overlay sidebar for mobile ===== */
@media (max-width: 768px) {

  .mobile-legend-toggle {
    display: block; /* visible only on mobile */
  }

  /* container to behave nicely on mobile */
  .container {
    position: relative;
    height: 100vh;
    flex-direction: column;
  }

  /* Make the map fill the whole viewport and sit behind the sidebar */
  #map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    z-index: 0;
  }

  /* Sidebar becomes a fixed overlay panel hidden by default */
  .sidebar {
    /* padding-top: 80px; */
    position: fixed;
    top: 0;
    left: 0;
    width: 86%;
    max-width: 360px;
    height: 100vh;
    transform: translateX(-110%); /* hidden off-screen */
    transition: transform 0.28s ease;
    z-index: 1100;
    overflow-y: auto;
    background: #f7f7f7;
    box-shadow: 2px 0 12px rgba(0,0,0,0.2);
    border-right: 1px solid #ddd;
    -webkit-overflow-scrolling: touch;
  }

  /* When open, slide in */
  .sidebar.open {
    transform: translateX(0);
  }

  /* Floating button to open the sidebar */
  .mobile-legend-toggle {
  position: fixed;
  top: 3px;                /* stick to very top */
  left: 8px;               /* stick to very left */
  z-index: 1200;

  padding: 4px 8px;      /* smaller padding */
  border-radius: 6px;    /* slightly less rounded */
  background: #1b85b8;
  color: #fff;
  border: none;
  font-size: 12px;       /* smaller font */
  box-shadow: 0 2px 4px rgba(0,0,0,0.2); /* lighter shadow */
}

  /* Dim the map when sidebar is open (overlay) */
  .overlay {
    position: fixed;
    top: 0;
    left: 50%;
    right: 0;
    bottom: 20px;
    background: rgba(0,0,0,0.35);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
  }
  .overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* smaller font sizes for mobile */
  .sidebar h2 { font-size: 18px;}
  .sidebar h3 { font-size: 16px; }
  .sidebar { font-size: 15px; padding: 14px; }
  .toggle-button, .view-button {
    padding: 10px 12px;
    font-size: 15px;
  }

}
/*********************************************/

/* Side Bar */

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh; /* full sidebar height */
  width: 250px; /* adjust width as needed */
  background: #f7f7f7;
  padding: 20px;
  border-right: 1px solid #ddd;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  overflow-y: auto;
  font-size: 18px;
  line-height: 1.5;
  font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.sidebar-header {
  margin-bottom: 20px;
}

.sidebar-legends {
  flex-grow: 1; /* this allows legends to expand naturally if needed */
}
.sidebar h3 {
  font-size: 20px;     /* slightly bigger than the body text (18px) */
  font-weight: 600;    /* semi-bold for headings */
  margin-top: 0;       /* remove default top margin for a tight look */
  margin-bottom: 10px; /* space below the heading */
  color: #333;         /* optional: make it dark and clear */
}

/* Add extra spacing above Rainfall */
.sidebar h3 + h3 {
  margin-top: 20px; /* 👈 puts gap above Rainfall */
}
/* Or target just the second h3 */
.sidebar h3:nth-of-type(2) {
  margin-top: 20px; /* extra top space above Rainfall */
}
/* Style the small (in 1 hour) nicely */
.sidebar small {
  display: block;     /* puts it on its own line */
  margin-top: -5px;   /* pull it slightly closer to the heading */
  margin-bottom: 10px; /* add a bit of spacing below it */
  font-size: 12px;    /* smaller text */
  color: #555;        /* softer grey if you like */
}

.sidebar h2 {
  font-size: 22px;   /* bigger than h3 */
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 5px;
  color: #333;
}
.sidebar-description {
  font-size: 14px;
  line-height: 1.4;
  color: #555;
  margin: 10px 0 20px;
  text-align: justify;

  background-color: #e0f3ff; /* light blue background */
  padding: 12px 16px;        /* spacing inside the box */
  border-radius: 10px;       /* rounded corners */
   border: 1px solid #cce7f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* sidebar note */
.sidebar-note {
  margin-top: 30px;   /* space above the note */
  font-size: 10px;    /* small but readable */
  color: #555;        /* softer grey text */
  line-height: 1.4;
  text-align: justify;
  padding-bottom: 20px;

  
}

.sidebar-note a {
  color: #0056b3;        /* match text color */
  text-decoration: none; /* optional */
  font-weight: 600; 
}

.sidebar-note a:hover {
  color: #007BFF;        /* slightly darker on hover */
}

.legend-list {
  list-style: none;
  padding: 0;
  font-size: 15px;
}
.legend-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px; /* optional gap */
}
.legend-row span {
  margin-right: 20px; /* optional spacing between items */
}
.legend-list.water-level {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 2 columns */
  gap: 8px 20px; /* space between items */
  list-style: none;
  padding: 0;
  margin: 0;
}
.legend-list.water-level li {
  display: flex;
  align-items: center;
  font-size: 14px;
}
.legend-color {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  margin-right: 8px;
}
.legend-color.normal {
  background-color: #ADD8E6;
}

.legend-color.alert {
  background-color: #A7C7E7;
}
.legend-color.warning {
  background-color: #7393B3;
}
.legend-color.danger {
  background-color: #d74338;
}

/* Button */
.toggle-button{
  display: block;
  margin: 10px 0;
  padding: 8px 12px;
  color: #fff;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;  
  font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.toggle-button.active {
  background-color: #A6A6A6 !important; /* Red or any color you want when active */
}
.view-button {
    flex: 1;
    padding: 8px 12px;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.9;
  }
.view-button.disabled {
    background-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
    pointer-events: none; /* makes it unclickable */
  }

  #toggleFloodAreas {background-color: #1b85b8;}
  #goPeninsular { background-color: #7393B3; }
  #goBorneo { background-color: #7d95b9; }
  #goFullMalaysia { background-color: #5289B5; }

  .selected {
    background-color: #A6A6A6 !important; /* or change background color, e.g. darker */
    opacity: 1;
  }

#map {
  flex: 1;
}

/* html, body, #map { height: 100%; margin: 0; } */

/* ----------------------------- */
/* Rain cloud and lightning icon */

.weather-icon {
  position: relative;
  width: 80px;
  height: 80px;
  margin: auto;  /* for what? */
  transform: translate(-25px, -70px);
}

.cloud {
  width: 30px;
  height: 21px;
  border-radius: 50%;
  position: absolute;
  top: 10px;
  left: 10px;
  box-shadow: 14px 0 currentColor, 28px 0 currentColor;
}

.rain-light .cloud {
  background: #ccc;
  color: #ccc;
}

.rain-medium .cloud {
  background: #aaa;
  color: #aaa;
}

.rain-heavy .cloud {
  background: #888;
  color: #888;
}

/* VERY HEAVY CLOUD */
/* Remove box-shadow for very heavy cloud */
.rain-very-heavy .cloud {
  box-shadow: none;
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(to top, #333 0%, #bbb 100%);
}

/* Position each puff */
.rain-very-heavy .part1 {
  width: 30px; height: 21px;
  top: 10px; left: 25px;
}

.rain-very-heavy .part2 {
  width: 30px; height: 21px;
  top: 10px; left: 40px;
}

.rain-very-heavy .part3 {
  width: 30px; height: 21px;
  top: 10px; left: 10px;
}

.rain {
  position: absolute;
  width: 2px;
  height: 10px;
  background: #0077cc;
  bottom: 35px;/*change back to 35px */
  animation: rain-fall 1s linear infinite;
}

@keyframes rain-fall {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(30px); opacity: 0; }
}
.rain-light .rain { animation-duration: 1.4s; opacity: 0.3; }
.rain-medium .rain { animation-duration: 0.8s; opacity: 0.6; }
.rain-heavy .rain { animation-duration: 0.4s; opacity: 1; }
.rain-very-heavy .rain { animation-duration: 0.3s; opacity: 1; }

.rain-light .rain1 { left: 36px; animation-delay: 0s; }
.rain-light .rain2 { left: 39px; animation-delay: 0.5s; }
.rain-light .rain3 { left: 42px; animation-delay: 1s; }
.rain-light .rain4 { left: 48px; animation-delay: 0.3s; }
.rain-light .rain5 { left: 52px; animation-delay: 0.2s; }
.rain-light .rain6 { left: 57px; animation-delay: 1s; }

.rain-medium .rain1 { left: 30px; animation-delay: 0.1s; }
.rain-medium .rain2 { left: 33px; animation-delay: 0.3s; }
.rain-medium .rain3 { left: 36px; animation-delay: 0s; }
.rain-medium .rain4 { left: 39px; animation-delay: 0.2s; }
.rain-medium .rain5 { left: 42px; animation-delay: 0.4s; }
.rain-medium .rain6 { left: 45px; animation-delay: 0.1s; }
.rain-medium .rain7 { left: 48px; animation-delay: 0.5s; }
.rain-medium .rain8 { left: 51px; animation-delay: 0.2s; }
.rain-medium .rain9 { left: 54px; animation-delay: 0.3s; }
.rain-medium .rain10 { left: 57px; animation-delay: 0.4s; }

.rain-heavy .rain1 { left: 28px; animation-delay: 0.1s; }
.rain-heavy .rain2 { left: 30px; animation-delay: 0.3s; }
.rain-heavy .rain3 { left: 32px; animation-delay: 0s; }
.rain-heavy .rain4 { left: 34px; animation-delay: 0.2s; }
.rain-heavy .rain5 { left: 36px; animation-delay: 0.4s; }
.rain-heavy .rain6 { left: 38px; animation-delay: 0.1s; }
.rain-heavy .rain7 { left: 40px; animation-delay: 0.3s; }
.rain-heavy .rain8 { left: 42px; animation-delay: 0s; }
.rain-heavy .rain9 { left: 44px; animation-delay: 0.2s; }
.rain-heavy .rain10 { left: 46px; animation-delay: 0.4s; }
.rain-heavy .rain11 { left: 48px; animation-delay: 0.1s; }
.rain-heavy .rain12 { left: 50px; animation-delay: 0.3s; }
.rain-heavy .rain13 { left: 52px; animation-delay: 0s; }
.rain-heavy .rain14 { left: 54px; animation-delay: 0.2s; }
.rain-heavy .rain15 { left: 56px; animation-delay: 0.4s; }
.rain-heavy .rain16 { left: 58px; animation-delay: 0.5s; }

.rain-very-heavy .rain1 { left: 26px; animation-delay: 0.0s; }
.rain-very-heavy .rain2 { left: 28px; animation-delay: 0.1s; }
.rain-very-heavy .rain3 { left: 30px; animation-delay: 0.2s; }
.rain-very-heavy .rain4 { left: 32px; animation-delay: 0.3s; }
.rain-very-heavy .rain5 { left: 34px; animation-delay: 0.0s; }
.rain-very-heavy .rain6 { left: 36px; animation-delay: 0.1s; }
.rain-very-heavy .rain7 { left: 38px; animation-delay: 0.2s; }
.rain-very-heavy .rain8 { left: 40px; animation-delay: 0.3s; }
.rain-very-heavy .rain9 { left: 42px; animation-delay: 0.0s; }
.rain-very-heavy .rain10 { left: 44px; animation-delay: 0.1s; }
.rain-very-heavy .rain11 { left: 46px; animation-delay: 0.2s; }
.rain-very-heavy .rain12 { left: 48px; animation-delay: 0.3s; }
.rain-very-heavy .rain13 { left: 50px; animation-delay: 0.0s; }
.rain-very-heavy .rain14 { left: 52px; animation-delay: 0.1s; }
.rain-very-heavy .rain15 { left: 54px; animation-delay: 0.2s; }
.rain-very-heavy .rain16 { left: 56px; animation-delay: 0.3s; }
.rain-very-heavy .rain17 { left: 58px; animation-delay: 0.0s; }
.rain-very-heavy .rain18 { left: 60px; animation-delay: 0.1s; }
.rain-very-heavy .rain19 { left: 62px; animation-delay: 0.2s; }
.rain-very-heavy .rain20 { left: 64px; animation-delay: 0.3s; }
.rain-very-heavy .rain21 { left: 66px; animation-delay: 0.0s; }
.rain-very-heavy .rain22 { left: 68px; animation-delay: 0.1s; }
.rain-very-heavy .rain23 { left: 70px; animation-delay: 0.2s; }
.rain-very-heavy .rain24 { left: 72px; animation-delay: 0.3s; }

.lightning {
  position: absolute;
  top: 25px;
  left: 40px;
  opacity: 0;
}
.rain-medium .lightning {
  width: 3px;
  height: 20px;
  background: white;
  border: 1px solid #888;
  transform: rotate(20deg);
  animation: lightning-flash 3s infinite;
  box-shadow: 0 0 10px #fff;
}
.rain-heavy .lightning {
  width: 0;
  height: 0;
  animation: heavy-lightning-flash 1.5s infinite;
}
.rain-heavy .lightning::before,
.rain-heavy .lightning::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 20px;
  background: white;
  border: 1px solid #666;
  box-shadow: 0 0 5px #fff;
}
.rain-heavy .lightning::before {
  transform: rotate(30deg);
  top: 0;
  left: 0;
}
.rain-heavy .lightning::after {
  transform: rotate(-30deg);
  top: 17px;
  left: 5px;
}

.rain-very-heavy .lightning {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  animation: heavy-lightning-flash 1.5s infinite;
}

.rain-very-heavy .lightning::before,
.rain-very-heavy .lightning::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 20px;
  background: white;
  border: 1px solid #666;
  box-shadow: 0 0 5px #fff;
}

/* Shape of each bolt */
.rain-very-heavy .lightning::before {
  transform: rotate(30deg);
  top: 0;
  left: 0;
}

.rain-very-heavy .lightning::after {
  transform: rotate(-30deg);
  top: 17px;
  left: 5px;
}

/* Position the first bolt */
.rain-very-heavy .bolt1 {
  top: 25px;
  left: 35px;
}

/* Position the second bolt */
.rain-very-heavy .bolt2 {
  top: 30px;
  left: 50px;
  animation-delay: 0.3s; /* offset for a flicker effect */
}

@keyframes lightning-flash {
  0%, 96%, 100% { opacity: 0; }
  97% { opacity: 1; }
  98% { opacity: 0.6; }
  99% { opacity: 1; }
}
@keyframes heavy-lightning-flash {
  0%, 10%, 30%, 60%, 90%, 100% { opacity: 0; }
  5%, 12%, 32%, 62%, 92% { opacity: 1; }
}

/* ----------------------------- */
/* ---------Flood marking--------*/
.flood-icon {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  animation: unified-pulse 1.2s infinite ease-in-out;
  /* box-shadow: 0 0 6px rgba(0,0,0,0.5); */
}
.flood-normal {
  background-color: #ADD8E6;
  animation: none;
}
.flood-alert {
  background-color: #A7C7E7;
  /* animation: medium-breathe 1.5s ease-in-out infinite; */
}
.flood-warning {
  background-color: #7393B3;
}
.flood-danger {
  background-color: #d74338;
}
.flood-warning::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background-color: #7393B3;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.4;
  animation: warning-beam 2s infinite ease-out;
}

.flood-danger::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background-color: #d74338;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.5;
  animation: danger-beam 1.2s infinite ease-out;
}

/* Shared pulse for medium, warning, danger */
@keyframes unified-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes warning-beam {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
  100% { transform: translate(-50%, -50%) scale(2.0); opacity: 0; }
}

@keyframes danger-beam {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}



