/* ═══════════════════════════════════════════════════════════════════════
   HFSignals.live — Embeddable Audio Widget  (self-contained)
   Drop-in CSS for audio-widget.js.  All selectors are prefixed with
   .hfsig-aw-* so they won't collide with host-page styles.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Root container — CSS Grid: title spans both cols, left + right ── */
.hfsig-aw-root {
  --aw-bg: #0d0d1a;
  --aw-bg2: #1a1a2e;
  --aw-border: rgba(0, 212, 170, 0.32);
  --aw-text: #c8d0e8;
  --aw-dim: #8fa0bf;
  --aw-accent: #00d4aa;
  --aw-input: #10162a;
  --aw-focus: rgba(0, 212, 170, 0.4);
  --aw-from: #00d250;
  --aw-to: #dc5040;
  --aw-both: #e6c800;
  font-family: 'Share Tech Mono', monospace;
  color: var(--aw-text);
  background: linear-gradient(180deg, var(--aw-bg2), var(--aw-bg));
  border: 1px solid var(--aw-border);
  border-radius: 8px;
  padding: 14px;
  max-width: 480px;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.35);
  line-height: 1.4;

  display: grid;
  grid-template-columns: 2fr 3fr;
  grid-template-rows: auto 1fr;
  gap: 0 10px;
}

/* ── Light theme ── */
.hfsig-aw-root[data-theme="light"] {
  --aw-bg: #f4f7fb;
  --aw-bg2: #ffffff;
  --aw-border: rgba(0, 136, 106, 0.28);
  --aw-text: #1a1a2e;
  --aw-dim: #5f6f8c;
  --aw-accent: #00886a;
  --aw-input: #eef3f8;
  --aw-focus: rgba(0, 136, 106, 0.25);
  --aw-from: #008830;
  --aw-to: #b43228;
  --aw-both: #b48c00;
}

/* ── Colorblind theme ── */
.hfsig-aw-root[data-theme="cb"] {
  --aw-bg: #0f1222;
  --aw-bg2: #151a31;
  --aw-border: rgba(79, 215, 255, 0.36);
  --aw-text: #e8f3ff;
  --aw-dim: #9fb0c9;
  --aw-accent: #4fd7ff;
  --aw-input: #121938;
  --aw-focus: rgba(79, 215, 255, 0.30);
  --aw-from: #39b8ff;
  --aw-to: #d94fb2;
  --aw-both: #f6d84a;
}

/* ── Title row — flex row, title left, brand right ── */
.hfsig-aw-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--aw-accent);
  font-weight: 700;
  margin-bottom: 10px;
}

/* ── Brand cluster (site link + logo) — right side of title row ── */
.hfsig-aw-brand {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hfsig-aw-logo-link {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.hfsig-aw-logo-link img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  display: block;
}

.hfsig-aw-site-link {
  font-size: 9px;
  color: var(--aw-dim);
  text-decoration: none;
}

.hfsig-aw-site-link:hover {
  color: var(--aw-accent);
  text-decoration: underline;
}

/* ── Left column — flex column ── */
.hfsig-aw-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Right column — map fills entire cell with 2:1 aspect ratio ── */
.hfsig-aw-right {
  display: flex;
  min-width: 0;
  min-height: 0;
}

.hfsig-aw-map {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--aw-border);
  border-radius: 4px;
  background: rgba(10,16,28,0.92);
  box-sizing: border-box;
  align-self: flex-start;
}

/* ── Mode toggle row (toggle + first control) ── */
.hfsig-aw-ctrl-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

/* ── Mode toggle buttons ── */
.hfsig-aw-toggle {
  display: flex;
  flex-shrink: 0;
}

.hfsig-aw-tab {
  border: 1px solid var(--aw-border);
  background: var(--aw-input);
  color: var(--aw-dim);
  padding: 4px 8px;
  font-size: 10px;
  font-family: 'Share Tech Mono', monospace;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
  line-height: 1.3;
}

.hfsig-aw-tab:first-child {
  border-radius: 4px 0 0 4px;
}

.hfsig-aw-tab:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

.hfsig-aw-tab[aria-selected="true"] {
  background: var(--aw-accent);
  color: #001a14;
  border-color: var(--aw-accent);
  font-weight: 700;
}

/* ── Shared input / select styles ── */
.hfsig-aw-input,
.hfsig-aw-select {
  min-width: 0;
  border: 1px solid var(--aw-border);
  background: var(--aw-input);
  color: var(--aw-text);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 10px;
  font-family: 'Share Tech Mono', monospace;
  box-sizing: border-box;
}

.hfsig-aw-input:focus,
.hfsig-aw-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--aw-focus);
}

/* First control in the toggle row — fills remaining space */
.hfsig-aw-ctrl-row .hfsig-aw-select,
.hfsig-aw-ctrl-row .hfsig-aw-input {
  flex: 1;
}

/* Color-coded dropdown borders matching map legend */
.hfsig-aw-select-from {
  border-color: var(--aw-from);
}
.hfsig-aw-select-from:focus {
  box-shadow: 0 0 0 2px rgba(0, 210, 80, 0.3);
}
.hfsig-aw-select-to {
  border-color: var(--aw-to);
}
.hfsig-aw-select-to:focus {
  box-shadow: 0 0 0 2px rgba(220, 80, 60, 0.3);
}

/* ── Invisible spacer toggle — matches toggle width for alignment ── */
.hfsig-aw-spacer {
  visibility: hidden;
  pointer-events: none;
}

/* ── Panel visibility ── */
.hfsig-aw-panel { display: none; }
.hfsig-aw-panel.active { display: contents; }

/* ── "To signals from" row — always visible ── */
.hfsig-aw-to-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.hfsig-aw-to-row .hfsig-aw-select {
  flex: 1;
}

/* ── Band picker ── */
.hfsig-aw-band-wrap {
  flex: 1;
  position: relative;
}

.hfsig-aw-band-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.hfsig-aw-band-drop {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--aw-input);
  border: 1px solid var(--aw-border);
  border-radius: 5px;
  padding: 4px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  max-height: 180px;
  overflow-y: auto;
}

.hfsig-aw-band-drop.open {
  display: block;
}

.hfsig-aw-band-actions {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--aw-border);
}

.hfsig-aw-band-action {
  flex: 1;
  border: 1px solid var(--aw-border);
  background: var(--aw-input);
  color: var(--aw-accent);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 9px;
  font-family: 'Share Tech Mono', monospace;
  cursor: pointer;
  text-align: center;
}

.hfsig-aw-band-action:hover {
  background: var(--aw-accent);
  color: #001a14;
}

.hfsig-aw-band-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 2px;
  font-size: 10px;
  color: var(--aw-text);
  cursor: pointer;
}

.hfsig-aw-band-item input[type="checkbox"] {
  accent-color: var(--aw-accent);
  width: 12px;
  height: 12px;
  cursor: pointer;
}

/* ── Play row — button left, status right ── */
.hfsig-aw-play-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* ── Status text ── */
.hfsig-aw-status {
  flex: 1;
  font-size: 9px;
  color: var(--aw-dim);
  line-height: 1.4;
  min-height: 14px;
}

.hfsig-aw-status.err { color: #ff8080; }
.hfsig-aw-status.ok  { color: var(--aw-accent); }

/* ── Play / Stop button ── */
.hfsig-aw-play {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  border: 1px solid var(--aw-border);
  background: linear-gradient(180deg, rgba(0,212,170,0.14), rgba(0,212,170,0.06));
  color: var(--aw-accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.1s ease, opacity 0.12s ease;
}

.hfsig-aw-play:hover { transform: scale(1.06); }
.hfsig-aw-play:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.hfsig-aw-play svg { width: 18px; height: 18px; fill: currentColor; }
.hfsig-aw-play .aw-icon-stop { display: none; }
.hfsig-aw-play.playing .aw-icon-play { display: none; }
.hfsig-aw-play.playing .aw-icon-stop { display: block; }

.hfsig-aw-play .aw-icon-spin { display: none; }
.hfsig-aw-play.loading .aw-icon-play,
.hfsig-aw-play.loading .aw-icon-stop { display: none; }
.hfsig-aw-play.loading .aw-icon-spin {
  display: block;
  animation: hfsig-aw-spin 0.9s linear infinite;
}

@keyframes hfsig-aw-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}


/* ── Mobile responsive — stack columns vertically ────────────────── */
@media (max-width: 480px) {
  .hfsig-aw-root {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    max-width: 100%;
    padding: 10px;
  }

  .hfsig-aw-title {
    font-size: 11px;
  }

  .hfsig-aw-map {
    aspect-ratio: 2 / 1;
    width: 100%;
    margin-top: 8px;
  }

  .hfsig-aw-right {
    order: 3;
  }

  .hfsig-aw-left {
    order: 2;
  }

  .hfsig-aw-play-row {
    margin-top: 8px;
  }

  /* Prevent band picker from overflowing */
  .hfsig-aw-band-drop {
    max-width: 100%;
  }
}
