/**
 * n.exchange Journal native WordPress templates.
 * Loaded after the compatibility layer so PHP-template components always win.
 */

html {
  scroll-padding-top: calc(var(--nex-header-height) + 2rem);
}

body.nexchange-native-templates {
  margin: 0;
  background: var(--nex-white);
  color: var(--nex-text);
}

.nex-main {
  min-height: 60vh;
}

.nex-skip-link:focus {
  position: fixed !important;
  z-index: 99999;
  width: auto !important;
  height: auto !important;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem !important;
  clip: auto !important;
  border-radius: 0.5rem;
  background: var(--nex-white);
  color: var(--nex-text);
}

/* Native header */
.nex-site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  border-bottom: 1px solid rgba(17, 21, 43, 0.09);
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.admin-bar .nex-site-header {
  top: 32px;
}

.nex-site-header__row {
  display: flex;
  min-height: var(--nex-header-height);
  gap: 2rem;
  align-items: center;
  justify-content: space-between;
}

.nex-brand {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.55rem;
  align-items: center;
  color: var(--nex-text);
  text-decoration: none;
}

.nex-brand:hover {
  color: var(--nex-accent);
  text-decoration: none;
}

.nex-brand__logo {
  display: block;
  width: clamp(10.25rem, 15vw, 12.75rem);
  height: auto;
  flex: 0 0 auto;
}

.nex-brand__mark {
  position: relative;
  display: grid;
  width: 2rem;
  height: 2rem;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem;
  overflow: hidden;
  border-radius: 0.45rem;
  background: var(--nex-text);
}

.nex-brand__mark i {
  position: relative;
  display: block;
  background: var(--nex-white);
}

.nex-brand__mark i:first-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 48%);
}

.nex-brand__mark i:last-child {
  clip-path: polygon(0 0, 100% 52%, 100% 100%, 0 100%);
}

.nex-brand__name {
  font-size: 1.42rem;
  font-weight: 760;
  letter-spacing: -0.055em;
}

.nex-brand__section {
  padding-left: 0.7rem;
  border-left: 1px solid var(--nex-line);
  color: var(--nex-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nex-primary-nav,
.nex-menu,
.nex-primary-nav__actions {
  display: flex;
  align-items: center;
}

.nex-primary-nav {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: clamp(1rem, 3vw, 2.4rem);
}

.nex-menu {
  gap: clamp(0.8rem, 2vw, 1.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nex-menu a,
.nex-search-toggle {
  border: 0;
  background: transparent;
  color: var(--nex-text);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.nex-menu a:hover,
.nex-menu .current-menu-item > a,
.nex-menu .current-menu-ancestor > a,
.nex-search-toggle:hover {
  color: var(--nex-accent);
}

.nex-primary-nav__actions {
  gap: 0.8rem;
}

.nex-button-link {
  display: inline-flex;
  min-height: 44px;
  padding: 0.7rem 1.05rem;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--nex-accent);
  color: var(--nex-white) !important;
  font-size: 0.88rem;
  font-weight: 780;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.nex-button-link:hover {
  background: var(--nex-accent-hover);
  color: var(--nex-white);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 9px 22px rgba(38, 56, 196, 0.24);
}

.nex-button-link--light {
  background: var(--nex-white);
  color: var(--nex-blue-950) !important;
}

.nex-button-link--light:hover {
  background: var(--nex-green-400);
  color: var(--nex-blue-950) !important;
}

.nex-text-link {
  color: var(--nex-accent);
  font-weight: 780;
  text-decoration: none;
}

.nex-text-link:hover {
  text-decoration: underline;
}

.nex-menu-toggle {
  display: none;
  min-height: 44px;
  padding: 0.6rem 0.8rem;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--nex-line);
  border-radius: 999px;
  background: var(--nex-white);
  color: var(--nex-text);
  font-weight: 760;
}

.nex-menu-toggle__icon,
.nex-menu-toggle__icon::before,
.nex-menu-toggle__icon::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: currentColor;
  content: "";
  transition: transform 180ms ease;
}

.nex-menu-toggle__icon::before { transform: translateY(-5px); }
.nex-menu-toggle__icon::after { transform: translateY(3px); }

.nex-header-search {
  padding: 0.85rem 0;
  border-top: 1px solid var(--nex-line);
  background: var(--nex-surface-soft);
}

.nex-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.nex-search input[type="search"] {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--nex-line);
  border-radius: 999px;
  background: var(--nex-white);
  color: var(--nex-text);
}

.nex-search button {
  min-height: 48px;
  padding: 0.75rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: var(--nex-text);
  color: var(--nex-white);
  font-weight: 760;
}

/* Blog and archive heroes */
.nex-featured__article {
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  min-height: 23rem;
}

.nex-featured__media {
  display: block;
  min-height: 100%;
  overflow: hidden;
  background: var(--nex-blue-950);
}

.nex-featured__media img,
.nex-featured__media .nex-card__placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nex-featured__copy {
  display: flex;
  flex-direction: column;
  padding: clamp(1.4rem, 3vw, 2.1rem);
}

.nex-featured__label,
.nex-featured__category,
.nex-card__category,
.nex-article-category {
  width: max-content;
  color: var(--nex-accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.nex-featured__label {
  margin: 0 0 0.45rem;
  color: var(--nex-muted);
}

.nex-featured__copy h2 {
  margin: 0.85rem 0 0.75rem;
  font-size: clamp(1.5rem, 2.3vw, 2.15rem);
  line-height: 1.07;
  letter-spacing: -0.04em;
}

.nex-featured__copy h2 a {
  color: var(--nex-text);
  text-decoration: none;
}

.nex-featured__copy > p:not(.nex-featured__label) {
  margin: 0 0 1rem;
  color: var(--nex-muted);
}

.nex-featured__meta {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  color: var(--nex-muted);
  font-size: 0.78rem;
}

.nex-featured__link {
  margin-top: 1rem;
  color: var(--nex-accent);
  font-weight: 800;
  text-decoration: none;
}

.nex-archive-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(3.2rem, 7vw, 5.5rem) 0;
  background: linear-gradient(135deg, var(--nex-blue-950), var(--nex-accent));
  color: var(--nex-white);
}

.nex-archive-hero::after {
  position: absolute;
  width: 26rem;
  height: 26rem;
  right: -8rem;
  top: -12rem;
  border: 3rem solid rgba(102, 215, 151, 0.16);
  border-radius: 50%;
  content: "";
}

.nex-archive-hero .nex-shell {
  position: relative;
  z-index: 1;
}

.nex-archive-hero h1 {
  max-width: 18ch;
  margin: 0;
  color: var(--nex-white);
  font-size: clamp(2.7rem, 6vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.nex-archive-hero p,
.nex-archive-hero__description {
  max-width: 42rem;
  margin: 1.1rem 0 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.12rem;
}

.nex-archive-hero .nex-eyebrow {
  margin-bottom: 1rem;
  color: var(--nex-green-400);
  font-size: 0.76rem;
}

/* Discovery and content grid */
.nex-discovery .nex-search {
  min-width: 0;
}

.nex-discovery__row {
  grid-template-columns: minmax(18rem, 28rem) max-content;
  justify-content: center;
}

.nex-category-pills {
  justify-content: center;
}

.nex-category-pills a {
  text-align: center;
}

body.category .nex-archive-hero .nex-shell {
  text-align: center;
}

body.category .nex-archive-hero :is(h1, p, .nex-archive-hero__description) {
  margin-inline: auto;
}

body.category .nex-archive-hero .nex-eyebrow {
  justify-content: center;
}

.nex-archive-section {
  padding: clamp(3.2rem, 6vw, 5rem) 0;
}

.nex-section-heading {
  display: flex;
  gap: 2rem;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.nex-section-heading .nex-eyebrow {
  margin-bottom: 0.65rem;
  color: var(--nex-accent);
}

.nex-section-heading h2 {
  margin: 0;
  color: var(--nex-text);
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.nex-section-heading > p {
  max-width: 30rem;
  margin: 0;
  color: var(--nex-muted);
}

.nex-post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.4rem;
  align-items: stretch;
}

.nex-card {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 39rem;
  overflow: hidden;
  border: 0;
  border-radius: var(--nex-radius-md);
  background: var(--nex-accent);
  color: var(--nex-white);
  box-shadow: 0 1px 0 rgba(17, 21, 43, 0.05), 0 12px 32px rgba(17, 26, 92, 0.11);
}

.nex-card:hover,
.nex-card:focus-within {
  border: 0;
  transform: translateY(-4px);
  box-shadow: 0 20px 48px rgba(17, 26, 92, 0.2);
}

.nex-card__media {
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--nex-blue-950);
}

.nex-card__media img,
.nex-card__placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nex-card__placeholder {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, var(--nex-blue-950), var(--nex-accent));
}

.nex-card__placeholder::before,
.nex-card__placeholder::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.nex-card__placeholder::before {
  width: 11rem;
  height: 11rem;
  right: -3rem;
  top: -4rem;
  border: 2rem solid rgba(102, 215, 151, 0.23);
}

.nex-card__placeholder::after {
  width: 8rem;
  height: 8rem;
  left: -2rem;
  bottom: -4rem;
  background: rgba(91, 62, 209, 0.48);
}

.nex-card__placeholder > span {
  position: absolute;
  z-index: 1;
  left: 1.25rem;
  top: 1.1rem;
  color: var(--nex-white);
  font-size: 1.25rem;
  font-weight: 760;
  letter-spacing: -0.05em;
}

.nex-card__body {
  display: flex;
  min-height: 0;
  padding: 1.35rem 1.35rem 1rem;
  flex-direction: column;
}

.nex-card__category {
  padding: 0.36rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--nex-white) !important;
}

.nex-card .nex-card__title {
  display: -webkit-box !important;
  overflow: hidden !important;
  margin: 1rem 0 0.75rem;
  color: var(--nex-white) !important;
  font-size: clamp(1.28rem, 2vw, 1.62rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.nex-card .nex-card__title a,
.nex-card:hover .nex-card__title a,
.nex-card:focus-within .nex-card__title a {
  color: var(--nex-white) !important;
  text-decoration-color: currentColor;
}

.nex-card .nex-card__excerpt {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 1rem;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.94rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.nex-card__more {
  margin-top: auto;
  color: var(--nex-white) !important;
  font-size: 0.84rem;
  font-weight: 820;
  text-decoration: none;
}

.nex-card__more:hover {
  color: var(--nex-green-400) !important;
}

.nex-card__footer {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
}

/* Pagination, empty and error states */
.nex-pagination {
  margin-top: 2.5rem;
}

.nex-pagination ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nex-pagination :is(a, span) {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  padding: 0.6rem;
  place-items: center;
  border: 1px solid var(--nex-line);
  border-radius: 999px;
  color: var(--nex-text);
  text-decoration: none;
}

.nex-pagination .current,
.nex-pagination a:hover {
  border-color: var(--nex-accent);
  background: var(--nex-accent);
  color: var(--nex-white);
}

.nex-empty-state,
.nex-error-page .nex-shell {
  max-width: 46rem;
  margin-inline: auto;
  padding: clamp(3rem, 8vw, 6rem) 1rem;
  text-align: center;
}

.nex-empty-state h2,
.nex-error-page h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.nex-empty-state .nex-search,
.nex-error-page .nex-search {
  margin: 1.5rem 0;
}

.nex-empty-state__mark,
.nex-error-page__code {
  margin: 0;
  color: var(--nex-accent);
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 850;
  line-height: 0.9;
}

/* Article refinements */
.nex-article-category {
  display: inline-flex;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: var(--nex-white);
}

.nex-article-hero__breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.nex-article-hero__breadcrumbs a {
  color: inherit;
}

.nex-article-visual .nex-card__placeholder {
  min-height: 100%;
}

.nex-share-rail {
  display: grid;
  gap: 0.6rem;
}

.nex-share-rail > :is(a, button) {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--nex-line);
  border-radius: 50%;
  background: var(--nex-white);
  color: var(--nex-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.nex-toc [data-nex-toc-list] ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nex-toc [data-nex-toc-list] li.is-subheading a {
  padding-left: 1rem;
  font-size: 0.76rem;
}

.nex-post-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--nex-line);
}

.nex-post-navigation > div:last-child {
  text-align: right;
}

.nex-post-navigation span {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--nex-muted);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nex-post-navigation a {
  color: var(--nex-text);
  font-weight: 760;
  text-decoration: none;
}

.nex-related .nex-section-heading {
  margin-bottom: 1.8rem;
}

/* CTA band */
.nex-cta-grid {
  width: min(calc(100% - 2rem), var(--nex-site-width));
  margin-inline: auto;
}

.nex-newsletter,
.nex-product-cta {
  min-height: 24rem;
}

.nex-newsletter {
  display: flex;
  margin: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.nex-newsletter .nex-button-link {
  margin-top: 0.5rem;
}

.nex-product-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: auto;
  align-items: center;
}

/* Native pages */
.nex-page {
  padding: clamp(3rem, 7vw, 6rem) 0;
}

.nex-page__header,
.nex-page__content {
  width: min(100%, var(--nex-reading-width));
  margin-inline: auto;
}

.nex-page__header h1 {
  margin: 0 0 2rem;
  font-size: clamp(2.7rem, 6vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

/* Native footer */
.nex-site-footer {
  margin-top: clamp(3rem, 7vw, 6rem);
  padding: clamp(3.5rem, 7vw, 5rem) 0 1.5rem;
  background: #101633;
  color: var(--nex-white);
}

.nex-site-footer__grid {
  display: grid;
  grid-template-columns: minmax(16rem, 1.45fr) repeat(3, minmax(9rem, 0.72fr));
  gap: clamp(2rem, 5vw, 4rem);
  padding-bottom: 2.5rem;
}

.nex-brand--footer {
  width: max-content;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  background: var(--nex-white);
}

.nex-brand--footer .nex-brand__logo {
  width: 12rem;
}

.nex-site-footer__brand p {
  max-width: 23rem;
  margin: 1rem 0;
  color: rgba(255, 255, 255, 0.72);
}

.nex-footer-cta {
  color: var(--nex-green-400) !important;
  font-weight: 780;
  text-decoration: none;
}

.nex-site-footer h2 {
  margin: 0 0 1rem;
  color: var(--nex-green-400);
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.nex-site-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nex-site-footer li + li {
  margin-top: 0.55rem;
}

.nex-site-footer a {
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
}

.nex-site-footer a:hover {
  color: var(--nex-white);
  text-decoration: underline;
}

.nex-site-footer__bottom {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding-top: 1.35rem;
}

.nex-site-footer__bottom p {
  margin: 0;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.76rem;
}

@media (max-width: 1100px) {
  .nex-menu-toggle {
    display: inline-flex;
  }

  .nex-primary-nav {
    position: absolute;
    z-index: 110;
    display: none;
    width: min(calc(100% - 2rem), 32rem);
    right: 1rem;
    top: calc(100% + 0.5rem);
    padding: 1rem;
    border: 1px solid var(--nex-line);
    border-radius: var(--nex-radius-md);
    background: var(--nex-white);
    box-shadow: var(--nex-shadow);
  }

  .nex-primary-nav.is-open {
    display: block;
  }

  .nex-menu,
  .nex-primary-nav__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .nex-menu {
    gap: 0;
  }

  .nex-menu a,
  .nex-search-toggle {
    display: block;
    width: 100%;
    padding: 0.75rem;
    text-align: left;
  }

  .nex-primary-nav__actions {
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--nex-line);
  }

  .nex-post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nex-card {
    min-height: 38rem;
  }

  .nex-site-footer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .admin-bar .nex-site-header {
    top: 46px;
  }

  .nex-brand__section {
    display: none;
  }

  .nex-blog-hero__grid,
  .nex-featured__article,
  .nex-discovery__row,
  .nex-post-grid,
  .nex-cta-grid,
  .nex-site-footer__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .nex-discovery__row {
    justify-content: stretch;
  }

  .nex-category-pills {
    justify-content: flex-start;
  }

  .nex-featured__media {
    aspect-ratio: 16 / 9;
  }

  .nex-discovery {
    position: relative;
    top: auto;
  }

  .nex-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .nex-card {
    min-height: 37rem;
  }

  .nex-article-hero__grid {
    grid-template-columns: 1fr;
  }

  .nex-article-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .nex-share-rail,
  .nex-toc--desktop {
    display: none;
  }

  .nex-toc--mobile {
    display: block;
  }

  .nex-post-navigation {
    grid-template-columns: 1fr;
  }

  .nex-post-navigation > div:last-child {
    text-align: left;
  }

  .nex-site-footer__bottom {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .nex-brand__logo {
    width: 9.5rem;
  }

  .nex-menu-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .nex-card {
    min-height: 35rem;
  }

  .nex-search {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nex-card,
  .nex-button-link,
  .nex-menu-toggle__icon {
    transition: none;
  }
}
