/* Game Master online reference. Builds on the tokens and components in
   /game-master.css (the app's own palette, radii and font); generated
   pages copy this file to /game-master/reference.css. */

.gm-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------ shell */

.gm-ref-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 200px;
  gap: var(--gm-s5);
  width: min(1440px, calc(100% - 2 * var(--gm-s4)));
  margin: 0 auto;
  padding-top: 57px;
  align-items: start;
}

.gm-ref-side,
.gm-ref-toc {
  position: sticky;
  top: 57px;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  padding: var(--gm-s4) 0 var(--gm-s6);
  scrollbar-width: thin;
  scrollbar-color: var(--gm-border) transparent;
}

.gm-ref-side {
  border-right: 1px solid var(--gm-divider);
  padding-right: var(--gm-s3);
}

.gm-ref-side-head {
  display: grid;
  gap: var(--gm-s3);
  padding-bottom: var(--gm-s3);
  border-bottom: 1px solid var(--gm-divider);
}

.gm-ref-brand {
  display: flex;
  align-items: center;
  gap: var(--gm-s2);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.gm-ref-brand img {
  border-radius: 8px;
}

.gm-ref-brand small {
  display: block;
  color: var(--gm-muted);
  font-weight: 400;
  font-size: var(--gm-fs-label);
  letter-spacing: var(--gm-tracking);
  text-transform: uppercase;
}

.gm-ref-ruleset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gm-s2);
  margin: 0;
}

.gm-ref-nav h2 {
  margin: var(--gm-s4) 0 var(--gm-s1);
}

.gm-ref-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gm-ref-nav a {
  display: block;
  padding: 5px var(--gm-s3);
  border-radius: var(--gm-radius-small);
  color: var(--gm-muted);
  text-decoration: none;
  font-size: var(--gm-fs-small);
  line-height: 1.35;
}

.gm-ref-nav a:hover {
  background: var(--gm-hover);
  color: var(--gm-text);
}

.gm-ref-nav a[aria-current="page"] {
  background: var(--gm-selected);
  color: var(--gm-text);
  box-shadow: inset 3px 0 0 var(--gm-accent);
  font-weight: 600;
}

.gm-ref-toc h2 {
  margin: 0 0 var(--gm-s2);
}

.gm-ref-toc ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--gm-s3);
  border-left: 1px solid var(--gm-divider);
}

.gm-ref-toc a {
  display: block;
  padding: 3px 0;
  color: var(--gm-muted);
  font-size: var(--gm-fs-small);
  text-decoration: none;
}

.gm-ref-toc a:hover {
  color: var(--gm-text);
}

.gm-ref-main {
  min-width: 0;
  padding: var(--gm-s5) 0 var(--gm-s7);
}

.gm-ref-menu {
  display: none;
}

/* ------------------------------------------------------------ search */

.gm-ref-search {
  position: relative;
  margin: 0;
}

.gm-ref-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gm-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.gm-ref-search input,
.gm-filters input,
.gm-filters select {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--gm-panel-low);
  color: var(--gm-text);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius);
  font: inherit;
  font-size: var(--gm-fs-small);
}

.gm-ref-search input {
  padding-left: 34px;
}

.gm-ref-search input:focus,
.gm-filters input:focus,
.gm-filters select:focus {
  border-color: var(--gm-accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--gm-focus);
}

.gm-ref-search-large {
  margin: var(--gm-s4) 0 var(--gm-s5);
}

.gm-ref-search-large input {
  min-height: 52px;
  font-size: 1rem;
}

.gm-ref-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--gm-s2);
}

.gm-ref-results a {
  display: block;
  padding: var(--gm-s3) var(--gm-s4);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius);
  text-decoration: none;
}

.gm-ref-results a:hover {
  border-color: var(--gm-border);
  background: var(--gm-panel-alt);
}

.gm-ref-results strong {
  display: block;
}

.gm-ref-results span:last-child {
  color: var(--gm-muted);
  font-size: var(--gm-fs-small);
}

.gm-ref-kind {
  display: inline-block;
  margin-right: var(--gm-s2);
  padding: 1px 6px;
  border: 1px solid var(--gm-divider);
  border-radius: 6px;
  color: var(--gm-accent-soft);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--gm-tracking);
  text-transform: uppercase;
  vertical-align: 1px;
}

/* ------------------------------------------------------------ articles */

.gm-ref-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gm-s1);
  list-style: none;
  margin: 0 0 var(--gm-s3);
  padding: 0;
  font-size: var(--gm-fs-small);
  color: var(--gm-muted);
}

.gm-ref-crumbs li + li::before {
  content: "›";
  margin-right: var(--gm-s1);
}

.gm-ref-crumbs a {
  color: var(--gm-muted);
}

.gm-ref-head {
  margin-bottom: var(--gm-s5);
}

.gm-ref-head h1,
.gm-ref-entry-head h1 {
  margin: var(--gm-s1) 0 var(--gm-s2);
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.gm-ref-head .gm-lead,
.gm-ref-entry-head .gm-lead {
  max-width: 72ch;
}

.gm-ref-home-head {
  display: flex;
  gap: var(--gm-s4);
  align-items: center;
}

.gm-ref-home-head img {
  border-radius: 18px;
  box-shadow: 0 0 24px rgba(64, 160, 255, 0.18);
}

.gm-ref-article {
  max-width: 920px;
}

.gm-ref-article h2 {
  font-size: var(--gm-fs-title);
  margin: 0 0 var(--gm-s3);
  line-height: 1.3;
}

.gm-ref-article h3 {
  font-size: var(--gm-fs-title-m);
  margin: var(--gm-s4) 0 var(--gm-s2);
}

.gm-ref-article p,
.gm-ref-article li {
  color: var(--gm-muted);
}

.gm-ref-article strong {
  color: var(--gm-text);
}

.gm-ref-section {
  padding: var(--gm-s5) 0;
  border-top: 1px solid var(--gm-divider);
  scroll-margin-top: 72px;
}

.gm-ref-section h2 .gm-chip {
  vertical-align: middle;
}

.gm-ref-points,
.gm-ref-steps {
  margin: 0;
  padding-left: 1.25rem;
}

.gm-ref-points li,
.gm-ref-steps li {
  margin: 0 0 var(--gm-s2);
}

.gm-ref-points li::marker {
  color: var(--gm-accent-soft);
}

.gm-ref-steps li::marker {
  color: var(--gm-accent-soft);
  font-weight: 700;
}

.gm-term {
  color: var(--gm-text);
  text-decoration: underline dotted var(--gm-accent-soft);
  text-underline-offset: 3px;
}

.gm-term:hover {
  text-decoration-style: solid;
}

.gm-chip-small {
  padding: 1px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.gm-ref-note {
  margin: var(--gm-s3) 0;
  padding: var(--gm-s3) var(--gm-s4);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-left: 3px solid var(--gm-accent);
  border-radius: var(--gm-radius);
}

.gm-ref-note-warning {
  border-left-color: var(--gm-warning);
}

.gm-ref-note p {
  margin: 0;
}

.gm-ref-note .gm-ref-note-title {
  margin-bottom: var(--gm-s1);
  color: var(--gm-text);
  font-weight: 600;
}

.gm-ref-important,
.gm-ref-philosophy,
.gm-ref-ruleset-note,
.gm-ref-mimic,
.gm-ref-related {
  margin: var(--gm-s4) 0;
}

.gm-ref-important {
  border-left: 3px solid var(--gm-accent);
}

.gm-ref-philosophy h2 {
  margin-top: var(--gm-s1);
}

.gm-ref-philosophy h3 {
  margin-top: 0;
}

.gm-ref-faq {
  margin: 0 0 var(--gm-s2);
  padding: var(--gm-s2) var(--gm-s3);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius);
}

.gm-ref-faq summary {
  cursor: pointer;
  color: var(--gm-text);
  font-weight: 600;
}

.gm-ref-faq p {
  margin: var(--gm-s2) 0 0;
}

.gm-ref-version {
  margin: var(--gm-s4) 0 0;
  color: var(--gm-muted);
  font-size: var(--gm-fs-small);
}

.gm-ref-builtin {
  margin: 0 0 var(--gm-s4);
  padding: var(--gm-s3) var(--gm-s4);
  background: var(--gm-panel-low);
  border: 1px dashed var(--gm-border);
  border-radius: var(--gm-radius);
  font-size: var(--gm-fs-small);
}

.gm-ref-related ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gm-s2) var(--gm-s4);
  margin: var(--gm-s2) 0 0;
  padding: 0;
}

.gm-ref-related li {
  color: var(--gm-text);
}

/* ------------------------------------------------------------ chapter lists and cards */

.gm-ref-chapters {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gm-s3);
}

.gm-ref-chapter,
.gm-ref-card-link {
  display: flex;
  gap: var(--gm-s3);
  height: 100%;
  box-sizing: border-box;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.gm-ref-card-link {
  flex-direction: column;
  gap: var(--gm-s1);
}

.gm-ref-chapter:hover,
.gm-ref-card-link:hover,
.gm-ref-card:hover {
  border-color: var(--gm-border);
  background: var(--gm-panel-alt);
}

.gm-ref-chapter > span:last-child {
  display: grid;
  gap: var(--gm-s1);
  align-content: start;
  justify-items: start;
}

.gm-ref-chapter .gm-muted,
.gm-ref-card-link .gm-muted {
  font-size: var(--gm-fs-small);
}

.gm-ref-chapter-num {
  flex: 0 0 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--gm-panel-alt);
  border: 1px solid var(--gm-border);
  border-radius: 50%;
  color: var(--gm-accent-soft);
  font-weight: 700;
  font-size: var(--gm-fs-small);
}

.gm-ref-card-link strong i {
  color: var(--gm-accent-soft);
  margin-right: 4px;
}

.gm-ref-explore {
  margin-bottom: var(--gm-s5);
}

.gm-ref-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gm-s2);
}

.gm-ref-card {
  display: flex;
  gap: var(--gm-s3);
  align-items: center;
  height: 100%;
  box-sizing: border-box;
  padding: var(--gm-s2);
  text-decoration: none;
}

.gm-ref-card img,
.gm-ref-avatar {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: var(--gm-radius-small);
  background: #2a2420;
  object-fit: cover;
}

.gm-ref-avatar {
  display: grid;
  place-items: center;
  color: var(--gm-muted);
  font-weight: 700;
  border: 1px solid var(--gm-divider);
}

.gm-ref-avatar-large {
  width: 220px;
  height: 220px;
  flex-basis: 220px;
  font-size: 3rem;
  border-radius: var(--gm-radius-card);
}

.gm-ref-card-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.gm-ref-card-body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gm-ref-card-body .gm-muted,
.gm-ref-card-meta {
  font-size: var(--gm-fs-small);
}

.gm-ref-card-meta {
  color: var(--gm-muted);
}

.gm-ref-flag {
  color: var(--gm-accent-soft);
  font-weight: 600;
}

/* ------------------------------------------------------------ entries */

.gm-ref-entry-head {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--gm-s5);
  align-items: start;
  margin-bottom: var(--gm-s4);
}

.gm-ref-portrait {
  width: 220px;
  height: 220px;
  object-fit: cover;
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius-card);
  background: #2a2420;
}

.gm-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin: 0 0 var(--gm-s3);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius);
  overflow: hidden;
}

.gm-facts div {
  margin: 0 -1px -1px 0;
  padding: var(--gm-s2) var(--gm-s3);
  border-right: 1px solid var(--gm-divider);
  border-bottom: 1px solid var(--gm-divider);
}

.gm-facts dt {
  color: var(--gm-muted);
  font-size: var(--gm-fs-label);
  letter-spacing: var(--gm-tracking);
  text-transform: uppercase;
}

.gm-facts dd {
  margin: 2px 0 0;
  color: var(--gm-text);
}

.gm-ref-abilities {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gm-s2);
}

.gm-ref-abilities > div {
  display: grid;
  justify-items: center;
  padding: var(--gm-s2);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius);
}

.gm-ref-abilities strong {
  font-size: 1.25rem;
}

.gm-ref-action {
  padding: var(--gm-s3) 0;
  border-top: 1px solid var(--gm-divider);
}

.gm-ref-action:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.gm-ref-action h3 {
  margin-top: 0;
}

.gm-ref-action p {
  margin: 0 0 var(--gm-s1);
}

.gm-ref-rule h3 {
  margin-top: 0;
}

.gm-ref-rule {
  padding: var(--gm-s3) var(--gm-s4);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius);
}

.gm-ref-rule p {
  margin: 0;
}

.gm-table th[scope="row"] {
  color: var(--gm-text);
  font-weight: 600;
}

.gm-table caption {
  padding: var(--gm-s2) var(--gm-s3);
  text-align: left;
  color: var(--gm-muted);
}

/* ------------------------------------------------------------ glossary */

.gm-ref-az ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gm-s1);
  list-style: none;
  margin: 0 0 var(--gm-s4);
  padding: 0;
}

.gm-ref-az a {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius-small);
  background: var(--gm-panel);
  text-decoration: none;
  font-weight: 600;
}

.gm-ref-az a:hover {
  border-color: var(--gm-border);
}

.gm-ref-letter {
  scroll-margin-top: 72px;
}

.gm-ref-letter h2 {
  margin: var(--gm-s4) 0 var(--gm-s2);
  color: var(--gm-accent-soft);
}

.gm-ref-terms {
  margin: 0;
}

.gm-ref-term {
  padding: var(--gm-s2) 0;
  border-top: 1px solid var(--gm-divider);
  scroll-margin-top: 72px;
}

.gm-ref-term dt a {
  font-weight: 600;
  text-decoration: none;
}

.gm-ref-term dt a:hover {
  text-decoration: underline;
}

.gm-ref-term dd {
  margin: 2px 0 0;
  color: var(--gm-muted);
}

/* ------------------------------------------------------------ filters */

.gm-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--gm-s2) var(--gm-s3);
  margin: 0 0 var(--gm-s4);
  padding: var(--gm-s3);
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius-card);
}

.gm-filters label {
  display: grid;
  gap: var(--gm-s1);
}

.gm-filter-wide {
  grid-column: 1 / -1;
}

.gm-filter-count {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--gm-muted);
  font-size: var(--gm-fs-small);
}

[data-filter-item][hidden],
.gm-ref-letter[hidden] {
  display: none;
}

/* ------------------------------------------------------------ annotated screenshots */

.gm-ref-shot {
  margin: var(--gm-s4) 0;
  background: var(--gm-panel);
  border: 1px solid var(--gm-divider);
  border-radius: var(--gm-radius-card);
  overflow: hidden;
}

.gm-ref-shot-frame {
  position: relative;
  width: 100%;
  background: var(--gm-panel-low);
}

.gm-ref-shot-frame img {
  display: block;
  width: 100%;
  height: 100%;
}

.gm-ref-callout {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--gm-accent);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.gm-ref-badge {
  position: absolute;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  background: var(--gm-accent);
  color: var(--gm-on-accent);
  border: 1px solid #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.gm-ref-shot figcaption {
  padding: var(--gm-s3) var(--gm-s4);
  border-top: 1px solid var(--gm-divider);
}

.gm-ref-legend {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gm-s2) var(--gm-s4);
  margin: var(--gm-s2) 0 0;
  padding: 0;
  font-size: var(--gm-fs-small);
}

.gm-ref-legend li {
  display: flex;
  gap: var(--gm-s2);
  margin: 0;
}

.gm-ref-num {
  flex: 0 0 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: var(--gm-accent);
  color: var(--gm-on-accent);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

/* ------------------------------------------------------------ pager and callout */

.gm-ref-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gm-s3);
  margin: var(--gm-s5) 0 0;
}

.gm-ref-pager a {
  display: grid;
  gap: 2px;
  text-decoration: none;
}

.gm-ref-pager a:hover {
  border-color: var(--gm-border);
}

.gm-ref-next {
  text-align: right;
}

.gm-ref-get {
  display: flex;
  align-items: center;
  gap: var(--gm-s3);
  max-width: 920px;
  margin-top: var(--gm-s6);
  padding: var(--gm-s3) var(--gm-s4);
}

.gm-ref-get img {
  border-radius: 12px;
}

.gm-ref-get > div:nth-child(2) {
  display: grid;
  flex: 1;
}

.gm-ref-get .gm-muted {
  font-size: var(--gm-fs-small);
}

.gm-ref-get-actions {
  display: grid;
  justify-items: end;
  gap: var(--gm-s1);
  font-size: var(--gm-fs-label);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1280px) {
  .gm-ref-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .gm-ref-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .gm-ref-shell {
    display: block;
    width: calc(100% - 2 * var(--gm-s4));
  }

  .gm-ref-menu {
    display: inline-flex;
    margin-bottom: var(--gm-s3);
    min-height: 44px;
  }

  .gm-ref-side {
    display: none;
    position: fixed;
    z-index: 120;
    top: 57px;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    max-height: none;
    padding: var(--gm-s4);
    background: var(--gm-panel);
    border-right: 1px solid var(--gm-border);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
  }

  .gm-ref-side.is-open {
    display: block;
  }

  .gm-ref-nav a {
    padding: 10px var(--gm-s3);
  }

  .gm-ref-chapters {
    grid-template-columns: 1fr;
  }

  .gm-ref-entry-head {
    grid-template-columns: 1fr;
  }

  .gm-ref-portrait,
  .gm-ref-avatar-large {
    width: 160px;
    height: 160px;
  }

  .gm-ref-abilities {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .gm-ref-head h1,
  .gm-ref-entry-head h1 {
    font-size: 1.625rem;
  }

  .gm-ref-home-head {
    align-items: flex-start;
  }

  .gm-ref-home-head img {
    width: 56px;
    height: 56px;
  }

  .gm-ref-cards {
    grid-template-columns: 1fr;
  }

  .gm-ref-pager {
    grid-template-columns: 1fr;
  }

  .gm-ref-get {
    flex-wrap: wrap;
  }

  .gm-ref-get-actions {
    justify-items: start;
    width: 100%;
  }

  /* Wide tables become one card per row. */
  .gm-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .gm-stack,
  .gm-stack tbody,
  .gm-stack tr,
  .gm-stack th,
  .gm-stack td {
    display: block;
    width: auto;
  }

  .gm-stack tr {
    padding: var(--gm-s2) 0;
    border-top: 1px solid var(--gm-divider);
  }

  .gm-stack tr:first-child {
    border-top: 0;
  }

  .gm-table.gm-stack th,
  .gm-table.gm-stack td {
    border-top: 0;
    padding: 2px var(--gm-s3);
  }

  .gm-stack td::before {
    content: attr(data-label) ": ";
    color: var(--gm-text);
    font-weight: 600;
  }

  .gm-stack td:empty {
    display: none;
  }

  .gm-ref-legend {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gm-ref-chapter,
  .gm-ref-card-link {
    transition: none;
  }
}
