/* Ban — parchment and heraldry.

   Light: a manuscript page, ink and gold leaf. Dark: the same page by
   candlelight. Every colour is a token below; nothing else names a colour.
   The theme follows the system unless the player picks one (data-theme on
   <html>, remembered by tick.js). No web fonts and no outside requests: the
   serif stack uses what the reader's system already has. */

:root {
  --bg: #ece0c6;
  --bg-deep: #e2d2b0;
  --page: #f8f0dd;
  --page-hi: #fdf8ea;
  --line: #ccb68b;
  --line-soft: #e3d3ad;
  --ink: #2c2116;
  --muted: #6f5d45;
  --gold: #946517;
  --gold-hi: #c99a3e;
  --gold-ink: #fff7e3;
  --gules: #8f2a1f;
  --vert: #3c6a34;
  --azur: #2c4d88;
  --sinople: #356b42;
  --sable: #2e2a26;
  --shade: rgba(74, 48, 12, 0.14);
  --wash: rgba(148, 101, 23, 0.07);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15100b;
    --bg-deep: #0f0b07;
    --page: #211910;
    --page-hi: #2a2015;
    --line: #4d3d28;
    --line-soft: #34291b;
    --ink: #eee1c6;
    --muted: #b09d7c;
    --gold: #d8a94c;
    --gold-hi: #e9c26e;
    --gold-ink: #1b140b;
    --gules: #e07a66;
    --vert: #93c477;
    --azur: #8eabe8;
    --sinople: #82c48b;
    --sable: #d3c9b8;
    --shade: rgba(0, 0, 0, 0.45);
    --wash: rgba(216, 169, 76, 0.07);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15100b;
  --bg-deep: #0f0b07;
  --page: #211910;
  --page-hi: #2a2015;
  --line: #4d3d28;
  --line-soft: #34291b;
  --ink: #eee1c6;
  --muted: #b09d7c;
  --gold: #d8a94c;
  --gold-hi: #e9c26e;
  --gold-ink: #1b140b;
  --gules: #e07a66;
  --vert: #93c477;
  --azur: #8eabe8;
  --sinople: #82c48b;
  --sable: #d3c9b8;
  --shade: rgba(0, 0, 0, 0.45);
  --wash: rgba(216, 169, 76, 0.07);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg-deep); }

body {
  margin: 0;
  padding: 0 0 3rem;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, var(--wash), transparent 55%),
    radial-gradient(ellipse at 90% 100%, var(--wash), transparent 50%),
    var(--bg);
  font: 17px/1.55 "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand {
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

h1 { margin: 0 0 0.25rem; font-size: 1.7rem; }
h2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 1.12rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--gold);
}
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; color: var(--muted); font-variant: small-caps; letter-spacing: 0.05em; }

a { color: var(--gold); }
a:hover { color: var(--gold-hi); }

.ico {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  flex: none;
}

/* --- Top bar --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.6rem 1.25rem;
  background: var(--page);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px var(--shade);
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gold);
  font-size: 1.35rem;
  text-decoration: none;
  font-variant: small-caps;
  letter-spacing: 0.12em;
}
.brand .ico { width: 1.4em; height: 1.4em; }
.nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink);
  text-decoration: none;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}
.nav a:hover { color: var(--gold); }
.nav .ico { color: var(--gold); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 0.9rem; }
.who { color: var(--muted); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.25rem 0.4rem;
  border-radius: 999px;
  line-height: 1;
}
.theme-toggle .theme-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-light { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-light { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .theme-dark { display: inline; }
}

/* --- Page and cards -------------------------------------------------------- */

main { max-width: 76rem; margin: 0 auto; padding: 1.25rem; }
main.etroit { max-width: 48rem; }

.card {
  position: relative;
  background: linear-gradient(var(--page-hi), var(--page));
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1rem 1.25rem 1.1rem;
  margin-bottom: 1rem;
  /* A manuscript page: an inner rule a few pixels inside the edge. */
  box-shadow: inset 0 0 0 4px var(--page), inset 0 0 0 5px var(--line-soft), 0 2px 8px var(--shade);
}

.entete {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.entete .blason { width: 2.6rem; height: 2.6rem; }
.entete p { margin: 0; }

.colonnes {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 0 1rem;
  align-items: start;
}
@media (max-width: 980px) {
  .colonnes { grid-template-columns: minmax(0, 1fr); }
}

.fine { color: var(--muted); font-size: 0.875rem; }
.encours { color: var(--gold); font-variant-numeric: tabular-nums; }
.gain { display: block; color: var(--vert); }
.verrou { color: var(--gold); }
.cout .manque { color: var(--gules); }

/* --- Resources ------------------------------------------------------------- */

.ressources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.5rem;
}
.ressource {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "ico nom" "ico val" "ico taux";
  column-gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--wash);
}
.ressource .res-ico { grid-area: ico; color: var(--gold); align-self: center; }
.ressource .res-ico .ico { width: 1.9rem; height: 1.9rem; }
.res-nom { grid-area: nom; color: var(--muted); font-size: 0.85rem; font-variant: small-caps; letter-spacing: 0.04em; }
.res-valeur { grid-area: val; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.res-cap { color: var(--muted); font-size: 0.8rem; }
.res-taux { grid-area: taux; font-variant-numeric: tabular-nums; color: var(--vert); font-size: 0.85rem; }
.res-taux.negatif { color: var(--gules); }
.ressource.peuple { border-color: var(--gold); }

/* --- Lists of buildings, troops, heroes ------------------------------------ */

.batiments, .troupes { list-style: none; margin: 0; padding: 0; }
.batiment { border-top: 1px solid var(--line-soft); padding: 0.8rem 0; }
.batiment:first-child { border-top: 0; padding-top: 0.2rem; }
.batiment.verrouille { opacity: 0.6; }
.bt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.niveau { color: var(--muted); font-size: 0.875rem; font-variant: small-caps; }
.troupes > li { border-top: 1px solid var(--line-soft); padding: 0.45rem 0; }
.troupes > li:first-child { border-top: 0; }
.troupes .ico { color: var(--gold); margin-right: 0.2rem; }
.armee .fine { margin: 0.2rem 0; }

/* --- Forms ----------------------------------------------------------------- */

form { margin: 0; }
form.inline { display: inline; }
label { color: var(--muted); font-size: 0.875rem; }

button, .button {
  display: inline-block;
  padding: 0.42rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--gold) 70%, black);
  border-radius: 3px;
  background: linear-gradient(var(--gold-hi), var(--gold));
  color: var(--gold-ink);
  font: inherit;
  font-size: 0.95rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px var(--shade);
}
button:hover, .button:hover { filter: brightness(1.06); color: var(--gold-ink); }
button:disabled {
  background: var(--line-soft);
  border-color: var(--line);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
  filter: none;
}
button.link {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  color: var(--muted);
  font-variant: normal;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.link:hover { color: var(--gold); filter: none; }

input, select {
  background: var(--page-hi);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.95rem;
  min-width: 14rem;
  max-width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 2px;
}
input.petit { min-width: 4.5rem; width: 5.5rem; }

.envoi { margin-top: 0.75rem; border-top: 1px solid var(--line-soft); padding-top: 0.6rem; }
.envoi summary { cursor: pointer; color: var(--gold); font-variant: small-caps; letter-spacing: 0.04em; }
.envoi p { margin: 0.5rem 0; }

/* --- Tables ---------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.35rem 0.45rem; border-top: 1px solid var(--line-soft); vertical-align: baseline; }
th { color: var(--muted); font-weight: 500; font-variant: small-caps; letter-spacing: 0.04em; border-top: 0; }
tr:nth-child(even) td { background: var(--wash); }
.table-defile { overflow-x: auto; }

/* --- Messages and alerts --------------------------------------------------- */

.messages { list-style: none; max-width: 76rem; margin: 1rem auto 0; padding: 0 1.25rem; }
.msg {
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--page);
}
.msg.error { border-left-color: var(--gules); }
.msg.success { border-left-color: var(--vert); }

.alerte { border-color: var(--gules); }
.alerte::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--gules);
}
.alerte h2 { color: var(--gules); }
.faveurs { border-color: var(--gold); }
.nonlu { border-left: 3px solid var(--gold); padding-left: 0.5rem; }
.refus h1 { color: var(--gules); }

code { background: var(--wash); border: 1px solid var(--line-soft); padding: 0.05rem 0.3rem; border-radius: 3px; font-size: 0.875em; }

/* --- Heraldry -------------------------------------------------------------- */

.blason { stroke-width: 2.2; }
.blason.azur { color: var(--azur); }
.blason.sinople { color: var(--sinople); }
.blason.gueules { color: var(--gules); }
.blason.sable { color: var(--sable); }
.blason.or { color: var(--gold); }

/* --- The map --------------------------------------------------------------- */

.carte svg.plan { width: 100%; height: auto; display: block; }
.carte .route { stroke: var(--line); stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; }
.carte .route-heures { fill: var(--muted); font-size: 15px; text-anchor: middle; }
.carte .province circle.terre { fill: var(--page-hi); stroke: var(--line); stroke-width: 2; }
.carte .province:hover circle.terre { stroke: var(--gold); }
.carte .province.chez-moi circle.terre { stroke: var(--gold); stroke-width: 4; }
.carte .province.choisie circle.terre { fill: var(--wash); stroke: var(--gold-hi); stroke-width: 4; }
.carte .province text { fill: var(--ink); font-size: 17px; text-anchor: middle; font-family: inherit; }
.carte .province .compte { fill: var(--muted); font-size: 14px; }
.carte .repaire { color: var(--gules); }
.carte .pastille.GOOD { fill: var(--azur); }
.carte .pastille.NEUTRAL { fill: var(--sinople); }
.carte .pastille.EVIL { fill: var(--gules); }
.carte a { cursor: pointer; }
.legende { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: 0.5rem; }
.legende span { display: inline-flex; align-items: center; gap: 0.3rem; }
.legende i { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; }
.legende i.GOOD { background: var(--azur); }
.legende i.NEUTRAL { background: var(--sinople); }
.legende i.EVIL { background: var(--gules); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  main { padding: 0.75rem; }
  .card { padding: 0.85rem 0.9rem; }
  input, select { min-width: 0; width: 100%; }
  input.petit { width: 5rem; }
  .who { display: none; }
}
