/* Remove the browser's default white border around the page */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, sans-serif;
}

/* Make the map fill the whole browser window */
#map {
  width: 100%;
  height: 100%;
}

/* The floating panel: white, rounded, with a soft shadow */
#info-panel {
  position: absolute;
  z-index: 1000; /* keeps the panels above the map */
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  overflow-y: auto; /* scroll inside the panel if the text is too long */
}

/* The control panel in the top-right corner */
#info-panel {
  top: 10px;
  right: 10px;
  width: 300px;
  max-width: calc(100% - 70px); /* leaves room for the zoom buttons on small screens */
  max-height: calc(100% - 20px);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums; /* stops numbers jiggling as they change */
}

.panel-title {
  font-weight: bold;
  font-size: 15px;
}

/* The name links back to the home page, but looks like a heading */
.panel-title a {
  color: inherit;
  text-decoration: none;
}

.panel-title a:hover {
  text-decoration: underline;
}

/* The tagline under the name */
.tagline {
  font-size: 12px;
  font-style: italic;
  color: #555;
  margin-bottom: 4px;
}

/* Each numbered step in the control panel, separated by a thin line */
.step {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #ddd;
}

.small,
.hint {
  font-size: 12px;
  color: #555;
}

/* The responsible use note under the title */
.responsible-use {
  margin-top: 4px;
  font-size: 11px;
}

/* Links in the panels (the README and the credits) */
.hint a,
.credits a,
.credit-line a {
  color: #1a5fb4;
}

/* --- Finding a place by name --- */
.place-search {
  display: flex;
  gap: 6px;
  margin: 4px 0 2px;
}

.place-search input {
  flex: 1;
  min-width: 0; /* lets the box shrink on narrow screens */
  font: inherit;
  padding: 3px 6px;
}

/* The list of places found: each one is a button */
.place-results {
  list-style: none;
  margin: 4px 0;
  padding: 0;
}

.place-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 3px 6px;
  margin-bottom: 3px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.credit-line {
  font-size: 11px;
  color: #666;
}

.examples-label {
  margin-top: 6px;
}

/* The "Copy link" fallback: the link in a box, ready to select */
#copy-link-status input {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
}

.status {
  margin-top: 4px;
  font-size: 13px;
  color: #1a5fb4;
}

/* The row of buttons. flex-wrap lets them wrap onto
   a second line on narrow screens such as phones. */
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 4px;
}

.buttons button {
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}

/* The two date boxes, side by side (or stacked when there isn't room) */
.dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.dates label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #555;
}

.dates input {
  font-size: 13px;
}

/* The brightness slider: label, slider and percentage on one line */
.brightness {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
}

.brightness input {
  flex: 1; /* the slider takes up the space that's left */
  min-width: 0;
}

/* The [hidden] attribute must win over "display: flex" above */
.brightness[hidden] {
  display: none;
}

/* Hide the location status line until there is something to say */
#locate-status:empty {
  display: none;
}

#place-coords {
  font-weight: normal;
  font-size: 12px;
  color: #555;
}

/* <dl> is a "description list": a label (dt) followed by its value (dd).
   Used for the place details, the terrain results and the terrain words. */
.facts,
.words {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.facts dt,
.words dt {
  font-weight: bold;
  margin-top: 4px;
}

.facts dd,
.words dd {
  margin: 0 0 0 10px;
}

.words {
  margin-top: 0;
  font-size: 12px;
}

.words-title {
  margin-top: 10px;
}

/* --- The three result tabs: Changes, Terrain, Place details --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #ccc;
}

.tabs button {
  flex: 1;
  padding: 5px 4px;
  font: inherit;
  font-size: 13px;
  border: 1px solid #ccc;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #f1f1f1;
  cursor: pointer;
  margin-bottom: -1px; /* sits on the line, so the chosen tab joins its content */
}

.tabs button[aria-selected="true"] {
  background: white;
  font-weight: bold;
  border-bottom: 1px solid white;
}

[role="tabpanel"] {
  padding-top: 8px;
}

/* The parts of the Changes tab, separated by a thin line */
.result-part + .result-part {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #ddd;
}

/* The "Click to analyse" button while the mode is on */
#click-mode-button[aria-pressed="true"] {
  background: #1a5fb4;
  color: white;
  border-color: #1a5fb4;
}

#click-size {
  font-size: 13px;
}

.credits {
  margin-top: 8px;
  font-size: 11px;
  color: #666;
}

/* --- The change detection results --- */
.legend {
  list-style: none;
  margin: 6px 0;
  padding: 0;
}

.legend li {
  display: flex;
  align-items: center;
}

/* The change summary: colour and name on the left, then the size and the
   percentage in two columns on the right, lined up from row to row */
.change-legend li {
  display: grid;
  grid-template-columns: auto 1fr 4.6em 3.2em;
  align-items: center;
}

.change-legend b,
.change-legend .pct {
  text-align: right;
  white-space: nowrap;
}

.change-legend .pct {
  font-size: 12px;
  color: #555;
}

/* The little coloured squares, matching the colours in main.js (CHANGE_COLOURS) */
.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}

.swatch.gained { background: rgb(46, 204, 64); }
.swatch.lost { background: rgb(255, 65, 54); }
.swatch.built { background: rgb(0, 116, 217); }
.swatch.burned { background: rgb(166, 75, 0); }
.swatch.skipped { background: rgba(150, 150, 150, 0.6); }

/* The warning that some plant changes may be seasonal */
.season-note {
  margin-top: 8px;
  padding: 6px 8px;
  border-left: 3px solid #c17d00;
  background: #fff6e0;
  font-size: 13px;
}

.season-note .small {
  margin-top: 4px;
  color: #333;
}

details summary {
  cursor: pointer;
  margin-top: 4px;
}

details p {
  margin: 6px 0 0;
}

/* Keep each 10 m square sharp when zoomed in, instead of blurring them together */
.change-layer {
  image-rendering: pixelated;
}

/* --- Notes at the top middle of the map: the timelapse date and "Zoom out..." --- */
#map-notes {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%); /* centres the notes */
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none; /* clicks go through them to the map */
}

#frame-date,
#zoom-note {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  white-space: nowrap;
}

#frame-date {
  font-size: 16px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#frame-date[hidden],
#zoom-note[hidden] {
  display: none;
}

/* --- The charts: the time series (Changes tab) and the elevation profile (Terrain tab) --- */
#series-progress {
  width: 100%;
  margin-top: 4px;
}

#series-progress[hidden],
#series-player[hidden] {
  display: none;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 6px;
}

.chart .grid {
  stroke: #e3e3e3;
  stroke-width: 1;
}

.chart .grid.zero {
  stroke: #b5b5b5;
}

.chart .axis-label {
  font-size: 10px;
  fill: #666;
}

/* A white ring around each dot keeps overlapping dots apart */
#series-chart .dot {
  stroke: white;
  stroke-width: 2;
}

/* The line showing which image is on the map */
#series-chart .frame-marker {
  stroke: #333;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* The invisible hover/click strips */
#series-chart .hit {
  fill: transparent;
  cursor: pointer;
}

#series-chart .hit:hover {
  fill: rgba(0, 0, 0, 0.05);
}

.series-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

/* A short line in each score's colour, matching the chart */
.line-swatch {
  display: inline-block;
  width: 16px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

.line-swatch.ndvi { background: #2a78d6; }
.line-swatch.ndbi { background: #eb6834; }

/* The elevation profile's line and the ground under it */
.chart .profile-line {
  fill: none;
  stroke: #8a5a2b;
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart .profile-ground {
  fill: rgba(138, 90, 43, 0.15);
}

/* --- The before/after swipe slider, at the bottom middle of the screen --- */
#swipe-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%); /* centres the bar */
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  white-space: nowrap;
}

#swipe-slider {
  width: 220px;
  cursor: ew-resize;
}

/* The white line on the map where "before" meets "after" */
#swipe-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1px; /* centre the 3 px line on the cut */
  z-index: 900; /* above the map, below the panels */
  background: white;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
  pointer-events: none; /* clicks go through it to the map */
}

/* The [hidden] attribute must win over "display: flex" above */
#swipe-bar[hidden] {
  display: none;
}

/* On narrow screens (phones): the panel stops above the slider and scrolls inside */
@media (max-width: 760px) {
  #info-panel {
    max-height: calc(100% - 90px);
  }

  #swipe-bar {
    max-width: calc(100% - 20px);
    box-sizing: border-box;
  }

  #swipe-slider {
    width: 120px;
  }
}
