/* Give the primary quick search a little more visual prominence. */
.quicksearch-container { width: min(340px, calc(100vw - 24px)); max-width: 340px; margin-inline: auto; }
.quicksearch-container .quicksearch-wrapper { width: 100%; max-width: none; }
#quicksearchInput { width: 100%; height: 60px; font-size: 15px; padding-inline: min(30px, 8vw); }
#quicksearchInput::placeholder { text-align: center; text-indent: -8px; font-size: min(14.9px, calc((100vw - 24px) / 22.8)) !important; }
.quicksearch-container .quicksearch-button { padding-inline: 4px; right: 8px; }
#toggleTop10 { font-family: "Open Sans", Arial, sans-serif; }

#home-form-feedback {
  position: fixed;
  z-index: 20000;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: 480px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 18px 44px 18px 18px;
  border: 1px solid #80bd96;
  border-radius: 12px;
  background: linear-gradient(125deg, #fff0b3, #c9f2d5 65%, #bdeee8);
  box-shadow: 0 6px 24px #0003;
}
#home-form-feedback[hidden] { display: none; }
#home-form-feedback p {
  margin: 0;
  font: 600 15px/1.5 Arial, sans-serif;
  color: #213e32;
  text-align: center;
  text-shadow: none;
  overflow-wrap: anywhere;
}
#home-form-feedback button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #213e32;
  font: 24px/1 Arial, sans-serif;
  cursor: pointer;
}
/* The homepage stays within the viewport; panels keep their own scrolling. */
@media (min-width: 769px) {
  #popular-list, #contributorsBox {
    top: max(calc(12vh + 12px), 106px);
    max-height: min(60dvh, calc(100dvh - max(calc(12vh + 12px), 106px) - 150px));
  }
}
@media (min-width: 1401px) {
  #popular-list, #contributorsBox {
    top: max(calc(12vh + 12px), 123px);
    max-height: min(60dvh, calc(100dvh - max(calc(12vh + 12px), 123px) - 150px));
  }
}
html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* Normal-size footer labels; compact sizing applies only to narrow phones. */
footer p:has(#toggle-form-btn),
footer p:has(.advertising-toggle) {
  font: 400 12px/1.35 'Segoe UI', Arial, sans-serif;
}
footer #toggle-form-btn svg, footer .advertising-toggle svg { width: 18px; height: 18px; }

/* Compact homepage controls on narrow phones, including iPhone Safari. */
@media (max-width: 430px) {
  html { -webkit-text-size-adjust: 100%; }
  footer {
    box-sizing: border-box;
    width: calc(100% - 112px);
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
  }
  footer p:has(#toggle-form-btn),
  footer p:has(.advertising-toggle) {
    width: fit-content;
    max-width: 100%;
    margin: 5px auto !important;
    font: 400 11px/1.35 'Segoe UI', Arial, sans-serif !important;
  }
  footer p:has(#toggle-form-btn) > span,
  footer p:has(.advertising-toggle) > span {
    display: inline-flex !important;
    box-sizing: border-box;
    max-width: 100%;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 2px 6px !important;
    border-radius: 10px !important;
  }
  footer #toggle-form-btn,
  footer .advertising-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    min-height: 24px;
  }
  footer #toggle-form-btn svg,
  footer .advertising-toggle svg { width: 18px; height: 18px; }
  #openFavorites, #openHaveGone, #locationBtn, #compassBtn {
    top: auto;
    right: 3px;
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 17px;
    transform: none;
  }
  #openFavorites { bottom: 132px; }
  #openHaveGone { bottom: 98px; }
  #locationBtn { bottom: 64px; }
  #compassBtn { bottom: 30px; }
  #contributorsBtn, #toggleTop10 {
    width: 52px;
    box-sizing: border-box;
    padding: 3px;
    font-size: 8px;
    line-height: 1.25;
  }
  #toggleTop10 { top: calc(84% + 42px); bottom: auto; }
  #toggleEventsBtn { font-size: 12px; padding: 5px 7px; }
  #datetime, #weather, #copyright { font-size: 9px; line-height: 1.35; }
}
/* One spacing rule for both stacks, independent of viewport height. */
:root { --home-control-size: 40px; --home-ranking-height: 40px; --home-control-gap: 8px; }
@media (max-width: 600px) {
  :root { --home-control-size: 32px; --home-ranking-height: 30px; }
}
@media (max-width: 430px) {
  :root { --home-control-size: 26px; --home-ranking-height: 28px; }
}
#openFavorites, #openHaveGone, #locationBtn, #compassBtn,
#contributorsBtn, #toggleTop10 {
  box-sizing: border-box;
  transition: background-color .2s, box-shadow .2s;
  top: auto;
  margin: 0;
  transform: none;
}
#openFavorites, #openHaveGone, #locationBtn, #compassBtn {
  right: 4px;
  width: var(--home-control-size);
  height: var(--home-control-size);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 768px) {
#copyright {
  box-sizing: border-box;
  left: auto;
  right: calc(32px + (var(--home-control-size) - 20px) / 2);
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  transform: none;
  text-align: right;
  max-width: calc(100vw - 48px - (var(--home-control-size) - 20px) / 2);
  overflow-wrap: anywhere;
}
.fb-float { position: fixed; left: auto; right: calc(4px + (var(--home-control-size) - 20px) / 2); top: auto; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: 20px; height: 20px; margin: 0; transform: none; transition: none; }
.fb-float img { display: block; }
}
#compassBtn { bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
#locationBtn { bottom: calc(32px + env(safe-area-inset-bottom, 0px) + var(--home-control-size) + var(--home-control-gap)); }
#openHaveGone { bottom: calc(32px + env(safe-area-inset-bottom, 0px) + 2 * (var(--home-control-size) + var(--home-control-gap))); }
#openFavorites { bottom: calc(32px + env(safe-area-inset-bottom, 0px) + 3 * (var(--home-control-size) + var(--home-control-gap))); }
#contributorsBtn, #toggleTop10 { left: 4px; height: var(--home-ranking-height); }
#contributorsBtn {
  display: block;
  align-content: center;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  height: auto;
  min-height: var(--home-ranking-height);
}
#contributorsBtn br { display: initial; }
#contributorsBtn, #toggleTop10 {
  width: 70px;
  height: 28px;
  min-height: 28px;
  padding: 2px;
  display: block;
  align-content: center;
  text-align: center;
  white-space: normal;
  overflow-wrap: normal;
  font: 700 10px/1.2 "Open Sans", Arial, sans-serif;
}
@media (max-width: 600px) {
  #contributorsBtn, #toggleTop10 { width: 58px; height: 24px; min-height: 24px; font-size: 8px; }
}
#toggleTop10 { bottom: calc(44px + env(safe-area-inset-bottom, 0px)); }
#contributorsBtn { bottom: calc(44px + env(safe-area-inset-bottom, 0px) + var(--home-ranking-height) + var(--home-control-gap)); }
#sosBtn {
  transition: none;
  top: auto;
  bottom: calc(44px + env(safe-area-inset-bottom, 0px) + 2 * (var(--home-ranking-height) + var(--home-control-gap)));
  height: var(--home-control-size);
  margin: 0;
  transform: none;
}
/* These controls belong to the mobile layout only. */
@media (max-width: 599px) {
  #openFavorites, #openHaveGone, #locationBtn, #compassBtn { display: flex !important; }
}
@media (min-width: 600px) {
  #openFavorites, #openHaveGone, #locationBtn, #compassBtn { display: none !important; }
}
#openFavorites:hover, #openHaveGone:hover, #locationBtn:hover, #compassBtn:hover,
#contributorsBtn:hover, #toggleTop10:hover, .fb-float:hover img { transform: none; }

/* Desktop events can extend the page just enough to show every card. */
@media (min-width: 769px) {
  html:has(body.events-open) {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto;
  }
  body.events-open {
    height: auto;
    min-height: 100dvh;
    overflow: visible !important;
  }
  body.events-open #next-events {
    box-sizing: border-box;
    margin-bottom: 24px;
    flex-shrink: 0;
  }
  body.events-open .event-card {
    flex: 0 0 160px;
    overflow-wrap: anywhere;
  }
}
