/* Base styles shared by every component: reset, typography, cards, buttons, skeletons. */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 70% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.005em; }
h3 { font-size: var(--text-md); font-weight: 600; }

a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.muted { color: var(--text-muted); }

/* Card: the one surface every dashboard block sits on. */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--card-highlight), transparent 120px), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: var(--space-5);
  min-width: 0;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out), border-color var(--duration) var(--ease-out);
}
.btn:hover { border-color: var(--brand); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--brand-soft); border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon { width: 18px; height: 18px; flex: none; }

/* Skeleton: the loading state every component shows before its data arrives. */
.skeleton {
  display: block;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s ease-in-out infinite;
}
@keyframes skeleton-shine {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Message shown inside a card when there is nothing to draw, or loading failed. */
.notice {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  min-height: 120px;
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.notice--error { color: var(--red); }

/* A page-wide message shown instead of the page (e.g. no campaigns). */
.page-notice { min-height: 240px; font-size: var(--text-md); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Panel that drops down from a button (see media/js/core/popover.js). */
.popover-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  z-index: 40;
  padding: var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--card-shadow);
}

/* Search box with a leading icon. */
.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
}
.search-field:focus-within { border-color: var(--brand); }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}
.search-field input:focus-visible { box-shadow: none; }

/* Filter button or select (top bar filters, campaign picker). */
.filter-control {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  max-width: 100%;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.filter-control:hover { border-color: var(--brand); }
.filter-control:disabled { opacity: 0.55; cursor: not-allowed; }
.filter-control[data-active] { border-color: var(--brand); background: var(--brand-soft); }
.filter-control__label { color: var(--text-muted); font-weight: 500; }
.filter-control__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-control .icon { color: var(--text-muted); width: 16px; height: 16px; }

/* Two or three mutually exclusive options shown side by side (role="radiogroup"). */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.segmented__option {
  height: 28px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}
.segmented__option:hover { color: var(--text); }
.segmented__option[aria-checked="true"] { background: var(--surface-raised); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
