/* v0.3.8 — keep the current submenu page readable in GeneratePress. */
.main-navigation .main-nav ul ul li.current-menu-item > a,
.main-navigation .main-nav ul ul li.current_page_item > a,
.main-navigation .main-nav ul ul li.current-menu-item > a:hover,
.main-navigation .main-nav ul ul li.current_page_item > a:hover,
.main-navigation .main-nav ul ul li.current-menu-item > a:focus,
.main-navigation .main-nav ul ul li.current_page_item > a:focus {
  color: #ffffff !important;
}

/*
 * Give the complete desktop header enough real width for both languages.
 * Keep every normal menu label on one line and preserve the flag group at the
 * end instead of asking GeneratePress to shrink or clip individual items.
 */
@media (min-width: 769px) {
  .site-header .inside-header {
    width: calc(100% - 32px);
    max-width: 1240px;
    box-sizing: border-box;
    overflow: visible;
  }

  .main-navigation,
  .main-navigation .main-nav {
    min-width: 0;
    overflow: visible;
  }

  .main-navigation .main-nav > ul {
    display: flex;
    width: max-content;
    max-width: none;
    flex-wrap: nowrap;
    align-items: center;
  }

  .main-navigation .main-nav > ul > li {
    flex: 0 0 auto;
  }

  .main-navigation .main-nav > ul > li:not(.ctst-language-switch) > a {
    padding-right: 14px;
    padding-left: 14px;
    white-space: nowrap;
  }

  /*
   * Give long English and Spanish desktop submenu titles room to breathe.
   * Mobile keeps GeneratePress's native full-width menu behaviour.
   */
  .main-navigation .main-nav ul ul {
    width: 360px;
    max-width: calc(100vw - 32px);
  }

  .main-navigation .main-nav ul ul li > a {
    box-sizing: border-box;
    white-space: normal;
    line-height: 1.45;
    overflow-wrap: break-word;
  }
}

/* Two clear 30px language choices at the end of the primary menu. */
.main-navigation .main-nav > ul > li.ctst-language-switch {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  margin-left: 6px;
  white-space: nowrap;
}

.ctst-language-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.main-navigation .main-nav > ul > li.ctst-language-switch .ctst-language-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 44px;
  padding: 0;
  line-height: normal;
  background: transparent !important;
}

.ctst-language-option .ctst-language-icon {
  display: block;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  transition: transform 160ms ease, outline-color 160ms ease;
}

.ctst-language-option-current .ctst-language-icon {
  outline: 2px solid #127a82;
  outline-offset: 2px;
}

.ctst-language-option:hover .ctst-language-icon {
  transform: scale(1.06);
}

.ctst-language-option:focus-visible {
  outline: 3px solid #127a82;
  outline-offset: 1px;
}

@media (max-width: 768px) {
  .main-navigation.toggled .main-nav > ul > li.ctst-language-switch {
    display: flex;
    margin-left: 0;
    border-top: 0;
    box-shadow: none;
  }

  .main-navigation.toggled .ctst-language-switcher {
    gap: 6px;
    min-height: 58px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .main-navigation.toggled .main-nav > ul > li.ctst-language-switch .ctst-language-option {
    width: 44px;
    min-width: 44px;
    height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ctst-language-option .ctst-language-icon {
    transition: none;
  }

  .ctst-language-option:hover .ctst-language-icon {
    transform: none;
  }
}

/* Compact, transparent publication and Country Watch review dates. */
.ctst-guide-date-original,
.ctst-guide-date-reviewed {
  font-size: 0.84em;
  line-height: 1.45;
}

.ctst-guide-date-reviewed {
  color: #526b78;
}

/* Give the longer Spanish footer headings a little more breathing room. */
.ctst-spanish .footer-widgets .widget-title,
.ctst-spanish .site-footer .widget-title {
  line-height: 1.45;
  margin-bottom: 28px;
}

/* Centre the four footer widgets as one balanced group on wide screens. */
@media (min-width: 1200px) {
  .inside-footer-widgets {
    display: grid;
    width: calc(100% - 48px);
    max-width: 1450px;
    margin-right: auto;
    margin-left: auto;
    transform: translateX(-8px);
    grid-template-columns:
      minmax(220px, 280px)
      minmax(300px, 400px)
      minmax(280px, 330px)
      minmax(150px, 190px);
    column-gap: 48px;
    justify-content: center;
  }

  .inside-footer-widgets > div {
    width: auto !important;
    min-width: 0;
  }
}

/* Give both long Spanish guide headings a full line on very wide screens. */
@media (min-width: 1440px) {
  .ctst-spanish .inside-footer-widgets {
    grid-template-columns:
      minmax(220px, 250px)
      minmax(350px, 370px)
      minmax(410px, 430px)
      minmax(160px, 180px);
    column-gap: 40px;
  }

  .ctst-spanish .footer-widget-2 .widget-title,
  .ctst-spanish .footer-widget-3 .widget-title {
    white-space: nowrap;
  }
}

/* ChipTrace desktop sidebar search and related-article spacing. */
@media (min-width: 769px) {
  #right-sidebar .widget_search,
  #right-sidebar .wp-block-search,
  .widget-area .widget_search,
  .widget-area .wp-block-search {
    margin-bottom: 18px !important;
  }

  #right-sidebar .widget_ctst_related_articles,
  .widget-area .widget_ctst_related_articles,
  #right-sidebar [id*="ctst_related_articles"],
  .widget-area [id*="ctst_related_articles"] {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  #right-sidebar .widget_search .widget-title,
  #right-sidebar .wp-block-search__label,
  .widget-area .widget_search .widget-title,
  .widget-area .wp-block-search__label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  #right-sidebar .widget_search .search-form,
  #right-sidebar .wp-block-search__inside-wrapper,
  .widget-area .widget_search .search-form,
  .widget-area .wp-block-search__inside-wrapper {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 56px !important;
    gap: 10px !important;
    align-items: stretch !important;
    width: 100% !important;
    margin: 0 !important;
  }

  #right-sidebar .widget_search .search-form label,
  .widget-area .widget_search .search-form label {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  #right-sidebar .widget_search .search-field,
  #right-sidebar .widget_search input[type="search"],
  #right-sidebar .wp-block-search__input,
  .widget-area .widget_search .search-field,
  .widget-area .widget_search input[type="search"],
  .widget-area .wp-block-search__input {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 56px;
    box-sizing: border-box;
    margin: 0 !important;
  }

  #right-sidebar .widget_search .search-submit,
  #right-sidebar .widget_search button,
  #right-sidebar .wp-block-search__button,
  .widget-area .widget_search .search-submit,
  .widget-area .widget_search button,
  .widget-area .wp-block-search__button {
    width: 56px !important;
    min-width: 56px !important;
    max-width: 56px !important;
    min-height: 56px;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden;
    white-space: nowrap;
    text-indent: -9999px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 22px 22px !important;
  }

  #right-sidebar .widget_search .search-submit::before,
  #right-sidebar .widget_search button::before,
  #right-sidebar .wp-block-search__button::before,
  .widget-area .widget_search .search-submit::before,
  .widget-area .widget_search button::before,
  .widget-area .wp-block-search__button::before {
    content: none !important;
    display: none !important;
  }
}

/* Dynamic ChipTrace article grid. */
.ct-article-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 42px 30px;
  width: 100%;
  margin: 0;
}

.ct-article-card {
  min-width: 0;
  margin: 0;
}

.ct-article-image-link {
  display: block;
  overflow: hidden;
  border-radius: 22px;
  background: #f3f9fb;
  text-decoration: none;
}

.ct-article-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  transition: transform 180ms ease;
}

.ct-article-image-placeholder {
  background:
    linear-gradient(135deg, rgba(18, 122, 130, 0.08), rgba(18, 122, 130, 0.02)),
    #f3f9fb;
}

.ct-article-image-link:hover .ct-article-image,
.ct-article-image-link:focus-visible .ct-article-image {
  transform: scale(1.015);
}

.ct-article-content {
  padding: 0 4px;
}

.ct-article-title {
  margin: 0 0 10px;
  font-family: "Inter", Helvetica, Arial, sans-serif;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
}

/* Compact titles on the English and Spanish article-guide index pages. */
.ctst-article-grid-index .ct-article-title {
  font-size: 18px;
}

/* Keep excerpt starts aligned while allowing the complete titles to remain visible. */
@media (min-width: 681px) {
  .ctst-article-grid-index:not(.ctst-spanish) .ct-article-title {
    min-height: 3.9em;
  }

  .ctst-article-grid-index.ctst-spanish .ct-article-title {
    min-height: 5.2em;
  }
}

.ct-article-title a {
  color: #10232d;
  text-decoration: none;
}

.ct-article-title a:hover {
  color: #127a82;
}

.ct-article-excerpt {
  margin: 0;
  color: #42525e;
  font-size: 1.05rem;
  line-height: 1.55;
}

/* Give every guide-index excerpt the same five-line visual footprint. */
.ctst-article-grid-index .ct-article-excerpt {
  display: -webkit-box;
  height: 7.75em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
}

.ct-article-image-link:focus-visible,
.ct-article-title a:focus-visible {
  outline: 3px solid #127a82;
  outline-offset: 4px;
}

@media (max-width: 1024px) {
  .ct-article-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .ct-article-grid {
    grid-template-columns: 1fr;
    gap: 34px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .ct-article-image {
    transition: none;
  }

  .ct-article-image-link:hover .ct-article-image,
  .ct-article-image-link:focus-visible .ct-article-image {
    transform: none;
  }
}

/* v0.3.3 — place the single featured image below the title without duplicating it. */
.single-post .inside-article {
  display: flex;
  flex-direction: column;
}

.single-post .inside-article > .entry-header {
  order: 1;
}

.single-post .inside-article > .featured-image,
.single-post .inside-article > .post-image,
.single-post .inside-article > .page-header-image-single {
  order: 2;
  margin-top: 28px;
  margin-bottom: 28px;
}

.single-post .inside-article > .entry-content {
  order: 3;
}

.single-post .inside-article > .entry-meta,
.single-post .inside-article > footer.entry-meta {
  order: 4;
}

@media (max-width: 768px) {
  .single-post .inside-article > .featured-image,
  .single-post .inside-article > .post-image,
  .single-post .inside-article > .page-header-image-single {
    margin-top: 22px;
    margin-bottom: 24px;
  }
}
