/* Découvrir Lille: same colours, font and top bar as tbpi.github.io */

/* ---- colours and sizes, used everywhere below as var(--name) ---- */
:root {
  --blue-dark: #173f73;   /* headings */
  --blue: #1f5fae;        /* links, active language button */
  --nav-start: #24589c;   /* left end of the top bar */
  --nav-end: #2f6fb8;     /* right end of the top bar */
  --blue-light: #d6e6f7;  /* lines, table headers, borders */
  --blue-pale: #eef4fc;   /* tint at the top of the page background */
  --text: #1c2733;        /* normal text: a very dark blue-grey */
  --muted: #6b7785;       /* dates, captions, footnotes */
  --bar-height: 70px;
  --gap: 50px;            /* space at the sides and between text and image */
  --pin-faded: saturate(0.5) brightness(1.1); /* map pins, when not displayed */
  --pin-bright: saturate(1.8); /* pin of the shown fact highlighted */
  color-scheme: light only;
}

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

body {
  margin: 0;
  padding-top: var(--bar-height);  /* room for the fixed top bar */
  font-family: "Raleway", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: #fff linear-gradient(to bottom, var(--blue-pale), #fff 300px) no-repeat;
}
/* a for the html link <a> ... </a> */
/* Rules for every link on the page */
a {
  color: var(--blue);
  text-underline-offset: 0.2em;
  transition: color 0.3s;
}
/* hover effect */
a:hover {
  color: var(--blue-dark);
}

/* ---- top bar: stays at the top while scrolling ---- */
.site-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;  /* top bar stays above zoom buttons of map */
  height: var(--bar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--gap);
  background: var(--nav-start) linear-gradient(to right, var(--nav-start), var(--nav-end));
  border-bottom: 5px solid var(--blue-light);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.site-bar a {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px var(--gap) 50px;
}

/* ---- Christmas background: a photo that stays put while the page scrolls ---- */
/* an empty layer fixed to the window, behind the page; delete this block to switch it off */
body::before {
  content: "";            /* ::before only appears with some content, even empty */
  position: fixed;        /* fixed to the window: does not scroll with the text */
  inset: 0;               /* top, right, bottom, left = 0: the whole window */
  z-index: -1;            /* behind the page */
  background: url("background.jpg") center / cover;  /* fill the window, keep proportions */
}
/* white sheet under the content so the text stays readable */
main {
  background: rgba(255, 255, 255, 0.75);
}

/* ---- Advent grid: 24 square doors above the card (12 x 2, phones 8 x 3) ---- */
.advent-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  max-width: 640px;  /* doors of about 48px */
  margin-bottom: 25px;
}
/* style for every door */
.advent-grid > * {
  display: grid;
  place-items: center;  /* number in the middle */
  aspect-ratio: 1;      /* square */
  border: 1px solid var(--blue-light);
  font-weight: 500;
  text-decoration: none;
}
.advent-grid a {  /* open door */
  background: var(--blue-light);
}
.advent-grid span {  /* closed door */
  color: var(--muted);
}
.advent-grid .shown {  /* door of the shown fact; class set by app.js */
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ---- the fact card: text on the left, image space on the right ---- */
/* one grid row per text part; the image starts in row 2, at the line under the title */
.fact {
  display: grid;
  grid-template-columns: minmax(0, 850px) 260px;  /* text | image */
  grid-template-rows: repeat(4, auto) 1fr;        /* 1fr: room for a tall image */
  column-gap: var(--gap);                         /* between text and image */
  scroll-margin-top: 100vh;
}
.fact-text,
.lang-block {
  display: contents;  /* no box of their own: their parts become grid rows */
}
.fact-text > *,
.lang-block > * {
  grid-column: 1;  /* text in the left column */
}
/* Need to hide the hidden facts and languages with css style */
.fact[hidden],
.lang-block[hidden] {
  display: none; /* display: grid / contents would otherwise win over hidden */
}
.fact-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  border-bottom: 1px solid var(--blue-light);
}
.fact-header h1 {
  margin: 0 0 0.3em;
  color: var(--blue-dark);
  font-size: 1.8em;
  line-height: 1.2;
}
.fact-header time {
  flex-shrink: 0;
  font-size: 0.85em;
  color: var(--muted);
}
.fact-link {
  margin-top: 0;  /* grid rows do not share margins */
  font-size: 0.9em;
}
/* previous / next door below the text */
.door-nav {
  display: flex;
  font-size: 0.9em;
}
.door-nav .next {
  margin-left: auto;  /* the next door stays on the right, also when it is alone */
}
.fact-image {
  grid-column: 2;    /* reserved, also without an image */
  grid-row: 2 / -1;  /* from the title line down */
  margin: 0;
}
.fact-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}
.fact-image figcaption {
  font-size: 0.8em;
  color: var(--muted);
}

/* ---- footnotes, as written by the Markdown footnote plugin ---- */
.footnote-ref {
  font-size: 0.75em; /* small number*/
  line-height: 0;    /* even line spacing */
}
.footnote-ref a,
.footnote-backref {
  text-decoration: none;
}
.footnote-ref a,
.footnote-item {
  scroll-margin-top: calc(var(--bar-height) + 20px);
}
.footnotes-sep {
  border: 0;
  border-top: 1px solid var(--blue-light);
  margin: 1.5em 0 0.5em;
}
.footnotes {
  font-size: 0.85em;
  color: var(--muted);
}
.footnotes-list {
  margin: 0;
  padding-left: 1.4em;
}
.footnote-item p {
  margin: 0.3em 0;
}

/* ---- language switch in the top bar: EN | FR | DE ---- */
.lang-switch {
  display: flex;
  margin-left: auto;  /* push to the right end of the bar */
}
.lang-switch button {
  font: inherit;
  font-weight: 500;
  padding: 0 10px;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
}
.lang-switch button + button {
  border-left: 1px solid var(--blue-light);  /* the | between two codes */
}
.lang-switch button[aria-pressed="true"] {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}
.lang-switch button:disabled {
  color: rgba(255, 255, 255, 0.45);
  cursor: not-allowed;
}

/* ---- texts in three languages (ui macro in index.html) ---- */
/* show only the language of the page; app.js sets <html lang> */
html:not([lang="en"]) .ui > [lang="en"], /* comma for 'or' */
html:not([lang="fr"]) .ui > [lang="fr"],
html:not([lang="de"]) .ui > [lang="de"] {
  display: none;
}

/* ---- contact line (like the fact text) and discreet author line, below the map ---- */
.about {
  margin-top: 25px;  /* same space as between the text and the map */
}
.about .author {
  font-size: 0.9em;
  color: var(--muted);
}

/* ---- map ---- */
#map {
  height: 480px;
  margin-top: 25px;  /* space above the map, also without language buttons */
  border: 1px solid var(--blue-light);
  border-radius: 2px;
}
#map:empty,
#map:empty + .map-legend {
  display: none;
}

.popup-facts {
  margin: 0.4em 0 0;
  padding-left: 1.1em;
}
/* pin colour per group (group: build.py, class: app.js): a filter on Leaflet's blue pin */
.pin-heritage  { --pin-hue: hue-rotate(50deg); }                    /* violet */
.pin-economy   { --pin-hue: hue-rotate(0deg); }                     /* blue */
.pin-outdoors  { --pin-hue: hue-rotate(-95deg); }                   /* green */
.pin-culture   { --pin-hue: hue-rotate(115deg); }                   /* pink */
.pin-food      { --pin-hue: hue-rotate(160deg); }                   /* red-orange */
.pin-knowledge { --pin-hue: hue-rotate(-40deg); }                   /* teal */
.pin-society   { --pin-hue: hue-rotate(200deg) brightness(1.35); }  /* amber */
.pin-misc      { --pin-hue: grayscale(1); }                         /* grey */
/* every pin faded … */
.leaflet-marker-icon.pin {
  filter: var(--pin-hue) var(--pin-faded);
  opacity: 0.75;
}
.leaflet-marker-icon.pin.pin-misc:not(.current-pin) {
  filter: grayscale(1) brightness(1.6);
}
/* … except the pin of the shown fact: bright (class set by app.js) */
.leaflet-marker-icon.pin.current-pin {
  filter: var(--pin-hue) var(--pin-bright);
  opacity: 1;
}
/* category of each entry in the popups (under its title and date) */
.popup-category {
  font-size: 0.85em;
  color: var(--muted);
}
/* legend under the map */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85em;
  color: var(--muted);
}
/* the dot in the legend and the popups: Leaflet's pin blue with the bright pin filter */
.map-legend li::before,
.popup-category::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: #2a81cb;
  filter: var(--pin-hue) var(--pin-bright);
}

/* ---- phones and narrow windows (768px, as on tbpi.github.io) ---- */
@media (max-width: 768px) {
  :root { --gap: 20px; }                         /* smaller gap instead of 50px */
  .fact { display: block; }                      /* image space below the text */
  .fact-image { margin-top: var(--gap); }
  .fact-image:empty { display: none; }           /* no empty space on a phone */
  #map { height: 360px; }                        /* reduce height from 480px */
  .advent-grid { grid-template-columns: repeat(8, 1fr); }  /* 8 x 3 smaller doors */
}
