/* The best-in-slot pages: /bis, /bis/<class> and /bis/<class>/<spec>.
 *
 * Loaded through the head_extra block of those pages only, after pq.css and shell.css.  pq.css is
 * the design system the companion windows embed byte for byte, so nothing the lists need is added
 * to it; everything new is here, under .bis-*.  The paper doll itself is pq.css's own
 * (.look-doll, .doll-*, .look-stats), drawn by the same macro as the character sheet
 * (partials/doll.html) -- the only things this file adds to it are what a doll square that is a
 * link needs (a.doll-item) and the class crest in the middle of the figure.
 *
 * Colours go through the site's custom properties with fallbacks, so the pages follow whatever
 * palette the shell sets.  Item quality is never colour alone: every row prints the word.
 */

.bis,
.bis-index {
  --bis-panel: var(--bg-raised, #101725);
  --bis-inset: var(--bg-inset, #080c14);
  --bis-line: var(--border, #1d2739);
  --bis-line-strong: var(--border-strong, #2d3b54);
  --bis-text: var(--text, #d8dfec);
  --bis-dim: var(--text-dim, #a2afc5);
  --bis-faint: var(--text-faint, #8190a9);
  --bis-heading: var(--heading, #e6b422);
  --bis-gold-dim: var(--gold-dim, #8f7016);
  --bis-good: #5fd35f;
}

/* ----------------------------------------------------------------- the class colours
 * The client's own ChrClasses colours.  A rim and a tile edge, never the only carrier of a class:
 * the name is always text.  tests/test_bis_pages.py holds these to the data file. */
.bis-c-warrior { --bis-class: #c69b6d; }
.bis-c-paladin { --bis-class: #f48cba; }
.bis-c-hunter { --bis-class: #aad372; }
.bis-c-rogue { --bis-class: #fff468; }
.bis-c-priest { --bis-class: #ffffff; }
.bis-c-death-knight { --bis-class: #c41e3a; }
.bis-c-shaman { --bis-class: #0070dd; }
.bis-c-mage { --bis-class: #3fc7eb; }
.bis-c-warlock { --bis-class: #8788ee; }
.bis-c-monk { --bis-class: #00ff98; }
.bis-c-druid { --bis-class: #ff7c0a; }

/* ------------------------------------------------------------------- doll squares as links
 * pq.css gives an <a> its link colour and underline; a square that is a link keeps the look of the
 * character sheet's square, and says it is one by its edge. */
a.doll-item {
  color: inherit;
  text-decoration: none;
}
a.doll-item:visited { color: inherit; }
a.doll-item:hover,
a.doll-item:focus-visible {
  border-color: var(--gold-dim, #8f7016);
  background: var(--bg-raised, #101725);
  color: inherit;
}
.tip-line.is-dim { color: var(--text-faint, #8190a9); }
/* A square's second line is one short source; it is cut, not wrapped, so the doll keeps its shape. */
.bis-doll .doll-text .basis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
/* ...and cut it must be: a column of squares is one track no wider than the doll's column, and a
 * square's text takes what the icon leaves.  Without these the list's implicit `auto` track grew to
 * the longest unwrapped name or source and pushed the page sideways (320 px, and 600-1024 px where
 * the three columns stand).  Here, not in pq.css, which stays the companion's copy byte for byte. */
.bis-doll .doll-list { grid-template-columns: minmax(0, 1fr); }
.bis-doll .doll-slot { min-width: 0; }
.bis-doll .doll-text { flex: 1 1 0; min-width: 0; }
.bis-doll .doll-item-name { max-width: 100%; }

/* ---------------------------------------------------------------------- icons */

.bis-icon {
  flex: 0 0 auto;
  box-sizing: border-box;
  border-radius: 4px;
  border: 1px solid var(--bis-line-strong);
  background: var(--bis-inset);
  object-fit: cover;
  vertical-align: middle;
}
.bis-sm { width: 24px; height: 24px; }
.bis-md { width: 40px; height: 40px; border-radius: 6px; }
.bis-lg { width: 64px; height: 64px; border-radius: 8px; }
.bis-icon.is-placeholder {
  display: inline-grid;
  place-items: center;
  color: var(--bis-faint);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.bis-lg.is-placeholder { font-size: 1rem; }

/* Item quality, the game's own colours (the same ones as .q1 .. .q7 in pq.css). */
.bis-q0 { color: #b0b0b0; }
.bis-q1 { color: #f2f3f8; }
.bis-q2 { color: #4ce04c; }
.bis-q3 { color: #4ea6ff; }
.bis-q4 { color: #c88bf5; }
.bis-q5 { color: #ff9d33; }
.bis-q6 { color: #e6cc80; }
.bis-q7 { color: #4fd6ff; }

/* --------------------------------------------------------------- the choosers */

.bis-choosers {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--bis-panel);
  border: 1px solid var(--bis-line);
  border-radius: 10px;
}
.bis-chiplist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bis-chiplist a,
.bis-chiplist .is-disabled {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  border: 1px solid var(--bis-line);
  border-radius: 999px;
  color: var(--bis-dim);
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}
.bis-chiplist a:hover { color: var(--bis-text); border-color: var(--bis-line-strong); }
.bis-chiplist a[aria-current] {
  color: var(--bis-heading);
  border-color: var(--bis-gold-dim);
  background: var(--bis-inset);
}
.bis-chiplist .is-disabled { opacity: 0.6; border-style: dashed; cursor: not-allowed; }
.bis-chiplist .basis { font-size: 0.78rem; }
.bis-reviewed { color: var(--bis-good); font-size: 0.78rem; }

/* ---------------------------------------------------------------------- the head */

.bis-head { margin: 1rem 0; }
.bis-head h1 { margin: 0 0 0.4rem; font-size: 1.6rem; }
.bis-head .lede { max-width: 70ch; color: var(--bis-dim); margin: 0 0 0.75rem; }
.bis-filters { display: grid; gap: 0.5rem; margin: 0.75rem 0; }
.bis-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: center;
}
.bis-filter-label {
  min-width: 7rem;
  color: var(--bis-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bis-notice {
  max-width: 70ch;
  margin: 0.75rem 0;
}
.bis-note { max-width: 78ch; }

/* ----------------------------------------------------------- the figure and the set */

.bis-set { margin-top: 1rem; }
.bis-crest {
  grid-area: figure;
  margin: 0;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.35rem;
  padding: 1rem 0.75rem;
  text-align: center;
  align-self: stretch;
  border: 2px solid var(--bis-class, var(--bis-line-strong));
  border-radius: var(--radius, 10px);
  background:
    radial-gradient(ellipse 70% 45% at 50% 40%, rgba(230, 180, 34, 0.1), rgba(0, 0, 0, 0) 70%),
    var(--bis-inset);
}
.bis-crest-icons { display: flex; align-items: center; gap: 0.5rem; }
/* With a 3D figure the crest is the figure's frame: a 3:4 portrait, the class's icons centred in it
   until the figure is drawn over them (pq.css's .look-model). */
.bis-crest.has-model { align-content: start; padding: 0.5rem; }
.bis-model { width: 100%; aspect-ratio: 3 / 4; display: grid; place-items: center; }
/* While the figure is being drawn (partials/bis_figure.html asks for itself again until it is): a
   small turning ring before the words, still for a reader who asked for less motion. */
.bis-figure-drawing::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.4em;
  vertical-align: -0.08em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: bis-figure-turn 0.9s linear infinite;
}
@keyframes bis-figure-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bis-figure-drawing::before { animation: none; } }
.bis-crest-name { margin: 0; color: var(--bis-heading); font-weight: 700; }
.bis-crest-line { margin: 0; color: var(--bis-dim); font-size: 0.85rem; }

.bis-jump {
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--bis-panel);
  border: 1px solid var(--bis-line);
  border-radius: 10px;
}
.bis-jump-title { margin: 0 0 0.35rem; color: var(--bis-faint); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* -------------------------------------------------------------------- the lists
 * One row per item: the rank, the icon, the name, the item level and the first source -- one line
 * where the page is wide, two where it is not.  The rest of the item is its details card, .bis-tip,
 * which follows the doll's (.doll-tip in pq.css): shown while the row is pointed at or holds the
 * keyboard focus, by CSS alone.  It is hidden by clipping rather than display: none because it holds
 * links (partials/bis_slot.html says why); when shown it hangs below the row, over the level and
 * source columns on a wide page so the names of the rows below stay in reach of the pointer. */

.bis-slot { margin-top: 1rem; scroll-margin-top: 4rem; }
.bis-rows {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  background: var(--bis-inset);
  border: 1px solid var(--bis-line);
  border-radius: 8px;
}
.bis-row {
  position: relative;
  display: grid;
  grid-template-columns: 2.2rem 32px auto minmax(0, 1fr);
  grid-template-areas:
    "rank icon name name"
    "rank icon ilvl src";
  gap: 0 0.6rem;
  align-items: center;
  padding: 0.35rem 0.6rem;
  line-height: 1.3;
}
.bis-row + .bis-row { border-top: 1px solid var(--bis-line); }
.bis-row:first-child { border-radius: 7px 7px 0 0; }
.bis-row:last-child { border-radius: 0 0 7px 7px; }
.bis-row:only-child { border-radius: 7px; }
.bis-row:hover,
.bis-row:focus-within { background: var(--bis-panel); }
.bis-row.is-best { box-shadow: inset 3px 0 0 var(--bis-gold-dim); }
.bis-rank {
  grid-area: rank;
  display: grid;
  place-items: center;
  color: var(--bis-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.bis-badge {
  padding: 0.1rem 0.35rem;
  color: #1a1305;
  background: var(--bis-heading);
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.bis-row > .bis-icon { grid-area: icon; width: 32px; height: 32px; border-radius: 5px; }
.bis-main { grid-area: name; min-width: 0; }
.bis-name { font-weight: 700; text-decoration: none; }
.bis-name:hover { text-decoration: underline; }
.bis-ilvl {
  grid-area: ilvl;
  color: var(--bis-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bis-src {
  grid-area: src;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bis-faint);
  font-size: 0.85rem;
}
.bis-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.45rem;
  border: 1px solid var(--bis-line-strong);
  border-radius: 999px;
  color: var(--bis-dim);
  font-size: 0.72rem;
  font-weight: 400;
  vertical-align: 0.1em;
}

/* The details card, hidden: the .sr-only technique, so it is read and its links are reachable. */
.bis-tip {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
/* ... and shown, as the doll's card is: below the row, over the rows after it. */
.bis-row:hover > .bis-tip,
.bis-row:focus-within > .bis-tip {
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.6rem 0.7rem;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  background: var(--bg-raised, #101725);
  border: 1px solid var(--border-strong, #2d3b54);
  border-radius: var(--radius-sm, 6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-size: 0.88rem;
}
.bis-tip-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
.bis-tip p { margin: 0; }
.bis-tip-name { font-weight: 700; }
.bis-line { display: flex; flex-wrap: wrap; gap: 0.1rem 0.6rem; align-items: baseline; }
.bis-quality { font-size: 0.78rem; }
.bis-level { color: var(--bis-dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.bis-meta,
.bis-stats,
.bis-sockets { color: var(--bis-dim); }
/* Stats and versions in columns, two where the card is wide enough and one where it is not, rather
   than a run that wraps anywhere. */
.bis-stats,
.bis-versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 0 1rem; }
.bis-stats b { color: var(--bis-text); font-variant-numeric: tabular-nums; }
.bis-sources { margin: 0; padding: 0; list-style: none; }
.bis-sources li { color: var(--bis-text); }
.bis-label {
  color: var(--bis-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.35rem;
}
.bis-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.bis-tags li {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--bis-line-strong);
  border-radius: 999px;
  color: var(--bis-dim);
  font-size: 0.78rem;
}
.bis-versions { color: var(--bis-faint); font-size: 0.82rem; }
.bis-versions .bis-label { grid-column: 1 / -1; }
.bis-versions .is-shown { color: var(--bis-text); font-weight: 700; }
.bis-warn { color: var(--warn, #ffcc66); font-size: 0.85rem; }

/* A wide page: one line per row, the columns lined up from row to row, and the card under the
   level and source columns. */
@media (min-width: 52rem) {
  .bis-row {
    grid-template-columns: 2.2rem 32px minmax(0, clamp(15rem, 36vw, 22rem)) 5.5rem minmax(0, 1fr);
    grid-template-areas: "rank icon name ilvl src";
  }
  .bis-row:hover > .bis-tip,
  .bis-row:focus-within > .bis-tip {
    grid-column: ilvl-start / src-end;
    right: auto;
    width: min(27rem, 100%);
  }
}

/* ----------------------------------------------- enchants, gems and consumables */

.bis-picks-grid {
  display: grid;
  gap: 0.75rem 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  margin-top: 0.5rem;
}
.bis-picks-grid h3 { margin: 0 0 0.25rem; font-size: 0.95rem; }
.bis-picklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.35rem; }
.bis-picklist li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 0.5rem;
  align-items: center;
}
.bis-picklist .bis-icon { grid-row: span 2; }
.bis-picklist li.no-icon { grid-template-columns: minmax(0, 1fr); }
.bis-pick-text { color: var(--bis-dim); font-size: 0.85rem; }

/* ------------------------------------------------------------ the method note */

.bis-method { margin-top: 1rem; }
.bis-method ul { padding-left: 1.1rem; }
.bis-method li { margin-bottom: 0.5rem; max-width: 78ch; }
.bis-weights { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0.25rem 0; padding: 0; list-style: none; }
.bis-weights li { margin: 0; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ the class chooser */

.bis-tiles {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}
.bis-tile {
  display: grid;
  gap: 0.6rem;
  align-content: start;
  padding: 1rem 1.1rem;
  background: var(--bis-panel);
  border: 1px solid var(--bis-line);
  border-top: 3px solid var(--bis-class, var(--bis-line-strong));
  border-radius: var(--radius, 10px);
}
.bis-tile:hover { border-color: var(--bis-gold-dim); border-top-color: var(--bis-class, var(--bis-gold-dim)); }
.bis-tile h2 { display: flex; align-items: center; gap: 0.6rem; margin: 0; font-size: 1.2rem; }
.bis-tile h2 a { text-decoration: none; }
.bis-tile .basis { margin: 0; font-size: 0.82rem; }

@media (max-width: 30rem) {
  .bis-row { grid-template-columns: 1.9rem 32px auto minmax(0, 1fr); gap: 0 0.5rem; padding: 0.35rem 0.45rem; }
  .bis-name { font-size: 0.95rem; }
  .bis-md { width: 36px; height: 36px; }
  .bis-filter-label { flex-basis: 100%; }
}

@media print {
  .bis-choosers, .bis-jump, .bis-filters { display: none !important; }
  .bis-tiles, .bis-rows { break-inside: auto; }
  /* On paper there is no pointer: each row's card is printed under it. */
  .bis-tip {
    position: static;
    grid-column: name-start / -1;
    width: auto;
    height: auto;
    margin: 0.2rem 0 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
  }
  .bis-tip-name { display: none; }
}

/* A row's own "report this item" link, the last line of its card: small, quiet, and not in print.
   It goes to /contribute with the list and the item filled in. */
.bis-report { margin: 0.15rem 0 0; font-size: 0.78rem; }
.bis-report a { color: var(--text-faint, #7d8399); text-decoration: underline dotted; }
.bis-report a:hover, .bis-report a:focus-visible { color: var(--text, #e7e9f2); }
@media print { .bis-report { display: none !important; } }
