/* Global layout */
html, body {
  height: 100dvh;               /* dynamic viewport height (accounts for browser bars) */
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;           /* prevent horizontal scroll */
  font-family: Arial, sans-serif;
}

/* Header */
header {
  flex: 0 0 auto;               /* only as tall as content */
  background: #b22222;
  color: white;
  text-align: center;
  padding: 0.5em;
}

h1 {
  line-height: 1rem;
}

/* Main layout */
main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 0 5%;
  max-width: 100%;
  overflow: hidden;          /* prevent children from pushing map off-screen */
}

#stop-info {
  flex: 1 1 auto;            /* take remaining space above map */
  overflow-y: auto;          /* scroll just this panel */
  padding: 1em 0;
  box-sizing: border-box;
}

/* Narration text */
#stop-text,
#extra-text {
  white-space: normal;          /* allow wrapping */
  word-wrap: break-word;        /* legacy wrapping */
  overflow-wrap: anywhere;      /* modern wrapping */
  display: block;
  max-width: 100%;
  margin-bottom: 1em;
}

/* Sentence highlighting */
.sentence {
  display: inline;
  white-space: normal;
}

.sentence.highlight {
  background-color: yellow;
  color: black;
}

/* Mark tag fallback */
mark {
  background-color: yellow;
  color: black;
  font-weight: bold;
  white-space: normal;
}

/* Map container (fixed proportion of screen) */
#map {
  flex: 0 0 30dvh;              /* about 40%>30 of dynamic viewport height */
  flex-shrink: 0;               /* don’t shrink */
}

/* Buttons */
button {
  margin: 0.5em;
  padding: 0.5em 1em;
  font-size: 1em;
  cursor: pointer;
}

/* Prev/Next navigation */
.nav-buttons {
  display: flex;
  flex-wrap: wrap;              /* allow wrapping on small screens */
  justify-content: space-between;
  gap: 0.5em;
}

.nav-buttons button {
  flex: 1 1 auto;               /* allow shrink/wrap */
  min-width: 120px;             /* keep them usable */
}

/* Locate Me button */
.locate-btn {
  font-size: 14px;
  border-radius: 4px;
  background: white;
  border: 1px solid #666;
  padding: 4px 8px;
}

/* Push Leaflet controls above Android/iOS browser bars */
.leaflet-bottom.leaflet-right {
  margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
}

/* Narration text chunks for highlighting */
.chunk.highlight {
  background-color: yellow;
  color: black;
}