/* Open GPU DB — workstation layout. Theme variables are set by themes.mjs;
   the defaults below are the house "Open GPU" palette so the page renders
   correctly before scripts run (and without JavaScript). */
:root {
  --bg: #101318;
  --panel: #161a21;
  --raised: #1c212a;
  --line: #262c37;
  --ink: #e8eaf0;
  --muted: #8a93a5;
  --faint: #5b6372;
  --accent: #d9a441;

  --vendor-nvidia: #76b900;
  --vendor-amd: #e5443d;
  --vendor-intel: #2f7fd3;
  --vendor-apple: #a2a2a7;
  --vendor-matrox: #7a5cd6;
  --vendor-3dfx: #e08a2e;
  --vendor-sony: #c96bb5;
  --vendor-xgi: #4ec0b2;

  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }

[hidden] { display: none !important; }

html { height: 100%; }

body {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--ui);
}

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 20;
  background: var(--accent);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 0 0 6px 6px;
  font-weight: 600;
  text-decoration: none;
  transition: top .15s;
}

.skip-link:focus { top: 0; }

/* ---- Top bar ---- */

.top-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 54px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
}

.brand { text-decoration: none; flex: none; }

.wordmark { font: 600 13px/1 var(--mono); letter-spacing: .14em; white-space: nowrap; }
.wordmark b { color: var(--accent); font-weight: 600; }

.search-wrap { flex: 1; max-width: 560px; position: relative; }

.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: 500 14px var(--ui);
  padding: 8px 38px 8px 12px;
}

.search-wrap input::placeholder { color: var(--faint); }
.search-wrap input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.search-wrap kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font: 500 11px var(--mono);
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}

.catalog-count {
  margin-left: auto;
  font: 500 12px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.catalog-count span { color: var(--ink); font-weight: 600; }

/* ---- Layout ---- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 222px minmax(340px, 1fr);
}

body.record-open .layout {
  grid-template-columns: 222px minmax(340px, 1fr) 440px;
}

/* ---- Facet rail ---- */

.facets {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px 14px 32px;
}

.facet-group { margin-bottom: 22px; }

.facet-group h2 {
  font: 600 10px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}

.facet {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--muted);
}

.facet:hover { background: var(--raised); color: var(--ink); }
.facet[aria-pressed="true"] { background: var(--raised); color: var(--ink); }

.facet .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.facet .facet-count { margin-left: auto; font: 400 11px var(--mono); color: var(--faint); }

.facet-select {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
  font: inherit;
}

.clear-filters {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  color: var(--muted);
  font: 500 12px var(--mono);
}

.clear-filters:hover { color: var(--ink); border-color: var(--muted); }

/* ---- Result list ---- */

.list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

#result-status { font: 500 12px var(--mono); color: var(--muted); }

.facet-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  font: 500 12px var(--mono);
  color: var(--muted);
}

#results { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.list-head {
  display: grid;
  grid-template-columns: 1fr 92px 100px;
  gap: 12px;
  padding: 9px 16px 8px 13px;
  border-bottom: 1px solid var(--line);
  font: 600 10px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  flex: none;
}

.list-head span:not(:first-child) { text-align: right; }

#result-rows { flex: 1; overflow-y: auto; }

.row {
  display: grid;
  grid-template-columns: 1fr 92px 100px;
  gap: 12px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  padding: 9px 16px 9px 10px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
}

.row:hover { background: var(--panel); }

.row[aria-current="true"] {
  background: var(--raised);
  border-left-color: var(--vendor, var(--accent));
}

.row .row-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.row .row-family {
  display: block;
  font: 400 11px var(--mono);
  color: var(--faint);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .row-metric {
  font: 500 12px var(--mono);
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.list-sentinel { height: 1px; }

.show-more {
  padding: 13px;
  text-align: center;
  color: var(--muted);
  font: 500 12px var(--mono);
}

.show-more:hover { color: var(--ink); }

/* ---- State panels ---- */

.state-panel {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 22px 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.state-panel strong { color: var(--ink); display: block; margin-bottom: 2px; }
.state-panel > span { font: 600 16px var(--mono); color: var(--faint); }
.state-error > span { color: var(--vendor-amd); }

.loader {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .loader { animation: none; }
  .skip-link { transition: none; }
}

/* ---- Record panel ---- */

.record {
  display: none;
  overflow-y: auto;
  background: var(--panel);
  position: relative;
}

body.record-open .record { display: block; }

.record-inner { padding: 22px 26px 48px; }

.record-close {
  position: sticky;
  top: 10px;
  float: right;
  z-index: 2;
  font: 500 13px var(--mono);
  line-height: 1;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 6px 9px;
}

.record-close:hover { color: var(--ink); border-color: var(--muted); }

.spine { height: 4px; border-radius: 2px; margin-bottom: 16px; }

.crumb { font: 500 11px var(--mono); color: var(--faint); letter-spacing: .05em; }
.crumb b { color: var(--muted); font-weight: 500; }

.record-name {
  font: 800 25px/1.15 var(--ui);
  letter-spacing: -.01em;
  margin: 6px 0 4px;
}

.record-sub { color: var(--muted); font-size: 13px; }
.record-sub .sep { color: var(--faint); margin: 0 6px; }

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 18px 0;
}

.spec { background: var(--raised); padding: 12px 14px; }

.spec dt {
  font: 600 9.5px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 5px;
}

.spec dd { font: 600 16px var(--mono); }
.spec dd.spec-soft { font-size: 13.5px; }
.spec dd small { font: 400 11px var(--mono); color: var(--muted); display: block; margin-top: 2px; }

.bars { margin: 20px 0; display: grid; gap: 13px; }

.bar-label {
  display: flex;
  justify-content: space-between;
  font: 500 11px var(--mono);
  color: var(--muted);
  margin-bottom: 5px;
}

.bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--vendor, var(--accent));
}

.record-section {
  font: 600 10px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 24px 0 10px;
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 22px;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

.kv dt { font: 400 11.5px var(--ui); color: var(--muted); white-space: nowrap; }
.kv dd { font: 500 12px var(--mono); text-align: right; }

.siblings { display: flex; flex-wrap: wrap; gap: 7px; }

.sibling {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.sibling:hover { color: var(--ink); border-color: var(--muted); }
.sibling b { font: 500 11px var(--mono); color: var(--faint); margin-left: 6px; font-weight: 500; }

.source-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.source-row a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}

.source-row a:hover { border-bottom-style: solid; }
.source-row .source-primary-tag { font: 500 10px var(--mono); color: var(--accent); letter-spacing: .08em; }

.record-id { margin-top: 24px; font: 400 11px var(--mono); color: var(--faint); }
.record-id code { color: var(--muted); font-family: var(--mono); }

.record-empty {
  padding: 48px 26px;
  color: var(--faint);
  font: 500 12.5px var(--mono);
  text-align: center;
}

/* ---- Footer ---- */

.foot-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 20px;
  height: 38px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font: 400 11.5px var(--mono);
  color: var(--faint);
  flex: none;
}

.foot-bar nav { display: flex; gap: 18px; }
.foot-bar a { color: var(--muted); text-decoration: none; }
.foot-bar a:hover { color: var(--ink); }

.theme-button {
  margin-left: auto;
  font: 500 11.5px var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
}

.theme-button:hover { color: var(--ink); border-color: var(--muted); }

/* ---- Theme picker ---- */

#theme-picker {
  margin: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  width: 320px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}

#theme-picker::backdrop { background: rgba(0, 0, 0, .4); }

.picker-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.picker-head strong { font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.picker-hint { font: 400 10.5px var(--mono); color: var(--faint); }

#theme-list { max-height: 380px; overflow-y: auto; padding: 8px; outline: none; }

.picker-group {
  font: 600 9.5px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 8px 8px 4px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.theme-option .theme-dots { display: flex; gap: 3px; flex: none; }
.theme-option .theme-dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .35); }
.theme-option .theme-check { margin-left: auto; font: 500 11px var(--mono); color: var(--accent); visibility: hidden; }
.theme-option[aria-selected="true"] .theme-check { visibility: visible; }
.theme-option.highlighted { background: var(--raised); color: var(--ink); }

/* ---- Responsive ---- */

@media (max-width: 1100px) {
  .layout,
  body.record-open .layout { grid-template-columns: 208px minmax(0, 1fr); }

  body.record-open .record {
    position: fixed;
    inset: 0;
    z-index: 15;
    border-left: 0;
  }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }

  .facets { display: none; }

  body.facets-open .facets {
    display: block;
    position: fixed;
    top: 54px;
    bottom: 0;
    left: 0;
    z-index: 12;
    width: min(300px, 85vw);
    background: var(--panel);
    border-right: 1px solid var(--line);
    box-shadow: 12px 0 40px rgba(0, 0, 0, .35);
  }

  .facet-toggle { display: block; }

  .top-bar { gap: 12px; }
  .catalog-count { display: none; }

  .row { grid-template-columns: 1fr 80px; }
  .row .row-metric:last-child { display: none; }
  .list-head { grid-template-columns: 1fr 80px; }
  .list-head span:last-child { display: none; }

  .foot-bar { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px 16px; }
}
