/* =========================================
   1. Base Grid Layout & Proportional Scaling 
   ========================================= */
.act-grid { 
    line-height: 1.25; 
    width: 100%; 
    padding: 0 0.078125em; 
    font-size: 2rem; 
    font-family: catamaran, Arial, PingFangTC, Microsoft JhengHei revise, "Microsoft JhengHei", "Microsoft YaHei", sans-serif; 
}

/* Dynamic Font Scaling: this scales all 'em' values perfectly across screen sizes */
@media (max-width: 1919.98px) { .act-grid { font-size: 1.875rem; } }
@media (max-width: 1629.98px) { .act-grid { font-size: 1.75rem; } }
@media (max-width: 1439.98px) { .act-grid { font-size: 1.5625rem; } }
@media (max-width: 1199.98px) { .act-grid { font-size: 1.25rem; } }
@media (max-width: 991.98px) { .act-grid { padding: 0; font-size: 1.25rem; } }
@media (max-width: 767.98px) { .act-grid { font-size: 1.0625rem; } }

.act-grid__row { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-around; }
.act-grid__col { width: calc(100% / 1910 * 761 - 0.078125em); display: flex; flex-direction: column; justify-content: space-between; }
.act-grid__col-2 { width: calc(100% / 1910 * 378 - 0.078125em); display: flex; flex-direction: column; justify-content: space-between; }
.act-grid__item { display: flex; margin-bottom: 0.15625em; overflow: hidden; text-decoration: none !important; }

/* FIX: Restored to display: block; to fix height calculation for dotdotdot */
.act-grid__item-wrap { position: relative; width: 100%; height: 100%; transition: transform 0.4s; display: block; }

/* Flex Settings */
.act-grid__item--2, .act-grid__item--3, .act-grid__item--5 { flex: 1; }

/* =========================================
   2. COLOR MAPPING (With Transparency) 
   ========================================= */
/* ITEMS 1, 4, 5 -> PURPLE (Solid wrapper, transparent detail box) */
.act-grid__item--1 .act-grid__item-wrap,
.act-grid__item--4 .act-grid__item-wrap,
.act-grid__item--5 .act-grid__item-wrap { background: #663399; }

.act-grid__item--1 .act-grid__detail,
.act-grid__item--4 .act-grid__detail,
.act-grid__item--5 .act-grid__detail { background: rgba(102, 51, 153, 0.9); /* 90% opacity */ }

/* ITEMS 2, 3, 6 -> DARK BLUE (Solid wrapper, transparent detail box) */
.act-grid__item--2 .act-grid__item-wrap,
.act-grid__item--3 .act-grid__item-wrap,
.act-grid__item--6 .act-grid__item-wrap { background: #0054a6; }

.act-grid__item--2 .act-grid__detail,
.act-grid__item--3 .act-grid__detail,
.act-grid__item--6 .act-grid__detail { background: rgba(0, 84, 166, 0.9); /* 90% opacity */ }

/* Full overlay for Pagination Button */
.act-grid__detail--full::before { position: absolute; content: ""; width: 100%; height: 100%; opacity: 1; background: rgba(0, 84, 166, 0.9); top: 0; z-index: -1; }


/* =========================================
   3. Hover Animations & Backgrounds
   ========================================= */
.act-grid__item-wrap:focus .act-grid__bg, .act-grid__item-wrap:hover .act-grid__bg { transform: scale(1.1); }
.act-grid__bg { transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); z-index: 1; position: relative; }

/* Aspect Ratio Placeholders */
.placeholder { display: block; width: 100%; padding: 0; overflow: hidden; }
.placeholder__item { position: absolute; top: 0; left: 0; bottom: 0; height: 100%; width: 100%; border: 0; object-fit: cover; z-index: 1; }
.placeholder--sqr { padding-top: 100%; }
.placeholder--act-grid { padding-top: 30.42328042%; }
.placeholder--act-grid-2 { padding-top: 101.32275132%; }
.act-grid__item--2 .act-grid__item-wrap .placeholder, .act-grid__item--3 .act-grid__item-wrap .placeholder { width: 50%; }

/* =========================================
   4. Detail Overlays
   ========================================= */
.act-grid__detail { 
    padding: 1.28125em 0.875em; 
    color: #fff; 
    height: auto; 
    width: calc(100% * 635 / 761); 
    position: absolute; 
    left: 0; 
    bottom: 0; 
    z-index: 2; 
    display: flex; 
    flex-direction: column; 
    justify-content: center;
    transform: translateZ(0);
}

.act-grid__detail--right { width: 50%; left: auto; right: 0; height: 100%; }
.act-grid__detail--bottom { width: 100%; height: calc(100% * 230 / 608); }
.act-grid__detail--full { padding: 0; width: 100%; height: 100%; background: transparent !important; justify-content: center; }

/* =========================================
   5. Typography (Original Max-Height Method)
   ========================================= */
.act-grid__title { 
    font-weight: 400; 
    margin: 0; 
    color: #fff; 
    overflow: hidden;
    padding-bottom: 0.125em;
    height: auto;
    max-height: 3.125em;
    line-height: 1.25;
    flex-shrink: 0; /* FIX: Prevents Flexbox from squishing the box before dotdotdot measures it */
}


@media (max-width: 1629.98px) { .act-grid__title { max-height: 3.25em; } }
@media (max-width: 1439.98px) { .act-grid__title { max-height: 3.4em; } }
@media (max-width: 1199.98px) { .act-grid__title { max-height: 3.4em; } }
@media (max-width: 991.98px) { .act-grid__title { max-height: 3.4em; } }
@media (max-width: 767.98px) { .act-grid__title { max-height: 3.52941176em; } }

.act-grid__info { margin-top: 0.3em; }

/* Changed to inline-flex to align icon and text, added border-radius for Pill shape */
.act-grid__tag { 
    display: inline-flex; 
    align-items: center;
    color: #4e4e4e; 
    font-size: 0.5em; 
    font-weight: 700; 
    line-height: 1; 
    background-color: #fff; 
    padding: 0.4375em 1.2em; /* Slightly adjusted padding for pill shape */
    margin: 0 1.125em 0 0; 
    border-radius: 500px; /* Forces the Pill shape */
}

/* Changed to inline-flex to align calendar icon with date text */
.act-grid__date { 
    font-size: 0.625em; 
    display: inline-flex; 
    align-items: center;
    white-space: nowrap; 
    font-weight: bold; 
    color: #fff; 
}

/* Buttons */
.act-grid__title--more { display: flex; flex-direction: column; text-align: center; position: absolute; font-size: 0.5625em; left: 50%; top: 50%; transform: translate(-50%, -50%); transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); color: #fff; width: 100%;}
.act-grid__item--6:hover .act-grid__title--more { transform: translate(-50%, -50%) scale(1.1); }
.act-grid__title--more .ico { font-size: 5.27777778em; margin-bottom: 5px; display: inline-block; }

/* =========================================
   DESKTOP SPECIFIC FIXES (Pure Math Approach)
   ========================================= */
@media (min-width: 992px) {
    /* 1. Make Item 6 (Buttons) exactly half-height when there is only 1 button */
    .act-grid__item--6 .act-grid__item-wrap:only-child .placeholder--sqr {
        padding-top: 50%;
    }

    /* 2. Force the wrapper to act as a strict bounding box */
    .act-grid__item--5 .act-grid__item-wrap {
        position: relative;
        display: block;
        height: 100%;
    }

    /* 3. Disable the restrictive placeholder so it doesn't fight Flexbox */
    .act-grid__item--5 .placeholder--act-grid-2 {
        padding-top: 0 !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    /* 4. Keep Item 5's textbox the EXACT same physical height it was before */
    .act-grid__item--5 .act-grid__detail--bottom {
        height: 33%;
        min-height: 130px; /* Safe fallback to prevent squishing */
    }
}




/* =========================================
   6. RESPONSIVE (Tablet / Mobile)
   ========================================= */
@media (max-width: 991.98px) {
    .act-grid__row { justify-content: space-between; }
    .act-grid__col { width: calc(50% - 0.078125em); }
    .act-grid__col-2 { width: 100%; flex-direction: row; }
    
    .act-grid__detail { padding: 1.25em 1.2em; }
    
    /* FIX: Items 2 & 3 - Position relative naturally drops them below the image! */
    .act-grid__detail--right { width: 100%; height: auto; position: relative; }
    .act-grid__item--2 .act-grid__item-wrap .placeholder, 
    .act-grid__item--3 .act-grid__item-wrap .placeholder { width: 100%; }
    .placeholder--act-grid { padding-top: 60.84656085%; }
    
    /* FIX: Item 5 Mobile Stacking */
    .act-grid__item--5 { width: calc(100% / 3 * 2 - 0.078125em); flex: initial; }
    .act-grid__item--5 .act-grid__item-wrap { display: flex; flex-direction: row; }
    .act-grid__item--5 .placeholder { width: calc(100% * 156 / 512); }
    .act-grid__item--5 .placeholder--act-grid-2 { padding-top: calc(100% * 156 / 512); }
    .act-grid__detail--bottom { width: calc(100% * 356 / 512); height: auto; position: relative; left: auto; display: flex; flex-direction: column; justify-content: center; }
    
    .act-grid__item--6 { width: calc(100% / 3 - 0.078125em); }
    .placeholder--act-grid-2 { padding-top: 62.15139442%; }
    .act-grid__title--more { font-size: 0.8em; }
        /* Force Item 6 (Buttons) to be half-height when there is only 1 button */
    .act-grid__item--6 .act-grid__item-wrap:only-child .placeholder--sqr {
        padding-top: 50%;
    }

}

@media (max-width: 767.98px) {
    /* 1. Unhide Col 2 and set standard column widths */
    .act-grid__col { width: 100%; }
    .act-grid__col--disable { display: flex; }
    .act-grid__col-2 { flex-direction: column; width: 100%; }
    
    /* 2. Swap Order of Items 3 and 4 */
    .act-grid__item--3 { order: 2; }
    .act-grid__item--4 { order: 1; }
    
    /* 3. Standardize All Items (1 through 5) to Stack Vertically */
    .act-grid__item { width: 100%; }
    .act-grid__item-wrap,
    .act-grid__item--5 .act-grid__item-wrap { /* Added specific override for Item 5 */
        display: flex; 
        flex-direction: column; 
        height: auto; 
    }
    
    /* 4. Force 4:3 Image Ratio for All Items */
    .act-grid__item-wrap .placeholder,
    .act-grid__item--5 .placeholder,
    .act-grid__item--5 .placeholder--act-grid-2 { /* Added specific override for Item 5 */
        width: 100%; 
        padding-top: 75%; 
    }

    
    /* 5. Taller Textboxes & Natural Flow */
    .act-grid__detail, 
    .act-grid__detail--right, 
    .act-grid__detail--bottom { 
        position: relative; 
        width: 100%; 
        height: auto; 
        left: auto; 
        right: auto;
        bottom: auto;
        padding: 1.75em 1.2em; /* Increased padding for taller textbox */
    }
    
    /* 6. Bigger Title & Info */
    .act-grid__title { font-size: 1.15em; max-height: 3.6em; line-height: 1.2; }
    .act-grid__tag { font-size: 0.65em; padding: 0.6em 1.5em; }
    .act-grid__date { font-size: 0.75em; }
    
    /* 7. Next/Previous Buttons (Match Textbox Height) */
    .act-grid__item--6 { order: 3; } /* Ensure it stays at the bottom */
    .act-grid__item--6 .act-grid__item-wrap { flex-direction: row; }
    .act-grid__item--6 .placeholder { display: none; /* Remove ratio hack so height is natural */ }
    .act-grid__item--6 .act-grid__detail--full { height: auto; padding: 1.5em 1em; position: relative; }
    
    .act-grid__title--more { 
        position: relative; 
        left: auto; 
        top: auto; 
        transform: none; 
        flex-direction: row; 
        align-items: center; 
        justify-content: center; 
        font-size: 0.85em; /* Bigger button text */
    }
    .act-grid__item--6:hover .act-grid__title--more { transform: none; }
    .act-grid__title--more .ico { font-size: 2.2em; margin-right: 0.3em; margin-bottom: 0; }
}

