/* Copyright 2026, Niklas Hauser
 * SPDX-License-Identifier: MPL-2.0
 * The tree table of table-view.js, on top of ../shared/theme.css. */

.svd-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.svd-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: left; font-weight: 500; font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap;
}
.svd-table td { padding: 4px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; white-space: nowrap; }
.svd-table tbody tr:hover td { background: var(--hover); }
.svd-table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.svd-table .off { color: var(--faint); margin-left: 6px; }
.svd-table td.c-name { padding-left: calc(6px + var(--d, 0) * 20px); }
.svd-table td.c-desc { white-space: normal; min-width: 260px; max-width: 70ch; color: var(--muted); }
.svd-table .nm { font-family: var(--font-mono); }

/* Expand and collapse toggle */
.tw {
  width: 20px; height: 20px; padding: 0; margin: 0 2px 0 0; border: 0; border-radius: 4px;
  background: transparent; color: var(--muted); cursor: pointer; vertical-align: middle;
  display: inline-grid; place-items: center;
}
.tw:hover { color: var(--ink); background: var(--accent-soft); }
.tw::before {
  content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: translateX(-1px) rotate(-45deg); transition: transform 120ms ease;
}
.tw[aria-expanded="true"]::before { transform: translateY(-1px) rotate(45deg); }
.tw:focus-visible { outline-offset: 2px; }
.tw-gap { display: inline-block; width: 22px; }

/* Show on map button, visible on hover */
.locate {
  position: relative; width: 16px; height: 16px; padding: 0; margin: 0 6px 0 -4px; border: 0; border-radius: 50%;
  background: transparent; color: var(--accent); cursor: pointer; vertical-align: -3px; opacity: 0;
}
.locate::before { content: ""; position: absolute; inset: 3px; border: 1.5px solid currentColor; border-radius: 50%; }
.locate::after { content: ""; position: absolute; left: 7px; top: 7px; width: 2px; height: 2px; border-radius: 50%; background: currentColor; }
.svd-table tbody tr:hover .locate, .locate:focus-visible { opacity: 1; }
.locate:hover { background: var(--accent-soft); }
@media (hover: none) { .locate { opacity: 0.7; } }
.locate-gap { display: inline-block; width: 16px; margin: 0 6px 0 -4px; }

/* Tree levels */
tr.lv-peripheral td { background: var(--band); border-bottom-color: var(--rule-strong); }
tr.lv-peripheral .nm { font-weight: 600; font-size: 13.5px; }
tr.lv-cluster .nm { font-weight: 600; }
tr.lv-register .nm { font-weight: 500; }
tr.lv-field td.c-bits { color: var(--ink); }
tr.lv-enum td { color: var(--muted); }
tr.lv-enum .nm { color: var(--ink); }
tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--mark); } }

.svd-table mark { background: var(--mark); color: var(--mark-ink); border-radius: 2px; padding: 0 1px; }

/* Attributes like "derived from" or "IRQ 37 USART1" */
.pill {
  display: inline-block; margin-left: 8px; padding: 0 5px; border: 1px solid var(--rule-strong); border-radius: 4px;
  font: 11px/1.5 var(--font-mono); color: var(--muted); white-space: nowrap; vertical-align: 1px;
}
td.c-desc .pill:first-child { margin-left: 0; }

.acc {
  display: inline-block; padding: 0 6px; border-radius: 4px; border: 1px solid var(--rule-strong);
  font: 11px/1.6 var(--font-mono); color: var(--muted);
}
.acc-ro { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.acc-wo { border-style: dashed; }

/* Where the field sits in its register */
.bar {
  display: inline-block; width: 64px; height: 7px; margin-left: 10px; vertical-align: 1px; border-radius: 1px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--surface) calc(25% - 1px) 25%),
    linear-gradient(90deg, transparent var(--l), var(--accent) var(--l) calc(var(--l) + var(--w)), transparent calc(var(--l) + var(--w))),
    var(--rule);
}
.svd-table .none td { padding: 28px 16px; color: var(--muted); white-space: normal; }

@media (prefers-reduced-motion: reduce) {
  .tw::before { transition: none; }
  tr.flash td { animation: none; background: var(--mark); }
}
