/* Article list + detail pages — same editorial system as homepage articles */

.ap-page {
    --ha-ink: #1c2b2a;
    --ha-muted: #6b7c7a;
    --ha-line: #d5e0dd;
    --ha-paper: #f4f7f6;
    --ha-card: #ffffff;
    --ha-accent: #0f766e;
    --ha-accent-2: #c45c26;
    --ha-shadow: 0 12px 32px rgba(28, 43, 42, 0.08);
    position: relative;
    padding: 20px 0 40px;
    direction: rtl;
    overflow: visible;
}

.ap-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 100% 0%, rgba(15, 118, 110, 0.08), transparent 55%),
        radial-gradient(ellipse 70% 50% at 0% 100%, rgba(196, 92, 38, 0.05), transparent 50%),
        linear-gradient(180deg, var(--ha-paper) 0%, #eef3f1 100%);
    z-index: 0;
}

.ap-page > .container {
    position: relative;
    z-index: 1;
}

/* Breadcrumb / page head */
.ap-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    font-family: iransans, yekan, sans-serif;
    font-size: 13px;
    color: var(--ha-muted);
}

.ap-crumb a {
    color: var(--ha-accent);
    text-decoration: none !important;
}

.ap-crumb a:hover {
    color: var(--ha-accent-2);
}

.ap-crumb-sep {
    opacity: 0.45;
}

.ap-head {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ha-line);
    direction: ltr;
}

.ap-head-copy {
    text-align: right;
    direction: rtl;
    flex: 1 1 auto;
}

.ap-kicker {
    display: inline-block;
    font-family: iransans, yekan, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--ha-accent);
    margin-bottom: 6px;
}

.ap-title {
    margin: 0;
    font-family: yekan, iransans2, sans-serif;
    font-size: 26px;
    font-weight: bold;
    color: var(--ha-ink);
    line-height: 1.35;
}

.ap-sub {
    margin: 8px 0 0;
    font-family: iransans, yekan, sans-serif;
    font-size: 13px;
    color: var(--ha-muted);
    line-height: 1.7;
}

/* Toolbar: sort + categories */
.ap-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.ap-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--ha-line);
    border-radius: 12px;
}

.ap-sort-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    font-family: iransans, yekan, sans-serif;
    font-size: 12px;
    color: var(--ha-muted);
}

.ap-sort a {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 9px;
    font-family: yekan, iransans, sans-serif;
    font-size: 13px;
    color: var(--ha-ink);
    text-decoration: none !important;
    transition: background 0.2s ease, color 0.2s ease;
}

.ap-sort a:hover {
    background: rgba(15, 118, 110, 0.08);
    color: var(--ha-accent);
}

.ap-sort a.is-active {
    background: var(--ha-accent);
    color: #fff;
}

.ap-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.ap-cat-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--ha-line);
    background: rgba(255, 255, 255, 0.7);
    font-family: yekan, iransans, sans-serif;
    font-size: 12px;
    color: var(--ha-ink);
    text-decoration: none !important;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ap-cat-chip:hover {
    border-color: var(--ha-accent);
    color: var(--ha-accent);
}

.ap-cat-chip.is-active {
    background: var(--ha-ink);
    border-color: var(--ha-ink);
    color: #fff;
}

/* List grid */
.ap-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.ap-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--ha-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(213, 224, 221, 0.9);
    box-shadow: 0 8px 22px rgba(28, 43, 42, 0.06);
    text-decoration: none !important;
    color: inherit;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ap-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(28, 43, 42, 0.11);
}

.ap-card-media {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #dbe5e2;
}

.ap-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.ap-card:hover .ap-card-media img {
    transform: scale(1.05);
}

.ap-card-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: right;
    flex: 1 1 auto;
}

.ap-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    font-family: iransans, yekan, sans-serif;
    font-size: 12px;
    color: var(--ha-muted);
}

.ap-meta-cat {
    color: var(--ha-accent);
    font-weight: 600;
}

.ap-meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #b0bfbc;
}

.ap-card-title {
    margin: 0;
    font-family: yekan, iransans2, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: var(--ha-ink);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.25s ease;
}

.ap-card:hover .ap-card-title {
    color: var(--ha-accent);
}

.ap-card-excerpt {
    margin: 0;
    font-family: iransans, yekan, sans-serif;
    font-size: 12px;
    line-height: 1.75;
    color: var(--ha-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ap-read {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
    font-family: yekan, iransans, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--ha-accent-2);
}

.ap-read i {
    font-size: 12px;
    transition: transform 0.25s ease;
}

.ap-card:hover .ap-read i {
    transform: translateX(-4px);
}

.ap-empty {
    text-align: center;
    padding: 40px 20px;
    background: var(--ha-card);
    border-radius: 16px;
    border: 1px solid var(--ha-line);
    font-family: iransans, yekan, sans-serif;
    color: var(--ha-muted);
    line-height: 2;
}

.ap-empty a {
    color: var(--ha-accent);
    font-weight: 600;
}

/* Pagination */
.ap-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--ha-line);
    border-radius: 14px;
}

.ap-pager-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ap-pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    background: var(--ha-accent);
    color: #fff !important;
    font-family: yekan, iransans, sans-serif;
    font-size: 13px;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ap-pager-btn:hover {
    background: #0b5f59;
    transform: translateY(-1px);
}

.ap-pager-btn.is-disabled {
    background: #c5d0cd;
    pointer-events: none;
}

.ap-pager-status {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    background: #e8eeec;
    font-family: iransans, yekan, sans-serif;
    font-size: 13px;
    color: var(--ha-ink);
}

.ap-pager-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: yekan, iransans, sans-serif;
    font-size: 13px;
    color: var(--ha-muted);
}

.ap-pager-form input[type="number"] {
    width: 72px;
    height: 40px;
    border: 1px solid var(--ha-line);
    border-radius: 10px;
    padding: 0 10px;
    text-align: center;
    font-family: iransans, yekan, sans-serif;
    background: #fff;
}

.ap-pager-form button {
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--ha-line);
    border-radius: 10px;
    background: #fff;
    color: var(--ha-ink);
    font-family: yekan, iransans, sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ap-pager-form button:hover {
    border-color: var(--ha-accent);
    color: var(--ha-accent);
}

/* ========== Detail page ========== */
.ap-article {
    background: var(--ha-card);
    border-radius: 18px;
    border: 1px solid rgba(213, 224, 221, 0.9);
    box-shadow: var(--ha-shadow);
    overflow: hidden;
}

.ap-article-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 0;
    align-items: stretch;
    direction: rtl;
}

.ap-article-cover {
    min-height: 280px;
    background: #dbe5e2;
    overflow: hidden;
}

.ap-article-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ap-article-intro {
    padding: 28px 28px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    text-align: right;
}

.ap-article-intro .ap-title {
    font-size: 28px;
    line-height: 1.5;
}

.ap-article-body {
    padding: 8px 28px 32px;
    text-align: justify;
    direction: rtl;
}

.ap-prose {
    font-family: iransans, yekan, sans-serif;
    font-size: 15px;
    line-height: 2;
    color: #2a3a38;
}

.ap-prose h1,
.ap-prose h2,
.ap-prose h3,
.ap-prose h4 {
    font-family: yekan, iransans2, sans-serif;
    color: var(--ha-ink);
    line-height: 1.5;
    margin: 1.4em 0 0.6em;
    text-align: right;
}

.ap-prose h1 { font-size: 1.45em; }
.ap-prose h2 { font-size: 1.28em; }
.ap-prose h3 { font-size: 1.12em; }

.ap-prose p {
    margin: 0 0 1em;
}

.ap-prose img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 12px 0;
}

.ap-prose a {
    color: var(--ha-accent);
}

.ap-prose ul,
.ap-prose ol {
    padding-right: 1.4em;
    margin: 0 0 1em;
}

.ap-article-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--ha-line);
}

.ap-back {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--ha-line);
    background: rgba(244, 247, 246, 0.9);
    color: var(--ha-ink) !important;
    font-family: yekan, iransans, sans-serif;
    font-size: 13px;
    text-decoration: none !important;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ap-back:hover {
    background: var(--ha-accent);
    border-color: var(--ha-accent);
    color: #fff !important;
}

.ap-related {
    margin-top: 36px;
}

.ap-related .ap-head {
    margin-bottom: 18px;
}

.ap-related-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

@media screen and (max-width: 991px) {
    .ap-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ap-article-hero {
        grid-template-columns: 1fr;
    }

    .ap-article-cover {
        min-height: 0;
        aspect-ratio: 16 / 10;
    }

    .ap-article-intro {
        padding: 20px 20px 8px;
    }

    .ap-article-intro .ap-title {
        font-size: 22px;
    }

    .ap-article-body {
        padding: 8px 20px 24px;
    }

    .ap-related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media screen and (max-width: 767px) {
    .ap-page {
        padding: 12px 0 28px;
    }

    .ap-head {
        flex-direction: column;
        align-items: stretch;
    }

    .ap-title {
        font-size: 20px;
    }

    .ap-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ap-sort {
        width: 100%;
        justify-content: space-between;
    }

    .ap-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .ap-card-title {
        font-size: 15px;
    }

    .ap-pager {
        flex-direction: column;
    }

    .ap-related-grid {
        grid-template-columns: 1fr;
    }

    .ap-article-intro .ap-title {
        font-size: 18px;
    }

    .ap-prose {
        font-size: 14px;
        line-height: 1.9;
    }
}
