/* Floating attribute panel (map tap) — see infobox_sheet.js.
 * Desktop / tablet: Cesium's InfoBox is left exactly as Cesium draws it
 * (floating far right). The WebGIS .gl-infobox copies that look.
 * Phones (<= 640 px): both become a full-width bottom sheet.
 * The hamburger drawer is not styled here. */

.gl-ib-grip { display: none; }

/* ---- WebGIS floating panel (desktop / tablet) ---- */
.gl-infobox {
  position: absolute;
  top: 66px;
  right: 0;
  width: 40%;
  max-width: 480px;
  min-width: 280px;
  max-height: calc(100% - 150px);
  display: flex;
  flex-direction: column;
  z-index: var(--gl-ib-z, 1075);
  background: rgba(38, 38, 38, 0.95);
  color: #edffff;
  border: 1px solid #444;
  border-right: none;
  border-top-left-radius: 7px;
  border-bottom-left-radius: 7px;
  box-shadow: 0 0 10px 1px #000;
  font-family: sans-serif;
  transform: translate(100%, 0);
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.2s, opacity 0.2s ease-in, transform 0.2s ease-in;
}
.gl-infobox.open {
  transform: translate(0, 0);
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
.gl-infobox-title {
  flex: 0 0 auto;
  display: block;
  min-height: 20px;
  padding: 5px 30px 5px 25px;
  background: rgba(84, 84, 84, 1);
  border-top-left-radius: 7px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  font-size: 14px;
}
.gl-infobox-close {
  position: absolute;
  top: 5px;
  right: 5px;
  height: 20px;
  background: transparent;
  border: none;
  border-radius: 2px;
  font-weight: bold;
  font-size: 16px;
  padding: 0 5px;
  margin: 0;
  color: #edffff;
  cursor: pointer;
}
.gl-infobox-close:hover { background: #888; color: #000; }
.gl-infobox-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 5px 10px 10px;
  font-size: 13px;
}
/* Same table look as Cesium's InfoBoxDescription.css */
.gl-infobox-body table.cesium-infoBox-defaultTable {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 13px;
  color: #edffff;
}
.gl-infobox-body table.cesium-infoBox-defaultTable tr:nth-child(odd) { background-color: rgba(84, 84, 84, 0.8); }
.gl-infobox-body table.cesium-infoBox-defaultTable tr:nth-child(even) { background-color: rgba(84, 84, 84, 0.25); }
.gl-infobox-body table.cesium-infoBox-defaultTable th {
  width: auto;
  font-weight: normal;
  padding: 3px;
  vertical-align: middle;
  text-align: center;
  color: #edffff;
  border: none;
}
.gl-infobox-body table.cesium-infoBox-defaultTable td {
  padding: 3px 5px 3px 3px;
  vertical-align: middle;
  text-align: left;
  border: none;
}

/* ---- Phones: bottom sheet (Cesium InfoBox + WebGIS panel) ---- */
@media (max-width: 640px) {
  .cesium-infoBox.gl-ib-sheet,
  .gl-infobox {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    max-height: min(62vh, 560px);
    display: flex;
    flex-direction: column;
    z-index: var(--gl-ib-sheet-z, 38);
    box-sizing: border-box;
    border: none;
    border-top: 1px solid #555;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow: hidden;
    transform: translateY(110%);
    opacity: 1;
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s 0.22s;
  }
  .cesium-infoBox.gl-ib-sheet.cesium-infoBox-visible,
  .gl-infobox.open {
    transform: translateY(0);
    visibility: visible;
    transition: transform 0.22s ease;
  }
  .cesium-infoBox.gl-ib-sheet.cesium-infoBox-visible.gl-ib-collapsed,
  .gl-infobox.open.gl-ib-collapsed {
    transform: translateY(calc(100% - 52px - env(safe-area-inset-bottom, 0px)));
  }
  .gl-ib-sheet .gl-ib-grip,
  .gl-infobox .gl-ib-grip {
    display: block;
    position: absolute;
    top: 5px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.45);
    z-index: 2;
    pointer-events: none;
  }
  .cesium-infoBox.gl-ib-sheet .cesium-infoBox-title,
  .gl-infobox .gl-infobox-title {
    flex: 0 0 auto;
    height: auto;
    min-height: 26px;
    line-height: 26px;
    padding: 14px 54px 8px 54px;
    border-radius: 14px 14px 0 0;
    font-weight: 700;
    font-size: 14px;
    box-sizing: content-box;
    touch-action: none;
    cursor: pointer;
    user-select: none;
  }
  .cesium-infoBox.gl-ib-sheet button.cesium-infoBox-close,
  .gl-infobox .gl-infobox-close {
    top: 6px;
    right: 6px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    z-index: 3;
  }
  .cesium-infoBox.gl-ib-sheet button.cesium-infoBox-camera {
    top: 10px;
    left: 8px;
    z-index: 3;
  }
  /* The InfoBox body is an iframe: cap it to the sheet so it scrolls inside. */
  .cesium-infoBox.gl-ib-sheet .cesium-infoBox-iframe {
    flex: 0 1 auto;
    width: 100%;
    max-height: calc(min(62vh, 560px) - 52px - env(safe-area-inset-bottom, 0px)) !important;
  }
  .gl-infobox .gl-infobox-body {
    overflow-x: hidden;
    overflow-y: auto;
    padding: 6px 10px 14px;
  }
  .gl-infobox-body table.cesium-infoBox-defaultTable th,
  .gl-infobox-body table.cesium-infoBox-defaultTable td { overflow-wrap: anywhere; word-break: break-word; }

  /* Tools FAB / hint sit above the sheet instead of under it. */
  body.gl-ib-on #toolsFabWrap { bottom: calc(var(--gl-ib-h, 0px) + 12px) !important; }
  body.gl-ib-on #toolsMenu { max-height: calc(100vh - var(--gl-ib-h, 0px) - 150px); overflow-y: auto; }
  body.gl-ib-on #toolHint { bottom: calc(var(--gl-ib-h, 0px) + 84px) !important; }
  /* Map zoom buttons and imagery credits stay visible above the sheet. */
  body.gl-ib-on .leaflet-bottom { margin-bottom: calc(var(--gl-ib-h, 0px) + 8px) !important; }
  body.gl-ib-on .cesium-viewer-bottom { bottom: calc(var(--gl-ib-h, 0px) + 8px) !important; }
}
