/* Starward Empires manual. Tokens, nav and footer mirror index.html - keep them in step. */

:root {
  --bg:            #0C0E15;
  --bg-2:          #12141C;
  --surface:       #171B27;
  --surface-2:     #1F2534;
  --border:        #262D3D;
  --border-strong: #39415A;
  --accent:        #4FA8E0;
  --accent-bright: #74C0F2;
  --accent-dim:    #2E6E9E;
  --text:          #E6ECF5;
  --text-2:        #AEB9CC;
  --muted:         #78859C;
  /* --muted falls just short of 4.5:1 on the table header and hovered search rows */
  --muted-strong:  #8E9AB0;
  --display: 'Space Grotesk', sans-serif;
  --mono: 'Space Mono', 'SFMono-Regular', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  font-family: var(--display);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

.starfield {
  position: fixed;
  inset: 0;
  background-image: url('../assets/starfield.webp');
  background-size: 256px 256px;
  opacity: 0.4;
  z-index: -2;
  pointer-events: none;
}
.starfield::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12,14,21,0.35) 0%, var(--bg) 60%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); }
a:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 3px; }

/* For a screen reader only - e.g. the name of a button the game draws as a bare glyph */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── NAV ─────────────────────────────────────────── */
nav.top {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12,14,21,0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
nav.top .inner {
  max-width: 1120px; margin: 0 auto;
  height: 62px; padding: 0 1.75rem;
  display: flex; align-items: center; justify-content: space-between;
}
nav.top .logo {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
  color: var(--text);
}
nav.top .logo img { width: 30px; height: 30px; display: block; }
nav.top .links { display: flex; gap: 1.75rem; }
nav.top .links a {
  color: var(--text-2); font-size: 0.9rem; font-weight: 500;
  transition: color 0.15s;
}
nav.top .links a:hover,
nav.top .links a[aria-current] { color: var(--text); }

/* ── LAYOUT ──────────────────────────────────────── */
.manual {
  max-width: 1120px; margin: 0 auto;
  padding: 2.25rem 1.75rem 3rem;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.side {
  position: sticky; top: 84px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  font-size: 0.9rem;
}
.side .label {
  font-family: var(--mono); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 0.5rem;
}
.side nav + nav { margin-top: 1.75rem; }
.side ul { list-style: none; }
.sections a, .toc a {
  display: block;
  padding: 0.3rem 0.7rem;
  border-left: 2px solid var(--border);
  color: var(--text-2);
}
.sections a:hover, .toc a:hover { color: var(--text); border-left-color: var(--border-strong); }
.sections a[aria-current] {
  color: var(--text); font-weight: 600;
  border-left-color: var(--accent);
  background: rgba(79,168,224,0.06);
}
.toc ul ul a { padding-left: 1.5rem; font-size: 0.84rem; color: var(--muted); }

/* ── SEARCH ──────────────────────────────────────── */
.search { position: relative; margin-bottom: 1.5rem; }
.search input {
  width: 100%;
  font-family: var(--display); font-size: 0.92rem; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 0.6rem 0.85rem;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }
.search input:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.search .results {
  list-style: none;
  margin-top: 0.5rem;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.search .results:empty { display: none; }
.search .results a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  color: var(--text); font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.search .results li:last-child a { border-bottom: none; }
.search .results a:hover, .search .results a:focus-visible { background: var(--surface-2); }
/* Inset, as the list clips anything drawn outside a row */
.search .results a:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -2px; border-radius: 8px; }
.search .results .where, .search .results .none {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-strong); white-space: nowrap;
}
.search .results .none { display: block; padding: 0.6rem 0.85rem; }
.search.big { max-width: 34rem; margin: 1.75rem 0 2.25rem; }
.search.big input { font-size: 1rem; padding: 0.8rem 1rem; }

/* ── ARTICLE ─────────────────────────────────────── */
.crumbs {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
article .crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; max-width: none; }
article .crumbs li { font-size: inherit; line-height: inherit; color: inherit; margin: 0; }
.crumbs li + li::before { content: '/'; margin-right: 0.4rem; color: var(--border-strong); }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); }

article h1 {
  font-size: 2.3rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1;
  margin-bottom: 0.75rem;
}
article h2 {
  font-size: 1.4rem; font-weight: 700; letter-spacing: -0.015em;
  margin: 2.75rem 0 0.9rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
article h3 { font-size: 1.05rem; font-weight: 600; margin: 1.9rem 0 0.6rem; }
article p, article li, article dd { color: var(--text-2); font-size: 0.95rem; line-height: 1.75; }
article p { margin-bottom: 1rem; max-width: 46rem; }
article ul, article ol { margin: 0 0 1.1rem 1.3rem; max-width: 46rem; }
article li { margin-bottom: 0.35rem; }
article strong { color: var(--text); font-weight: 600; }
article .lead { font-size: 1.08rem; color: var(--text); }
article .meta {
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.03em;
  color: var(--muted);
}
article > .meta:last-child {
  margin-top: 2.75rem; padding-top: 1.25rem; max-width: none;
  border-top: 1px solid var(--border);
}

aside.note {
  border: 1px solid var(--accent-dim); border-radius: 12px;
  background: rgba(79,168,224,0.06);
  padding: 0.9rem 1.1rem;
  margin: 1.25rem 0;
  max-width: 46rem;
}
aside.note p { margin: 0; color: var(--text); }

/* Facts list at the top of a reference page */
dl.facts {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.4rem 1.5rem;
  margin: 1.5rem 0 0.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border); border-radius: 12px;
  background: rgba(23,27,39,0.6);
  max-width: 46rem;
}
dl.facts dt {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  padding-top: 0.3rem;
}
dl.facts dd { color: var(--text); }

/* ── TABLES ──────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--border); border-radius: 12px;
  background: rgba(23,27,39,0.6);
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.9rem; text-align: left; vertical-align: top; }
thead th {
  font-family: var(--mono); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-strong);
  background: rgba(31,37,52,0.7);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
/* A row's own header (its tier, level or name) reads as an ordinary first cell */
td, tbody th { color: var(--text-2); border-bottom: 1px solid var(--border); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: none; }
td:first-child, tbody th { color: var(--text); font-weight: 500; }
td.num, th.num { text-align: right; }
td.num { font-family: var(--mono); font-size: 0.84rem; white-space: nowrap; }
td.num .quiet { font-family: var(--display); }
td.name, td.tier, td.nowrap, tbody th { white-space: nowrap; }
tr:target td, tr:target th { background: rgba(79,168,224,0.1); }
.start {
  display: inline-block;
  margin-left: 0.25rem;
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent);
  border: 1px solid var(--accent-dim); border-radius: 999px;
  padding: 0.05rem 0.5rem;
  white-space: nowrap;
}
td ul.plain { list-style: none; margin: 0; }
td ul.plain li { font-size: inherit; line-height: 1.6; margin: 0; }
td .quiet { color: var(--muted); }

/* ── PICTURES ────────────────────────────────────── */
/* The game's own facility and component art. It is drawn for a dark screen, so it sits
   straight on the page; the corners are only rounded for the few full-bleed tiles. */
.masthead { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 0.25rem; }
.masthead > div { min-width: 0; }
.masthead .lead { margin-bottom: 0; }
img.art { flex: none; width: 128px; height: 128px; border-radius: 14px; }
img.thumb {
  width: 40px; height: 40px;
  margin: -0.35rem 0.7rem -0.35rem 0;
  vertical-align: middle;
  border-radius: 6px;
}
img.thumb.small { width: 28px; height: 28px; margin: -0.2rem 0.5rem -0.2rem 0; border-radius: 4px; }
td ul.plain li + li { margin-top: 0.35rem; }
/* A picture and its name stay on one line - the table scrolls sideways before they split */
td ul.plain a:has(img.thumb) { white-space: nowrap; }

/* Action-button icons in the tutorial */
img.verb {
  width: 28px; height: 28px;
  box-sizing: content-box;
  padding: 5px;
  margin-right: 0.6rem;
  vertical-align: middle;
  background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 9px;
}
td:has(> img.verb) { white-space: nowrap; }

/* ── HOME CARDS ──────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem; margin-top: 0.5rem; }
.card {
  display: block;
  border: 1px solid var(--border); border-radius: 14px;
  background: linear-gradient(180deg, rgba(23,27,39,0.7), rgba(18,20,28,0.7));
  padding: 1.4rem 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card .kicker {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
  display: block; margin-bottom: 0.6rem;
}
.card h2 {
  font-size: 1.15rem; font-weight: 600; color: var(--text);
  margin: 0 0 0.35rem; padding: 0; border: none;
}
.card p { font-size: 0.9rem; margin: 0; }

/* ── FOOTER ──────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 2.25rem 0;
}
footer .inner {
  max-width: 1120px; margin: 0 auto; padding: 0 1.75rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
footer .brand { display: flex; align-items: center; gap: 0.55rem; color: var(--text-2); font-size: 0.88rem; }
footer .brand img { width: 22px; height: 22px; }
footer .flinks { display: flex; gap: 1.4rem; font-size: 0.85rem; flex-wrap: wrap; }
footer .flinks a { color: var(--text-2); }
footer .flinks a:hover { color: var(--text); }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 860px) {
  nav.top .links { display: none; }
  nav.top .inner, footer .inner { padding: 0 1.1rem; }
  .manual { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding: 1.25rem 1.1rem 2.5rem; }

  /* The sidebar becomes a strip of section links, then the page's contents as chips */
  .side { position: static; max-height: none; overflow: visible; }
  .side .label { display: none; }
  .sections ul, .toc > ul { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .sections a, .toc > ul > li > a {
    border: 1px solid var(--border-strong); border-radius: 999px;
    padding: 0.25rem 0.75rem; font-size: 0.82rem;
  }
  .sections a[aria-current] { border-color: var(--accent); }
  .toc { margin-top: 0.75rem; }
  .toc > ul > li > a { border-color: var(--border); color: var(--muted); }
  .toc ul ul { display: none; }
  .search { margin-bottom: 0.9rem; }

  article h1 { font-size: 1.85rem; }
  article h2 { font-size: 1.25rem; margin-top: 2.25rem; }
  .masthead { gap: 1rem; align-items: flex-start; }
  img.art { width: 84px; height: 84px; border-radius: 10px; }
  th, td { padding: 0.55rem 0.7rem; }
  /* Let a wide table scroll rather than squeeze its prose into a ribbon */
  td:not(:first-child):not(.num):not(.tier):not(.nowrap) { min-width: 11rem; }
  td:nth-child(3):last-child:not(.num) { min-width: 16rem; }
  .cards { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: 0.5rem; }
}
