/*
 * DOPPLER — visual system per NOIR's STYLEGUIDE.md.
 *
 * Tokens, type stacks, easing, layering, atmosphere, and the application
 * surfaces (§13) are inherited unchanged. Declared choices:
 *
 *   - --signal is not used. §12 reserves it for "the next action is here", and
 *     nothing on this page is hidden behind a control. A story entering the top
 *     ten is news, not an instruction, so its ping is white.
 *   - The ping is the one motion that repeats, and only when the data changes:
 *     motion that reveals something, once, then holds still (§1.5).
 *   - Nothing here ticks. The sweep time is updated every 30 seconds as prose
 *     ("2 MIN AGO"), never as a running countdown (§11).
 *   - A second breakpoint at 60rem, as in MELTER: map and list cannot share a
 *     row on a narrow screen.
 */

:root {
  color-scheme: dark;

  --bg: #000000;
  --fg: #ffffff;
  --fg-dim: rgba(255, 255, 255, 0.58);
  --fg-faint: rgba(255, 255, 255, 0.14);
  --fg-body: rgba(255, 255, 255, 0.72);
  --fg-punct: rgba(255, 255, 255, 0.38);
  --fg-ghost: rgba(255, 255, 255, 0.035);

  --font-display: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --mx: 38%;
  --my: 42%;

  --rule: 1px solid var(--fg-faint);
  --pad: clamp(0.8rem, 1.6vw, 1.3rem);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* desktop: the list scrolls, the shell never does */
}

/* ------------------------------------------------------------ atmosphere -- */

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    58vmax 58vmax at var(--mx) var(--my),
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.018) 34%,
    transparent 68%
  );
  opacity: 0;
  animation: rise-in 2.4s var(--ease) 0.1s forwards;
}

.grain {
  position: fixed;
  inset: -150%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 700ms steps(1) infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(130% 100% at 45% 45%, transparent 55%, rgba(0, 0, 0, 0.62) 100%);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 3%); }
  40%  { transform: translate(4%, -5%); }
  60%  { transform: translate(-3%, -2%); }
  80%  { transform: translate(5%, 4%); }
  100% { transform: translate(0, 0); }
}

/* ---------------------------------------------------------------- header -- */

.bar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: calc(var(--pad) * 0.8) var(--pad);
  border-bottom: var(--rule);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.14em;
  line-height: 1;
  text-decoration: none;
}

.brand__name {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.9vw, 1.42rem);
  font-weight: 900;
  letter-spacing: 0.17em;
  margin-right: -0.17em;
  color: var(--fg);
}

.brand__by {
  font-family: var(--font-mono);
  font-size: clamp(0.56rem, 0.85vw, 0.68rem);
  letter-spacing: 0.19em;
  margin-right: -0.19em;
  color: var(--fg-dim);
}

.brand:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }

.sweep,
.since {
  margin: 0;
  font-size: clamp(0.56rem, 0.8vw, 0.66rem);
  letter-spacing: 0.18em;
  color: var(--fg-punct);
  white-space: nowrap;
}

.sweep { margin-left: auto; }
.sweep.is-stale, .sweep.is-lost { color: var(--fg); }
.since.has-new { color: var(--fg); }

.privacy {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0;
  padding: 0.4em 0.75em;
  border: var(--rule);
  font-size: clamp(0.56rem, 0.8vw, 0.66rem);
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  white-space: nowrap;
}

.privacy__label { margin-right: -0.2em; }

.privacy__dot {
  width: 5px;
  height: 5px;
  background: var(--fg);
  border-radius: 50%;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ deck -- */

.deck {
  position: relative;
  z-index: 4;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(22rem, 31rem);
}

/* ------------------------------------------------------------------- map -- */

.scope {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 2.4rem);
  border-right: var(--rule);
}

.map {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  overflow: visible;
  animation: fade-in 1.6s var(--ease) 0.1s both;
}

/* Coastlines are structure: the faint step of the ladder, as a true hairline. */
.map__land {
  fill: var(--fg-ghost);
  stroke: var(--fg-faint);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.map__graticule {
  fill: none;
  stroke: var(--fg-faint);
  stroke-width: 1px;
  stroke-dasharray: 1 6;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
}

.pin { cursor: pointer; }

.pin__halo {
  fill: none;
  stroke: var(--fg-faint);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.35s var(--ease), r 0.35s var(--ease);
}

.pin__dot {
  fill: var(--fg);
  transition: r 0.35s var(--ease);
}

.pin__label {
  fill: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  pointer-events: none;
  transition: fill 0.35s var(--ease);
}

.pin__place {
  fill: var(--fg);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.pin.is-active .pin__halo { stroke: var(--fg-dim); r: 11; }
.pin.is-active .pin__dot { r: 4.2; }
.pin.is-active .pin__label { fill: var(--fg); }
.pin.is-active .pin__place { opacity: 1; }

/* Everything but the active pin recedes while one is in focus. */
.map.has-active .pin:not(.is-active) { opacity: 0.35; }
.map .pin { transition: opacity 0.35s var(--ease); }

/*
 * DOPPLER SHIFT, arrival: one expanding ring when a story enters the top ten.
 * A single slow wave — 2.8s, the guide's breath — never a loop.
 */
.ping {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  animation: ping 2.8s var(--ease) 0.4s both;
}

@keyframes ping {
  from { transform: scale(0.2); opacity: 0.9; }
  to   { transform: scale(4.2); opacity: 0; }
}

/* A new entrant keeps a quiet mark until the next sweep, so the ping is
   never the only way to know. */
.pin.is-entered .pin__halo { stroke: var(--fg-dim); stroke-dasharray: 2 3; }

.scope__legend {
  display: flex;
  justify-content: center;
  gap: 1.6rem;
  margin: 0;
  font-size: clamp(0.52rem, 0.74vw, 0.6rem);
  letter-spacing: 0.18em;
  color: var(--fg-punct);
}

.scope__legend span { display: inline-flex; align-items: center; gap: 0.55em; }

.legend__dot, .legend__ring {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend__dot { background: var(--fg); }
.legend__ring { border: 1px dashed var(--fg-dim); width: 10px; height: 10px; }

/* ---------------------------------------------------------------- events -- */

.events {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.events__head {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.9rem var(--pad);
  border-bottom: var(--rule);
  flex: 0 0 auto;
}

.events__title {
  margin: 0;
  font-size: clamp(0.6rem, 0.85vw, 0.7rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--fg);
}

.events__meta {
  margin-left: auto;
  font-size: clamp(0.54rem, 0.76vw, 0.62rem);
  letter-spacing: 0.14em;
  color: var(--fg-punct);
}

.events__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-faint) transparent;
}

.events__empty {
  margin: 0;
  padding: var(--pad);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: var(--fg);
}

.event {
  position: relative;
  padding: 1.05rem var(--pad) 1.1rem;
  border-bottom: var(--rule);
  border-left: 2px solid transparent;
  transition: border-color 0.35s var(--ease), background-color 0.35s var(--ease);
  animation: rise-in 0.9s var(--ease) both;
}

.event:focus-within,
.event.is-active {
  border-left-color: var(--fg);
  background: rgba(255, 255, 255, 0.025);
}

.event__meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.6rem;
  font-size: clamp(0.55rem, 0.78vw, 0.63rem);
  letter-spacing: 0.18em;
}

.event__rank { color: var(--fg); font-weight: 500; }

.shift { color: var(--fg-punct); }
.shift--approaching { color: var(--fg); }
.shift--receding { color: var(--fg-dim); }

.event__new {
  margin-left: auto;
  padding: 0.18em 0.55em;
  border: 1px solid var(--fg-dim);
  color: var(--fg);
  letter-spacing: 0.22em;
}

.event__headline {
  margin: 0 0 0.45rem;
  font-size: clamp(0.76rem, 1vw, 0.86rem);
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.event__headline a {
  color: var(--fg);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.5s var(--ease);
}

.event__headline a:hover,
.event__headline a:focus-visible {
  background-size: 100% 1px;
  outline: none;
}

.event__summary {
  margin: 0 0 0.75rem;
  font-size: clamp(0.66rem, 0.86vw, 0.74rem);
  line-height: 1.8;
  color: var(--fg-body);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
  font-size: clamp(0.55rem, 0.78vw, 0.63rem);
  letter-spacing: 0.14em;
}

.event__facts dt { color: var(--fg-punct); }
.event__facts dd { margin: 0; color: var(--fg); text-transform: uppercase; }
.event__facts dd.is-unplaced { color: var(--fg-dim); }

.event__facts a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--fg-faint);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.event__facts a:hover,
.event__facts a:focus-visible {
  color: var(--fg);
  border-color: var(--fg-dim);
  outline: none;
}

/* ---------------------------------------------------------------- footer -- */

.foot {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  padding: 0.7rem var(--pad);
  border-top: var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  justify-content: space-between;
}

.foot p {
  margin: 0;
  font-size: clamp(0.52rem, 0.72vw, 0.6rem);
  letter-spacing: 0.12em;
  line-height: 1.8;
  color: var(--fg-punct);
}

.foot__outlets .is-down { color: var(--fg); text-decoration: line-through; }

.link {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--fg-faint);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.link:hover, .link:focus-visible { color: var(--fg); border-color: var(--fg-dim); outline: none; }

/* ------------------------------------------------------------- utilities -- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 0.6em 1em;
  background: var(--bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
}

.skip-link:focus { left: 0.5rem; top: 0.5rem; }

[hidden] { display: none !important; }

/* ------------------------------------------------------------ responsive -- */

@media (max-width: 60rem) {
  body { overflow: auto; height: auto; }
  .deck { grid-template-columns: 1fr; }
  .scope { border-right: 0; border-bottom: var(--rule); }
  .events__list { overflow: visible; }
  .bar { flex-wrap: wrap; }
  .sweep { margin-left: 0; order: 3; width: 100%; }
}

@media (max-width: 30rem) {
  .since { order: 4; width: 100%; }
  .scope__legend { gap: 1rem; }
}

/* -------------------------------------------------------- reduced motion -- */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .glow, .map, .event { animation-duration: 0.01ms; animation-delay: 0s; }
  /* The ping is the animation; the dashed halo is the state, and it stays. */
  .ping { display: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------- site nav -- */

/*
 * The same map of noirapps.io that closes every page of the site — apps, site,
 * legal, contact — so every page reaches every other. Groups wrap as units.
 * Links are root-relative because the app lives one directory down.
 * STYLEGUIDE §6, "Footer".
 */
.sitenav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem clamp(1.6rem, 3vw, 2.6rem);
}

.sitenav__group {
  display: flex;
  gap: clamp(0.9rem, 1.6vw, 1.3rem);
}

.sitenav a {
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 0.9vw, 0.72rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-decoration: none;
  text-underline-offset: 0.45em;
  transition: color 0.45s var(--ease);
}

.sitenav a:hover,
.sitenav a:focus-visible {
  color: var(--fg);
  text-decoration: underline;
  outline: none;
}

.sitenav a[aria-current="page"] { color: var(--fg); }

/* An address is data, not a label: barely tracked. */
.sitenav .sitenav__mail { letter-spacing: 0.06em; }

/* The footer is a wrapping row of fine print; the map takes a row of its own. */
.foot .sitenav {
  flex-basis: 100%;
  padding-top: 0.5rem;
}
