/* Shared mobile / responsive rules for B-LOON */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* B-LOON brand mark — same size + position on every page */
#header {
  position: absolute !important;
  top: 0 !important;
  left: 10px !important;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: 100px !important;
  line-height: 100px !important;
  z-index: 3;
}
#header,
#header a {
  font-size: 24px !important;
  font-weight: bold !important;
  font-family: Helvetica, Arial, sans-serif !important;
  text-decoration: none !important;
}

img {
  max-width: 100%;
  height: auto;
}

/* About page photo grids — 3 cols tablet/desktop, 2 cols phone */
.img-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  justify-items: center;
  align-items: center;
  max-width: 960px;
  margin: 12px auto;
  text-align: center;
}

.img-grid img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

.img-full {
  display: block;
  width: 100%;
  max-width: 960px;
  height: auto;
  margin: 12px auto;
}

/* Urban Explorers Dordrecht: 3 on first row, 2 larger under spanning full width */
.img-grid-3-2 {
  grid-template-columns: repeat(6, 1fr);
}

.img-grid-3-2 img:nth-child(1) { grid-column: 1 / 3; }
.img-grid-3-2 img:nth-child(2) { grid-column: 3 / 5; }
.img-grid-3-2 img:nth-child(3) { grid-column: 5 / 7; }
.img-grid-3-2 img:nth-child(4) { grid-column: 1 / 4; }
.img-grid-3-2 img:nth-child(5) { grid-column: 4 / 7; }

/* ADBK Nurnberg: always 3 in a row, keep natural aspect ratio */
.img-grid-3-equal {
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
}

.img-grid-3-equal img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

#wrapper img[width],
#wrapper img[height] {
  width: auto;
  max-width: 100%;
  height: auto;
}

.img-grid img[width],
.img-grid img[height] {
  width: 100%;
  height: auto;
}

input[type="text"],
input[type="email"],
textarea {
  max-width: 100%;
  font-size: 16px; /* avoids iOS zoom on focus */
}

#code-form input[type="text"] {
  width: 4.5em;
  text-align: center;
}

@media (max-width: 720px) {
  /* Same brand position on every mobile page */
  #header,
  body.page-home #header,
  body.page-about #header,
  body.page-form #header {
    position: absolute !important;
    top: 0 !important;
    left: 8px !important;
    right: auto !important;
    width: auto !important;
    max-width: 45% !important;
    height: 56px !important;
    margin: 0 !important;
    padding: 0 4px !important;
    line-height: 56px !important;
    font-size: 24px !important;
    z-index: 3;
  }

  #login {
    position: static !important;
    width: auto !important;
    top: auto !important;
    right: auto !important;
    padding: 8px 12px 12px;
    font-size: 16px !important;
  }

  #table1 {
    float: none !important;
    width: 100%;
  }

  #table1 td {
    display: inline-block;
    vertical-align: middle;
    padding: 2px 4px;
  }

  #wrapper {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 12px !important;
  }

  /* Full-bleed home map; login right on one line with brand */
  body.page-home {
    min-height: 100%;
    min-height: 100dvh;
  }

  body.page-home #login,
  body.page-about #login {
    position: absolute !important;
    right: 4px !important;
    top: 0 !important;
    left: auto !important;
    width: auto !important;
    max-width: 58% !important;
    height: 56px !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 13px !important;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    z-index: 3;
  }

  body.page-home #table1,
  body.page-about #table1 {
    float: none !important;
    width: auto !important;
    margin: 0 !important;
  }

  body.page-home #table1 td,
  body.page-about #table1 td {
    display: table-cell !important;
    padding: 0 2px !important;
    white-space: nowrap;
  }

  body.page-home #code-form input[type="text"],
  body.page-about #code-form input[type="text"] {
    margin: 0;
    font-size: 16px;
  }

  body.page-home #submit,
  body.page-about #submit {
    margin: 0;
    padding: 6px 10px;
    min-height: 36px;
    font-size: 13px;
  }

  body.page-home #wrapper {
    position: absolute !important;
    top: 56px !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: calc(100dvh - 56px) !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: hidden !important;
  }

  body.page-home #google_map {
    width: 100% !important;
    height: 100% !important;
    min-height: calc(100dvh - 56px) !important;
    max-height: none !important;
  }

  body.page-about #wrapper {
    position: static !important;
    margin-top: 56px !important;
    padding-top: 12px !important;
  }

  body.page-about #google_map,
  #google_mapnurn,
  #google_mapbru,
  #google_mapadam {
    width: 100% !important;
    max-width: 100% !important;
    height: 55vw !important;
    min-height: 240px !important;
    max-height: 420px !important;
  }

  #black,
  #wrapper,
  body {
    white-space: normal !important;
  }

  #black {
    white-space: normal !important;
    width: 100%;
  }

  #black td {
    display: block;
    width: 100%;
    padding: 2px 0;
  }

  table[style*="width:80%"],
  form table,
  #wrapper > table {
    width: 100% !important;
  }

  #wrapper table td {
    display: block;
    width: 100% !important;
    padding: 4px 0;
  }

  /* Result details: keep "Name :" and value on one line */
  body.page-form #black,
  body.page-form table#black {
    display: table !important;
    width: 100% !important;
    table-layout: auto !important;
    margin: 0 0 12px !important;
  }

  body.page-form #black tr {
    display: table-row !important;
  }

  body.page-form #black td {
    display: table-cell !important;
    width: auto !important;
    padding: 2px 8px 2px 0 !important;
    vertical-align: top !important;
    white-space: normal !important;
    font-size: 15px !important;
    line-height: 1.3 !important;
  }

  body.page-form #black td:first-child {
    white-space: nowrap !important;
    width: 1% !important;
    padding-right: 10px !important;
  }

  body.page-form #black td[colspan] {
    white-space: normal !important;
    width: 100% !important;
  }

  /* Match detail text size; space around dates */
  body.page-form .found-title,
  body.page-form .found-date {
    font-size: 15px !important;
    line-height: 1.3 !important;
    font-weight: normal !important;
    margin: 18px 0 !important;
  }

  body.page-form .found-heading {
    font-size: 22px !important;
    line-height: 1.3 !important;
    font-weight: bold !important;
    margin: 18px 0 !important;
  }

  body.page-form .found-prompt {
    font-size: 15px !important;
    line-height: 1.3 !important;
    font-weight: normal !important;
    margin: 20px 0 !important;
  }

  /* Forms still stack fields full-width */
  body.page-form form td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
  }

  /* Send forms: same brand bar; content starts below it */
  body.page-form #wrapper {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    font-size: 14px !important;
    line-height: 1.15 !important;
    padding: 2px 10px 16px !important;
    margin: 56px 0 0 !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }

  body.page-form #wrapper table {
    border-spacing: 0 !important;
    border-collapse: collapse !important;
    margin: 0 !important;
  }

  body.page-form #wrapper table td {
    font-size: 15px !important;
    line-height: 1.2 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.page-form #wrapper input[type="text"],
  body.page-form #wrapper input[type="email"],
  body.page-form #wrapper textarea {
    font-size: 16px !important;
    padding: 4px 6px !important;
    margin: 0 0 4px !important;
    border-width: 1px !important;
  }

  /* I Like: ~4 lines in portrait, compact in landscape */
  body.page-form #wrapper textarea {
    line-height: 1.25 !important;
    min-height: 48px !important;
    height: 48px !important;
    max-height: 56px !important;
  }

  @media (orientation: portrait) {
    body.page-form #wrapper textarea {
      min-height: 5.5em !important;
      height: 5.5em !important;
      max-height: 6em !important;
    }
  }

  body.page-form .hide-mobile,
  body.page-form #wrapper > br {
    display: none !important;
  }

  body.page-form #submit {
    margin: 4px 0 20px !important;
    padding: 6px 12px !important;
    min-height: 36px !important;
    display: inline-block !important;
  }

  body.page-form .status-not-found {
    display: block !important;
    margin: 24px 0 8px !important;
    padding: 0 !important;
    font-size: 22px !important;
    line-height: 1.3 !important;
    font-weight: bold !important;
  }

  body.page-form #back {
    display: inline-block !important;
    position: static !important;
    left: auto !important;
    margin: 0 !important;
    padding: 6px 12px !important;
    min-height: 36px !important;
  }

  /* Landscape: Back in normal flow so it does not cover text */
  body.page-form #wrapper table.back-row,
  body.page-form .back-row {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 80% !important;
    margin: 12px 0 8px !important;
    z-index: auto !important;
  }

  /* Portrait: pin Back to bottom of the viewport */
  @media (orientation: portrait) {
    body.page-form #wrapper {
      padding-bottom: 72px !important;
    }

    body.page-form #wrapper table.back-row,
    body.page-form .back-row {
      position: fixed !important;
      left: 10px !important;
      right: 10px !important;
      bottom: max(16px, env(safe-area-inset-bottom)) !important;
      width: auto !important;
      max-width: none !important;
      margin: 0 !important;
      z-index: 20 !important;
      background: transparent !important;
    }
  }

  #wrapper input[type="text"],
  #wrapper input[type="email"],
  #wrapper textarea {
    width: 100% !important;
    margin-left: 0;
    margin-right: 0;
  }

  #back,
  #submit {
    position: static !important;
    left: auto !important;
    margin: 8px 0;
    min-height: 44px;
    min-width: 44px;
  }

  #result {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .ol-popup {
    max-width: min(280px, calc(100vw - 32px));
    left: 0;
    font-size: 14px;
  }

  .ol-popup-content,
  .marker-info-win,
  .marker-info-win p,
  .info-content {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
  }

  .img-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-left: auto;
    margin-right: auto;
  }

  .img-grid-3-2 {
    grid-template-columns: repeat(6, 1fr);
  }

  .img-grid-3-equal {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 480px) and (max-width: 720px) {
  .img-grid:not(.img-grid-3-2) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
