/* Theme colours Bootstrap has no variable for. Everything else uses --bs-* so it follows data-bs-theme. */
:root {
  --pfkm-warn-text: #a15c00;
  --pfkm-hover-bg: #eef4ff;
  --pfkm-selected-bg: #dbe9ff;
  --pfkm-swatch-border: rgba(0, 0, 0, 0.35);
}

[data-bs-theme=dark] {
  --pfkm-warn-text: #f0b352;
  --pfkm-hover-bg: #1c2a44;
  --pfkm-selected-bg: #243a63;
  --pfkm-swatch-border: rgba(255, 255, 255, 0.35);
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--bs-body-bg), 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* --- kingdom pages --- */
.kingdom-swatch {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 3px;
  border: 1px solid var(--pfkm-swatch-border);
  margin-right: 0.4em;
}

.kingdom-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
}

.kingdom-facts dt { font-weight: 400; font-size: 0.8rem; color: var(--bs-secondary-color); }
.kingdom-facts dd { margin: 0; font-size: 1.15rem; }
.stat-sources summary { cursor: pointer; color: var(--bs-secondary-color); }
.leader-mod { width: 5rem; }

.ledger-bar { height: 7px; min-width: 1px; border-radius: 2px; margin: 2px 0; }
.ledger-bar.income { background: var(--bs-success); }
.ledger-bar.spending { background: var(--bs-danger); }

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}
/* --- turn wizard --- */
.turn-step {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}
.turn-step.done { text-decoration: line-through; }
.turn-step.current {
  border-color: var(--bs-primary);
  background: var(--bs-primary);
  color: #fff;
}
.turn-phase {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
  margin-right: 0.25rem;
}
.turn-roll { width: 7.5rem; }

/* Edict phase checklist: a tick, the task, then its buttons. */
.turn-tasks > li { padding: 0.45rem 0; border-bottom: 1px solid var(--bs-border-color-translucent); }
.turn-task-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.turn-task-head form { display: contents; }
.turn-task-done { color: var(--bs-secondary-color); }
.turn-task-actions { margin: 0.35rem 0 0 1.9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
/* The edict selects are a Bootstrap row, which brings its own gutters. */
form.turn-task-actions { gap: 0; margin-right: 0; }
.turn-tick {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--bs-secondary-color);
  border-radius: 4px;
  background: var(--bs-body-bg);
  color: transparent;
  font-size: 0.9rem;
  line-height: 1;
}
.turn-tick.done { background: var(--bs-success); border-color: var(--bs-success); color: #fff; }
button.turn-tick:hover { border-color: var(--bs-primary); }

/* Hex picker modal: the map on the left, the chosen hex on the right. */
.hex-picker { display: flex; gap: 12px; height: min(70vh, 720px); min-height: 320px; }
.hex-picker .hexmap-svg { flex: 1; min-width: 0; height: 100%; }
.hex-picker-side { width: 300px; flex-shrink: 0; overflow-y: auto; font-size: 0.875rem; }
.hex-picker .picker-status { min-height: 1.4em; margin-bottom: 0.5rem; }
.hex-picker .hex.pick-dim { opacity: 0.4; }
.hex-picker .hex.pick-ok .terrain { stroke: #facc15; stroke-width: 3; cursor: pointer; }
/* Over a background picture the terrain is only a tint, so hexes that cannot be chosen are darkened instead of faded. */
.hex-picker .hexmap-svg.has-background .hex.pick-ok .terrain:not(.fog) { stroke: #facc15; }
.hex-picker .has-background .hex.pick-dim { opacity: 1; }
.hex-picker .has-background .hex.pick-dim .terrain:not(.fog) { fill: #000 !important; fill-opacity: 0.5; }
.hex-picker .picker-action { margin-bottom: 0.6rem; }
.hex-picker .picker-blocked { margin-top: 0.3rem; color: var(--bs-secondary-color); }
.hex-picker details summary { cursor: pointer; color: var(--bs-secondary-color); }
@media (max-width: 900px) {
  .hex-picker { flex-direction: column; height: auto; }
  .hex-picker .hexmap-svg { height: 55vh; flex: none; }
  .hex-picker-side { width: 100%; }
}
.turn-log li { padding: 0.3rem 0; border-bottom: 1px solid var(--bs-border-color-translucent); }

/* --- printable sheets --- */
.print-sheet { max-width: 60rem; }
.print-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; align-items: start; }
.print-stat table td { padding: 0 0 1px; vertical-align: top; }
.print-district {
  display: grid;
  /* Six lots in three blocks of two, with a street after every second lot. */
  grid-template-columns: repeat(2, 1fr) 0.6rem repeat(2, 1fr) 0.6rem repeat(2, 1fr);
  grid-template-rows: repeat(2, 4rem) 0.6rem repeat(2, 4rem) 0.6rem repeat(2, 4rem);
  gap: 2px;
  width: 36rem;
  max-width: 100%;
}
.print-lot {
  border: 1px solid var(--bs-body-color);
  padding: 2px 4px;
  font-size: 0.75rem;
  line-height: 1.15;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background: var(--bs-body-bg);
}
.print-lot.empty { border: 1px dashed var(--bs-secondary-color); }
.print-lot.ruin { font-style: italic; color: var(--bs-secondary-color); }
.print-border-label { width: 36rem; max-width: 100%; text-align: center; font-size: 0.75rem; color: var(--bs-secondary-color); }
.print-border-side { writing-mode: vertical-rl; font-size: 0.75rem; color: var(--bs-secondary-color); }
.print-district-block { break-inside: avoid; }

@media print {
  body { margin-bottom: 0; }
  .container, .container-fluid { max-width: none; padding: 0; }
  .print-sheet { max-width: none; }
  a { color: inherit; text-decoration: none; }
  .kingdom-facts dt, .print-border-label, .print-border-side { color: #444; }
}
@media (max-width: 767px) {
  .print-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Icons in the top bar sit just before their label. */
.nav-icon {
  margin-right: .35em;
}

/* An icon at the start of a button sits just before its label. */
.btn > .ra:first-child {
  margin-right: .35em;
}
