/* SPDX-License-Identifier: GPL-2.0-or-later */
:root {
  color-scheme: light dark;
  --paper: #f4f0e7;
  --surface: #fbf8f1;
  --ink: #262823;
  --muted: #65675f;
  --accent: #526a55;
  --rule: #cbc5b8;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

html:lang(ja) {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, "Noto Sans CJK JP", sans-serif;
}

html:lang(ja) h1,
html:lang(ja) h2,
html:lang(ja) h3,
html:lang(ja) .eyebrow,
html:lang(ja) .totals dd,
html:lang(ja) .group-category,
html:lang(ja) .score span,
html:lang(ja) dt,
html:lang(ja) .explorer thead th,
html:lang(ja) .place-card .kind {
  letter-spacing: normal;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191a17;
    --surface: #212320;
    --ink: #eceadf;
    --muted: #a3a599;
    --accent: #a3c3a5;
    --rule: #3d3f39;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.12em;
}

a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.site-header,
.breadcrumbs,
main,
footer {
  width: min(100% - 2rem, 76rem);
  margin-inline: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.site-name {
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.site-header p,
footer p {
  margin: 0;
  color: var(--muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: flex-end;
  margin-left: auto;
}

.language-switcher {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin-left: 0.25rem;
  font-size: 0.75rem;
}

.language-switcher a {
  color: var(--muted);
  text-decoration: none;
}

.language-switcher a:hover,
.language-switcher a[aria-current="page"] {
  color: var(--accent);
}

.language-switcher a[aria-current="page"] {
  font-weight: 700;
}

.breadcrumbs {
  padding-block: 1rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.875rem;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.35rem;
  color: var(--rule);
}

main {
  flex: 1;
  padding-block: 2.5rem 5rem;
}

footer {
  padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--rule);
}

.footer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
}

.built {
  margin-top: 0.75rem;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.footer-badge:hover {
  color: var(--accent);
}

.footer-badge svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  line-height: 1.15;
}

h1 {
  max-width: 26ch;
  margin: 0.25rem 0 1rem;
  font-size: clamp(1.9rem, 5vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.03em;
}

h2 {
  margin-top: 2.5rem;
  font-size: 1.5rem;
}

h3 {
  font-size: 1.05rem;
}

.page-intro {
  max-width: 50rem;
  margin-bottom: 3rem;
}

.page-intro > p:not(.eyebrow) {
  max-width: 46rem;
  font-size: 1.125rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.ranking article {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.ranking h3,
.ranking p {
  margin: 0 0 0.5rem;
}

.ranking h3 {
  font-size: 1.25rem;
}

.award-logo {
  display: block;
  width: 3.25rem;
  aspect-ratio: 1;
  object-fit: contain;
}

@media (prefers-color-scheme: light) {
  .award-logo[src$="the-brain-prize.svg"] {
    filter: invert(1);
  }
}

@media (prefers-color-scheme: dark) {
  .award-logo[src$="millennium-technology-prize.svg"] {
    filter: invert(1);
  }
}

.award-identity {
  display: grid;
  gap: 0.4rem;
  justify-items: center;
}

.award-identity .rank {
  font-size: 0.75rem;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 3rem;
  margin: 0 0 3rem;
  padding-block: 1.25rem;
  border-block: 1px solid var(--rule);
}

.totals dt {
  color: var(--ink);
  font-size: 1.6rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-transform: none;
}

.totals dd {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.highlights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0 2.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.highlights li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.55rem;
  border-bottom: 1px solid var(--rule);
}

.highlights span {
  flex: none;
  max-width: 55%;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: right;
}

.caveat {
  max-width: 44rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.page-intro > p.caveat {
  font-size: 0.9375rem;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

.view-tabs .tab-alt {
  margin-left: auto;
}

.view-tabs span {
  color: var(--rule);
}

.view-tabs a {
  padding-block: 0.4rem;
  color: var(--muted);
  text-decoration: none;
}

.view-tabs a[aria-current="page"] {
  margin-bottom: -1px;
  border-bottom: 3px solid var(--accent);
  color: var(--ink);
  font-weight: 700;
}

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

/* Direct children only: an institution's constituent units nest a second list inside the middle column, and those
   rows are not themselves ranked. */
.rank-list > li {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 6rem;
  gap: 1rem;
  align-items: baseline;
  padding-block: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

/* The schools and departments recorded under an institution. They are shown, never ranked, and they do not sum to
   the parent: one laureate can be recorded under both a school and the university itself. */
.rank-units {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.875rem;
}

.rank-units li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.15rem;
}

.rank-units-more {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* The native triangle is the one piece of browser chrome on the page. Drop it and let the "+" carry the affordance. */
.rank-units-more summary {
  width: fit-content;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid transparent;
}

.rank-units-more summary::-webkit-details-marker {
  display: none;
}

.rank-units-more summary:hover {
  color: var(--ink);
  border-bottom-color: var(--rule);
}

.rank-units-more summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.rank-units-more .rank-units {
  margin-top: 0.2rem;
}

.rank-unit-count {
  font-variant-numeric: tabular-nums;
}

/* Second line of a ranked institution: where it is, what it is known for, and how to apply. */
.rank-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.rank-position {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rank-count {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* A bar under the count, sized by its share of the leader, so the distribution reads at a glance. */
.rank-count::after {
  content: "";
  display: block;
  width: calc(var(--share) * 1%);
  height: 3px;
  margin-top: 0.3rem;
  margin-left: auto;
  background: var(--accent);
}

.rank-list-plain .rank-count::after {
  content: none;
}

.score-bar {
  display: block;
  width: calc(var(--score) * 1%);
  height: 3px;
  margin-top: 0.45rem;
  background: var(--accent);
}

.external-link {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.8em;
  text-decoration: none;
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.score {
  grid-column: 2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.score span {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.facts {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
}

.facts h2 {
  margin-top: 0;
}

.winner-list,
.recipient-list {
  padding-left: 1.25rem;
}

.winner-list li {
  margin-block: 0.5rem;
}

/* Award years and categories are navigation, not reading matter: they wrap into columns so the laureates below them
   stay reachable. A prize like the Max Planck Medal has ninety award years. */
.route-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.5rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-list-years {
  grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
}

.category-years,
.category-recipients {
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-years > li {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 1rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--rule);
}

.category-year {
  position: sticky;
  top: 1rem;
  align-self: start;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.category-recipients li + li {
  margin-top: 1rem;
}

.category-recipients p {
  max-width: 62ch;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  font-style: italic;
}

.category-recipients .recipient-names {
  max-width: none;
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-style: normal;
}

.group-category {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.co-laureates {
  margin: 0;
  padding-left: 1.25rem;
}

.co-laureates li {
  margin-block: 0.35rem;
}

.winner-list span {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

.recipient-list {
  list-style: decimal-leading-zero;
}

.recipient-list li {
  padding: 0.5rem 0 1.5rem 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.recipient-list h3 {
  margin-bottom: 0.5rem;
}

.person-awards {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.person-awards > li {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 1rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.person-award-year {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.person-awards h3 {
  margin: 0 0 0.35rem;
}

.person-awards p {
  margin: 0;
  color: var(--muted);
}

.subject-badges,
.person-index-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.subject-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.4;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
}

.birth-country {
  text-decoration: none;
}

.people-index {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 3rem;
}

.people-index li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.4rem;
  border-bottom: 1px solid var(--rule);
  break-inside: avoid;
}

.people-index span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.subject-people {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.subject-people > li {
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.subject-people header {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  justify-content: space-between;
}

.subject-people h2 {
  margin: 0;
  font-size: 1.15rem;
}

.subject-people header span {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.subject-people ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.pagination {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.pagination span {
  color: var(--muted);
}

.winner-article {
  display: contents;
}

.lead {
  font-size: 1.2rem;
}

/* Institution, unit, and place are one address, so they close ranks and only separate affiliations get air. */
.winner-affiliations h2 {
  margin-bottom: 0.75rem;
}

.winner-affiliations p {
  margin-block: 0.15rem;
}

.winner-affiliations p.place {
  color: var(--muted);
}

.winner-affiliations div + div {
  margin-top: 1rem;
}

/* The citation is the reason the page exists, so it sits directly under the name. */
.page-intro > p.citation {
  max-width: 44rem;
  margin: 0 0 1.25rem;
  font-size: 1.3rem;
  line-height: 1.45;
}

.page-intro > p.ask-ai {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-block: 1.5rem;
  font-size: 0.875rem;
}

.ask-ai a {
  color: var(--muted);
  text-decoration: none;
}

.ask-ai a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.subject-badge:hover {
  border-color: var(--accent);
}

.winner-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
}

.external-source {
  color: var(--muted);
  font-weight: 400;
}

.ror-tag {
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.6;
}

.facts dl,
.award-facts {
  margin: 0;
}

.facts dl div,
.award-facts div {
  padding-block: 0.65rem;
  border-top: 1px solid var(--rule);
}

/* Four registry ids stacked like the facts above them would nearly double the panel, so label and value share a
   line and the group closes ranks: only the first row keeps a rule, and the ids read as one block. */
.facts dl div.identifier {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding-block: 0.3rem;
}

.facts dl div.identifier + div.identifier {
  border-top: none;
}

.facts dl div.identifier dt {
  flex: none;
  width: 5rem;
}

.facts dl div.identifier dd {
  margin: 0;
  font-size: 0.8rem;
}

dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

dd {
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
}

/* The about page is prose, so it needs a reading measure the data pages never do. */
.about main p,
.about main li {
  max-width: 46rem;
}

.about main li + li {
  margin-top: 0.75rem;
}

@media (max-width: 52rem) {
  .site-header > p {
    display: none;
  }

  .site-nav-toggle {
    order: 2;
    margin-left: 0.75rem;
    padding: 0;
  }

  .site-nav-toggle summary {
    list-style: none;
    cursor: pointer;
    color: var(--accent);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
    margin: -0.4rem -0.6rem;
  }

  .site-nav-toggle summary::-webkit-details-marker {
    display: none;
  }

  .site-nav {
    order: 3;
    display: none;
    flex-direction: column;
    gap: 0;
    margin-left: 0;
    margin-top: 0.5rem;
    width: 100%;
    border-top: 1px solid var(--rule);
    padding-top: 0.5rem;
  }

  .site-nav-toggle[open] + .site-nav {
    display: flex;
  }

  .site-nav a {
    padding-block: 0.5rem;
    display: block;
    border-bottom: 1px solid var(--rule);
  }

  /* Language codes ride beside the hamburger rather than claiming a row of their own. */
  .language-switcher {
    order: 1;
    margin-left: auto;
  }
}

/* Two columns leave a laureate about 18 characters, so names shatter over three lines and their badges strand. */
@media (max-width: 40rem) {
  .people-index {
    columns: 1;
  }

  /* Laureates, awards, and prizes fill one row on a phone. Years and countries would start a second row for two
     figures the page repeats further down, so they wait for the width to carry them. */
  .totals {
    gap: 1rem 1.5rem;
  }

  .totals div:nth-child(n + 4) {
    display: none;
  }

  .page-intro > p:not(.eyebrow) {
    font-size: 0.9375rem;
  }

  /* Desktop can spend 40px above the heading; a phone gives up a fifth of the first screen for it. */
  .breadcrumbs {
    padding-block: 0.75rem;
  }

  main {
    padding-block: 1.5rem 3rem;
  }

  .page-intro {
    margin-bottom: 2rem;
  }

  .view-tabs {
    margin-bottom: 1.5rem;
  }
}

@media (min-width: 52rem) {
  .site-nav-toggle {
    display: none;
  }
}

@media (min-width: 64rem) {
  .site-header,
  .breadcrumbs,
  main,
  footer {
    width: min(100% - 6rem, 76rem);
  }

  .ranking article {
    grid-template-columns: 3rem minmax(0, 1fr) 7rem;
    gap: 2rem;
  }

  .score {
    grid-column: 3;
    text-align: right;
  }

  .score-bar {
    margin-left: auto;
  }

  .winner-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 3rem;
  }

  .winner-article {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
    gap: 4rem;
    align-items: start;
  }

  .winner-article .facts {
    position: sticky;
    top: 1rem;
  }
}
