/*
 * rabex-fixes.css — targeted front-end fixes, loaded after style.css.
 * style.css is left untouched. Each block maps to a reported issue (docs/WORK-2026-10.md).
 */

/* ===== Issue 1: consistent, symmetric page gutters on tablet & mobile =====
 * style.css sets .container padding to 30px at tablet widths and gives
 * .container_single__rabex a left-only padding (asymmetric in RTL). */
@media (max-width: 1024px) {
    .container { padding-left: 20px; padding-right: 20px; }
    .container_single__rabex { padding-left: 15px; padding-right: 15px; }
}
@media (max-width: 575px) {
    .container { padding-left: 16px; padding-right: 16px; }
    /* Single-post page on phones: the SECTION carried a 30px side padding and the
       inner container another 16px, so items landed at 30-46px and unevenly. Put
       a single 16px gutter on the section, make the container full-width with NO
       side padding, so every item (image, title, category, body) lines up at 16. */
    .rabex_single_post_container { padding-left: 16px; padding-right: 16px; }
    .container_single__rabex {
        max-width: none;
        width: auto;
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }
    /* Header search box: style.css sets width:calc(100% - 60px) centered at <=991,
       i.e. a 30px gutter; bring it to the 16px page gutter on phones. */
    .search_in_rabex { width: calc(100% - 32px); }
    /* Table-of-contents box: at <=991 it is calc(100% - 60px) centered, but it now
       sits INSIDE the already-16px content column, so its edge landed at ~46px.
       Fill the column so the box edge lines up at 16px like every other item. */
    .rabex_single_post__tbl_contents {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        /* style.css pads the box 14px 45px on phones; 45px inner padding is a lot
           on a full-width box, so bring the horizontal padding down to 16px too. */
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* Newsletter (footer): below 992px the form stacks to a column and the submit
   button is width:100%, but the email input kept its desktop fixed 348px width
   (min/max-width:348), so it sat 32px from the edges while the button sat at 16.
   Let the input fill the form like the button so their edges line up. */
@media (max-width: 991px) {
    .newletter_rabex input {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
}

/* ===== Issue 2: table of contents =====
 * 2a (desktop): style.css gives each item line-height:41px (huge) and no gap
 * between items, and the bullet is anchored for that height. Tighten the line,
 * add a real gap BETWEEN headings, and re-anchor the dot to the first line. */
.rabex_single_post__tbl_contents__body li {
    line-height: 1.7;
    margin-bottom: 14px;
}
.rabex_single_post__tbl_contents__body li:last-child { margin-bottom: 0; }
.rabex_single_post__tbl_contents__body li::before {
    top: 10px;            /* was 16px, tuned for the old 41px line-height */
    flex: 0 0 auto;
}

/* 2b (mobile): collapse the list by default; the tap handler on the head
 * (scripts.js: toggleClass('open') + slideToggle) opens it. */
@media (max-width: 991px) {
    .rabex_single_post__tbl_contents__body { display: none; }
    .rabex_single_post__tbl_contents.open .rabex_single_post__tbl_contents__body { display: block; }
}

/* ===== Issue 3: unified, unambiguous star rating (rabex_rating_stars()) =====
 * Five identical stars; filled (is-on) up to the rating. The page is RTL, so the
 * first star in source order sits on the right -> it fills from the right. */
.rabex_rating { display: inline-flex; align-items: center; gap: 8px; }
.rabex_rating_num { font-weight: 500; font-size: 16px; color: #113355; white-space: nowrap; }
.rabex_rating_stars { display: inline-flex; flex-direction: row; gap: 3px; }
.rabex_rating .rabex_star path { stroke: #c7ced8; stroke-width: 1.5; fill: none; }
.rabex_rating .rabex_star.is-on path { fill: #f5a623; stroke: #f5a623; }
.rabex_mobile_star_rating .rabex_rating_num { font-size: 14px; }
.rabex_mobile_star_rating .rabex_star { width: 16px; height: 16px; }

/* ===== Issue 1b: no horizontal (left/right) scroll on phones & tablets =====
 * Something spills past the viewport on small screens; keep everything inside it
 * and make wide media fit instead of forcing a sideways scroll. */
@media (max-width: 991px) {
    /* clip (not hidden) avoids shifting the page or breaking position:sticky */
    body { overflow-x: clip; }
    img, iframe, video, table, .swiper { max-width: 100%; }
}

/* ===== Issue 3b: on mobile, move the star rating onto its own line BELOW the
 * meta (level/reading-time/date). The .rabex_post_details flex row is too wide
 * for a phone, so the stars were clipped; stack it vertically instead. */
@media (max-width: 991px) {
    .rabex_post_details { flex-direction: column; align-items: flex-start; gap: 10px; }
    .rabex_post_details__left { width: 100%; }
    .rabex_post_details__left .rabex_mobile_star_rating { justify-content: flex-start; }
}

/* ===== Issue 1c: article/video CARD images fill the card =====
 * the_post_thumbnail([350,217]) renders a fixed 350px-wide image, so inside the
 * full-width RTL card it left a gap on the left and didn't fill the card (on every
 * width). Make the card image fill the card; thumbnails vary in height, so fix a
 * single aspect-ratio with object-fit:cover to keep cards equal height. The srcset
 * includes a 742w source, so stretching to the card width stays crisp.
 * Covers articles/videos archives, the home page, categories and the related-posts
 * strip (all use inc/post.php / inc/video.php). The big single-post image
 * (.attachment-730x380) and the small tops/search thumbs are untouched. */
img.attachment-350x217,
img.size-350x217 {
    width: 100%;
    height: auto;
    aspect-ratio: 350 / 217;
    object-fit: cover;
    display: block;
}

/* --- Goftino chat button overlaps content on phones (same widget as news):
       scale the fixed 80x80 #goftino_w down so it covers less content. Kept,
       not hidden; icon scales with it so nothing is clipped. --- */
@media screen and (max-width: 575px) {
    #goftino_w.goftino-wakeup,
    #goftino_w {
        transform: scale(0.65) !important;
        transform-origin: bottom left !important;
    }
}

/* Interactive rating: rating.js fills stars 1..N via .on (hover and persisted).
   Each star is wrapped in a .rbx-rate-cell with its 1-5 number so the score is
   clear on mobile; the whole cell is the tap target. */
/* match the news palette: empty = light-grey outline, filled = solid orange */
.rabex_star_rate .rating_star_rabex path { stroke: #BBC3CD; }
.rabex_star_rate .rating_star_rabex.on,
.rabex_star_rate .rating_star_rabex.selected { fill: #FFA200; }
.rabex_star_rate .rating_star_rabex.on path,
.rabex_star_rate .rating_star_rabex.selected path { stroke: #FFA200; }
.rating_star_rabex { outline: none; cursor: pointer; }
.rating_star_rabex:focus-visible { outline: 2px solid #0052FF; outline-offset: 2px; border-radius: 3px; }
.rabex_star_rate .rbx-rate-cell {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-right: 9px;
    cursor: pointer;
}
.rabex_star_rate .rbx-rate-cell svg.rating_star_rabex { margin-right: 0; }
.rabex_star_rate .rbx-rate-num {
    font-size: 11px;
    line-height: 1;
    margin-top: 3px;
    font-weight: bold;
    color: #BBC3CD;
    user-select: none;
}
.rabex_star_rate .rbx-rate-cell:has(.rating_star_rabex.on) .rbx-rate-num,
.rabex_star_rate .rbx-rate-cell:has(.rating_star_rabex.selected) .rbx-rate-num { color: #FFA200; }

/* Header account name (shown instead of the login button when signed in via SSO).
   The login button is a fixed 124px (92px on phones) box sized for "ورود به رابکس",
   so a full name wraps to two lines. Let the name variant size to one line, centred,
   with an ellipsis if it is very long. */
.rabex_login.rabex_account_name {
    display: inline-block;
    width: auto;
    max-width: 170px;
    height: 42px;
    line-height: 42px;
    padding: 0 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}
@media screen and (max-width: 991px) {
    .rabex_login.rabex_account_name {
        max-width: 150px;
        height: 40px;
        line-height: 40px;
        font-size: 13px;
        padding: 0 12px;
    }
}

/* ===== Prototype: [smartslider3] rendered with the theme's Swiper =====
   (functions/smartslider-swiper.php). Centred, max-width from the slider; prev/next arrows
   (white on a dark box, orange on hover); no bullets — matching the original sliders. */
.rbx-ss-swiper { position: relative; margin: 18px auto; }
.rbx-ss-swiper .swiper-slide img { display: block; width: 100%; height: auto; border-radius: 8px; }
.rbx-ss-swiper .rbx-ss-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
    width: 30px; height: 46px; padding: 0; border: 0; cursor: pointer;
    background-color: rgba(0, 0, 0, .7); border-radius: 4px;
    background-repeat: no-repeat; background-position: center; background-size: 42%;
    transition: background-color .15s ease;
}
.rbx-ss-swiper .rbx-ss-nav:hover { background-color: #FF9139; }
.rbx-ss-swiper .rbx-ss-prev { right: 8px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E"); }
.rbx-ss-swiper .rbx-ss-next { left: 8px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 6l-6 6 6 6'/%3E%3C/svg%3E"); }
.rbx-ss-swiper .swiper-button-disabled { opacity: .35; cursor: default; }
