/* Copyright 2026, Niklas Hauser
 * SPDX-License-Identifier: MPL-2.0
 * The variant, legend and details views of variant-view.js and the register map of map-view.js,
 * on top of ../shared/theme.css. The map canvas reads the colours below too. */

:root {
  --core-bg: #E7ECEA;
  --core-line: #8A9993;
  /* features are coloured hsl(var(--h) var(--feat-s) var(--feat-*-l)), like the shared categories */
  --feat-s: var(--cat-s);
  --feat-line-l: var(--cat-line-l);
  --feat-bg-l: var(--cat-bg-l);
  --feat-ink-l: var(--cat-ink-l);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --core-bg: #1B2320;
    --core-line: #4A5853;
    /* a little brighter than the shared categories, so that thin bit fields stand out */
    --feat-s: 48%;
    --feat-line-l: 58%;
    --feat-bg-l: 22%;
    --feat-ink-l: 78%;
  }
}
:root[data-theme="dark"] {
  --core-bg: #1B2320;
  --core-line: #4A5853;
  --feat-s: 48%;
  --feat-line-l: 58%;
  --feat-bg-l: 22%;
  --feat-ink-l: 78%;
}

.variant { display: grid; gap: 10px; align-content: start; min-width: 0; }
.lines { margin: 0; font: 12px/1.6 var(--font-mono); color: var(--muted); display: grid; gap: 1px; }
.lines li { list-style: none; }
.lines b { color: var(--ink); font-weight: 600; }

/* Feature legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.feat {
  display: flex; align-items: center; gap: 7px; padding: 5px 9px; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-s); background: var(--surface);
  color: inherit; font: 12px var(--font-sans); text-align: left;
}
.feat:hover { background: var(--hover); }
.feat[aria-pressed="true"] { border-color: hsl(var(--h) var(--feat-s) var(--feat-line-l)); background: hsl(var(--h) var(--feat-s) var(--feat-bg-l)); }
.swatch {
  width: 11px; height: 11px; border-radius: 3px; flex: none;
  background: hsl(var(--h) var(--feat-s) var(--feat-bg-l)); border: 1px solid hsl(var(--h) var(--feat-s) var(--feat-line-l));
}
.feat .num { font: 600 12px var(--font-mono); flex: none; }
.feat .name { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feat .info { color: var(--faint); font: 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.feat.core .swatch { background: var(--core-bg); border-color: var(--core-line); }

/* Details of a register, bit field or feature */
.variant-details { display: grid; gap: 8px; align-content: start; }
.variant-details h3 { margin: 0; font: 600 14px var(--font-mono); overflow-wrap: anywhere; }
.variant-details .sub { color: var(--muted); font: 12px var(--font-mono); }
.variant-details p { margin: 0; font-size: 12px; color: var(--muted); }
.variant-details hr { border: 0; border-top: 1px solid var(--rule); margin: 2px 0; width: 100%; }
.variant-details .badge {
  justify-self: start; font: 600 11px var(--font-mono); padding: 2px 7px; border-radius: 5px;
  background: var(--core-bg); border: 1px solid var(--core-line);
}
.variant-details .badge.opt {
  background: hsl(var(--h) var(--feat-s) var(--feat-bg-l));
  border-color: hsl(var(--h) var(--feat-s) var(--feat-line-l));
  color: hsl(var(--h) var(--feat-s) var(--feat-ink-l));
}

/* Register map */
.regmap {
  position: relative; border: 1px solid var(--rule); border-radius: 9px; overflow: hidden; min-width: 0;
  background: var(--surface); height: 100%; min-height: 320px;
}
.regmap canvas { display: block; width: 100%; height: 100%; min-width: 0; touch-action: none; cursor: default; }
.regmap canvas.dragging { cursor: grabbing; }
.regmap canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.regmap .tip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 320px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius-s);
  padding: 5px 8px; display: grid; gap: 1px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}
.regmap .tip strong { font: 600 12px var(--font-mono); }
.regmap .tip span { color: var(--muted); font-size: 11px; }
.regmap .zoom { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; z-index: 4; }
.regmap .zoom button {
  width: 28px; height: 28px; border: 1px solid var(--rule-strong); border-radius: 6px;
  background: var(--surface); color: inherit; font: 15px var(--font-mono); cursor: pointer; line-height: 1;
}
.regmap .zoom button:hover { background: var(--hover); }
.regmap .hint {
  position: absolute; left: 8px; bottom: 8px; z-index: 4; color: var(--faint);
  font-size: 11px; background: var(--surface); border-radius: 6px; padding: 2px 7px;
}
