/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

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

:root {
  --color-bg: #ffffff;
  --color-fg: #1a1a1a;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-accent: #2563eb;
  --color-accent-muted: #eff6ff;
  --color-code-bg: #f3f4f6;
  --color-badge-bg: #f3f4f6;
  --color-badge-analyzed-bg: #ecfdf5;
  --color-badge-analyzed-fg: #047857;
  --color-trend-up: #047857;
  --color-trend-down: #b91c1c;
}

@media screen and (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121212;
    --color-fg: #e5e7eb;
    --color-muted: #9ca3af;
    --color-border: #2e2e2e;
    --color-accent: #7aa2f7;
    --color-accent-muted: #1b2333;
    --color-code-bg: #1e1e1e;
    --color-badge-bg: #1e1e1e;
    --color-badge-analyzed-bg: #0d2818;
    --color-badge-analyzed-fg: #34d399;
    --color-trend-up: #34d399;
    --color-trend-down: #f87171;
  }
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell,
    "Helvetica Neue", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  padding: 2.5rem 1.5rem;
  background-color: var(--color-bg);
  color: var(--color-fg);
}

.container {
  max-width: 860px;
  margin: 0 auto;
}

h1, h2, h3 {
  line-height: 1.3;
}

h1 {
  font-size: 1.9rem;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.3rem;
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

h2[id] {
  scroll-margin-top: 1rem;
}

.heading-anchor {
  color: var(--color-muted);
  opacity: 0.3;
  transition: opacity 0.1s ease;
}

.heading-anchor svg {
  vertical-align: middle;
}

h2:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
  text-decoration: none;
}

h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--color-muted);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

p {
  margin: 0.5rem 0;
}

.subtitle {
  color: var(--color-muted);
  margin-top: 0;
}

ul, ol {
  padding-left: 1.4rem;
}

li {
  margin: 0.3rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1.5rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

/* A wonder race spans one row per losing contender; keep the wonder,
   winner and finish at the top of the group rather than centred in it. */
.wonder-races td[rowspan] {
  vertical-align: top;
}

th {
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

code {
  background-color: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

pre {
  background-color: var(--color-code-bg);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--color-accent);
  background-color: var(--color-accent-muted);
  color: var(--color-fg);
}

.badge {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  background-color: var(--color-badge-bg);
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.badge--analyzed {
  background-color: var(--color-badge-analyzed-bg);
  color: var(--color-badge-analyzed-fg);
}

.digest-section {
  margin: 0.75rem 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.digest-section--empty {
  opacity: 0.6;
}

.digest-section summary {
  cursor: pointer;
  font-weight: 600;
  font-family: monospace;
}

.digest-section pre {
  margin: 0.75rem 0 0.25rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.meta {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.report {
  margin-top: 1rem;
}

.empty-state {
  color: var(--color-muted);
}

.capital-layout {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.capital-layout text {
  text-anchor: middle;
}

.capital-layout .corridor {
  stroke: var(--color-border);
  stroke-width: 1.5;
}

.capital--major circle {
  fill: var(--color-accent);
}

.capital--major text {
  fill: var(--color-fg);
  font-size: 14px;
}

.capital--minor circle {
  fill: var(--color-muted);
}

.capital--minor text {
  fill: var(--color-muted);
  font-size: 11px;
}

.buffer-city text {
  fill: var(--color-muted);
  font-size: 11px;
}

/*
 * Per-civ colour: the data-viz reference categorical palette, fixed order.
 * A capital and its buffer cities share a slot. The label always stays in
 * ink (rules above) - the slot only fills the dot - so identity is carried
 * by the label and position, not by colour alone. Slots outnumbering the
 * palette fall back to var(--color-accent).
 */
.capital-layout .map-civ-0 circle { fill: #2a78d6; }
.capital-layout .map-civ-1 circle { fill: #eb6834; }
.capital-layout .map-civ-2 circle { fill: #1baf7a; }
.capital-layout .map-civ-3 circle { fill: #eda100; }
.capital-layout .map-civ-4 circle { fill: #e87ba4; }
.capital-layout .map-civ-5 circle { fill: #008300; }
.capital-layout .map-civ-6 circle { fill: #4a3aa7; }
.capital-layout .map-civ-7 circle { fill: #e34948; }

@media (prefers-color-scheme: dark) {
  .capital-layout .map-civ-0 circle { fill: #3987e5; }
  .capital-layout .map-civ-1 circle { fill: #d95926; }
  .capital-layout .map-civ-2 circle { fill: #199e70; }
  .capital-layout .map-civ-3 circle { fill: #c98500; }
  .capital-layout .map-civ-4 circle { fill: #d55181; }
  .capital-layout .map-civ-5 circle { fill: #008300; }
  .capital-layout .map-civ-6 circle { fill: #9085e9; }
  .capital-layout .map-civ-7 circle { fill: #e66767; }
}

.trend {
  margin-right: 0.4rem;
  font-size: 0.85em;
}

.trend--up {
  color: var(--color-trend-up);
}

.trend--down {
  color: var(--color-trend-down);
}

.moments {
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 0;
}

.moments summary {
  cursor: pointer;
  font-weight: 600;
}

.disclosure {
  margin: 0.5rem 0 1rem;
}

.disclosure summary {
  cursor: pointer;
  width: fit-content;
  color: var(--color-accent);
}

.disclosure > table,
.disclosure > .note {
  margin-top: 0.5rem;
}

.moment-detail {
  color: var(--color-muted);
  font-size: 0.9em;
  margin: 0.15rem 0 0.4rem;
}

.note {
  color: var(--color-muted);
  font-size: 0.9rem;
  max-width: 60ch;
}
