/* dark/light mode variables */
:root {
  --bg-color: #fff;
  --text-color: #222;
  --link-color: #0066cc;
  --border-color: #ddd;
  --star-color: #444;
  --card-bg: #fff;
  --button-bg: #f5f5f5;
  --button-hover-bg: #eaeaea;
  --shadow-color: rgba(0, 0, 0, 0.2);
}

body.dark-mode {
  --bg-color: #1c1c1e;
  --text-color: #e6e6e6;
  --link-color: #66aaff;
  --border-color: #333;
  --star-color: #ccc;
  --card-bg: #2a2a2d;
  --button-bg: #333;
  --button-hover-bg: #444;
  --shadow-color: rgba(0, 0, 0, 0.6);
  .leaflet-layer,
  .leaflet-control-zoom-in,
  .leaflet-control-zoom-out,
  .leaflet-control-attribution {
    filter: brightness(0.65) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
  }
}

/* Optional: auto dark mode based on system preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1c1c1e;
    --text-color: #e6e6e6;
    --link-color: #66aaff;
    --border-color: #333;
    --star-color: #ccc;
    --card-bg: #2a2a2d;
    --button-bg: #333;
    --button-hover-bg: #444;
    --shadow-color: rgba(0, 0, 0, 0.6);
  }
  .leaflet-layer,
  .leaflet-control-zoom-in,
  .leaflet-control-zoom-out {
    filter: brightness(0.65) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
  }
  .leaflet-control-attribution {
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: #e6e6e6;
  }
}

/* Reset & layout basics */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link-color);
}

/* Header area */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-color);
}

.top-bar a {
  padding: 0 10px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

h1 a {
  text-decoration: none;
  color: var(--text-color);
}

/* responsive header bar for small screens */
@media (max-width: 600px) {
  .top-bar {
    flex-direction: column;
  }
  nav {
    margin-top: 5px;
  }
}

/* responsive main body */
main {
  max-width: 700px;
  width: 90%;
  margin: 1em auto;
  padding: 0 1em;
}

/* header bar with refresh button and fuel selector */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  background: var(--button-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
button:hover {
  background: var(--button-hover-bg);
}

input[type="radio"] {
  margin-right: 0;
}

.fuel-selector {
  margin: 10px;
  justify-content: center;
  gap: 20px;
}

.fuel-selector label {
  font-size: 16px;
}

/* cards for favourites page */
.fav-station {
  position: relative;
  display: flex;
  border-radius: 10px;
  padding: 1em;
  box-shadow: 0px 0px 10px var(--shadow-color);
  margin: 1em 0;
}

.fav-station p {
  margin: 0.5em 0;
}

.fav-station img {
  display: block;
  height: 5em;
  width: 5em;
  padding-right: 1em;
}

.remove-fav {
  position: absolute;
  top: 0.4em;
  right: 0.6em;
  border: none;
  background: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
}

.remove-fav:hover {
  color: red;
}

/* map page */
#map {
  flex-grow: 1;
}

/* Custom marker for petrol stations */
/* override leaflet popup colours */
.leaflet-popup-content-wrapper {
  background: var(--card-bg);
}

.leaflet-popup-tip {
  background: var(--card-bg);
}

/* styling for inner-popup content */
.station-icon {
  display: flex;
  background: var(--card-bg) !important;
  color: var(--text-color);
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  background: white;
  border-radius: 6px;
  pointer-events: auto; /* allows popup click */
  position: relative;
}

.station-icon img {
  width: 32px;
  height: 32px;
  margin-top: 4px;
  margin-bottom: 5px;
  object-fit: contain;
  display: block;
}

.station-icon span {
  white-space: nowrap;
}

.station-icon::after {
  content: '';
  position: absolute;
  bottom: -8px;               /* Position the triangle below the box */
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--card-bg);
}

.station-icon {
  filter: drop-shadow(0 3px 5px var(--shadow-color));
}

/* popup for petrol stations */
.station-popup {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 200px;
  background: var(--card-bg);
  color: var(--text-color);
}

.station-popup img {
  width: 32px;
  height: 32px;
  margin-top: 6px;
}

.station-popup button {
  display: block;
  margin-top: 4px;
  font-size: 0.85em;
}

.nerd-mode {
  margin-top: 6px;
  font-size: 0.85em;
  display: none;
}

.brand-inline {
  display: inline-flex;
  align-items: end;
}

button.fav-btn {
  background: none;
  border: none;
  padding: 0;
  margin-left: 4px;
  line-height: 1;
  font-size: 1.5em;
  color: var(--star-color);
}

button.fav-btn::before {
  content: '☆';
}

button.fav-btn:hover::before {
  background: none;
  color: #aaa;
  content: '★';
}

button.fav-btn.favourited::before {
  color: gold;
  content: '★';
}
