/* Oakland quake watch: a light graph-paper instrument, not a dashboard.
   Tokens ------------------------------------------------------------ */
:root {
  --paper: #ECEEF1;
  --surface: #F7F8FA;
  --ink: #16202B;
  --ink-2: #4B5765;
  --ink-3: #8A94A0;
  --rule: #D5DAE0;
  --rule-soft: #E3E7EC;
  --hour: #B3170E;
  --day: #E8562E;
  --week: #F29A5C;
  --older: #8A94A0;
  --body: #1F5FBF;
  --surf: #12A36C;
  --focus: #1D4ED8;
  --bar-h: 56px;
  --panel-w: 380px;
  --handle-h: 10px;
  --map-min-h: 140px;
  font-family: "Archivo", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
h1, h2, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, select, input { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Header bar ---------------------------------------------------------- */
.bar {
  min-height: var(--bar-h);
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 22px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  font-size: 17px;
  font-weight: 650;
  font-variation-settings: "wdth" 90;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.live {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-3);
  box-shadow: 0 0 0 0 rgba(179, 23, 14, 0.5);
}
.live.ok { background: var(--hour); animation: pulse 2.4s ease-out infinite; }
.live.err { background: var(--ink-3); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(179, 23, 14, 0.45); }
  70%  { box-shadow: 0 0 0 9px rgba(179, 23, 14, 0); }
  100% { box-shadow: 0 0 0 0 rgba(179, 23, 14, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .live.ok { animation: none; }
}

.controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.controls label { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 2px 18px 2px 2px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2316202B' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 2px center;
  max-width: 260px;
  text-overflow: ellipsis;
}
.custom-wrap { display: inline-flex; align-items: baseline; gap: 4px; color: var(--ink-3); font-size: 13px; }
.custom-wrap[hidden] { display: none; }
.custom-wrap input {
  width: 62px;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  padding: 2px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.comps { display: inline-flex; gap: 4px; }
.chip {
  width: 34px; height: 26px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.chip[hidden] { display: none; }

.refresh { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.updated { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.updated.err { color: var(--hour); }
.refresh button, .pill {
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
}
.refresh button:hover, .pill:hover { background: var(--ink); color: var(--surface); }
.refresh button.on { background: var(--ink); color: var(--surface); }
.refresh button:disabled { opacity: 0.5; cursor: default; }

/* Layout -------------------------------------------------------------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  grid-template-rows: 1fr;
}
.panel {
  grid-column: 1;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.right {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.seismo {
  flex: none;
  height: 420px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.handle {
  flex: none;
  height: var(--handle-h);
  background: var(--paper);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  cursor: ns-resize;
  position: relative;
  touch-action: none;
}
.handle::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 36px; height: 2px;
  transform: translate(-50%, -50%);
  background: var(--ink-3);
  border-radius: 1px;
}
/* A 26 px grab zone around the 10 px strip. */
.handle::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: -8px; bottom: -8px;
  cursor: ns-resize;
}
.handle:hover::after, .handle:focus-visible::after { background: var(--ink); }
.map { flex: 1; min-height: var(--map-min-h); background: var(--paper); }

/* Panel sections ----------------------------------------------------- */
.panel h2 { font-size: 14px; font-weight: 650; font-variation-settings: "wdth" 90; }
.status {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--rule);
}
.lede {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
  font-variation-settings: "wdth" 82;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.sub { margin-top: 8px; color: var(--ink-2); font-size: 14px; }
.home-row { margin-top: 12px; color: var(--ink-3); font-size: 13px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.link {
  background: none; border: 0; padding: 0;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: 13px;
}
.link.armed { color: var(--hour); }

.arrivals, .captures { padding: 16px 0 6px; border-bottom: 1px solid var(--rule); }
.arrivals h2, .captures h2 { padding: 0 20px; }
.hint { padding: 4px 20px 8px; color: var(--ink-3); font-size: 13px; }
.arrivals .empty, .captures .empty, .events .empty { padding: 8px 20px 14px; color: var(--ink-3); font-size: 14px; }
.arr, .cap {
  width: 100%;
  display: block;
  padding: 10px 20px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--rule-soft);
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
}
.arr:hover, .cap:hover { background: var(--paper); }
.cap.active { background: var(--paper); box-shadow: inset 3px 0 0 var(--ink); }
.arr-head { display: flex; gap: 8px; align-items: baseline; }
.arr-mag { font-weight: 700; font-variant-numeric: tabular-nums; }
.arr-place { flex: 1; }
.arr-meta { display: block; color: var(--ink-3); font-size: 13px; margin-top: 1px; }
.arr-phases { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ph { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
.ph::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--c); }
.ph.past { color: var(--ink-3); }
.ph.past::before { opacity: 0.45; }
.ph.now { color: var(--ink); font-weight: 700; }
.ph.now::before { width: 5px; }

.nearby { display: flex; flex-direction: column; flex: 1; }
.filters {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px 8px;
  font-size: 13px; color: var(--ink-2);
}
.filters h2 { margin-right: auto; }
.filters label { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.filters select { font-size: 13px; padding-right: 16px; }
.events { flex: 1; }
.events li { display: flex; align-items: stretch; border-top: 1px solid var(--rule-soft); }
.ev {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 22px 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px 9px 20px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
}
.ev:hover { background: var(--paper); }
.ev.selected { background: var(--paper); box-shadow: inset 3px 0 0 var(--ink); }
.ev.fresh { animation: fresh 2.4s ease-out 1; }
@keyframes fresh { from { background: #FBE3D8; } to { background: transparent; } }
.ev-dot {
  width: var(--s, 10px); height: var(--s, 10px);
  border-radius: 50%;
  background: var(--c);
  justify-self: center;
}
.ev-dot.hollow { background: transparent; border: 1.5px solid var(--older); }
.ev-mag { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.ev-place { display: block; font-size: 14px; }
.ev-meta { display: block; color: var(--ink-3); font-size: 13px; }
.ev-time { color: var(--ink-2); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ev-act {
  flex: none;
  align-self: center;
  margin: 0 12px 0 0;
  background: transparent;
  border: 1.5px solid var(--ink-3);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ev-act:hover { border-color: var(--ink); color: var(--ink); }
.ev-act.ready { border-color: var(--body); color: var(--body); }
.ev-act.busy { border-style: dashed; cursor: default; }
.catalog-line { padding: 10px 20px 16px; color: var(--ink-3); font-size: 13px; border-top: 1px solid var(--rule-soft); display: flex; gap: 10px; }
.catalog-line .err { color: var(--hour); }
.cap-head { display: flex; gap: 8px; align-items: baseline; }
.cap-meta { display: block; color: var(--ink-3); font-size: 13px; margin-top: 1px; }

/* Seismogram ---------------------------------------------------------- */
.seismo-head {
  display: flex; align-items: baseline; gap: 12px 16px; flex-wrap: wrap;
  padding: 10px 20px 4px;
}
.seismo-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.seismo-head h2 { font-size: 15px; font-weight: 650; font-variation-settings: "wdth" 90; }
.seismo-sub { color: var(--ink-3); font-size: 13px; }
.legend { display: flex; gap: 14px; color: var(--ink-2); font-size: 13px; margin-left: auto; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.sw.stroke { width: 3px; height: 13px; border-radius: 2px; }
.sw.hollow { background: transparent; border: 1.5px solid var(--older); }
.replay-bar {
  width: 100%;
  display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  padding: 8px 0 4px;
  border-top: 1px solid var(--rule-soft);
  font-size: 14px;
}
.replay-bar[hidden] { display: none; }
.replay-bar label { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.replay-title { font-weight: 650; }
.pill { padding: 4px 12px; font-size: 14px; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; }
#seismo { display: block; width: 100%; height: 100%; }
#seismo.scrub { cursor: pointer; }
#seismo:focus-visible { outline-offset: -2px; }
select:disabled { opacity: 0.45; cursor: default; }

/* Map details --------------------------------------------------------- */
.home-pin { width: 22px; height: 22px; }
.home-pin::before, .home-pin::after {
  content: ""; position: absolute; background: var(--ink);
}
.home-pin::before { left: 10px; top: 0; width: 2px; height: 22px; }
.home-pin::after  { top: 10px; left: 0; height: 2px; width: 22px; }
.home-pin span {
  position: absolute; left: 5px; top: 5px; width: 12px; height: 12px;
  border-radius: 50%; border: 2px solid var(--ink); background: var(--surface);
}
.sta-pin { width: 18px; height: 16px; cursor: pointer; }
.sta-pin span {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 16px solid var(--ink-3);
}
.sta-pin span::after {
  content: ""; position: absolute; left: -5px; top: 5px; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 9px solid var(--surface);
}
.sta-pin.active span { border-bottom-color: var(--body); }
.sta-pin.active span::after { border-bottom-color: var(--body); }
.sta-pin:hover span { border-bottom-color: var(--ink); }
.leaflet-container { font-family: inherit; font-size: 13px; }
.leaflet-popup-content-wrapper { border-radius: 6px; box-shadow: 0 2px 10px rgba(22, 32, 43, 0.18); }
.leaflet-popup-content { margin: 12px 30px 12px 14px; line-height: 1.35; }
.leaflet-popup-content p { margin: 0 0 4px; }
.leaflet-popup-content .pm { font-weight: 700; font-size: 15px; }
.leaflet-popup-content a { color: var(--ink-2); }
.leaflet-popup-content .link { font-size: 13px; }
.leaflet-container a.leaflet-popup-close-button { font-size: 20px; color: var(--ink-2); padding: 6px 6px 0 0; }
.leaflet-tooltip { font-family: inherit; font-size: 12px; border-radius: 4px; border-color: var(--rule); color: var(--ink); }
.leaflet-container.picking { cursor: crosshair; }
.leaflet-bar a { color: var(--ink); }
.leaflet-control-attribution { background: rgba(247, 248, 250, 0.8); color: var(--ink-3); }

/* Small screens ------------------------------------------------------- */
@media (max-width: 900px) {
  html, body { height: auto; min-height: 100%; }
  .bar { gap: 12px 24px; padding: 12px 16px; }
  .refresh { margin-left: 0; width: 100%; }
  .layout {
    flex: none;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .right { grid-column: 1; grid-row: 1; }
  .map { flex: none; height: 44vh; }
  .panel { grid-column: 1; grid-row: 2; border-right: 0; border-top: 1px solid var(--rule); overflow: visible; }
  .legend { margin-left: 0; }
}
