/* EMKAN v138 — final public geometry + unified utilities/search/education/covers.
   This is a narrow corrective layer over v136; it does not restyle the approved theme. */
:root{
  --emkan-v138-menu-max:1288px;
  --emkan-v138-content-max:1430px;
  --emkan-v138-utility-inset:12px;
  --emkan-v138-menu-gap:24px;
  --emkan-v138-line:var(--line,#d8dadd);
}

/* 1) Header is intentionally one step narrower than breadcrumb/page content. */
@media (min-width:901px){
  html body .site-header{
    width:min(calc(100% - 96px),var(--emkan-v138-menu-max))!important;
    max-width:var(--emkan-v138-menu-max)!important;
    margin-inline:auto!important;
  }
  html body .site-header .nav-frame{
    position:relative!important;
    display:block!important;
    width:100%!important;
    min-height:52px!important;
  }
  html body .site-header .primary-nav{
    width:100%!important;
    min-height:52px!important;
    padding-inline:104px!important;
    box-sizing:border-box!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
  }
  html body .site-header .nav-list{
    width:max-content!important;
    max-width:100%!important;
    margin:0 auto!important;
    gap:clamp(18px,var(--emkan-v138-menu-gap),28px)!important;
    align-items:center!important;
    justify-content:center!important;
  }

  /* Explicitly clear old logical offsets BEFORE physical coordinates. */
  html body .site-header .language-button,
  html[dir="rtl"] body .site-header .language-button,
  html[dir="ltr"] body .site-header .language-button{
    position:absolute!important;
    inset-inline-start:auto!important;
    inset-inline-end:auto!important;
    left:var(--emkan-v138-utility-inset)!important;
    right:auto!important;
    top:50%!important;
    bottom:auto!important;
    transform:translateY(-50%)!important;
    margin:0!important;
    z-index:40!important;
  }
  html body .site-header .theme-button,
  html body .site-header .nav-frame>#themeButton.theme-button,
  html[dir="rtl"] body .site-header .theme-button,
  html[dir="ltr"] body .site-header .theme-button{
    position:absolute!important;
    inset-inline-start:auto!important;
    inset-inline-end:auto!important;
    right:var(--emkan-v138-utility-inset)!important;
    left:auto!important;
    top:50%!important;
    bottom:auto!important;
    transform:translateY(-50%)!important;
    margin:0!important;
    z-index:40!important;
  }

  /* Outer page measure: breadcrumb/back and every main page shell align exactly. */
  body:not(.welcome-page):not(.menu-page) .page-shell>main,
  body :is(
    .architecture-main,.module-main,.store-main,.store-category-main,.product-main,
    .checkout-main,.articles-main,.article-page,.detail-main,.v49-main,.podcast-main,
    .about-main,.contact-main,.careers-main,.emkan-search-main,.emkan-member-main,
    .project-main,.account-shell
  ){
    width:min(calc(100% - 96px),var(--emkan-v138-content-max))!important;
    max-width:var(--emkan-v138-content-max)!important;
    margin-inline:auto!important;
    box-sizing:border-box!important;
  }
  body :is(.emkan-context-bar,.store-context-bar,.podcast-context-bar,.product-toolbar,.detail-nav,.short-back,.article-page-back){
    width:100%!important;
    max-width:none!important;
    margin-inline:0!important;
    box-sizing:border-box!important;
  }
}

/* 2) Store search: same line, same magnifier, including the generated proxy search. */
:is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy){
  position:relative!important;
  display:block!important;
  width:100%!important;
  min-height:28px!important;
  margin:0 0 14px!important;
  padding:0!important;
  border:0!important;
  background:transparent!important;
}
:is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy)>span[class^="lang-"]{
  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;white-space:nowrap!important;border:0!important;
}
:is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy) input[type="search"]{
  display:block!important;
  width:100%!important;height:28px!important;min-height:28px!important;
  margin:0!important;padding-block:0 5px!important;
  border:0!important;border-bottom:1px solid var(--line)!important;border-radius:0!important;
  background:transparent!important;color:var(--fg)!important;box-shadow:none!important;outline:0!important;
  font:inherit!important;font-size:10px!important;line-height:1.5!important;
  -webkit-appearance:none!important;appearance:none!important;
}
:is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy) input[type="search"]:is(:hover,:focus){
  border-bottom-color:var(--hover-accent)!important;
}
:is(html[lang="fa"],html[lang="ar"]) :is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy) input[type="search"]{
  direction:rtl!important;text-align:right!important;padding-inline:0 25px!important;
}
html[lang="en"] :is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy) input[type="search"]{
  direction:ltr!important;text-align:left!important;padding-inline:0 25px!important;
}
:is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy)>.emkan-v138-store-search-icon{
  display:block!important;
  visibility:visible!important;
  position:absolute!important;z-index:5!important;top:50%!important;
  width:12px!important;height:12px!important;
  transform:translateY(-58%)!important;
  color:var(--category-muted,var(--fg))!important;opacity:.58!important;
  fill:none!important;stroke:currentColor!important;stroke-width:1.5!important;
  stroke-linecap:round!important;stroke-linejoin:round!important;
  pointer-events:none!important;
}
:is(html[lang="fa"],html[lang="ar"]) :is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy)>.emkan-v138-store-search-icon{left:7px!important;right:auto!important}
html[lang="en"] :is(.store-category-side,.emkan-store-filter-rail) :is(.product-search,.emkan-store-search-proxy)>.emkan-v138-store-search-icon{right:7px!important;left:auto!important}

/* 3) Education detail: rail/search/tree on the correct physical side; lead fills the formerly empty area. */
@media (min-width:901px){
  body.emkan-v138-education-detail #contentApp .v69-content-detail-layout{
    display:grid!important;
    direction:ltr!important;
    width:100%!important;
    max-width:100%!important;
    margin-inline:0!important;
    column-gap:clamp(40px,4vw,60px)!important;
    align-items:start!important;
  }
  :is(html[lang="fa"],html[lang="ar"]) body.emkan-v138-education-detail #contentApp .v69-content-detail-layout{
    grid-template-columns:minmax(0,1fr) 190px!important;
    grid-template-areas:"content rail"!important;
  }
  html[lang="en"] body.emkan-v138-education-detail #contentApp .v69-content-detail-layout{
    grid-template-columns:190px minmax(0,1fr)!important;
    grid-template-areas:"rail content"!important;
  }
  body.emkan-v138-education-detail #contentApp .v69-content-search-rail{
    grid-area:rail!important;
    width:190px!important;max-width:190px!important;
    margin:0!important;padding:0!important;
    align-self:start!important;
  }
  body.emkan-v138-education-detail #contentApp .v69-content-detail-body{
    grid-area:content!important;
    width:100%!important;max-width:none!important;min-width:0!important;
    margin:0!important;padding:0!important;
  }
}
.emkan-v138-learning-lead{
  width:100%!important;
  margin:0 0 24px!important;
  padding:0 0 18px!important;
  border-bottom:1px solid var(--line)!important;
  box-sizing:border-box!important;
}
.emkan-v138-learning-lead h1{margin:0 0 8px!important;font-size:21px!important;font-weight:620!important;line-height:1.65!important;color:var(--fg)!important}
.emkan-v138-learning-lead p{margin:0!important;max-width:790px!important;font-size:11px!important;line-height:2!important;color:var(--category-muted,var(--muted,var(--fg)))!important}
:is(html[lang="fa"],html[lang="ar"]) .emkan-v138-learning-lead{text-align:right!important;direction:rtl!important}
html[lang="en"] .emkan-v138-learning-lead{text-align:left!important;direction:ltr!important}
body.emkan-v138-education-detail .emkan-v136-learning-lead{display:none!important}

/* 4) Every listing/card cover is square. Fullscreen/gallery images are intentionally excluded. */
:is(
 .category-square,.store-square,.img-wrapper,.product-card-media,.related-item-media,.related-media,
 .v49-card-media,.v49-course-media,.v49-course-cover,.v49-work-media,.research-entry-media,.research-index-media,
 .dx-card-media,.dx-card-placeholder,.podcast-series-cover,.episode-cover,.player-cover,.v115-course-poster,
 .product-main-image,.learning-course-cover,.civil-entry-media,.person-card-media,.v115-course-media,.category-media,.v106-course-thumb,.v73-sample-thumb,.emkan-v138-square-cover
){
  aspect-ratio:1/1!important;
  overflow:hidden!important;
  min-height:0!important;
}
:is(
 .category-square,.store-square,.img-wrapper,.product-card-media,.related-item-media,.related-media,
 .v49-card-media,.v49-course-media,.v49-course-cover,.v49-work-media,.research-entry-media,.research-index-media,
 .dx-card-media,.podcast-series-cover,.episode-cover,.player-cover,.v115-course-poster,
 .product-main-image,.learning-course-cover,.civil-entry-media,.person-card-media,.v115-course-media,.category-media,.v106-course-thumb,.v73-sample-thumb,.emkan-v138-square-cover
)>img,
:is(.emkan-v138-square-cover,img.emkan-v138-square-image){
  width:100%!important;height:100%!important;object-fit:cover!important;
}

/* Keep image enlargement natural / rectangular, never inherited from square covers. */
:is(.emkan-v135-viewer-stage,.project-lightbox-stage,.project-viewer-stage) img{
  aspect-ratio:auto!important;
  width:auto!important;height:auto!important;
  max-width:100%!important;max-height:100%!important;
  object-fit:contain!important;
}

/* 5) Module-level visual variables from admin: restrained overrides only. */
body:not([class*="admin"]){
  --line:var(--emkan-v138-line,var(--line));
  font-size:var(--emkan-v138-base-size,inherit);
}
body:not([class*="admin"]) :is(.category-grid,.store-grid,.project-grid,.v49-grid,.research-index-grid){
  gap:var(--emkan-v138-card-gap,inherit)!important;
}

@media (max-width:900px){
  .emkan-v138-learning-lead{margin-bottom:18px!important;padding-bottom:14px!important}
  .emkan-v138-learning-lead h1{font-size:18px!important}
}
