/* ===========================================================================
 * mes789-system / assets/css/media-engines.css
 * ---------------------------------------------------------------------------
 * หน้าตาของ Engine 1 (ฝังลิงก์) / Engine 5 (ฟิลเตอร์) / Engine 7 (GIF)
 * โหลดต่อจาก shell-nav.css
 * =========================================================================== */

/* ===========================================================================
   Engine 1 — สื่อที่ฝังจากภายนอก
   =========================================================================== */
.mes-embed {
    position: relative;
    width: 100%;
    margin: 12px 0;
    border-radius: var(--radius-sm, 9px);
    overflow: hidden;
    background: #000;
}
.mes-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* การ์ดพรีวิวลิงก์ที่ดึงรูปมาได้ */
.mes-link-card {
    display: block;
    margin: 12px 0;
    border-radius: var(--radius-sm, 9px);
    overflow: hidden;
    line-height: 0;
    border: 1px solid var(--line, #2e2323);
}
.mes-link-card img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 420px;
    object-fit: cover;
}

/* การ์ดลิงก์แบบไม่มีรูป (เช่น Google Photos) */
.mes-embed-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    padding: 14px 16px;
    border: 1px solid var(--line, #2e2323);
    border-radius: var(--radius-sm, 9px);
    background: var(--surface-2, #221a1a);
    text-decoration: none;
    color: var(--text, #ece5e0);
}
.mes-embed-card:hover { border-color: var(--gold-dim, #8a7128); }
.mes-embed-icon { font-size: 1.7rem; line-height: 1; flex-shrink: 0; }
.mes-embed-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mes-embed-text strong { font-size: .95rem; }
.mes-embed-text em {
    font-style: normal;
    font-size: .8rem;
    color: var(--text-dim, #a1938c);
}

/* GIF ในโพสต์ */
.mes-gif {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px 0;
    border-radius: var(--radius-sm, 9px);
}

/* ===========================================================================
   Engine 7 — หน้าต่างเลือก GIF
   =========================================================================== */
.gif-picker {
    border: 1px solid var(--line, #2e2323);
    border-radius: var(--radius, 14px);
    background: var(--surface, #1a1414);
    padding: 12px;
    margin-top: 10px;
}
.gif-picker-search {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.gif-picker-search input {
    flex: 1;
    padding: .55rem .9rem;
    border-radius: 999px;
    border: 1px solid var(--line, #2e2323);
    background: var(--surface-2, #221a1a);
    color: var(--text, #ece5e0);
    font-family: inherit;
}

/* เรียงแบบ masonry ด้วย CSS columns — GIF สูงไม่เท่ากัน
   grid จะบังคับความสูงเท่ากันแล้วภาพจะโดนตัด */
.gif-grid {
    columns: 3 110px;
    column-gap: 6px;
    max-height: 340px;
    overflow-y: auto;
}
.gif-grid button {
    display: block;
    width: 100%;
    margin: 0 0 6px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: none;
    cursor: pointer;
    line-height: 0;
    break-inside: avoid;
}
.gif-grid button:hover,
.gif-grid button:focus-visible {
    border-color: var(--gold, #d4af37);
    outline: none;
}
.gif-grid img { width: 100%; height: auto; display: block; }

.gif-empty {
    text-align: center;
    padding: 28px 12px;
    color: var(--text-mute, #6f6360);
    font-size: .9rem;
}
.gif-credit {
    text-align: right;
    font-size: .7rem;
    color: var(--text-mute, #6f6360);
    margin-top: 8px;
}

/* ===========================================================================
   Engine 5 — ตัวเลือกฟิลเตอร์
   =========================================================================== */
.fx-picker { margin-top: 12px; }

.fx-presets {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}
.fx-preset {
    flex: 0 0 auto;
    width: 72px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.fx-preset.active { border-color: var(--gold, #d4af37); }
.fx-preset img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}
.fx-preset span {
    display: block;
    font-size: .7rem;
    color: var(--text-dim, #a1938c);
    padding: 4px 0 2px;
    text-align: center;
}
.fx-preset.active span { color: var(--gold, #d4af37); font-weight: 600; }

/* แถบปรับละเอียด */
.fx-sliders {
    display: grid;
    grid-template-columns: 88px 1fr 44px;
    gap: 6px 10px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line, #2e2323);
}
.fx-sliders label { font-size: .82rem; color: var(--text-dim, #a1938c); }
.fx-sliders input[type=range] { width: 100%; accent-color: var(--gold, #d4af37); }
.fx-sliders output {
    font-size: .78rem;
    color: var(--text-mute, #6f6360);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.fx-preview {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: var(--radius-sm, 9px);
    display: block;
    margin-bottom: 12px;
    /* เปลี่ยนฟิลเตอร์แล้วค่อย ๆ ไล่ ไม่กระตุก */
    transition: filter .2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .fx-preview { transition: none; }
}
