/* EMKAN v39 — final responsive/system layer.
   Scope: layout safety, fixed menu geometry, unified cover motion, browser/device resilience.
   It intentionally avoids changing page-specific art direction. */
:root{
  --emkan-safe-inline:clamp(16px,3.2vw,48px);
  --emkan-safe-block:clamp(18px,2.6vw,38px);
  --emkan-cover-duration:1320ms;
  --emkan-cover-step:190ms;
  --emkan-cover-ease:cubic-bezier(.22,.61,.36,1);
}
*,*::before,*::after{box-sizing:border-box}
html{min-width:320px;-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-behavior:smooth}
body{min-width:320px;max-width:100%;overflow-x:clip}
:is(main,section,article,aside,nav,header,footer,div,form,fieldset){min-width:0}
:is(img,video,canvas,svg,picture,iframe){max-width:100%}
img,video{height:auto}
input,textarea,select,button{max-width:100%;font:inherit}
textarea{resize:vertical}

/* Control positions are physical; item order follows the document language. */
:is(#languageButton,.language-button,#accountLanguageRail,.account-language-rail){direction:ltr!important;unicode-bidi:isolate!important}

/* Shared page geometry guardrails. */
:is(.page-shell,.site-shell,.module-shell,.content-shell,.store-shell,.research-shell,.civil-shell,.architecture-shell){width:100%;max-width:100%;margin-inline:auto}
:is(.module-main,.store-main,.research-main,.civil-main,.architecture-main,.content-main,.emkan-ai-main){max-width:100%;min-width:0}
:is(.category-grid,.store-grid,.projects-grid,.projects-layout,.research-grid,.civil-entry-grid,.v49-grid,.v49-work-grid){min-width:0}
:is(.category-grid,.store-grid,.projects-grid,.research-grid,.civil-entry-grid,.v49-grid,.v49-work-grid)>*{min-width:0}

/* Unified calm cover reveal. Existing page-specific delays remain respected. */
:is(.gallery-item,.emkan-stagger-card,.emkan-v26-cover,.emkan-v25-cover,.category-card,.store-card,.project-card){
  transition-timing-function:var(--emkan-cover-ease)!important;
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}
  :is(.gallery-item,.emkan-stagger-card,.emkan-v26-cover,.emkan-v25-cover,.category-card,.store-card,.project-card){opacity:1!important;transform:none!important}
}

/* Large desktop / ultrawide: stop content from stretching while preserving page templates. */
@media (min-width:1600px){
  :is(.page-shell,.site-shell,.module-shell,.content-shell,.store-shell,.research-shell,.civil-shell,.architecture-shell){max-width:1540px}
}

/* Tablet landscape and compact laptops. */
@media (max-width:1180px){
  :root{--emkan-safe-inline:clamp(18px,2.8vw,34px)}
  :is(.page-shell,.site-shell,.module-shell,.content-shell,.store-shell,.research-shell,.civil-shell,.architecture-shell){padding-inline:var(--emkan-safe-inline)}
  :is(.category-grid,.store-grid,.research-grid,.civil-entry-grid){column-gap:clamp(14px,2vw,24px)}
}

/* Tablet / mobile: universal overflow safety without changing desktop composition. */
@media (max-width:900px){
  body{overflow-x:hidden}
  :is(.page-shell,.site-shell,.module-shell,.content-shell,.store-shell,.research-shell,.civil-shell,.architecture-shell){width:100%!important;max-width:100%!important;padding-inline:clamp(15px,4vw,28px)!important}
  :is(.module-main,.store-main,.research-main,.civil-main,.architecture-main,.content-main,.emkan-ai-main){width:100%!important;max-width:100%!important;margin-inline:auto!important}
  :is(.category-grid,.store-grid,.projects-grid,.research-grid,.civil-entry-grid,.v49-grid,.v49-work-grid){width:100%!important;max-width:100%!important}
  :is(.category-card,.store-card,.project-card,.gallery-item,.v49-card){max-width:100%!important}
}

@media (max-width:640px){
  :root{--emkan-safe-inline:16px;--emkan-safe-block:18px}
  body{font-size:clamp(14px,3.8vw,16px)}
  :is(.page-shell,.site-shell,.module-shell,.content-shell,.store-shell,.research-shell,.civil-shell,.architecture-shell){padding-inline:16px!important}
  :is(.module-main,.store-main,.research-main,.civil-main,.architecture-main,.content-main,.emkan-ai-main){padding-inline:0!important}
  :is(.category-grid,.store-grid,.projects-grid,.research-grid,.civil-entry-grid,.v49-grid,.v49-work-grid){gap:clamp(14px,4vw,20px)!important}
  :is(button,.button,.primary-button,.small-button,input,select,textarea){touch-action:manipulation}
}

@media (max-width:420px){
  :is(.page-shell,.site-shell,.module-shell,.content-shell,.store-shell,.research-shell,.civil-shell,.architecture-shell){padding-inline:14px!important}
}

/* Generic admin-controlled module UI variables. */
html[data-emkan-ui="1"] body{background:var(--emkan-ui-bg,var(--bg))!important}
html[data-emkan-ui="1"] :is(.module-main,.store-main,.research-main,.civil-main,.architecture-main,.content-main,.emkan-ai-main){max-width:var(--emkan-ui-width,none)}
html[data-emkan-ui-hide-header="1"] body>header,html[data-emkan-ui-hide-header="1"] .site-header{display:none!important}
html[data-emkan-ui-hide-breadcrumb="1"] :is(.breadcrumb,.breadcrumbs,.emkan-context-path,.product-context-path,.article-context-bar-v13){display:none!important}
html[data-emkan-ui-hide-intro="1"] :is(.page-intro,.module-intro,.category-intro,.intro-block){display:none!important}
html[data-emkan-ui-hide-search="1"] :is(.search-box,.emkan-search-form,.side-search,.sidebar-search){display:none!important}
html[data-emkan-ui-hide-filters="1"] :is(.filters,.filter-rail,.category-filter,.detail-subcategory-filter,.civil-filter-rail){display:none!important}
html[data-emkan-ui-motion="0"] :is(.gallery-item,.emkan-stagger-card,.emkan-v26-cover,.emkan-v25-cover,.category-card,.store-card,.project-card){animation:none!important;transition:none!important;opacity:1!important;transform:none!important}

html[data-emkan-ui-spacing="compact"] :is(.category-grid,.store-grid,.projects-grid,.research-grid,.civil-entry-grid,.v49-grid,.v49-work-grid){gap:clamp(10px,1.6vw,18px)!important}
html[data-emkan-ui-spacing="wide"] :is(.category-grid,.store-grid,.projects-grid,.research-grid,.civil-entry-grid,.v49-grid,.v49-work-grid){gap:clamp(22px,3vw,38px)!important}
@supports(padding:max(0px)){@media(max-width:900px){body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}}}
/* Optional admin-selected palette. It is inactive until a value is explicitly configured. */
html[data-emkan-ui-text-color="1"] body{color:var(--emkan-ui-fg)!important}
html[data-emkan-ui-text-color="1"] :is(p,li,dd,dt,label,input,textarea,select,button){color:inherit}
html[data-emkan-ui-accent="1"] :is(a:hover,button:hover,.is-active,.is-current){--accent:var(--emkan-ui-accent);--brand-accent:var(--emkan-ui-accent)}
html[data-emkan-ui-motion-speed="slow"]{--emkan-cover-duration:1600ms;--emkan-cover-step:220ms}
html[data-emkan-ui-motion-speed="fast"]{--emkan-cover-duration:880ms;--emkan-cover-step:120ms}
