/* ===============================================================
   fa.css — the Farsi / RTL layer.
   Loaded ONLY under /fa (and Farsi articles), after style.css, so
   equal-specificity rules here win by order. No lang attributes:
   everything RTL is handled in CSS, keyed off body.fa.
   Columns keep their positions (article left, sidebar right) —
   only direction/typography flips.
   =============================================================== */

/* Farsi body type */
body.fa {
    font-family: 'Pelak', 'Tiempos Text', Georgia, serif;
}

/* ---- header: mirrored — logo right, menus left ---- */
body.fa > header {
    direction: rtl;
}

body.fa > header nav[aria-label="primary"] li a {
    /* type only — the box metrics (line-height: 0 + paddings) must stay
       identical to the English side: the top strip height, the underline
       offset and the secondary nav position are all measured from this
       nav's height */
    font-family: 'Pelak';
    font-weight: 600;
    font-size: 18px;
}

/* the logo keeps its English wording, but the lockup mirrors: the
   RTL header puts the mark (order:-1) in the far-right column and the
   texts to its left; right-aligning the texts makes Albert/Bootesaz
   and the tagline hug the mark */
body.fa > header > a {
    text-align: right;
}

@media (max-width: 844px) {
    /* hamburger moves to the LEFT — the logo owns the right side now */
    body.fa .nav-toggle {
        right: auto;
        left: clamp(20px, 8vw, 36px);
    }

    /* drop the portrait slightly so the (right-side) logo clears his head */
    body.fa.home > main > section:first-of-type > article:first-of-type > figure {
        top: 45px;
    }
}

/* language switcher strip */
body.fa > header > div nav a {
    font-family: 'Tiempos Text', Georgia, serif;
}

/* ---- secondary nav (social chips): under the MENUS — which sit on
   the left on the Farsi side — instead of colliding with the logo ---- */
body.fa > nav[aria-label="secondary"] :is(ol, ul) {
    grid-column: 1;
    justify-self: start;
}

/* ---- mobile overlay menu ---- */
body.fa .m-menu {
    direction: rtl;
}
body.fa .m-links a {
    font-family: 'Pelak';
    font-weight: 700;
    direction: rtl;
}
body.fa .m-lang {
    font-family: 'Tiempos Text', Georgia, serif;
}

/* ---- home hero (Farsi copy in the same position) ---- */
body.fa.home > main > section:first-of-type > article:first-of-type > header hgroup :is(h1, h2, h3) {
    direction: rtl;
    text-align: right;
    font-family: 'Pelak';
}
body.fa.home > main > section:first-of-type > article:first-of-type > header hgroup > h1 {
    font-weight: 400;
}
body.fa.home > main > section:first-of-type > article:first-of-type > header hgroup > h2.highlight {
    font-weight: 600;
    line-height: 1.9;
}

/* ---- home diagonal: lead + headline list, RTL ---- */
body.fa.home > main > section article.diagonal > section {
    direction: rtl;

    & article > header h2,
    & article > header h2 a {
        font-family: 'Pelak';
        font-weight: 800;
        line-height: 1.6;
    }

    & article > header p {
        font-family: 'Pelak';
        font-style: normal;
    }

    & article > p {
        font-family: 'Pelak';
        line-height: 1.9;

        & a {
            font-family: 'Pelak';
            font-style: normal;
            margin-left: 0;
            margin-right: 10px;
        }
    }
}

/* ---- inner pages: article column + sidebar stay put, text flips ---- */
body.fa > main > section > article.diagonal > div,
body.fa > main > section > article.diagonal > aside,
body.fa > main > section > article.diagonal > section.subscribe {
    direction: rtl;
}

/* page/article title on the band */
body.fa > main > section > article.diagonal > div > header h2 {
    font-family: 'Pelak';
    font-weight: 900;
    line-height: 1.7;
}

/* byline */
body.fa > main > section > article.diagonal > div > header p {
    font-family: 'Pelak';
    font-style: normal;

    & span {
        float: left;          /* author moves to the far side in RTL */
    }
}

/* article body */
body.fa > main > section > article.diagonal > div > p {
    font-family: 'Pelak';
    line-height: 2;

    & > a {
        font-family: 'Pelak';
        font-style: normal;
        margin-left: 0;
        margin-right: 10px;
    }
}

/* ---- breadcrumbs ---- */
body.fa nav.breadcrumbs {
    direction: rtl;
    font-family: 'Pelak';

    & li {
        font-style: normal;
    }

    & li + li::before {
        margin-right: 0;
        margin-left: 8px;
        transform: scaleX(-1);
        display: inline-block;
    }
}

/* ---- results list (search / archive / مقالات) ---- */
body.fa > main > section > article.diagonal > div > section.results > article {
    & > header > p {
        font-family: 'Pelak';
        font-style: normal;
    }

    & > header h2 a {
        font-family: 'Pelak';
        font-weight: 800;
        line-height: 1.7;
    }

    & > p {
        font-family: 'Pelak';
        line-height: 1.9;

        & > a {
            font-family: 'Pelak';
            font-style: normal;
            margin-left: 0;
            margin-right: 8px;
        }
    }
}

/* ---- sidebar widgets ---- */
body.fa > main > section > article.diagonal > aside {
    & h3 {
        font-family: 'Pelak';
        font-weight: 800;
        background-position: 100% 100%;   /* the yellow bar hugs the right */
    }

    & > section.latest-articles article {
        & header > p {
            font-family: 'Pelak';
            font-style: normal;
        }

        & h2 a {
            font-family: 'Pelak';
            font-weight: 700;
            line-height: 1.8;
        }
    }

    & > section.latest-videos article {
        direction: rtl;

        & time,
        & header > a.watch {
            font-family: 'Pelak';
            font-style: normal;
            direction: rtl;
        }
    }

    & > section.search > form > input {
        font-family: 'Pelak';
        border-right: 1px solid #555555;
        border-left: 0;
        border-radius: 0 6px 6px 0;
    }

    & > section.search > form > button {
        font-family: 'Pelak';
        border-radius: 6px 0 0 6px;
    }
}

/* ---- videos page playlist ---- */
body.fa > main > section > article.diagonal > div > section.videos > article {
    & > header time,
    & > p > a {
        font-family: 'Pelak';
        font-style: normal;
    }
}

/* ---- share bar ---- */
body.fa .social-media {
    direction: rtl;

    &::before {
        right: auto;
        left: 10px;
        font-family: 'Pelak';
        font-style: normal;
    }
}

/* ---- subscribe card ---- */
body.fa > main section.subscribe,
body.fa > main > section.subscribe {
    direction: rtl;

    & > h2 {
        font-family: 'Pelak';
        font-weight: 800;
    }

    & > p {
        font-family: 'Pelak';
        line-height: 1.9;
    }

    & > form > input {
        font-family: 'Pelak';
        direction: rtl;
        border-right: 2px solid #555555;
        border-left: 0;
        border-radius: 0 8px 8px 0;
    }

    & > form > button {
        font-family: 'Pelak';
        border-radius: 8px 0 0 8px;
    }
}

/* ---- contact form ---- */
body.fa form.contact-form {
    & > input,
    & > textarea,
    & > button {
        font-family: 'Pelak';
        direction: rtl;
    }

    & > button {
        justify-self: start;    /* start = right in RTL */
    }
}

body.fa > main > section > article.diagonal > div > address a {
    font-family: 'Tiempos Headline', Georgia, serif;   /* the email stays latin */
    direction: ltr;
    display: inline-block;
}

/* ---- pagination ---- */
body.fa nav.pagination {
    direction: rtl;

    & > a,
    & > span {
        font-family: 'Pelak';
    }
}

/* ---- footer ---- */
body.fa > footer .ft-inner {
    direction: rtl;
}
body.fa > footer .ft-nav {
    font-family: 'Pelak';
    font-size: 18px;
}
body.fa > footer .ft-brand {
    direction: ltr;             /* latin lockup */
    text-align: right;
}
body.fa > footer .ft-side {
    justify-items: start;       /* start = left edge kept, mirrors cleanly */
}
body.fa > footer .ft-lang {
    font-family: 'Tiempos Text', Georgia, serif;
}
body.fa > footer .ft-bottom {
    direction: rtl;
    font-family: 'Pelak';
}

/* footer two-column mobile layout keeps menus/socials mirrored */
@media (max-width: 844px) {
    body.fa > footer .ft-nav  { grid-column: 1; }
    body.fa > footer .ft-side { grid-column: 2; }
}


/* ---- subscribe card inside the diagonal (single articles, inner pages):
   mirrored corners must out-rank style.css's inner-page rules ---- */
body.fa > main > section > article.diagonal > section.subscribe > form > input {
    direction: rtl;
    font-family: 'Pelak';
    border: 2px solid #555555;
    border-left: 0;
    border-radius: 0 8px 8px 0;
}
body.fa > main > section > article.diagonal > section.subscribe > form > input:focus {
    border-color: #0065b3;
}
body.fa > main > section > article.diagonal > section.subscribe > form > button {
    font-family: 'Pelak';
    border-radius: 8px 0 0 8px;
}


/* ---- menu underline spans the full item width on the Farsi side ---- */
body.fa > header nav :is(ol, ul) li a::after {
    max-width: 100%;
    left: 0;
}

/* ---- the language switcher shows a U.S. flag (same size as the
   persian flag on the English side) ---- */
body.fa > header nav:not([aria-label="primary"]) a::before {
    background: url(images/us-icon.svg) center / cover no-repeat;
    border-radius: 2px;
}
