/* QuestRouter site: one stylesheet for every page. Tokens on :root, dark mode
   from the OS setting (or data-theme on <html>). No external fonts or assets. */

:root {
  color-scheme: light;
  --surface-0: #f4f3ef;
  --surface-1: #fcfcfb;
  --surface-2: #efeee9;
  --border: #dad8d1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6b6a66;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --link: #1c5cab;
  --focus: #2a78d6;
  --bar-fill: #2a78d6;
  --bar-track: #e4e2dc;
  --goal: #52514e;
  --horde: #a3261f;
  --alliance: #1d4f91;
  --contested: #5a5850;
  --good: #0a7d0a;
  --critical: #b42b2b;
  --code-bg: #efeee9;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  --radius: 10px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #3a3a37;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #a3a29a;
    --accent: #6da7ec;
    --accent-ink: #0b0b0b;
    --link: #86b6ef;
    --focus: #86b6ef;
    --bar-fill: #3987e5;
    --bar-track: #33332f;
    --goal: #c3c2b7;
    --horde: #f08b84;
    --alliance: #8fb8f2;
    --contested: #c3c2b7;
    --good: #4cc24c;
    --critical: #f07a7a;
    --code-bg: #242422;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --border: #3a3a37;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #a3a29a;
  --accent: #6da7ec;
  --accent-ink: #0b0b0b;
  --link: #86b6ef;
  --focus: #86b6ef;
  --bar-fill: #3987e5;
  --bar-track: #33332f;
  --goal: #c3c2b7;
  --horde: #f08b84;
  --alliance: #8fb8f2;
  --contested: #c3c2b7;
  --good: #4cc24c;
  --critical: #f07a7a;
  --code-bg: #242422;
  --shadow: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* `hidden` must win over component display rules (.field, .actions are flex). */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 16px/1.55 var(--font);
  overflow-x: hidden;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

code,
kbd,
pre,
textarea.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  left: 8px;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header / footer */

.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
}

.brand svg {
  flex: none;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}

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

.site-nav a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

main.wrap {
  padding-top: 28px;
  padding-bottom: 48px;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 20px 0 32px;
}

.site-footer p {
  margin: 4px 0;
}

/* Typography */

h1 {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.2;
  margin: 0 0 8px;
}

h2 {
  font-size: 1.25rem;
  margin: 32px 0 12px;
}

h3 {
  font-size: 1.05rem;
  margin: 20px 0 8px;
}

.lede {
  color: var(--text-secondary);
  max-width: 70ch;
  margin: 0 0 20px;
}

.muted {
  color: var(--text-muted);
}

.prose {
  max-width: 72ch;
}

.prose li + li {
  margin-top: 4px;
}

/* Cards, tiles */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card {
  margin-top: 16px;
}

.card > :first-child {
  margin-top: 0;
}

.card form .field + .field {
  margin-top: 18px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}

.tile .label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.tile .value {
  display: block;
  font-size: 1.6rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tile .value.compact {
  font-size: 1.2rem;
  line-height: 1.55;
  overflow-wrap: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile .sub {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Controls */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 16px;
  margin: 0 0 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field label,
.field .label,
fieldset legend {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

input[type="text"],
input[type="search"],
select,
textarea {
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  max-width: 100%;
}

textarea {
  width: 100%;
  min-height: 9rem;
  resize: vertical;
}

input[readonly] {
  background: var(--surface-2);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-1);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.segmented input:checked + label {
  background: var(--accent);
  color: var(--accent-ink);
}

.segmented input:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
}

.button.secondary {
  background: transparent;
  color: var(--accent);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* Status messages */

.status {
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.status:empty {
  display: none;
}

.status[data-kind="ok"] {
  border-color: var(--good);
}

.status[data-kind="error"] {
  border-color: var(--critical);
}

.status .icon {
  font-weight: 700;
  margin-right: 6px;
}

.status[data-kind="ok"] .icon {
  color: var(--good);
}

.status[data-kind="error"] .icon {
  color: var(--critical);
}

/* Coverage table */

.table-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.table-note {
  font-size: 0.88rem;
  margin: 10px 0 0;
}

abbr[title] {
  text-decoration: none;
  cursor: help;
}

table.coverage {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.coverage th,
table.coverage td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

table.coverage thead th {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-2);
  white-space: nowrap;
}

table.coverage thead th button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

table.coverage thead th[aria-sort] button::after {
  content: " \2195";
  opacity: 0.45;
}

table.coverage thead th[aria-sort="ascending"] button::after {
  content: " \2191";
  opacity: 1;
}

table.coverage thead th[aria-sort="descending"] button::after {
  content: " \2193";
  opacity: 1;
}

table.coverage tbody tr:last-child td {
  border-bottom: 0;
}

table.coverage tbody tr:hover {
  background: var(--surface-2);
}

td.num,
th.num {
  text-align: right;
}

.zone-name {
  font-weight: 600;
  white-space: nowrap;
}

td.when {
  white-space: nowrap;
}

.zone-id {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.faction {
  font-size: 0.85rem;
  font-weight: 600;
}

.faction[data-faction="Horde"] {
  color: var(--horde);
}

.faction[data-faction="Alliance"] {
  color: var(--alliance);
}

.faction[data-faction="Contested"] {
  color: var(--contested);
}

.cov {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
}

.cov .pct {
  width: 3.4em;
  text-align: right;
  font-weight: 600;
}

/* Thin bar: rounded data end, 95 % goal tick (handoff success criterion). */
.bar {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--bar-track);
}

.bar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  background: var(--bar-fill);
}

.bar .goal {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 95%;
  width: 2px;
  background: var(--goal);
  border-radius: 1px;
}

.routes {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.routes li {
  white-space: nowrap;
}

.routes .gain {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.legend .swatch {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.legend .swatch.fill {
  width: 18px;
  height: 8px;
  border-radius: 4px;
  background: var(--bar-fill);
}

.legend .swatch.goal {
  width: 2px;
  height: 14px;
  background: var(--goal);
}

.empty {
  padding: 24px 16px;
  color: var(--text-secondary);
  text-align: center;
}

/* Paste page */

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
}

.kv dt {
  color: var(--text-secondary);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.chips li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
}

.session + .session {
  margin-top: 12px;
}

/* Upload page */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 28px var(--gutter);
  text-align: center;
}

.dropzone[data-over] {
  border-color: var(--accent);
  background: var(--surface-1);
}

.dropzone p {
  margin: 6px 0;
}

.dropzone .dropzone-title {
  font-size: 1.1rem;
}

.actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.paths {
  margin: 8px 0 12px;
}

.paths dt {
  font-weight: 600;
  margin-top: 8px;
}

.paths dd {
  margin: 2px 0;
}

.badge[data-state="new"],
.badge[data-state="grown"] {
  color: var(--accent);
  border-color: var(--accent);
}

.badge[data-state="accepted"] {
  color: var(--good);
  border-color: var(--good);
}

.badge[data-state="rejected"] {
  color: var(--critical);
  border-color: var(--critical);
}

.session-result:empty {
  display: none;
}

.cta {
  margin: 0 0 24px;
}

/* Footer links */

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  color: var(--text-secondary);
}

.small {
  font-size: 0.88rem;
}

/* Support, credits, data, privacy pages */

.callout {
  border-left: 4px solid var(--accent);
  margin: 8px 0 8px;
  max-width: 72ch;
}

.callout h2 {
  margin-top: 0;
}

.support-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  max-width: 72ch;
}

.support-options .card + .card {
  margin-top: 0;
}

.support-options h3 {
  margin: 0 0 4px;
}

.support-options p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.perks li + li {
  margin-top: 8px;
}

.credit-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 12px 0 8px;
}

.credit-sections .card + .card {
  margin-top: 0;
}

.credit-sections h2 {
  margin-top: 0;
}

ul.credits {
  margin: 0;
  padding: 0;
  list-style: none;
}

.credit {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.credit:last-child {
  border-bottom: 0;
}

.credit-name {
  font-weight: 600;
}

.credit-note {
  display: block;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 1px;
}

.consent-quote {
  margin: 8px 0 12px;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}

.license-summary {
  margin: 4px 0 8px;
}

.license-summary h2 {
  margin-top: 0;
}

.toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}

/* Dashboard sponsor slot: empty and hidden unless config.js sets SPONSOR. */

.sponsor {
  margin: 28px 0 0;
}

.sponsor-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  background: var(--surface-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  max-width: 72ch;
}

.sponsor-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sponsor-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.sponsor-link img {
  border-radius: 6px;
}

.sponsor-text {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* Phone width: the coverage table becomes one card per zone. */
@media (max-width: 720px) {
  .tile .value.compact {
    font-size: 1rem;
  }

  table.coverage thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  table.coverage,
  table.coverage tbody,
  table.coverage tr,
  table.coverage td {
    display: block;
    width: 100%;
  }

  table.coverage tr {
    padding: 10px 14px;
    min-width: 0;
    border-bottom: 1px solid var(--border);
  }

  table.coverage td {
    border: 0;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
  }

  table.coverage td::before {
    content: attr(data-label);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: left;
    flex: none;
  }

  table.coverage td.zone-cell {
    display: block;
    text-align: left;
  }

  table.coverage td.zone-cell::before {
    content: none;
  }

  .cov {
    min-width: 0;
    flex: 1;
    max-width: 260px;
  }

  .routes li {
    white-space: normal;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .kv dd {
    margin-bottom: 6px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .bar .fill {
    transition: width 0.3s ease-out;
  }
}

@media (forced-colors: active) {
  .bar {
    border: 1px solid CanvasText;
  }

  .bar .fill {
    background: Highlight;
  }

  .bar .goal {
    background: CanvasText;
  }
}
