/* =============================================================
   HF Band Scout — Base Styles
   Reset, body, typography, global utilities
   ============================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  height: 100dvh;
  height: 100vh; /* fallback */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
}

h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-md); }

p { color: var(--text-secondary); }

a {
  color: var(--accent-primary);
  text-decoration: underline;
}

a:hover { opacity: 0.85; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ── Buttons ── */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Icon button ── */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--border-default); }

/* ── Inputs ── */
input, select {
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus {
  border-color: var(--border-focus);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A8FA8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

input[type="range"] {
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-ok      { background: rgba(0, 200, 150, 0.15); color: var(--score-excellent); }
.badge-warn    { background: rgba(239, 159, 39, 0.15); color: var(--accent-warning); }
.badge-error   { background: rgba(226, 75, 74, 0.15);  color: var(--accent-danger); }
.badge-stale   { background: rgba(85, 92, 120, 0.2);   color: var(--text-muted); }

/* ── Score colour classes ── */
.score-excellent { color: var(--score-excellent); }
.score-good      { color: var(--score-good); }
.score-moderate  { color: var(--score-moderate); }
.score-poor      { color: var(--score-poor); }
.score-marginal  { color: var(--text-muted); }
.score-closed    { color: var(--text-muted); }

/* ── Spinner ── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Screen reader only ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  bottom: calc(var(--timeline-h) + var(--conditions-h) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease, toast-out 200ms ease 2.8s forwards;
  pointer-events: auto;
  white-space: nowrap;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Dividers ── */
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-4) 0;
}

/* ── Empty state ── */
.list-placeholder {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ── Scrollbar styling (webkit) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Tooltip bubble ─────────────────────────────────────────────────────── */
.tt-bubble {
  position: absolute;
  z-index: 9000;
  max-width: 280px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.tt-bubble.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Help [?] button ────────────────────────────────────────────────────── */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
.help-btn:hover,
.help-btn:focus-visible {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  outline: none;
}

/* ─── Help modal ─────────────────────────────────────────────────────────── */
.help-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.65);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.help-modal.is-open {
  display: flex;
}
.help-modal-box {
  position: relative;
  max-width: 480px;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.help-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.help-modal-close:hover { color: var(--text-primary); }
.help-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
  padding-right: 2rem;
}
.help-modal-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
