/* ===== GLOBAL STYLES ===== */

/* Target the first h1 in main content area for POSTS specifically */
.post-template .main-content h1:first-of-type,
.post-template-project-post .main-content h1:first-of-type {
    padding: 0 0 20px 0 !important;
    margin-top: 8px !important;
    margin-bottom: 8px !important;
}

/* Target the first h1 in main content area for PAGES (excluding home page) */
.page:not(.page_category-home) .main-content h1:first-of-type {
    padding: 0 !important;
    margin-top: 8px !important;
    margin-bottom: 8px !important;
}

/* Project column container */
.project-column-container {
    width: 100% !important;
}

/* YouTube video fills its space horizontally */
iframe {
    width: 100%;
    object-fit: cover;
    border: none;
}

/* ===== HOME PAGE STYLES ===== */

.page_category-home {
    --grid-gap-desktop: 2rem;
    --grid-gap-mobile: 1.5rem;
    --text-font-size: 18px;
    --media-max-height: 300px;
    --media-min-height: 200px;
}

/* Home page specific h1 spacing */
.page_category-home .home-projects-title {
    margin-bottom: 30px !important;
    padding-bottom: 10px !important;
}

/* Desktop Layout: Text (2fr) and Media (1fr) Independent Flow */
.page_category-home .wp-block-column.text .text-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--grid-gap-desktop, 2rem);
}

.page_category-home .text-content p {
    text-align: left;
}

/* Hide redundant right column since content is misplaced */
.wp-block-column.media {
    display: none;
}

/* Layout flow margin reset */
.page_category-home :where(.is-layout-flow) > :last-child {
    margin-block-end: 0;
}

.page_category-home :where(.is-layout-flow) > * {
    margin-block-start: 0;
    margin-block-end: 0;
}

/* Container Styling */
.page_category-home .entry-content .text {
    grid-column: 2;
}

.page_category-home .entry-content .media {
    grid-column: 1;
}

/* Media Styling */
.page_category-home .entry-content img {
    width: 100%;
    min-height: var(--media-min-height);
    max-height: var(--media-max-height);
    object-fit: cover;
    border-radius: 4px;
}

/* First Media or Paragraph Alignment */
.page_category-home .entry-content > p:first-of-type,
.page_category-home .entry-content > img:first-of-type,
.page_category-home .entry-content > iframe:first-of-type {
    margin-top: 0;
    align-self: start;
}

/* Text Styling */
.page_category-home .entry-content p {
    margin: 0;
    font-size: var(--text-font-size);
    align-self: start;
}

/* Indented Paragraphs */
.page_category-home p.indented {
    text-indent: 2rem;
}

/* YouTube fix */
.page_category-home .entry-content .wp-block-embed-youtube .wp-block-embed__wrapper::before {
    content: none !important;
    display: none !important;
}

/* Margin Reset for page_category-home Posts (Highly Specific) */
body.page_category-home .entry-content .wp-block-post-content.is-layout-flow > * {
    margin-block: 0 !important;
}

/* ===== MEDIA QUERIES ===== */

/* Mobile Layout (up to 768px) */
@media screen and (max-width: 768px) {
    /* Hide header background image on mobile, keep only logo */
    .top-header-image .wp-block-cover__image-background {
        display: none !important;
    }
    
    .top-header-image {
        min-height: 4rem !important;
    }
    
    .top-header-image .wp-block-cover__background {
        opacity: 1 !important;
    }

    /* Mobile h1 spacing */
    h1.wp-block-post-title,
    .wp-block-heading h1,
    main h1 {
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }

    /* Home page mobile layout */
    .page_category-home .wp-block-column.text .text-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--grid-gap-desktop, 2rem);
    }
    
    .page_category-home .entry-content figure.wp-block-image {
        grid-row: 1;
        grid-column: 1;
    }
    
    .page_category-home .entry-content p {
        grid-row: 2;
        grid-column: 1;
    }
    
    .page_category-home .entry-content img {
        padding-top: 0;
    }
}

/* Tablet Layout (769px to 1024px) - Single column layout */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .page_category-home .wp-block-column.text .text-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--grid-gap-desktop, 2rem);
    }
    
    .page_category-home .entry-content {
        grid-template-columns: 1fr;
        gap: var(--grid-gap-desktop);
    }
    
    .page_category-home .entry-content .text,
    .page_category-home .entry-content .media {
        grid-column: 1 !important;
    }
    
    .page_category-home .entry-content figure.wp-block-image {
        grid-row: 1;
        grid-column: 1;
    }
    
    .page_category-home .entry-content p {
        grid-row: 2;
        grid-column: 1;
    }
}

/* Events title and Featured Projects title spacing (768px to 1263px) */
@media screen and (min-width: 768px) and (max-width: 1263px) {
    .calendar-col h1.home-events-title.wp-block-heading,
    .wp-block-columns.calendar-events h1.home-events-title,
    h1.home-events-title.has-text-align-center,
    .home-projects-section h1.home-projects-title.wp-block-heading,
    h1.home-projects-title.has-text-align-center {
        padding: 8px 0 40px 0 !important;
        margin: 0 !important;
    }
}/* ===== GLOBAL STYLES ===== */

/* Target the first h1 in main content area for POSTS specifically */
.post-template .main-content h1:first-of-type,
.post-template-project-post .main-content h1:first-of-type {
    padding: 0 0 20px 0 !important;
    margin-top: 8px !important;
    margin-bottom: 8px !important;
}

/* Target the first h1 in main content area for PAGES (excluding home page) */
.page:not(.page_category-home) .main-content h1:first-of-type {
    padding: 0 !important;
    margin-top: 8px !important;
    margin-bottom: 8px !important;
}

/* Project column container */
.project-column-container {
    width: 100% !important;
}

/* YouTube video fills its space horizontally */
iframe {
    width: 100%;
    object-fit: cover;
    border: none;
}

/* ===== HOME PAGE STYLES ===== */

.page_category-home {
    --grid-gap-desktop: 2rem;
    --grid-gap-mobile: 1.5rem;
    --text-font-size: 18px;
    --media-max-height: 300px;
    --media-min-height: 200px;
}

/* Home page specific h1 spacing */
.page_category-home .home-projects-title {
    margin-bottom: 30px !important;
    padding-bottom: 10px !important;
}

/* Desktop Layout: Text (2fr) and Media (1fr) Independent Flow */
.page_category-home .wp-block-column.text .text-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--grid-gap-desktop, 2rem);
}

.page_category-home .text-content p {
    text-align: left;
}

/* Hide redundant right column since content is misplaced */
.wp-block-column.media {
    display: none;
}

/* Layout flow margin reset */
.page_category-home :where(.is-layout-flow) > :last-child {
    margin-block-end: 0;
}

.page_category-home :where(.is-layout-flow) > * {
    margin-block-start: 0;
    margin-block-end: 0;
}

/* Container Styling */
.page_category-home .entry-content .text {
    grid-column: 2;
}

.page_category-home .entry-content .media {
    grid-column: 1;
}

/* Media Styling */
.page_category-home .entry-content img {
    width: 100%;
    min-height: var(--media-min-height);
    max-height: var(--media-max-height);
    object-fit: cover;
    /*margin-bottom: 1rem;*/
    border-radius: 4px;
}

/* First Media or Paragraph Alignment */
.page_category-home .entry-content > p:first-of-type,
.page_category-home .entry-content > img:first-of-type,
.page_category-home .entry-content > iframe:first-of-type {
    margin-top: 0;
    align-self: start;
}

/* Text Styling */
.page_category-home .entry-content p {
    margin: 0;
    font-size: var(--text-font-size);
    align-self: start;
}

/* Indented Paragraphs */
.page_category-home p.indented {
    text-indent: 2rem;
}

/* YouTube fix */
.page_category-home .entry-content .wp-block-embed-youtube .wp-block-embed__wrapper::before {
    content: none !important;
    display: none !important;
}

/* Margin Reset for page_category-home Posts (Highly Specific) */
body.page_category-home .entry-content .wp-block-post-content.is-layout-flow > * {
    margin-block: 0 !important;
}

/* ===== MEDIA QUERIES ===== */

/* Mobile Layout (up to 768px) */
@media screen and (max-width: 768px) {
    /* Hide header background image on mobile, keep only logo */
    .top-header-image .wp-block-cover__image-background {
        display: none !important;
    }
    
    .top-header-image {
        min-height: 4rem !important;
    }
    
    .top-header-image .wp-block-cover__background {
        opacity: 1 !important;
    }

    /* Mobile h1 spacing */
    h1.wp-block-post-title,
    .wp-block-heading h1,
    main h1 {
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }

    /* Home page mobile layout */
    .page_category-home .wp-block-column.text .text-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--grid-gap-desktop, 2rem);
    }
    
    .page_category-home .entry-content figure.wp-block-image {
        grid-row: 1;
        grid-column: 1;
    }
    
    .page_category-home .entry-content p {
        grid-row: 2;
        grid-column: 1;
    }
    
    .page_category-home .entry-content img {
        padding-top: 0;
    }
}

/* Tablet Layout (769px to 1024px) - Single column layout */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .page_category-home .wp-block-column.text .text-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--grid-gap-desktop, 2rem);
    }
    
    .page_category-home .entry-content {
        grid-template-columns: 1fr;
        gap: var(--grid-gap-desktop);
    }
    
    .page_category-home .entry-content .text,
    .page_category-home .entry-content .media {
        grid-column: 1 !important;
    }
    
    .page_category-home .entry-content figure.wp-block-image {
        grid-row: 1;
        grid-column: 1;
    }
    
    .page_category-home .entry-content p {
        grid-row: 2;
        grid-column: 1;
    }
}

/* Events title and Featured Projects title spacing (768px to 1263px) */
@media screen and (min-width: 768px) and (max-width: 1263px) {
    .calendar-col h1.home-events-title.wp-block-heading,
    .wp-block-columns.calendar-events h1.home-events-title,
    h1.home-events-title.has-text-align-center,
    .home-projects-section h1.home-projects-title.wp-block-heading,
    h1.home-projects-title.has-text-align-center {
        padding: 8px 0 40px 0 !important;
        margin: 0 !important;
    }
}

/* ===== CALENDAR EVENTS STYLES ===== */
/* ===== MINIMAL CALENDAR STYLES - PLUGIN FRIENDLY ===== */

/* Allow plugin to work - NO interference with clicks */
.page_category-home .calendar-event[data-post-url] {
    /* Let the plugin handle all interactions */
    position: static !important;
    z-index: auto !important;
    pointer-events: auto !important;
}

/* Remove any interference with child elements */
.page_category-home .calendar-event * {
    pointer-events: auto !important;
}

/* Basic layout only - no interaction blocking */
.page_category-home .calendar-events {
    display: flex;
    flex-direction: column;
}

/* Simple mobile layout without interference */
@media (max-width: 768px) {
    .page_category-home .calendar-event {
        margin-bottom: 2rem;
    }
    
    .page_category-home .calendar-event h3 {
        text-align: center;
        margin-bottom: 1rem;
    }
    
    .page_category-home .calendar-event .event-featured-image-container {
        text-align: center;
        margin-bottom: 1rem;
    }
    
    .page_category-home .calendar-event .event-featured-image {
        max-width: 100%;
        height: auto;
    }
}/* Calendar Events Clickability Fix for Home Page */

/* Ensure calendar events are clickable on home page */
.page_category-home .calendar-event[data-post-url] {
    cursor: pointer !important;
    position: relative;
    z-index: 1;
}

/* Ensure all child elements allow clicks to pass through */
.page_category-home .calendar-event > *:not(a) {
    pointer-events: none;
}

/* But keep links clickable */
.page_category-home .calendar-event a {
    pointer-events: auto;
    position: relative;
    z-index: 2;
}

/* Override any pointer-events from child elements */
.page_category-home .calendar-event h3 {
    pointer-events: none; /* Allow clicks to pass through to parent */
}

.page_category-home .calendar-event .event-featured-image-container,
.page_category-home .calendar-event .event-date,
.page_category-home .calendar-event .event-location,
.page_category-home .calendar-event .event-excerpt {
    pointer-events: none;
}

/* Mobile styles - fix calendar events without affecting page margins */
@media (max-width: 1262px) {
    /* Apply grid layout for better control */
    .page_category-home .calendar-event {
        display: grid;
        grid-template-columns: 100%;
        grid-template-rows: auto auto auto auto auto;
        grid-template-areas:
            "title"
            "image"
            "date"
            "location"
            "excerpt";
        overflow-x: hidden;
        padding-top: 0;
        margin-top: 0 !important;
    }
    
    /* Explicit grid positioning */
    .page_category-home .calendar-event h3 {
        grid-area: title;
        width: 100%;
        box-sizing: border-box;
        padding: 0 1rem;
        margin: 0 0 0.75rem 0;
        text-align: center !important;
    }
    
    .page_category-home .calendar-event .event-featured-image-container {
        grid-area: image;
        width: 100%;
        height: 100px;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
    
    .page_category-home .calendar-event .event-featured-image {
        width: 100%;
        height: 100px;
        object-fit: cover;
        object-position: center center;
    }
    
    .page_category-home .calendar-event .event-date {
        grid-area: date;
        width: 100%;
        box-sizing: border-box;
        padding: 0.5rem 1rem;
        margin: 0;
    }
    
    .page_category-home .calendar-event .event-location {
        grid-area: location;
        width: 100%;
        box-sizing: border-box;
        padding: 0 1rem;
        margin: 0;
    }
    
    .page_category-home .calendar-event .event-excerpt {
        grid-area: excerpt;
        width: 100%;
        box-sizing: border-box;
        padding: 0.5rem 1rem;
        margin: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Button styling */
    .page_category-home .calendar-event .event-excerpt a {
        display: inline-block;
        margin-top: 0.5rem;
    }
    
    /* Fix for potentially misconfigured column layouts */
    .page_category-home .calendar-col {
        padding: 0 1rem;
        box-sizing: border-box;
        overflow-x: hidden;
    }
}