/* 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: 40px; }
#quicksearchInput::placeholder { text-align: center; text-indent: 0; font-size: clamp(11px, 3.2vw, 12px) !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;
}

/* Use one visible height for the page and hero in mobile embedded browsers. */
@media (max-width: 768px) {
  html, body {
    height: var(--home-viewport-height, 100dvh);
    min-height: var(--home-viewport-height, 100dvh);
  }
  .fixed-bg {
    height: var(--home-viewport-height, 100dvh);
    min-height: var(--home-viewport-height, 100dvh);
  }
  #openFavorites, #openHaveGone, #locationBtn, #compassBtn,
  #contributorsBtn, #toggleTop10, #toggleEventsBtn, #sosBtn,
  #weather, #datetime, #copyright, .fb-float {
    translate: 0 var(--home-footer-shift, 0px);
  }
}

/* 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;
  }
}

/* Narrow mobile search boxes; preserve their height and page scrolling. */
@media (max-width: 768px) {
  .quicksearch-container { width: min(340px, calc(100vw - 112px)); max-width: 340px; }
  #quicksearchInput { padding-inline: 24px; }
  #quicksearchInput::placeholder { font-size: clamp(12px, 3.4vw, 14px) !important; }
  .quicksearch-container .quicksearch-button { right: 4px; font-size: 15px; }
  body #searchSelector { width: min(260px, calc(100vw - 148px)); max-width: calc(100vw - 148px); padding-inline: 6px; gap: 4px; }
  body #searchSelector > #nearby-description { flex: 1 1 0; min-width: 0; white-space: normal; font-size: 11px; }
  body #searchSelector > button { width: 28px; flex-basis: 28px; }
  .searchbox, .container:has(#address) { width: min(280px, calc(100vw - 132px)); margin-inline: auto; }
  .searchbox .input-with-button, .container:has(#address) .input-with-button { width: 100%; }
  #searchInput, #address { width: 100%; }
}

/* Readable, centered text within the narrow homepage searches. */
#quicksearchInput, #searchInput, #address { text-align: center !important; font-size: 15px; }
#quicksearchInput::placeholder, #searchInput::placeholder, #address::placeholder { text-align: center; text-indent: 0; }
@media (max-width: 768px) {
  #quicksearchInput, #searchInput, #address { font-size: 14px; padding-inline: 24px; }
  #searchInput::placeholder, #address::placeholder { font-size: 13px; }
  body #searchSelector > #nearby-description { text-align: center; font-size: 14px; }
}

/* Fit the complete quicksearch hint and keep nearby actions circular. */
#quicksearchInput::placeholder { font-size: var(--quicksearch-hint-size, 12px) !important; }
body #searchSelector > :is(#blink-btn, #keyboard-btn) {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  flex: 0 0 30px;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
}

@media (min-width: 769px) { body #searchSelector { width: 260px; } }

/* Larger primary search text on desktop. */
@media (min-width: 769px) {
  #quicksearchInput { font-size: 18px; padding-inline: 20px 36px; }
  #quicksearchInput::placeholder { font-size: 14px !important; }
}
/* Keep nearby results centered even when their input container is narrower. */
#resultsList, #results {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  margin-inline: 0;
}
/* Fit text inside the original control dimensions. */
#address::placeholder { font-size: var(--address-hint-size, 13px); }
body #searchSelector > #nearby-description { font-size: var(--nearby-label-size, 14px); }
/* Keep the nearby label on one line within its existing box. */
body #searchSelector > #nearby-description { white-space: nowrap; }
/* Reserve breathing room between the label and the location actions. */
body #searchSelector > #nearby-description { margin-inline-end: 8px; }
/* Shift only the two search hints slightly left inside their fields. */
#quicksearchInput::placeholder, #address::placeholder { text-indent: -8px; }
/* Keep the initial letter clear of the input's clipping edge. */
#quicksearchInput::placeholder { text-indent: -4px; }
/* Keep the manual-location hint's first letter clear of the clipping edge. */
#address::placeholder { text-indent: -4px; }
/* Extra space before nearby actions on the narrowest phones. */
@media (max-width: 360px) {
  body #searchSelector > #nearby-description { margin-inline-end: 12px; }
}
/* Keep the colon visibly separated from the pin on small phones. */
@media (max-width: 430px) {
  body #searchSelector > #nearby-description { margin-inline-end: 18px; }
}
/* Desktop manual-location hint: fit the full text clear of the search icon. */
@media (min-width: 769px) {
  #address::placeholder { font-size: var(--address-hint-size, 11px) !important; }
}
/* Fine adjustments for the 360px phone layout, preserving control dimensions. */
@media (min-width: 350px) and (max-width: 374px) {
  body #searchSelector > #nearby-description { translate: 2px 0; }
}

/* Keep text clear of search icons without changing the input dimensions. */
@media (max-width: 768px) {
  #quicksearchInput { padding-inline: 12px 36px; }
  #address { padding-inline: 14px 34px; }
}
/* Use the available text space more efficiently on very narrow phones. */
@media (max-width: 320px) {
  #quicksearchInput { padding-inline: 6px 26px; }
  #address { padding-inline: 6px 30px; }
  #quicksearchInput::placeholder, #address::placeholder {
    letter-spacing: -.3px;
    text-indent: 0;
  }
  body #searchSelector > #nearby-description { letter-spacing: -.25px; }
}
/* Larger nearby label only on the smallest phone layout. */
@media (max-width: 320px) {
  body #searchSelector > #nearby-description {
    font-size: max(9px, var(--nearby-label-size, 9px));
  }
}
/* The nearby search control now shows only its two action icons. */
body #searchSelector > #nearby-description { display: none; }
/* Size the nearby control to its two remaining icons on every screen. */
body #searchSelector {
  width: fit-content;
  max-width: calc(100vw - 24px);
}
/* Transparent action wrapper with the existing light and dark greens reversed. */
body #searchSelector {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body #searchSelector > :is(#blink-btn, #keyboard-btn),
body #searchSelector > :is(#blink-btn, #keyboard-btn):hover {
  background: #f6f8f2f5;
  color: #28624b;
}
/* Larger location and keyboard actions with matching inner symbols. */
body #searchSelector > :is(#blink-btn, #keyboard-btn) {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  flex-basis: 38px;
}
body #searchSelector > :is(#blink-btn, #keyboard-btn) svg {
  width: 25px;
  height: 25px;
}
/* Nudge the destination hint just 2px right for visual balance. */
#quicksearchInput::placeholder { text-indent: -2px; }
@media (max-width: 320px) {
  #quicksearchInput::placeholder { text-indent: 2px; }
}
/* Move the destination hint another 2px right. */
#quicksearchInput::placeholder { text-indent: 0; }
@media (max-width: 320px) {
  #quicksearchInput::placeholder { text-indent: 4px; }
}
/* Let the destination count panel hug its text with the existing side padding. */
#home-destinations-title {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
}
