/* Blog post listing: toolbar (sort/search) + card grid + category sidebar (Blog.cshtml) */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.blog-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 24px;
    animation: fadeInUp .8s ease both;
}

.blog-toolbar__field {
    display: flex;
}

    .blog-toolbar__field select,
    .blog-toolbar__field input[type="search"] {
        border: 1px solid color-mix(in srgb, var(--default-color, #3c4049), transparent 80%);
        border-radius: 999px;
        padding: 10px 16px;
        font-size: 14px;
        background: var(--surface-color, #fff);
        transition: border-color .2s ease, box-shadow .2s ease;
    }

    .blog-toolbar__field input[type="search"]:focus {
        outline: none;
        border-color: var(--accent-color-purple, #843895);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color-purple, #843895), transparent 85%);
    }

.blog-toolbar__search {
    position: relative;
    flex: 1 1 320px;
    min-width: 220px;
    max-width: 420px;
}

    .blog-toolbar__search input[type="search"] {
        width: 100%;
        padding-right: 40px;
    }

    .blog-toolbar__search button {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        color: #767676;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

.blog-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
    animation: fadeInUp .8s ease both;
}

.blog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    flex: 1 1 auto;
    min-width: 0;
}

.content-page-hero__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap; /* กันพังตอนจอแคบ ให้ search ตกลงมาอยู่แถวใหม่ */
}

.content-page-hero__title {
    margin: 0; /* กัน margin เดิมของ h1 ดันให้เพี้ยน */
}

.blog-toolbar__search {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.blog-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
}

.blog-toolbar__sort {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 1px solid color-mix(in srgb, var(--default-color, #3c4049), transparent 80%);
    border-radius: 999px;
    background: var(--surface-color, #fff);
    color: #767676;
    transition: border-color .2s ease, color .2s ease;
}

    .blog-toolbar__sort:hover {
        border-color: var(--accent-color-purple, #843895);
        color: var(--accent-color-purple, #843895);
    }

@media (min-width: 768px) {
    .blog-grid {
        grid-template-columns: repeat(var(--items-per-row-tablet, 2), 1fr);
    }
}

@media (min-width: 1200px) {
    .blog-grid {
        grid-template-columns: repeat(var(--items-per-row-desktop, 3), 1fr);
    }
}

/* LEFT / RIGTH: sidebar beside the grid, on the chosen side, from tablet width up */
@media (min-width: 768px) {
    .blog-layout--left,
    .blog-layout--right {
        flex-direction: row;
        align-items: flex-start;
    }

    .blog-layout--left .blog-sidebar,
    .blog-layout--right .blog-sidebar {
        width: 260px;
        flex: 0 0 260px;
    }

    .blog-layout--left .blog-sidebar {
        order: 1;
    }

    .blog-layout--left .blog-grid {
        order: 2;
    }

    .blog-layout--right .blog-sidebar {
        order: 2;
    }

    .blog-layout--right .blog-grid {
        order: 1;
    }
}

.blog-empty {
    color: #767676;
}

.research-related {
    margin-top: 2rem;
}

.research-related__title {
    margin: 0 0 1rem;
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 700;
    line-height: 1.3;
    color: #1d1b20;
}

.research-related__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.research-related__card .blog-card__media {
    min-height: 0;
    aspect-ratio: 16 / 9;
}

.research-related__views {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.research-related__views i {
    color: var(--accent-color-purple, #843895);
}

@media (min-width: 768px) {
    .research-related__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .research-related__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.blog-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 24px;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface-color, #fff);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--default-color, #3c4049), transparent 92%);
    transition:
        transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1),
        box-shadow 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
    /* ใช้ backwards (ไม่ใช่ both) — ถ้า fill ค้างเฟรมสุดท้ายไว้ transform จาก animation
       จะทับ transition ตอน hover ทำให้การ์ดไม่ยกตัว */
    animation: fadeInUp .8s ease backwards;
}

    .blog-card:hover {
        box-shadow: 0 6px 16px color-mix(in srgb, var(--default-color, #3c4049), transparent 90%);
        transform: translateY(-4px);
    }

    .blog-card:nth-child(2) { animation-delay: .05s; }
    .blog-card:nth-child(3) { animation-delay: .1s; }
    .blog-card:nth-child(4) { animation-delay: .15s; }
    .blog-card:nth-child(5) { animation-delay: .2s; }
    .blog-card:nth-child(6) { animation-delay: .25s; }
    .blog-card:nth-child(n+7) { animation-delay: .3s; }

/* ลิงก์โปร่งใสคลุมทั้งการ์ด (stretched link) — กดตรงไหนก็ไปหน้าโพสต์ */
.blog-card__link {
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* ลิงก์ย่อยในการ์ด (หัวข้อ/หมวดหมู่) ต้องลอยเหนือ stretched link ให้กดแยกได้ */
.blog-card__title a,
.blog-card__cat a {
    position: relative;
    z-index: 3;
}

.blog-card__media {
    position: relative;
    background-size: cover;
    background-position: center;
    background-color: color-mix(in srgb, var(--accent-color-purple, #843895), transparent 94%);
    min-height: 190px;
    transition: transform 0.75s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.blog-card:hover .blog-card__media {
    transform: scale(1.03);
}

.blog-card__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 22px 20px;
    flex: 1 1 auto;
    background: var(--surface-color, #fff);
    position: relative;
    min-width: 0;
    /* z-index: 1; */
}

.blog-card__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    order: 1;
    min-width: 0;
}

    .blog-card__title a {
        color: #1d1b20; /* M3 on-surface */
        text-decoration: none;
        transition: color .2s ease;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

        .blog-card__title a:hover {
            color: #1d1b20;
            text-decoration: none;
        }

.blog-card__subheading {
    margin: 0;
    color: var(--accent-color-purple, #843895);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    order: 0;
}

.blog-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin: 0;
    color: #1d1b20;
    font-size: 0.8125rem;
    order: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.blog-card__meta .blog-card__views,
.blog-card__meta .research-related__views {
    color: #1d1b20;
}

.blog-card__date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--default-color, #000000);
}

    .blog-card__date::before {
        content: "\f214";
        font-family: "bootstrap-icons";
        font-size: 0.85rem;
        color: inherit;
    }

/* M3 tonal chip */
.blog-card__cat a {
        display: inline-flex;
        align-items: center;
        min-height: 26px;
        max-width: 100%;
        padding: 2px 12px;
        border-radius: 8px;
        background: color-mix(in srgb, var(--accent-color-purple, #843895), transparent 90%); /* secondary container */
        color: color-mix(in srgb, var(--accent-color-purple, #843895), black 15%);
        font-size: 0.75rem;
        font-weight: 600;
        transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.blog-card__cat a:hover {
        background: color-mix(in srgb, var(--accent-color-purple, #843895), transparent 80%);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
        color: color-mix(in srgb, var(--accent-color-purple, #843895), black 25%);
    }

.blog-card__excerpt {
    margin: 0;
    color: #49454f; /* M3 on-surface-variant (text) */
    font-size: 0.875rem;
    line-height: 1.6;
    order: 2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Item text position: relative arrangement of the avatar image vs. text body */
.blog-card--text-below {
    flex-direction: column;
}

.blog-card--text-above {
    flex-direction: column-reverse;
}

.blog-card--text-left {
    flex-direction: row-reverse;
    min-height: 240px;
}

    .blog-card--text-left .blog-card__media {
        flex: 0 0 42%;
        min-height: 100%;
    }

.blog-card--text-right {
    flex-direction: row;
    min-height: 240px;
}

    .blog-card--text-right .blog-card__media {
        flex: 0 0 42%;
        min-height: 100%;
    }

/* จอแคบ: การ์ดแบบรูปข้างตัวหนังสือกลับเป็นแนวตั้ง ไม่งั้นทั้งคู่โดนบีบ */
@media (max-width: 575px) {
    .blog-card--text-left,
    .blog-card--text-right {
        flex-direction: column;
        min-height: 0;
    }

    .blog-card--text-left .blog-card__media,
    .blog-card--text-right .blog-card__media {
        flex: 0 0 auto;
        min-height: 180px;
    }
}

.blog-card--text-overlay {
    position: relative;
    min-height: 260px;
    justify-content: flex-end;
}

    .blog-card--text-overlay .blog-card__media {
        position: absolute;
        inset: 0;
        min-height: 100%;
    }

    .blog-card--text-overlay .blog-card__body {
        position: relative;
        z-index: 3;
        padding: 56px 22px 20px;
        background: linear-gradient(to top, rgba(29, 27, 32, .90) 0%, rgba(29, 27, 32, .55) 55%, rgba(29, 27, 32, 0) 100%);
        color: #fff;
    }

    .blog-card--text-overlay .blog-card__title a {
        color: #fff;
    }

        .blog-card--text-overlay .blog-card__title a:hover {
            color: #fff;
        }

    .blog-card--text-overlay .blog-card__subheading {
        color: var(--accent-color-yellow, #e2ae0d);
    }

    .blog-card--text-overlay .blog-card__meta,
    .blog-card--text-overlay .blog-card__date,
    .blog-card--text-overlay .blog-card__meta .blog-card__views,
    .blog-card--text-overlay .blog-card__meta .research-related__views {
        color: rgba(255, 255, 255, .8);
    }

    .blog-card--text-overlay .blog-card__meta {
        border-top-color: rgba(255, 255, 255, .22);
    }

    .blog-card--text-overlay .blog-card__date::before {
        color: color-mix(in srgb, var(--accent-color-purple, #843895), white 50%);
    }

    .blog-card--text-overlay .blog-card__cat a {
        background: rgba(255, 255, 255, .18);
        color: #fff;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

        .blog-card--text-overlay .blog-card__cat a:hover {
            background: rgba(255, 255, 255, .3);
            color: #fff;
        }

    .blog-card--text-overlay .blog-card__title,
    .blog-card--text-overlay .blog-card__subheading {
        text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
    }

    .blog-card--text-overlay .blog-card__meta,
    .blog-card--text-overlay .blog-card__excerpt {
        text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
    }

    .blog-card--text-overlay .blog-card__excerpt {
        color: rgba(255, 255, 255, .85);
    }

    .blog-card--text-overlay .blog-card__excerpt {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

.blog-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 0 0 auto;
}

.blog-sidebar__categories {
    padding: 1.5rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
}

    .blog-sidebar__categories h4 {
        margin: 0 0 1rem;
        font-size: 1.2rem;
        font-weight: 700;
        line-height: 1.3;
        color: #111827;
    }

    .blog-sidebar__categories ul {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .blog-sidebar__categories ul + ul {
        margin-top: 0.35rem;
    }

    .blog-sidebar__categories ul ul {
        margin: 0.35rem 0 0 16px;
    }

    .blog-sidebar__categories a {
        display: block;
        padding: 0.6rem 1.25rem;
        border-radius: 999px;
        color: #111827;
        font-size: 0.98rem;
        font-weight: 500;
        line-height: 1.45;
        text-decoration: none;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .blog-sidebar__categories a:hover {
        background: #f0f0f0;
        color: var(--accent-color, #843895);
    }

    .blog-sidebar__categories li.is-active > a {
        background: #f0f0f0;
        font-weight: 600;
    }

    .blog-sidebar__categories li.is-active > a:hover {
        background: #e8e8e8;
    }

    .blog-sidebar__categories details:not([open]) > ul {
        display: none;
    }

    .blog-sidebar__categories details > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        cursor: pointer;
        list-style: none;
        padding: 0.6rem 1.25rem;
        border-radius: 999px;
        color: #111827;
        font-size: 0.98rem;
        font-weight: 500;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

        .blog-sidebar__categories details > summary::-webkit-details-marker {
            display: none;
        }

        .blog-sidebar__categories details > summary:hover {
            background: #f0f0f0;
            color: var(--accent-color, #843895);
        }

    .blog-category-toggle {
        display: inline-flex;
        color: #767676;
        font-size: 11px;
        transition: transform .15s ease;
    }

    .blog-sidebar__categories details[open] > summary .blog-category-toggle {
        transform: rotate(90deg);
    }

@media (max-width: 767px) {
    .blog-sidebar__categories {
        padding: 1.15rem;
        border-radius: 16px;
    }

        .blog-sidebar__categories h4 {
            font-size: 1.05rem;
        }
}

.blog-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    justify-content: center;
}

    .blog-pagination a,
    .blog-pagination span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        height: 40px;
        padding: 0 12px;
        border: none;
        border-radius: 999px;
        font-size: 14px;
        color: #49454f;
        text-decoration: none;
        transition: background-color .2s ease, color .2s ease;
    }

    .blog-pagination a:not(.is-active):hover {
        background: color-mix(in srgb, var(--accent-color-purple, #843895), transparent 92%);
    }

    .blog-pagination a:hover {
        border-color: var(--accent-color-purple);
        color: var(--accent-color-purple);
    }

    .blog-pagination a.is-active {
        background: var(--accent-color-purple);
        border-color: var(--accent-color-purple);
        color: var(--surface-color);
    }

    .blog-pagination span.is-disabled {
        color: #c2c2c2;
        cursor: default;
    }

/* Sub Page Listing block (blockgrid/Components/subPageListing.cshtml) */

.spl {
    position: relative;
    margin: 16px 0;
}

/* หัวข้อ block ให้หนา/ขนาดเท่ากับหัวข้อของ pods-block (.pods-block .gallery__heading ใน main.css) */
.spl .gallery__heading-group {
    margin-bottom: 1rem;
}

.spl .gallery__heading {
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
}

/* ซ่อนหัวข้อแล้วเหลือแต่ปุ่ม - ให้ปุ่มยังอยู่ขวาเหมือนตอนมีหัวข้อ */
.gallery__heading-group-subpage > .gallery__buttons:only-child {
    margin-left: auto;
}

.umb-block-grid__layout-item:not(:has(*)) {
    display: none;
}

/* Item text position, applied from the block wrapper so cards don't need per-card classes */
.spl--text-above .blog-card {
    flex-direction: column-reverse;
}

.spl--text-left .blog-card {
    flex-direction: row-reverse;
    min-height: 240px;
}

    .spl--text-left .blog-card__media {
        flex: 0 0 42%;
        min-height: 100%;
    }

.spl--text-right .blog-card {
    flex-direction: row;
    min-height: 240px;
}

    .spl--text-right .blog-card__media {
        flex: 0 0 42%;
        min-height: 100%;
    }

@media (max-width: 575px) {
    .spl--text-left .blog-card,
    .spl--text-right .blog-card {
        flex-direction: column;
        min-height: 0;
    }

    .spl--text-left .blog-card__media,
    .spl--text-right .blog-card__media {
        flex: 0 0 auto;
        min-height: 180px;
    }
}

.spl--text-overlay .blog-card {
    position: relative;
    min-height: 260px;
    justify-content: flex-end;
}

    .spl--text-overlay .blog-card__media {
        position: absolute;
        inset: 0;
        min-height: 100%;
    }

    .spl--text-overlay .blog-card__body {
        position: relative;
        z-index: 3;
        flex: 0 0 auto;
        width: 100%;
        margin-top: auto;
        padding: 56px 22px 20px;
        background: linear-gradient(to top, rgba(29, 27, 32, .90) 0%, rgba(29, 27, 32, .55) 55%, rgba(29, 27, 32, 0) 100%);
        color: #fff;
    }

    .spl--text-overlay .blog-card__title a {
        color: #fff;
    }

        .spl--text-overlay .blog-card__title a:hover {
            color: #fff;
        }

    .spl--text-overlay .blog-card__subheading {
        color: var(--accent-color-yellow, #e2ae0d);
    }

    .spl--text-overlay .blog-card__meta,
    .spl--text-overlay .blog-card__date,
    .spl--text-overlay .blog-card__meta .blog-card__views,
    .spl--text-overlay .blog-card__meta .research-related__views {
        color: rgba(255, 255, 255, .8);
    }

    .spl--text-overlay .blog-card__meta {
        border-top-color: rgba(255, 255, 255, .22);
    }

    .spl--text-overlay .blog-card__date::before {
        color: color-mix(in srgb, var(--accent-color-purple, #843895), white 50%);
    }

    .spl--text-overlay .blog-card__cat a {
        background: rgba(255, 255, 255, .18);
        color: #fff;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

        .spl--text-overlay .blog-card__cat a:hover {
            background: rgba(255, 255, 255, .3);
            color: #fff;
        }

    .spl--text-overlay .blog-card__title,
    .spl--text-overlay .blog-card__subheading {
        text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
    }

    .spl--text-overlay .blog-card__meta,
    .spl--text-overlay .blog-card__excerpt {
        color: rgba(255, 255, 255, .85);
        text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
    }

    .spl--text-overlay .blog-card__excerpt {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

/* Image group: hide / opacity / crop style */
.spl--hide-image .blog-card__media {
    display: none;
}

.spl .blog-card__media {
    opacity: var(--spl-img-opacity, 1);
    transition: opacity .2s ease;
}

.spl .blog-card:hover .blog-card__media {
    opacity: var(--spl-img-opacity-hover, 1);
}

.spl--image-square .blog-card__media { aspect-ratio: 1 / 1; }
.spl--image-circle .blog-card__media { aspect-ratio: 1 / 1; border-radius: 50%; }
.spl--image-landscape .blog-card__media { aspect-ratio: 4 / 3; }
.spl--image-portrait .blog-card__media { aspect-ratio: 3 / 4; }
.spl--image-wide .blog-card__media { aspect-ratio: 21 / 9; }
.spl--image-tall .blog-card__media { aspect-ratio: 2 / 3; }
.spl--image-16x9 .blog-card__media { aspect-ratio: 16 / 9; }
.spl--image-4x3 .blog-card__media { aspect-ratio: 4 / 3; }
.spl--image-3x4 .blog-card__media { aspect-ratio: 3 / 4; }
.spl--image-10x4 .blog-card__media { aspect-ratio: 10 / 3.3; }
.spl--text-overlay.spl--image-10x4 .blog-card { aspect-ratio: 10 / 3.3; }

/* Tabs (one per picked Blog/Category, only rendered when more than one is picked) */
.spl-tabs {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.spl-tabs__radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.spl-tabs__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.spl-tabs__label {
    position: relative;
    cursor: pointer;
    padding: 8px 18px;
    font-size: 16px;
    color: #4a4a4a;
    user-select: none;
    transition: color .2s ease;
}

/* เส้นใต้ยาวเท่าตัวอักษร ไม่รวม padding - border-bottom จะยาวเต็ม element
   left/right ต้องเท่ากับ horizontal padding ของ label */
.spl-tabs__label::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 4px;
    height: 2px;
    border-radius: 2px;
    background: transparent;
    transition: background-color .2s ease;
}

/* BASIC: ตัวอักษรเปล่า ๆ */
.spl-tabs--basic .spl-tabs__label {
    border-bottom: none;
}

/* BUTTON: pill buttons */
.spl-tabs--button .spl-tabs__label {
    border: 1px solid #e2e2e2;
    border-radius: 999px;
}

/* UNDERLINE: เส้นคั่นใต้แถบ tab ทั้งแถว */
.spl-tabs--underline .spl-tabs__nav {
    border-bottom: 1px solid #e2e2e2;
}

.spl-tabs--underline .spl-tabs__label {
    border-bottom: none;
    margin-bottom: 0;
}

.spl-tabs__panel {
    display: none;
}

/* Active tab: ตัวอักษรม่วง + เส้นใต้ม่วงยาวเท่าตัวอักษร เหมือนกันทุก tab style
   .spl-tabs__nav อยู่ข้างใน .spl-tabs__header ไม่ใช่ sibling ของ radio จึงต้องไล่ผ่าน header */
.spl-tabs__radio:nth-of-type(1):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(1),
.spl-tabs__radio:nth-of-type(2):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(2),
.spl-tabs__radio:nth-of-type(3):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(3),
.spl-tabs__radio:nth-of-type(4):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(4),
.spl-tabs__radio:nth-of-type(5):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(5),
.spl-tabs__radio:nth-of-type(6):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(6),
.spl-tabs__radio:nth-of-type(7):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(7),
.spl-tabs__radio:nth-of-type(8):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(8),
.spl-tabs__radio:nth-of-type(9):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(9),
.spl-tabs__radio:nth-of-type(10):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(10) {
    color: var(--accent-color-purple, #843895);
    font-weight: 600;
}

.spl-tabs__radio:nth-of-type(1):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(1)::after,
.spl-tabs__radio:nth-of-type(2):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(2)::after,
.spl-tabs__radio:nth-of-type(3):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(3)::after,
.spl-tabs__radio:nth-of-type(4):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(4)::after,
.spl-tabs__radio:nth-of-type(5):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(5)::after,
.spl-tabs__radio:nth-of-type(6):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(6)::after,
.spl-tabs__radio:nth-of-type(7):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(7)::after,
.spl-tabs__radio:nth-of-type(8):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(8)::after,
.spl-tabs__radio:nth-of-type(9):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(9)::after,
.spl-tabs__radio:nth-of-type(10):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(10)::after {
    background: var(--accent-color-purple, #843895);
}

/* BUTTON: active ก็ให้เป็นเส้นใต้เหมือนกัน - ขอบ pill เปลี่ยนเป็นม่วง ไม่ถมพื้น */
.spl-tabs--button .spl-tabs__radio:nth-of-type(1):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(1),
.spl-tabs--button .spl-tabs__radio:nth-of-type(2):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(2),
.spl-tabs--button .spl-tabs__radio:nth-of-type(3):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(3),
.spl-tabs--button .spl-tabs__radio:nth-of-type(4):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(4),
.spl-tabs--button .spl-tabs__radio:nth-of-type(5):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(5),
.spl-tabs--button .spl-tabs__radio:nth-of-type(6):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(6),
.spl-tabs--button .spl-tabs__radio:nth-of-type(7):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(7),
.spl-tabs--button .spl-tabs__radio:nth-of-type(8):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(8),
.spl-tabs--button .spl-tabs__radio:nth-of-type(9):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(9),
.spl-tabs--button .spl-tabs__radio:nth-of-type(10):checked ~ .spl-tabs__header .spl-tabs__label:nth-child(10) {
    border-color: var(--accent-color-purple, #843895);
}

.spl-tabs__radio:nth-of-type(1):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(1),
.spl-tabs__radio:nth-of-type(2):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(2),
.spl-tabs__radio:nth-of-type(3):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(3),
.spl-tabs__radio:nth-of-type(4):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(4),
.spl-tabs__radio:nth-of-type(5):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(5),
.spl-tabs__radio:nth-of-type(6):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(6),
.spl-tabs__radio:nth-of-type(7):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(7),
.spl-tabs__radio:nth-of-type(8):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(8),
.spl-tabs__radio:nth-of-type(9):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(9),
.spl-tabs__radio:nth-of-type(10):checked ~ .spl-tabs__panels .spl-tabs__panel:nth-child(10) {
    display: block;
}

/* Carousel: turns the card grid into a horizontally snapping strip, showing exactly
   "Items per row" cards per view (same --items-per-row-* variables as the plain grid) */
.spl--carousel .blog-grid,
.spl--carousel .spl-tabs__panel .blog-grid {
    display: flex;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;

    /* เผื่อที่ให้เงาการ์ด + ตอน hover ยกตัว ไม่โดนกรอบเลื่อนตัดขอบ
       (ชดเชยด้วย margin ลบ ให้ layout โดยรวมอยู่ที่เดิม) */
    padding: 12px 8px 32px;
    margin: -12px -8px -16px;

    /* Hide the scrollbar - navigation is via the arrows/dots, not the native scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    .spl--carousel .blog-grid::-webkit-scrollbar,
    .spl--carousel .spl-tabs__panel .blog-grid::-webkit-scrollbar {
        display: none;
    }

.spl--carousel .blog-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
}

@media (min-width: 768px) {
    .spl--carousel .blog-card {
        flex-basis: calc((100% - (var(--items-per-row-tablet, 2) - 1) * 24px) / var(--items-per-row-tablet, 2));
    }
}

@media (min-width: 1200px) {
    .spl--carousel .blog-card {
        flex-basis: calc((100% - (var(--items-per-row-desktop, 3) - 1) * 24px) / var(--items-per-row-desktop, 3));
    }
}

/* ปุ่มลูกศร: หน้าตาเดียวกับ .pods-carousel__arrow ใน main.css */
.spl-carousel__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: #fff;
    cursor: pointer;
    color: color-mix(in srgb, var(--heading-color, #843895), transparent 15%);
    font-size: 1.1rem;
    line-height: 1;
    z-index: 2;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.14);
    transition:
        color 0.25s ease,
        transform 0.25s ease,
        box-shadow 0.25s ease,
        background-color 0.25s ease;
}

    .spl-carousel__arrow:hover {
        color: var(--accent-color-purple, #843895);
        box-shadow: 0 6px 22px rgba(15, 23, 42, 0.18);
        transform: translateY(-50%) scale(1.06);
    }

    .spl-carousel__arrow:active {
        transform: translateY(-50%) scale(0.96);
    }

    .spl-carousel__arrow:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color-purple, #843895), transparent 75%);
    }

    .spl-carousel__arrow--prev {
        left: -8px;
    }

    .spl-carousel__arrow--next {
        right: -8px;
    }

    .spl-carousel__arrow[hidden],
    .spl-carousel__dots[hidden] {
        display: none !important;
    }

.spl-carousel__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

    .spl-carousel__dots button {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        border: none;
        background: #e2e2e2;
        cursor: pointer;
        padding: 0;
    }

    .spl-carousel__dots button.is-active {
        background: var(--accent-color-purple, #843895);
    }

@media (prefers-reduced-motion: reduce) {
    .blog-toolbar,
    .blog-layout,
    .blog-card {
        animation: none;
    }
}

/*--------------------------------------------------------------
# Detail pages with category sidebar (personnel / training / blog / news)
--------------------------------------------------------------*/
.detail-post-page .content-page__layout {
    display: grid;
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    align-items: stretch;
    justify-items: stretch;
    gap: 1.75rem;
    margin-top: 0.5rem;
}

.detail-post-page.content-page--layout-right .content-page__layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
}

.detail-post-page .content-page__nav,
.detail-post-page .content-page__main {
    margin: 0 !important;
    padding: 0 !important;
}

/* Nav column holds the section nav plus the category panel, so the column is what sticks —
   sticking each aside on its own would let the second slide over the first */
.detail-post-page .content-page__nav {
    position: sticky !important;
    top: calc(var(--header-height, 80px) + 1rem) !important;
    align-self: start;
}

.detail-post-page .content-page__nav > .training-sidebar,
.detail-post-page .content-page__nav > .blog-sidebar,
.detail-post-page .content-page__nav > aside {
    position: static;
    top: auto;
    margin: 0 !important;
}

.detail-post-page .training-sidebar,
.detail-post-page .blog-sidebar {
    margin: 0 !important;
    gap: 0 !important;
}

.detail-post-page .training-sidebar__categories,
.detail-post-page .blog-sidebar__categories {
    margin: 0 !important;
}

.detail-post-page .research-post__article,
.detail-post-page .personnel-post,
.detail-post-page .training-post,
.detail-post-page .news-post {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none;
}

.detail-post-page .research-detail,
.detail-post-page .research-detail--with-cover {
    margin: 0 0 1rem 0 !important;
    padding: 0 !important;
}

.detail-post-page .research-detail__aside,
.detail-post-page .research-detail__media,
.detail-post-page .research-detail__content,
.detail-post-page .personnel-post__header,
.detail-post-page .training-post__header,
.detail-post-page .news-post__header,
.detail-post-page .news-post__cover,
.detail-post-page .research-post__title {
    margin-top: 0 !important;
}

.detail-post-page .personnel-post__header,
.detail-post-page .training-post__header,
.detail-post-page .news-post__header {
    margin-bottom: 0.75rem;
}

.detail-post-page .research-post__title {
    margin-bottom: 0.6rem;
}

.detail-post-page .news-post__cover {
    margin-bottom: 1rem;
}

@media (max-width: 991px) {
    .detail-post-page .content-page__layout {
        grid-template-columns: 1fr !important;
    }

    .detail-post-page .content-page__nav {
        position: static !important;
        top: auto !important;
    }
}


/* Blog detail: headline row + share + footer (same as News detail) */
.detail-post-page .research-post__headline-row {
    display: flex;
    flex-wrap: wrap; /* the right column is narrow, so let the share group drop */
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin: 0 0 1rem;
}

.detail-post-page .research-post__headline-row .news-post__headline-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 1rem;
}

.detail-post-page .research-post__headline-row .news-post__share {
    margin-left: auto;
}

.detail-post-page .research-post__date,
.detail-post-page .news-post__share-label {
    color: #000000;
    font-size: 0.825rem;
    line-height: 1.4;
}

.detail-post-page .research-post__downloads-count,
.detail-post-page .research-post__downloads-count span {
    color: #000000;
}

.detail-post-page .news-post__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 0;
    border-top: 0;
}

.detail-post-page .news-post__footer-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.detail-post-page .news-post__footer .news-post__publisher,
.detail-post-page .news-post__footer .news-post__views {
    margin: 0;
    color: #000000;
    font-size: 0.825rem;
}

/* Blog detail: fact list reads black, categories render as tonal pills */
.detail-post-page .research-post__fact-label,
.detail-post-page .research-post__fact-value {
    color: #000000;
}

.detail-post-page .news-post__cats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    background: none;
    font-size: 0; /* hides the "," separators emitted between category links */
}

.detail-post-page .news-post__cats a {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color-purple, #843895), transparent 90%);
    color: var(--accent-color-purple, #843895);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition: background-color .2s ease, color .2s ease;
}

.detail-post-page .news-post__cats a:hover {
    background: color-mix(in srgb, var(--accent-color-purple, #843895), transparent 82%);
    color: color-mix(in srgb, var(--accent-color-purple, #843895), black 15%);
    text-decoration: none;
}

/* the "·" separator from main.css is redundant once each link is a pill */
.detail-post-page .news-post__cats a + a::before {
    content: none;
}

@media (max-width: 575px) {
    .detail-post-page .research-post__headline-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-post-page .research-post__headline-row .news-post__share {
        margin-left: 0;
    }

    .detail-post-page .news-post__footer {
        align-items: flex-start;
        flex-direction: column;
        justify-content: flex-start;
    }

    .detail-post-page .news-post__footer-meta {
        margin-left: 0;
    }
}

.spl-tabs__header,
.gallery__heading-group-subpage {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.spl-cta__link {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* โหมด overlay: รูปยึดเต็มการ์ดด้วย inset:0 เสมอ ดังนั้น aspect-ratio ต้องไปกำหนดที่ตัวการ์ดแทน */
.spl--text-overlay.spl--image-square .blog-card { aspect-ratio: 1 / 1; }
.spl--text-overlay.spl--image-circle .blog-card { aspect-ratio: 1 / 1; }
.spl--text-overlay.spl--image-landscape .blog-card { aspect-ratio: 4 / 3; }
.spl--text-overlay.spl--image-portrait .blog-card { aspect-ratio: 3 / 4; }
.spl--text-overlay.spl--image-wide .blog-card { aspect-ratio: 21 / 9; }
.spl--text-overlay.spl--image-tall .blog-card { aspect-ratio: 2 / 3; }
.spl--text-overlay.spl--image-16x9 .blog-card { aspect-ratio: 16 / 9; }
.spl--text-overlay.spl--image-4x3 .blog-card { aspect-ratio: 4 / 3; }
.spl--text-overlay.spl--image-3x4 .blog-card { aspect-ratio: 3 / 4; }

/* Position text (overlay only): panel floats over the image on one side */
.spl--text-overlay.spl--content-left .blog-card,
.spl--text-overlay.spl--content-right .blog-card {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 320px;
}

/* media ยังคงยึดเต็มการ์ดเหมือน overlay ปกติ - ไม่แตะ position */
.spl--text-overlay.spl--content-left .blog-card__body,
.spl--text-overlay.spl--content-right .blog-card__body {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 32%;
    min-width: 260px;
    z-index: 3;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    padding: 28px 24px;
    color: #fff;
}

.spl--text-overlay.spl--content-left .blog-card__body {
    left: 0;
    background: linear-gradient(90deg, rgba(20, 22, 30, .9) 0%, rgba(20, 22, 30, .9) 10%, rgba(20, 22, 30, 0) 100%);
}

.spl--text-overlay.spl--content-right .blog-card__body {
    right: 0;
    background: linear-gradient(270deg, rgba(20, 22, 30, .9) 0%, rgba(20, 22, 30, .9) 10%, rgba(20, 22, 30, 0) 100%);
}

.spl--text-overlay.spl--content-left .blog-card__title a,
.spl--text-overlay.spl--content-right .blog-card__title a,
.spl--text-overlay.spl--content-left .blog-card__subheading,
.spl--text-overlay.spl--content-right .blog-card__subheading {
    color: #fff;
}

.spl--text-overlay.spl--content-left .blog-card__meta,
.spl--text-overlay.spl--content-right .blog-card__meta,
.spl--text-overlay.spl--content-left .blog-card__date,
.spl--text-overlay.spl--content-right .blog-card__date,
.spl--text-overlay.spl--content-left .blog-card__excerpt,
.spl--text-overlay.spl--content-right .blog-card__excerpt {
    color: rgba(255, 255, 255, .85);
}

.blog-card__readmore {
    position: relative;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 6px;
    margin-top: auto;
    padding: 8px 18px;
    border-radius: 999px;
    background: #fff;
    color: #1d1b20;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    order: 9;
}

.blog-card__readmore:hover {
    background: #f0f0f0;
    color: #1d1b20;
    text-decoration: none;
}

@media (max-width: 767px) {
    .spl--text-overlay.spl--content-left .blog-card,
    .spl--text-overlay.spl--content-right .blog-card {
        aspect-ratio: auto;
        min-height: 340px;
    }

    .spl--text-overlay.spl--content-left .blog-card__body,
    .spl--text-overlay.spl--content-right .blog-card__body {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        min-width: 0;
        margin-top: auto;
        background: linear-gradient(to top, rgba(20, 22, 30, .92) 0%, rgba(20, 22, 30, .6) 60%, rgba(20, 22, 30, 0) 100%);
    }
}

@media (max-width: 767px) {
    .spl--text-overlay.spl--image-10x4 .blog-card,
    .spl--text-overlay.spl--content-left .blog-card,
    .spl--text-overlay.spl--content-right .blog-card {
        aspect-ratio: 3 / 4;
        flex-direction: column;
        justify-content: flex-end;
        min-height: 0;
    }

    .spl--text-overlay.spl--content-left .blog-card__media,
    .spl--text-overlay.spl--content-right .blog-card__media {
        position: absolute;
        inset: 0;
        flex: none;
        min-height: 100%;
        aspect-ratio: auto;
    }

    .spl--text-overlay.spl--content-left .blog-card__body,
    .spl--text-overlay.spl--content-right .blog-card__body {
        position: relative;
        z-index: 3;
        flex: 0 0 auto;
        width: 100%;
        margin-top: auto;
        padding: 56px 22px 20px;
        background: linear-gradient(to top, rgba(29, 27, 32, .90) 0%, rgba(29, 27, 32, .55) 55%, rgba(29, 27, 32, 0) 100%);
    }
}