/* BOOK module styles: book-hero, book-table, book-detail. Only site.css variables (with a
   fallback where the design ticket adds a token). Every class here carries the bk- prefix; the
   shared primitives (.chip .state .src .num .tag) get zero-specificity fallbacks through :where()
   so the design system's own rules always win. Motion is transform and opacity only. */

/* ------------------------------------------------------------- primitive fallbacks */

:where(.bk) :where(.num) { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
:where(.bk) :where(.chip) {
  font: 500 13px/1 var(--sans);
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
:where(.bk) :where(.chip[aria-pressed="true"]) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
:where(.bk) :where(.state) {
  display: inline-block;
  font: 500 11.5px/1.5 var(--mono);
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  vertical-align: 1px;
}
:where(.bk) :where(.state[data-state="live"]) { background: color-mix(in srgb, var(--m) 20%, var(--paper)); border-color: transparent; }
:where(.bk) :where(.state[data-state="stale"]) { background: var(--butter, #fff0c2); border-color: transparent; }
:where(.bk) :where(.src) { font-size: 12.5px; color: var(--ink-2); }
.bk-age { white-space: nowrap; }
:where(.bk) :where(.src a) { color: var(--ink); }
:where(.bk) :where(.tag) {
  display: inline-block;
  font: 500 11px/1.6 var(--sans);
  padding: 0 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--v) 12%, var(--paper));
  color: var(--ink);
}

/* ---------------------------------------------------------------------------- shared */

.bk { --bk-ease: cubic-bezier(0.32, 0.72, 0, 1); }
.bk-vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.bk-unread { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.bk-why { font-size: 12.5px; color: var(--ink-2); }
.bk-age { color: var(--ink-2); }
.bk-fail { margin: 0; color: var(--ink-2); }
.bk[aria-busy="true"] > * { opacity: 0.6; }
.bk-sp.bk-in .num,
.bk-sp.bk-out .num,
.bk-hbps.bk-in,
.bk-hbps.bk-out {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
}
.bk-sp.bk-in .num, .bk-hbps.bk-in { background: color-mix(in srgb, var(--m) 18%, var(--paper)); }
.bk-sp.bk-out .num, .bk-hbps.bk-out { background: var(--butter, #fff0c2); }
.bk-route { background: color-mix(in srgb, var(--m) 22%, var(--paper)); }

.bk-ref { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.bk-deriv { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); max-width: 80ch; overflow-wrap: anywhere; }
.bk-best { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); max-width: 70ch; }
.bk-best .num { color: var(--ink); }
.bk-cap { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); max-width: 64ch; }

/* ------------------------------------------------------------------------------ hero */

.bk-hero { container: bkhero / inline-size; }
/* the host's own card gives way only once the bezel is drawn; an unread hero keeps it */
.bk-hero:has(> .bk-shell) { padding: 0; border: 0; background: transparent; }
.bk-hero > .bk-shell { transition: opacity 0.26s var(--bk-ease); }
.bk-hero.bk-fade > .bk-shell { opacity: 0; }
.bk-shell {
  padding: 6px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--v) 12%, var(--paper));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--paper) 70%, transparent),
    0 30px 60px -36px color-mix(in srgb, var(--v) 55%, transparent);
}
.bk-core {
  border-radius: 18px;
  background: var(--paper);
  padding: 20px 22px 18px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--v) 16%, transparent);
}
.bk-htop { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 20px; align-items: flex-start; }
.bk-hname-u { margin: 0; font-size: 14px; color: var(--ink-2); }
.bk-refnum .num { font-size: 18px; color: var(--ink); }
.bk-hero .bk-refnum .num { font-size: clamp(26px, 3.4vw, 38px); font-weight: 400; letter-spacing: -0.03em; }
.bk-pick { display: flex; flex-wrap: wrap; gap: 6px; }

.bk-hrows {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(9em, 12em) minmax(120px, 1fr) auto;
  column-gap: 16px;
}
.bk-hrow, .bk-axis {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  grid-template-areas: "name lane val" "name lane src";
  align-items: center;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.bk-hrows > .bk-hrow:first-child, .bk-axis + .bk-hrow { border-top: 0; }
.bk-hname { grid-area: name; font-size: 14px; }
.bk-issuer { font-weight: 600; }
.bk-label { color: var(--ink-2); }
.bk-hval { grid-area: val; text-align: right; font-size: 15px; white-space: nowrap; }
.bk-hbps { font-family: var(--mono); font-size: 12.5px; }
.bk-hsrc { grid-area: src; text-align: right; }
.bk-lane { grid-area: lane; display: block; height: 28px; }
.bk-track {
  position: relative;
  display: block;
  height: 100%;
  container-type: inline-size;
  background: linear-gradient(to right, transparent calc(50% - 0.5px), color-mix(in srgb, var(--v) 55%, var(--paper)) calc(50% - 0.5px), color-mix(in srgb, var(--v) 55%, var(--paper)) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to right, var(--line), var(--line)) center / 100% 1px no-repeat;
}
.bk-mark {
  position: absolute;
  left: 0;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--v);
  box-shadow: 0 0 0 3px var(--paper);
  transform: translateX(50cqw);
  transition: transform 1.1s var(--bk-ease);
  will-change: transform;
}
.bk-mroute { background: var(--m); }
.bk-mark.bk-still { transition: none; }
.bk-axis { grid-template-areas: ". lane ."; padding: 0 0 4px; border-top: 0; font: 11.5px/1 var(--mono); color: var(--ink-2); }
.bk-axl, .bk-axc, .bk-axr { grid-area: lane; }
.bk-axc { justify-self: center; }
.bk-axr { justify-self: end; }
.bk-open-link { margin: 12px 0 0; font-size: 14px; }

/* ----------------------------------------------------------------------- table, detail */

.bk-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.bk-asof { font-size: 13px; margin: 10px 0 0; }
.bk-group { margin-top: 32px; }
.bk-group[hidden] { display: none; }
.bk-ghead h3 { margin: 0; font-size: 20px; }
.bk-ghead h3 a { text-decoration: none; }
.bk-ghead h3 a:hover { text-decoration: underline; }
.bk-ghead .mono { color: var(--ink-2); font-weight: 400; font-size: 15px; }

.bk-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.bk-table th, .bk-table td { text-align: left; vertical-align: baseline; padding: 10px 12px 10px 0; }
.bk-table thead th { font-size: 12px; font-weight: 500; color: var(--ink-2); padding-top: 0; border-bottom: 1px solid var(--line); }
.bk-table tbody tr { border-bottom: 1px solid var(--line); }
.bk-table tbody tr:last-child { border-bottom: 0; }
.bk-table .bk-px, .bk-table .bk-sp { text-align: right; white-space: nowrap; }
/* an unread reason wraps under the word "unread" instead of widening the price column */
.bk-table .bk-px .bk-why { display: block; white-space: normal; min-width: 12em; }
.bk-name { font-weight: 400; }
.bk-name .tag { margin-left: 2px; }
.bk-dim .bk-issuer, .bk-dim .bk-label { color: var(--ink-2); }
.bk-k { display: none; }
.bk-more { display: none; }
.bk-srccell .state { margin-right: 4px; }
.bk-qh { margin-top: 28px; font-size: 18px; }
.bk-quotes td, .bk-quotes th { white-space: nowrap; }
.bk-event td { vertical-align: top; }

/* a hero card in a half-width column: the source drops under the row */
@container bkhero (max-width: 700px) {
  .bk-hrows { grid-template-columns: minmax(7.5em, 9.5em) minmax(80px, 1fr) auto; column-gap: 12px; }
  .bk-hrow { grid-template-areas: "name lane val" "src src src"; row-gap: 2px; padding: 7px 0; }
  .bk-axis { grid-template-areas: ". lane ."; }
  .bk-hsrc { text-align: left; }
  .bk-hname { font-size: 13.5px; }
}
/* a phone: lanes go full width */
@container bkhero (max-width: 440px) {
  .bk-hrows { grid-template-columns: minmax(0, 1fr) auto; }
  .bk-hrow { grid-template-areas: "name val" "lane lane" "src src"; row-gap: 4px; }
  .bk-axis { grid-template-areas: "lane lane"; }
}

/* phones and tablets: two columns and a row sheet (i2 finding 8), no horizontal scroll; the full
   seven-column table needs about 860 px of content width */
@media (max-width: 1023px) {

  .bk-table, .bk-table tbody, .bk-table tr, .bk-table th, .bk-table td { display: block; }
  .bk-table thead { display: none; }
  .bk-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    padding: 10px 0;
  }
  .bk-table th, .bk-table td { padding: 0; }
  .bk-table .bk-name { grid-column: 1; grid-row: 1 / span 2; overflow-wrap: anywhere; }
  .bk-table .bk-px { grid-column: 2; grid-row: 1; }
  .bk-table .bk-sp { grid-column: 2; grid-row: 2; }
  /* an unread row: "unread" and its reason take a full-width line under the name */
  .bk-table .bk-dim .bk-px { grid-column: 1 / -1; grid-row: 3; padding-top: 4px; text-align: left; white-space: normal; }
  .bk-table .bk-dim .bk-px .bk-why { display: inline; min-width: 0; }
  .bk-table .bk-x { grid-column: 1 / -1; display: none; padding-top: 6px; overflow-wrap: anywhere; }
  .bk-table .bk-open .bk-x { display: block; }
  .bk-k { display: inline; font-size: 12px; color: var(--ink-2); margin-right: 6px; }
  .bk-more {
    display: inline-block;
    margin: 6px 0 0;
    padding: 4px 10px;
    font: 500 12px/1.4 var(--sans);
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
  }
  .bk-open .bk-more { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .bk .src { white-space: normal; }
  .bk-event tbody tr { grid-template-columns: 1fr; row-gap: 4px; }
  .bk-event th, .bk-event td { grid-column: 1 !important; grid-row: auto !important; }
  .bk-quotes tbody tr { grid-template-columns: 1fr; row-gap: 2px; }
  .bk-quotes .bk-k { display: inline; }
  .bk-quotes th, .bk-quotes td { grid-column: 1 !important; grid-row: auto !important; white-space: normal; text-align: left; }
}

html.reduced-motion .bk-mark,
html.reduced-motion .bk-hero > .bk-shell { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .bk-mark, .bk-hero > .bk-shell { transition: none; }
}
