/* =========================================================
   Enxoval.pt "Casa" - layout
   Header, footer, page shell, archives, search, 404.
   Colour values live in tokens.css only.
   Some rules use !important only to beat the !important rules that are still in legacy.css
   (header background and border, grid row width and padding, footer background).
   Astra breakpoint: mobile header below 922px.
   ========================================================= */

:root {
  --hdr-pad: clamp(16px, 4.4vw, 56px);
}

/* =========================================================
   1. Header
   ========================================================= */
body.enx-v2 #masthead,
body.enx-v2 #masthead .main-header-bar {
  background: var(--white) !important;
  border-bottom: 1px solid var(--line) !important;
}

/* The row wrappers: full width bar, content padded like the mockup */
body.enx-v2 #masthead .ast-builder-grid-row-container,
body.enx-v2 #masthead .ast-container {
  max-width: 1440px !important;
  padding-left: var(--hdr-pad) !important;
  padding-right: var(--hdr-pad) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
body.enx-v2 #masthead .ast-builder-grid-row {
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 0;
}
body.enx-v2 #masthead .site-header-section {
  display: flex;
  align-items: center;
  min-height: 0;
}
body.enx-v2 #masthead .site-header-primary-section-left { gap: 40px; flex: 1 1 auto; }
body.enx-v2 #masthead .site-header-primary-section-right { gap: 10px; flex: 0 0 auto; }

/* Logo */
body.enx-v2 #masthead .site-branding,
body.enx-v2 #masthead .site-logo-img { display: flex; align-items: center; padding: 0; }
body.enx-v2 #masthead .custom-logo-link { display: flex; align-items: center; min-height: 44px; line-height: 0; }
body.enx-v2 #masthead img.custom-logo {
  display: block;
  height: 54px;
  width: auto;
  max-width: none;
  mix-blend-mode: multiply;
}

/* Header block padding (desktop) */
@media (min-width: 922px) {
  body.enx-v2 #masthead .ast-builder-grid-row-container { padding-top: 16px; padding-bottom: 16px; }
}

/* One row at every desktop width. Tools shrink first, so the menu never wraps. */
@media (min-width: 922px) {
  body.enx-v2 #masthead .main-header-menu { flex-wrap: nowrap; }
}

/* ---------- Primary menu (desktop) ---------- */
body.enx-v2 #masthead .main-header-menu {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
}
body.enx-v2 #masthead .main-header-menu > .menu-item > .menu-link {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 13px;
  font-family: var(--font-body);
  font-size: 0.9063rem;   /* 14.5px */
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: color 0.15s ease, background-color 0.15s ease;
}
body.enx-v2 #masthead .main-header-menu > .menu-item:hover > .menu-link,
body.enx-v2 #masthead .main-header-menu > .menu-item:focus-within > .menu-link,
body.enx-v2 #masthead .main-header-menu > .current-menu-item > .menu-link,
body.enx-v2 #masthead .main-header-menu > .current-menu-ancestor > .menu-link {
  color: var(--sage-deep);
  background: var(--sage-tint);
}
body.enx-v2 #masthead .dropdown-menu-toggle { display: inline-flex; align-items: center; margin: 0; padding: 0; }
body.enx-v2 #masthead .dropdown-menu-toggle .ast-arrow-svg { width: 10px; height: 10px; fill: currentColor; }

/* Narrow desktop. These rules follow the base menu rule, so they win. */
@media (min-width: 922px) and (max-width: 1360px) {
  :root { --hdr-pad: 28px; }
  body.enx-v2 #masthead .site-header-primary-section-left { gap: 8px; }
  body.enx-v2 #masthead .ast-builder-menu-1 { padding-left: 0; }
  body.enx-v2 #masthead .main-header-menu > .menu-item > .menu-link { padding: 0 8px; }
  body.enx-v2 #masthead .enx-search--pill { width: 150px; }
  body.enx-v2 #masthead .enx-list-pill { padding-left: 14px; padding-right: 14px; }
}
@media (min-width: 922px) and (max-width: 1180px) {
  :root { --hdr-pad: 16px; }
  body.enx-v2 #masthead .main-header-menu > .menu-item > .menu-link { padding: 0 6px; font-size: 0.8125rem; }
  body.enx-v2 #masthead .enx-search--pill { width: 44px; padding: 0; justify-content: center; }
  body.enx-v2 #masthead .enx-search--pill .enx-search__field { display: none; }
}
@media (min-width: 922px) and (max-width: 980px) {
  body.enx-v2 #masthead .main-header-menu > .menu-item > .menu-link { padding: 0 3px; }
  body.enx-v2 #masthead .enx-list-pill { padding-left: 10px; padding-right: 10px; }
}

/* Submenus */
body.enx-v2 #masthead .main-header-menu .sub-menu {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  padding: 8px;
  min-width: 300px;
}
body.enx-v2 #masthead .main-header-menu .sub-menu .menu-item { border: 0; }
body.enx-v2 #masthead .main-header-menu .sub-menu .menu-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
body.enx-v2 #masthead .main-header-menu .sub-menu .menu-link:hover,
body.enx-v2 #masthead .main-header-menu .sub-menu .menu-link:focus-visible {
  background: var(--sage-tint);
  color: var(--sage-deep);
}
@media (min-width: 922px) {
  body.enx-v2 #masthead .sub-menu .menu-link > .ast-icon { display: none; }
}

/* ---------- Header tools: search and list pill ---------- */
body.enx-v2 .enx-hdr-tools { display: flex; align-items: center; gap: 10px; }

body.enx-v2 .enx-search { margin: 0; display: flex; align-items: center; }
body.enx-v2 .enx-search__field { display: block; flex: 1 1 auto; margin: 0; min-width: 0; font-weight: 400; }
body.enx-v2 .enx-search--pill {
  width: 200px;
  height: 44px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
}
body.enx-v2 .enx-search--pill:focus-within { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-tint); }
body.enx-v2 .enx-search input[type="search"] {
  width: 100%;
  height: 42px;
  min-height: 0;
  padding: 0 14px 0 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 0.875rem;
  color: var(--ink);
  outline: none;
}
body.enx-v2 .enx-search input[type="search"]:focus { box-shadow: none; border: 0; }
body.enx-v2 .enx-search .enx-search__submit {
  order: -1;
  flex: 0 0 44px;
  width: 44px;
  height: 42px;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  color: var(--muted);
}
body.enx-v2 .enx-search .enx-search__submit:hover { background: transparent; color: var(--sage-deep); border: 0; }
body.enx-v2 .enx-search .enx-icon { width: 18px; height: 18px; }

body.enx-v2 .enx-list-pill {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 18px;
  background: var(--sage);
  color: var(--white);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}
body.enx-v2 .enx-list-pill:hover,
body.enx-v2 .enx-list-pill:focus-visible { background: var(--sage-deep); color: var(--white); }

/* Which variant shows where. Desktop header: pill form and list pill. Mobile header: search circle only. */
body.enx-v2 #ast-desktop-header .enx-search-m { display: none; }
body.enx-v2 #ast-mobile-header .enx-search--pill,
body.enx-v2 #ast-mobile-header .enx-list-pill { display: none; }

/* ---------- Mobile header ---------- */
@media (max-width: 921px) {
  body.enx-v2 #masthead .ast-builder-grid-row-container { padding-top: 8px; padding-bottom: 12px; }
  body.enx-v2 #masthead img.custom-logo { height: 42px; }
  body.enx-v2 #masthead .site-header-primary-section-right { gap: 8px; }
  body.enx-v2 #ast-mobile-header .enx-hdr-tools { gap: 8px; }
  body.enx-v2 #ast-mobile-header .ast-primary-header-bar { padding-top: 6px; padding-bottom: 6px; }

  /* Search circle with a dropdown panel under the header bar */
  body.enx-v2 .enx-search-m { display: block; }
  body.enx-v2 .enx-search-m > summary {
    list-style: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--white);
    color: var(--ink);
    cursor: pointer;
  }
  body.enx-v2 .enx-search-m > summary::-webkit-details-marker { display: none; }
  body.enx-v2 .enx-search-m[open] > summary { background: var(--sage-tint); border-color: var(--sage); }
  body.enx-v2 .enx-search--panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 1200;
    gap: 8px;
    padding: 12px var(--hdr-pad);
    background: var(--white);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lift);
  }
  body.enx-v2 .enx-search--panel input[type="search"] {
    height: 44px;
    padding: 0 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
  }
  body.enx-v2 .enx-search--panel .enx-search__submit {
    order: 0;
    flex: 0 0 44px;
    height: 44px;
    background: var(--sage);
    color: var(--white);
    border-radius: 50%;
  }
  body.enx-v2 .enx-search--panel .enx-search__submit:hover { background: var(--sage-deep); color: var(--white); }

  /* Menu toggle: sage circle, white icon. Astra keeps its own open and close behaviour. */
  body.enx-v2 #ast-mobile-header .ast-button-wrap .menu-toggle {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    background: var(--sage);
    border: 0;
    border-radius: 50%;
    color: var(--white);
    box-shadow: none;
  }
  body.enx-v2 #ast-mobile-header .ast-button-wrap .menu-toggle:hover,
  body.enx-v2 #ast-mobile-header .ast-button-wrap .menu-toggle[aria-expanded="true"] { background: var(--sage-deep); color: var(--white); }
  body.enx-v2 #ast-mobile-header .ast-button-wrap .menu-toggle .ahfb-svg-iconset svg { width: 22px; height: 22px; fill: currentColor; }

  /* Mobile menu panel and drawer */
  body.enx-v2 .ast-mobile-header-content,
  body.enx-v2 .ast-mobile-popup-drawer .ast-mobile-popup-inner {
    background: var(--white);
  }
  body.enx-v2 .ast-header-break-point .main-header-menu {
    background: var(--white);
    border: 0;
  }
  body.enx-v2 .ast-header-break-point .main-header-menu .menu-item { border-bottom: 1px solid var(--line); }
  body.enx-v2 .ast-header-break-point .main-header-menu .menu-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 8px 20px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    background: transparent;
    border-radius: 0;
  }
  body.enx-v2 .ast-header-break-point .main-header-menu .menu-item:hover > .menu-link,
  body.enx-v2 .ast-header-break-point .main-header-menu .current-menu-item > .menu-link { color: var(--sage-deep); background: var(--sage-tint); }
  body.enx-v2 .ast-header-break-point .main-header-menu .sub-menu {
    background: var(--surface);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    margin: 0;
  }
  body.enx-v2 .ast-header-break-point .main-header-menu .sub-menu .menu-link { padding-left: 36px; font-size: 0.9375rem; font-weight: 600; }
  body.enx-v2 .ast-header-break-point .main-header-menu .ast-menu-toggle {
    min-width: 44px;
    min-height: 44px;
    color: var(--ink);
  }
}

/* =========================================================
   2. Footer (markup: retail/theme/astra-child/parts/footer-html-1.html)
   ========================================================= */
body.enx-v2 .site-footer,
body.enx-v2 #colophon {
  background: var(--sage-deep) !important;
  border: 0 !important;
  margin-top: 64px;
  padding: 0 !important;
  color: var(--sage-tint);
}
body.enx-v2 .site-footer .ast-builder-grid-row-container,
body.enx-v2 .site-footer .ast-builder-grid-row,
body.enx-v2 .site-footer .site-primary-footer-wrap {
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  background: transparent !important;
}
body.enx-v2 .site-footer .ast-header-html,
body.enx-v2 .site-footer .ast-builder-html-element { color: var(--sage-tint); }

body.enx-v2 .enx-footer {
  text-align: left;
  max-width: 1440px;
  margin: 0 auto;
  padding: 52px var(--hdr-pad) 30px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--sage-tint);
}
body.enx-v2 .enx-footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 40px;
}
body.enx-v2 .enx-footer p { margin: 0; }
body.enx-v2 .enx-footer__brand { display: flex; flex-direction: column; gap: 12px; }
body.enx-v2 .enx-footer__brand p:not(.enx-footer__logo) { max-width: 300px; color: var(--sage-tint); }
body.enx-v2 .enx-footer__logo {
  font-family: var(--font-head);
  font-weight: var(--fw-head);
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--white);
}
body.enx-v2 .enx-footer__col { display: flex; flex-direction: column; gap: 8px; }
body.enx-v2 .enx-footer__col h3 {
  margin: 0 0 4px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--white);
}
body.enx-v2 .enx-footer__col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
body.enx-v2 .enx-footer__col li { margin: 0; }
body.enx-v2 .enx-footer__col a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--sage-tint);
  text-decoration: none;
  border-radius: 6px;
}
body.enx-v2 .enx-footer__col a:hover,
body.enx-v2 .enx-footer__col a:focus-visible { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
body.enx-v2 .enx-footer a:focus-visible { outline-color: var(--white); }
body.enx-v2 .enx-footer__legal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 18px;
  border-top: 1px solid color-mix(in srgb, var(--white) 25%, transparent);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--sage-tint);
}
/* Copyright widget from the Astra footer builder (footer-copyright-editor) if it is enabled later */
body.enx-v2 .site-footer .ast-footer-copyright,
body.enx-v2 .site-footer .ast-small-footer,
body.enx-v2 .site-footer .site-below-footer-wrap {
  background: transparent !important;
  color: var(--sage-tint);
  text-align: left;
}
body.enx-v2 .site-footer .ast-footer-copyright a { color: var(--white); }

@media (max-width: 900px) {
  body.enx-v2 .enx-footer__grid { grid-template-columns: 1fr 1fr; gap: 28px 24px; }
  body.enx-v2 .enx-footer__brand { grid-column: 1 / -1; }
  body.enx-v2 .enx-footer { padding-top: 36px; gap: 24px; }
}
@media (max-width: 420px) {
  body.enx-v2 .enx-footer__grid { grid-template-columns: 1fr; }
}
@media (pointer: coarse) {
  body.enx-v2 .enx-footer__col a { min-height: 44px; }
}

/* =========================================================
   3. Page shell
   ========================================================= */
body.enx-v2 .site-content { background: var(--surface); }
body.enx-v2 .ast-separate-container .ast-article-single,
body.enx-v2 .ast-separate-container .ast-article-post { background: transparent; }
body.enx-v2 .ast-breadcrumbs-wrapper,
body.enx-v2 .ast-breadcrumbs { font-size: 0.8125rem; color: var(--muted); }
body.enx-v2 .ast-breadcrumbs a { color: var(--ink-soft); }
body.enx-v2 .entry-meta,
body.enx-v2 .entry-meta a { color: var(--muted); font-size: 0.875rem; }
body.enx-v2 .entry-content img { border-radius: var(--radius-md); height: auto; }

/* =========================================================
   4. Archives (category, blog) and search results
   ========================================================= */
body.enx-v2.archive .ast-article-post,
body.enx-v2.blog .ast-article-post,
body.enx-v2.search .ast-article-post {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: none;
}
body.enx-v2 .ast-article-post .entry-title {
  font-family: var(--font-head);
  font-weight: var(--fw-head);
  font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);
  line-height: 1.2;
}
body.enx-v2 .ast-article-post .entry-title a { color: var(--ink); text-decoration: none; }
body.enx-v2 .ast-article-post .entry-title a:hover { color: var(--sage-deep); }
body.enx-v2 .ast-article-post .post-thumb img { border-radius: var(--radius-md); }
body.enx-v2 .ast-article-post .entry-content,
body.enx-v2 .ast-article-post .ast-excerpt-container { color: var(--ink-soft); font-size: 1rem; }
body.enx-v2 .ast-read-more-container a,
body.enx-v2 .ast-article-post .read-more a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1.5px solid var(--sage);
  border-radius: var(--radius-pill);
  color: var(--sage-deep);
  font-weight: 700;
  text-decoration: none;
}
body.enx-v2 .ast-read-more-container a:hover,
body.enx-v2 .ast-article-post .read-more a:hover { background: var(--sage); color: var(--white); }

body.enx-v2 .ast-archive-description {
  background: var(--sand);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
}
body.enx-v2 .ast-archive-description .ast-archive-title { margin: 0 0 8px; }
body.enx-v2 .ast-archive-description p { color: var(--ink-soft); }

/* Pagination */
body.enx-v2 .ast-pagination { display: flex; justify-content: center; margin-top: 32px; }
body.enx-v2 .ast-pagination .nav-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
body.enx-v2 .ast-pagination .page-numbers {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
body.enx-v2 .ast-pagination .page-numbers.current,
body.enx-v2 .ast-pagination .page-numbers:hover { background: var(--sage); border-color: var(--sage); color: var(--white); }

/* Search page: the form and the empty state */
body.enx-v2 .search-form { display: flex; align-items: center; gap: 8px; max-width: 560px; }
body.enx-v2 .search-form label { flex: 1 1 auto; margin: 0; }
body.enx-v2 .search-form .search-field { width: 100%; border-radius: var(--radius-pill); padding: 0 20px; }
body.enx-v2 .search-form .search-submit { flex: 0 0 auto; }
body.enx-v2 .search-no-results .page-title,
body.enx-v2 .search-results .page-title { font-size: var(--fs-title); }

/* =========================================================
   5. 404
   ========================================================= */
body.enx-v2.error404 .ast-404-layout-1 .page-title,
body.enx-v2.error404 .page-title { font-size: var(--fs-h1); text-align: center; }
body.enx-v2.error404 .page-sub-title { text-align: center; color: var(--ink-soft); font-size: 1.0625rem; }
body.enx-v2.error404 .ast-404-search { max-width: 560px; margin: 24px auto 0; }
body.enx-v2.error404 .ast-404-search .search-form { margin: 0 auto; }

/* =========================================================
   6. Small screens
   ========================================================= */
@media (max-width: 600px) {
  body.enx-v2.archive .ast-article-post,
  body.enx-v2.blog .ast-article-post,
  body.enx-v2.search .ast-article-post { padding: 18px; }
  body.enx-v2 .ast-archive-description { padding: 22px 20px; }
}

/* Astra's "wide" featured image uses margin-left/right:-120px (>=922px, no sidebar) and width:unset, which makes
   the image 240px wider than the content box and adds a horizontal page scroll (also on production today). */
body.enx-v2 .site-content .ast-article-image-container--wide {
  margin-left: 0;
  margin-right: 0;
  max-width: 100%;
  width: 100%;
}
body.enx-v2 .ast-article-image-container--wide img { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); }

/* 44px touch targets: Astra's previous/next links and the 404 search button are 17-23px high. */
body.enx-v2 .post-navigation a { display: inline-flex; align-items: center; min-height: 44px; }
body.enx-v2 .search-submit,
body.enx-v2 .ast-search-submit { min-width: 44px; min-height: 44px; }
