/* ============================================================
   promo.css : การ์ดโฆษณา i-Test ลอยอยู่ด้านล่างจอ (promo.php)
   ------------------------------------------------------------
   จอคอม  : การ์ดกว้าง กลางจอด้านล่าง  รูป | ชื่อ + ข้อความ | ปุ่มสมัครสมาชิก   ปุ่มปิดมุมขวาบน
   มือถือ : แถบเตี้ย รูป | ชื่อ + ปุ่มเล็ก (ซ่อนข้อความยาว) วางเหนือเมนูล่าง
   ตั้งค่าเองทั้งหมด ไม่พึ่งสไตล์ของหน้า (ใช้ได้ทั้งหน้าที่มี report.css / home.css / report_page.css)
   ============================================================ */

.ad-card {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 98;
    width: min(1080px, calc(100% - 48px));
    color: #1f1f1f;
    font-family: 'Noto Sans Thai', 'Sarabun', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
    /* ซ่อนไว้ใต้ขอบจอ แล้วเลื่อนขึ้นเมื่อสคริปต์ใส่ .on */
    transform: translate(-50%, calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
    transition: transform .65s cubic-bezier(.2, 1.25, .35, 1), opacity .35s ease;
}
.ad-card.on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
/* การ์ด i-TEST ในเนื้อหาอยู่ในจอ (promo.php) : หลบลงไปชั่วคราว */
.ad-card.on.away { transform: translate(-50%, calc(100% + 40px)); opacity: 0; pointer-events: none; }
.ad-card.off { transition-duration: .4s, .3s; transition-timing-function: ease-in, ease; }
.ad-card * { box-sizing: border-box; }

/* กรอบทองไล่สี + เงาทองฟุ้ง ให้เด่นจากพื้นหน้า */
.ad-in {
    position: relative;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    grid-template-areas: "av t go" "av d go";
    align-items: center;
    column-gap: 18px;
    row-gap: 2px;
    padding: 14px 60px 14px 14px;
    border: 2px solid transparent;
    border-radius: 24px;
    background:
        linear-gradient(90deg, #fbf2df 0, #fff 30%) padding-box,
        linear-gradient(115deg, #f1dcae, #D6B172 35%, #a8844a 62%, #ecd29c) border-box;
    box-shadow: 0 22px 50px rgba(110, 78, 26, .28), 0 0 0 6px rgba(214, 177, 114, .14);
}

/* รูปครู บนพื้นทอง + วงแหวนกระเพื่อม */
.ad-av {
    grid-area: av;
    position: relative;
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: 20px;
    background: linear-gradient(145deg, #f5e3bd, #D6B172);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), 0 6px 16px rgba(168, 132, 74, .35);
}
.ad-av img { display: block; width: 64px; height: 64px; border-radius: 16px; object-fit: cover; }
.ad-av::after {
    content: "";
    position: absolute;
    inset: -5px;
    border: 2px solid rgba(214, 177, 114, .75);
    border-radius: 24px;
    animation: ad-ring 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes ad-ring {
    0% { transform: scale(.94); opacity: .9; }
    100% { transform: scale(1.16); opacity: 0; }
}

.ad-t {
    grid-area: t;
    align-self: end;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
}
.ad-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #1f1f1f, #4a3818);
    color: #f3d9a4;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1.6;
}
.ad-d {
    grid-area: d;
    align-self: start;
    margin: 0;
    color: #5b5446;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
    /* ยาวเกิน 2 บรรทัด ตัดท้าย */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ปุ่มสมัครสมาชิก : ทองไล่สี ตัวอักษรเข้ม แสงวิ่งผ่าน (ชุดเดียวกับปุ่ม I-TEST บนเมนู) */
.ad-go {
    grid-area: go;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 26px;
    border-radius: 999px;
    overflow: hidden;
    background: linear-gradient(135deg, #e3c48e, #D6B172 45%, #c49a55);
    color: #1f1f1f;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(214, 177, 114, .55), inset 0 1px 0 rgba(255, 255, 255, .45);
    transition: transform .2s, box-shadow .2s;
}
.ad-go:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(214, 177, 114, .65); color: #1f1f1f; text-decoration: none; }
.ad-go i { font-size: 15px; transition: transform .2s; }
.ad-go:hover i { transform: translateX(4px); }
.ad-go::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .65), transparent);
    animation: ad-shine 3.6s ease-in-out 1.8s infinite;
}
@keyframes ad-shine {
    0% { left: -60%; }
    40%, 100% { left: 130%; }
}

/* ปุ่มปิด */
.ad-x {
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f3eee5;
    color: #6b604f;
    font-family: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.ad-x:hover { background: #1f1f1f; color: #fff; }
.ad-x:focus-visible, .ad-go:focus-visible { outline: 3px solid rgba(214, 177, 114, .6); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .ad-card { transition: opacity .2s ease; }
    .ad-av::after, .ad-go::after { animation: none; display: none; }
}

/* ---------- จอแคบ / มือถือ : แถบเตี้ย ---------- */
@media (max-width: 760px) {
    .ad-card { width: calc(100% - 20px); bottom: 12px; }
    .ad-in {
        grid-template-columns: 48px minmax(0, 1fr);
        grid-template-areas: "av t" "av go";
        column-gap: 12px;
        row-gap: 5px;
        padding: 9px 48px 9px 9px;
        border-radius: 18px;
        box-shadow: 0 12px 30px rgba(110, 78, 26, .28), 0 0 0 4px rgba(214, 177, 114, .14);
    }
    .ad-av { width: 48px; height: 48px; border-radius: 13px; }
    .ad-av img { width: 40px; height: 40px; border-radius: 10px; }
    .ad-av::after { inset: -4px; border-radius: 16px; }
    .ad-t { font-size: 15px; gap: 4px 8px; }
    .ad-badge { padding: 1px 8px; font-size: 10px; }
    .ad-d { display: none; }
    .ad-go { justify-self: start; height: 32px; padding: 0 14px; gap: 7px; font-size: 13px;
             box-shadow: 0 6px 14px rgba(214, 177, 114, .5), inset 0 1px 0 rgba(255, 255, 255, .45); }
    .ad-go i { font-size: 11px; }
    .ad-x { top: 50%; right: 8px; width: 32px; height: 32px; margin-top: -16px; font-size: 13px; }
}
/* มีเมนูล่าง (menu.css ≤ 480px) : วางเหนือเมนู พ้นปุ่ม I-TEST ที่ยกขึ้นกลางเมนู */
@media (max-width: 480px) {
    .ad-card { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
}

/* มือถือ : แสดงรายละเอียดด้วย (ตัวเล็ก ไม่เกิน 3 บรรทัด) ชื่อ · รายละเอียด · ปุ่ม เรียงลงมาข้างรูป (2026-09-29) */
@media (max-width: 760px) {
    .ad-in {
        grid-template-areas: "av t" "av d" "av go";
        align-items: start;
        row-gap: 3px;
    }
    .ad-av { align-self: start; }
    .ad-d {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        font-size: 11.5px;
        line-height: 1.45;
        color: #6b6152;
    }
    .ad-go { margin-top: 3px; }
    .ad-x { top: 8px; margin-top: 0; width: 28px; height: 28px; font-size: 12px; }
}
