/* Montessori Atlas — styles
   A dark "data map" with a warm paper-coloured reading panel. */

:root {
  --map: #0c0e12;
  --glass: rgba(20, 23, 29, .82);
  --glass-line: rgba(255, 255, 255, .08);
  --ink-light: #ece8de;
  --ink-light-muted: #9a978f;
  --paper: #f6f3ea;
  --paper-2: #ece8dc;
  --paper-line: #e0dbcd;
  --ink: #23211d;
  --ink-muted: #6f6a60;
  --radius: 10px;
  --panel-w: 420px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--map);
  color: var(--ink-light);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#map { position: fixed; inset: 0; background: var(--map); }

button { font: inherit; color: inherit; }

kbd {
  font: 500 11px/1 var(--sans);
  padding: 3px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: .6;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* ---------- Search ---------- */

.search {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 3;
  width: min(330px, calc(100vw - 92px));
}
.search input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 38px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  background: var(--glass) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='7' cy='7' r='5' fill='none' stroke='%239a978f' stroke-width='1.5'/%3E%3Cpath d='m11 11 3.5 3.5' stroke='%239a978f' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 13px center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  font: inherit;
  font-size: 14.5px;
  color: var(--ink-light);
  outline: none;
  -webkit-appearance: none;
}
.search input::placeholder { color: var(--ink-light-muted); }
.search input:focus { border-color: rgba(255, 255, 255, .22); }
.search input::-webkit-search-cancel-button { display: none; }
.search-key { position: absolute; top: 12px; right: 12px; color: var(--ink-light-muted); pointer-events: none; }
.search input:focus ~ .search-key { display: none; }

.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.search-results li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.search-results li.active, .search-results li:hover { background: var(--paper-2); }
.search-results li.empty { color: var(--ink-muted); cursor: default; font-size: 14px; }
.search-results li.empty:hover { background: none; }
.sr-text { min-width: 0; }
.sr-name { display: block; font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { display: block; font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Legend ---------- */

.legend { position: fixed; left: 16px; bottom: 26px; z-index: 2; min-width: 214px; padding: 6px; }
.legend-head { display: flex; align-items: center; justify-content: space-between; }
.legend-toggle, .legend-all { border: 0; background: none; cursor: pointer; padding: 7px 10px; border-radius: 7px; }
.legend-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-light);
}
.legend-toggle svg { color: var(--ink-light-muted); transition: transform .2s; }
.legend.collapsed .legend-toggle svg { transform: rotate(-90deg); }
.legend-all { font-size: 12px; color: var(--ink-light-muted); text-decoration: underline; }
.legend-all:hover { color: var(--ink-light); }

.legend-list { list-style: none; margin: 2px 0 0; padding: 0; }
.legend.collapsed .legend-list { display: none; }
.lg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 5px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 13px;
  text-align: left;
  color: var(--ink-light);
  cursor: pointer;
}
.lg-item:hover { background: rgba(255, 255, 255, .06); }
.lg-item.off { color: var(--ink-light-muted); }
.lg-item.off .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); opacity: .6; }
.lg-count { margin-left: auto; padding-left: 14px; font-size: 11.5px; color: var(--ink-light-muted); font-variant-numeric: tabular-nums; }

/* ---------- Info button ---------- */

.info-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 42px;
  height: 42px;
  font: italic 600 18px/1 var(--serif);
  color: var(--ink-light);
  cursor: pointer;
  transition: right .3s ease, background .2s;
}
.info-btn:hover { background: rgba(40, 44, 52, .9); }

/* map controls, dark */
.maplibregl-ctrl-bottom-right { transition: right .3s ease; }
.maplibregl-ctrl-group {
  background: var(--glass) !important;
  border: 1px solid var(--glass-line);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--glass-line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(.85); }
.maplibregl-ctrl-group button:not(:disabled):hover { background-color: rgba(255, 255, 255, .06) !important; }
.maplibregl-ctrl-attrib { background: rgba(12, 14, 18, .7) !important; color: var(--ink-light-muted); }
.maplibregl-ctrl-attrib a { color: var(--ink-light-muted) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1); }

body.panel-open .info-btn { right: calc(var(--panel-w) + 16px); }
body.panel-open .maplibregl-ctrl-bottom-right { right: var(--panel-w); }

/* ---------- Side panel (paper) ---------- */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  width: var(--panel-w);
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  box-shadow: -10px 0 40px rgba(0, 0, 0, .35);
  transform: translateX(105%);
  transition: transform .32s ease;
  overscroll-behavior: contain;
}
body.panel-open .panel { transform: none; }

.panel-close {
  position: sticky;
  top: 14px;
  float: right;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 14px 14px 0 0;
  border: 0;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
}
.panel-close:hover { background: var(--paper-line); }

.panel-body { padding: 30px 30px 48px; }

.p-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.p-title { margin: 12px 0 6px; font: 600 28px/1.18 var(--serif); letter-spacing: -.01em; }
.p-place { margin: 0 0 20px; color: var(--ink-muted); font-size: 14px; }
.p-img { display: block; width: 100%; max-height: 240px; object-fit: cover; margin: 0 0 20px; border-radius: 8px; background: var(--paper-2); }
.p-desc { margin: 0 0 12px; font: 400 16.5px/1.6 var(--serif); }

.p-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 18px;
  margin: 20px 0;
  padding: 14px 0;
  border-top: 1px solid var(--paper-line);
  border-bottom: 1px solid var(--paper-line);
  font-size: 14px;
}
.p-details dt { color: var(--ink-muted); }
.p-details dd { margin: 0; }

.p-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--paper-line);
  border-radius: 7px;
  background: transparent;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--paper-2); }
.btn.primary { border-color: #24443a; background: #24443a; color: #f6f3ea; }
.btn.primary:hover { background: #1b352d; }

.p-links { list-style: none; margin: 0 0 20px; padding: 0; }
.p-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--paper-line);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
}
.p-links a:hover { text-decoration: underline; }
.p-links svg { flex: none; color: var(--ink-muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0; }
.tag {
  padding: 4px 10px;
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  background: none;
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
}
.tag:hover { background: var(--paper-2); color: var(--ink); }

.p-section h3 {
  margin: 30px 0 6px;
  font: 600 17px/1.3 var(--serif);
  color: var(--ink);
}

.conn { list-style: none; margin: 0; padding: 0; }
.conn button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 6px;
  border: 0;
  border-bottom: 1px solid var(--paper-line);
  background: none;
  text-align: left;
  cursor: pointer;
}
.conn button:hover { background: var(--paper-2); }
.conn-text { flex: 1; min-width: 0; }
.conn-name { display: block; font-size: 14px; font-weight: 550; }
.conn-meta { display: block; font-size: 12px; color: var(--ink-muted); }
.conn svg { flex: none; color: var(--ink-muted); }

.p-source { margin: 26px 0 0; font-size: 12.5px; color: var(--ink-muted); }
.p-share { margin-top: 26px; }

/* ---------- Tooltip ---------- */

.tip { pointer-events: none; }
.tip .maplibregl-popup-content {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
}
.tip .maplibregl-popup-tip { display: none; }
.tip-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tip-meta { display: block; margin-left: 17px; color: var(--ink-muted); font-size: 12px; }

/* ---------- About window ---------- */

.about {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 30px 32px;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
  font: 400 16px/1.6 var(--serif);
}
.about::backdrop { background: rgba(6, 7, 9, .55); }
.about h2 { margin: 0 0 10px; font-size: 28px; font-weight: 600; }
.about h3 { margin: 22px 0 6px; font-size: 18px; font-weight: 600; }
.about ul { margin: 8px 0 0; padding-left: 20px; }
.about li { margin-bottom: 4px; }
.about a { color: inherit; }
.about kbd { color: var(--ink); }
.about-note { margin-top: 22px; font: 400 13px/1.5 var(--sans); color: var(--ink-muted); }
.about form { margin-top: 18px; text-align: right; }
.about .btn { font-family: var(--sans); }

/* ---------- Messages (errors, ?check report) ---------- */

.message {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  width: min(580px, calc(100vw - 32px));
  max-height: 50vh;
  overflow-y: auto;
  padding: 16px 20px;
  transform: translateX(-50%);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
  font-size: 14px;
  line-height: 1.5;
}
.message h4 { margin: 0 0 6px; font: 600 17px var(--serif); }
.message ul { margin: 6px 0 0; padding-left: 18px; }
.message code { background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
.message .close { float: right; border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-muted); }

/* ---------- Phones ---------- */

@media (max-width: 700px) {
  :root { --panel-w: 100vw; }
  .panel {
    top: auto;
    left: 0;
    width: auto;
    height: 64vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(105%);
  }
  .panel-body { padding: 22px 20px 40px; }
  .p-title { font-size: 24px; }
  body.panel-open .info-btn { right: 16px; }
  body.panel-open .maplibregl-ctrl-bottom-right { right: 0; }
  body.panel-open .legend { display: none; }
  .legend { bottom: 24px; min-width: 0; }
  .search-key { display: none; }
}
