/* CVAR Index page, on top of the site's style.css: one card with a plain heading, a toolbar that stays under the top
   bar, and a table whose column headings stay under the toolbar (--tb-h is the toolbar's height, set by cvars.js). */

.card.idx { padding: 18px 20px 12px; }
.idx-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 4px; }
.idx-head h1 { margin: 0; font: 600 22px/1.25 var(--body); letter-spacing: -0.01em; text-transform: none; }
.idx-spec { margin: 0; font: 500 12.5px/1.5 var(--mono); color: var(--muted); }

/* toolbar */
.tb {
  position: sticky; top: calc(var(--bar-h) - 1px); z-index: 6; background: var(--panel);
  margin: 0 -20px; padding: 10px 20px; border-bottom: 1px solid var(--line);
}
.tb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-row + .tb-row { margin-top: 8px; }
.search { position: relative; flex: 1 1 340px; min-width: 0; }
.search svg {
  position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; pointer-events: none;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
.search input, .tb-sel select, .tb-btn {
  height: 34px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); color: var(--fg);
}
.search input { width: 100%; padding: 0 36px 0 33px; font: 400 13.5px var(--mono); }
.search input::placeholder { color: var(--muted); opacity: 0.8; white-space: pre; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search input:focus, .tb-sel select:focus { border-color: var(--accent); }
.search input.bad { border-color: var(--caution); }
.search kbd, .help kbd {
  padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; font: 500 11.5px/1.6 var(--mono); color: var(--muted);
}
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

.tb-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 11px; cursor: pointer; white-space: nowrap;
  font: 500 13px var(--body);
}
.tb-btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.tb-btn[aria-expanded="true"], .tb-btn.active { border-color: var(--accent); }
.tb-btn.copied { border-color: var(--ok); color: var(--ok); }
.fx-n:empty { display: none; }
.fx-n { padding: 0 5px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font: 600 11px/1.55 var(--mono); }
.tb-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tb-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tb-sel { display: inline-flex; align-items: center; gap: 7px; }
.tb-sel > span:first-child { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sel { position: relative; display: block; }
.sel::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; margin-top: -5px; pointer-events: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg);
}
.tb-sel select { appearance: none; -webkit-appearance: none; padding: 0 30px 0 10px; cursor: pointer; font: 500 13px var(--body); }
.tb-sel select option { background: var(--panel); color: var(--fg); }

.facets { display: flex; flex-wrap: wrap; gap: 6px; }
.count { margin: 0 0 0 auto; font: 400 12.5px/1.4 var(--mono); color: var(--muted); }
.count b { color: var(--fg); font-weight: 600; }
.count .err { color: var(--caution); }
.count button, .chip-clear, .fx-top button {
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.count button:hover, .chip-clear:hover, .fx-top button:hover { text-decoration-thickness: 2px; }
.tb-out { display: flex; gap: 6px; }

/* the filters in force, each one a button that removes it */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--fg); font: 400 12.5px var(--body);
}
.chip:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.chip-k { color: var(--muted); }
.chip-op { font: 600 12.5px var(--mono); color: var(--accent); }
.chip.not .chip-op { color: var(--caution); }
.chip code { font: 500 12px var(--mono); }
.chip-x { margin-left: 2px; color: var(--muted); font-size: 14px; line-height: 1; }
.chips .or { font: 400 11.5px var(--mono); color: var(--muted); }
.chip-clear { margin-left: 4px; font-size: 12.5px; }

/* popovers: Syntax and the filters */
.pop { position: relative; }
.pop-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 300px; max-width: calc(100vw - 32px);
  max-height: min(72vh, 600px); overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 18px 44px -18px rgb(0 0 0 / 0.6);
}
.help { left: auto; right: 0; width: 430px; padding: 8px 10px; }
.help table { border-collapse: collapse; width: 100%; }
.help td { padding: 4px 6px; vertical-align: top; font-size: 13px; }
.help td:first-child { white-space: nowrap; }
.help td:last-child { color: var(--muted); }
.help code { font: 500 12.5px var(--mono); color: var(--fg); }
.fx-panel { width: 340px; }
.fx-top {
  display: flex; justify-content: space-between; gap: 12px; padding: 4px 8px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line); font: 400 11.5px/1.5 var(--mono); color: var(--muted);
}
.fx-top button { font-size: 12px; }
.fx-list { list-style: none; margin: 0; padding: 0; }
.fx-v { display: flex; align-items: flex-start; gap: 4px; margin: 0; }
.fx-v label {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 15px minmax(0, 1fr) auto; align-items: start; gap: 9px;
  padding: 5px 6px 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px;
}
.fx-v label:hover { background: var(--panel-2); }
.fx-v input { width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.fx-l { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.fx-l code { font: 500 12.5px/1.6 var(--mono); }
.fx-note { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.fx-c { font: 500 11.5px/1.7 var(--mono); color: var(--muted); }
.fx-v.zero:not(.on):not(.off) label { opacity: 0.45; }
.fx-v.off .fx-l > :first-child { color: var(--muted); text-decoration: line-through; }
.fx-x {
  flex: none; height: 24px; margin-top: 3px; padding: 0 7px; cursor: pointer; border: 1px solid var(--line); border-radius: 5px;
  background: none; color: var(--muted); font: 500 11.5px/1 var(--mono);
}
.fx-x:hover { border-color: color-mix(in srgb, var(--caution) 45%, var(--line)); color: var(--fg); }
.fx-x[aria-pressed="true"] {
  color: var(--caution); border-color: color-mix(in srgb, var(--caution) 45%, var(--line));
  background: color-mix(in srgb, var(--caution) 12%, transparent);
}

/* the table (style.css styles every table, th, td and code: undone here) */
.idx code { padding: 0; border: 0; border-radius: 0; background: none; font-size: inherit; white-space: normal; }
.idx table td, .idx table th { white-space: normal; font-weight: inherit; }
.idx tbody tr:hover { background: none; }
.help td { border: 0; }
.tbl { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.w-name { width: 31%; }
.w-def { width: 12%; }
.w-flags { width: 15%; }
.tbl th, .tbl td { text-align: left; vertical-align: top; }
.tbl thead th {
  position: sticky; top: calc(var(--bar-h) - 1px + var(--tb-h, 98px)); z-index: 4; background: var(--panel);
  padding: 8px 12px 7px 0; border-bottom: 1px solid var(--line);
  font: 600 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.tbl thead th:first-child { padding-left: 22px; }
.cv > td { padding: 7px 12px 7px 0; border-top: 1px solid var(--line); }
.cv > td:first-child { position: relative; padding-left: 22px; padding-right: 30px; }
.cv > td:last-child { padding-right: 8px; }
.tbl tbody > tr:first-child > * { border-top: 0; }
/* the rest of the rows as plain HTML, there until cvars.js runs: laid out only near the screen */
.idx-chunk { content-visibility: auto; contain-intrinsic-size: auto 9000px; }
.idx-chunk .tbl tbody > tr:first-child > * { border-top: 1px solid var(--line); }
.cv { cursor: pointer; }
.cv:hover > td { background: var(--panel-2); }
.cv.open > td, .cv-x > td { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.cv.hl > td { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
/* a caret that turns when the row is open */
.cv > td:first-child::before {
  content: ""; position: absolute; left: 7px; top: 14px; width: 5px; height: 5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg);
}
.cv.open > td:first-child::before { transform: rotate(45deg); top: 12px; }

.nm {
  display: inline; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  color: var(--fg); font: 500 13px/1.5 var(--mono); overflow-wrap: anywhere;
}
.nm:hover { color: var(--accent); }
.cp, .x-copy {
  display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; margin: -2px 0 -4px 4px; vertical-align: top;
  cursor: copy; border: 1px solid transparent; border-radius: 5px; background: none; color: var(--muted);
}
.cp svg, .x-copy svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.cp:hover, .x-copy:hover { color: var(--fg); border-color: var(--line); background: var(--panel); }
.cp.copied, .x-copy.copied { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.cp { position: absolute; top: 6px; right: 6px; margin: 0; opacity: 0; }
.cv:hover .cp, .cv:focus-within .cp, .cp.copied { opacity: 1; }
@media (hover: none) { .cp { opacity: 0.7; } }

.c-def { font: 400 12.5px/1.5 var(--mono); overflow-wrap: anywhere; }
.c-def code { font: inherit; color: var(--fg); }
.c-def .gi, .c-def .rg { display: block; font-size: 11.5px; color: var(--muted); }
.c-def .gi code { color: var(--teal); }
.c-flags { font: 500 11.5px/1.75 var(--mono); color: var(--muted); }
.fl { white-space: nowrap; }
.c-flags .fl { white-space: normal; }
.f-archive { color: var(--teal); }
.f-cheat { color: var(--caution); }
.f-replicated { color: var(--note); }
.f-gameinfo_cannot_override { color: var(--important); }
.c-desc { font-size: 13.5px; line-height: 1.5; }
.na { color: var(--muted); }
.tbl mark { padding: 0; border-radius: 2px; background: color-mix(in srgb, var(--accent) 32%, transparent); color: inherit; }

.tbl .grp > th {
  padding: 18px 8px 6px 22px; border-bottom: 1px solid var(--line);
  font: 600 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg);
}
.tbl .grp > th small { margin-left: 6px; font-weight: 500; color: var(--muted); }
.grp + .cv > td { border-top: 0; }

/* an open row */
.cv-x > td { padding: 2px 8px 14px 22px; }
.xd { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 13px; }
.xd dt { padding-top: 2px; font: 500 12px/1.6 var(--mono); color: var(--muted); }
.xd dd { margin: 0; min-width: 0; line-height: 1.6; }
.xd dd > code, .xd .x-flag code { font: 500 12.5px var(--mono); }
.x-line {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%; padding: 1px 2px 1px 8px; vertical-align: middle;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2);
}
.x-line code { font: 500 12.5px/1.6 var(--mono); overflow-wrap: anywhere; }
.x-line .x-copy { margin: 0; }
.x-note { margin-left: 10px; color: var(--muted); }
.x-flag { display: block; }
.xd a { font: 500 12.5px var(--mono); }
.xd dd > .x-copy { margin: 0 0 0 6px; vertical-align: middle; }

.idx-empty { padding: 28px 0 12px; text-align: center; color: var(--muted); }
.idx-empty p { margin-bottom: 12px; }
.idx-more { height: 1px; }

@media (max-width: 760px) {
  .card.idx { padding: 14px 14px 8px; }
  .tb { position: relative; top: auto; margin: 0 -14px; padding: 10px 14px; }
  .pop { position: static; }
  .pop-panel { left: 14px; right: 14px; width: auto; min-width: 0; }
  .search { flex-basis: 100%; }
  .search kbd { display: none; }
  .search input { padding-right: 10px; font-size: 16px; }
  .count { flex-basis: 100%; order: 3; margin: 2px 0 0; }
  .tb-sel { margin-left: auto; }
  .tbl, .tbl tbody { display: block; }
  .tbl thead, .tbl colgroup { display: none; }
  .cv {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "name name" "def flags" "desc desc";
    column-gap: 12px; padding: 10px 0 10px 20px; border-top: 1px solid var(--line); position: relative;
  }
  .tbl tbody > tr.cv:first-child { border-top: 0; }
  .cv > td, .cv > td:first-child, .cv > td:last-child { padding: 0; border: 0; position: static; background: none !important; }
  .cv.open, .cv-x { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
  .cv.hl { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
  .cv > td:first-child::before { left: 5px; top: 18px; }
  .cv.open > td:first-child::before { top: 16px; }
  .c-name { grid-area: name; }
  .c-def { grid-area: def; display: flex; flex-wrap: wrap; gap: 0 8px; margin-top: 3px; }
  .c-def .gi, .c-def .rg { display: inline; }
  .c-flags { grid-area: flags; margin-top: 3px; }
  .c-desc { grid-area: desc; margin-top: 4px; }
  .cv-x, .grp { display: block; }
  .cv-x > td, .grp > th { display: block; }
  .cv-x > td { padding: 0 8px 14px 20px; background: none; }
  .xd { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .xd dt { padding-top: 8px; }
}
