/* Tables and page-reference links inside feature text (static/js/rules-rich.js).
   Everything inherits size, line height, colour and family from the text around it, so a table in a Tamer feature
   reads at exactly the size of every other class's feature text (tests/test_rules_rich_ui_contract.py). Colours are
   the design tokens, so the light and the dark theme both work. */

.rr-slot:empty { display: none; }

.rr-table-wrap {
  max-width: 100%;
  margin: 8px 0;
  overflow-x: auto;                       /* a wide table scrolls inside itself on a phone */
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.rr-table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rr-table {
  width: 100%;
  border-collapse: collapse;
  font: inherit;
  line-height: inherit;
  color: inherit;
}
.rr-table caption {
  caption-side: top;
  text-align: left;
  padding: 8px 10px 4px;
  font-weight: 700;
  color: var(--text);
}
.rr-table th,
.rr-table td {
  padding: 5px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-weight: inherit;
}
.rr-table thead th {
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface2);
  vertical-align: bottom;
}
.rr-table thead th.rr-group { text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
.rr-table tbody th[scope="row"] { font-weight: 600; color: var(--text); white-space: nowrap; }
.rr-table tbody tr:nth-child(even) > * { background: color-mix(in srgb, var(--surface2) 45%, transparent); }
.rr-table tbody tr:last-child > * { border-bottom: 0; }
.rr-table .rr-group-row th {
  background: var(--surface2);
  color: var(--accent);
  font-weight: 700;
  text-align: left;
}

.rr-notes {
  margin: 0;
  padding: 6px 10px 8px;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.92em;
}
.rr-notes li + li { margin-top: 3px; }
.rr-mark { font-weight: 700; color: var(--text); }

/* A page reference that now leads somewhere. */
.rr-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.rr-link:hover { color: var(--accent-strong); }
.rr-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
/* A reference to something this app does not carry: plain text that says why. */
.rr-unavailable { text-decoration: underline dotted; cursor: help; }

/* The place a link lands on flashes once. */
.rr-landed { animation: rr-landed 1.6s ease-out 1; }
@keyframes rr-landed {
  from { box-shadow: 0 0 0 3px var(--accent); }
  to { box-shadow: 0 0 0 3px transparent; }
}
@media (prefers-reduced-motion: reduce) { .rr-landed { animation: none; outline: 2px solid var(--accent); } }

/* The item a link opens (Surgeon's Tools). */
.rr-popover {
  position: fixed;
  inset: auto 16px 16px auto;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
}
.rr-popover h4 { margin: 0 0 6px; font-size: 1em; }
.rr-popover p { margin: 4px 0; }
.rr-popover button { margin-top: 8px; }

/* What a subclass gives, level by level (the subclass choice card). */
.rr-subclass-compare { margin: 8px 0; }
.rr-subclass-compare h4 { margin: 10px 0 2px; font-size: 1em; }
.rr-subclass-compare ul { margin: 2px 0 6px; padding-left: 18px; }

@media (max-width: 640px) {
  .rr-table thead th:not(.rr-group), .rr-table tbody th[scope="row"] { white-space: normal; }
  .rr-table th, .rr-table td { padding: 5px 8px; }
}

/* Spells a class feature grants (wizard Spells step): groups under the picks, one per giving feature. */
.spell-granted { margin-top: 14px; }
.spell-granted-head {
  margin: 12px 0 4px;
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent);
}
.spell-granted-row .spell-cadence-chip.locked { white-space: nowrap; }

/* Monster Trainer's read-only lines on the sheet: what the companions have at this tamer level. */
.rr-companions-summary { margin: 8px 0 2px; padding-top: 6px; border-top: 1px solid var(--border); }
.rr-companions-summary ul { margin: 4px 0 0; padding-left: 18px; }
.rr-companions-summary li { margin: 2px 0; }
