/* Final responsive layer. Kept separate so page-specific styles stay small and predictable. */
:root {
  --mra-mobile-gutter: 12px;
  --mra-tablet-gutter: 16px;
  --mra-touch-target: 44px;
}

html { overflow-x: clip; }
body { min-width: 280px; }
body:not(.mra-sticky-header) .mra-header { position: relative; inset-block-start: auto; }
body:not(.mra-sticky-header) { --mra-sticky-offset: var(--mra-adminbar-offset); }

:where(.mra-shell,.mra-main,.mra-home-layout,.mra-commerce-main,.mra-content-layout,.mra-entry-content,.woocommerce,.woocommerce-page) { min-width: 0; }
:where(.mra-header__main,.mra-section-heading,.mra-shop-toolbar,.mra-footer__card,.mra-content-layout,.mra-product-card__meta) > * { min-width: 0; }
:where(table,img,video,iframe,svg) { max-width: 100%; }
:where(.woocommerce table,.mra-prose table) { max-width: 100%; }

/* Make controls comfortable without inflating dense catalog cards. */
:where(.mra-icon-button,.mra-header-action,.mra-carousel__arrow,.mra-mobile-dock a,.mra-mobile-dock button) { touch-action: manipulation; }
@media (pointer: coarse) {
  :where(.mra-button,.wp-element-button,.woocommerce a.button,.woocommerce button.button,.woocommerce input.button,input[type="submit"],button:not(.mra-carousel__dot)) { min-height: var(--mra-touch-target); }
}

/* Cards: compact desktop hover tray, always reachable on touch. */
.mra-product-card__actionbar {
  border: 1px solid rgba(0,0,0,.045);
  box-shadow: 0 5px 18px rgba(0,0,0,.11);
}
.mra-product-card__action + .mra-product-card__action::before { background: #ededed; }
@media (hover: hover) and (pointer: fine) {
  .mra-product-card__actionbar { transition-duration: .24s; }
  .mra-product-card__action:hover { transform: translateY(-1px) scale(1.035); }
}
@media (hover: none), (pointer: coarse) {
  .mra-product-card__actionbar { opacity: 1; pointer-events: auto; transform: none; }
  .mra-product-card__action {
    width: max(40px, min(var(--mra-product-action-size), 44px)) !important;
    min-width: max(40px, min(var(--mra-product-action-size), 44px)) !important;
    height: 40px !important;
    min-height: 40px !important;
  }
  .mra-product-card__action .mra-icon { width: 17px; height: 17px; }
  .mra-product-card__action + .mra-product-card__action::before { inset-block: 10px; }
}

/* Long-form Persian reading is intentionally larger than dense UI text. */
.mra-prose { font-size: 16.5px; line-height: 2.05; }
.mra-prose p, .mra-prose li { text-wrap: pretty; }
.mra-prose :where(p,li,dd,td) { overflow-wrap: break-word; }

/* Carousels own native overflow; JS only handles navigation state. */
[data-mra-carousel-track] { overscroll-behavior-inline: contain; }
.mra-carousel.is-no-overflow .mra-carousel__controls { display: none; }
.mra-carousel__dots:empty { display: none; }
.mra-carousel__arrow:disabled { pointer-events: none; }

/* Wide desktop: keep visual density controlled rather than stretching cards. */
@media (min-width: 1600px) {
  .mra-shell { width: min(calc(100% - 48px), var(--mra-shell)); }
  .mra-main { padding-block-start: 28px; }
}

/* Laptop and smaller desktop. */
@media (max-width: 1240px) {
  :root { --mra-gutter: var(--mra-tablet-gutter); }
  .mra-header__main { gap: 10px; }
  .mra-section-heading { gap: 12px; }
  .mra-footer__card { min-width: 0; }
}

/* Tablet / compact laptop. Header becomes the same predictable compact shell. */
@media (max-width: 1000px) {
  :root { --mra-gutter: var(--mra-tablet-gutter); }
  .mra-header__main { grid-template-columns: 44px minmax(92px,1fr) auto; min-height: 60px; gap: 6px; }
  .mra-header__menu-button { width: 40px; height: 40px; }
  .mra-header__identity { justify-content: center; }
  .mra-header__brand { justify-content: center; }
  .mra-header__actions { gap: 1px; }
  .mra-header-action { width: 40px; min-width: 40px; height: 40px; }
  .mra-search { inset-inline: var(--mra-gutter); }
  .mra-dialog__surface:not(.mra-cart-dialog__surface) { max-height: calc(100dvh - var(--mra-adminbar-offset)); }
  .mra-shop-toolbar { flex-wrap: wrap; }
  .mra-shop-toolbar__actions { margin-inline-start: auto; }
  .woocommerce table.shop_table { width: 100%; }
}

/* Portrait tablets. */
@media (max-width: 840px) {
  .mra-main { padding-block: 16px 32px; }
  .mra-section-heading { margin-bottom: 13px; }
  .mra-section-heading h2 { font-size: clamp(19px,3.3vw,23px); }
  .mra-section-heading p { line-height: 1.8; }
  .mra-quick-view__body { grid-template-columns: minmax(0,.95fr) minmax(0,1.05fr); }
  .mra-quick-view__content { padding: 22px; }
  .mra-content-layout { gap: 22px; }
}

/* Phones and small tablets. */
@media (max-width: 760px) {
  :root { --mra-gutter: var(--mra-mobile-gutter); --mra-header-offset: 60px; }
  body { padding-bottom: 0; }
  body.mra-mobile-dock-enabled { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  .mra-shell { width: min(calc(100% - (var(--mra-mobile-gutter) * 2)), var(--mra-shell)); }
  .mra-main { padding-block: 12px 26px; }
  .mra-page-header { margin-block: 3px 18px; }
  .mra-page-header p,.mra-page-header__description { max-width: 62ch; font-size: 13px; line-height: 1.9; }

  h1 { font-size: clamp(25px,7.1vw,36px); }
  h2 { font-size: clamp(20px,5.45vw,27px); }
  h3 { font-size: clamp(17px,4.7vw,21px); }

  .mra-header { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .mra-header__main { grid-template-columns: 40px minmax(74px,1fr) auto; min-height: 60px; padding-block: 2px; }
  .mra-header__menu-button { width: 40px; height: 40px; }
  .mra-header__actions { gap: 0; }
  .mra-header-action { width: 38px; min-width: 38px; height: 40px; }
  .mra-header-action--account { display: none !important; }
  .mra-brand-logo,.mra-brand-logo__image { width: 46px !important; height: 40px !important; max-width: 46px !important; max-height: 40px !important; }
  .mra-brand-logo { flex-basis: 46px; }
  .custom-logo { max-width: 112px; height: 34px; }

  .mra-search { inset-inline: var(--mra-mobile-gutter); padding: 6px; border-radius: 12px; }
  .mra-search__input { min-height: 44px; font-size: 16px !important; }
  .mra-search-results { max-height: min(60dvh, 520px); }

  .mra-section-heading { align-items: flex-end; gap: 8px; margin-bottom: 12px; }
  .mra-section-heading__copy { flex: 1 1 auto; }
  .mra-section-heading h2 { font-size: 19px; line-height: 1.55; }
  .mra-section-heading p { font-size: 12.5px; line-height: 1.75; }
  .mra-text-link { min-height: 38px; align-items: center; font-size: 12px; }

  .mra-dialog { padding: 0; }
  .mra-dialog__surface { width: min(100%, 430px); max-height: 100dvh; border-radius: 18px 18px 0 0; }
  .mra-quick-view { padding: 7px; }
  .mra-quick-view__surface { width: 100%; max-height: calc(100dvh - 14px); }
  .mra-quick-view__body { grid-template-columns: 1fr; }
  .mra-quick-view__media { min-height: clamp(215px,61vw,315px); max-height: 320px; }
  .mra-quick-view__content { padding: 18px; }
  .mra-quick-view__content p { font-size: 13.5px; }
  .mra-quick-view__actions { margin-top: 15px; }

  .mra-mobile-dock {
    min-height: 62px;
    padding: 4px max(5px,env(safe-area-inset-right)) max(5px,env(safe-area-inset-bottom)) max(5px,env(safe-area-inset-left));
    background: rgba(255,255,255,.99);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 -8px 22px rgba(0,0,0,.055);
  }
  .mra-mobile-dock a,.mra-mobile-dock button { min-height: 50px; border-radius: 10px; font-size: 11px; line-height: 1.3; }
  body:not(.mra-mobile-dock-labels) .mra-mobile-dock span { 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;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important; }
  body:not(.mra-mobile-dock-labels) .mra-mobile-dock .mra-icon { width: 21px; height: 21px; }

  [data-mra-carousel-track] { scroll-snap-type: inline proximity; scroll-padding-inline: 1px; }
  .mra-carousel__controls { min-height: 0; margin-top: 7px; }
  .mra-carousel__dots { gap: 5px; }

  .mra-product-card__content { padding: 9px 9px 10px; }
  .mra-product-card__brand { font-size: 11px; }
  .mra-product-card__title { font-size: max(12.75px,calc(var(--mra-product-title-size) - 1px)) !important; line-height: 1.68 !important; }
  .mra-product-card__price { font-size: max(12.75px,calc(var(--mra-product-price-size) - 1px)); line-height: 1.5; }
  .mra-product-card__actionbar { inset-block-end: 7px; border-radius: 12px; padding-inline: 3px; }

  .mra-prose { font-size: 16px; line-height: 2; }
  .mra-prose table { font-size: 13px; }

  .woocommerce table.shop_table { max-width: 100%; }
  .woocommerce form .form-row input.input-text,.woocommerce form .form-row textarea,.woocommerce form .form-row select { width: 100%; }
  .woocommerce .quantity { max-width: 100%; }
}

/* Narrow phones. Preserve two-column catalog only when the merchant asked for it. */
@media (max-width: 520px) {
  :root { --mra-gutter: var(--mra-mobile-gutter); }
  .mra-header__main { grid-template-columns: 38px minmax(58px,1fr) auto; }
  .mra-header__menu-button { width: 38px; height: 38px; }
  .mra-header-action { width: 36px; min-width: 36px; height: 38px; }
  .mra-header-action .mra-icon { width: 17px; height: 17px; }
  .mra-wishlist-count,.mra-cart-count { inset-block-start: 1px; }
  .mra-section-heading h2 { font-size: 18.5px; }
  .mra-section-heading p { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .mra-product-card__media { min-height: 0; }
  .mra-product-card__meta { gap: 4px; }
  .mra-product-card__rating { font-size: 10.5px; }
  .mra-product-card__badge { font-size: 10px; }
  .mra-footer__bottom { gap: 7px; }
}

/* Very narrow devices still get usable controls and no clipped header. */
@media (max-width: 380px) {
  :root { --mra-gutter: max(8px, var(--mra-mobile-gutter)); }
  .mra-header__main { grid-template-columns: 36px minmax(52px,1fr) auto; gap: 2px; }
  .mra-header-action { width: 34px; min-width: 34px; height: 38px; }
  .mra-header-action--wishlist { display: none; }
  .mra-brand-logo,.mra-brand-logo__image { width: 42px !important; height: 38px !important; max-width: 42px !important; max-height: 38px !important; }
  .mra-brand-logo { flex-basis: 42px; }
  .custom-logo { max-width: 92px; height: 31px; }
  .mra-mobile-dock a,.mra-mobile-dock button { font-size: 10.5px; }
  .mra-product-card__content { padding-inline: 8px; }
  .mra-product-card__action { width: 38px !important; min-width: 38px !important; height: 38px !important; min-height: 38px !important; }
  .mra-prose { font-size: 15.75px; }
}

/* Short landscape phones need screen space more than persistent labels. */
@media (orientation: landscape) and (max-width: 1000px) and (max-height: 520px) {
  :root { --mra-header-offset: 52px; }
  .mra-header__main { min-height: 52px; }
  .mra-header__menu-button,.mra-header-action { height: 38px; }
  body.mra-mobile-dock-enabled.mra-compact-landscape-dock { padding-bottom: calc(50px + env(safe-area-inset-bottom)); }
  body.mra-compact-landscape-dock .mra-mobile-dock { min-height: 48px; padding-block: 2px max(2px,env(safe-area-inset-bottom)); }
  body.mra-compact-landscape-dock .mra-mobile-dock a,
  body.mra-compact-landscape-dock .mra-mobile-dock button { min-height: 44px; gap: 0; }
  body.mra-compact-landscape-dock .mra-mobile-dock span { 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;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important; }
  body.mra-compact-landscape-dock .mra-mobile-dock .mra-icon { width: 20px; height: 20px; }
  .mra-dialog__surface { max-height: calc(100dvh - 8px); }
}

/* Avoid expensive decorative effects when the user/device asks for less. */
@media (prefers-reduced-motion: reduce) {
  .mra-product-card:hover,.mra-product-card__action:hover,.mra-carousel__arrow:hover { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .mra-header,.mra-mobile-dock { backdrop-filter: none; -webkit-backdrop-filter: none; background: #fff; }
}

/* Product layout guard: the final layer owns the sub-900px grid so earlier
   page rules cannot leave an unused second column. */
@media (max-width: 900px) {
  .single-product .mra-product-top {
    grid-template-columns: minmax(0,1fr) !important;
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
  }
  .single-product .mra-product-top > .mra-product-media {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: min(100%,560px) !important;
    max-width: 560px;
    margin-inline: auto !important;
  }
  .single-product .mra-product-top > .summary {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
  }
  .single-product .mra-product-top > :not(.mra-product-media):not(.summary) {
    grid-column: 1 / -1 !important;
  }
}

/* A short landscape phone has enough inline room for media + buying details.
   Using both columns avoids a long, narrow strip and keeps the primary action
   visible without sacrificing readable line lengths. */
@media (orientation: landscape) and (max-width: 900px) and (max-height: 520px) {
  .single-product .mra-product-top {
    grid-template-columns: minmax(250px,.88fr) minmax(310px,1.12fr) !important;
    max-width: none;
    gap: 12px !important;
    align-items: start;
  }
  .single-product .mra-product-top > .mra-product-media {
    grid-column: 1 !important;
    grid-row: 1 !important;
    max-width: none;
  }
  .single-product .mra-product-top > .summary {
    grid-column: 2 !important;
    grid-row: 1 !important;
    max-width: none;
    gap: 10px !important;
  }
  .single-product .mra-product-top > :not(.mra-product-media):not(.summary) {
    grid-column: 1 / -1 !important;
  }
  .single-product .mra-product-info,
  .single-product .mra-product-purchase { padding: 13px; }
  .single-product .product_title { font-size: clamp(18px,2.8vw,21px) !important; }
  .single-product .woocommerce-product-details__short-description { font-size: 13.5px; line-height: 1.85; }
  .single-product .mra-product-highlights { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.mra-mobile-dock-enabled .mra-sticky-buy {
    inset-block-end: calc(48px + env(safe-area-inset-bottom));
  }
}

body.mra-mobile-dock-enabled { scroll-padding-bottom: calc(74px + env(safe-area-inset-bottom)); }

/* Midora 1.14 — predictable responsive interaction layer */
.mra-header{z-index:var(--mra-z-sticky)!important;}
.mra-category-menu__panel{z-index:var(--mra-z-dropdown)!important;}
.mra-mobile-dock{z-index:var(--mra-z-dock)!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;background:rgba(255,255,255,.98)!important;}
@media(max-width:760px){
  .mra-dialog__surface{width:min(100%,430px)!important;}
  .mra-product-card__action--quick{display:none!important;}
}
@media(max-width:430px){
  .mra-auth-form__meta{align-items:flex-start;flex-direction:column;gap:6px;}
}

/* Midora mobile dock: five high-value destinations ------------------------ */
@media(max-width:1080px){
  .mra-mobile-dock{grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);}
  .mra-mobile-dock a,.mra-mobile-dock button{position:relative;min-width:0;padding-inline:2px;}
  .mra-mobile-dock__count{position:absolute;inset-block-start:3px;inset-inline-start:calc(50% + 6px);min-width:16px;height:16px;display:grid;place-items:center;padding-inline:3px;border:2px solid #fff;border-radius:999px;background:var(--mra-accent);color:#fff;font-size:9px;font-weight:800;line-height:1;}
  .mra-mobile-dock__count[data-count="0"]{display:none;}
}

/* Midora 1.21 compact header -------------------------------------------------
   Equal side columns keep the brand mathematically centered even when the
   action cluster is wider than the menu button. Search remains an overlay and
   therefore never steals a grid column. */
@media (max-width:1000px){
  .mra-header__main{
    direction:ltr;
    grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)!important;
    grid-template-areas:"actions brand menu";
    column-gap:6px!important;
  }
  .mra-header__menu-button{
    grid-area:menu;
    justify-self:end;
    direction:rtl;
  }
  .mra-header__identity{
    grid-area:brand;
    justify-self:center;
    width:max-content;
    max-width:100%;
    direction:rtl;
  }
  .mra-header__actions{
    grid-area:actions;
    justify-self:start;
    justify-content:flex-start;
    min-width:0;
    direction:rtl;
  }
  .mra-search{direction:rtl}
}

/* WordPress switches the mobile admin bar to an absolute bar on narrow
   screens. The document already reserves its initial height, so a permanent
   46px sticky offset would leave a visible gap after scrolling. */
@media (max-width:600px){
  body.admin-bar{--mra-adminbar-offset:0px}
}


/* Midora 1.28.3 — compact header utilities and monochrome mobile navigation.
   The menu stays on the physical right; shipment and search sit between it
   and the centered brand. Desktop header and order tracking remain unchanged. */
@media (max-width: 1000px) {
  .mra-header__mobile-tools {
    grid-area: menu;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-self: end;
    justify-content: flex-start;
    direction: rtl;
    gap: 1px;
    min-width: 0;
  }
  .mra-header__mobile-tools .mra-header__menu-button {
    grid-area: auto;
    justify-self: auto;
    flex: none;
    border: 0;
    background: transparent;
    color: #181818;
  }
  .mra-header__mobile-tools .mra-header__mobile-action {
    display: grid;
    flex: none;
    place-items: center;
    min-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: #181818;
  }
  .mra-header__mobile-tools .mra-icon { width: 19px; height: 19px; }
  .mra-header__mobile-tools :is(button:hover, button:focus-visible) {
    color: #111;
    background: #f1f1f1;
  }
  /* A single visible control per action, avoiding duplicate keyboard targets. */
  .mra-header__actions .mra-header-action--search,
  .mra-header__actions > .ztom-header-action.mra-header-action { display: none; }
  .mra-header__mobile-tools button:focus-visible,
  .mra-mobile-dock :is(a,button):focus-visible {
    outline: 2px solid #202020;
    outline-offset: 2px;
  }
}
@media (max-width: 520px) {
  .mra-header__mobile-tools { gap: 0; }
  .mra-header__mobile-tools .mra-header__mobile-action {
    width: 36px;
    min-width: 36px;
    height: 40px;
  }
  .mra-header__mobile-tools .mra-icon { width: 18px; height: 18px; }
}
@media (max-width: 380px) {
  .mra-header__mobile-tools .mra-header__mobile-action {
    width: 34px;
    min-width: 34px;
    height: 38px;
  }
}
@media (max-width: 1000px) {
  /* Overrides the Order Manager plugin's accent-color dock rule without
     changing the styling of the tracking dialog or desktop actions. */
  body .mra-mobile-dock :is(a, button),
  body .mra-mobile-dock .ztom-dock-tracking {
    color: #191919;
  }
  body .mra-mobile-dock :is(a,button) :is(.mra-icon, span) {
    color: inherit;
  }
  body .mra-mobile-dock :is(a,button):is(:hover,:focus-visible) {
    color: #080808;
    background: #f4f4f4;
  }
  body .mra-mobile-dock .mra-mobile-dock__count {
    background: #202020;
    color: #fff;
  }
}
