/* ==========================================================================
   ubu-footer-dir.css — Footer แบบ B: ส่วนบางที่เห็นตลอด + ไดเรกทอรีเมนูทั้งหมด (พับได้)
   โหลดหลัง ubu-modern-v3.css (ใช้ตัวแปร --u-* เดิม) ถ้าจะย้อนกลับ: เอา <link> ออก
   ========================================================================== */

/* สีที่ใช้ร่วมกัน: ทำให้ใช้ได้ทั้งพื้น footer เข้มและอ่อน (PHP ใส่คลาส --dark / --light ให้) */
.u-footer {
  --u-f-line: rgb(255 255 255 / 0.25);
  --u-f-soft: rgb(255 255 255 / 0.1);
  --u-f-muted: rgb(255 255 255 / 0.8);
  --u-f-title: var(--u-accent);
}
.u-footer--light {
  --u-f-line: rgb(15 27 61 / 0.25);
  --u-f-soft: rgb(15 27 61 / 0.07);
  --u-f-muted: rgb(15 27 61 / 0.78);
  --u-f-title: var(--u-c1);
}

/* ---------- ส่วนบน ---------- */
.u-footer__top--b { display: flex; flex-wrap: wrap; gap: 32px 56px; align-items: flex-start; }
.u-footer__top--b .u-footer__brand { flex: 1.3 1 340px; }
.u-footer__name { font-size: 20px; }
.u-footer__addr { font-size: 15px; line-height: 1.7; opacity: 1; color: var(--u-f-muted); }

.u-fquick, .u-fdir__cta { flex: 1 1 260px; min-width: 0; }
.u-fquick__title { margin: 0 0 8px !important; font-size: 16px !important; font-weight: 600; line-height: 1.4; color: var(--u-f-title); }
.u-fquick ul { display: grid; gap: 0; }
.u-fquick a { display: block; padding: 5px 0; font-size: 15px; line-height: 1.5; }
.u-fquick a:hover { text-decoration: underline !important; text-underline-offset: 4px; }
.u-fdir__ctatext { margin: 0 0 12px; font-size: 15px; color: var(--u-f-muted); }

.u-fdir__toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 24px;
  border-radius: 999px; background: var(--u-accent); color: var(--u-on-accent);
  font-size: 16px; font-weight: 600; line-height: 1.3; cursor: pointer;
}
.u-fdir__toggle[hidden] { display: none; }
.u-fdir__toggle:hover { filter: brightness(1.06); }
.u-fdir__toggle .fa { transition: rotate 0.2s; }
.u-fdir__toggle[aria-expanded="true"] .fa { rotate: 180deg; }

/* ---------- ไดเรกทอรี ---------- */
.u-fdir { margin-top: 36px; display: grid; gap: 20px; background: var(--u-f-panel, var(--u-f-soft)); border-radius: 32px; padding: clamp(18px, 3vw, 28px) clamp(18px, 3vw, 32px) clamp(18px, 3vw, 32px); }
.u-fdir[hidden] { display: none; }

/* ก่อน JS ทำงาน (หรือไม่มี JS): ซ่อนส่วนควบคุม แสดงทุกหมวดเป็นรายการยาว */
.u-fdir__search, .u-fdir__tabs, .u-fdir__acc, .u-fdir__accwrap { display: none; }
.u-fdir.is-js .u-fdir__search { display: flex; }
.u-fdir.is-js .u-fdir__tabs { display: flex; }

.u-fdir__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.u-fdir__search { flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.u-fdir__field { position: relative; flex: 1 1 320px; }
.u-fdir__field .fa { position: absolute; left: 18px; top: 50%; translate: 0 -50%; color: var(--u-muted); pointer-events: none; }
.u-fdir__input {
  width: 100%; height: 52px; padding: 0 20px 0 48px; border: 2px solid transparent; border-radius: 999px;
  background: #fff; color: var(--u-ink); font: inherit; font-size: 16px; appearance: none;
}
.u-fdir__input::placeholder { color: var(--u-muted); }
.u-fdir__input:focus-visible { outline: 3px solid var(--u-accent); outline-offset: 2px; }
.u-fdir__status { margin: 0; font-size: 15px; color: var(--u-f-muted); min-height: 1.6em; }

.u-fdir__tabs { flex-wrap: wrap; gap: 10px; }
.u-fdir__tab {
  min-height: 44px; padding: 6px 18px; border: 1px solid var(--u-f-line); border-radius: 999px;
  background: transparent; color: inherit; font-size: 15px; font-weight: 500; line-height: 1.3; cursor: pointer;
}
.u-fdir__tab:hover { background: var(--u-f-soft); }
.u-fdir__tab[aria-selected="true"] { background: var(--u-accent); border-color: var(--u-accent); color: var(--u-on-accent); }
.u-fdir.is-searching .u-fdir__tab[aria-selected="true"] { background: transparent; border-color: var(--u-f-line); color: inherit; }
.u-fdir__tab[data-empty="true"] { opacity: 0.4; }

.u-fdir__pane { background: var(--u-c4, #0b1633); border-radius: 24px; padding: 24px 28px; }
.u-footer--light .u-fdir__pane { background: rgb(255 255 255 / 0.6); }
.u-fdir__panetitle {
  margin: 0 !important; padding-bottom: 12px; border-bottom: 1px solid var(--u-f-line);
  font-size: 20px; font-weight: 600; line-height: 1.4; color: var(--u-f-title);
}
.u-fdir__n { margin-inline-start: 6px; font-size: 14px; font-weight: 500; color: var(--u-f-muted); }
.u-fdir__links { margin-top: 14px; column-width: 240px; column-gap: 40px; }
@media (min-width: 1000px) { .u-fdir__links { column-count: 3; column-width: auto; } }
.u-fdir__links li { break-inside: avoid; }
.u-fdir__links a { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; font-size: 15px; line-height: 1.5; }
.u-fdir__links a::before {
  content: ""; flex: none; width: 6px; height: 6px; border-top: 2px solid currentColor; border-right: 2px solid currentColor;
  rotate: 45deg; opacity: 0.6; translate: 0 -2px;
}
.u-fdir__links a:hover { text-decoration: underline !important; text-underline-offset: 4px; }

/* ---------- มือถือ: ไม่ใช้ chips ใช้ accordion เปิดทีละหมวด ---------- */
@media (max-width: 699px) {
  .u-fdir { border-radius: 20px; padding: 16px; }
  .u-fdir.is-js .u-fdir__tabs { display: none; }
  .u-fdir.is-js .u-fdir__panetitle { display: none; }
  .u-fdir.is-js .u-fdir__accwrap { display: block; margin: 0; }
  .u-fdir.is-js .u-fdir__acc {
    display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: space-between; gap: 12px;
    padding: 6px 2px; color: var(--u-f-title); font-size: 16px; font-weight: 600; line-height: 1.35; text-align: start;
  }
  .u-fdir__acc .fa { flex: none; transition: rotate 0.2s; }
  .u-fdir__acc[aria-expanded="true"] .fa { rotate: 180deg; }
  .u-fdir__pane { background: transparent; border-radius: 0; padding: 0; border-bottom: 1px solid var(--u-f-line); }
  .u-fdir__links { column-width: auto; column-count: 1; margin-top: 0; padding-bottom: 10px; }
  .u-fdir__links a { min-height: 44px; align-items: center; padding: 8px 2px 8px 10px; }
  .u-fdir__toggle { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .u-fdir__toggle .fa, .u-fdir__acc .fa { transition: none; }
}

/* โฟกัสที่มองเห็นชัดบนพื้น footer */
.u-footer .u-fdir__tab:focus-visible, .u-footer .u-fdir__acc:focus-visible,
.u-footer .u-fdir__toggle:focus-visible, .u-footer .u-fquick a:focus-visible, .u-footer .u-fdir__links a:focus-visible {
  outline: 3px solid var(--u-accent); outline-offset: 3px; border-radius: 8px;
}
.u-footer--light .u-fdir__tab:focus-visible, .u-footer--light .u-fdir__acc:focus-visible,
.u-footer--light .u-fquick a:focus-visible, .u-footer--light .u-fdir__links a:focus-visible { outline-color: var(--u-c1); }

/* ข้อความส่วนล่างให้อ่านง่ายขึ้นเล็กน้อย (เดิม 12.65px) */
.u-footer__bottom, .u-footer__bottom p, .u-footer__count { font-size: 14px; }
.u-footer__barwrap { margin-top: 40px; background: var(--u-f-panel, transparent); }
.u-footer__barwrap .u-footer__bottom { margin: 0; padding: 18px 0 22px; border: 0; }

/* ---------- พื้นหลังไล่เฉด: สีธีม (bg_color4) -> เข้มลงด้านล่าง ----------
   ดึงสีจากฐานข้อมูลผ่าน --u-c4 จึงเปลี่ยนตามหน่วยงานเอง (ใช้ได้แม้ยังไม่ได้เปลี่ยนเป็น footer_v3_dir.php)
   ถ้าเบราว์เซอร์ไม่รองรับ color-mix จะใช้สีพื้นเรียบเดิม | ถ้าจะยกเลิก: ลบบล็อกนี้ออก */
@supports (background: color-mix(in srgb, red 50%, black)) {
  footer.u-footer {
    background-color: var(--u-c4, #0b1633) !important;
    background-image: linear-gradient(180deg, var(--u-c4, #0b1633) 0%, color-mix(in srgb, var(--u-c4, #0b1633) 62%, #000) 100%) !important;
    
  }
  footer.u-footer.u-footer--light {
    background-image: linear-gradient(180deg, var(--u-c4, #fff) 0%, color-mix(in srgb, var(--u-c4, #fff) 90%, #000) 100%) !important;
    
  }
}

/* ==========================================================================
   ปรับตามต้นแบบ Footer B (ขอบบนโค้ง, แผงเมนู, แถบลิขสิทธิ์เต็มความกว้าง) แต่ใช้สีธีมหน่วยงาน
   ========================================================================== */
footer.u-footer {
  border-radius: 36px 36px 0 0;
  padding-top: clamp(32px, 4.5vw, 56px);
  --u-f-panel: color-mix(in srgb, var(--u-c4, #0b1633) 86%, #fff);
}
@media (min-width: 1100px) { footer.u-footer { border-radius: 56px 56px 0 0; } }
footer.u-footer.u-footer--light { --u-f-panel: color-mix(in srgb, var(--u-c4, #fff) 92%, #000); }

/* วงแหวนความคืบหน้าของหน้า (JS ใส่ --u-p เป็น 0–100) */
.u-top::before {
  content: ""; position: absolute; inset: -5px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--u-accent) calc(var(--u-p, 0) * 1%), rgb(0 0 0 / 0.18) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}
.u-top:hover { filter: brightness(1.08); }
