/*
 * Platform adjustments over the verbatim espadanbattery.com sheets (base.css, shell.css, ...).
 *
 * 1. Design tokens. The source hard-codes its palette; these rules re-express the page-level colors
 *    and the body font through --esp-* custom properties that the theme settings emit, so an
 *    admin's choice actually takes effect. Every fallback is the source value, so with default
 *    settings the computed styles are identical. Each rule carries one extra level of specificity
 *    (html ...) instead of relying on load order.
 * 2. Replacements for inline styles the source used and the CSP forbids.
 */

html body,
html {
    background-color: var(--esp-bg, #1a1a1a);
    font-family: var(--esp-font, iranYekanX);
}

html body {
    color: var(--esp-text, #fff);
}

html a {
    color: var(--esp-link, #fff5d1);
}

html a:hover {
    color: var(--esp-link-hover, #00ae4d);
}

html .btn-garantie {
    background: linear-gradient(var(--esp-bg, #1a1a1a), var(--esp-bg, #1a1a1a)) padding-box,
        linear-gradient(135deg, var(--esp-accent-start, #009441), var(--esp-accent-end, #d6ab04)) border-box;
}

html .primaryButton {
    background: linear-gradient(var(--esp-bg, #1a1a1a), var(--esp-bg, #1a1a1a)) padding-box,
        linear-gradient(135deg, var(--esp-accent-start, #009441), var(--esp-accent-end, #d6ab04)) border-box;
}

/*
 * 1b. Typography. The platform's site-typography sheet (/site-assets/theme.css and its inline tokens,
 *     emitted after the theme) re-sets body, headings and .btn — line-height 1.85, navy headings,
 *     rounded buttons. With the theme setting «فونت متن = فونت سایت اصلی» the layout adds
 *     .esp-typo-reference to <body> and these rules restore the source's values. Each is exactly one
 *     element above the platform's selector (html … / :where() adds nothing), so the source's own
 *     class-based rules still win over them.
 */
html body:where(.esp-typo-reference) {
    font-size: 1rem;
    font-weight: 400;
    line-height: var(--bs-body-line-height, 1.5);
    letter-spacing: normal;
}

html :where(.esp-typo-reference) :is(h1, h2, h3, h4, h5, h6) {
    color: inherit;
    font-family: inherit;
    letter-spacing: normal;
    text-transform: none;
}

/* Verbatim from base.css, re-asserted over the platform's heading sizes. */
html :where(.esp-typo-reference) h1 { font-size: calc(34px + 1.875vw); line-height: 1.1; font-weight: 600; text-transform: capitalize; }
html :where(.esp-typo-reference) h2 { font-size: calc(20.8px + .375vw); line-height: 1; font-weight: 600; text-transform: capitalize; }
html :where(.esp-typo-reference) h3 { font-size: calc(15.2px + .25vw); font-weight: 500; line-height: 1.2; }
html :where(.esp-typo-reference) h4 { font-size: calc(16.8px + .0625vw); font-weight: 400; line-height: 1.2; }
html :where(.esp-typo-reference) h5 { font-size: calc(14.8px + .0625vw); font-weight: 400; line-height: 1.2; }
html :where(.esp-typo-reference) h6 { font-size: calc(12.8px + .0625vw); font-weight: 400; line-height: 1.2; }

/* Bootstrap's own button radius and base.css's button type scale, over the platform's .btn tokens. */
html :where(.esp-typo-reference) .btn {
    border-radius: var(--bs-btn-border-radius);
    font-family: inherit;
    font-size: calc(13.2px + .25vw);
    font-weight: 500;
    line-height: var(--bs-btn-line-height);
    letter-spacing: normal;
    text-transform: none;
}

html :where(.esp-typo-reference) .btn-md { font-size: calc(13.6px + .125vw); }
html :where(.esp-typo-reference) .btn-sm { font-size: 14px; }
html :where(.esp-typo-reference) .btn-2 { font-size: calc(13.2px + .25vw); font-weight: 400; }

/* Source: <img src="/images/Logo.png" style="width:40%"> */
html .headerContainer .esp-header-logo {
    width: var(--esp-logo-width, 40%);
}

/* The search field of the source dialog was a bare input; the form wrapper must not add spacing. */
html .modal-content-special form {
    margin: 0;
}

/*
 * 3. Page-builder wrappers. The installed pages rebuild the source's plain wrapper divs
 *    (.container > .aboutContainer > …) as builder sections and containers carrying the same
 *    classes. These rules make those wrappers behave like the source's plain divs again.
 */

/* Source: a plain <div class="xxxContainer">; the builder's flex column, gap and gutters are not part of it. */
.esp-site .poshesh-builder-page .poshesh-container.esp-flow {
    display: block;
    max-width: none;
    margin-inline: 0;
    padding-inline: 0;
    gap: 0;
}

/* Source: <div class="garantiContainer"><div class="row …">; the container is that row. */
.esp-site .poshesh-builder-page .poshesh-container.esp-row {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: none;
    padding-inline: 0;
    gap: 0;
}

/* The builder clips its page box; the source did not (focus rings and hover shadows overflow). */
.esp-site .poshesh-builder-page {
    overflow: visible;
}

/* Bootstrap's own stepped container widths, which the builder replaces with one --pbx-container. */
@media (min-width: 576px) {
    .esp-site .poshesh-builder-page .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .esp-site .poshesh-builder-page .container { max-width: 720px; }
}

@media (min-width: 992px) {
    .esp-site .poshesh-builder-page .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .esp-site .poshesh-builder-page .container { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .esp-site .poshesh-builder-page .container { max-width: 1320px; }
}

/* The platform's rounded builder fields (.poshesh-builder-page input) lose to the source's own
   .garantiContainer .form-control rule on specificity, so no override is needed here. */

/* Source: <img id="dntCaptchaImg" style="margin-bottom: 4px;"> */
.esp-site .garantiContainer .inputContainer #dntCaptchaImg {
    margin-bottom: 4px;
}

/* Source: the inner layout's (_Inner.cshtml) <style>.product-box img { min-height: 211px }</style>.
   Without it the product pictures keep their own ratio and every card on /products is shorter. */
.esp-site .product-box img {
    min-height: 211px;
}

/*
 * 4. Deliberate fixes of source layout bugs (each one scrolled the page sideways on espadanbattery.com too).
 */

/* The article's featured picture kept its natural width inside a col-md-4 column, so it ran past the
   page edge (11px at 1440, 137px on a phone with the 500px placeholder; a real photo goes much further). */
.esp-site .branchMap .esp-article-image {
    max-width: 100%;
    height: auto;
}

/* The divider between the warranty form and its picture sits 40px left of the form. Once the two
   columns stack (below md) it is off-screen and only adds horizontal scroll. */
@media (max-width: 767.98px) {
    .esp-site .garantiContainer .inputContainer:before {
        display: none;
    }
}
