/* WeHow homepage layout overrides.
   Loaded separately with a filemtime version so CDN/browser caches refresh
   whenever this file changes. */

/* Keep normal homepage content modules and the visual editor preview aligned. */
body.home #wrap > .modules-fullwidth > .container,
body.visual-editor.page-template-page-home #wrap > .wpcom-container > .modules-fullwidth > .container {
  width: 100%;
  max-width: clamp(1200px, 80%, 1800px);
  margin-left: auto;
  margin-right: auto;
  padding-left: 32px;
  padding-right: 32px;
  box-sizing: border-box;
}

/* Preset search links: intentionally independent of the theme search module. */
.wehow-hot-searches {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 7px 8px;
  margin: 0;
}

.wehow-hot-searches a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 26px;
  padding: 3px 7px;
  border: 0.5px solid #c1c1c1;
  border-radius: 0;
  color: var(--theme-black-color, #333);
  background: hsla(var(--theme-color-hsl), .05);
  box-shadow: 0 0 1px rgba(0, 0, 0, .1);
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

.wehow-hot-searches a:hover,
.wehow-hot-searches a:focus-visible,
.wehow-hot-searches a:active,
.wehow-hot-searches a.is-active,
.wehow-hot-searches a[aria-current="page"] {
  color: #fff;
  border-color: var(--theme-hover, #333);
  background: var(--theme-hover, #333);
  text-decoration: none;
}

/* Optional four-row markup keeps desktop spacing predictable while each row
   can still wrap safely if a label is replaced with longer text. */
.wehow-hot-searches__row {
  display: contents;
}

/* Allow the search input to shrink without covering the submit button. */
body.page-template-page-home #modules-17 .modules-search-from,
body.page-template-page-home #modules-17 .modules-search-post,
body.page-template-page-home #modules-17 .modules-search-input {
  min-width: 0;
}

body.page-template-page-home #modules-17 .modules-search-input {
  width: 0;
}

body.page-template-page-home #modules-17 .modules-search-button {
  flex: 0 0 auto;
}

/* Use the bottom of the topic thumbnails as the homepage visual baseline. */
body.page-template-page-home #modules-16 .topic-list-3 .topic-wrap > span {
  display: none;
}

/* Desktop: the compact keyword area fills the height set by the topic cards. */
@media (min-width: 1200px) {
  body.page-template-page-home #modules-15 > .row {
    align-items: stretch;
  }

  body.page-template-page-home #modules-15 > .row > .col-md-8 {
    display: flex;
    flex-direction: column;
  }

  body.page-template-page-home #modules-15 > .row > .col-md-8 > .modules-search {
    flex: 0 0 auto;
  }

  body.page-template-page-home #modules-15 > .row > .col-md-8 > .modules-html-code {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 0 !important;
    overflow: hidden;
  }

  body.page-template-page-home #modules-15 > .row > .col-md-8 > .modules-html-code .wehow-hot-searches {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    max-height: 100%;
    align-content: space-between;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  body.page-template-page-home #modules-15 .wehow-hot-searches--four-rows {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    align-content: normal;
    justify-content: space-between;
    gap: 4px;
  }

  body.page-template-page-home #modules-15 .wehow-hot-searches--four-rows .wehow-hot-searches__row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: 5px 8px;
    width: 100%;
  }

  body.page-template-page-home #modules-15 .wehow-hot-searches--four-rows .wehow-hot-searches__row:nth-child(4) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.page-template-page-home #modules-15 .wehow-hot-searches--four-rows a {
    width: 100%;
    min-width: 0;
  }
}

/* Tablet/mobile: keep the modules stacked and show every keyword in full. */
@media (max-width: 1199px) {
  body.page-template-page-home #modules-15 > .row > .col-md-8,
  body.page-template-page-home #modules-15 > .row > .col-md-16 {
    width: 100%;
  }

  body.page-template-page-home #modules-15 > .row > .col-md-8 {
    margin-bottom: 24px;
  }

  .wehow-hot-searches {
    margin-bottom: 24px;
    overflow: visible;
  }
}

@media (max-width: 768px) {
  body.home #wrap > .modules-fullwidth > .container,
  body.visual-editor.page-template-page-home #wrap > .wpcom-container > .modules-fullwidth > .container {
    padding-left: 15px;
    padding-right: 15px;
  }
}
