/* ==========================================================================
 * RankwellPress — HOMEPAGE LAYOUT (CSS Grid)
 * File: assets/css/templates/_homepage.css
 * FLAT — no card borders, no backgrounds, no shadows.
 * ========================================================================== */

.rankwellpress-homepage-layout * {
    box-sizing: border-box;
}

/* Mobile-first: single column */
.rankwellpress-homepage-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--rw-space-5, 1.5rem);
    margin: var(--rw-space-5, 1.5rem) 0;
}

/* Desktop: 2-column grid */
@media (min-width: 769px) {
    .rankwellpress-homepage-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) var(--rw-sidebar-width, 320px);
        grid-template-areas: "content sidebar";
        align-items: start;
        gap: var(--rw-space-5, 1.5rem);
    }

    .rankwellpress-homepage-layout .site-main {
        grid-area: content;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    .rankwellpress-homepage-layout .site-sidebar {
        grid-area: sidebar;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        position: sticky;
        top: 90px;
        align-self: start;
    }
}

/* Mobile: single column stack */
@media (max-width: 768px) {
    .rankwellpress-homepage-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "content"
            "sidebar";
        gap: var(--rw-space-5, 1.5rem);
    }

    .rankwellpress-homepage-layout .site-main {
        grid-area: content;
        min-width: 0;
    }

    .rankwellpress-homepage-layout .site-sidebar {
        grid-area: sidebar;
        width: 100%;
        position: static;
    }
}

/* Overflow protection */
.rankwellpress-homepage-layout .site-main {
    overflow-wrap: break-word;
}

.rankwellpress-homepage-layout .site-main img,
.rankwellpress-homepage-layout .site-main iframe,
.rankwellpress-homepage-layout .site-main video,
.rankwellpress-homepage-layout .site-main table,
.rankwellpress-homepage-layout .site-main pre {
    max-width: 100%;
    height: auto;
}

.rankwellpress-homepage-layout .site-main table {
    display: block;
    width: 100%;
    overflow-x: auto;
}

/* Widgets */
.rankwellpress-main-widgets,
.rankwellpress-sidebar-widgets {
    width: 100%;
}

/* Latest Posts Grid */
.latest-posts-grid .post-thumbnail {
    overflow: hidden;
    aspect-ratio: 16/9;
    border-radius: 4px;
}

.latest-posts-grid .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--rw-widget-item-gap, var(--rw-space-5, 1.5rem));
}

@media (min-width: 600px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
 * POST CARD — FLAT (no border, background, or shadow)
 * ========================================================================== */

.post-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    transition: none;
}

.post-card:hover {
    transform: none;
    box-shadow: none;
}

.post-card .post-thumbnail {
    overflow: hidden;
    aspect-ratio: 16/9;
    border-radius: 4px;
    margin-bottom: 12px;
}

.post-card .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.post-card:hover .post-thumbnail img {
    transform: scale(1.04);
}

.post-card .post-content {
    padding: 0;
}

.post-card .post-title {
    font-size: var(--rw-widget-post-title-size, 1.1rem);
    font-weight: var(--rw-widget-post-title-weight, 700);
    line-height: 1.3;
    margin: 0 0 8px 0;
}

.post-card .post-title a {
    color: var(--rw-widget-post-title-color, var(--rw-grid-title, #111827));
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-card .post-title a:hover {
    color: var(--rw-widget-post-title-hover, var(--rw-grid-title-hover, #0d7c3e));
}

.post-card .post-excerpt {
    font-size: 0.9rem;
    color: var(--rw-text-body, #4b5563);
    line-height: 1.5;
    margin-bottom: 12px;
}

.post-card .read-more {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rw-color-primary, #0d7c3e);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.post-card .read-more:hover {
    opacity: 0.75;
    color: var(--rw-color-primary, #0d7c3e);
}

/* ==========================================================================
 * SECTION HEADER
 * ========================================================================== */

.section-header {
    margin-bottom: var(--rw-space-4, 1rem);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--rw-text-heading, #111827);
    margin: 0;
}

/* =========================================================
 * WIDGET COLOR CONTROL
 * ========================================================= */

.rankwellpress-homepage-layout .rwp-title-underline,
.rankwellpress-homepage-layout .rwp-title-border,
.rankwellpress-homepage-layout .rwp-title-top-border,
.rankwellpress-homepage-layout .rwp-title-minimal,
.rankwellpress-homepage-layout .rwp-title-between-lines {
    color: var(--rw-widget-title-color, #0d7c3e);
}

.rankwellpress-homepage-layout .rwp-title-slant {
    color: var(--rw-text-inverse, #ffffff);
}

.rankwellpress-homepage-layout .rwp-title-bg-fill {
    color: var(--rw-text-heading, #111827);
}

.rankwellpress-homepage-layout .rwp-title-underline::after {
    background-color: color-mix(in srgb, var(--rw-widget-title-color, #0d7c3e) 40%, transparent);
    box-shadow: none;
}

.rankwellpress-homepage-layout .rwp-title-border {
    border-left-color: var(--rw-widget-title-color, #0d7c3e);
}

.rankwellpress-homepage-layout .rwp-title-slant::before {
    background-color: var(--rw-widget-title-color, #0d7c3e);
}

.rankwellpress-homepage-layout .rwp-title-top-border {
    border-top-color: var(--rw-widget-title-color, #0d7c3e);
}

.rankwellpress-homepage-layout .rwp-title-bg-fill {
    background-color: color-mix(in srgb, var(--rw-widget-title-color, #0d7c3e) 10%, transparent);
}

.rankwellpress-homepage-layout .rwp-title-bg-fill span::before {
    background-color: var(--rw-widget-title-color, #0d7c3e);
}

.rankwellpress-homepage-layout .rwp-title-between-lines::before,
.rankwellpress-homepage-layout .rwp-title-between-lines::after {
    background: linear-gradient(90deg, transparent 0%, var(--rw-widget-title-color, #0d7c3e) 50%, transparent 100%);
}

/* List Item Titles */
.rankwellpress-homepage-layout .rwp-card-title a,
.rankwellpress-homepage-layout .rwp-card-full-title a,
.rankwellpress-homepage-layout .rwp-grid-card .rwp-card-title a {
    color: var(--rw-widget-post-title-color, #111827);
}

.rankwellpress-homepage-layout .rwp-card-title a:hover,
.rankwellpress-homepage-layout .rwp-card-full-title a:hover,
.rankwellpress-homepage-layout .rwp-grid-card .rwp-card-title a:hover {
    color: var(--rw-widget-post-title-hover, #0d7c3e);
}

/* Category Badges — flat text only */
.rankwellpress-homepage-layout .rwp-card-badge,
.rankwellpress-homepage-layout .rwp-grid-card .rwp-card-badge,
.rankwellpress-homepage-layout .rwp-card-full-badge a {
    background-color: transparent;
    color: var(--rw-widget-category-text, #0d7c3e);
}

/* Hero Badges — flat text only */
.rankwellpress-homepage-layout .featured-badge,
.rankwellpress-homepage-layout .rankwellpress-headlines-category {
    background-color: transparent;
    color: var(--rw-widget-category-text, #ffffff);
}

/* Hero Title */
.rankwellpress-homepage-layout .rankwellpress-headlines-featured-title a {
    color: var(--rw-text-inverse, #ffffff);
}

.rankwellpress-homepage-layout .rankwellpress-headlines-featured-title a:hover {
    color: var(--rw-border-light, #e5e7eb);
}

/* Featured Title */
.rankwellpress-homepage-layout .featured-title a {
    color: var(--rw-text-inverse, #ffffff);
}

.rankwellpress-homepage-layout .featured-title a:hover {
    color: var(--rw-border-light, #e5e7eb);
}

/* Typography Variables */
.rankwellpress-homepage-layout .rwp-card-title,
.rankwellpress-homepage-layout .rwp-grid-card .rwp-card-title {
    font-size: var(--rw-widget-post-title-size, 14px);
    font-weight: var(--rw-widget-post-title-weight, 600);
}

.rankwellpress-homepage-layout .rwp-card-full-title {
    font-size: var(--rw-widget-post-title-size, 14px);
    font-weight: var(--rw-widget-post-title-weight, 600);
}

.rankwellpress-homepage-layout .rwp-card-full--compact .rwp-card-full-title {
    font-size: var(--rw-herogrid-compact-size, 14px);
    font-weight: var(--rw-herogrid-compact-weight, 600);
}

.rankwellpress-homepage-layout .rwp-card-full--minimal .rwp-card-full-title {
    font-size: var(--rw-herogrid-minimal-size, 13px);
    font-weight: var(--rw-herogrid-minimal-weight, 600);
}

/* Title typography */
.rankwellpress-homepage-layout .rwp-title-underline,
.rankwellpress-homepage-layout .rwp-title-border,
.rankwellpress-homepage-layout .rwp-title-slant,
.rankwellpress-homepage-layout .rwp-title-top-border,
.rankwellpress-homepage-layout .rwp-title-bg-fill,
.rankwellpress-homepage-layout .rwp-title-minimal,
.rankwellpress-homepage-layout .rwp-title-between-lines {
    font-size: var(--rw-widget-title-size, 20px);
    font-weight: var(--rw-widget-title-weight, 700);
}

/* Line clamp */
.rankwellpress-homepage-layout .rwp-card-title a,
.rankwellpress-homepage-layout .rwp-card-full-title,
.rankwellpress-homepage-layout .rwp-grid-card .rwp-card-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-line-clamp: var(--rw-line-clamp, 2);
}

/* Widget spacing */
.rankwellpress-homepage-layout .rankwellpress-headlines-list,
.rankwellpress-homepage-layout .flexnews-list,
.rankwellpress-homepage-layout .news-grid,
.rankwellpress-homepage-layout .rankwellpress-hero-grid {
    gap: var(--rw-widget-item-gap, 12px);
}

/* Admin Warning */
.rankwellpress-homepage-layout .admin-warning {
    padding: 30px;
    border: 2px dashed var(--rw-widget-border, var(--rw-border-light, #e5e7eb));
    border-radius: 8px;
    text-align: center;
    background: var(--rw-widget-bg, var(--rw-bg-body, #f7f8fa));
}

/* ==========================================================================
 * DARK MODE OVERRIDES — flat
 * ========================================================================== */

html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-title-slant::before {
    background-color: #ffffff !important;
}

html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-title-slant {
    color: #000000 !important;
}

html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-card-title a,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-card-full-title a,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-grid-card .rwp-card-title a,
html[data-theme="dark"] .rankwellpress-homepage-layout .rankwellpress-headlines-featured-title a,
html[data-theme="dark"] .rankwellpress-homepage-layout .featured-title a,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-title-underline,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-title-border,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-title-top-border,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-title-minimal {
    color: #ffffff !important;
}

html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-card-title a:hover,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-card-full-title a:hover,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-grid-card .rwp-card-title a:hover {
    color: var(--rw-color-primary, #0d7c3e) !important;
}

/* Dark mode badges */
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-card-badge,
html[data-theme="dark"] .rankwellpress-homepage-layout .rwp-grid-card .rwp-card-badge {
    background-color: transparent !important;
    color: #e5e7eb !important;
    border: none !important;
}

html[data-theme="dark"] .rankwellpress-homepage-layout .rankwellpress-headlines-category,
html[data-theme="dark"] .rankwellpress-homepage-layout .featured-badge {
    background-color: transparent !important;
    color: #ffffff !important;
}

/* Dark mode post card */
html[data-theme="dark"] .post-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .post-card .post-title a {
    color: #f8fafc !important;
}

html[data-theme="dark"] .post-card .post-title a:hover {
    color: var(--rw-color-primary, #0d7c3e) !important;
}

html[data-theme="dark"] .post-card .post-excerpt {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .post-card .read-more {
    color: var(--rw-color-primary, #0d7c3e) !important;
}

html[data-theme="dark"] .rankwellpress-homepage-layout .admin-warning {
    background: #111111 !important;
    border-color: #333333 !important;
    color: #ffffff !important;
}

/* ============================================
   MOBILE HOMEPAGE MARGIN FIX
   ============================================ */
@media (max-width: 767px) {
    /* Force the container to have side padding */
    .rankwellpress-container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Prevent the grid layout from stretching wider than the container */
    .rankwellpress-homepage-layout {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
    }
}