/* ==========================================================================
   storymap.css — ArcGIS StoryMaps "Summit" look for R Markdown + mapgl
   Colours/fonts from the StoryMaps standard theme reference.
   Avenir Next is a commercial font: it is used if installed, otherwise
   Nunito Sans (Google Fonts) stands in.
   ========================================================================== */

:root {
  --sm-bg: #ffffff;
  --sm-bg-2: #f4f7f7;            /* secondary background (calculated) */
  --sm-heading: #002625;
  --sm-text: #304e4e;
  --sm-caption: #3d6665;
  --sm-accent: #087f9b;
  --sm-accent-2: #fc3b36;
  --sm-accent-3: #126057;
  --sm-rule: #d5dede;

  --sm-font-head: "Avenir Next", "Avenir", "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  --sm-font-body: "Noto Serif", Georgia, "Times New Roman", serif;

  --sm-col: 680px;               /* text column */
  --sm-wide: 1120px;             /* wide media */
  --sm-header-h: 64px;
  --sm-nav-h: 52px;
}

/* ---------- base ---------------------------------------------------------- */
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--sm-nav-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--sm-bg);
  color: var(--sm-text);
  font-family: var(--sm-font-body);
  font-size: 1.125rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* R Markdown wrapper: let blocks go full width, constrain text instead */
.main-container { max-width: none !important; margin: 0 !important; padding: 0 !important; }

.section > :is(p, h2, h3, h4, h5, h6, ul, ol, blockquote, hr, pre) {
  max-width: var(--sm-col);
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: content-box;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--sm-font-head);
  color: var(--sm-heading);
  line-height: 1.25;
  font-weight: 600;
}
.section h2 { font-size: 2rem;    margin-top: 4.5rem; margin-bottom: 1.25rem; }
.section h3 { font-size: 1.5rem;  margin-top: 3rem;   margin-bottom: 1rem; }
.section h4 { font-size: 1.125rem; margin-top: 2rem;  margin-bottom: .5rem; }

p { margin-top: 0; margin-bottom: 1.5rem; }
ul, ol { padding-left: 48px; margin-bottom: 1.5rem; }
li { margin-bottom: .5rem; }

a { color: var(--sm-accent); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--sm-heading); }

blockquote {
  border-left: 4px solid var(--sm-accent);
  padding: .25rem 0 .25rem 24px !important;
  font-family: var(--sm-font-head);
  font-size: 1.375rem;
  color: var(--sm-heading);
}
hr { border: 0; border-top: 2px solid var(--sm-rule); margin-top: 3rem; margin-bottom: 3rem; }

/* ---------- header -------------------------------------------------------- */
.sm-header {
  height: var(--sm-header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--sm-rule);
  position: relative;
  z-index: 20;
}
.sm-logo { height: 36px; width: auto; display: block; }
.sm-logo-text { font-family: var(--sm-font-head); font-weight: 700; color: var(--sm-heading); }
.sm-header a { text-decoration: none; }

/* ---------- cover (full, gradient, centred/middle) ------------------------ */
.sm-cover {
  position: relative;
  height: calc(100vh - var(--sm-header-h));
  min-height: 420px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
}
.sm-cover-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.sm-cover-gradient {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,.45) 0%, rgba(0,0,0,.15) 60%, rgba(0,0,0,0) 100%),
    linear-gradient(to bottom, rgba(0,0,0,.15) 0%, rgba(0,0,0,.35) 100%);
}
.sm-cover-panel { position: relative; max-width: 900px; padding: 0 32px; }
.sm-cover-title {
  font-family: var(--sm-font-head);
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 700;
  color: #fff;
  margin: 0 0 1rem;
  text-shadow: 0 1px 12px rgba(0,0,0,.35);
}
.sm-cover-summary {
  font-family: var(--sm-font-head);
  font-size: clamp(1.1rem, 2vw, 1.375rem);
  line-height: 1.5;
  margin: 0 auto 1rem;
  max-width: 720px;
  text-shadow: 0 1px 8px rgba(0,0,0,.4);
}
.sm-cover-meta { font-family: var(--sm-font-head); font-size: .95rem; opacity: .9; margin: 0; }
.sm-cover-credit {
  position: absolute; right: 12px; bottom: 8px;
  font-family: var(--sm-font-head); font-size: .75rem; opacity: .8;
}
.sm-cover-scroll {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: #fff; text-decoration: none; font-size: 2rem; line-height: 1;
  animation: sm-bob 2s ease-in-out infinite;
}
@keyframes sm-bob { 50% { transform: translate(-50%, 6px); } }
@media (prefers-reduced-motion: reduce) { .sm-cover-scroll { animation: none; } }

/* ---------- sticky navigation -------------------------------------------- */
.sm-nav {
  position: sticky; top: 0; z-index: 15;
  height: var(--sm-nav-h);
  background: rgba(255,255,255,.97);
  border-bottom: 1px solid var(--sm-rule);
  transition: box-shadow .2s;
}
.sm-nav.is-stuck { box-shadow: 0 2px 8px rgba(0,38,37,.08); }
.sm-nav ul {
  list-style: none; margin: 0 auto; padding: 0 16px;
  height: 100%;
  display: flex; justify-content: flex-start; gap: 4px;   /* centred via auto margins below,
     so long menus scroll instead of cutting off the first entries */
  overflow-x: auto; scrollbar-width: none;
}
.sm-nav ul::-webkit-scrollbar { display: none; }
.sm-nav li { margin: 0; display: flex; }
.sm-nav li:first-child { margin-left: auto; }
.sm-nav li:last-child { margin-right: auto; }
.sm-nav a {
  display: flex; align-items: center;
  padding: 0 14px;
  font-family: var(--sm-font-head);
  font-size: .9375rem;
  font-weight: 500;
  color: var(--sm-text);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.sm-nav a:hover { color: var(--sm-heading); }
.sm-nav a.is-active { color: var(--sm-heading); border-bottom-color: var(--sm-accent); }

/* ---------- media blocks -------------------------------------------------- */
.sm-block { margin: 2.5rem auto 3rem; padding: 0 24px; }
.sm-standard { max-width: var(--sm-col); }
.sm-wide     { max-width: var(--sm-wide); }
.sm-full     { max-width: none; padding: 0; }
.sm-block img { display: block; width: 100%; height: auto; }

.sm-map-frame { position: relative; width: 100%; background: var(--sm-bg-2); }
.sm-map-frame > .html-widget { width: 100% !important; height: 100% !important; }

.sm-caption {
  font-family: var(--sm-font-body);
  font-size: .875rem;
  line-height: 1.5;
  color: var(--sm-caption);
  margin-top: .75rem;
  text-align: center;
}
.sm-full .sm-caption { padding: 0 24px; }

/* embedded pages: BFE charts, Shiny dashboard (sm_frame) */
.sm-frame-box {
  position: relative;
  height: var(--sm-frame-h);
  background: #F9FAFB;
  transition: height .2s;
}
@media (max-width: 860px) { .sm-frame-box { height: var(--sm-frame-h-mobile); } }
.sm-frame-box iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%; border: 0;
  opacity: 0; transition: opacity .3s;
}
.sm-frame-box.is-loaded iframe { opacity: 1; }
.sm-frame-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--sm-font-head); font-size: .9375rem; color: var(--sm-caption);
}
.sm-frame-box.is-loaded .sm-frame-loading { display: none; }
.sm-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--sm-rule); border-top-color: var(--sm-accent);
  animation: sm-spin 1s linear infinite;
}
@keyframes sm-spin { to { transform: rotate(360deg); } }
.sm-source { font-size: .8125rem; }

/* mapgl legend + popups in theme fonts, square shapes */
.mapboxgl-legend, .maplibregl-legend {
  font-family: var(--sm-font-head) !important;
  color: var(--sm-heading) !important;
  border-radius: 0 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.18) !important;
}
.mapgl-legend-title { font-weight: 600 !important; }
.maplibregl-popup-content {
  font-family: var(--sm-font-head);
  color: var(--sm-text);
  border-radius: 0;
  padding: 12px 16px;
  font-size: .875rem;
  line-height: 1.45;
}
.maplibregl-popup-content h4 { margin: 0 0 4px; font-size: 1rem; }
.maplibregl-ctrl-group { border-radius: 0 !important; }

/* ---------- sidecar (docked) ---------------------------------------------- */
.sm-sidecar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, var(--sm-narrative-w, 36%)) 1fr;
  margin: 4rem 0;
  background: var(--sm-bg-2);
}
.sm-panel-right { grid-template-columns: 1fr minmax(320px, var(--sm-narrative-w, 36%)); }
.sm-panel-right .sm-sidecar-media { order: 1; }
.sm-panel-right .sm-sidecar-narrative { order: 2; }

.sm-sidecar-media {
  position: sticky;
  top: var(--sm-nav-h);
  height: calc(100vh - var(--sm-nav-h));
  order: 2;
}
.sm-sidecar-media > .html-widget { width: 100% !important; height: 100% !important; }
.sm-sidecar-narrative { order: 1; }

.sm-slide {
  min-height: calc(100vh - var(--sm-nav-h));
  display: flex; align-items: center;
  padding: 0 32px;
  box-sizing: border-box;
}
.sm-slide-card {
  background: #fff;
  padding: 28px 32px;
  width: 100%;
  opacity: .45;
  transition: opacity .35s;
}
.sm-slide.is-active .sm-slide-card { opacity: 1; }
.sm-slide-card h3 { margin-top: 0; font-size: 1.5rem; }
.sm-slide-card p:last-child { margin-bottom: 0; }
.sm-slide-card :is(p, ul, ol, h3, h4) { max-width: none; padding: 0; }

@media (max-width: 860px) {
  .sm-sidecar, .sm-panel-right { display: block; }
  .sm-sidecar-media { top: var(--sm-nav-h); height: 60vh; z-index: 1; }
  .sm-sidecar-narrative { position: relative; z-index: 2; margin-top: -10vh; }
  .sm-slide { min-height: 80vh; padding: 0 16px; align-items: flex-end; padding-bottom: 20vh; }
  .sm-slide-card { opacity: 1; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
}

/* ---------- credits ("Quellen") ------------------------------------------- */
.sm-credits {
  width: calc(100% - 48px);
  max-width: var(--sm-col);
  margin: 1rem auto 3rem;
  border-collapse: collapse;
  font-size: .875rem;
  line-height: 1.5;
}
.sm-credits td { padding: 12px 0; border-top: 1px solid var(--sm-rule); vertical-align: top; }
.sm-credits td:first-child { width: 50%; padding-right: 24px; color: var(--sm-text); }
.sm-credits td:last-child { color: var(--sm-caption); }

/* ---------- footer --------------------------------------------------------- */
.sm-footer {
  margin-top: 4rem;
  padding: 32px 24px;
  background: var(--sm-bg-2);
  text-align: center;
  font-family: var(--sm-font-head);
  font-size: .8125rem;
  color: var(--sm-caption);
}

/* hide R Markdown chrome we don't want */
#header { display: none; }

/* ---------- images in slides + image viewer --------------------------------- */
.sm-slide-figure { margin: 16px 0 0; }
.sm-slide-card .sm-slide-figure + .sm-slide-figure { margin-top: 12px; }
@media (min-width: 861px) {
  /* several images in one slide: two per row */
  .sm-slide-card:has(.sm-slide-figure + .sm-slide-figure) {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px;
  }
  .sm-slide-card:has(.sm-slide-figure + .sm-slide-figure) > :not(.sm-slide-figure) { grid-column: 1 / -1; }
  .sm-slide-card:has(.sm-slide-figure + .sm-slide-figure) .sm-slide-figure { margin-top: 12px; }
}
.sm-slide-figure .sm-caption { text-align: left; margin-top: 6px; font-size: .8125rem; }

.sm-zoom {
  position: relative; display: block; width: 100%;
  padding: 0; border: 0; background: none; cursor: zoom-in;
}
.sm-zoom img { display: block; width: 100%; height: auto; }
.sm-slide-figure .sm-zoom img { aspect-ratio: 3 / 2; object-fit: cover; }
.sm-zoom-icon {
  position: absolute; right: 8px; bottom: 8px;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 38, 37, .7); color: #fff; font-size: 16px; line-height: 1;
  opacity: .85; transition: opacity .2s;
}
.sm-zoom:hover .sm-zoom-icon, .sm-zoom:focus-visible .sm-zoom-icon { opacity: 1; }
.sm-zoom:focus-visible { outline: 3px solid var(--sm-accent); outline-offset: 2px; }

html.sm-lb-open { overflow: hidden; }
.sm-lightbox {
  border: 0; padding: 0; margin: 0;
  width: 100vw; height: 100vh; max-width: none; max-height: none;
  background: transparent; color: #fff;
}
.sm-lightbox[open] { display: flex; align-items: center; justify-content: center; }
.sm-lightbox::backdrop { background: rgba(0, 20, 20, .88); }
.sm-lightbox figure { margin: 0; max-width: calc(100vw - 140px); text-align: center; }
.sm-lightbox img {
  display: block; margin: 0 auto;
  max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
}
.sm-lb-caption {
  margin-top: 12px; font-family: var(--sm-font-body); font-size: .9375rem;
  line-height: 1.5; color: #e6eeee; max-width: 760px; margin-left: auto; margin-right: auto;
}
.sm-lb-caption a { color: #9fd6e3; }
.sm-lightbox button {
  position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff;
  width: 48px; height: 48px; font-size: 30px; line-height: 1; cursor: pointer;
}
.sm-lightbox button:hover, .sm-lightbox button:focus-visible { background: rgba(255, 255, 255, .28); }
.sm-lb-close { top: 16px; right: 16px; }
.sm-lb-prev  { left: 16px;  top: 50%; transform: translateY(-50%); }
.sm-lb-next  { right: 16px; top: 50%; transform: translateY(-50%); }
.sm-lightbox.is-single .sm-lb-prev, .sm-lightbox.is-single .sm-lb-next { display: none; }
@media (max-width: 600px) {
  .sm-lightbox figure { max-width: calc(100vw - 24px); }
  .sm-lb-prev, .sm-lb-next { top: auto; bottom: 16px; transform: none; }
}

/* ---------- abstract box (::: {.sm-abstract} … ::: in index.Rmd) ------------ */
.sm-abstract {
  width: calc(100% - 48px);
  max-width: calc(var(--sm-col) + 56px);
  margin: 3.5rem auto 0;
  padding: 24px 28px;
  box-sizing: border-box;
  background: var(--sm-bg-2);
  border-left: 4px solid var(--sm-accent);
  font-size: 1.0625rem;
  line-height: 1.7;
}
.sm-abstract > :is(p, ul, ol) { max-width: none; padding: 0; margin: 0 0 .75rem; }
.sm-abstract > :last-child { margin-bottom: 0; }
.sm-abstract .sm-abstract-titel {               /* same look as a ## heading */
  display: block; margin-bottom: 1rem;
  font-family: var(--sm-font-head); font-size: 2rem; font-weight: 600;
  line-height: 1.25; color: var(--sm-heading);
}

/* ---------- tables in the text (Markdown | pipe tables or knitr::kable) ------ */
.section > table {
  width: calc(100% - 48px);
  max-width: var(--sm-col);
  margin: 1.75rem auto 2rem;
  border-collapse: collapse;
  font-family: var(--sm-font-head);
  font-size: .9375rem;
  line-height: 1.45;
  color: var(--sm-text);
}
.section > table caption {
  caption-side: top; text-align: left;
  padding-bottom: .6rem;
  font-family: var(--sm-font-body); font-size: .875rem; color: var(--sm-caption);
}
.section > table th {
  text-align: left; vertical-align: bottom;   /* default; :---: and ---: set below */
  padding: 8px 12px 8px 0;
  border-bottom: 2px solid var(--sm-heading);
  color: var(--sm-heading); font-weight: 600;
}
.section > table td {
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--sm-rule);
  vertical-align: top;
}
.section > table tr:last-child td { border-bottom: 2px solid var(--sm-rule); }
.section > table :is(th, td):last-child { padding-right: 0; }
.section > table th[align="right"], .section > table th[style*="right"] { text-align: right; }
.section > table th[align="center"], .section > table th[style*="center"] { text-align: center; }
@media (max-width: 600px) {          /* narrow screens: table scrolls sideways if needed */
  .section > table { display: block; overflow-x: auto; }
}
/* ---------- Swiss quotation marks for "…" typed in the Markdown text --------- */
/* (needs pandoc_args: ["--html-q-tags"] in the YAML header of index.Rmd)       */
q { quotes: "«" "»" "‹" "›"; }
:lang(fr) q { quotes: "«\00a0" "\00a0»" "‹\00a0" "\00a0›"; }
/* ---------- lists: numbers/bullets aligned with the body text ---------------- */
.section > :is(ul, ol) {
  padding-left: calc(24px + 1.4em);          /* marker starts at the text edge */
  max-width: calc(var(--sm-col) - 1.4em);    /* right edge stays with the text */
}
