/**
 * Styles for the blog: the "Artikkelit (blogi)" card list and single article
 * pages.
 *
 * Hand-written plain CSS served from resources/assets/, for the same reason as
 * fund-page.css: the Sage 9 / node-sass build cannot currently be run, so
 * rules added to main.scss would never reach the browser. .embed-container
 * comes from fund-page.css, which loads on every page.
 *
 * Colours are taken from resources/assets/styles/common/_variables.scss:
 *   $blue #003057   $yellow #fac85a   $lightgrey #f6f5f4   $brown #85714d
 */

/* ---------- List ---------- */

.articles__title {
  margin-top: 0;
}

.articles__lead {
  max-width: 46rem;
}

/* ---------- Filter pills ---------- */

.articles__filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.articles__filter {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 0.6em 0.5em 1.1em;
  border: 1px solid rgba(0, 48, 87, 0.18);
  border-radius: 999px;
  background: #fff;
  color: #003057;
  font-size: 0.8em;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  transition: 0.2s ease-in-out color, 0.2s ease-in-out background-color, 0.2s ease-in-out border-color, 0.2s ease-in-out box-shadow;
}

.articles__filter .article-icon {
  width: 1.25em;
  height: 1.25em;
  margin-left: -0.2em;
}

.articles__filter:hover,
.articles__filter:focus {
  border-color: #003057;
  color: #003057;
  text-decoration: none;
  box-shadow: 0 4px 12px -6px rgba(0, 48, 87, 0.4);
}

.articles__filter:focus {
  outline: none;
}

.articles__filter:focus-visible {
  outline: 2px solid #003057;
  outline-offset: 2px;
}

.articles__filter[aria-current],
.articles__filter[aria-current]:hover,
.articles__filter[aria-current]:focus {
  border-color: #003057;
  background: #003057;
  color: #fac85a;
  box-shadow: none;
}

.articles__filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7em;
  height: 1.7em;
  padding: 0 0.5em;
  border-radius: 999px;
  background: rgba(0, 48, 87, 0.08);
  font-size: 0.8em;
  font-weight: 600;
}

.articles__filter[aria-current] .articles__filter-count {
  background: rgba(250, 200, 90, 0.18);
}

/* ---------- Grid ---------- */

.articles__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5em;
  margin-top: 1.5em;
  transition: 0.2s ease-in-out opacity;
}

/* While a filter is fetching, the old cards fade back rather than vanish, so
   the page does not jump. */
.articles.is-filtering .articles__grid {
  opacity: 0.35;
  pointer-events: none;
}

.article-card {
  animation: article-in 0.35s ease-out backwards;
}

@keyframes article-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (min-width: 700px) {
  .articles__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .articles__grid--cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.articles__more {
  margin-top: 2.5em;
  text-align: center;
}

.articles__more-button,
.articles__more-button:hover,
.articles__more-button:focus {
  color: #fac85a;
  text-decoration: none;
}

.articles__more-button.is-loading {
  cursor: progress;
  opacity: 0.75;
}

.articles__more-button.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 0.6em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: articles-spin 0.7s linear infinite;
}

@keyframes articles-spin {
  to {
    transform: rotate(360deg);
  }
}

.articles__empty {
  opacity: 0.7;
}

/* Announces "more loaded" to screen readers without showing anything. */
.articles__status,
.article-card__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Card ---------- */

.article-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(0, 48, 87, 0.12);
  transition: 0.25s ease-in-out box-shadow, 0.25s ease-in-out transform;
}

.article-card--linked:hover,
.article-card--linked:focus-within {
  box-shadow: 0 14px 32px -16px rgba(0, 48, 87, 0.45);
  transform: translateY(-2px);
}

.article-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #003057;
}

.article-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: 0.4s ease-in-out transform;
}

.article-card--linked:hover .article-card__img {
  transform: scale(1.03);
}

/* The embed fills the 16:9 media box instead of padding out its own. */
.article-card__media .embed-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

.article-card__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #fac85a;
}

.article-card__placeholder .article-icon {
  width: 3.5em;
  height: 3.5em;
  opacity: 0.9;
}

.article-card--tiedosto .article-card__media {
  background: #f6f5f4;
}

.article-card--tiedosto .article-card__placeholder {
  color: #003057;
}

.article-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 1.25em 1.25em 1.4em;
}

.article-card__meta {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin: 0;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #85714d;
}

.article-card__meta time {
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #03080b;
  opacity: 0.6;
}

/* Type icon. Each type gets its own treatment so the list can be scanned by
   shape and colour, not only by reading the label. */
.article-card__badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  background: #003057;
  color: #fac85a;
}

.article-card__badge .article-icon {
  width: 1.35em;
  height: 1.35em;
}

.article-card--youtube .article-card__badge {
  background: #fac85a;
  color: #003057;
}

.article-card--tiedosto .article-card__badge {
  background: #f6f5f4;
  color: #003057;
  box-shadow: inset 0 0 0 1px rgba(0, 48, 87, 0.2);
}

/* h3 carries a rule and a 2em size site-wide; neither suits a card. */
.article-card__title {
  margin: 0.6em 0 0.4em;
  border-bottom: 0;
  font-size: 1.35em;
  line-height: 1.15;
}

.article-card__link,
.article-card__link:hover,
.article-card__link:focus {
  color: inherit;
  text-decoration: none;
  outline: none;
}

/* The title link covers the whole card, so the card is one click target
   without nesting block content inside an <a>. */
.article-card__link::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
}

.article-card__link:focus-visible::after {
  outline: 2px solid #003057;
  outline-offset: 3px;
}

.article-card__excerpt {
  margin: 0 0 1.25em;
  font-size: 0.8em;
  line-height: 1.6;
  opacity: 0.8;
}

.article-card__action {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin: auto 0 0;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #003057;
}

.article-card__action .article-icon {
  width: 1.4em;
  height: 1.4em;
  transition: 0.25s ease-in-out transform;
}

.article-card--blogi:hover .article-card__action .article-icon {
  transform: translateX(4px);
}

.article-card--tiedosto:hover .article-card__action .article-icon {
  transform: translateY(2px);
}

.article-card__file-meta {
  font-weight: 400;
  opacity: 0.6;
}

/* ---------- Single article ---------- */

.article__hero {
  position: relative;
}

/* A soft shade under the title so it stays legible on light photographs. */
.article__hero::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(to bottom, rgba(0, 20, 38, 0.05) 30%, rgba(0, 20, 38, 0.55));
}

.article__header h1 {
  max-width: 22em;
  margin: 0 auto;
}

@media (min-width: 700px) {
  .article__header h1 {
    font-size: 2.75em;
  }
}

.article__header--plain {
  min-height: 0;
}

.article__header--plain .page__header__bg {
  height: auto;
  min-height: 12em;
  background-color: #003057;
}

.article__header--plain .article__hero::before {
  display: none;
}

/* Without a photo the title and meta bands are the same blue; a hairline
   keeps them reading as two parts. */
.article__header--plain .page__header__content {
  border-top: 1px solid rgba(250, 200, 90, 0.2);
}

.article__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
}

.article__meta .article-icon {
  width: 1.2em;
  height: 1.2em;
}

.article__container {
  max-width: 44rem;
}

.article__video {
  margin-bottom: 2em;
}

.article__content h2 {
  font-size: 1.9em;
}

.article__content h3 {
  font-size: 1.4em;
  border-bottom: 0;
}

.article__content img {
  height: auto;
}

/* The site-wide blockquote floats at half width, which a single reading
   column is too narrow for. */
.article__content blockquote {
  float: none;
  width: auto;
  margin: 1.5em 0;
}

.article__back {
  margin: 3em 0 0;
  padding-top: 1.5em;
  border-top: 1px solid rgba(0, 48, 87, 0.15);
}

.article__back a {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  color: #003057;
  font-size: 0.85em;
  text-decoration: none;
}

.article__back .article-icon {
  width: 1.2em;
  height: 1.2em;
  transition: 0.25s ease-in-out transform;
}

.article__back a:hover .article-icon {
  transform: translateX(-4px);
}

@media (prefers-reduced-motion: reduce) {
  .article-card {
    animation: none;
  }

  .articles__grid,
  .article-card,
  .article-card__img,
  .article-card .article-icon,
  .article__back .article-icon {
    transition: none;
  }

  .article-card--linked:hover,
  .article-card--linked:focus-within,
  .article-card--linked:hover .article-card__img {
    transform: none;
  }

  .articles__more-button.is-loading::after {
    animation-duration: 2s;
  }
}
