/* ============================================================
   SENTINEL — Pulse (the ambient divergence surface)
   Loads after style.css and dashboard.css. Uses the four
   --pulse-* divergence tokens added to style.css. The sentinel
   state is the only thing on the page that pulses.
   ============================================================ */

/* ===================== STICKY HEADER (88px) ===================== */
.pu-head {
  position: sticky; top: 0; z-index: 50;
  height: 88px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.pu-head__left { display: flex; align-items: center; gap: 14px; }
.pu-head__right { display: flex; align-items: center; gap: 12px; justify-self: end; }
.pu-tabs { display: flex; gap: 6px; justify-self: center; }
.pu-tab {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 10px 18px 12px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.pu-tab:hover { color: var(--text); }
.pu-tab.is-on { color: var(--text); border-bottom-color: var(--accent); }
.pu-select {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 7px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  max-width: 170px;
}

/* ===================== MORNING BRIEF BAND ===================== */
.pu-brief {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px var(--gutter) 18px;
}
.mb-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--text);
  max-width: 80ch;
  margin: 0 0 14px;
}
.mb-headline--gate { color: var(--text-muted); font-size: 15px; }
.mb-headline--gate a { color: var(--accent); font-style: normal; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.mb-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mb-card {
  display: flex; flex-direction: column; gap: 7px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.mb-card:hover { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.mb-card__top { display: flex; align-items: center; gap: 9px; }
.mb-card__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mb-card__name {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.mb-card__state {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}
.mb-card__line { font-size: 12px; line-height: 1.5; color: var(--text-muted); }

/* ===================== GEO VIEW ===================== */
.pu-stage {
  position: relative;
  height: calc(100vh - 88px - 132px);
  min-height: 480px;
  border-top: 1px solid var(--border);
}
.pu-map { position: absolute; inset: 0; }
.pu-stage .maplibregl-ctrl-attrib {
  font-family: var(--font-mono); font-size: 8px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--text-faint);
}
.pu-stage .maplibregl-ctrl-attrib a { color: var(--text-faint); }

/* hover panel */
.pu-hover {
  position: absolute; z-index: 7;
  width: 264px;
  pointer-events: none;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 13px 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.pu-hover__name {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--text);
  margin: 0 0 7px;
}
.pu-hover__pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 4px 9px;
  border-radius: 3px;
  margin-bottom: 9px;
}
.pu-hover__bars { display: flex; flex-direction: column; gap: 5px; margin-bottom: 9px; }
.pu-bar { display: grid; grid-template-columns: 118px 1fr; gap: 8px; align-items: center; }
.pu-bar__label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pu-bar__track { height: 5px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.pu-bar__fill { height: 100%; border-radius: 2px; }
.pu-hover__line { font-size: 11px; line-height: 1.45; color: var(--text-muted); margin: 0 0 8px; }
.pu-hover__watch {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* state pill colors (mono label always parallel to color) */
.pu-state--red { background: color-mix(in srgb, var(--pulse-red) 16%, transparent); color: var(--pulse-red); border: 1px solid var(--pulse-red); }
.pu-state--white { background: color-mix(in srgb, var(--pulse-white) 12%, transparent); color: var(--pulse-white); border: 1px solid var(--pulse-white); }
.pu-state--sentinel { background: color-mix(in srgb, var(--pulse-sentinel) 14%, transparent); color: var(--pulse-sentinel); border: 1px solid var(--pulse-sentinel); }
.pu-state--quiet { background: transparent; color: var(--text-muted); border: 1px solid var(--border-strong); }

/* live ticker — bottom-left */
.pu-ticker {
  position: absolute; bottom: 16px; left: 16px; z-index: 6;
  width: 320px; min-height: 96px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column; gap: 8px;
}
.pu-ticker__live {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pu-ticker__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulseDot 2.4s ease-in-out infinite; }
.pu-ticker__counts {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
}
.pu-ticker__counts b { font-weight: 500; transition: color 0.4s; }
.pu-ticker__counts b.is-flash { color: var(--accent); }

/* control panel — bottom-right */
.pu-controls {
  position: absolute; bottom: 16px; right: 16px; z-index: 6;
  width: 230px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.pu-controls__head {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pu-controls__body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.pu-controls.is-collapsed .pu-controls__body { display: none; }
.pu-ctl-group { display: flex; flex-direction: column; gap: 6px; }
.pu-ctl-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pu-ctl-row { display: flex; flex-wrap: wrap; gap: 5px; }
.pu-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: uppercase;
}
.pu-chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pu-reset { background: none; border: 0; cursor: pointer; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); text-align: left; padding: 0; }

/* legend strip under the map */
.pu-legend {
  max-width: 1440px; margin: 0 auto;
  padding: 12px var(--gutter) 40px;
  display: flex; flex-wrap: wrap; gap: 16px;
}
.pl-key {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pl-key__swatch { width: 10px; height: 10px; border-radius: 2px; }
.pl-key__swatch--pulse { animation: puSwatch 2.4s ease-in-out infinite; }
@keyframes puSwatch { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* a11y ring: visually hidden cell buttons, north→south */
.pu-a11y { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ===================== SECTORS VIEW ===================== */
.pu-sectors {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px var(--gutter) 56px;
}
.cr-wrap { margin: 4px 0 26px; }
.cr-band {
  display: flex;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.cr-block {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px;
  padding: 0 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  min-width: 0;
}
.cr-block:last-child { border-right: 0; }
.cr-block__label { font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.12em; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-block__val { font-family: var(--font-mono); font-size: 10px; color: var(--accent); }
.cr-flows { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 8px; }
.cr-flow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cr-flow__arrow { display: inline-flex; gap: 2px; }
.cr-flow__arrow i {
  width: 5px; height: 5px;
  border-top: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  transform: rotate(45deg);
  animation: crFlow 1.4s linear infinite;
}
.cr-flow__arrow i:nth-child(2) { animation-delay: 0.2s; }
.cr-flow__arrow i:nth-child(3) { animation-delay: 0.4s; }
@keyframes crFlow { 0% { opacity: 0.15; } 50% { opacity: 1; } 100% { opacity: 0.15; } }

.hc-svg { width: 100%; height: auto; display: block; }
.hc-cluster__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  fill: var(--accent);
}
.hex { cursor: pointer; }
.hex polygon { stroke-width: 1; transition: fill-opacity 0.2s; }
.hex--red polygon { fill: var(--pulse-red); fill-opacity: 0.3; stroke: var(--pulse-red); }
.hex--white polygon { fill: var(--pulse-white); fill-opacity: 0.22; stroke: var(--pulse-white); }
.hex--sentinel polygon { fill: var(--pulse-sentinel); fill-opacity: 0.3; stroke: var(--pulse-sentinel); animation: puHex 2.4s ease-in-out infinite; }
.hex--quiet polygon { fill: var(--pulse-quiet); fill-opacity: 0.4; stroke: var(--pulse-quiet); }
@keyframes puHex { 0%, 100% { fill-opacity: 0.42; } 50% { fill-opacity: 0.18; } }
.hex:hover polygon, .hex:focus-visible polygon { fill-opacity: 0.55; }
.hex:focus-visible { outline: none; }
.hex:focus-visible polygon { stroke-width: 2.5; }
.hex__name { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; fill: var(--text); }
.hex__state { font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.12em; fill: var(--text-faint); }
.hex__bar { fill: var(--text-muted); opacity: 0.8; }
.pu-sector-line {
  margin: 26px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  max-width: 90ch;
}
.pu-sector-line b { color: var(--text); font-weight: 500; }

/* ===================== WATCHES VIEW ===================== */
.pu-watches { max-width: 880px; margin: 0 auto; padding: 16px var(--gutter) 64px; }
.pu-watch-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.pu-watch-row .dot { width: 9px; height: 9px; border-radius: 50%; }
.pu-watch-row .meta { color: var(--text-faint); font-size: 10px; }
.pu-watch-row button {
  background: none; border: 1px solid var(--border-strong); border-radius: 999px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); padding: 5px 11px; cursor: pointer;
}
.pu-watch-row button:hover { color: var(--alert); border-color: var(--alert); }

/* ===================== GATE / OFFLINE ===================== */
.pu-gate {
  max-width: 620px;
  margin: 64px auto;
  padding: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.pu-gate h2 { font-family: var(--font-display); font-weight: 400; font-size: 28px; margin: 0; color: var(--text); }
.pu-gate p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-muted); max-width: 46ch; }
.pu-offline {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--alert);
}

/* ===================== PULSE DRAWER ===================== */
#pulseDrawer .drawer__body { padding: 0; }
.pd-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--border);
}
.pd-head__kind { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em; color: var(--text-faint); margin-bottom: 6px; }
.pd-head__name { font-family: var(--font-display); font-weight: 400; font-size: 28px; letter-spacing: -0.01em; margin: 0 0 4px; color: var(--text); }
.pd-head__ts { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }
.pd-state {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  padding: 5px 10px; border-radius: 3px; white-space: nowrap; flex-shrink: 0;
}
.pd-state--red { color: var(--pulse-red); border: 1px solid var(--pulse-red); background: color-mix(in srgb, var(--pulse-red) 12%, transparent); }
.pd-state--white { color: var(--pulse-white); border: 1px solid var(--pulse-white); background: color-mix(in srgb, var(--pulse-white) 10%, transparent); }
.pd-state--sentinel { color: var(--pulse-sentinel); border: 1px solid var(--pulse-sentinel); background: color-mix(in srgb, var(--pulse-sentinel) 12%, transparent); }
.pd-state--quiet { color: var(--text-muted); border: 1px solid var(--border-strong); }
.pd-section { padding: 18px 26px; border-bottom: 1px solid var(--border); }
.pd-section--last { border-bottom: 0; }
.pd-eyebrow { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.pd-chart { width: 100%; height: 200px; }
.pd-chart__label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; fill: var(--text-faint); text-transform: uppercase; }
.pd-caption { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--text-faint); line-height: 1.6; margin: 8px 0 0; }
.pd-para { font-size: 13px; line-height: 1.65; color: var(--text-muted); margin: 0 0 12px; }
.pd-para:last-child { margin-bottom: 0; }
.pd-receipt {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--border);
  font-family: var(--font-display); font-size: 15px; color: var(--text);
}
.pd-receipt:last-of-type { border-bottom: 0; }
.pd-receipt__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.pd-receipt__dot--red { background: var(--alert); }
.pd-receipt__dot--heads { background: var(--accent); }
.pd-receipt__go { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }
.pd-watch { display: flex; flex-direction: column; gap: 10px; }
.pd-watch__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--text-muted); }
.pd-watch__label b { color: var(--accent); }
.pd-watch input[type='range'] { accent-color: var(--accent); }
.pd-snapout { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 880px) {
  .pu-head { height: 56px; grid-template-columns: auto 1fr auto; padding: 0 12px; }
  .pu-head .brand__word { display: none; }
  .pu-tab { padding: 8px 10px 10px; font-size: 9px; }
  .pu-select--tz { display: none; }
  .mb-cards { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
  .mb-card { flex: 0 0 78vw; }
  .pu-stage { height: calc(100vh - 56px - 120px); min-height: 420px; }
  .pu-ticker { width: auto; right: 16px; bottom: auto; top: 12px; min-height: 0; }
  .pu-controls { width: auto; left: 16px; right: 16px; }
  .pu-hover { left: 12px !important; right: 12px; bottom: 12px; top: auto !important; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .pl-key__swatch--pulse, .hex--sentinel polygon, .cr-flow__arrow i, .pu-ticker__dot { animation: none !important; }
  .pu-ticker__counts b { transition: none; }
}
