/*
 * Campaign readiness tracker design tokens + components.
 *
 * Layered on top of vendored Bootstrap 5.3.3: Bootstrap provides layout, dropdowns,
 * and forms; identity comes from these tokens. Signature element: the gate rail — a
 * segmented strip, one cell per activation gate in runbook order.
 */

:root {
  --yb-paper: #F4F6F8;
  --yb-surface: #FFFFFF;
  --yb-ink: #1A2230;
  --yb-muted: #5C6675;
  --yb-line: #DFE4EB;
  --yb-accent: #2F52C4;
  --yb-accent-soft: #EDF1FB;
  /* Status hues are colorblind-safe, drawn from the Okabe-Ito families (ok: bluish
     green, warn: vermillion) so ok/warn separate under deuteranopia/protanopia where
     the old green/amber pair collapsed. Contrast as text on --yb-surface (#FFFFFF):
     ok #00805C 4.95:1, warn #C2450E 5.06:1, pending #64748B 4.76:1 — all AA for
     normal text. unknown (#98A1AD, 2.61:1) and skipped (#C9CFD6, 1.57:1) are never
     used as text: badge text for those statuses is set in --yb-muted (see below).
     Status is additionally never encoded by hue alone — each status has a distinct
     fill pattern (see the gate-rail section) and badges carry text labels. */
  --yb-ok: #00805C;
  --yb-warn: #C2450E;
  --yb-pending: #64748B;
  --yb-unknown: #98A1AD;
  --yb-skipped: #C9CFD6;
  --yb-mono: ui-monospace, "SF Mono", "Cascadia Mono", monospace;

  /* Wire Bootstrap's own variables to the token system. */
  --bs-body-bg: var(--yb-paper);
  --bs-body-color: var(--yb-ink);
  --bs-link-color: var(--yb-accent);
  --bs-link-hover-color: #24409B;
  --bs-border-color: var(--yb-line);
  --bs-border-radius: 6px;
}

body {
  background: var(--yb-paper);
  color: var(--yb-ink);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

a {
  color: var(--yb-accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

/* Data is the personality: every count, ID, date, threshold is set in mono. */
.yb-mono {
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92em;
}

.yb-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--yb-muted);
}

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

.yb-card {
  background: var(--yb-surface);
  border: 1px solid var(--yb-line);
  border-radius: 6px;
}

/* ---------------------------------------------------------------- navbar */

.yb-nav {
  background: var(--yb-ink);
  border-bottom: 1px solid var(--yb-ink);
}
.yb-nav .navbar-brand {
  color: #FFFFFF;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.yb-nav .nav-link {
  color: #C4CAD6;
  transition: color 120ms ease;
}
.yb-nav .nav-link:hover {
  color: #FFFFFF;
}
.yb-nav .nav-link.active {
  color: #FFFFFF;
  box-shadow: inset 0 -2px 0 var(--yb-accent);
}
.yb-nav .dropdown-menu {
  border: 1px solid var(--yb-line);
  border-radius: 6px;
}

/* ------------------------------------------------------------- gate rail */

.gate-rail {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.gate-rail .gate-cell {
  display: block;
  width: 18px;
  height: 10px;
  border-radius: 2px;
  background: var(--status-color, var(--yb-skipped));
  transition: background-color 120ms ease;
}

/* Large rail (detail header): each cell is a link to its numbered gate section. */
.gate-rail--lg .gate-cell {
  width: auto;
  height: auto;
  flex: 1 1 0;
  min-width: 44px;
  background: none;
  text-align: center;
  text-decoration: none;
}
.gate-rail--lg .gate-cell-bar {
  display: block;
  height: 12px;
  border-radius: 2px;
  background: var(--status-color, var(--yb-skipped));
  transition: background-color 120ms ease, filter 120ms ease;
}
.gate-rail--lg .gate-cell:hover .gate-cell-bar {
  filter: brightness(0.85);
}
.gate-rail--lg .gate-cell-num {
  display: block;
  margin-top: 4px;
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--yb-muted);
}

.status-ok { --status-color: var(--yb-ok); }
.status-warn { --status-color: var(--yb-warn); }
.status-pending { --status-color: var(--yb-pending); }
.status-unknown { --status-color: var(--yb-unknown); }
.status-skipped { --status-color: var(--yb-skipped); }

/* Redundant non-color encoding: every status also gets a distinct fill pattern, so
   the rails and badge dots read in grayscale (and under any color-vision deficiency):
   ok = solid, warn = diagonal stripes, pending = bottom-half fill, unknown =
   cross-hatch, skipped = hollow. Applied to the small-rail cells, the large-rail
   bars, and the status-badge dots alike. */
.gate-rail:not(.gate-rail--lg) .gate-cell.status-warn,
.gate-rail--lg .gate-cell.status-warn .gate-cell-bar,
.status-badge.status-warn .status-dot {
  background: repeating-linear-gradient(
    135deg,
    var(--yb-warn) 0,
    var(--yb-warn) 2px,
    var(--yb-surface) 2px,
    var(--yb-surface) 5.5px
  );
  border: 1px solid var(--yb-warn);
}
.gate-rail:not(.gate-rail--lg) .gate-cell.status-pending,
.gate-rail--lg .gate-cell.status-pending .gate-cell-bar,
.status-badge.status-pending .status-dot {
  background: linear-gradient(to top, var(--yb-pending) 50%, transparent 50%);
  border: 1px solid var(--yb-pending);
}
.gate-rail:not(.gate-rail--lg) .gate-cell.status-unknown,
.gate-rail--lg .gate-cell.status-unknown .gate-cell-bar,
.status-badge.status-unknown .status-dot {
  background:
    repeating-linear-gradient(
      45deg,
      var(--yb-unknown) 0,
      var(--yb-unknown) 2px,
      transparent 2px,
      transparent 5.5px
    ),
    repeating-linear-gradient(
      -45deg,
      var(--yb-unknown) 0,
      var(--yb-unknown) 2px,
      transparent 2px,
      transparent 5.5px
    );
  border: 1px solid var(--yb-unknown);
}
.gate-rail:not(.gate-rail--lg) .gate-cell.status-skipped,
.gate-rail--lg .gate-cell.status-skipped .gate-cell-bar,
.status-badge.status-skipped .status-dot {
  background: transparent;
  border: 1px solid var(--yb-skipped);
}

/* The pattern fills are meaningful, not decorative: keep them when printing. */
.gate-rail .gate-cell,
.gate-rail--lg .gate-cell-bar,
.status-badge .status-dot {
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

/* Windows High Contrast (forced-colors) strips background images and repaints
   borders in CanvasText, so the fills above vanish; re-encode each status as a
   distinct border-style instead. ok has no border in the normal palette — it gets
   one here. */
@media (forced-colors: active) {
  .gate-rail:not(.gate-rail--lg) .gate-cell.status-ok,
  .gate-rail--lg .gate-cell.status-ok .gate-cell-bar,
  .status-badge.status-ok .status-dot {
    border: 3px solid;
  }
  .gate-rail:not(.gate-rail--lg) .gate-cell.status-warn,
  .gate-rail--lg .gate-cell.status-warn .gate-cell-bar,
  .status-badge.status-warn .status-dot {
    border: 3px dashed;
  }
  .gate-rail:not(.gate-rail--lg) .gate-cell.status-pending,
  .gate-rail--lg .gate-cell.status-pending .gate-cell-bar,
  .status-badge.status-pending .status-dot {
    border: 3px dotted;
  }
  .gate-rail:not(.gate-rail--lg) .gate-cell.status-unknown,
  .gate-rail--lg .gate-cell.status-unknown .gate-cell-bar,
  .status-badge.status-unknown .status-dot {
    border: 3px double;
  }
  .gate-rail:not(.gate-rail--lg) .gate-cell.status-skipped,
  .gate-rail--lg .gate-cell.status-skipped .gate-cell-bar,
  .status-badge.status-skipped .status-dot {
    border: 1px solid;
  }
}

/* ---------------------------------------------------------- status badge */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--status-color, var(--yb-muted));
}
/* The unknown/skipped hues fail AA as text on white — keep the dot in the status
   hue but set their label text in the accessible muted ink. */
.status-badge.status-unknown,
.status-badge.status-skipped {
  color: var(--yb-muted);
  font-weight: 500;
}
.status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--status-color, var(--yb-skipped));
  flex-shrink: 0;
}

/* ----------------------------------------------------------- stat tiles */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
/* The tiles are links: radio-style filter chips for the ?status= param. Exactly one
   is selected at a time (aria-current="true"); the selected tile links back to All. */
.stat-tile {
  display: block;
  background: var(--yb-surface);
  border: 1px solid var(--yb-line);
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--yb-ink);
  text-decoration: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.stat-tile:hover {
  color: var(--yb-ink);
  text-decoration: none;
  border-color: var(--yb-accent);
}
.stat-tile.is-selected {
  border-color: var(--yb-accent);
  background: var(--yb-accent-soft);
  box-shadow: 0 0 0 2px var(--yb-accent);
}
.stat-tile.is-selected .yb-eyebrow {
  color: var(--yb-accent);
}
.stat-tile .stat-value {
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
}
.stat-tile.stat-attention .stat-value { color: var(--yb-warn); }
.stat-tile.stat-active .stat-value { color: var(--yb-ok); }
.stat-tile.stat-ready .stat-value { color: var(--yb-accent); }
.stat-tile.stat-waiting .stat-value { color: var(--yb-pending); }

/* --------------------------------------------------------------- tables */

.table-scroll {
  overflow-x: auto;
}

.yb-table {
  width: 100%;
  background: var(--yb-surface);
  border-collapse: collapse;
  font-size: 14px;
}
.yb-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--yb-muted);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--yb-line);
  white-space: nowrap;
}
.yb-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--yb-line);
  vertical-align: middle;
}
.yb-table tbody tr {
  transition: background-color 120ms ease;
}
.yb-table tbody tr:hover {
  background: #F8FAFC;
}
.yb-table tr:last-child td {
  border-bottom: none;
}

/* --------------------------------------------------------- filter bar */

.filter-bar .form-control,
.filter-bar .form-select {
  border-color: var(--yb-line);
  font-size: 14px;
}
.filter-bar .form-control:focus,
.filter-bar .form-select:focus {
  border-color: var(--yb-accent);
  box-shadow: 0 0 0 2px var(--yb-accent-soft);
}
/* filters.js adds js-live and submits on change/debounced input; the explicit submit
   button is only needed as the no-JS fallback. */
.filter-bar.js-live .filter-submit {
  display: none;
}

.btn-yb {
  background: var(--yb-accent);
  border: 1px solid var(--yb-accent);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  transition: background-color 120ms ease;
}
.btn-yb:hover,
.btn-yb:focus {
  background: #24409B;
  border-color: #24409B;
  color: #FFFFFF;
}

.btn-yb-quiet {
  background: var(--yb-surface);
  border: 1px solid var(--yb-line);
  color: var(--yb-ink);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  transition: border-color 120ms ease, color 120ms ease;
}
.btn-yb-quiet:hover,
.btn-yb-quiet:focus {
  border-color: var(--yb-accent);
  color: var(--yb-accent);
}

/* ------------------------------------------------------- gate checklist */

.gate-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.gate-item {
  display: flex;
  gap: 16px;
  background: var(--yb-surface);
  border: 1px solid var(--yb-line);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 10px;
  scroll-margin-top: 84px;
  transition: border-color 120ms ease, background-color 120ms ease;
}
/* Scroll highlight when a gate-rail cell navigates here. */
.gate-item:target {
  border-color: var(--yb-accent);
  background: var(--yb-accent-soft);
}
.gate-item .gate-num {
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--yb-muted);
  min-width: 22px;
  padding-top: 2px;
}
.gate-item .gate-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.gate-item .gate-detail {
  font-size: 13.5px;
  color: var(--yb-muted);
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
.gate-item .gate-detail time {
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95em;
}
.gate-item.gate-skipped .gate-title {
  color: var(--yb-muted);
  font-weight: 600;
}

/* -------------------------------------------------------------- sidebar */

.fact-list {
  margin: 0;
  font-size: 13.5px;
}
.fact-list dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--yb-muted);
  margin-top: 10px;
}
.fact-list dt:first-child {
  margin-top: 0;
}
.fact-list dd {
  margin: 1px 0 0;
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13.5px;
}
.link-list li {
  padding: 5px 0;
  border-bottom: 1px solid var(--yb-line);
}
.link-list li:last-child {
  border-bottom: none;
}

/* ----------------------------------------------------- onboarding wizard */

/* Numbered section rail: the vertical sibling of the gate rail. Sticky on wide
   screens so the section links stay reachable while scrolling the form. */
.wizard-rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 16px;
}
.wizard-rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--yb-line);
  color: var(--yb-muted);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 120ms ease, color 120ms ease;
}
.wizard-rail-item:hover {
  border-left-color: var(--yb-accent);
  color: var(--yb-accent);
  text-decoration: none;
}
.wizard-rail-num {
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
@media (max-width: 991.98px) {
  .wizard-rail {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .wizard-rail-item {
    border-left: none;
    border-bottom: 3px solid var(--yb-line);
    padding: 4px 8px;
  }
  .wizard-rail-item:hover {
    border-bottom-color: var(--yb-accent);
  }
}

.wizard-section {
  padding: 18px 20px;
  margin-bottom: 16px;
  scroll-margin-top: 16px;
}
.wizard-section:target {
  border-color: var(--yb-accent);
}
.wizard-section-head {
  display: flex;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--yb-line);
}
.wizard-section-hint {
  font-size: 13px;
  color: var(--yb-muted);
  margin: 2px 0 0;
}

.wizard-field .form-label {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.wizard-field .required-marker {
  color: var(--yb-warn);
  margin-left: 2px;
}
.wizard-field .form-text {
  font-size: 12.5px;
  color: var(--yb-muted);
}
.wizard-field .invalid-feedback {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--yb-warn);
}
.wizard-field.has-error .form-control,
.wizard-field.has-error .form-select {
  border-color: var(--yb-warn);
}
.wizard-field .form-control,
.wizard-field .form-select {
  border-color: var(--yb-line);
  font-size: 14px;
}
.wizard-field .form-control:focus,
.wizard-field .form-select:focus {
  border-color: var(--yb-accent);
  box-shadow: 0 0 0 2px var(--yb-accent-soft);
}
/* Identifiers, dates, and the scope are data — set them in mono like everywhere else. */
#id_advertiser_platform_identifier,
#id_activation_platform_identifier,
#id_seat_identifier,
#id_campaign_name,
#id_activation_secrets_scope,
#id_holdout_percentage,
#id_flight_first_date,
#id_flight_last_date,
#id_primary_conversion_goal {
  font-family: var(--yb-mono);
  font-variant-numeric: tabular-nums;
}

.name-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
}
.name-suggestion code {
  color: var(--yb-ink);
  background: var(--yb-accent-soft);
  border-radius: 4px;
  padding: 2px 6px;
}

/* Wire select2's default theme to the tokens (light mode, options inline). */
.select2-container--default .select2-selection--single {
  border: 1px solid var(--yb-line);
  border-radius: 6px;
  height: calc(1.5em + 0.75rem + 2px);
  font-size: 14px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: calc(1.5em + 0.75rem);
  color: var(--yb-ink);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: calc(1.5em + 0.75rem);
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--yb-accent);
  box-shadow: 0 0 0 2px var(--yb-accent-soft);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--yb-accent);
}
.select2-dropdown {
  border: 1px solid var(--yb-line);
  border-radius: 6px;
  font-size: 14px;
}
/* The creatable comboboxes' "Create ..." tag — visibly distinct from real options. */
.select2-create-option {
  font-weight: 600;
  color: var(--yb-accent);
}
.select2-results__option--highlighted[aria-selected] .select2-create-option {
  color: #fff;
}

/* --------------------------------------------------------------- states */

.empty-state {
  background: var(--yb-surface);
  border: 1px dashed var(--yb-line);
  border-radius: 6px;
  padding: 32px 24px;
  text-align: center;
  color: var(--yb-muted);
  font-size: 14px;
}

.alert {
  border-radius: 6px;
  border: 1px solid var(--yb-line);
  font-size: 14px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
