/* mapindex articles (public/article.html), loaded after site.css. The sheet of
   text itself (`.article`, `.prose`) is shared with other pages and stays there. */

/* Credit tables share their column widths, so the sections line up. */
.credits th:first-child {
  width: 42%;
}

.credits th:nth-child(2) {
  width: 30%;
}

/* Without a detail column the licence stays where the other tables have it. */
.credits--short th:first-child {
  width: 72%;
}

.credits--short th:nth-child(2) {
  width: auto;
}

.credits__author {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--text-14);
}

/* An article's picks (curation/articles.py): the maps it recommends as a numbered
   list, each row the title and the paragraph written for it, the map's image and its
   facts. An article with picks is wider, so its rows have room, while its text keeps
   a readable measure. On narrow screens a row stacks: image, text, facts. */
.article-layout--wide .article {
  max-width: 72rem;
}

.article-layout--wide :is(.article__head, .prose > :not(.picks)) {
  max-width: 46rem;
}

.article-layout--wide .prose {
  container-type: inline-size;
}

.prose .picks {
  margin-top: 2em;
  padding-left: 0;
  list-style: none;
  counter-reset: pick;
}

.prose .picks li + li {
  margin-top: 0;
}

.pick {
  counter-increment: pick;
  position: relative;
  display: grid;
  grid-template-areas: "preview" "text" "facts";
  gap: var(--space-3);
  padding-block: var(--space-6);
  border-top: 1px solid var(--color-raised);
  scroll-margin-top: calc(var(--masthead-height) + var(--space-4));
}

.picks li:first-child .pick {
  border-top: 0;
  padding-top: 0;
}

.pick__text {
  grid-area: text;
  min-width: 0;
}

.prose .pick__title {
  margin: 0;
  font-size: var(--text-18);
  line-height: 1.3;
  text-wrap: balance;
}

.pick__title::before {
  content: counter(pick, decimal-leading-zero);
  display: block;
  margin-bottom: var(--space-1);
  color: var(--color-accent);
  font-size: var(--text-13);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.pick__link {
  color: inherit;
  text-decoration: none;
}

/* The whole row opens the map. */
.pick__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.pick:hover .pick__link {
  color: var(--color-accent);
}

.prose .pick__note {
  margin-top: var(--space-2);
  color: var(--color-text);
  font-size: var(--text-15);
  line-height: 1.55;
}

.pick__note a,
.pick__facts a {
  position: relative; /* above the link that covers the row */
  z-index: 1;
}

.pick__preview {
  position: relative;
  grid-area: preview;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-l);
  background: var(--color-raised);
  box-shadow: var(--shadow-card);
}

.pick__preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease);
}

.pick:hover .pick__preview img {
  transform: scale(1.03);
}

.pick__facts {
  grid-area: facts;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: 0;
  font-size: var(--text-13);
  line-height: 1.4;
}

.pick__fact dt {
  color: var(--color-text-muted);
  font-size: var(--text-11);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pick__fact dd {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--space-2);
  margin: 2px 0 0;
}

.pick__fact--lead dd {
  flex-direction: column;
  gap: 0;
}

.pick__fact--lead strong {
  font-size: var(--text-20);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.pick__fact--lead span,
.pick__more {
  color: var(--color-text-muted);
}

.pick__country,
.pick__provider {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.pick__country img {
  border-radius: 2px;
}

.pick__provider .icon {
  width: 1rem;
  height: 1rem;
}

@container (min-width: 40rem) {
  .pick {
    grid-template-areas: "text preview" "facts preview";
    grid-template-columns: minmax(0, 1fr) 15rem;
    grid-template-rows: auto 1fr;
    column-gap: var(--space-6);
  }

  .pick__facts {
    align-self: end;
  }
}

@container (min-width: 58rem) {
  .pick {
    grid-template-areas: "text preview facts";
    grid-template-columns: minmax(0, 1fr) 17rem 10rem;
    grid-template-rows: auto;
    align-items: start;
  }

  .pick__facts {
    flex-direction: column;
    align-self: start;
    gap: var(--space-3);
  }
}

/* Where a nested article sits: its places above it, as the eyebrow. */
.trail {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.trail li + li::before {
  content: "›";
  margin-right: var(--space-2);
  color: var(--color-text-muted);
}

.trail a {
  color: inherit;
  text-decoration: none;
}

.trail a:hover {
  text-decoration: underline;
}

/* After an article: the search for more maps, its places and those beside it. */
.article__more {
  display: grid;
  gap: var(--space-6);
  padding: clamp(var(--space-4), 3vw, var(--space-6));
  border-radius: var(--radius-l);
  background: var(--color-raised);
}

.article__more section {
  display: grid;
  gap: var(--space-3);
}

.article__more-title {
  font-size: var(--text-17);
}

.article__more .chip {
  background: var(--color-card);
  color: var(--color-text);
  font-size: var(--text-14);
}

.article__more .chip:hover {
  color: var(--color-accent);
}

/* --- Article contents ------------------------------------------------------- */

/* A long article lists its sections: beside the text where the page is wide enough,
   as a row of pills under the masthead where it is not. With JavaScript it shows
   once the title has scrolled away and marks the section in view (site.js). */
.contents__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents__link {
  display: block;
  color: var(--color-text-muted);
  text-decoration: none;
  transition:
    color 0.15s var(--ease),
    background-color 0.15s var(--ease);
}

.contents__link:hover {
  color: var(--color-text);
}

.contents__link[aria-current="true"] {
  color: var(--color-accent-soft-ink);
  background: var(--color-accent-soft);
}

.js .contents {
  transition:
    opacity 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.js .contents:not(.is-shown) {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 84rem) {
  .article-layout--contents {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 50rem) minmax(0, 1fr);
    gap: var(--space-8);
    align-items: start;
  }

  .article-layout--contents .article {
    grid-column: 2;
    width: 100%;
  }

  /* A wide article keeps room for the contents beside it; where the screen is not
     wide enough for both, the article gives way. */
  .article-layout--contents.article-layout--wide {
    grid-template-columns: minmax(15rem, 1fr) minmax(0, 72rem) minmax(0, 1fr);
  }

  .contents {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    position: sticky;
    top: calc(var(--masthead-height) + var(--space-8));
    width: min(15rem, 100%);
    max-height: calc(100vh - var(--masthead-height) - var(--space-16));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--color-text-subtle) 35%, transparent) transparent;
    padding: var(--space-4);
    border-radius: var(--radius-l);
    background: color-mix(in srgb, var(--color-card) 88%, transparent);
    box-shadow: var(--shadow-card);
  }

  .js .contents:not(.is-shown) {
    transform: translateX(calc(-1 * var(--space-3)));
  }

  .contents__title {
    margin: 0 0 var(--space-3) var(--space-3);
  }

  .contents__list {
    display: grid;
    gap: 2px;
  }

  .contents__link {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-m);
    font-size: 0.9rem;
    line-height: 1.35;
  }
}

@media (max-width: 83.99rem) {
  .contents {
    position: sticky;
    top: var(--masthead-height);
    z-index: var(--z-contents);
    margin: calc(-1 * var(--space-6)) calc(-1 * var(--gutter)) var(--space-4);
    background: color-mix(in srgb, var(--color-surface) 96%, transparent);
    box-shadow: 0 6px 12px -10px color-mix(in srgb, var(--color-shadow) 40%, transparent);
  }

  .js .contents:not(.is-shown) {
    transform: translateY(calc(-1 * var(--space-2)));
  }

  .contents__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .contents__list {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding: var(--space-2) var(--gutter);
    scrollbar-width: none;
  }

  .contents__link {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--color-raised);
    font-size: var(--text-13);
    white-space: nowrap;
  }

  /* While the row of pills shows, it continues the masthead without a line between. */
  html:not(.js) body:has(.contents) .masthead,
  body:has(.contents.is-shown) .masthead {
    box-shadow: none;
  }

  /* Headings land below the row of pills as well as the masthead. */
  html:has(.article-layout--contents) {
    scroll-padding-top: calc(var(--masthead-height) + 3.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .contents,
  .contents__link {
    transition: none;
  }

  .js .contents:not(.is-shown) {
    transform: none;
  }
}
