/**
 * Home page — إطار حافة الشاشة + محتوى داخلي 5px.
 */

body.home-page .main-content {
    padding: 0;
}

.home-page-frame {
    --hp-edge: 5px;
    --hh-bg: #f8fafc;
    --hh-border: #cbd5e1;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding-inline: var(--hp-edge);
    border-inline: 2px solid var(--hh-border);
    box-sizing: border-box;
    background: var(--hh-bg);
}

html.site-dark .home-page-frame {
    --hh-bg: #0f172a;
    --hh-border: #334155;
}

.home-page-wrap {
    width: 100%;
    max-width: var(--max-width, 1280px);
    margin-inline: auto;
    padding: 10px 0 12px;
    box-sizing: border-box;
    --hh-bg: #f8fafc;
    --hh-bg2: #f1f5f9;
    --hh-border: #e2e8f0;
    --hh-text: #0f172a;
    --hh-muted: #64748b;
    --hh-accent: var(--color-primary, #0ea5e9);
    --hh-accent2: #38bdf8;
    --hh-accent-soft: rgba(14, 165, 233, 0.1);
    --hh-shadow: 0 10px 40px rgba(15, 23, 42, 0.07);
}

html.site-dark .home-page-wrap {
    --hh-bg: #141c2e;
    --hh-bg2: #0f172a;
    --hh-border: #273549;
    --hh-text: #f1f5f9;
    --hh-muted: #94a3b8;
    --hh-accent-soft: rgba(56, 189, 248, 0.1);
    --hh-shadow: 0 14px 44px rgba(0, 0, 0, 0.35);
}

/* Hero: see home-hero.css */

.home-more-section {
    position: relative;
    margin-top: 10px;
    padding: 20px 20px 22px;
    border-radius: 18px;
    background: linear-gradient(165deg, #ffffff 0%, var(--hh-bg2, #f1f5f9) 100%);
    border: 1.5px solid var(--hh-border, #e2e8f0);
    box-shadow:
        0 8px 28px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.92);
    overflow: hidden;
}

.home-more-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--hh-accent, #0ea5e9) 0%, var(--hh-accent2, #38bdf8) 55%, #7dd3fc 100%);
    pointer-events: none;
}

html.site-dark .home-more-section {
    background: linear-gradient(165deg, #141c2e 0%, #0f172a 100%);
}

.home-page-wrap > :last-child {
    margin-bottom: 0;
}

/* ── Home widget sections ── */
.home-widget {
    position: relative;
    margin: 24px 0;
    padding: 20px 20px 22px;
    border-radius: 18px;
    background: linear-gradient(165deg, #ffffff 0%, var(--hh-bg2, #f1f5f9) 100%);
    border: 1.5px solid var(--hh-border, #e2e8f0);
    box-shadow:
        0 8px 28px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.92);
    overflow: hidden;
}

.home-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--hh-accent, #0ea5e9) 0%, var(--hh-accent2, #38bdf8) 55%, #7dd3fc 100%);
    pointer-events: none;
}

.home-page-wrap .home-widget .post-card,
.home-page-wrap .home-more-section .post-card {
    position: relative;
    border-radius: 14px;
    border: 1.5px solid var(--hh-border, #e2e8f0);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.home-page-wrap .home-widget .post-card::before,
.home-page-wrap .home-more-section .post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--hh-accent2, #38bdf8), var(--hh-accent, #0ea5e9));
    opacity: 0.85;
    z-index: 2;
    pointer-events: none;
}

.home-page-wrap .home-widget .post-card-image,
.home-page-wrap .home-more-section .post-card-image {
    margin: 8px 8px 0;
    border-radius: 10px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.home-page-wrap .home-widget--cards .home-widget__grid .post-card-image {
    aspect-ratio: 16 / 10;
    border-bottom: none;
    overflow: hidden;
}

.home-page-wrap .home-widget--cards .home-widget__grid .post-card-image img,
.home-page-wrap .home-widget--cards .home-widget__grid .post-card-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.home-page-wrap .home-widget .post-card-body,
.home-page-wrap .home-more-section .post-card-body {
    padding: 12px 12px 13px;
}

.home-page-wrap .home-widget .post-card-title,
.home-page-wrap .home-more-section .post-card-title {
    font-size: 15px;
    line-height: 1.45;
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-page-wrap .home-widget .post-card-excerpt,
.home-page-wrap .home-more-section .post-card-excerpt {
    display: none;
}

.home-page-wrap .home-widget .post-card-meta,
.home-page-wrap .home-more-section .post-card-meta {
    margin-top: 8px;
    padding-top: 8px;
    font-size: 11px;
    border-top: 1px dashed rgba(186, 230, 253, 0.75);
}

.home-page-wrap .home-widget .post-card:hover,
.home-page-wrap .home-more-section .post-card:hover {
    transform: translateY(-3px);
    border-color: rgba(125, 211, 252, 0.85);
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.11);
}

.home-page-wrap .home-widget .post-card-hero .post-card-title {
    font-size: clamp(17px, 2vw, 22px);
    -webkit-line-clamp: 3;
}

.home-page-wrap .home-widget .post-card-hero .post-card-image {
    aspect-ratio: 16 / 9;
}

@media (hover: hover) {
    .home-page-wrap .home-widget .post-card:hover .post-card-image img,
    .home-page-wrap .home-more-section .post-card:hover .post-card-image img {
        transform: scale(1.04);
    }
}

html.site-dark .home-page-wrap .home-widget .post-card,
html.site-dark .home-page-wrap .home-more-section .post-card {
    background: linear-gradient(180deg, #1e293b 0%, #172033 100%);
    border-color: #334155;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

html.site-dark .home-page-wrap .home-widget .post-card-image,
html.site-dark .home-page-wrap .home-more-section .post-card-image {
    border-color: #334155;
    background: #0f172a;
}

html.site-dark .home-widget {
    background: linear-gradient(165deg, #141c2e 0%, #0f172a 100%);
}

.home-widget__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid rgba(14, 165, 233, 0.15);
}

.home-widget__head--inline {
    margin-top: 0;
}

.home-widget__head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.home-widget__pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--hh-accent, #0ea5e9);
    box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.5);
    flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .home-widget__pulse {
        animation: home-widget-pulse 2s infinite;
    }
}

@keyframes home-widget-pulse {
    0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.45); }
    70% { box-shadow: 0 0 0 10px rgba(14, 165, 233, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

.home-widget__title {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    font-weight: 800;
    color: var(--hh-text, #0f172a);
    position: relative;
}

.home-widget__title::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 0;
    width: 48px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--hh-accent, #0ea5e9), var(--hh-accent2, #38bdf8));
}

.home-widget__more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--hh-accent-soft, rgba(14, 165, 233, 0.1));
    color: var(--hh-accent, #0ea5e9);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, transform 0.15s;
}

.home-widget__more:hover {
    background: rgba(14, 165, 233, 0.18);
    transform: translateX(-2px);
}

.home-widget__grid,
.home-widget__featured-grid {
    display: grid;
    gap: 20px;
}

.home-widget--cols-2 .home-widget__grid,
.home-widget--cols-2 .home-widget__featured-grid,
.home-more-section--cols-2 .home-widget__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-widget--cols-3 .home-widget__grid,
.home-widget--cols-3 .home-widget__featured-grid,
.home-more-section--cols-3 .home-widget__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-widget--cols-4 .home-widget__grid,
.home-widget--cols-4 .home-widget__featured-grid,
.home-more-section--cols-4 .home-widget__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.home-widget--featured .home-widget-featured-main {
    grid-column: span 2;
    grid-row: span 2;
}

.home-widget__list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.home-widget-list-item {
    display: grid;
    grid-template-columns: 108px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.82);
    border: 1.5px solid var(--hh-border, #e2e8f0);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

html.site-dark .home-widget-list-item {
    background: rgba(15, 23, 42, 0.55);
}

.home-widget-list-item:hover {
    border-color: rgba(14, 165, 233, 0.35);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.home-widget-list-item__thumb {
    width: 108px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--hh-bg2, #f1f5f9);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.home-widget-list-item__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.home-widget-list-item__placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

.home-widget-list-item__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.home-widget-list-item__cat {
    font-size: 11px;
    font-weight: 800;
    color: var(--hh-accent, #0ea5e9);
}

.home-widget-list-item__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--hh-text, #0f172a);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-widget-list-item time {
    font-size: 12px;
    color: var(--hh-muted, #64748b);
}

@media (max-width: 1024px) {
    .home-widget--cols-4 .home-widget__grid,
    .home-widget--cols-4 .home-widget__featured-grid,
    .home-more-section--cols-4 .home-widget__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-widget--featured .home-widget-featured-main {
        grid-column: span 2;
        grid-row: span 1;
    }
}

@media (max-width: 768px) {
    .home-widget {
        padding: 16px;
    }

    .home-widget--cols-2 .home-widget__grid,
    .home-widget--cols-3 .home-widget__grid,
    .home-widget--cols-4 .home-widget__grid,
    .home-widget__featured-grid,
    .home-more-section--cols-2 .home-widget__grid,
    .home-more-section--cols-3 .home-widget__grid,
    .home-more-section--cols-4 .home-widget__grid {
        grid-template-columns: 1fr;
    }

    .home-widget--featured .home-widget-featured-main {
        grid-column: span 1;
        grid-row: span 1;
    }

    .home-widget-list-item {
        grid-template-columns: 96px 1fr;
        gap: 12px;
    }

    .home-widget-list-item__thumb {
        width: 96px;
        height: 68px;
    }
}

/* Dark mode */
/* ── Home sections quick nav ── */
.home-sections-bar {
    margin: 8px 0 18px;
    padding: 10px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(240,249,255,0.92) 100%);
    border: 1px solid var(--hh-border, #e2e8f0);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    position: sticky;
    top: calc(var(--header-scroll-offset, var(--header-mainbar-height, 60px)) + 8px);
    z-index: 40;
}

html.site-dark .home-sections-bar {
    background: linear-gradient(180deg, rgba(20,28,46,0.96) 0%, rgba(15,23,42,0.94) 100%);
}

.home-sections-bar__track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

.home-sections-bar__track::-webkit-scrollbar {
    display: none;
}

.home-sections-bar__link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    color: var(--hh-text, #0f172a);
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(186, 230, 253, 0.9);
    transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.home-sections-bar__link:hover,
.home-sections-bar__link:focus-visible {
    background: rgba(14, 165, 233, 0.16);
    border-color: rgba(56, 189, 248, 0.95);
    transform: translateY(-1px);
}

.home-widget__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.home-widget__badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    color: #0369a1;
    background: rgba(14, 165, 233, 0.12);
    border: 1px solid rgba(186, 230, 253, 0.85);
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease;
}

a.home-widget__badge:hover,
a.home-widget__badge:focus-visible {
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(56, 189, 248, 0.95);
}

.home-widget__empty {
    margin: 0;
    padding: 28px 16px;
    text-align: center;
    color: var(--hh-muted, #64748b);
    font-size: 14px;
    font-weight: 700;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px dashed rgba(148, 163, 184, 0.35);
}

.home-widget {
    scroll-margin-top: calc(var(--header-mainbar-height, 60px) + 72px);
}

@media (max-width: 768px) {
    .home-sections-bar {
        margin: 4px 0 14px;
        padding: 8px 10px;
        top: calc(var(--header-mainbar-height, 54px) + 6px);
    }

    .home-sections-bar__link {
        font-size: 12px;
        padding: 7px 12px;
    }

    .home-widget {
        margin: 20px 0;
        padding: 16px 14px 18px;
        scroll-margin-top: calc(var(--header-mainbar-height, 54px) + 58px);
    }

    .home-widget__head {
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 14px;
        padding-bottom: 12px;
    }

    .home-widget__title {
        font-size: 1.08rem;
    }

    .home-widget-list-item__title {
        font-size: 15px;
    }
}
