@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/instrument-sans.woff2) format("woff2");
}

:root {
  --band: #2e1a4d;
  --band-line: #5b3d8a;
  --band-sub: #d8cde8;
  --accent: #46296f;
  --link: #4f2f7e;
  --link-hover: #331c57;
  --tint: #f5f2f9;
  --page: #f8f6fb;
  --rule: #e6e1ed;
  --muted: #5f5a68;
}

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

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

body {
  margin: 0;
  background: var(--page);
  color: #221f28;
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
}

a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 3;
  padding: 0.5rem 0.75rem;
  background: #fff;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.container {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */

.site-header {
  position: relative;
  overflow: hidden;
  padding: clamp(3.5rem, 8vw, 6rem) 0;
  background: var(--band);
  color: #fff;
}

.site-header .container {
  position: relative;
}

.hero-art {
  position: absolute;
  top: 50%;
  right: -9rem;
  width: 40rem;
  max-width: none;
  height: auto;
  transform: translateY(-50%);
}

.site-header h1 {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.site-header p {
  max-width: 30rem;
  margin: 1.25rem 0 0;
  color: var(--band-sub);
  font-size: 1.125rem;
}

.site-header a {
  color: #fff;
  text-decoration: underline;
}

.site-header a:hover {
  color: #fff;
}

.totals {
  display: flex;
  gap: 2.5rem;
  width: fit-content;
  margin: 2.25rem 0 0;
  padding-top: 1.125rem;
  border-top: 1px solid var(--band-line);
}

.totals div {
  display: flex;
  flex-direction: column-reverse;
}

.totals dt {
  color: var(--band-sub);
  font-size: 0.8125rem;
}

.totals dd {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* Ingredient bar */

.index {
  padding: 0.625rem 0;
  background: #fff;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
  font-weight: 500;
}

.index ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.25rem;
  margin: 0 -0.625rem;
  padding: 0;
  list-style: none;
}

.index a {
  display: block;
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
}

.index a:hover {
  background: var(--tint);
}

/* Ingredient cards */

main.container {
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}

.ingredient {
  margin-bottom: 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  scroll-margin-top: 1rem;
}

.ingredient:last-child {
  margin-bottom: 0;
}

.ingredient:target {
  border-color: var(--band-line);
}

.ingredient-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.875rem;
  align-items: baseline;
  padding: 1.125rem 7rem 1.125rem 1.5rem;
  background: var(--tint) url(card-art.svg) no-repeat right -2.5rem center / 14rem;
}

.ingredient h2 {
  margin: 0;
  color: var(--accent);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.count {
  flex: none;
  color: var(--muted);
  font-size: 0.8125rem;
}

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

.sources li {
  border-top: 1px solid var(--rule);
}

.sources a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 1rem;
  align-items: center;
  height: 100%;
  padding: 0.75rem 1.5rem;
  overflow-wrap: anywhere;
  transition: background-color 0.15s ease;
}

.sources a:hover {
  background: var(--tint);
}

.source-name {
  grid-column: 1;
  font-weight: 600;
}

.source-id {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.875rem;
}

.arrow {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 1rem;
  height: 1rem;
  color: #a79fb5;
  transition: color 0.15s ease, transform 0.15s ease;
}

.sources a:hover .arrow {
  color: var(--link);
  transform: translate(2px, -2px);
}

/* Footer */

.site-footer {
  padding: 1.5rem 0 2rem;
  background: #fff;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0;
}

/* Wide screens: ingredient bar stays visible, sources sit in two columns. */
@media (min-width: 48rem) {
  .index {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .ingredient {
    scroll-margin-top: 5.5rem;
  }

  .sources {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sources li:nth-child(even) {
    border-left: 1px solid var(--rule);
  }

  /* An odd last link takes the full row, so no half-empty row is left behind. */
  .sources li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 40rem) {
  .hero-art {
    top: -4rem;
    right: -11rem;
    width: 26rem;
    transform: none;
    opacity: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .sources a,
  .arrow {
    transition: none;
  }
}
