/* ===================================
   Theme Configuration & Variables
   =================================== */

/* 
   All theme variables (fonts, colors, spacing) are now injected dynamically 
   by theme-settings.js from WordPress Theme Settings plugin.
   This ensures single source of truth and prevents CSS conflicts.
*/

:root {
    /* Fallback colors for legacy rules - will be overridden by theme settings */
    --color-primary: #667eea;
    --color-primary-dark: #5a67d8;
    --color-text: #2c3e50;
    --color-text-light: #666;
    --color-bg: #f8f9fa;
    --color-white: #ffffff;
    
    /* Fallback spacing - will be overridden by theme settings */
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
}

/* Base Styles */
body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.7;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
}

/* Global Button Styles - Inherited from Theme Settings */
/* All button styling now comes from Theme Settings plugin */

.btn-outline-primary:hover {
    background-color: #ef4444 !important;
    color: white !important;
}

/* Bootstrap Overrides */
/* Header is the fixed container — navbar is relative inside it */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    margin-bottom: 0;
}

.navbar {
    position: relative;
}

.navbar .container {
    position: relative;
}

/* Desktop: matches standard Bootstrap navbar height */
body {
    padding-top: 56px;
}

main {
    margin-top: 0;
    padding-top: 0;
    padding-left: 5px;
    padding-right: 5px;
}

#custom-footer {
    padding-left: 5px;
    padding-right: 5px;
}

.navbar-brand {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text) !important;
}

/* Page title — hidden on desktop, shown stacked inside navbar on mobile/tablet */
.navbar-mobile-page-title {
    display: none;
    font-family: var(--font-logo) !important;
    font-size: var(--size-logo) !important;
    font-weight: var(--weight-logo) !important;
    color: var(--color-logo) !important;
    text-align: center;
    line-height: 1.2;
}

/* Hide when empty */
.navbar-mobile-page-title:empty {
    display: none !important;
}

.nav-link {
    font-weight: 500;
    color: var(--color-text-light) !important;
    transition: color 0.3s;
}

.nav-link:hover,
.nav-link.active {
    color: #ff0000 !important;
}

/* Container with py-5 class */
.py-5 > .container,
.container.py-5 {
    padding-left: 0;
    padding-right: 0;
}

@media (max-width: 1199px) {
    /* Brand + page title stacked and centered in navbar */
    .navbar-brand-stack {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        max-width: calc(100% - 3.5rem);
    }

    /* Reset brand positioning (now on the stack wrapper) */
    .navbar-brand {
        position: static;
        transform: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-right: 0;
        margin-left: 0;
        padding-left: 0;
        padding-right: 0;
    }

    /* Show page title inside navbar — same size as brand */
    .navbar-mobile-page-title {
        display: block;
    }

    .navbar-mobile-page-title[data-type="post"],
    .navbar-mobile-page-title[data-type="tag"] {
        display: none !important;
    }

    /* Taller navbar to fit both lines; body padding matches */
    .navbar .container {
        min-height: 80px;
        display: flex;
        align-items: center;
        position: relative;
    }

    body {
        padding-top: 80px;
    }

    .navbar-toggler {
        position: relative;
        z-index: 2;
    }
    
    /* Fix mobile menu overlay issue - menu should not push content down */
    .navbar-collapse {
        position: absolute !important;
        top: 100%;
        left: 0;
        right: 0;
        background-color: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        border-top: 1px solid rgba(0,0,0,0.1);
    }
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: var(--color-white);
    min-height: 500px;
    display: flex;
    align-items: center;
}

/* Remove background when hero has a media container */
.hero:has(.hero-image-container),
.hero:has(.page-hero-container),
.hero:has(.home-hero-slideshow),
.hero:has(.layered-gallery-container) {
    background: none;
    min-height: auto;
    display: block;
}

/* Parallax featured images */
.parallax-featured-image {
    will-change: transform;
    transition: none !important; /* Remove transitions for smooth parallax */
}

.hero h2 {
    font-family: var(--font-heading);
}

.hero .lead {
    font-size: 1.25rem;
    opacity: 0.95;
}

/* Blog Section */
.blog-section {
    background-color: var(--color-white);
}

.blog-section h2 {
    color: var(--color-text);
    font-family: var(--font-heading);
}

/* Post Cards - Bootstrap Integration */
.post-card {
    background: var(--color-white);
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s, box-shadow 0.3s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Post Image Link */
.post-card .post-image {
    display: block;
    width: 100%;
    overflow: hidden;
    aspect-ratio: 1 / 1;
}

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

.post-card:hover .post-image img {
    transform: scale(1.05);
}

.post-content {
    padding: 1.5rem;
    padding-left: 5px;
    padding-right: 5px;
    padding-bottom: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Post Title */
.post-content .post-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

.post-content .post-title a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.3s ease;
}

.post-content .post-title a:hover {
    color: #ef4444;
}

/* Fallback for h3 title (if not using .post-title class) */
.post-content h3 {
    color: var(--color-text);
    font-family: var(--font-heading);
    margin-bottom: 0.75rem;
    font-size: 1.35rem;
}

.post-content h3 a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.3s ease;
}

.post-content h3 a:hover {
    color: #ef4444;
}

.post-content .excerpt {
    color: #6b7280;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-content .cpw-read-more {
    text-decoration: none;
    display: block;
    width: calc(100% + 3rem);
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    padding: 1rem 0 !important;
    margin-top: auto;
    border-radius: 0;
    /* All button styling inherited from theme settings */
}

.post-content .cpw-read-more:hover {
    text-decoration: none;
    /* Hover styling inherited from theme settings */
}

@media (max-width: 576px) {
    .post-content .cpw-read-more {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}

/* Tag/Category Archive Styling */
.tag-archive,
.category-archive {
    padding: 4rem 0;
    background-color: #ffffff;
}

.tag-archive h1,
.category-archive h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
}

/* Post Single View */
.post-single {
    background-color: var(--color-white);
}

.post-breadcrumb {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.post-breadcrumb a {
    color: var(--color-text-light);
    text-decoration: none;
    transition: color 0.3s;
}

.post-breadcrumb a:hover {
    color: var(--color-primary);
}

.post-breadcrumb span {
    margin: 0 0.5rem;
}

.post-sidebar {
    background-color: #f9fafb;
    padding: 1.5rem;
    border-radius: 8px;
    position: sticky;
    top: 80px;
}

.post-sidebar h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.sidebar-post-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-post-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sidebar-post-item img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.sidebar-post-info {
    flex: 1;
}

.sidebar-post-info h5 {
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.3;
}

.sidebar-post-info a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.3s;
}

.sidebar-post-info a:hover {
    color: var(--color-primary);
}

.sidebar-post-info .post-date {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
}

.post-featured-image {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 0;
    margin-bottom: 2rem;
}

.post-footer .btn {
    /* Button styling inherited from theme settings */
}

.post-footer .btn:hover {
    /* Hover styling inherited from theme settings */
}

/* Footer */
footer {
    background-color: #2c3e50;
    color: white;
    padding: 2rem 0;
    text-align: center;
    margin-top: 4rem;
}

/* Loading and Error States */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

.error {
    text-align: center;
    padding: var(--spacing-md);
    color: #dc3545;
    background-color: #f8d7da;
    border-radius: 8px;
    border: 1px solid #f5c2c7;
}

/* Single Post Page */
.post-single {
    background-color: var(--color-white);
}

.post-featured-image {
    width: 100%;
    max-height: 600px;
    object-fit: cover;
    border-radius: 0;
    margin-bottom: var(--spacing-md);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.post-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid #e9ecef;
}

.post-header h1 {
    color: var(--color-text);
    font-family: var(--font-heading);
    font-size: 2.75rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.post-meta {
    color: var(--color-text-light);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.post-body {
    color: var(--color-text);
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: var(--spacing-md);
    padding-left: 5px;
    padding-right: 5px;
}

.post-body p {
    margin-bottom: 1.25rem;
}

.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0;
    margin: 2rem 0;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
}

.post-body h2 {
    color: var(--color-text);
    font-family: var(--font-heading);
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    font-size: 2rem;
}

.post-body h3 {
    color: var(--color-text);
    font-family: var(--font-heading);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.post-body ul, .post-body ol {
    margin-bottom: 1.25rem;
    padding-left: 2rem;
}

.post-body li {
    margin-bottom: 0.5rem;
}

.post-body blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--color-text-light);
    font-size: 1.15rem;
}

/* WordPress Block Alignment Classes */
.alignfull {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.alignwide {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* Remove blockquote styling from video embeds */
blockquote.wp-block-quote.alignfull {
    border: none;
    padding: 0;
    margin: 3rem 0;
    font-style: normal;
}

/* WordPress Video Embeds */
.wp-block-embed iframe,
.wp-block-embed video {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
}

.wp-block-embed.alignfull iframe,
.wp-block-embed.alignfull video {
    width: 100% !important;
}

.post-footer {
    padding-top: var(--spacing-md);
    border-top: 2px solid #e9ecef;
}

/* Responsive Typography */
@media (max-width: 768px) {
    .py-5 .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .hero {
        min-height: 60vh;
    }
    
    /* Remove padding on mobile when hero has media containers */
    .hero:has(.hero-image-container),
    .hero:has(.page-hero-container),
    .hero:has(.home-hero-slideshow),
    .hero:has(.layered-gallery-container) {
        min-height: auto;
    }
    
    /* Hero containers: respect per-page mobile height set by router (--hero-height-mobile),
       falling back to 250px. 60vh is no longer hardcoded. */
    .hero-image-container,
    .page-hero-container,
    .post-featured-image-container,
    .home-hero-slideshow {
        min-height: var(--hero-height-mobile, 250px) !important;
        height: var(--hero-height-mobile, 250px);
    }
    
    .hero h2 {
        font-size: 2.5rem;
    }
    
    .post-header h1 {
        font-size: 2.5rem;
    }
    
    .post-body {
        font-size: 1.125rem;
    }
    
    .navbar-brand {
        font-size: 1.6rem;
        line-height: 1.1;
    }

    /* Bigger post titles on mobile */
    .post-single .hero {
        min-height: var(--hero-height-mobile, 250px) !important;
        height: var(--hero-height-mobile, 250px) !important;
    }
    
    /* Post hero container - respect per-page mobile height, fall back to 250px */
    .post-featured-image-container {
        min-height: var(--hero-height-mobile, 250px) !important;
        height: var(--hero-height-mobile, 250px) !important;
    }
    
    /* Post hero image - fit to full height on mobile */
    .post-featured-image-container img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* Remove padding from post content wrapper on mobile */
    .post-single > div.py-5 {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    
}
