/* Keep the contact form inside its grid, including long translated options. */
#contact > .grid {
  grid-template-columns: minmax(0, 1fr);
}

#contact .grid > *,
#contact form,
#contact label {
  min-width: 0;
}

#contact label {
  grid-template-columns: minmax(0, 1fr);
}

#contact input,
#contact select,
#contact textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

#contact .flex,
#contact p {
  overflow-wrap: anywhere;
}

#contact .flex > svg {
  flex-shrink: 0;
}

#contact select,
select[data-certit-lang] {
  appearance: auto;
  min-height: 44px;
}

/* These targets remain visible below the sticky header after anchor navigation. */
main section[id],
#certit-main-content {
  scroll-margin-top: 7rem;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #0369a1;
  outline-offset: 3px;
}

.certit-skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10000;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: #fff;
  background: #075985;
  font-weight: 700;
  transform: translateY(-180%);
}

.certit-skip-link:focus {
  transform: translateY(0);
}

@media (min-width: 1024px) {
  #contact > .grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
}

@media (max-width: 639px) {
  #contact form {
    padding: 1.25rem;
  }

  /* A readable font also prevents focus zoom on iOS form controls. */
  #contact input,
  #contact select,
  #contact textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Header contact actions: Telegram, Instagram, then Facebook. */
main > header [data-certit-header-social] {
  flex-shrink: 0;
  gap: 0.5rem;
}

main > header [data-certit-header-social] > a {
  min-height: 44px;
  padding-inline: 1rem;
  white-space: nowrap;
}

main > header a.certit-instagram-link {
  background-image: linear-gradient(to right, #a21caf, #be185d);
  box-shadow: 0 6px 16px rgb(162 28 175 / 15%);
}

main > header a.certit-instagram-link:hover {
  background-image: linear-gradient(to right, #86198f, #9d174d);
}

/* Keep all three actions visible on phones; language selection stays in the menu. */
@media (max-width: 1023px) {
  main > header [data-certit-header-row] {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  main > header [data-certit-header-social] {
    display: flex;
    flex-basis: 100%;
    justify-content: flex-end;
    order: 3;
  }

  main > header [data-certit-header-social] > select {
    display: none;
  }

  main section[id],
  #certit-main-content {
    scroll-margin-top: 10rem;
  }
}

/* Give navigation its own row so translated labels do not crowd three social links. */
@media (min-width: 1024px) {
  main > header [data-certit-header-row] {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  main > header [data-certit-header-row] > nav {
    flex-basis: 100%;
    justify-content: center;
    order: 3;
  }

  main section[id],
  #certit-main-content {
    scroll-margin-top: 8.5rem;
  }
}

main > header a.certit-facebook-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: #0866c6;
  box-shadow: 0 6px 16px rgb(8 102 198 / 15%);
}

main > header a.certit-facebook-link:hover {
  background: #0755a5;
}

main > header a.certit-facebook-link > svg {
  flex: 0 0 auto;
}

/* Three labelled links fit within the 288px content width of a 320px phone. */
@media (max-width: 639px) {
  main > header [data-certit-header-social] {
    min-width: 0;
    max-width: 100%;
    gap: 0.375rem;
  }

  main > header [data-certit-header-social] > a {
    padding-inline: 0.5rem;
    font-size: 0.8125rem;
  }

  main > header a.certit-facebook-link > svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 319px) {
  main > header [data-certit-header-social] {
    flex-wrap: wrap;
  }
}
/* Keep the Constitution announcement copy above the book on narrow phones. */
@media (min-width: 421px) and (max-width: 1023px) {
  .certit-announcement-card:has(img[src*="20261023_constitution_20_oz.png"]) {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }
  .certit-announcement-media.is-overlay:has(> img[src*="20261023_constitution_20_oz.png"]) {
    min-height: 690px;
  }
}
@media (max-width: 420px) {
  .certit-announcement-media.is-overlay:has(> img[src*="20261023_constitution_20_oz.png"]) {
    min-height: 690px;
  }
}
@media (max-width: 360px) {
  .certit-announcement-media.is-overlay:has(> img[src*="20261023_constitution_20_oz.png"]) {
    min-height: 780px;
  }
}
