/* css/brand.css — หน้า Bangkok Brand / Make in Bangkok (ฝังใน iframe ได้)
   สีตั้งเป็นตัวแปรด้านบน ; theme-gold = Bangkok Brand, theme-teal = MIB */

:root {
    --bg: #f4f6f3;
    --surface: #ffffff;
    --line: #e2e8e0;
    --ink: #1c2420;
    --ink-2: #4a5550;
    --ink-3: #66716b;
    --focus: #1d4ed8;
    --radius: 14px;
}
.theme-gold {
    --hero-1: #123f24; --hero-2: #17552f; --accent: #f2c14e;
    --primary: #2e7d32; --primary-ink: #1b5e20; --primary-soft: #e8f3e9;
}
.theme-teal {
    --hero-1: #0b3b47; --hero-2: #0f5663; --accent: #8fe0d2;
    --primary: #0f766e; --primary-ink: #0b5650; --primary-soft: #e3f4f2;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Leelawadee", Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}
a { color: var(--primary-ink); }
a:focus, button:focus, input:focus, select:focus, [tabindex]:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.bp { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* ---------- การเข้าถึง ---------- */
.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 16px;
    background: #0f172a; color: #fff; font-weight: 700; border-radius: 0 0 8px 8px; text-decoration: none;
}
.skip-link:focus { top: 0; }
.muted { color: var(--ink-3); }

/* ---------- หัวหน้า ---------- */
.bp-hero {
    position: relative;
    overflow: hidden;
    padding: 26px 28px 24px;
    border-radius: var(--radius);
    color: #fff;
    background: linear-gradient(120deg, var(--hero-1) 0%, var(--hero-2) 100%);
}
.bp-hero::after {               /* ลายวงกลมตกแต่ง */
    content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%;
    border: 36px solid rgba(255, 255, 255, .06);
}
.bp-eyebrow {
    margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: .02em; color: var(--accent);
}
.bp-hero h1 { margin: 0; font-size: 30px; line-height: 1.2; }
.bp-lead { margin: 8px 0 0; max-width: 680px; color: rgba(255, 255, 255, .88); }

/* ---------- ค้นหา ---------- */
.bp-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-top: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.fld { flex: 1 1 160px; min-width: 0; }
.fld-search { flex: 2 1 260px; }
.fld label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.fld input, .fld select {
    width: 100%; height: 42px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--ink);
    background: #fff; border: 1px solid #7d8a82; border-radius: 10px;
}
.fld.fld-actions { flex: 0 0 auto; display: flex; gap: 8px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 18px;
    font: inherit; font-weight: 700; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.btn-primary:hover { background: var(--primary-ink); }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1px solid #7d8a82; }
.btn-ghost:hover { background: #f1f4f1; }

/* ---------- ภาพรวม ---------- */
.bp-overview { margin-top: 14px; }
.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
    padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    display: flex; flex-direction: column;
}
.stat-v { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-l { margin-top: 4px; font-size: 14px; color: var(--ink-2); }
.stat-main { background: var(--primary-soft); border-color: transparent; }
.stat-main .stat-v { color: var(--primary-ink); }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.panels-one { grid-template-columns: 1fr; }
.panel { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h3 { margin: 0; font-size: 16px; }
.panel-hint { margin: 2px 0 10px; font-size: 13px; color: var(--ink-3); }

/* แท่งแนวนอน: สีเดียว ค่าเขียนกำกับทุกแท่ง (ไม่ต้องมีคำอธิบายสี) */
.bars { list-style: none; margin: 0; padding: 0; }
.bar-row {
    display: grid; grid-template-columns: minmax(110px, 32%) 1fr 64px; align-items: center; gap: 10px;
    padding: 6px 8px; margin: 0 -8px; border-radius: 8px; color: var(--ink); text-decoration: none;
}
a.bar-row:hover { background: #f3f6f3; }
.bar-row.is-on { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.bar-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 12px; background: #edf1ec; border-radius: 0 6px 6px 0; overflow: hidden; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; min-width: 2px; max-width: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }
.bar-row.is-rest { border-top: 1px dashed var(--line); border-radius: 0; margin-top: 4px; padding-top: 8px; }
.bar-note { font-size: 13px; color: var(--ink-3); }
.bar-val { text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- ระดับ ---------- */
.rank-badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
    font-size: 13px; font-weight: 700; line-height: 1.6; border: 1px solid; white-space: nowrap;
}
.rank-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .85; }
.rank-premium  { background: #f1eafc; color: #4b2a86; border-color: #b9a0e6; }
.rank-platinum { background: #e5f2f4; color: #1d5360; border-color: #8fbfc8; }
.rank-gold     { background: #fdf3d2; color: #6e5000; border-color: #e0b84a; }
.rank-silver   { background: #eef1f4; color: #3c4753; border-color: #a9b3bd; }
.rank-bronze   { background: #f8e7da; color: #7a3a10; border-color: #d39a6c; }
.rank-other    { background: #f1f3f1; color: #3c4540; border-color: #c4ccc6; }

/* ---------- รายการ ---------- */
.bp-results { margin-top: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.bp-results:focus { outline: none; }
.res-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.res-head h2 { margin: 0; font-size: 20px; }
.res-count { margin: 2px 0 0; color: var(--ink-2); }

.seg { display: inline-flex; padding: 3px; background: #eef2ee; border-radius: 10px; }
.seg a { padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.seg a.on { background: #fff; color: var(--primary-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.chips { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; gap: 4px; align-items: center; padding: 4px 12px; border-radius: 999px; font-size: 14px;
    background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; border: 1px solid transparent;
}
.chip:hover { border-color: var(--primary); }

.cards { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card article {
    height: 100%; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
    border-top: 4px solid var(--primary);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.type-chip { font-size: 13px; color: var(--ink-2); background: #f1f4f1; padding: 2px 10px; border-radius: 999px; }
.card h3 { margin: 10px 0 8px; font-size: 17px; line-height: 1.35; word-break: break-word; }
.card-meta { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.card-meta div { display: grid; grid-template-columns: 96px 1fr; gap: 6px; }
.card-meta dt { color: var(--ink-3); }
.card-meta dd { margin: 0; color: var(--ink); word-break: break-word; }
.tel-link { color: var(--primary-ink); font-weight: 600; white-space: nowrap; }

.table-wrap { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl thead th { background: var(--primary); color: #fff; font-weight: 700; white-space: nowrap; }
.tbl tbody th { font-weight: 600; }
.tbl tbody tr:nth-child(even) { background: #f8faf8; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; width: 64px; }
.tbl .nowrap { white-space: nowrap; }

.empty { margin-top: 16px; padding: 28px; text-align: center; border: 2px dashed var(--line); border-radius: 12px; color: var(--ink-2); }
.empty p { margin: 4px 0; }

.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; }
.pager a, .pager span {
    min-width: 40px; height: 40px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; font-weight: 600; text-decoration: none;
}
.pager a { border: 1px solid #7d8a82; color: var(--ink-2); background: #fff; }
.pager a:hover { border-color: var(--primary); color: var(--primary-ink); }
.pager .cur { background: var(--primary); color: #fff; }
.pager .gap { color: var(--ink-3); }

.bp-foot { margin: 14px 0 4px; text-align: center; font-size: 13px; color: var(--ink-3); }

/* ---------- จอแคบ ---------- */
@media (max-width: 900px) {
    .panels { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .bp { padding: 10px; }
    .bp-hero { padding: 20px; }
    .bp-hero h1 { font-size: 24px; }
    .fld, .fld-search { flex-basis: 100%; }
    .fld.fld-actions { flex-basis: 100%; }
    .fld-actions .btn { flex: 1; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat-v { font-size: 24px; }
    .bar-row { grid-template-columns: 38% 1fr 52px; }
    .bp-results { padding: 14px; }
}

/* โหมดสีของระบบ (Windows High Contrast) */
@media (forced-colors: active) {
    .bar-fill { background: CanvasText; }
    .bar-track { border: 1px solid CanvasText; }
    .bar-row.is-on { outline: 2px solid Highlight; }
}
@media print {
    .bp-filters, .seg, .pager, .skip-link, .panel-hint { display: none; }
    .bp-hero { color: #000; background: none; border: 1px solid #000; }
    .bp-lead, .bp-eyebrow { color: #000; }
}
