/* Values marked "settings.md" are overwritten from there once it loads */
:root {
  --bg: #f6f3ee;                  /* settings.md: BACKGROUND_COLOR */
  --text: #22302b;
  --muted: #5f6b66;
  --stone: #dcd6cc;
  --accent: #6abf4b;              /* settings.md: ACCENT_COLOR */
  --form-height: 720px;           /* settings.md: FORM_HEIGHT */
  --form-width: 480px;            /* settings.md: FORM_WIDTH */
  --top-text-width: 300px;        /* settings.md: TOP_TEXT_WIDTH */
  --page-width: 1600px;           /* settings.md: PAGE_WIDTH */
  --side-space: 96px;             /* settings.md: PAGE_SIDE_SPACE */
  --text-size: 17px;              /* settings.md: TEXT_SIZE */
  --title-size: 56px;             /* settings.md: TITLE_SIZE */
  --box-gap: 64px;                /* settings.md: BOX_GAP */
  --row-gap: 96px;                /* settings.md: ROW_GAP */
  --column-gap: 64px;             /* settings.md: COLUMN_GAP */
  --info-pad: 0px;                /* a {banner} runs this far past its section's sides */
  --heading-font: "Gotham Rounded", "Nunito", system-ui, sans-serif;  /* settings.md: HEADING_FONT */
  --heading-weight: 700;                                              /* settings.md: HEADING_WEIGHT */
  --body-font: "Gotham Rounded", "Nunito", system-ui, sans-serif;     /* settings.md: BODY_FONT */
  --body-weight: 700;                                                 /* settings.md: BODY_WEIGHT */
  --bold-weight: 900;                                                 /* settings.md: BOLD_WEIGHT */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
  font-weight: var(--body-weight);
  font-size: var(--text-size);
  line-height: 1.65;
}

/* The page: a centered column of rows of sections side by side */
.page {
  max-width: calc(var(--page-width) + 2 * var(--side-space));
  margin: 0 auto;
  padding: 56px var(--side-space) 96px;
}

/* HIDE_SCROLLBAR: no scroll bar, but the page still scrolls */
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* The bar across the top of the screen, with the title in the middle and
   the logo at the left (settings.md: TITLE_BAR_COLOR, LOGO_IMAGE) */
.top-bar {
  background: var(--title-bar-color, transparent);
  color: var(--title-bar-text, inherit);
  --muted: color-mix(in srgb, currentColor 75%, transparent);
}

.top-bar-inner {
  position: relative;
  max-width: calc(var(--page-width) + 2 * var(--side-space));
  margin: 0 auto;
  padding: 40px var(--side-space);
}

/* The title keeps clear of the logo on both sides, so it stays centered */
.title-block {
  padding: 0 var(--logo-space, 0px);
  text-align: center;
}

.logo {
  position: absolute;
  left: var(--side-space);
  top: 50%;
  transform: translateY(-50%);
  line-height: 0;
}

/* LOGO_BLACK: the logo solid black (the filter is in index.html) */
.logo.black img { filter: url(#logo-black); }

.logo img {
  display: block;
  width: auto;
  height: var(--logo-height);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--column-gap);
  align-items: start;
  margin-bottom: var(--row-gap);
}

.row:last-child { margin-bottom: 0; }

/* SECTIONS: a row with a color. The color runs out to the edges of the
   screen (the border-image is painted outside the row without making it
   any wider), with SECTION_PADDING above and below the row's contents. */
.row.colored {
  padding-block: var(--section-padding);
  border-image: conic-gradient(var(--section-color) 0 0) fill 0 // 0 100vw;
}

/* BOXED_TEXT: a text section as rounded boxes (settings.md: BOX_COLOR),
   each sliding in from its side when it scrolls into view */
.text-box {
  margin-bottom: var(--box-gap);
  padding: 28px 32px;
  border-radius: 20px;
  background: var(--box-color);
  transition: opacity var(--box-slide-ms) ease-out, transform var(--box-slide-ms) cubic-bezier(.2, .8, .2, 1);
}

/* A box still waiting to slide in is cut off at the edge of the screen,
   so the page never scrolls sideways */
.boxed {
  overflow-x: clip;
  overflow-clip-margin: var(--side-space);
}

.text-box:last-child { margin-bottom: 0; }
.text-box > :first-child { margin-top: 0; }
.text-box > :last-child { margin-bottom: 0; }

.text-box.waiting {
  opacity: 0;
  transform: translateX(calc(var(--slide, -1) * 80px));
}

/* MAP_CARD: the route map in a box like the BOXED_TEXT ones */
.map-card {
  padding: 28px 32px;
  border-radius: 20px;
  background: var(--box-color);
}

/* A colored last row runs down to the bottom of the page */
.page:has(> .row.colored:last-child) { padding-bottom: 0; }

/* SECTIONS: a row's title, centered across the whole row */
.section-title {
  grid-column: 1 / -1;
  margin: 0 0 32px;
  font: var(--heading-weight) min(var(--section-title-size), 7vw) / 1.2 var(--heading-font);
  text-align: center;
}

/* The top row: the text in the middle of the page, with the map and the
   form in equal columns either side. The form is at most FORM_WIDTH wide,
   centered in its column. */
.row-top { grid-template-columns: minmax(0, 1fr) minmax(0, var(--top-text-width)) minmax(0, 1fr); }
.row-top .donate { width: min(100%, var(--form-width)); justify-self: center; }

/* The map in its own section lines up with the top of the text beside it */
.map-col .route-map { margin: 0; }

/* So a {banner} picture knows how wide its section is */
.row > * { container-type: inline-size; }

/* SECTIONS: a row's picture, under its title and across the whole row
   (settings.md: SECTION_PICTURE_HEIGHT; 0 keeps the picture's own shape) */
.section-picture {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
  height: var(--section-picture-height, auto);
  margin-bottom: 56px;
  object-fit: cover;
  object-position: center;
  border-radius: var(--picture-radius, 12px);
}

/* TEXT_CARDS: a text section in a rounded box like the quotes */
.text-card {
  padding: 28px 32px;
  border-radius: 20px;
  background: var(--box-color);
}

/* Donation form: FORM_HEIGHT tall, scrolling inside itself if it's longer */
.donate { height: var(--form-height); }

.donate-form {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
}

.form-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 2px solid var(--stone);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  white-space: pre-line;   /* a new line in FORM_PLACEHOLDER starts a new line */
}

h1 {
  margin: 0;
  font: var(--heading-weight) min(var(--title-size), 9vw)/1.15 var(--heading-font);
}

/* CENTERED_TEXT: the whole section centered */
.centered-section { text-align: center; }
.centered-section ul,
.centered-section ol { list-style-position: inside; padding-left: 0; }

/* The text sections, from the text folder (styles copied from the SFS sections) */

/* The line right under the title */
.content h1 + p {
  margin: 8px 0 0;
  color: var(--muted);
}

/* No gap above a section's first line or below its last */
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }

.content p { margin: 0 0 1em; }

/* **bold** in the text (settings.md: BOLD_WEIGHT) */
.content strong { font-weight: var(--bold-weight); }

.content h3 {
  margin: 1.6em 0 0.5em;
  font-family: var(--heading-font);
  font-weight: var(--heading-weight);
  font-size: 1.25em;
  line-height: 1.3;
}

/* ## in content.md: a centered heading, with the lines right under it centered too */
.content h3.name {
  margin-top: 2.2em;
  text-align: center;
}

/* Words pushed into the middle of the page, between -> and <- in the file */
.content .centered { text-align: center; }

/* A centered list has no room down the left for its bullets, so they go in
   front of the words instead */
.content ul.centered,
.content ol.centered { list-style-position: inside; padding-left: 0; }

.content ul,
.content ol { margin: 0 0 1em; padding-left: 1.3em; }
.content li { margin-bottom: 0.35em; }
.content ul.spaced li,
.content ol.spaced li { margin-bottom: 1em; }

/* Written 1) 2) 3) rather than 1. 2. 3., a numbered list becomes steps:
   each number in a filled accent circle */
.content ol.steps {
  counter-reset: step;
  padding-left: 0;
  list-style: none;
}

.content ol.steps li {
  position: relative;
  min-height: 36px;
  padding-left: calc(36px + 18px);
  margin-bottom: 28px;
}

.content ol.steps li:last-child { margin-bottom: 0; }

.content ol.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: calc((1.65em - 36px) / 2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  font-size: 0.95em;
}

/* Two columns either side of a gutter: Role — Name in the file */
.content .pairs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 64px;
  margin: 0 0 1em;
}

.content .pairs p { margin: 0; }
.content .pairs .pair-left { text-align: right; }
.content .pairs .pair-dash { display: none; }

.content a { color: inherit; text-underline-offset: 3px; }

/* An extra empty line in content.md */
.content .md-space { height: 1em; margin: 0; }

/* Pictures (settings.md: PICTURE_WIDTH, PICTURE_HEIGHT, PICTURE_CORNER_RADIUS) */
.content p.picture { margin: 0.8em 0 1.2em; text-align: center; line-height: 0; }

.content .md-image {
  max-width: min(var(--picture-width, 720px), 100%);
  height: auto;
  border-radius: var(--picture-radius, 12px);
}

/* {banner} after a picture: it runs the full width of the section, past
   the text column and its side padding, with square corners.
   (100cqw is the section's width inside its padding.) */
.content p.picture.banner,
.content .route-map.banner {
  width: calc(100cqw + 2 * var(--info-pad));
  max-width: none;
  margin-left: calc(50% - 50cqw - var(--info-pad));
  margin-right: 0;
}

.content p.picture.banner .md-image,
.content.set-picture-height p.picture.banner .md-image {
  display: block;
  width: 100%;
  max-width: none;
  height: var(--banner-height, auto);
  object-fit: cover;
  object-position: center;
  border-radius: 0;
}

/* The route map (!map! in content.md; map.js). Sizes are in cqw, a
   percent of the map's width, so the words grow and shrink with the map,
   with a smallest and largest size so they stay readable. */
.route-map {
  position: relative;
  margin: 1.2em 0 1.6em;
  container-type: inline-size;
  line-height: 1.25;
}

.rm-stage {
  position: relative;
  aspect-ratio: 2114 / 2030;
}

.rm-stage > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.rm-line,
.rm-casing {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rm-line { stroke: var(--route-color); }
.rm-casing { stroke: rgba(0, 0, 0, .45); }

/* The detail box, the area it zooms in on, and the lines joining them */
.rm-area { fill: none; stroke: #fff; stroke-width: 3; }
.rm-link { stroke: #fff; stroke-width: 1.5; }
.rm-frame { fill: none; stroke: #1b1d1d; stroke-width: 5; }

/* The detail box waits until the route is drawn, then grows out of its
   area; the lines joining them and the stops in it follow once it's there */
.rm-detail > *,
.rm-detail-title {
  opacity: 0;
  transition: opacity .3s;
}

.rm-box {
  transform: var(--from);
  transform-origin: 0 0;
  transition: opacity .2s, transform .7s cubic-bezier(.2, .8, .2, 1);
}

.rm-detail-shown .rm-detail > *,
.rm-detail-shown .rm-detail-title { opacity: 1; }
.rm-detail-shown .rm-box { transform: none; }
.rm-detail-shown .rm-link,
.rm-detail-shown .rm-detail-title { transition-delay: .6s; }

.rm-detail-title {
  position: absolute;
  margin: 0;
  font: var(--heading-weight) clamp(11px, 2.2cqw, 22px) / 1.2 var(--heading-font);
  white-space: nowrap;
}

/* A stop: the marker sits on the spot, the name beside it */
.rm-marks { position: absolute; inset: 0; pointer-events: none; }

.rm-stop {
  --dot: clamp(16px, 2.3cqw, 26px);
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  transform: scale(.4);
  transition: opacity .3s, transform .35s cubic-bezier(.3, 1.6, .5, 1);
}

.rm-stop.shown { opacity: 1; transform: none; }

.route-map:not(.rm-detail-shown) .rm-stop.rm-in-box { opacity: 0; transform: scale(.4); }
.rm-detail-shown .rm-stop.rm-in-box { transition-delay: .65s; }

.rm-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--dot);
  height: var(--dot);
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--stop-color);
  color: #fff;
  font-size: calc(var(--dot) * .55);
  line-height: 1;
}

.rm-stop .rm-dot {
  position: absolute;
  transform: translate(-50%, -50%);
}

.rm-start { --dot: clamp(13px, 1.7cqw, 20px); }
.rm-start .rm-dot { background: var(--start-color); }
.rm-small { --dot: clamp(7px, .8cqw, 11px); }
.rm-small .rm-dot { border-width: 1.5px; }

.rm-label {
  position: absolute;
  padding: .2em .45em;
  border-radius: 6px;
  background: rgba(27, 29, 29, .9);
  color: #fff;
  font-size: clamp(10px, 1.6cqw, 16px);
  white-space: nowrap;
}

.rm-stop[data-side="right"] .rm-label { left: calc(var(--dot) / 2 + 5px); transform: translateY(-50%); }
.rm-stop[data-side="left"] .rm-label { right: calc(var(--dot) / 2 + 5px); transform: translateY(-50%); }
.rm-stop[data-side="below"] .rm-label { top: calc(var(--dot) / 2 + 4px); transform: translateX(-50%); }
.rm-stop[data-side="above"] .rm-label { bottom: calc(var(--dot) / 2 + 4px); transform: translateX(-50%); }

/* The key: the title, the numbered stops and what the line means */
.rm-legend { position: absolute; }

.rm-legend p,
.rm-legend ol { margin: 0; padding: 0; list-style: none; }

.rm-legend-title {
  margin-bottom: .35em !important;
  font: var(--heading-weight) clamp(14px, 2.4cqw, 26px) / 1.2 var(--heading-font);
}

.rm-legend li {
  display: flex;
  align-items: center;
  gap: .5em;
  margin: 0 0 .3em;
  font-size: clamp(11px, 1.7cqw, 17px);
}

.rm-legend .rm-dot { --dot: 1.6em; font-size: .85em; }

.rm-note {
  display: flex;
  align-items: center;
  gap: .6em;
  margin-top: .5em !important;
  color: var(--muted);
  font-size: clamp(10px, 1.25cqw, 13px);
}

.rm-swatch {
  flex: none;
  width: 2.4em;
  height: 4px;
  border-radius: 2px;
  background: var(--route-color);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45);
}

/* No room on a small map: the key goes under it */
.rm-legend.rm-below { position: static; margin-top: 12px; }

@container (max-width: 520px) {
  .rm-legend { position: static; margin-top: 12px; }
  .rm-detail-title { display: none; }  /* runs into the box's labels */
}

/* MAP_EDIT_MODE */
.rm-editing .rm-stage { cursor: crosshair; }

.rm-edit {
  margin-top: 12px;
  padding: 12px;
  border: 2px dashed currentColor;
  border-radius: 8px;
  font-size: .875rem;
}

.rm-edit p { margin: 0 0 .5em; }

.rm-edit textarea {
  display: block;
  width: 100%;
  margin-bottom: .5em;
  font: .875rem/1.4 ui-monospace, monospace;
}

/* PICTURE_HEIGHT: every picture the same height, filling it and its width,
   taking the middle of the picture if the two don't match */
.content.set-picture-height .md-image {
  width: min(var(--picture-width, 720px), 100%);
  height: var(--picture-height);
  object-fit: cover;
  object-position: center;
}

@media (max-width: 480px) {
  .content .pairs { grid-template-columns: 1fr; column-gap: 0; }
  .content .pairs .pair-left { text-align: center; margin-top: 0.5em; }
  .content .pairs .pair-right { text-align: center; }
}

/* Mid-size screens: no room for three across, so the top row's text goes
   under the map, with the form to their right */
@media (max-width: 1500px) {
  .row-top { grid-template-columns: minmax(0, 1fr) minmax(0, var(--form-width)); row-gap: 40px; }
  .row-top .donate { grid-column: 2; grid-row: var(--form-row, 1) / span 2; }
}

/* Narrow screens: no room for side by side, so each row stacks, left
   section first */
@media (max-width: 900px) {
  .page { padding: 40px 16px 64px; }
  .top-bar-inner { padding: 24px 16px; }
  .logo { left: 16px; }
  .boxed { overflow-clip-margin: 16px; }
  .logo img { height: min(var(--logo-height), 44px); }
  .row,
  .row-top { grid-template-columns: minmax(0, 1fr); row-gap: 40px; margin-bottom: calc(var(--row-gap) * .6); }
  .row-top .donate { grid-column: auto; grid-row: auto; }
  .section-title,
  .section-picture { margin-bottom: 0; }
  .section-picture { max-height: 75vw; }   /* not a tall sliver on a phone */
}
