/* ══════════════════════════════════════════════════════════════════
   COMMON.CSS — styles every page shares
   ══════════════════════════════════════════════════════════════════
   Linked from all four pages (index, login, map, simulator) BEFORE each
   page's own inline <style>, so a page can still override anything here.

   What lives here:
     1. Theme variables — the palette, fonts and radii every page uses.
        Change a colour here and it changes everywhere. (Variables only
        ONE page needs — e.g. the map's --core teal or index.html's
        --sidebar-w — stay in that page's own :root.)
     2. The reset and the [hidden] rule.
     3. .nav-btn — the top-bar button used on every page.
     4. Components that shared-ui.js builds on every page: the
        "can't reach the server" banner, the bug-report dialog and the
        build label.

   Everything else is still in each page's inline <style>; when a rule is
   needed by a second page, move it here rather than copying it.
   ══════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════
   1. THEME VARIABLES
══════════════════════════════════════ */
:root {
  /* Backgrounds, from the outer canvas down to panels */
  --bg-canvas:      #2a4a6b;
  --bg-topbar-top:  #1a2030;
  --bg-topbar-bot:  #0d1117;
  --bg-panel:       #0f161f;

  /* Borders — plain, and a warmer gold one for emphasis */
  --border:         #2a3444;
  --border-gold:    #6b5a2a;

  /* The gold accent family */
  --gold:           #c8a84b;
  --gold-dim:       #8a7030;
  --gold-bright:    #e8c86a;

  /* Errors and warnings */
  --error:          #c85a4b;
  --error-bright:   #e07a6a;

  /* Text, brightest to dimmest */
  --text-primary:   #e8dcc8;
  --text-secondary: #9a8870;
  --text-muted:     #5a5040;

  /* Fonts: Cinzel for headings/labels, Inter for body text */
  --ff-display:     'Cinzel', serif;
  --ff-body:        'Inter', sans-serif;

  /* Corner radii */
  --radius-sm:      3px;
  --radius-md:      8px;
  --radius-lg:      12px;
}

/* ══════════════════════════════════════
   2. RESET
══════════════════════════════════════ */
/* border-box: an element's width includes its padding and border, which
   keeps layout maths predictable; zeroing margin/padding removes each
   browser's own default spacing. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Makes the HTML `hidden` attribute win over classes that set `display`
   (like .nav-btn's flex), so hidden things actually stay hidden. */
[hidden] { display: none !important; }

/* ══════════════════════════════════════
   3. TOP-BAR BUTTON
══════════════════════════════════════ */
.nav-btn {
  display: flex;
  align-items: center;
  padding: 7px 18px;
  font-family: var(--ff-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-transform: uppercase;
  transition: all 0.15s;
}
.nav-btn:not(:disabled):hover,
.nav-btn.active {
  color: var(--gold-bright);
  border-color: var(--border-gold);
  background: rgba(200,168,75,0.08);
}
/* The main action in a row of buttons (e.g. a dialog's confirm button). */
.nav-btn.primary {
  color: var(--gold-bright);
  border-color: var(--border-gold);
  background: rgba(200,168,75,0.12);
}
.nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
/* Keyboard focus ring, shared by every button built from .nav-btn. */
.nav-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ══════════════════════════════════════
   4a. CONNECTION BANNER (shared-ui.js → showConnectionBanner)
   A bar pinned under the top bar while the page can't get data from the
   server: what's wrong in one line, an optional detail line, and Retry.
   It stays until the next successful load hides it — unlike a toast, it
   doesn't vanish while the problem is still there.
══════════════════════════════════════ */
#connection-banner {
  position: fixed;
  top: 60px; /* just under the 52px top bar every page has */
  left: 50%;
  transform: translateX(-50%);
  z-index: 300; /* above modals and toasts: nothing else on screen is current while this shows */
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(640px, calc(100vw - 32px));
  padding: 10px 12px 10px 16px;
  background: rgba(10,10,10,0.96);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-family: var(--ff-body);
}
.connection-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.connection-banner-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--error-bright);
}
.connection-banner-detail {
  font-size: 12px;
  color: var(--text-secondary);
  overflow-wrap: anywhere; /* a long server message wraps instead of widening the bar */
}
#connection-banner .nav-btn {
  flex-shrink: 0;
  padding: 6px 14px;
}

/* ══════════════════════════════════════
   4b. BUG-REPORT DIALOG (shared-ui.js → openBugReport)
   A centred dialog: a box for what happened, the details collected
   automatically (shown so the tester sees exactly what's being shared),
   and a Copy button that puts both on the clipboard to paste into the
   beta's bug channel.
══════════════════════════════════════ */
#bug-report-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.6);
}
#bug-report {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  font-family: var(--ff-body);
  color: var(--text-primary);
}
#bug-report h2 {
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-bright);
}
.bug-report-intro {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.bug-report-label {
  font-family: var(--ff-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
#bug-report-text {
  width: 100%;
  min-height: 96px;
  padding: 10px;
  resize: vertical;
  font: 14px/1.4 var(--ff-body);
  color: var(--text-primary);
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
#bug-report-text:focus {
  outline: none;
  border-color: var(--border-gold);
}
#bug-report-details {
  max-height: 160px;
  overflow: auto;
  padding: 10px;
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bug-report-buttons {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.bug-report-status {
  margin-right: auto;
  font-size: 13px;
  color: var(--gold-bright);
}

/* ══════════════════════════════════════
   4c. BUILD LABEL (shared-ui.js → mountBuildLabel)
   Which build of the game this is, in the bottom-left corner, so a
   screenshot always says what version it came from. Deliberately quiet,
   and click-through so it never blocks the page under it.
══════════════════════════════════════ */
/* Bottom-centre: the one spot no page uses — the city view's side panels
   fill the bottom corners, and the map keeps its hint and coordinates there. */
#build-label {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 6px;
  z-index: 5;
  font-family: var(--ff-body);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
}
