/*
 * RotoBaller ADP — [rb_adp] front end
 *
 * Same visual language as the rankings card tool (Outfit type, left-pinned rank/name
 * columns, sticky controls+header block, team-colored badges, row stripes) with the
 * legacy ADP tool's position BUTTON bar instead of a position dropdown, and no scoring
 * selector. Column set is ADP-specific: one column per live source in adp.json.
 *
 * Self-contained: the rankings tool's stylesheet is only enqueued on rankings pages, so
 * the shared tokens are duplicated here rather than depended on.
 */

/* Hidden until the JS boots so the mount never flashes an empty box. */
#rb-adp { display: none; }
body.rb-adp-on #rb-adp {
	display: block;
	margin: 2px 0 0;
	font-family: 'Outfit', -apple-system, "Helvetica Neue", Arial, sans-serif;
	-webkit-text-size-adjust: 100%;
}

#rb-adp * { box-sizing: border-box; }

/* Every grid cell fills its track EXPLICITLY rather than relying on a grid item's default
   justify-self:stretch. A site stylesheet gives divs in the content area a non-auto width and a
   non-stretch justify, so the cells shrank to their own content and sat at the left edge of their
   track — the header labels and the values then drifted apart column by column (visible on mobile,
   where the grid overflows). Neither justify-self:stretch nor width:auto can win that back; an
   explicit width resolves against the grid area and is immune to both. Do not remove: this looks
   redundant in isolation and is only reproducible with the theme's CSS loaded. */
#rb-adp .rb-adp-c,
#rb-adp .rb-adp-h-c,
#rb-adp .rb-adp-badge,
#rb-adp .rb-adp-head .rb-adp-name { width: 100%; }

#rb-adp .rb-adp-loading,
#rb-adp .rb-adp-error,
#rb-adp .rb-adp-empty {
	padding: 28px 12px;
	text-align: center;
	color: #6b7280;
	font-size: 14px;
}
#rb-adp .rb-adp-error { color: #b21f2d; }

/* ---------------------------------------------------------------- chrome (pins on scroll) */
/* chromewrap holds the placeholder gap while chrome is position:fixed. The theme's
   html{overflow-x:hidden} breaks position:sticky, so we pin with fixed — same approach the
   rankings tool uses, and it works in place here (no transformed ancestor in the embed). */
#rb-adp .rb-adp-chromewrap { position: relative; }
#rb-adp .rb-adp-chrome { background: #fff; }
#rb-adp .rb-adp-chrome.rb-fixed {
	position: fixed;
	z-index: 1000000;
	box-shadow: 0 3px 6px rgba(0, 0, 0, .07);
}
/* While pinned the chrome's own drop shadow separates it from the list — the header's
   grey underline on top of that reads as a double divider. */
#rb-adp .rb-adp-chrome.rb-fixed .rb-adp-head { border-bottom-color: transparent; }

/* ---------------------------------------------------------------- controls (dropdowns) */
/* Blue pill selects, matching the rankings tool's .rb-mc-sel. Position + ADP source share the
   row with the search / download icons; the two selects split whatever width is left. */
#rb-adp .rb-adp-controls {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 8px;
}
#rb-adp .rb-adp-field {
	flex: 1 1 0;
	display: inline-flex;
	min-width: 0;
	margin: 0;
}
#rb-adp .rb-adp-sel {
	width: 100%;
	min-width: 0;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	padding: 9px 26px 9px 13px;
	border: none;
	border-radius: 20px;
	line-height: 1.15;
	height: auto;
	cursor: pointer;
	background-color: #1e7fd6;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='1.7' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
}
#rb-adp .rb-adp-sel:focus { outline: none; box-shadow: 0 0 0 3px rgba(30, 127, 214, .25); }
/* The picker itself renders with the OS palette, so force readable option text — white-on-white
   otherwise, since the select's own colour is inherited on some platforms. */
#rb-adp .rb-adp-sel option { color: #15171a; background: #fff; }

/* icon buttons (search / download) — same treatment as the rankings controls */
#rb-adp .rb-adp-icon {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid #dfe3e8;
	border-radius: 50%;
	background: #fff;
	color: #44505c;
	padding: 0;
	cursor: pointer;
}
#rb-adp .rb-adp-icon:hover { background: #eef4fb; color: #136dc8; }
#rb-adp .rb-adp-icon:active { background: #eef4fb; }

@media (max-width: 600px) {
	#rb-adp .rb-adp-controls { gap: 5px; padding: 8px 6px; }
	#rb-adp .rb-adp-sel { font-size: 12px; padding: 8px 22px 8px 10px; background-position: right 8px center; }
	#rb-adp .rb-adp-icon { width: 28px; height: 28px; }
}

/* search: its own row below the buttons, so it never covers them */
#rb-adp .rb-adp-search {
	display: none;
	align-items: center;
	gap: 6px;
	height: 38px;
	margin: 0 8px 8px;
	padding: 0 8px 0 12px;
	background: #fff;
	border: 1px solid #1e7fd6;
	border-radius: 20px;
}
#rb-adp .rb-adp-search.open { display: flex; }
#rb-adp .rb-adp-search-ic { color: #9aa0a8; display: inline-flex; }
#rb-adp .rb-adp-search input {
	flex: 1 1 auto;
	min-width: 0;
	border: none;
	outline: none;
	font-family: inherit;
	font-size: 15px;
	color: #15171a;
	background: transparent;
}
#rb-adp .rb-adp-search-x {
	flex: 0 0 auto;
	width: 26px; height: 26px;
	display: inline-flex; align-items: center; justify-content: center;
	border: none; background: #eef1f4; color: #5a616b; border-radius: 50%; padding: 0; cursor: pointer;
}

/* ---------------------------------------------------------------- grid tracks */
/* --rb-nameW is a STATIC width for the name column: the grid never reflows on horizontal
   scroll, so scrolling stays native-smooth and the name just snaps big -> small. */
#rb-adp .rb-adp-list,
#rb-adp .rb-adp-head { --rb-badgeW: 44px; --rb-teamW: 50px; --rb-nameW: 150px; }

@media (max-width: 600px) {
	#rb-adp .rb-adp-list,
	#rb-adp .rb-adp-head { --rb-badgeW: 38px; --rb-teamW: 42px; --rb-nameW: 124px; }
}

/* body: horizontal scroll only — the PAGE owns vertical scroll */
#rb-adp .rb-adp-list {
	overflow-x: auto;
	overflow-y: visible;
	-webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------------- column header */
#rb-adp .rb-adp-head {
	position: relative;
	z-index: 5;
	display: grid;
	align-items: center;
	min-width: 100%;
	min-height: 46px;
	overflow-x: hidden;
	background: #fff;
	border-top: 1px solid #e6e9ed;
	border-bottom: 1px solid #d8dce1;
	color: #4b5563;
}
#rb-adp .rb-adp-head .rb-adp-badge,
#rb-adp .rb-adp-head .rb-adp-name { background: #fff; cursor: pointer; }
#rb-adp .rb-adp-head .rb-adp-badge { flex-direction: row; z-index: 7; justify-content: center; }
/* The header's name cell is sticky and spans its whole grid track: it has to mask the source
   labels sliding underneath on horizontal scroll, otherwise a clipped fragment of the next label
   (e.g. "YE" from BYE) peeks out beside the pinned RK badge. The width comes from the shared
   fill-the-track rule above — keep it 100% here, NOT auto, or that rule is overridden and the
   mask collapses to the width of the word "Player". */
#rb-adp .rb-adp-head .rb-adp-name {
	position: sticky;
	left: var(--rb-badgeW);
	z-index: 6;
	align-self: stretch;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	width: 100%;
	max-width: none;
	padding: 0 8px;
	pointer-events: auto;
}
#rb-adp .rb-adp-head .rb-adp-nm { text-shadow: none; white-space: nowrap; }
/* On horizontal scroll the "PLAYER" label gets out of the way so the real column labels
   underneath it (AVG, YAHOO, …) are readable above the values they belong to — the rankings
   tool does exactly this. visibility, not display, so the header keeps its grid track and stays
   aligned with the body. */
#rb-adp.rb-hscroll .rb-adp-head .rb-adp-name { visibility: hidden; }

/* Force every header label to one identical size, immune to theme rules that bleed into the
   container (the page's stylesheets load after ours and set a tall inherited line-height). */
#rb-adp .rb-adp-head .rb-adp-hcell,
#rb-adp .rb-adp-head .rb-adp-h-c,
#rb-adp .rb-adp-head .rb-adp-name .rb-adp-nm {
	font-size: 11px !important;
	line-height: 1.15 !important;
	font-weight: 700 !important;
	letter-spacing: .3px;
	text-transform: uppercase;
	color: #4b5563;
}
#rb-adp .rb-adp-h-c {
	text-align: center;
	padding: 0 4px;
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
}
#rb-adp .rb-adp-h-c:hover { color: #1e7fd6 !important; }
#rb-adp .rb-adp-sort { display: inline-block; width: 0; height: 0; margin-left: 3px; vertical-align: middle; }
#rb-adp .rb-adp-sort.asc  { border-left: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 4px solid #1e7fd6; }
#rb-adp .rb-adp-sort.desc { border-left: 3px solid transparent; border-right: 3px solid transparent; border-top: 4px solid #1e7fd6; }

/* ---------------------------------------------------------------- rows */
#rb-adp .rb-adp-row {
	display: grid;
	align-items: center;
	min-height: 52px;
	min-width: 100%;
	width: max-content;
	border-bottom: 1px solid #edeff1;
	text-decoration: none !important;
	color: #1a1a1a !important;
}
#rb-adp .rb-adp-row.rb-adp-even { background: #fff; }
#rb-adp .rb-adp-row.rb-adp-odd  { background: #f6f7f9; }
#rb-adp a.rb-adp-row:hover { background: #eef4fb; }

/* frozen rank badge — the only fully pinned cell */
#rb-adp .rb-adp-badge {
	position: sticky;
	left: 0;
	z-index: 5;
	align-self: stretch;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	padding: 4px 5px;
}
#rb-adp .rb-adp-row.rb-adp-even .rb-adp-badge { background: #fff; }
#rb-adp .rb-adp-row.rb-adp-odd  .rb-adp-badge { background: #f6f7f9; }
#rb-adp a.rb-adp-row:hover .rb-adp-badge { background: #eef4fb; }
#rb-adp .rb-adp-rank {
	min-width: 22px;
	height: 20px;
	padding: 0 4px;
	border-radius: 5px;
	background: #5f6671;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	display: flex;
	align-items: center;
	justify-content: center;
}
/* The POS column already carries the chip at rest, so the badge's copy stays hidden until the
   horizontal scroll pushes that column out of view. */
#rb-adp.rb-hscroll .rb-adp-row .rb-adp-rank { transform: scale(.85); }
#rb-adp .rb-adp-badge .rb-adp-pos-chip { display: none; }
#rb-adp.rb-hscroll .rb-adp-row .rb-adp-badge .rb-adp-pos-chip,
/* …and permanently when the POS column has been dropped to give the name its width back. */
#rb-adp.rb-adp-posinbadge .rb-adp-row .rb-adp-badge .rb-adp-pos-chip { display: block; }

/* position chip — same palette as the rankings tool */
#rb-adp .rb-adp-pos-chip {
	font-size: 9px;
	font-weight: 700;
	line-height: 1;
	padding: 2px 4px;
	border-radius: 3px;
	background: #eef1f4;
	color: #444;
}
#rb-adp .rb-adp-pos-chip.qb  { background: #efe9fc; color: #5a3bbf; }
#rb-adp .rb-adp-pos-chip.rb  { background: #d9f1f4; color: #0e7490; }
#rb-adp .rb-adp-pos-chip.wr  { background: #e6f1fb; color: #185fa5; }
#rb-adp .rb-adp-pos-chip.te  { background: #fdefdb; color: #9a5b09; }
#rb-adp .rb-adp-pos-chip.k   { background: #f6e8f4; color: #9d2c7a; }
#rb-adp .rb-adp-pos-chip.dst { background: #eceff2; color: #3f4a57; }

/* name = sticky overlay in a static-width column. At rest: big, vertically centered.
   On scroll: snaps small + rises so the source columns slide underneath and stay visible. */
#rb-adp .rb-adp-row .rb-adp-name {
	position: sticky;
	left: var(--rb-badgeW);
	z-index: 4;
	align-self: center;
	justify-self: start;
	width: max-content;
	max-width: calc(var(--rb-nameW) - 12px);
	display: flex;
	flex-direction: column;
	gap: 1px;
	padding: 0 8px;
	pointer-events: none;
}
#rb-adp.rb-hscroll .rb-adp-row .rb-adp-name {
	align-self: start;
	padding-top: 5px;
	max-width: 74vw;
}
#rb-adp .rb-adp-row .rb-adp-nm {
	font-size: 14px;
	font-weight: 700;
	color: #15171a;
	line-height: 1.1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: clip;
	text-shadow: 0 0 4px #fff, 0 0 4px #fff, 0 0 7px #fff;
}
#rb-adp.rb-hscroll .rb-adp-row .rb-adp-nm { font-size: 11px; }

/* ---------------------------------------------------------------- data cells */
#rb-adp .rb-adp-c {
	text-align: center;
	padding: 0 4px;
	font-size: 13px;
	font-weight: 500;
	color: #33404d;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
#rb-adp .rb-adp-c.rb-adp-empty-v { color: #c2c8d0; }

/* ---------------------------------------------------------------- team logo column */
/* Sits between the rank badge and the name, and is deliberately NOT sticky: on horizontal
   scroll it slides away behind the pinned name, same as the rankings tool. */
#rb-adp .rb-adp-team { display: flex; align-items: center; justify-content: center; }
#rb-adp .rb-adp-tlogo { width: 26px; height: 26px; object-fit: contain; display: block; }
#rb-adp .rb-adp-tabbr { font-size: 12px; font-weight: 700; }
@media (min-width: 601px) {
	#rb-adp .rb-adp-tlogo { width: 32px; height: 32px; }
	#rb-adp .rb-adp-tabbr { font-size: 14px; }
}
/* the consensus column is the ranking basis — give it a little more weight */
#rb-adp .rb-adp-c[data-key="average"] { font-weight: 700; color: #15202b; }
#rb-adp .rb-adp-c[data-key="__team"] { font-weight: 700; }
#rb-adp .rb-adp-c[data-key="__pos"] { display: flex; align-items: center; justify-content: center; }

/* ---------------------------------------------------------------- footer note */
#rb-adp .rb-adp-foot {
	padding: 12px 10px 18px;
	font-size: 12px;
	line-height: 1.5;
	color: #9aa0a8;
}
#rb-adp .rb-adp-foot b { color: #6b7280; font-weight: 600; }

/* ---------------------------------------------------------------- desktop refinements */
@media (min-width: 601px) {
	#rb-adp .rb-adp-list,
	#rb-adp .rb-adp-head { --rb-badgeW: 48px; --rb-nameW: 200px; }
	#rb-adp .rb-adp-row { min-height: 56px; }
	#rb-adp .rb-adp-c { font-size: 14px; }
	#rb-adp .rb-adp-row .rb-adp-nm { font-size: 15px; }
	#rb-adp .rb-adp-controls { padding: 12px 8px; }
	#rb-adp .rb-adp-icon { width: 36px; height: 36px; }
	/* Roomier pills on desktop, but capped — two selects stretched across a 1100px container
	   would read as banners rather than controls. */
	#rb-adp .rb-adp-sel { padding: 10px 28px 10px 14px; font-size: 14px; }
	#rb-adp .rb-adp-field { flex: 0 1 190px; }
	/* Position chip matches the rankings tool's desktop size (.rb-mc-cpos .rb-mc-pos). Scoped to
	   the POS column so the badge's copy — which only appears on horizontal scroll — stays small. */
	#rb-adp .rb-adp-c[data-key="__pos"] .rb-adp-pos-chip {
		font-size: 15px;
		padding: 4px 11px;
		border-radius: 5px;
	}
}
/* Full names fit without clipping once there's room for them. */
@media (min-width: 1000px) {
	#rb-adp .rb-adp-list,
	#rb-adp .rb-adp-head { --rb-nameW: 236px; }
}
