/* Shared context headers */
.em-context-header {
  margin-bottom: 32px;
}

.em-context-card {
  position: relative;
  overflow: hidden;
  padding: 28px 32px;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--brand-primary);
  background: var(--bg-surface);
}

@media (max-width: 767px) {
  .em-context-title {
    display: none;
  }
}

.em-context-glow {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: var(--brand-subtle);
  opacity: 0.5;
  pointer-events: none;
}

.em-context-breadcrumb {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.em-context-breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.em-context-breadcrumb-link {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.em-context-breadcrumb-link.is-current {
  color: var(--text-secondary);
  font-weight: 600;
}

.em-context-breadcrumb-sep {
  font-size: 12px;
  color: var(--border-default);
}

.em-context-main {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  min-width: 0;
}

.em-context-copy {
  flex: 1;
  min-width: 0;
}

.em-context-pill-row {
  margin-bottom: 10px;
}

.em-context-title {
  font-size: clamp(24px, 3.5vw, 38px);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.18;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.em-context-desc {
  max-width: 620px;
  margin: 0;
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.em-context-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.em-context-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.em-single-body-inner,
.em-main-content,
.em-sidebar,
.em-mercati-main {
  min-width: 0;
}

.em-single-body-inner pre,
.em-single-body-inner iframe,
.em-single-body-inner video,
.em-single-body-inner table,
.em-single-body-inner .wp-block-table {
  max-width: 100%;
}

.em-single-body-inner pre {
  overflow-x: auto;
}

.em-single-body-inner table,
.em-single-body-inner .wp-block-table table {
  width: 100%;
}

/* Responsive hardening */
@media (max-width: 1180px) {
  .em-etf-grid,
  .em-markets-guides-grid,
  .em-newsletter-mid,
  .em-brand-banner,
  .em-mercati-hero {
    grid-template-columns: 1fr;
  }

  .em-hero-home-grid {
    column-gap: 18px;
    row-gap: 10px;
  }

  .em-hero-home-left {
    padding-right: 0;
  }

  .em-home-top-grid,
  .em-explore-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .em-hero-carousel-thumbs {
    grid-template-columns: 1fr;
  }

  .em-brand-banner-cta {
    justify-content: flex-start;
  }

  .em-with-sidebar,
  .em-single-with-sidebar {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 32px;
  }

  .em-mercati-hero-stats {
    justify-content: flex-start;
  }
}
@media screen and (max-width:767px) {
  .em-hero-home-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "right"
      "newsletter";
  }
}

@media (min-width: 768px) and (max-width: 1179px) {
  .em-hero-home-left {
    align-self: end;
  }

  .em-hero-home-newsletter {
    align-self: start;
  }
}

@media (max-width: 1024px) {
  .em-with-sidebar,
  .em-single-with-sidebar {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .em-single-with-sidebar > .em-sidebar {
    padding-top: 0;
  }

  .em-sidebar {
    position: static;
  }


  .em-featured-grid {
    grid-template-columns: 1fr;
  }

  .em-related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .em-grid-3,
  .em-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .em-newsletter-mid {
    padding: 22px 24px;
  }

  .em-mercati-pillars {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .em-mercati-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .em-context-card {
    padding: 24px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .em-sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
  }

  .em-sidebar > * {
    min-width: 0;
  }
}

@media (max-width: 820px) {
  .em-related-header {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 14px;
  }

  .em-related-line {
    flex: 1 1 auto;
    flex-basis: auto;
    min-width: 0;
    order: initial;
  }

  .em-hero-home-newsletter-form {
    flex-direction: column;
    align-items: stretch;
  }

  .em-hero-home-newsletter-btn {
    width: 100%;
  }

  .em-home-top-grid,
  .em-explore-grid,
  .em-hero-carousel-thumbs {
    grid-template-columns: 1fr;
  }

  .em-guides-card .em-card-link,
  .em-etf-side-card .em-card-link,
  .em-card-horizontal .em-card-link {
    width: 100%;
    flex-direction: column;
  }

  .em-guides-image,
  .em-etf-side-image,
  .em-card-h-image {
    width: 100%;
    height: 120px;
  }

  .em-etf-main-image {
    height: 120px;
  }

  .em-card-horizontal .em-card-h-image,
  .em-card-horizontal .em-card-h-body {
    width: 100%;
  }

  .em-brand-banner-points {
    gap: 12px 16px;
  }

  .em-mercati-card-head-main {
    flex-wrap: wrap;
  }

  .em-mercati-card-head-left {
    max-width: none;
  }

  .em-mercati-card-head-right {
    text-align: left;
  }

  .em-mercati-card-mock {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .em-archive-wrapper,
  .em-with-sidebar,
  .em-mercati-page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .em-archive-wrapper {
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .em-with-sidebar.em-blog-wrapper {
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .em-single-with-sidebar {
    padding: 0 16px 40px;
  }

  .em-hero-home-title {
    font-size: clamp(28px, 10vw, 40px);
  }

  .em-hero-home-subtitle {
    max-width: none;
    font-size: 14.5px;
  }

  .em-hero-home-newsletter,
  .em-brand-banner,
  .em-newsletter-mid,
  .em-sidebar-newsletter {
    padding: 18px;
  }

  .em-brand-banner,
  .em-newsletter-mid {
    gap: 18px;
  }

  .em-hero-carousel-main {
    min-height: 320px;
  }

  .em-hero-carousel-main-content {
    padding: 18px 16px 16px;
  }

  .em-hero-carousel-main-title {
    font-size: 22px;
  }

  .em-hero-carousel-main-excerpt {
    font-size: 12.5px;
  }

  .em-hero-carousel-main-meta {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .em-grid-2,
  .em-grid-4,
  .em-featured-grid,
  .em-mercati-grid, 
  .em-learn-grid {
    grid-template-columns: 1fr;
  }
  
  .em-card-overlay--lg {
    height: 300px;
  }

  .em-card-overlay--sm {
    height: 180px;
  }

  .em-card-body,
  .em-card-featured-body,
  .em-card-h-body,
  .em-etf-main-body,
  .em-guides-body {
    padding: 16px;
  }

  .em-card-footer,
  .em-card-featured-meta-row,
  .em-card-h-footer,
  .em-card-meta-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .em-single-hero {
    min-height: 200px;
  }

  .em-single-hero-inner {
    height: 200px;
    padding: 32px 16px;
  }

  .em-single-title,
  .em-single-hero-title {
    font-size: clamp(26px, 8vw, 34px);
  }

  .em-single-hero-meta-separator {
    display: none;
  }

  .em-single-body {
    padding: 16px 8px;
  }

  .em-single-body-inner {
    overflow-wrap: anywhere;
  }

  .em-single-body-inner table,
  .em-single-body-inner .wp-block-table table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .em-single-sharebar {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .em-single-sharebar-left {
    width: auto;
    align-items: flex-start;
  }

  .em-single-sharebar-actions {
    width: auto;
    flex-direction: row;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: center;
  }

  .em-single-sharebtn {
    width: auto;
    flex: 0 0 auto;
    justify-content: center;
  }

  .em-single-summary,
  .em-toc {
    padding: 18px;
  }

  .em-newsletter-form,
  .em-404-nl-form {
    flex-direction: column;
  }

  .em-newsletter-input,
  .em-newsletter-btn,
  .em-404-nl-input,
  .em-404-nl-btn {
    width: 100%;
  }

  .em-header-bar-live {
    padding: 0 10px;
  }

  .em-header-bar-item {
    padding: 0 12px;
    gap: 8px;
  }

  .em-header-bar-market-values .em-market-price {
    display: none;
  }

  .em-mercati-page {
    padding-top: 24px;
    padding-bottom: 48px;
  }

  .em-mercati-subtitle {
    font-size: 15px;
  }

  .em-mercati-hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .em-mercati-hero-stat {
    width: 100%;
    min-width: 0;
  }

  .em-mercati-filters {
    align-items: stretch;
  }

  .em-mercati-filters-left {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .em-mercati-filter-pill {
    white-space: nowrap;
  }

  .em-mercati-card-head,
  .em-mercati-card-body {
    padding: 16px;
  }

  .em-mercati-card-footer-divider {
    width: 100%;
    height: 1px;
  }

  .em-mercati-card-link {
    width: 100%;
    justify-content: space-between;
  }

  .em-context-card {
    padding: 20px 18px;
  }

  .em-context-title {
    font-size: clamp(24px, 8vw, 32px);
  }

  .em-context-desc {
    font-size: 14px;
  }

  .em-card-h-readmore {
    width: 100%;
  }

  .em-hero-carousel-dot.is-active {
    width: 18px;
  }

  .em-mercati-hero-stats {
    grid-template-columns: 1fr;
  }

}
