/*
 * The Sources page (/features/sources/): the site's own hero, film and story,
 * plus the four diagrams that show what Sources counts.
 * DESIGN.md §9, "The Sources page in detail". Linked from that page only, and
 * every selector starts .sp- inside main.sp-page, so nothing reaches another page.
 */

.sp-page {
  /* The kinds of site, in the app's chart series order and colours (DESIGN.md §10). */
  --sp-yours: #2f7dff;
  --sp-competitors: #ff8a3d;
  --sp-publications: #1ac6b8;
  --sp-community: #b49bff;
  --sp-companies: #e84a8a;
  --sp-other: #ffc233;
  /* The app's good and bad, and their washes (DESIGN.md §3). */
  --sp-good: #15803d;
  --sp-good-wash: #eaf6ee;
  --sp-bad: #c42a52;
  --sp-bad-wash: #fbeef1;
}

.sp-k-yours {
  --part: var(--sp-yours);
}
.sp-k-competitors {
  --part: var(--sp-competitors);
}
.sp-k-publications {
  --part: var(--sp-publications);
}
.sp-k-community {
  --part: var(--sp-community);
}
.sp-k-companies {
  --part: var(--sp-companies);
}
.sp-k-other {
  --part: var(--sp-other);
}

/* ---------- How it works: clips of the app, 16:10, whole ---------- */

.sp-story .scene > .crux-film {
  border-radius: 14px;
}

.sp-story.is-inline .scene {
  aspect-ratio: auto;
}

/* ---------- The parts: copy, and a diagram on the sky ---------- */

/* One sentence of copy beside a tall diagram: the diagram takes the room. */
.sp-part {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.7fr);
}

.sp-part.is-flip {
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 0.8fr);
}

.sp-part h2 {
  margin-top: 4px;
}

.sp-lede {
  max-width: 400px;
  margin-top: 20px;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1.55;
}

.sp-fig {
  container-type: inline-size;
}

.sp-card {
  overflow: hidden;
  border: 1px solid rgb(17 17 17 / 0.08);
  border-radius: 16px;
  background: #fff;
  box-shadow:
    0 1px 2px rgb(17 17 17 / 0.06),
    0 40px 90px -40px rgb(0 30 70 / 0.42);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}

.sp-card img {
  flex: none;
  object-fit: contain;
}

.sp-card small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A row the diagram is not showing: its own display rule must not bring it back. */
.sp-card li[hidden] {
  display: none;
}

/* A site without a logo: its first letter, as the app's mark falls back. */
.sp-letter {
  display: grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--sheet-2);
  color: var(--ink-2);
  font: 500 11px/1 var(--font);
}

/* ---------- Cited: the bar by kind of site, and your share ---------- */

.sp-cited {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

.sp-cited-who {
  padding: 24px;
}

.sp-cited-own {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: #fafbfc;
}

.sp-card-title {
  font-size: 15px;
  font-weight: 500;
}

.sp-card-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.sp-stack {
  display: flex;
  gap: 2px;
  height: 10px;
  margin: 16px 0 14px;
  overflow: hidden;
  border-radius: 4px;
}

.sp-stack i {
  min-width: 2px;
  background: var(--part);
  transform-origin: left;
  transition: opacity 0.25s var(--ease);
}

.sp-stack i.is-dim,
.sp-key button.is-dim {
  opacity: 0.35;
}

.sp-key {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  margin: 0 0 0 -6px;
  padding: 0;
  list-style: none;
}

.sp-key button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--body);
  font: 400 12.5px/1.4 var(--font);
  cursor: pointer;
  transition:
    opacity 0.25s var(--ease),
    background-color 0.2s;
}

.sp-key button::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--part);
  content: "";
}

.sp-key button:hover,
.sp-key button[aria-pressed="true"] {
  background: var(--sheet);
}

.sp-key button[aria-pressed="true"] {
  color: var(--ink);
}

.sp-key b {
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.sp-sites-head {
  margin-top: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.sp-sites {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-sites li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 36px 72px;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #eef0f2;
}

.sp-sites li:last-child {
  border-bottom: 0;
}

.sp-sites img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.sp-sites b {
  display: block;
  overflow: hidden;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-sites small::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--part);
  vertical-align: 1px;
  content: "";
}

.sp-sites li[data-kind="yours"] {
  --part: var(--sp-yours);
}
.sp-sites li[data-kind="competitors"] {
  --part: var(--sp-competitors);
}
.sp-sites li[data-kind="publications"] {
  --part: var(--sp-publications);
}
.sp-sites li[data-kind="community"] {
  --part: var(--sp-community);
}
.sp-sites li[data-kind="companies"] {
  --part: var(--sp-companies);
}
.sp-sites li[data-kind="other"] {
  --part: var(--sp-other);
}

.sp-sites em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* The share of citations, scaled to the most cited site, in the kind's colour. */
.sp-sites .sp-bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--sheet);
  text-decoration: none;
}

.sp-sites .sp-bar::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  border-radius: 3px;
  background: var(--part);
  content: "";
}

.sp-overline {
  color: var(--muted);
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sp-figure {
  margin-top: 10px;
  color: var(--brand);
  font: 360 44px/1 var(--display);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.sp-delta {
  margin-top: 10px;
  color: var(--sp-good);
  font-size: 13px;
  font-weight: 500;
}

.sp-delta span {
  color: var(--faint);
  font-weight: 400;
}

.sp-own-line {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sp-own-top {
  margin-top: auto;
  padding-top: 24px;
}

.sp-own-pages {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.sp-own-pages li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #eef0f2;
  font-size: 13px;
}

.sp-own-pages span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-own-pages em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.sp-own-more {
  color: var(--muted);
}

@container (max-width: 560px) {
  .sp-cited {
    grid-template-columns: minmax(0, 1fr);
  }

  .sp-cited-own {
    order: -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
    gap: 4px 18px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    border-left: 0;
  }

  .sp-cited-own .sp-overline,
  .sp-cited-own .sp-own-line,
  .sp-cited-own .sp-own-pages {
    grid-column: 1 / -1;
  }

  .sp-own-top {
    padding-top: 12px;
  }

  .sp-cited-own .sp-figure {
    margin-top: 4px;
    font-size: 38px;
  }

  .sp-cited-own .sp-delta {
    margin: 0 0 4px;
  }

  .sp-cited-own .sp-own-line {
    margin-top: 6px;
  }

  .sp-cited-who {
    padding: 20px;
  }

  .sp-sites li {
    grid-template-columns: 20px minmax(0, 1fr) 36px 44px;
  }
}

/* ---------- Moving: pages gaining and slipping ---------- */

.sp-moving {
  padding: 20px 24px 8px;
}

.sp-chips {
  display: flex;
  gap: 6px;
}

.sp-chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 450 13px/1.2 var(--font);
  cursor: pointer;
  transition:
    color 0.2s,
    border-color 0.2s;
}

.sp-chips button:hover {
  color: var(--ink);
}

.sp-chips button[aria-pressed="true"] {
  border-color: var(--line);
  background: #fff;
  box-shadow: 0 1px 2px rgb(17 17 17 / 0.06);
  color: var(--ink);
}

.sp-chips b {
  color: var(--faint);
  font-weight: 450;
  font-variant-numeric: tabular-nums;
}

.sp-moving-cols,
.sp-pages li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 84px 52px;
  align-items: center;
  gap: 12px;
}

.sp-moving-cols {
  margin-top: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.sp-moving-cols span:first-child {
  grid-column: 1 / 3;
}

.sp-moving-cols span:not(:first-child) {
  text-align: right;
}

.sp-pages {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-pages li {
  padding: 12px 0;
  border-bottom: 1px solid #eef0f2;
}

.sp-pages li:last-child {
  border-bottom: 0;
}

.sp-pages li.is-new {
  animation: sp-rise 0.45s var(--ease) both;
  animation-delay: calc(var(--n, 0) * 40ms);
}

.sp-pages img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.sp-pages span > b {
  display: block;
  overflow: hidden;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-yours {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--brand);
  font-size: 11.5px;
  font-style: normal;
  font-weight: 500;
}

.sp-pages em {
  color: var(--faint);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.sp-pages em b {
  color: var(--ink);
  font-weight: 450;
}

.sp-pages strong {
  justify-self: end;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sp-pages .is-up {
  background: var(--sp-good-wash);
  color: var(--sp-good);
}

.sp-pages .is-down {
  background: var(--sp-bad-wash);
  color: var(--sp-bad);
}

@container (max-width: 460px) {
  .sp-moving {
    padding: 16px 16px 4px;
  }

  .sp-moving-cols,
  .sp-pages li {
    grid-template-columns: 20px minmax(0, 1fr) 76px 44px;
    gap: 8px;
  }

  .sp-moving-cols span {
    white-space: nowrap;
  }

  .sp-yours {
    display: none;
  }
}

/* ---------- Publish: cited sites, the ones a post can go on, biggest gap first ---------- */

.sp-publish {
  padding: 20px;
}

.sp-funnel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin: 0 0 18px;
  padding: 4px 4px 0;
  list-style: none;
}

.sp-funnel li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sp-funnel li + li::before {
  position: absolute;
  top: 50%;
  left: -24px;
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239a9ea4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E")
    center / contain no-repeat;
  content: "";
}

.sp-funnel span {
  color: var(--muted);
  font-size: 13px;
}

.sp-funnel b {
  font-size: 22px;
  font-weight: 450;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.sp-funnel li:last-child b {
  font-size: 17px;
  line-height: 1.6;
}

.sp-pubs {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-pubs > li {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: background-color 0.2s;
}

.sp-pubs > li > img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.sp-pubs b {
  display: block;
  font-weight: 500;
}

.sp-pubs b small {
  display: inline;
  margin-left: 6px;
  font-weight: 400;
}

.sp-pubs span > small {
  margin-top: 3px;
  font-size: 12.5px;
  white-space: normal;
}

.sp-pubs span > small img {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
}

@container (max-width: 520px) {
  .sp-publish {
    padding: 14px;
  }

  .sp-funnel {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 4px 6px 0;
  }

  .sp-funnel li {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }

  .sp-funnel li + li::before {
    top: -19px;
    left: 0;
    transform: rotate(90deg);
  }

  .sp-funnel li:last-child b {
    font-size: 15px;
  }

  .sp-pubs > li {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px 12px;
    padding: 12px;
  }

  .sp-pubs > li > img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }
}

/* ---------- Proof: what the answers took from one site ---------- */

.sp-proof {
  padding: 24px;
}

.sp-proof-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sp-proof-head img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.sp-proof-head b {
  display: block;
  font-size: 15px;
  font-weight: 500;
}

.sp-proof-line {
  margin-top: 14px;
  font-size: 17px;
  font-weight: 450;
  letter-spacing: -0.01em;
}

.sp-proof-tab {
  display: inline-block;
  margin-top: 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.sp-took {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.sp-took li {
  padding: 14px 0;
  border-bottom: 1px solid #eef0f2;
}

.sp-took q {
  font-size: 15px;
  line-height: 1.5;
}

.sp-took i {
  margin-left: 6px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.sp-took small {
  margin-top: 6px;
  white-space: normal;
}

.sp-took small img {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
}

@container (max-width: 460px) {
  .sp-proof {
    padding: 18px;
  }

  .sp-proof-line {
    font-size: 16px;
  }
}

/* ---------- Motion: each diagram plays once, on first sight ---------- */

.sp-fig.sp-wait .sp-stack i {
  transform: scaleX(0);
}

.sp-fig.sp-play .sp-stack i {
  animation: sp-grow 0.6s var(--ease) both;
  animation-delay: calc(var(--n, 0) * 60ms + 150ms);
}

.sp-fig.sp-wait .sp-sites .sp-bar::after {
  transform: scaleX(0);
  transform-origin: left;
}

.sp-fig.sp-play .sp-sites .sp-bar::after {
  transform-origin: left;
  animation: sp-grow 0.7s var(--ease) 0.5s both;
}

@keyframes sp-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: none;
  }
}

@keyframes sp-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sp-pages li.is-new,
  .sp-fig.sp-play .sp-stack i,
  .sp-fig.sp-play .sp-sites .sp-bar::after {
    animation: none;
  }
}

/* ---------- Narrower screens ---------- */

@media (max-width: 1100px) {
  .sp-part {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  }

  .sp-part.is-flip {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .sp-part,
  .sp-part.is-flip {
    grid-template-columns: minmax(0, 1fr);
  }
}
