/*
Theme Name: Z Route Theme
Theme URI: https://zrouteguide.com/
Author: Z Route
Template: zroute
Description: Active companion theme at themes/zroute-theme/. Design-system layer, homepage, and search page. Parent "zroute" keeps game assets and calculators.
Version: 1.8.22
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
Text Domain: zroute
*/

/*
 * Design system (§5)
 * Tokens live on the parent :root. These classes are the documented reusable set.
 * PHP helpers: zr_ds_* in inc/components.php
 *
 * Button, Icon Button, Search Box, Tabs, Breadcrumbs, Badge, Status Badge,
 * Card, Stat Card, Resource Card, Progress Bar, Filter Chips, Toggle,
 * Modal, Tooltip, Accordion, Data Table, Calculator Input/Result,
 * Timeline, Hero Card, Building Card, Guide Card, Code Card, Event Card.
 */

/* Tool, database, and guide pages share .zr-doc. The 44rem cap is for
   long articles; hubs and calculators need the full content width. */
.zr-doc {
  max-width: none;
}

/* Hero stage is a portrait card. Full content width left it as an empty banner. */
.zr-hstage {
  width: min(100%, 22rem);
  margin-inline: auto;
  min-height: 0;
}

/* Building level controls sit beside the name, wide enough to read. */
.zr-bpre__headrow {
  flex-wrap: wrap;
  align-items: flex-end;
}

.zr-bpre__yours {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-left: auto;
}

.zr-bpre__yours select,
.zr-bpre__yours input {
  width: 8.5rem;
  min-width: 7.5rem;
}

.zr-ds-btn,
.zr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--zr-radius-sm, 10px);
  border: 1px solid transparent;
  background: var(--zr-primary, #ff5a1f);
  color: var(--zr-on-primary, #1a0d08);
  font-family: var(--zr-font-display, inherit);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.zr-ds-btn--ghost,
.zr-btn--ghost {
  background: transparent;
  border-color: var(--zr-border, #243740);
  color: var(--zr-text, #f4f7f8);
}

.zr-ds-btn--icon,
.zr-iconbtn {
  width: 2.5rem;
  min-width: 2.5rem;
  padding: 0;
}

.zr-ds-badge,
.zr-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--zr-surface-2, #121f27);
  color: var(--zr-muted, #9eadb4);
}

.zr-badge--live,
.zr-badge--active {
  background: var(--zr-success-soft, rgba(81, 216, 138, 0.14));
  color: var(--zr-success, #51d88a);
}

.zr-badge--upcoming {
  background: var(--zr-accent-soft, rgba(24, 199, 217, 0.14));
  color: var(--zr-secondary, #18c7d9);
}

.zr-badge--ended,
.zr-badge--soon {
  background: var(--zr-primary-soft, rgba(255, 90, 31, 0.14));
  color: var(--zr-primary-ink, #ff8a57);
}

.zr-ds-card,
.zr-card {
  background: var(--zr-surface, #0d171d);
  border: 1px solid var(--zr-border, #243740);
  border-radius: var(--zr-radius, 12px);
}

.zr-ds-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 1rem;
  text-align: center;
}

.zr-ds-stat__n {
  font-family: var(--zr-font-display, inherit);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--zr-text, #f4f7f8);
}

.zr-ds-chip,
.zr-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--zr-border, #243740);
  background: var(--zr-surface-2, #121f27);
  color: var(--zr-text, #f4f7f8);
  cursor: pointer;
}

.zr-chip.is-on,
.zr-ds-chip.is-on {
  border-color: var(--zr-primary, #ff5a1f);
  background: var(--zr-primary-soft, rgba(255, 90, 31, 0.14));
  color: var(--zr-primary-ink, #ff8a57);
}

.zr-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--zr-muted, #9eadb4);
}

.zr-crumbs a {
  color: var(--zr-secondary, #18c7d9);
}
.zr-crumbs li + li::before {
  content: "›";
  margin-right: 0.35rem;
  opacity: 0.55;
}

/* Homepage composition (§8–15). Hero layout stays on the parent sheet. */
.zr-home .zr-stats {
  padding: 0;
}

.zr-home .zr-stats__list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  max-width: var(--zr-max, 1200px);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.zr-home .zr-section {
  margin-top: 2rem;
}

.zr-home .zr-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.zr-home .zr-section__head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.zr-codescroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.5rem;
  list-style: none;
  margin: 0;
  scroll-snap-type: x proximity;
}

.zr-codecard {
  flex: 0 0 12.5rem;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem;
}

.zr-codecard__code {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.zr-codecard__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.zr-tools-pop {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.zr-tools-pop a,
.zr-tools-pop article {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
}

.zr-tools-pop h3 {
  margin: 0;
  font-size: 1rem;
}

.zr-dbhome {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.zr-dbhome a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem;
  text-decoration: none;
  color: inherit;
  min-height: 6.5rem;
}

.zr-guide-grid,
.zr-event-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.zr-guide-grid a,
.zr-event-grid a {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
}

/* Search page (§33, §76) */
.zr-searchpage .zr-sbox--page {
  max-width: 40rem;
}

.zr-searchpage__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
}

.zr-searchpage__meta {
  color: var(--zr-muted, #9eadb4);
  font-size: 0.88rem;
}

.zr-searchpage__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.zr-searchpage__hit {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: inherit;
}

.zr-searchpage__hit mark {
  background: var(--zr-primary-soft, rgba(255, 90, 31, 0.22));
  color: inherit;
}

.zr-searchpage__empty {
  padding: 1.5rem 1rem;
  text-align: center;
}

@media (min-width: 768px) {
  .zr-home .zr-stats__list {
    grid-template-columns: repeat(4, 1fr);
  }

  .zr-tools-pop {
    grid-template-columns: 1fr 1fr;
  }

  .zr-dbhome {
    grid-template-columns: repeat(4, 1fr);
  }

  .zr-guide-grid,
  .zr-event-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .zr-home .zr-stats__list {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Stars panel: quality puzzle behind the hero chip. */
.zr-hms__frame {
  width: 88px;
  height: 88px;
  background: none;
  filter: none;
}

.zr-hms__frame::before,
.zr-hms__frame::after {
  content: none;
  display: none;
}

.zr-hms__frame img.zr-hms__layer,
.zr-hms__frame img.zr-hms__face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
}

.zr-hms__frame img.zr-hms__layer {
  z-index: 1;
}

.zr-hms__frame img.zr-hms__face {
  z-index: 2;
}

.zr-hms__costs[style*="--zr-shard"] .zr-hms__cost,
.zr-hms__costs[style*="--zr-frame"] .zr-hms__cost {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.zr-hms__costs[style*="--zr-shard"] .zr-hms__cost::before,
.zr-hms__costs[style*="--zr-frame"] .zr-hms__cost::before {
  content: "";
  width: 1.45rem;
  height: 1.45rem;
  flex: 0 0 auto;
  background-image: var(--zr-shard, none), var(--zr-frame, none);
  background-position: center, center;
  background-size: contain, contain;
  background-repeat: no-repeat, no-repeat;
}

.zr-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.zr-stepper__item {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--zr-border, #243740);
  color: var(--zr-muted, #4b5d66);
}

.zr-stepper__item.is-on {
  border-color: var(--zr-primary, #ff5a1f);
  color: var(--zr-text, #f4f7f8);
}

.zr-stepper__item.is-done {
  background: var(--zr-surface, #122028);
}

.zr-drawer {
  border: 1px solid var(--zr-border, #243740);
  border-radius: var(--zr-radius-sm, 10px);
  background: var(--zr-surface, #122028);
  margin: 0.6rem 0;
}

.zr-drawer summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 650;
}

.zr-drawer__body {
  padding: 0 1rem 0.9rem;
}

.zr-cmp {
  display: grid;
  gap: 0;
  overflow-x: auto;
  border: 1px solid var(--zr-border, #243740);
  border-radius: var(--zr-radius-sm, 10px);
}

.zr-cmp__row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(7rem, 1fr);
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--zr-border, #243740);
}

.zr-cmp__head {
  border-top: 0;
  font-weight: 650;
  background: var(--zr-surface, #122028);
}

.zr-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.zr-tree__node {
  display: grid;
  gap: 0.15rem;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--zr-accent, #08707d);
  background: var(--zr-surface, #122028);
}

.zr-tree__node small {
  color: var(--zr-muted, #4b5d66);
}

.zr-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 1rem;
}

.zr-tabs a {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--zr-border, #243740);
  text-decoration: none;
}

.zr-tabs a[aria-current="page"] {
  border-color: var(--zr-primary, #ff5a1f);
}

.zr-embed .zr-header,
.zr-embed .zr-footer,
.zr-embed .zr-tabbar {
  display: none;
}

.zr-cal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

/* Database hub: title on top, section cards in a grid.
   Parent .zr-db is a 4-column stat grid and was splitting this page. */
.zr-dbhub .zr-pagehead {
  max-width: 36rem;
}

.zr-dbgrid {
  list-style: none;
  margin: 1.15rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.zr-dbgrid > li {
  display: flex;
  min-width: 0;
}

.zr-dbhub .zr-dbgrid > li > .zr-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 9.25rem;
  padding: 1.05rem 1.1rem 1rem;
  text-decoration: none;
  color: inherit;
}

.zr-dbhub .zr-dbgrid > li > .zr-card strong {
  font-family: var(--zr-font-display, inherit);
  font-size: 1.2rem;
  line-height: 1.2;
}

.zr-dbhub .zr-dbgrid .zr-ds-stat__n {
  margin-top: auto;
  padding: 0.35rem 0 0;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  text-align: left;
}

.zr-dbhub .zr-dbgrid > li > .zr-card .zr-badge {
  margin-top: auto;
}

.zr-dbhub .zr-dbgrid > li > a.zr-card:hover {
  border-color: var(--zr-accent, #18c7d9);
}

.zr-dbhub .zr-dbgrid > li > .zr-card.is-soon {
  opacity: 1;
}

article.zr-card.is-soon,
.zr-card.is-soon {
  cursor: default;
}

article.zr-card.is-soon:hover,
.zr-card.is-soon:hover {
  border-color: var(--zr-border, #d5dee3);
}

.zr-soon-note {
  margin: 0.35rem 0 0;
  color: var(--zr-muted, #4b5d66);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

@media (min-width: 640px) {
  .zr-dbgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .zr-dbhub .zr-dbgrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.zr-bldcalc {
  margin: 0.85rem 0 0;
}

.zr-bldlist {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: 0.65rem;
}

.zr-bldlist > li {
  display: flex;
  min-width: 0;
}

.zr-bldlist__card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.7rem 0.75rem 0.8rem;
  text-decoration: none;
  color: inherit;
}

.zr-bldlist__card img {
  width: 4.25rem;
  height: 4.25rem;
  object-fit: contain;
  margin-bottom: 0.25rem;
}

.zr-bldlist__name {
  font-weight: 700;
  line-height: 1.25;
}

.zr-bldlist__meta {
  color: var(--zr-muted, #4b5d66);
  font-size: 0.85rem;
}

.zr-bldlist__card:hover {
  border-color: var(--zr-accent, #18c7d9);
}

.zr-rtable {
  overflow-x: auto;
  margin: 0 0 1.25rem;
  border: 1px solid var(--zr-border, #d5dee3);
  border-radius: 12px;
  background: var(--zr-surface, #fff);
}

.zr-rtable table {
  width: 100%;
  min-width: 58rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.zr-rtable th,
.zr-rtable td {
  padding: 0.55rem 0.7rem;
  text-align: right;
  white-space: nowrap;
  border-top: 1px solid var(--zr-border, #d5dee3);
  vertical-align: middle;
}

.zr-rtable thead th {
  border-top: 0;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--zr-muted, #4b5d66);
}

.zr-rtable th:first-child,
.zr-rtable td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--zr-surface, #fff);
}

.zr-rtable__branch th {
  text-align: left;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  background: var(--zr-bg, #f4f7f8);
}

.zr-rtable__tech {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.zr-rtable__tech img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  flex: 0 0 auto;
}

.zr-rtable__tech small {
  display: block;
  color: var(--zr-muted, #4b5d66);
  font-weight: 450;
  white-space: normal;
  max-width: 16rem;
}

.zr-rtable__power {
  color: #148f45;
  font-weight: 650;
}

.zr-rnode.is-required {
  outline: 2px solid #ff5a1f;
  outline-offset: 2px;
}

/* Desktop header search: later parent rules force a 2.75rem icon width and clip the label. */
@media (min-width: 1280px) {
  .zr-search-toggle {
    flex: 0 0 auto;
    justify-content: flex-start;
    gap: 0.45rem;
    width: auto;
    min-width: 9.25rem;
    padding: 0 0.7rem;
    overflow: visible;
    color: var(--zr-muted);
  }

  .zr-search-toggle__text,
  .zr-search-toggle__kbd {
    display: inline;
  }

  .zr-search-toggle__text {
    margin-right: auto;
    font-weight: 500;
    white-space: nowrap;
  }
}
