/* Play-guide components. Loaded only on guide pages; reuses the site token set in
   styles.css (--gold, --panel, --line …) rather than redefining any colours. */

.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(14px, 2.4vw, 28px);
  width: min(var(--max), calc(100% - 44px));
  /* Clears the 72px fixed site header; the page heading below then only needs
     ordinary spacing rather than its usual full offset. */
  margin: 96px auto 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--soft);
}

.guide-nav a {
  position: relative;
  padding: 6px 0;
}

.guide-nav a:hover {
  color: var(--text);
}

.guide-nav a[aria-current="page"] {
  color: var(--gold-2);
}

.guide-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -11px;
  left: 0;
  height: 2px;
  background: var(--gold);
}

.guide-nav + .page-head p {
  max-width: none;
}

.guide-nav + .page-head {
  padding-top: 26px;
}

.guide-body {
  width: min(var(--max), calc(100% - 44px));
  margin: 0 auto;
  padding: 26px 0 70px;
}

.guide-note {
  margin: 0 0 22px;
  padding: 12px 16px;
  border-left: 3px solid var(--gold);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.92rem;
}

.guide-empty {
  padding: 30px 0;
  color: var(--soft);
}

.group-heading {
  margin: 34px 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold-2);
}

/* ── Filter chips ─────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}

.filter-chip {
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.filter-chip:hover {
  color: var(--text);
  border-color: rgba(213, 163, 61, 0.7);
}

.filter-chip[aria-pressed="true"] {
  border-color: var(--gold);
  background: rgba(213, 163, 61, 0.14);
  color: var(--gold-2);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.unit-grid,
.building-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 285px), 1fr));
  gap: 14px;
}

.unit-card,
.building-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

/* An explicit `display` beats the user-agent rule for [hidden], so filtering by role
   would set the attribute and change nothing without this. */
.unit-card[hidden],
.building-card[hidden] {
  display: none;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 22px;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sort-control select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 16, 16, 0.72);
  color: var(--text);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.sort-control select:hover {
  border-color: rgba(213, 163, 61, 0.7);
}

.result-count {
  color: var(--soft);
  font-size: 0.78rem;
}

.unit-head {
  display: flex;
  align-items: center;
  gap: 13px;
}

.unit-portrait {
  width: 64px;
  height: 64px;
  flex: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(6, 12, 12, 0.6);
  object-fit: contain;
}

.unit-portrait.placeholder {
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  color: var(--gold);
}

.unit-heading h3,
.building-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.16rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.unit-role {
  margin: 3px 0 0;
  color: var(--soft);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.unit-blurb {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* ── Tier bars ────────────────────────────────────────────────────────────── */

.tier-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
  border-top: 1px solid var(--line-soft);
}

.tier-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 9px;
  padding-top: 4px;
}

.tier-name {
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tier-pips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

.pip {
  height: 5px;
  border-radius: 1px;
  background: rgba(231, 220, 194, 0.13);
}

.pip.on {
  background: var(--gold);
}

.tier-label {
  color: var(--text);
  font-size: 0.72rem;
  text-align: right;
}

/* ── Fact lists ───────────────────────────────────────────────────────────── */

.unit-facts {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--soft);
  font-size: 0.8rem;
}

.unit-facts .flag {
  color: var(--gold-2);
}

.unit-facts .chain {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Prose sections on the written pages ──────────────────────────────────── */

.guide-prose h2 {
  margin: 38px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gold-2);
}

.guide-prose h3 {
  margin: 24px 0 6px;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
}

.guide-prose p,
.guide-prose li {
  max-width: none;
  color: var(--muted);
  line-height: 1.65;
}

.guide-prose ul {
  padding-left: 20px;
}

.guide-prose li {
  margin-bottom: 6px;
}

.guide-prose strong {
  color: var(--text);
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 255px), 1fr));
  gap: 14px;
  margin: 16px 0 6px;
}

.rule-card {
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

.rule-card h3 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.credits-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.credits-grid .rule-card h2 {
  margin: 0 0 10px;
  font-size: 1.14rem;
}

.credits-grid .rule-card p,
.credits-grid .rule-card li {
  font-size: 0.9rem;
}

/* Cards that contain a link become clickable across their whole area, and say so on
   hover. Cards without a link (the "A first match" tip) get no affordance — a hover
   state on something that does nothing is worse than none. */
.rule-card:has(a) {
  position: relative;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.rule-card:has(a) h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.rule-card:has(a):hover {
  border-color: rgba(213, 163, 61, 0.75);
  background: var(--panel-2);
  transform: translateY(-2px);
}

.rule-card:has(a):hover h3 {
  color: var(--gold-2);
}

.rule-card:has(a) h3::after {
  content: "→";
  margin-left: 8px;
  color: var(--gold);
  font-family: var(--font-sans, inherit);
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.rule-card:has(a):hover h3::after {
  opacity: 1;
}

/* Keyboard parity: focusing the link lights the whole card. */
.rule-card:has(a:focus-visible) {
  border-color: var(--gold-2);
  background: var(--panel-2);
}

.rule-card:has(a) h3 a:focus-visible {
  outline: none;
}

.rule-card:has(a:focus-visible) h3 {
  color: var(--gold-2);
}

.rule-card:has(a:focus-visible) h3::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .rule-card:has(a) {
    transition: none;
  }

  .rule-card:has(a):hover {
    transform: none;
  }
}

.rule-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

@media (max-width: 1040px) {
  .guide-nav,
  .guide-nav + .page-head,
  .guide-body {
    width: min(100% - 28px, var(--max));
  }

  .guide-nav + .page-head {
    padding-top: 20px;
  }
}

@media (max-width: 820px) {
  .guide-nav {
    margin-top: 84px;
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .tier-row {
    grid-template-columns: 66px minmax(0, 1fr) 80px;
  }

  .unit-grid,
  .building-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Counter matrix ───────────────────────────────────────────────────────── */

.counter-wrap {
  margin: 16px 0 8px;
  overflow-x: auto;
}

.counter-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.counter-table caption {
  margin-bottom: 12px;
  color: var(--soft);
  font-size: 0.82rem;
  text-align: left;
}

.counter-table th {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
}

.counter-table th.corner {
  color: var(--soft);
  font-size: 0.66rem;
}

.counter-cell {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  background: rgba(10, 17, 17, 0.5);
  text-align: left;
  white-space: nowrap;
}

.counter-verdict {
  display: block;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 800;
}

.counter-mult {
  display: block;
  margin-top: 2px;
  color: var(--soft);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

/* Colour carries the same information as the verdict word, never on its own. */
.counter-cell.v-devastating {
  background: rgba(213, 163, 61, 0.26);
  border-color: rgba(213, 163, 61, 0.65);
}

.counter-cell.v-devastating .counter-verdict,
.counter-cell.v-strong .counter-verdict {
  color: var(--gold-2);
}

.counter-cell.v-strong {
  background: rgba(213, 163, 61, 0.16);
}

.counter-cell.v-favoured {
  background: rgba(213, 163, 61, 0.08);
}

.counter-cell.v-weak {
  background: rgba(23, 52, 84, 0.32);
}

.counter-cell.v-ineffective {
  background: rgba(23, 52, 84, 0.5);
}

.counter-cell.v-weak .counter-verdict,
.counter-cell.v-ineffective .counter-verdict {
  color: #9fc2e4;
}

@media (max-width: 560px) {
  .counter-table {
    font-size: 0.76rem;
  }
}
