/* 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); }

.captures { padding: 16px 0 6px; border-bottom: 1px solid var(--rule); }
.captures h2 { padding: 0 20px; }
.hint { padding: 4px 20px 8px; color: var(--ink-3); font-size: 13px; }
.hint.flush { padding: 0; }
.muted { color: var(--ink-3); }
.captures .empty, .events .empty { padding: 8px 20px 14px; color: var(--ink-3); font-size: 14px; }
.cap-meta { display: block; color: var(--ink-3); font-size: 13px; margin-top: 1px; }

/* The one event list ---------------------------------------------------- */
.nearby { display: flex; flex-direction: column; flex: 1; }
.list-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px 0; }
.list-head h2 { margin-right: auto; }
.shows { display: inline-flex; gap: 4px; }
.shows .chip { height: 24px; font-size: 12px; }
/* Home place switcher (regions with several named homes); empty otherwise. */
.places { display: inline-flex; gap: 4px; }
.places:empty { display: none; }
.places .chip { height: 24px; font-size: 12px; }
.filters {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px 2px;
  font-size: 13px; color: var(--ink-2);
}
.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 { border-top: 1px solid var(--rule-soft); }
.ev {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 34px 1fr;
  align-items: start;
  gap: 0 10px;
  padding: 10px 16px 10px 20px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
}
.ev:hover, .q.open .ev { background: var(--paper); }
.q.open { box-shadow: inset 3px 0 0 var(--ink); background: var(--paper); }
.ev.pinned .ev-home { color: var(--ink); font-weight: 600; }
.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;
  margin-top: 4px;
}
.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-body { display: block; min-width: 0; }
.ev-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ev-place { font-size: 14px; }
.ev-tag { flex: none; font-size: 12px; font-weight: 600; color: var(--body); white-space: nowrap; }
.ev-tag.sharp { color: var(--day); }
.ev-tag + .ev-tag { margin-left: 8px; }
.ev-meta { display: block; color: var(--ink-3); font-size: 13px; }
.ev-time { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ev-home { display: block; margin-top: 3px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.ev-phases { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ph-lead { color: var(--ink-3); }
.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; }
.ev-more { padding: 0 16px 12px 86px; font-size: 13px; color: var(--ink-2); }
.ev-more p { margin: 0 0 8px; }
.ev-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.act {
  display: inline-block;
  background: var(--surface);
  border: 1.5px solid var(--ink-3);
  color: var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.act:hover { border-color: var(--ink); }
.act.ready { border-color: var(--body); color: var(--body); }
.act.busy, .act:disabled { border-style: dashed; color: var(--ink-3); 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); }

/* Pages without a side panel ------------------------------------------- */
.solo { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.map-page .map { flex: 1; min-height: 0; }
.map-card {
  position: absolute; z-index: 500; top: 12px; right: 12px;
  max-width: 300px;
  padding: 10px 14px 12px;
  background: rgba(247, 248, 250, 0.94);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 13px;
}
.map-card .home-row { margin-top: 0; color: var(--ink-2); }
.map-card .legend { margin: 8px 0 6px; flex-wrap: wrap; gap: 4px 12px; }
.sw.tri { width: 0; height: 0; border-radius: 0; background: transparent; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--ink-3); }
.replay-pick { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; max-width: 100%; min-width: 0; }
.replay-pick select { flex: 1 1 auto; min-width: 0; font-size: 13px; max-width: min(320px, 100%); }

/* 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); }

/* Page links ---------------------------------------------------------- */
.pages { display: flex; gap: 16px; font-size: 14px; }
.pages a { color: var(--ink-2); text-decoration: none; padding: 2px 0; border-bottom: 1.5px solid transparent; white-space: nowrap; }
.pages a:hover { color: var(--ink); }
.pages a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

/* Shaking at home ----------------------------------------------------- */
.chip.wide { width: auto; padding: 0 10px; font-weight: 600; font-size: 13px; }
.home-page { --panel-w: 400px; }
.seismo.est { flex: 1; height: auto; min-height: 280px; }
.about { flex: none; background: var(--surface); border-top: 1px solid var(--rule); }
.about summary { padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: 650; font-variation-settings: "wdth" 90; }
.about-body { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; max-height: 42vh; overflow: auto; border-top: 1px solid var(--rule-soft); }
.about-body .captures { border-bottom: 0; border-right: 1px solid var(--rule-soft); }
.about-body .method p { max-width: 75ch; }
.home-row a.link { font-size: 13px; }
.method { padding: 16px 20px 20px; color: var(--ink-2); font-size: 13px; }
.method h2 { margin-bottom: 6px; color: var(--ink); }
.method p + p { margin-top: 8px; }
.sta-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 20px; border-top: 1px solid var(--rule-soft); line-height: 1.3; }
.sta-row .sw { margin-top: 3px; flex: none; }
.sta-name { display: block; font-size: 14px; }
.sw.thick { width: 4px; }
.sw.dash { background: repeating-linear-gradient(to bottom, var(--c) 0 4px, transparent 4px 7px); }
.tip {
  position: absolute;
  pointer-events: none;
  min-width: 190px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(22, 32, 43, 0.14);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tip[hidden] { display: none; }
.tip p { margin: 0; }
.tip-time { font-weight: 650; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.tip-row.strong { color: var(--ink); font-weight: 600; }
.tip-name { flex: 1; }
.tip-foot { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--rule-soft); color: var(--ink-2); }
.table-wrap { flex: 1; min-height: 0; overflow: auto; padding: 4px 20px 20px; }
.table-wrap[hidden] { display: none; }
.table-wrap table { border-collapse: collapse; width: 100%; max-width: 720px; font-size: 14px; font-variant-numeric: tabular-nums; }
.table-wrap caption { text-align: left; color: var(--ink-3); font-size: 13px; padding: 6px 0; }
.table-wrap th, .table-wrap td { text-align: right; padding: 6px 10px; border-top: 1px solid var(--rule-soft); font-weight: 400; }
.table-wrap thead th { color: var(--ink-2); font-weight: 600; border-top: 0; border-bottom: 1px solid var(--rule); }
.table-wrap th:first-child { text-align: left; }
#est { display: block; width: 100%; height: 100%; cursor: crosshair; }
#est:focus-visible { outline-offset: -2px; }

/* 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; flex-wrap: wrap; }
  .seismo.est { flex: none; height: 70vh; }
  .about-body { grid-template-columns: 1fr; max-height: none; }
  .about-body .captures { border-right: 0; border-bottom: 1px solid var(--rule-soft); }
  .map-page .map { flex: none; height: 78vh; }
  .map-card { position: static; max-width: none; border-width: 1px 0 0; border-radius: 0; }
  .ev-more { padding-left: 20px; }
}
