/* ==========================================================================
   Facebook-style post grid — self-contained & embeddable.
   Layout: 4 คอลัมน์ × 2 แถว (ค่าเริ่มต้น) บนจอกว้าง — จำนวนคอลัมน์ปรับได้ผ่าน
   CSS variable --fbg-cols ที่ shortcode ใส่มาเป็น inline style,
   ย่อเป็น 2 คอลัมน์ / 1 คอลัมน์บนจอเล็ก.
   Transparent background: it shows whatever is behind it on the host page.
   Safe to drop into any site — every rule is scoped to .fbg, so it won't
   touch the host page's <body>, box-sizing, fonts or colours.
   (For the exact look, also load the Sarabun webfont on the host page;
   otherwise it falls back to the system fonts in --fbg-font.)
   ========================================================================== */

.fbg {
    --fbg-card-bg: #ffffff;
    --fbg-text: #1c1e21;
    --fbg-muted: #65676b;
    --fbg-accent: #e01b1b;          /* Academic World brand red for the logo badge */
    --fbg-link: #1877f2;            /* "ดูเพิ่มเติม" link colour */
    --fbg-radius: 12px;
    --fbg-gap: 16px;                /* gap between cards */
    --fbg-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 2px 8px rgba(0, 0, 0, .06);
    --fbg-shadow-hover: 0 6px 20px rgba(0, 0, 0, .14);
    --fbg-font: "Segoe UI", "Sarabun", "Noto Sans Thai", Tahoma, system-ui, sans-serif;
}

/* Scoped reset — only affects the grid, never the host page */
.fbg,
.fbg *,
.fbg *::before,
.fbg *::after { box-sizing: border-box; }

/* --- Layout: 4 คอลัมน์ × 2 แถว (default) --------------------------------- */
.fbg {
    display: grid;
    grid-template-columns: repeat(var(--fbg-cols, 4), 1fr);
    gap: var(--fbg-gap);
    /* max-width: 1200px; */
    margin: 0 auto;
    background: transparent;        /* shows the host page through */
    color: var(--fbg-text);
    font-family: var(--fbg-font);
    -webkit-font-smoothing: antialiased;
}

@media (max-width: 1099px) {
    .fbg { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 559px) {
    .fbg { grid-template-columns: 1fr; }
}

/* --- Card ---------------------------------------------------------------- */
.fbg-card {
    display: flex;
    flex-direction: column;
    background: var(--fbg-card-bg);
    border-radius: var(--fbg-radius);
    overflow: hidden;
    box-shadow: var(--fbg-shadow);
    transition: box-shadow .2s ease, transform .2s ease;
}

.fbg-card:hover {
    box-shadow: var(--fbg-shadow-hover);
    transform: translateY(-2px);
}

/* Media + header overlay */
.fbg-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #dfe3ea, #c6ccd6);  /* fallback tint */
    overflow: hidden;
}

/* !important: host themes/builders override plain img geometry — e.g.
   Elementor ships `.elementor img { height: auto }`, which outranks a
   single-class selector and leaves grey letterboxing under square photos. */
.fbg-card__photo {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    display: block;
}

.fbg-card__head {
    position: absolute;
    inset: 0 0 auto 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: #fff;
    background: linear-gradient(180deg, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 100%);
}

.fbg-card__logo {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--fbg-accent);
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    overflow: hidden;
}

/* When the page has a real profile picture, show it instead of the text badge */
.fbg-card__logo--img {
    background: none;
    padding: 0;
}

.fbg-card__logo--img img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    display: block;
}

.fbg-card__meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}

.fbg-card__page {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    text-decoration: none;
}

.fbg-card__page:hover { text-decoration: underline; }

.fbg-card__date {
    font-size: 11px;
    opacity: .95;
}

/* Body */
.fbg-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 14px 16px 16px;
}

.fbg-card__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--fbg-text);
    /* clamp to a few lines; the full post is behind "ดูเพิ่มเติม" */
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Inline flag (replaces flag emoji, which don't render on Windows) */
.fbg-flag {
    height: 1em;
    width: auto;
    vertical-align: -0.16em;
    margin: 0 2px;
    border-radius: 2px;
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .18);
}

.fbg-card__more {
    align-self: flex-end;
    margin-top: auto;
    padding: 8px 0 0;
    border: 0;
    background: none;
    color: var(--fbg-muted);
    font: inherit;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}

.fbg-card__more:hover { color: var(--fbg-link); text-decoration: underline; }
