/*
 * «ترند هفته» box and the prev/next cards under an article, loaded by
 * src/Base/PopularityAssets.php on the homepage and on single posts.
 *
 * Hand-written: the compiled Tailwind stylesheet cannot be rebuilt here.
 * Light values are the theme's own greys (gray-700 55 59 79, gray-400
 * 128 133 158, gray-50 242 244 250, primary 0 203 140); dark values reuse the
 * --arz-c-* channels from theme-mode.css.
 */

/* ---------------------------------------------------------------- Trending */

.arz-trend__flame {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    background: currentColor;
    color: rgb(0 203 140);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M13.5 2c.4 3.2-1.1 5-2.6 6.6C9.4 10.2 8 11.7 8 14a4 4 0 0 0 8 0c0-1-.4-1.9-1-2.7.9.2 1.7.6 2.3 1.2A7 7 0 1 1 5 14c0-3.4 2-5.4 3.9-7.3C10.3 5.3 11.6 4 12 2h1.5Z'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M13.5 2c.4 3.2-1.1 5-2.6 6.6C9.4 10.2 8 11.7 8 14a4 4 0 0 0 8 0c0-1-.4-1.9-1-2.7.9.2 1.7.6 2.3 1.2A7 7 0 1 1 5 14c0-3.4 2-5.4 3.9-7.3C10.3 5.3 11.6 4 12 2h1.5Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.arz-trend__list {
    list-style: none;
    margin: 0;
    padding: .5rem 1rem 1rem;
    width: 100%;
    counter-reset: none;
}

.arz-trend__item + .arz-trend__item {
    border-block-start: 1px solid rgb(242 244 250);
}

.arz-trend__link {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 56px;              /* tap target well above 40px */
    padding: .625rem 0;
    color: rgb(55 59 79);
    text-decoration: none;
    transition: color .2s ease;
}

.arz-trend__link:hover,
.arz-trend__link:focus-visible {
    color: rgb(0 203 140);
}

.arz-trend__rank {
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    font-weight: 700;
    line-height: 1;
    background: rgb(242 244 250);
    color: rgb(55 59 79);
}

/* The top three carry the brand green, fading as the rank drops. */
.arz-trend__item:nth-child(1) .arz-trend__rank { background: rgb(0 203 140); color: #fff; }
.arz-trend__item:nth-child(2) .arz-trend__rank { background: rgb(0 203 140 / .75); color: #fff; }
.arz-trend__item:nth-child(3) .arz-trend__rank { background: rgb(0 203 140 / .5); color: #fff; }

.arz-trend__thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 48px;
    border-radius: .375rem;
    overflow: hidden;
    background: rgb(242 244 250);
}

.arz-trend__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
}

.arz-trend__title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Homepage: the box sits under «پربازدیدها» in the same column. */
.arz-trend--home { margin-block-start: 1rem; }
@media (min-width: 1024px) {
    .arz-trend--home { margin-block-start: 1.5rem; }
}

/* ---------------------------------------------------------------- Prev / next */

.arz-entry-nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-block: 1rem 2rem;
    margin-inline: 0;
}

@media (min-width: 768px) {
    .arz-entry-nav { grid-template-columns: 1fr 1fr; }
}

.arz-entry-nav__card {
    display: flex;
    align-items: center;
    gap: .875rem;
    min-height: 88px;
    padding: .875rem 1rem;
    border-radius: .5rem;
    background: #fff;
    box-shadow: 0 3px 15px 0 rgba(55, 59, 79, .03);
    color: rgb(55 59 79);
    text-decoration: none;
    border: 1px solid transparent;
    transition: border-color .2s ease, color .2s ease;
}

.arz-entry-nav__card:hover,
.arz-entry-nav__card:focus-visible {
    border-color: rgb(0 203 140 / .6);
    color: rgb(0 203 140);
}

/* Next card: thumbnail on the inline-end side (row-reverse is logical: it
   mirrors with the writing direction), text aligned to the inline start. */
.arz-entry-nav__card--next { flex-direction: row-reverse; text-align: start; }
.arz-entry-nav__card--empty { display: none; }
@media (min-width: 768px) {
    .arz-entry-nav__card--empty { display: block; visibility: hidden; }
}

.arz-entry-nav__thumb {
    flex: 0 0 auto;
    width: 80px;
    height: 60px;
    border-radius: .375rem;
    overflow: hidden;
    background: rgb(242 244 250);
}

.arz-entry-nav__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
}

.arz-entry-nav__body {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 0;
    flex: 1 1 auto;
}

.arz-entry-nav__label {
    font-size: .75rem;
    color: rgb(128 133 158);
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

/*
 * Chevrons: previous points to the inline start, next to the inline end.
 * Two logical borders of a square are rotated into a chevron; the rotation
 * is the only direction-dependent part, so it follows the document `dir`
 * (RTL: start = right, end = left) instead of a physical side.
 */
.arz-entry-nav__label::before {
    content: "";
    width: .5rem;
    height: .5rem;
    border-inline-start: 2px solid currentColor;
    border-block-start: 2px solid currentColor;
    transform: rotate(-45deg);          /* LTR: top+left → points left (start) */
    flex: 0 0 auto;
}
[dir="rtl"] .arz-entry-nav__label::before { transform: rotate(45deg); }         /* top+right → right (start) */

.arz-entry-nav__card--next .arz-entry-nav__label { flex-direction: row-reverse; justify-content: flex-end; }
.arz-entry-nav__card--next .arz-entry-nav__label::before {
    border-inline-start: 0;
    border-inline-end: 2px solid currentColor;
    transform: rotate(45deg);           /* LTR: top+right → points right (end) */
}
[dir="rtl"] .arz-entry-nav__card--next .arz-entry-nav__label::before { transform: rotate(-45deg); }   /* top+left → left (end) */

.arz-entry-nav__title {
    font-size: .9375rem;
    font-weight: 700;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------------------------------------------------------------- Dark mode */

html.dark-mode .arz-trend__item + .arz-trend__item { border-block-start-color: rgb(var(--arz-c-border)); }
html.dark-mode .arz-trend__link { color: rgb(var(--arz-c-title)); }
html.dark-mode .arz-trend__link:hover,
html.dark-mode .arz-trend__link:focus-visible { color: rgb(var(--arz-c-primary-strong)); }
html.dark-mode .arz-trend__flame { color: rgb(var(--arz-c-primary)); }
html.dark-mode .arz-trend__rank { background: rgb(var(--arz-c-over)); color: rgb(var(--arz-c-text)); }
html.dark-mode .arz-trend__item:nth-child(1) .arz-trend__rank { background: rgb(var(--arz-c-primary)); color: rgb(var(--arz-c-body)); }
html.dark-mode .arz-trend__item:nth-child(2) .arz-trend__rank { background: rgb(var(--arz-c-primary) / .75); color: rgb(var(--arz-c-body)); }
html.dark-mode .arz-trend__item:nth-child(3) .arz-trend__rank { background: rgb(var(--arz-c-primary) / .5); color: rgb(var(--arz-c-title-strong)); }
html.dark-mode .arz-trend__thumb,
html.dark-mode .arz-entry-nav__thumb { background: rgb(var(--arz-c-over)); }

html.dark-mode .arz-entry-nav__card { background: rgb(var(--arz-c-block)); color: rgb(var(--arz-c-title)); box-shadow: none; border-color: rgb(var(--arz-c-border)); }
html.dark-mode .arz-entry-nav__card:hover,
html.dark-mode .arz-entry-nav__card:focus-visible { border-color: rgb(var(--arz-c-primary)); color: rgb(var(--arz-c-primary-strong)); }
html.dark-mode .arz-entry-nav__label { color: rgb(var(--arz-c-muted)); }

@media (prefers-reduced-motion: reduce) {
    .arz-trend__link,
    .arz-entry-nav__card { transition: none; }
}
