/* Additions for the static site (the theme CSS is used unchanged). */

/* Publication search (replaces the Ajax Search Lite box) */
.site-search {
  margin: 0 0 1.5rem;
}
.site-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.8rem 0.6rem 2.4rem;
  border: 1px solid var(--primary, #004282);
  border-radius: 0;
  font: inherit;
  color: var(--primary, #004282);
  background: #fff url("theme/search.svg") no-repeat 0.7rem center / 1.1rem;
}
.site-search input:focus {
  outline: 2px solid var(--yellow, #fcc900);
  outline-offset: 1px;
}

/* Filtered-out archive items */
[data-filter-list] > [hidden] {
  display: none !important;
}

/* A list right after its lead-in paragraph ("… include the following:") follows it at paragraph
   spacing instead of the theme's extra list margin */
.block__text p + ul,
.block__text p + ol {
  margin-top: 0;
}

/* Heroes without a background colour have no bottom padding: when the text is longer than the
   images, it would touch the next section */
section.hero:not(.hero__has-background-color) .module__text {
  padding-bottom: 3rem;
}

/* Paused header animation (the pause button's state, see src/client/animation.ts) */
.header-animation-paused .svg-wrapper {
  animation-play-state: paused !important;
}

/* Hero with a logo instead of a photo (hero module setting "logo") */
section.hero .hero__logo {
  display: flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
@media (min-width: 768px) {
  section.hero__has-logo.hero__has-background-color {
    padding-bottom: 3rem;
  }
  section.hero__has-logo.hero__has-background-color .module__text {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
}
section.hero .hero__logo img {
  width: 100%;
  max-width: 22rem;
  height: auto;
}
@media (max-width: 767px) {
  section.hero .hero__logo {
    padding: 3rem 2rem 1rem;
  }
  section.hero .hero__logo img {
    max-width: 14rem;
  }
}

/* "News from our initiative": use the whole column so it fits on one line; where it can't,
   break it into even lines instead of leaving one word on its own */
.archive .col-8:has(> .header__headline) {
  flex: 0 0 100%;
  max-width: 100%;
}
.header__headline,
.hero__headline {
  text-wrap: balance;
}

/* News filter: the selected category keeps its hover colour (the theme colours by position)
   instead of turning white; "All" (the first tag) stays white */
.has_backgroundcolor .filter .tags li.active:nth-of-type(4n + 2) {
  background-color: var(--red);
  border-color: var(--red);
}
.has_backgroundcolor .filter .tags li.active:nth-of-type(4n + 3) {
  background-color: var(--petrol);
  border-color: var(--petrol);
}
.has_backgroundcolor .filter .tags li.active:nth-of-type(4n + 4) {
  background-color: var(--green);
  border-color: var(--green);
}
.has_backgroundcolor .filter .tags li.active:nth-of-type(4n + 5) {
  background-color: var(--blue);
  border-color: var(--blue);
}
.has_backgroundcolor .filter .tags li.active:not(:first-child) a {
  color: #fff;
}

/* Blue heroes with images: the headline starts level with the first image (the theme adds
   5rem above the text only, which pushed it below the image top) */
@media (min-width: 768px) {
  section.hero__has-background-color:has(.module__images) .module__text {
    padding-top: 0;
  }
}

/* Research projects filter: All and the research scenarios (R…) in the first row, the methods
   (M…) in a second row. The empty ::before takes a full row width between them. */
.archive.research-project .filter .tags::before {
  content: "";
  order: 1;
  flex-basis: 100%;
  height: 0;
}
.archive.research-project .filter .tags li[data-slug^="m"] {
  order: 2;
}

/* Publication list: 5px less between the rows of a card (tags, title, authors, venue, links) */
.card.publication .card__header .tags {
  padding-bottom: 11px;
}
.card.publication .author .tags {
  padding-top: 3px;
}
.card.publication .small {
  padding-top: 11px;
}
.card.publication .card__footer .tags {
  padding-top: 11px;
}

/* Logos module: partner logos side by side, 5 per row (3 on tablets, 2 on phones), more rows
   below when there are more. Every logo is fitted into the same box, so wide and square logos
   look about the same size. */
section.logos {
  padding: 3rem 0;
}
.logos__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2rem 2.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  align-items: center;
}
.logos__item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 7rem;
}
.logos__item a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.logos__item img {
  max-width: min(100%, 18rem);
  max-height: 7.5rem;
  width: auto;
  height: auto;
  object-fit: contain;
}
@media (max-width: 991px) {
  .logos__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 575px) {
  .logos__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
  }
}

/* Hero setting "image_size" (style: single): the photo takes a share of its column (small = 2/3,
   or a percentage) instead of the whole column up to the window edge, and sits on the side facing
   the text. The build sets the share as --hero-image-size. */
section.hero__image-sized .images.bleed img {
  right: 0;
  width: var(--hero-image-size) !important;
  max-width: var(--hero-image-size) !important;
  display: block;
}
section.hero__image-sized.hero__align-text-right .images.bleed img {
  margin-left: auto;
}
@media (max-width: 767px) {
  section.hero__image-sized .images.bleed img {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ---------------------------------------------------------------------------------------------
   Phones and tablets (tested in tests/mobile/layout.spec.ts)
   --------------------------------------------------------------------------------------------- */

/* Long words and URLs (DOIs, links) wrap instead of running off the screen */
main :is(p, li, td, dd, a, .small) {
  overflow-wrap: anywhere;
}

/* Publication filter tags stay whole boxes when they wrap onto a second line */
.archive.publication aside.filter .tags a {
  display: inline-block;
}

/* The fold-out button of the publication filter only exists on phones */
.filter__toggle {
  display: none;
}

@media (max-width: 767px) {
  /* A smaller type scale: the theme keeps 40px section headings and 28–36px titles on phones */
  :root {
    --font-size-xm: 24px;
    --font-size-lg: 22px;
    --font-size-xl: 30px;
    --font-size-xxl: 40px;
    --font-size-intro: 18px;
    --font-size-text-lg: 1.125rem;
  }
  h1,
  header.header.not-frontpage h1 {
    font-size: 26px;
  }
  .header.frontpage h1 {
    font-size: var(--font-size-xl);
  }

  /* Modules inside a page's article (research projects, …) don't add a second container margin */
  main article > section.container,
  main .flexible_content > section.container {
    padding-left: 0;
    padding-right: 0;
  }

  /* Titles in the publication list, and accordion headings, one step smaller */
  .card.publication hgroup.title h2 {
    font-size: 20px;
  }
  .accordion .title > * {
    font-size: var(--font-size-lg);
  }

  /* Footer links: large enough to tap */
  footer a {
    display: inline-block;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }

  /* Publication filter: one column, folded behind a button until opened */
  .archive.publication aside.filter {
    columns: auto;
    margin-top: 0;
    margin-bottom: 1.5rem;
  }
  .archive.publication aside.filter > h2 {
    display: none;
  }
  .filter__toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--primary);
    border-radius: 0;
    background: #fff;
    color: var(--primary);
    font: inherit;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
  }
  .filter__toggle::after {
    content: "▾";
  }
  .filter__toggle[aria-expanded="true"]::after {
    content: "▴";
  }
  .filter--collapsed .filter__panel {
    display: none;
  }
  .archive.publication aside.filter .filter__panel {
    padding-top: 1rem;
  }
  .archive.publication aside.filter .site-search input {
    width: 100%;
  }
  .archive.publication aside.filter .tags a {
    padding: 0.25rem 0.5rem;
  }
}

/* Team page: one section per team category (database.yaml), alumni as a short list */
.team-section + .team-section {
  margin-top: 3rem;
}
.team-section__title {
  margin-bottom: 1rem;
}
.team-alumni {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.team-alumni__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--yellow);
  background: #f4f4f4;
}
.team-alumni__item .name {
  font-weight: 700;
}
.team-alumni__item .now {
  font-style: italic;
}
@media (max-width: 991px) {
  .team-alumni {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 575px) {
  .team-alumni {
    grid-template-columns: 1fr;
  }
}

/* Alumni names in author lists are highlighted like team members, but are not links */
.bibtex-authors li.has_link:has(> .alumni-name):hover {
  background-color: var(--yellow);
}

/* Headings written in a text module's markdown (## / ###): the theme only styles the module's
   own headline, so these looked like body text */
.block__text .hero__content h2 {
  font-size: var(--font-size-intro);
  font-weight: 500;
  line-height: 1.25;
  margin: 2rem 0 0.75rem;
}
.block__text .hero__content h3 {
  font-size: var(--font-size-text);
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}

/* Figures in text stay inside the text column (some have a fixed width in their markup) */
.block__text figure {
  max-width: 100%;
  margin: 1.5rem 0;
}
.block__text figure img {
  max-width: 100%;
  height: auto;
}

/* Link tags on data cards wrap as whole tags onto a new line (the theme keeps them on one line,
   squeezing long tags until their words break) */
.archive.data .card .tags {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}
/* Tags aren't squeezed; only a tag wider than the card breaks inside, so it can't widen the card
   (a long link title on a research project card stretched its image) */
.cards .card .tags li {
  flex-shrink: 0;
  max-width: 100%;
}

/* News posts and research projects: the image to the right of the title, reaching below the
   header, as on data pages (see DOCS.md: show_image) */
.single header.header.has-featured-image,
.single header.header.has-featured-image .animated-header-container {
  overflow: visible !important;
}
.single header.header.has-featured-image {
  padding: 0;
}
.single header.header.has-featured-image #go_back {
  padding-top: 2rem;
}
.single header.header.has-featured-image .group__headline {
  padding: 1rem 0 2rem;
}
.single header.header.has-featured-image .header__featured_image {
  height: calc(100% + 3rem);
  margin-right: var(--data-image-right);
}
.single header.header.has-featured-image .header__featured_image img {
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  position: relative;
  z-index: 10;
}
.single:has(header.header.has-featured-image) main aside {
  padding-top: 3rem;
}
@media (max-width: 767px) {
  .single header.header.has-featured-image .header__featured_image {
    height: 300px;
    margin-right: 0;
  }
  .single:has(header.header.has-featured-image) main aside {
    padding-top: 0;
  }
}
