/* article-detail.css — Cover Hero, Markdown Typography, Related Articles */

/* Loading state */
.detail-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 20px;
    gap: 24px;
}
.detail-loading .load-ring {
    width: 48px;
    height: 48px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: detailSpin 0.8s linear infinite;
}
@keyframes detailSpin {
    to { transform: rotate(360deg); }
}
.detail-loading p {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

/* Cover Hero */
.detail-cover {
    position: relative;
    width: 100%;
    height: 420px;
    overflow: hidden;
    background: var(--color-bg-deep);
    animation: detailCoverIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes detailCoverIn {
    from {
        opacity: 0;
        transform: scale(1.02);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.detail-cover:hover img {
    transform: scale(1.03);
}

/* No-image cover fallback — a styled dark gradient with a gold icon
   (added by article-detail.js when article.cover_image_url is missing). */
.detail-cover.no-image {
    background:
        radial-gradient(ellipse at top, rgba(229, 184, 105, 0.06) 0%, transparent 60%),
        linear-gradient(135deg, #0A0A0C 0%, #14141A 100%);
}
.detail-cover.no-image img {
    display: none;
}
.detail-cover.no-image .detail-cover-overlay {
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.05) 0%,
        rgba(0, 0, 0, 0.30) 50%,
        rgba(0, 0, 0, 0.85) 100%
    );
}
html.light-mode .detail-cover.no-image {
    background:
        radial-gradient(ellipse at top, rgba(184, 134, 11, 0.08) 0%, transparent 60%),
        linear-gradient(135deg, #F5F5F0 0%, #FAFAFA 100%);
}

.detail-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0.45) 50%,
        rgba(0, 0, 0, 0.85) 100%
    );
}

.detail-cover-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 24px;
    max-width: 900px;
    margin: 0 auto;
    animation: detailContentIn 0.6s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes detailContentIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-cover-content h1 {
    font-family: var(--font-headers);
    font-size: clamp(1.6rem, 3.5vw, 2.6rem);
    color: #F5F5F7;
    line-height: 1.3;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.detail-cover-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    font-size: 0.85rem;
    color: rgba(245, 245, 247, 0.8);
}

.detail-cover-meta i {
    color: var(--color-gold);
    margin-inline-end: 5px;
}

.meta-sep {
    opacity: 0.3;
}

.detail-cover-tags {
    display: none;
}

/* ── Article Body Container ─────────────────────────────────────────── */
.detail-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 50px 24px 30px;
    animation: detailBodyIn 0.6s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes detailBodyIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Markdown Typography ────────────────────────────────────────────── */
.article-content {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--color-text-secondary);
    /* Wrap long URLs/code tokens so they never force horizontal scroll on narrow phones */
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

/* ── Images within content ──────────────────────────────────────────── */
.article-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 30px auto;
    border: 1px solid var(--color-border-grey);
    cursor: pointer;
    transition: opacity 0.3s ease;
}
.article-content img:hover { opacity: 0.92; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.article-content .table-wrap {
    overflow-x: auto;
    margin: 30px 0;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.article-content th,
.article-content td {
    padding: 12px 16px;
    border: 1px solid var(--color-border-grey);
    text-align: right;
}

html[dir="ltr"] .article-content th,
html[dir="ltr"] .article-content td {
    text-align: left;
}

.article-content th {
    background: rgba(229, 184, 105, 0.08);
    color: var(--color-text-primary);
    font-weight: 700;
}

.article-content td {
    color: var(--color-text-secondary);
}

.article-content tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

/* ── Table of Contents — plain heading + standard list ─────────────── */
.detail-toc-host {
    margin: 0 0 40px;
}

.detail-toc-title {
    font-family: var(--font-headers);
    font-size: 1.4rem;
    color: var(--color-text-primary);
    margin: 0 0 14px;
    padding: 0;
    border: none;
    line-height: 1.3;
}

.detail-toc-list {
    list-style: decimal;
    padding-inline-start: 28px;
    margin: 0;
    line-height: 1.9;
    color: var(--color-text-secondary);
}

.detail-toc-list .toc-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.detail-toc-list .toc-link:hover {
    color: var(--color-gold);
    text-decoration: underline;
}

/* ── Keywords (محتوى تقني — نص عادي بدون تنسيق) ──────────────────── */
.detail-keywords {
    margin: 40px 0 0;
}

.detail-keywords-title {
    font-family: var(--font-headers);
    font-size: 1.15rem;
    color: var(--color-text-primary);
    margin: 0 0 8px;
    padding: 0;
    border: none;
    line-height: 1.3;
}

.detail-keywords-note {
    margin: 0 0 10px;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.detail-keywords-list {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ── H2: Cohesive gold accent bar (replaces subtle ::after) ─────────── */
.article-content h2 {
    font-family: var(--font-headers);
    font-size: 1.65rem;
    color: var(--color-text-primary);
    margin: 56px 0 22px;
    padding: 0 0 14px 0;
    border-bottom: 1px solid var(--color-border-grey);
    position: relative;
    line-height: 1.35;
}
.article-content h2::before {
    content: '';
    position: absolute;
    bottom: -1px;
    inset-inline-start: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--color-gold), var(--color-gold-bright));
}
/* Replaces the previous ::after to avoid stacking two pseudo-elements. */
.article-content h2::after { content: none; }

/* ── H3: Subtle inline-start bar ───────────────────────────────────── */
.article-content h3 {
    font-family: var(--font-headers);
    font-size: 1.28rem;
    color: var(--color-text-primary);
    margin: 40px 0 16px;
    padding-inline-start: 14px;
    border-inline-start: 3px solid rgba(229, 184, 105, 0.5);
    line-height: 1.4;
}

/* ── H4: Gold-tinted subhead ───────────────────────────────────────── */
.article-content h4 {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--color-gold-bright);
    margin: 30px 0 14px;
    letter-spacing: 0.2px;
}

/* ── Paragraphs: refined Arabic readability ─────────────────────────── */
.article-content p {
    margin-bottom: 22px;
    line-height: 1.95;
    letter-spacing: -0.005em;
}

/* ── Lists: airy bullets with hover lift ───────────────────────────── */
.article-content ul,
.article-content ol {
    margin: 4px 0 26px;
    padding-inline-start: 28px;
    line-height: 1.9;
}
.article-content ul { list-style: none; }
.article-content ul li {
    position: relative;
    padding-inline-start: 22px;
    margin-bottom: 10px;
    transition: transform 0.2s ease, color 0.2s ease;
}
.article-content ul li::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0.7em;
    width: 8px;
    height: 8px;
    background: var(--color-gold);
    transform: rotate(45deg);
    transition: background 0.2s ease;
}
.article-content ul li:hover {
    color: var(--color-text-primary);
    transform: translateX(3px);
}
html[dir="ltr"] .article-content ul li:hover { transform: translateX(-3px); }
.article-content ul li:hover::before {
    background: var(--color-gold-bright);
}
.article-content ol li {
    margin-bottom: 10px;
    padding-inline-start: 4px;
}
.article-content ol li::marker {
    color: var(--color-gold);
    font-weight: 700;
}

/* ── Blockquote: elegant callout ────────────────────────────────────── */
.article-content blockquote {
    border: 1px solid rgba(229, 184, 105, 0.20);
    border-inline-start: 4px solid var(--color-gold);
    padding: 20px 26px;
    margin: 36px 0;
    background: linear-gradient(135deg, rgba(229, 184, 105, 0.04), rgba(229, 184, 105, 0.01));
    color: var(--color-text-secondary);
    font-style: italic;
    font-size: 1.02rem;
    line-height: 1.85;
    border-radius: 0 6px 6px 0;
}
html[dir="ltr"] .article-content blockquote {
    border-radius: 6px 0 0 6px;
}
.article-content blockquote p { margin-bottom: 0; }

/* ── Inline code + pre: refined ────────────────────────────────────── */
.article-content code {
    background: rgba(229, 184, 105, 0.10);
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
    color: var(--color-gold-bright);
    direction: ltr;
    text-align: left;
    border-radius: 3px;
    border: 1px solid rgba(229, 184, 105, 0.12);
}
.article-content pre {
    background: linear-gradient(135deg, #0A0A0C, #14141A);
    border: 1px solid var(--color-border-grey);
    border-inline-start: 3px solid var(--color-gold);
    padding: 22px 24px;
    overflow-x: auto;
    margin: 28px 0;
    direction: ltr;
    text-align: left;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
html.light-mode .article-content pre {
    background: linear-gradient(135deg, #F5F5F5, #FAFAFA);
}
.article-content pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
}

/* ── Horizontal Rule ────────────────────────────────────────────────── */
.article-content hr {
    border: none;
    height: 1px;
    background: var(--color-border-grey);
    margin: 40px 0;
}

/* ── Share Section ──────────────────────────────────────────────────── */
.detail-share {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
    border-top: 1px solid var(--color-border-grey);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.detail-share-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.detail-share-buttons {
    display: flex;
    gap: 10px;
}

.detail-share-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border-grey);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-body);
}

.detail-share-btn:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
    background: rgba(229, 184, 105, 0.06);
    transform: translateY(-2px);
}

/* ── CTA Section ────────────────────────────────────────────────────── */
.detail-cta {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px 50px;
    text-align: center;
}

.detail-cta h3 {
    font-family: var(--font-headers);
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    margin-bottom: 8px;
}

.detail-cta p {
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

/* ── Related Articles ───────────────────────────────────────────────── */
.detail-related {
    max-width: 1100px;
    margin: 0 auto;
    padding: 50px 24px 60px;
    border-top: 1px solid var(--color-border-grey);
}

.detail-related h2 {
    font-family: var(--font-headers);
    font-size: 1.4rem;
    margin-bottom: 30px;
    text-align: center;
}

.detail-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.detail-related-card {
    border: 1px solid var(--color-border-grey);
    background: var(--color-bg-card);
    padding: 24px;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
}
.detail-related-card:hover {
    border-color: var(--color-gold);
    transform: translateY(-4px);
}

.detail-related-card h4 {
    font-family: var(--font-headers);
    font-size: 0.95rem;
    color: var(--color-text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.detail-related-card p {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* ── 404 State ──────────────────────────────────────────────────────── */
.detail-not-found {
    text-align: center;
    padding: 100px 24px;
}
.detail-not-found-icon {
    font-size: 3.5rem;
    color: var(--color-gold-dim);
    margin-bottom: 20px;
}
.detail-not-found h2 {
    font-family: var(--font-headers);
    font-size: 1.6rem;
    margin-bottom: 10px;
}
.detail-not-found p {
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .detail-cover { height: 300px; }
    .detail-cover-content { padding: 24px 20px; }
    .detail-body { padding: 30px 20px 20px; }
    .article-content { font-size: 0.95rem; }
    .detail-related-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .detail-cover { height: 240px; }
    .detail-cover-content h1 { font-size: 1.3rem; }
    .article-content h2 { font-size: 1.3rem; }
}

/* ── Reduced Motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .detail-related-card { transition: none; }
    .detail-related-card:hover { transform: none; }
    .detail-share-btn { transition: none; }
    .detail-share-btn:hover { transform: none; }
}
