/*
 * The animated Stream Deck banner (ADR-011; .maestro/playbooks/Working/bn-common.md §7).
 *
 * A standalone page shown in a 320 px iframe on the WordPress blog, so it carries its own small
 * palette instead of site.css and Bootstrap. The colours repeat the dashboard's --sd-* tokens
 * where they mean the same thing: the precipitation lines are --sd-color-level (#0072B2) and
 * --sd-color-temperature (#D55E00), the well statuses are the --sd-band-*-edge colours (set
 * from banner.js as SVG fill attributes), and text is --sd-color-ink / --sd-color-text-muted.
 * The basemap palette is muted and light so the data layers read over it.
 */

:root {
  --sdb-ink: #1B1B1B;
  --sdb-muted: #4A4A4A;
  --sdb-link: #005A8C;
  --sdb-land: #EDF0EA;
  --sdb-backing: rgba(250, 251, 249, 0.86);
  --sdb-current: #0072B2;
  --sdb-previous: #D55E00;
  --sdb-ticker-w: clamp(170px, 26%, 270px);
  --sdb-foot-h: 30px;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sdb-land);
}

.sdb {
  position: relative;
  display: block;
  width: 100%;
  height: 320px;
  overflow: hidden;
  background: var(--sdb-land);
  color: var(--sdb-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.sdb:focus {
  outline: none;
}

.sdb:focus-visible {
  outline: 3px solid var(--sdb-ink);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 5px #FFFFFF;
}

.sdb [hidden] {
  display: none !important;
}

.sdb p {
  margin: 0;
}

/* Layer 0: the basemap. Path coordinates are quanta under one matrix; banner.js gives the paths
   vector-effect="non-scaling-stroke" (and the SVG text paint-order="stroke") as presentation
   attributes, so these widths stay in pixels. */
.sdb-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sdb-layer {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sdb-layer-water {
  fill: #C9DCE7;
}

.sdb-layer-vineyards {
  fill: #DCE5CC;
}

.sdb-layer-waterways {
  stroke: #9EC2D6;
  stroke-width: 1.3px;
}

.sdb-layer-roads-minor {
  stroke: #FFFFFF;
  stroke-width: 1px;
}

.sdb-layer-roads-major {
  stroke: #FFFFFF;
  stroke-width: 2.4px;
}

.sdb-layer-ca29-casing {
  stroke: rgba(226, 166, 59, 0.28);
  stroke-width: 10px;
}

.sdb-layer-ca29 {
  stroke: #DDA143;
  stroke-width: 2.4px;
}

.sdb-place {
  fill: #50565C;
  stroke: rgba(244, 246, 242, 0.92);
  stroke-width: 3px;
  stroke-linejoin: round;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-anchor: middle;
}

.sdb-place-1 {
  fill: #383D42;
  font-size: 12px;
  font-weight: 600;
}

.sdb-place-3 {
  fill: #6A7076;
  font-size: 9.5px;
  font-style: italic;
}

/* Layer 1: the wells, styled as wellMarkerStyle in groundwater.js. */
.sdb-pin {
  stroke: #F8F9FA;
  stroke-width: 1.5px;
  fill-opacity: 0.9;
}

/* Not rated: hollow and dashed. The dashed ring is drawn in the pin's own neutral colour, since a
   surface-coloured dash on a light map reads as a cog at this size. */
.sdb-well-unrated .sdb-pin {
  fill-opacity: 0.22;
  stroke: #4A4A4A;
  stroke-width: 1.3px;
  stroke-linecap: round;
  stroke-dasharray: 0.01 2.3;
  stroke-opacity: 0.85;
}

.sdb-pulse {
  fill: none;
  stroke-width: 1.5px;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: sdb-pulse 7.2s ease-out infinite;
}

.sdb-pulse-1 { animation-delay: 1.2s; }
.sdb-pulse-2 { animation-delay: 2.4s; }
.sdb-pulse-3 { animation-delay: 3.6s; }
.sdb-pulse-4 { animation-delay: 4.8s; }
.sdb-pulse-5 { animation-delay: 6s; }

@keyframes sdb-pulse {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }

  45%,
  100% {
    opacity: 0;
    transform: scale(2.6);
  }
}

/* Layer 2: the ticker. */
.sdb-ticker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sdb-ticker-w);
  background: linear-gradient(to bottom, rgba(250, 251, 249, 0.6) 0, var(--sdb-backing) 12px, var(--sdb-backing) calc(100% - 14px), rgba(250, 251, 249, 0.6) 100%);
  box-shadow: 1px 0 0 rgba(27, 27, 27, 0.07), 6px 0 18px rgba(27, 27, 27, 0.06);
}

.sdb-ticker-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 12px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(27, 27, 27, 0.08);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.sdb-live {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #B2182B;
  animation: sdb-live 2.4s ease-in-out infinite;
}

@keyframes sdb-live {
  50% {
    opacity: 0.35;
  }
}

.sdb-ticker-window {
  position: absolute;
  top: 33px;
  right: 0;
  bottom: calc(var(--sdb-foot-h) + 2px);
  left: 0;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent 0, #000000 22px, #000000 calc(100% - 26px), transparent 100%);
}

/* Two identical halves; moving down by one half loops seamlessly. banner.js sets the duration
   from the list height (about 18 px/s). */
.sdb-ticker-reel {
  animation: sdb-reel 60s linear infinite;
  will-change: transform;
}

@keyframes sdb-reel {
  from {
    transform: translateY(-50%);
  }

  to {
    transform: translateY(0);
  }
}

.sdb-ticker-list {
  margin: 0;
  padding: 6px 10px 0 12px;
  list-style: none;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.38;
}

.sdb-ticker-list li {
  padding: 0 0 4px 1.6em;
  text-indent: -1.6em;
}

.sdb-t {
  color: #5C6369;
  white-space: nowrap;
}

.sdb-n {
  color: var(--sdb-ink);
}

.sdb-v {
  color: #00527F;
  font-weight: 650;
  white-space: nowrap;
}

/* Layer 3: the chart. */
.sdb-chart {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--sdb-foot-h);
  left: var(--sdb-ticker-w);
  background: linear-gradient(to bottom, rgba(250, 251, 249, 0.55) 0, rgba(250, 251, 249, 0.12) 76px, rgba(250, 251, 249, 0.12) 100%);
}

.sdb-chart-head {
  position: relative;
  z-index: 1;
  width: fit-content;
  padding: 12px 14px 0 18px;
  text-shadow: 0 0 3px #FFFFFF, 0 0 3px #FFFFFF, 0 0 6px #FFFFFF;
}

.sdb-chart-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sdb-chart-subtitle {
  display: block;
  color: var(--sdb-muted);
  font-size: 11.5px;
  line-height: 1.3;
}

.sdb-plot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sdb-gridline {
  stroke: rgba(27, 27, 27, 0.16);
  stroke-width: 1px;
  stroke-dasharray: 2 4;
}

.sdb-baseline,
.sdb-tick-x-mark {
  stroke: rgba(27, 27, 27, 0.4);
  stroke-width: 1px;
}

.sdb-tick-y,
.sdb-tick-x {
  fill: var(--sdb-muted);
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 3px;
  stroke-linejoin: round;
  font-size: 10px;
}

.sdb-tick-y {
  text-anchor: end;
}

.sdb-tick-x {
  text-anchor: middle;
}

.sdb-series {
  transition: opacity 0.6s ease;
}

.sdb-series.sdb-fade {
  opacity: 0;
}

.sdb-halo,
.sdb-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sdb-halo {
  stroke: rgba(255, 255, 255, 0.92);
}

.sdb-halo-cur {
  stroke-width: 6.5px;
}

.sdb-halo-prev {
  stroke-width: 6px;
}

.sdb-line-cur {
  stroke: var(--sdb-current);
  stroke-width: 2.5px;
}

.sdb-line-prev {
  stroke: var(--sdb-previous);
  stroke-width: 2px;
}

.sdb-dot {
  stroke: #FFFFFF;
  stroke-width: 1.5px;
}

.sdb-dot-cur {
  fill: var(--sdb-current);
}

.sdb-dot-prev {
  fill: var(--sdb-previous);
}

.sdb-head {
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 3.5px;
  stroke-linejoin: round;
  font-size: 11.5px;
  font-weight: 700;
}

.sdb-head-cur {
  fill: var(--sdb-current);
}

.sdb-head-prev {
  fill: var(--sdb-previous);
}

/* Brand row and attribution. */
.sdb-foot {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: var(--sdb-foot-h);
  padding: 0 10px 6px 12px;
  box-sizing: border-box;
}

.sdb-attrib {
  width: calc(var(--sdb-ticker-w) - 22px);
  flex: none;
  color: #5C6369;
  font-size: 9px;
  line-height: 1.2;
}

.sdb-brand {
  min-width: 0;
  overflow: hidden;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 2px rgba(27, 27, 27, 0.12);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sdb-org {
  color: var(--sdb-muted);
}

.sdb-org::after {
  content: " · ";
}

.sdb-host {
  color: var(--sdb-link);
  font-weight: 700;
}

.sdb-host::before {
  content: " → ";
  color: var(--sdb-ink);
  font-weight: 400;
}

.sdb:hover .sdb-brand,
.sdb:focus-visible .sdb-brand {
  background: #FFFFFF;
}

.sdb:hover .sdb-host {
  text-decoration: underline;
}

@media (max-width: 860px) {
  .sdb-org {
    display: none;
  }
}

@media (max-width: 520px) {
  .sdb-site {
    display: none;
  }

  .sdb-host::before {
    content: "→ ";
  }

  .sdb-chart-head {
    padding: 10px 6px 0 12px;
  }

  .sdb-chart-title {
    font-size: 14px;
  }

  .sdb-chart-subtitle {
    font-size: 10px;
  }

  .sdb-head {
    font-size: 10.5px;
  }
}

/* Narrow: the attribution gets its own line across the whole width, above the brand. */
@media (max-width: 420px) {
  :root {
    --sdb-foot-h: 42px;
  }

  .sdb-foot {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    gap: 3px;
  }

  .sdb-attrib {
    width: auto;
  }

  .sdb-brand {
    align-self: flex-end;
    padding: 2px 8px;
    font-size: 11px;
  }
}

/* Pause everything that moves while the banner is off-screen or the tab is hidden. */
.sdb-paused .sdb-ticker-reel,
.sdb-paused .sdb-pulse,
.sdb-paused .sdb-live {
  animation-play-state: paused;
}

/* Reduced motion: a still banner (the chart is drawn complete by banner.js). */
@media (prefers-reduced-motion: reduce) {
  .sdb-ticker-reel,
  .sdb-live {
    animation: none;
  }

  .sdb-pulse {
    display: none;
  }

  .sdb-series {
    transition: none;
  }
}
