/* petaku — gaya tampilan sendiri, tanpa mengambil desain pihak lain */

:root {
  --bg:        #0b1220;
  --bg-soft:   #101a2c;
  --bg-raise:  #16233a;
  --line:      #24344f;
  --text:      #e6edf7;
  --muted:     #93a4bd;
  --accent:    #f59e0b;
  --danger:    #ef4444;
  --ok:        #22c55e;
  --panel-w:   340px;
  --topbar-h:  58px;
  --radius:    12px;
  --shadow:    0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  position: relative;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: linear-gradient(180deg, #0e1728, #0b1220);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark { color: var(--accent); display: flex; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: .3px;
}

.brand-text small {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  transition: background .3s;
}

.dot.is-ok   { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.dot.is-warn { background: var(--accent); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.dot.is-err  { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }

.panel-toggle {
  display: none;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-raise);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.panel-toggle:hover { border-color: #36506f; }

/* ---------- layout ---------- */
.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: #0a1626;
}

/* ---------- panel ---------- */
.panel {
  position: absolute;
  z-index: 1100;
  top: calc(var(--topbar-h) + 12px);
  left: 12px;
  width: var(--panel-w);
  max-height: calc(100% - var(--topbar-h) - 24px);
  display: flex;
  flex-direction: column;
  background: rgba(13, 21, 35, .94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .22s ease, opacity .22s ease;
}

.panel[hidden] { display: flex; }
.panel.is-closed {
  transform: translateX(calc(-1 * (var(--panel-w) + 20px)));
  opacity: 0;
  pointer-events: none;
}

.panel-section { padding: 12px 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  background: var(--bg-soft);
  border-radius: 9px;
}

.stat-num {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.filters {
  display: flex;
  gap: 7px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chip {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.chip:hover { color: var(--text); border-color: #36506f; }

.chip.is-active {
  background: rgba(245, 158, 11, .14);
  border-color: rgba(245, 158, 11, .5);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- daftar gempa ---------- */
.quake-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
  scrollbar-color: #2b3d59 transparent;
}

.quake-list::-webkit-scrollbar { width: 8px; }
.quake-list::-webkit-scrollbar-thumb {
  background: #2b3d59;
  border-radius: 4px;
}

.quake-item {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}

.quake-item:hover {
  background: var(--bg-raise);
  border-color: var(--line);
}

.quake-item.is-selected {
  background: rgba(245, 158, 11, .1);
  border-color: rgba(245, 158, 11, .4);
}

.mag-badge {
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: #07101c;
}

.quake-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quake-place {
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.quake-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.src-tag {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .4px;
  border: 1px solid currentColor;
  opacity: .85;
  flex: 0 0 auto;
}

.src-tag.bmkg { color: #7dd3fc; }
.src-tag.usgs { color: #c4b5fd; }

.quake-empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.panel-foot {
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- legenda ---------- */
.legend {
  position: absolute;
  z-index: 900;
  right: 12px;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(13, 21, 35, .9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 11.5px;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text);
  margin-bottom: 2px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ---------- pemberitahuan ---------- */
.notice {
  position: absolute;
  z-index: 1000;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  background: rgba(127, 29, 29, .95);
  border: 1px solid #b91c1c;
  border-radius: 10px;
  font-size: 13px;
  color: #fee2e2;
  box-shadow: var(--shadow);
}

/* ---------- footer ---------- */
.foot {
  flex: 0 0 auto;
  position: relative;
  z-index: 1200;
  padding: 7px 16px;
  background: #0e1728;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.foot p { margin: 1px 0; }
.foot-warn { color: #8a9ab3; font-size: 10.5px; }

/* ---------- popup Leaflet ---------- */
.leaflet-popup-content-wrapper {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.5; min-width: 210px; }
.leaflet-popup-tip { background: var(--bg-soft); border: 1px solid var(--line); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.pop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.pop-mag {
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  color: #07101c;
  font-variant-numeric: tabular-nums;
}

.pop-place { font-weight: 600; }

.pop-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  font-size: 12.5px;
}

.pop-rows dt { color: var(--muted); }
.pop-rows dd { margin: 0; }

.pop-warn {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: #fca5a5;
}

.pop-note { margin-top: 6px; font-size: 10.5px; color: var(--muted); }

/* ---------- animasi gempa terkuat ---------- */
@keyframes pulse-ring {
  0%   { stroke-opacity: .85; stroke-width: 2; }
  70%  { stroke-opacity: 0;   stroke-width: 10; }
  100% { stroke-opacity: 0;   stroke-width: 10; }
}

.pulse-ring { animation: pulse-ring 2.2s ease-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .pulse-ring { animation: none; }
  .panel { transition: none; }
}

/* ---------- layar kecil ---------- */
@media (max-width: 820px) {
  :root { --panel-w: auto; }

  .panel-toggle { display: block; }
  .topbar-status { font-size: 11.5px; }
  .brand-text small { display: none; }

  .panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 58vh;
    border-radius: 14px;
  }

  .panel.is-closed {
    transform: translateY(calc(100% + 20px));
  }

  .legend {
    right: 8px;
    bottom: auto;
    top: 10px;
    flex-direction: row;
    flex-wrap: wrap;
    max-width: calc(100% - 16px);
    font-size: 10.5px;
    gap: 4px 9px;
  }

  .legend-title { width: 100%; margin-bottom: 0; }

  .notice { bottom: auto; top: 62px; }

  .foot { display: none; }
}