/* =========================================================
   IMPACT STORIES: the list page
   Tokens, type and buttons come from css/wfc.css; the story cards,
   the "Sort by" menu and the "Load more" row come from css/components.css.
   The cards and the filter controls on this page have square corners.
   ========================================================= */

/* ---------- Breadcrumb line ---------- */

.wfc-trail {
  --crumb: var(--wfc-slate);
  --crumb-strong: var(--wfc-ink);
  --crumb-focus: var(--wfc-forest);
  padding-block: 20px;
  background: var(--wfc-paper);
}

/* ---------- Lead story ----------
   Photo on the left running to the screen's edge, text on a pale panel
   on the right. On phones the photo sits on top. */

.wfc-lede {
  position: relative;
  display: grid;
  background: var(--wfc-mist);
}

.wfc-lede__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  background: var(--wfc-line);
}

.wfc-lede__media img,
.wfc-lede__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: 50% 22%;
  transition: transform 0.8s var(--wfc-ease);
}

.wfc-lede:hover .wfc-lede__media img {
  transform: scale(1.03);
}

.wfc-lede__panel {
  display: grid;
  align-items: center;
  padding: clamp(32px, 6vw, 56px) var(--wfc-gutter);
}

.wfc-lede__body {
  display: grid;
  justify-items: start;
  gap: 18px;
  max-width: 640px;
}

.wfc-lede__date {
  margin: 0;
  font-family: var(--wfc-display);
  font-weight: 600;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1875rem);
  line-height: 1.2;
  color: var(--wfc-forest);
}

.wfc-lede__title {
  margin: 0;
  font-family: var(--wfc-display);
  font-weight: 800;
  font-stretch: 68%;
  font-size: clamp(2rem, 1.2rem + 2.6vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: -0.005em;
  color: var(--wfc-ink);
  text-wrap: balance;
}

.wfc-lede__text {
  margin: 0;
  font-family: var(--wfc-text);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.6;
  color: var(--wfc-slate);
}

.wfc-lede .wfc-btn {
  min-height: 52px;
  margin-top: 6px;
  padding: 0 28px;
}

/* The whole block is clickable through the button. */
.wfc-lede .wfc-btn::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* Side by side from tablets up: stacked, a wide photo would crop the person out. */
@media (min-width: 700px) {
  .wfc-lede {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: clamp(420px, 34vw, 600px);
  }

  .wfc-lede--text {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .wfc-lede__media {
    aspect-ratio: auto;
  }

  /* The text's right edge lines up with the page content below. */
  .wfc-lede__panel {
    --lede-pad: clamp(28px, 4vw, 60px);
    padding: clamp(36px, 4vw, 56px) var(--wfc-gutter) clamp(36px, 4vw, 56px) var(--lede-pad);
  }

  .wfc-lede__body {
    max-width: calc(620px - var(--lede-pad));
  }

  .wfc-lede--text .wfc-lede__panel {
    padding-inline: max(var(--wfc-gutter), calc((100% - 1240px) / 2));
  }

  .wfc-lede--text .wfc-lede__body {
    max-width: 760px;
  }
}

/* ---------- All stories ---------- */

.wfc-stories__title {
  color: var(--wfc-forest);
}

.wfc-stories__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* A square, outlined control: "Show filters" here, and the "Sort by" button beside it. */
.wfc-toolbtn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid #b9c4bb;
  background: var(--wfc-paper);
  font-family: var(--wfc-display);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--wfc-ink);
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.wfc-toolbtn i {
  font-size: 0.875rem;
  color: var(--wfc-forest);
}

.wfc-toolbtn:hover {
  border-color: var(--wfc-forest);
  color: var(--wfc-ink);
}

.wfc-toolbtn:focus-visible {
  outline: 3px solid var(--wfc-forest);
  outline-offset: 2px;
}

/* How many filters are on. */
.wfc-toolbtn__count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--wfc-forest);
  font-family: var(--wfc-text);
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--wfc-paper);
}

/* The filters that are on, under the bar; each is a link that takes it off. */
.wfc-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: -12px 0 32px;
  padding: 0;
  list-style: none;
}

.wfc-chips a:not(.wfc-link) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--wfc-mist);
  font-family: var(--wfc-text);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--wfc-ink);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.wfc-chips a:not(.wfc-link) i {
  font-size: 0.8rem;
  color: var(--wfc-forest);
}

.wfc-chips a:not(.wfc-link):hover {
  background: var(--wfc-line);
}

.wfc-chips a:not(.wfc-link):focus-visible {
  outline: 3px solid var(--wfc-forest);
  outline-offset: 2px;
}

.wfc-chips .wfc-link {
  margin-left: 6px;
}

/* ---------- Filters panel ----------
   A dialog opened by "Show filters": a wide, square panel near the top of
   the screen over a dimmed page, with groups that open and close. */

.wfc-filters {
  width: min(1240px, calc(100vw - 2 * var(--wfc-gutter)));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: clamp(16px, 11vh, 120px) auto auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--wfc-paper);
  color: var(--wfc-ink);
  overflow: auto;
}

.wfc-filters::backdrop {
  background: rgba(14, 42, 28, 0.62);
}

html:has(.wfc-filters[open]) {
  overflow: hidden;
}

/* Without JavaScript the button links here, and the panel is shown in place. */
.wfc-filters:target:not([open]) {
  position: static;
  display: block;
  width: auto;
  max-height: none;
  margin: 0 0 32px;
  border: 1px solid var(--wfc-line);
}

.wfc-filters form {
  padding: clamp(20px, 3vw, 40px);
}

.wfc-filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(16px, 2.4vw, 32px);
}

.wfc-filters__title {
  margin: 0;
  font-family: var(--wfc-display);
  font-weight: 800;
  font-stretch: 72%;
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
  line-height: 1;
  color: var(--wfc-ink);
}

.wfc-filters__close {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-right: -12px;
  font-size: 1.375rem;
  color: var(--wfc-ink);
  text-decoration: none;
  transition: color 0.2s ease;
}

.wfc-filters__close:hover {
  color: var(--wfc-forest);
}

.wfc-filters__close:focus-visible {
  outline: 3px solid var(--wfc-forest);
  outline-offset: -3px;
}

.wfc-filters__group {
  border-bottom: 1px solid var(--wfc-line);
}

.wfc-filters__group:first-of-type {
  border-top: 1px solid var(--wfc-line);
}

.wfc-filters__group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  font-family: var(--wfc-display);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.2;
  color: var(--wfc-ink);
  cursor: pointer;
  list-style: none;
}

.wfc-filters__group summary::-webkit-details-marker {
  display: none;
}

.wfc-filters__group summary:focus-visible {
  outline: 3px solid var(--wfc-forest);
  outline-offset: -3px;
}

/* A plus that becomes a minus when the group is open. */
.wfc-filters__group summary::after {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  background:
    linear-gradient(var(--wfc-forest), var(--wfc-forest)) center / 16px 2px no-repeat,
    linear-gradient(var(--wfc-forest), var(--wfc-forest)) center / 2px 16px no-repeat;
  transition: transform 0.3s var(--wfc-ease);
}

.wfc-filters__group[open] summary::after {
  background-size: 16px 2px, 0 0;
  transform: rotate(180deg);
}

.wfc-filters__body {
  padding: 0 0 24px;
}

.wfc-filters__body input[type="search"] {
  width: min(100%, 520px);
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid #b9c4bb;
  border-radius: 0;
  background: var(--wfc-paper);
  font-family: var(--wfc-text);
  font-size: 1rem;
  color: var(--wfc-ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wfc-filters__body input[type="search"]::placeholder {
  color: var(--wfc-slate);
}

.wfc-filters__body input[type="search"]:focus {
  border-color: var(--wfc-forest);
  box-shadow: 0 0 0 3px rgba(11, 102, 35, 0.18);
}

.wfc-filters__options {
  display: grid;
  justify-items: start;
}

.wfc-filters__options label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-family: var(--wfc-text);
  font-size: 1.0625rem;
  line-height: 1.3;
  color: var(--wfc-ink);
  cursor: pointer;
}

/* Drawn here so they look the same in every browser: a ring, filled with a green dot when chosen. */
.wfc-filters__options input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid #7d8a80;
  border-radius: 50%;
  background: var(--wfc-paper);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.wfc-filters__options input:checked {
  border-color: var(--wfc-forest);
  background: radial-gradient(circle, var(--wfc-forest) 0 5px, var(--wfc-paper) 6px);
}

/* A choice with no stories cannot be picked. */
.wfc-filters__options label:has(input:disabled) {
  color: var(--wfc-slate);
  cursor: not-allowed;
}

.wfc-filters__options input:disabled {
  border-color: var(--wfc-line);
  cursor: not-allowed;
}

.wfc-filters__options input:focus-visible {
  outline: 3px solid var(--wfc-forest);
  outline-offset: 2px;
}

/* How many stories the choice holds. */
.wfc-filters__options span {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--wfc-slate);
}

.wfc-filters__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  padding-top: clamp(20px, 2.6vw, 32px);
}

.wfc-filters__foot .wfc-btn {
  min-height: 52px;
  padding: 0 28px;
}

.wfc-stories__back {
  margin: -8px 0 28px;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .wfc-lede__media img,
  .wfc-toolbtn,
  .wfc-chips a,
  .wfc-filters__close,
  .wfc-filters__group summary::after,
  .wfc-filters__body input[type="search"] {
    transition: none;
  }

  .wfc-lede:hover .wfc-lede__media img {
    transform: none;
  }
}
