/* mbgroup.bio landing page. One typeface, a few neutral tokens, no build step. */

:root {
  --paper: #ffffff;
  --ink: #1f2328;
  --muted: #59636e;
  --line: #c8d0d8;
  --hover: #f3f5f7;
  --primary-hover: #3a414a;
  --focus: #0b5cad;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15181c;
    --ink: #e8eaed;
    --muted: #9aa3ad;
    --line: #3b424a;
    --hover: #1f2429;
    --primary-hover: #c9ced4;
    --focus: #7fb2f0;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1.125rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: clamp(4.5rem, 22vh, 12rem) 1.5rem 4rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 1.4rem + 3.4vw, 3.5rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.field {
  margin: 0.9rem 0 0;
  font-size: 1.3125rem;
  font-style: italic;
  color: var(--muted);
  text-wrap: balance;
}

.affiliation {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

/* Button row */

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2.75rem 0 0;
  padding: 0;
  list-style: none;
}

.links > li > a,
.menu > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.05rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.links > li > a:hover,
.menu > summary:hover,
.menu[open] > summary {
  background: var(--hover);
  border-color: var(--muted);
}

/* The St. Jude lab page is the primary destination: the one filled button. */
.links > li > a.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.links > li > a.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.links a:focus-visible,
.menu > summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Services menu */

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

/* Chevron: points down when closed, up when open. */
.menu > summary::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.25px solid var(--muted);
  border-bottom: 1.25px solid var(--muted);
  transform: translateY(-0.12rem) rotate(45deg);
  transition: transform 200ms var(--ease-out);
}

.menu[open] > summary::after {
  transform: translateY(0.1rem) rotate(-135deg);
}

.menu-list {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  z-index: 10;
  width: max-content;
  min-width: 16rem;
  max-width: calc(100vw - 3rem);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.menu[open] .menu-list {
  animation: menu-open 220ms var(--ease-out) both;
}

.menu-list li {
  position: relative;
}

/* Inset rules between services; they draw in from the left when the menu opens. */
.menu-list li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 1rem;
  height: 1px;
  background: var(--line);
  transform-origin: left center;
}

.menu[open] .menu-list li + li::before {
  animation: rule-draw 360ms var(--ease-out) both;
}

.menu[open] .menu-list li:nth-child(2)::before { animation-delay: 70ms; }
.menu[open] .menu-list li:nth-child(3)::before { animation-delay: 130ms; }
.menu[open] .menu-list li:nth-child(4)::before { animation-delay: 190ms; }

.menu-list a {
  display: block;
  padding: 0.7rem 1rem 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

.menu-list a:hover {
  background: var(--hover);
}

.menu-list a:focus-visible {
  outline-offset: -2px;
}

.menu-list .name {
  display: block;
  font-size: 1rem;
  line-height: 1.3;
}

.menu-list .note {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--muted);
}

@keyframes menu-open {
  from {
    opacity: 0;
    transform: translateY(-0.4rem);
  }
}

@keyframes rule-draw {
  from {
    transform: scaleX(0);
  }
}

/* Mid widths: align the menu to the right edge of Services so it stays inside the window. */
@media (max-width: 46rem) {
  .menu-list {
    left: auto;
    right: 0;
  }
}

/* Narrow screens (below where the four buttons fit on one row): stack them and open the menu in place. */
@media (max-width: 41rem) {
  .links {
    flex-direction: column;
  }

  .menu > summary {
    justify-content: space-between;
  }

  .menu-list {
    position: static;
    width: auto;
    margin-top: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .links > li > a,
  .menu > summary,
  .menu > summary::after {
    transition: none;
  }

  .menu[open] .menu-list,
  .menu[open] .menu-list li + li::before {
    animation: none;
  }
}
