:root {
  --paper: #f4eee3;
  --card: #fbf8f2;
  --ink: #2a241f;
  --muted: #7d7064;
  --line: #e2d8c8;
  --accent: #b4432c;
  --own: #5d6d3a;
  --display: "Fraunces", Georgia, serif;
  --text: "Newsreader", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--text); font-size: 17px; color: var(--ink); background: var(--paper); }

input, textarea, button { font: inherit; color: inherit; }
input, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.card {
  background: rgb(251 248 242 / 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgb(60 40 20 / 0.15);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.2rem;
  line-height: 1.05;
  font-variation-settings: "opsz" 144;
}
h1 em { color: var(--accent); }

h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 1.3rem; }

.primary {
  padding: 0.6rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--card);
  font-family: var(--display);
  font-weight: 500;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }

/* Login page */

.login {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, var(--card), var(--paper) 70%);
}
.login form { display: flex; flex-direction: column; gap: 0.8rem; width: min(22rem, 90vw); padding: 2rem; }
#wrong { margin: 0; color: var(--accent); font-style: italic; }

/* Map */

#map { position: fixed; inset: 0; background: var(--paper); }
.leaflet-container { font: inherit; }
.leaflet-tile-pane { filter: sepia(0.3) saturate(0.75) brightness(1.03); }
.leaflet-bar a { background: var(--card); color: var(--ink); }
.leaflet-control-attribution { background: rgb(251 248 242 / 0.8) !important; }

/* Side panel */

#panel {
  position: fixed;
  z-index: 1000;
  top: 1.25rem;
  left: 1.25rem;
  width: 21rem;
  max-height: calc(100% - 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
}
.lede { margin: 0; color: var(--muted); line-height: 1.4; }

#count {
  margin: 0.25rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-family: var(--display);
  font-style: italic;
  color: var(--muted);
}

#places { overflow-y: auto; }
#places details { border-bottom: 1px dotted var(--line); }
#places summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0.2rem;
  list-style: none;
  cursor: pointer;
}
#places summary::-webkit-details-marker { display: none; }
#places summary::before { content: "▸"; display: inline-block; color: var(--accent); transition: transform 0.15s; }
#places details[open] summary::before { transform: rotate(90deg); }
#places summary strong { font-family: var(--display); font-weight: 500; font-size: 1.1rem; }
#places summary .country { flex: 1; color: var(--muted); font-style: italic; font-size: 0.9rem; }
#places summary .tally {
  align-self: center;
  min-width: 1.6rem;
  padding: 0.1rem 0.5rem;
  text-align: center;
  line-height: 1.4;
  border-radius: 999px;
  background: var(--accent);
  color: var(--card);
  font-size: 0.8rem;
}
#places ul { margin: 0 0 0.5rem; padding: 0 0 0 1.4rem; list-style: none; }
#places li { padding: 0.2rem 0; cursor: pointer; }
#places li:hover { color: var(--accent); }

/* Pins and clusters (Leaflet positions the outer element, so visuals live on the inner span) */

.pin span, .cluster span {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--display);
  color: var(--card);
  box-shadow: 0 3px 10px rgb(60 30 10 / 0.35);
}
.pin span {
  width: 100%;
  height: 100%;
  background: var(--accent);
  border: 2px solid var(--card);
  font-weight: 600;
  font-size: 0.8rem;
  transition: transform 0.15s;
}
.pin span:hover { transform: scale(1.15); }
.pin.own span { background: var(--own); }

.cluster { display: grid; place-items: center; border-radius: 50%; background: rgb(180 67 44 / 0.22); }
.cluster span { width: 32px; height: 32px; background: var(--ink); font-style: italic; }

/* Popups */

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--ink); }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 1rem 1.2rem; font-size: 1rem; line-height: 1.4; }
.leaflet-popup-content p { margin: 0; }

.popup { min-width: 11rem; }
.popup .place { margin-bottom: 0.5rem; color: var(--accent); font-style: italic; }
.popup .comment { margin-bottom: 0.75rem; white-space: pre-wrap; }
.popup .comment:empty { display: none; }

.cluster-popup ul { margin: 0.25rem 0 0.75rem; padding: 0; list-style: none; max-height: 15rem; overflow-y: auto; }
.cluster-popup li { padding: 0.25rem 0; border-bottom: 1px dotted var(--line); cursor: pointer; }
.cluster-popup li:hover { color: var(--accent); }
.cluster-popup li .place { display: block; margin: 0; color: var(--muted); font-size: 0.85rem; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}
.link:hover { color: var(--accent); }

.pin-form { display: flex; flex-direction: column; gap: 0.5rem; width: 15rem; }
.pin-form textarea { height: 5rem; resize: vertical; }

@media (max-width: 640px) {
  #panel { top: 0.75rem; left: 0.75rem; right: 0.75rem; width: auto; max-height: 45%; padding: 1rem; gap: 0.5rem; }
  h1 { font-size: 1.6rem; }
  .lede { display: none; }
}
