/* QB detail panel (qb-panel.js). Docked to the right of the tab's content from 64rem, over the
   page from the right with a dim backdrop from 48rem, a bottom sheet below. It always starts
   under the sticky strip, never over it. Colours are the page's (qb-ranking.css); only transform
   and opacity are animated, and with reduced motion nothing moves. */

.qb {
  --qb-detail-w: 22rem;
}

/* The tab's content and the panel share one grid: a docked panel narrows the content once. */
.qb-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.qb-body > #qb-panel {
  grid-area: 1 / 1;
}
.qb-body[data-docked] {
  grid-template-columns: minmax(0, 1fr) var(--qb-detail-w);
  column-gap: var(--space-3);
}

.qb-detail {
  z-index: 18;
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-main);
  background: var(--dark-800, #19191e);
  color: var(--text);
}
.qb-detail_scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 var(--space-3) var(--space-3);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Docked: in the grid's second column, sticky under the strip, its own scroll when taller. */
.qb-detail[data-mode='docked'] {
  grid-area: 1 / 2;
  position: sticky;
  top: calc(var(--qb-top, 0px) + var(--qb-strip-h, 0px) + var(--space-3));
  max-height: calc(100dvh - var(--qb-top, 0px) - var(--qb-strip-h, 0px) - 2 * var(--space-3));
}

/* Over the page: fixed under the strip, from the right; the page behind is dimmed and still. */
.qb-detail[data-mode='overlay'] {
  position: fixed;
  top: calc(var(--qb-detail-top, 0px) + 0.5rem);
  right: 0.5rem;
  bottom: 0.5rem;
  width: min(24rem, calc(100vw - 1rem));
  box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 0.55);
}
.qb-detail[data-mode='sheet'] {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(85dvh, calc(100dvh - var(--qb-detail-top, 0px) - 0.5rem));
  padding-bottom: env(safe-area-inset-bottom);
  border-width: var(--border-width) 0 0;
  border-radius: var(--radius-main) var(--radius-main) 0 0;
  box-shadow: 0 -1rem 2.5rem rgb(0 0 0 / 0.55);
}
.qb-detail_backdrop {
  position: fixed;
  inset: var(--qb-detail-top, 0px) 0 0 0;
  z-index: 17;
  background: rgb(0 0 0 / 0.6);
}
:root:has(.qb-detail[aria-modal='true']:not([hidden])) {
  overflow: hidden;
}
/* The site's back-to-top button would sit on the panel's corner: away while the panel is open. */
:root:has(.qb-detail:not([hidden])) .lab-top {
  opacity: 0;
  visibility: hidden;
}

/* ---- header: ‹ › and ×, rank, name, score -------------------------------------------------- */
.qb-detail_top {
  flex: none;
  position: relative;
  z-index: 1;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid var(--border);
  border-radius: inherit;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  background: var(--dark-800, #19191e);
}
/* Once the body is scrolled, a soft shadow under the fixed header. */
.qb-detail_top[data-scrolled] {
  box-shadow: 0 0.5rem 1rem -0.5rem rgb(0 0 0 / 0.7);
}
.qb-detail_bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.qb-detail_steps {
  display: flex;
  gap: 0.375rem;
}
.qb-detail_grip {
  display: none;
}
.qb-detail[data-mode='sheet'] .qb-detail_bar {
  position: relative;
  padding-top: 0.5rem;
  touch-action: none;
}
.qb-detail[data-mode='sheet'] .qb-detail_grip {
  position: absolute;
  top: -0.25rem;
  left: 50%;
  display: block;
  width: 2.5rem;
  height: 0.25rem;
  margin-left: -1.25rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--text) 25%, transparent);
}
.qb-detail_icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: var(--border-width) solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.16s ease;
}
.qb-detail_icon svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.qb-detail_head {
  padding-top: var(--space-2);
}
.qb .qb-detail_rank {
  margin: 0;
  line-height: 1.3;
}
.qb .qb-detail_name {
  margin: 0.375rem 0 0;
  font: 600 1.5rem / 1.2 var(--display-family);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.qb-detail_name .qb-team {
  font-weight: 500;
}
/* The heading takes focus on open so a screen reader starts there; it is not a control. */
.qb-detail_name:focus {
  outline: none;
}
.qb .qb-detail_score {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0.375rem 0 0;
}
.qb-detail_big {
  font: 600 2rem / 1 var(--display-family);
}
.qb-detail_unit {
  display: grid;
  color: var(--text-2);
  font-size: 0.75rem;
  line-height: 1.35;
}
.qb-detail_label {
  color: var(--text);
  font-weight: 600;
}

/* ---- actions: Compare (a toggle with a check) and Open profile ------------------------------ */
.qb-detail_actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}
.qb-detail_compare,
.qb-detail_profile {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem 0 0.875rem;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-round);
  background: color-mix(in srgb, var(--brand-500) 5%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease;
}
.qb-detail_compare[aria-pressed='true'] {
  border-color: color-mix(in srgb, var(--brand-500) 60%, transparent);
  background: color-mix(in srgb, var(--brand-500) 12%, transparent);
}
.qb-detail_compare[aria-pressed='true'] .qb-pick_check {
  border-color: var(--qb-good);
  background: var(--qb-good);
}
.qb-detail_compare[aria-pressed='true'] .qb-pick_check svg {
  opacity: 1;
  transform: none;
}
.qb-detail_profile {
  padding-inline: 1rem;
  color: var(--qb-good);
}
.qb-detail_arrow {
  display: inline-block;
  margin-left: 0.25rem;
  transition: transform 0.2s var(--qb-ease);
}
.qb-detail_profile:hover .qb-detail_arrow {
  transform: translateX(0.1875rem);
}
/* Hover, focus and disabled states: the shared button system in qb-ranking.css. */
:is(.qb-detail_icon, .qb-detail_compare, .qb-detail_profile):active {
  transform: scale(0.95);
}

/* ---- body ------------------------------------------------------------------------------------ */
/* This week: the move vs last week on its own line, so the chevron stays by the heading. */
.qb-detail .qb-week summary .qb-week_icon {
  margin-left: auto;
}
.qb-detail .qb-week_move {
  order: 2;
  flex-basis: 100%;
  margin-left: 0;
}
.qb-detail .qb-prof_type {
  margin-top: 0;
}
.qb .qb-detail_h {
  margin: var(--space-3) 0 0;
  color: var(--text-2);
  font: 600 0.8125rem / 1.3 var(--display-family);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.qb-detail .qb-parts {
  margin-top: var(--space-2);
}
.qb-detail .qb-parts li {
  grid-template-columns: 7rem minmax(0, 1fr) 3rem;
}
.qb-detail_km {
  display: grid;
  margin: 0;
}
.qb-detail_km > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.375rem 0;
  border-top: var(--border-width) solid var(--border);
}
.qb-detail_km > div:first-child {
  border-top: 0;
}
.qb-detail_km dt {
  color: var(--text-2);
}
.qb-detail_km dd {
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}
.qb-detail_km .qb-muted {
  font-weight: 400;
}

/* ---- his row and his dot, while the panel shows him ---------------------------------------- */
.qb-table tbody tr.qb-detail-on > * {
  background: color-mix(in srgb, var(--brand-500) 14%, var(--background));
}
.qb-table tbody tr.qb-detail-on > :first-child {
  box-shadow: inset 4px 0 0 var(--qb-good);
}
.qb-chart svg[data-active] .qb-dot.qb-detail-on,
.qb-chart svg[data-picked] .qb-dot.qb-detail-on {
  opacity: 1;
}
.qb-dot.qb-detail-on .qb-dot_ring {
  opacity: 1;
  stroke: var(--qb-good);
  stroke-width: 2.5;
}
.qb-dot.qb-detail-on .qb-dot_mark {
  transform: scale(1.6);
}
.qb-dot.qb-detail-on .qb-dot_label,
.qb-chart svg[data-narrow] .qb-dot.qb-detail-on .qb-dot_label {
  display: inline;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .qb-detail_profile:hover .qb-detail_arrow {
    transform: none;
  }
}
