/* =========================================================
   UPATICS – Top Navigation  (navbar.css)
   Font: Inter only.  Light theme only.
   Cách dùng: <link> file này + dán navbar.html + navbar.js
   Trang hiện tại: đặt aria-current="page" lên <a> tương ứng.
   ========================================================= */

:root {
  /* Brand */
  --upx-ink: #0F1720;          /* "UP" + U mark */
  --upx-blue: #0B63C5;         /* "ATICS" + arrow + CTA */
  --upx-blue-hover: #0A55A8;
  --upx-blue-soft: #EAF2FC;

  /* Neutrals */
  --upx-bg: #FFFFFF;
  --upx-border: #E4E7EC;
  --upx-text-muted: #475467;   /* menu chưa active */
  --upx-text: #101828;         /* menu hover / active */
  --upx-pill: #F2F4F7;         /* nền pill active / hover */

  /* Data Profile gradient border */
  --upx-grad-1: #0B63C5;
  --upx-grad-2: #7C3AED;
  --upx-grad-3: #06B6D4;

  /* Layout (đo từ AnalystBuilder @1512px) */
  --upx-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --upx-nav-h: 56px;
  --upx-pad-x: clamp(16px, 3.4vw, 52px);  /* ≈52px @1512 */
  --upx-fs: 14px;
  --upx-link-h: 32px;
  --upx-link-px: 8px;          /* padding trái/phải của mục ĐANG ACTIVE (có icon) */
  --upx-link-gap: 8px;         /* khoảng trắng giữa 2 hộp menu (pill hover/active không chạm nhau) */
  --upx-icon: 14px;
  --upx-icon-gap: 6px;
  --upx-slot: calc(var(--upx-icon) + var(--upx-icon-gap));  /* chỗ icon chiếm khi active */
  --upx-radius: 8px;
  --upx-z: 100;
}

/* ---------- Base ---------- */
.upx-nav, .upx-nav * { box-sizing: border-box; }
.upx-nav {
  position: sticky; top: 0; z-index: var(--upx-z);
  height: var(--upx-nav-h);
  background: var(--upx-bg);
  border-bottom: 1px solid var(--upx-border);
  font-family: var(--upx-font);
  font-size: var(--upx-fs);
  line-height: 1;
  -webkit-font-smoothing: antialiased;
}
.upx-nav a { text-decoration: none; color: inherit; }
.upx-nav ul { list-style: none; margin: 0; padding: 0; }
.upx-nav :focus-visible { outline: 2px solid var(--upx-blue); outline-offset: 2px; }

/* 3 cột: [logo | menu (luôn giữa màn hình) | actions] */
.upx-nav__inner {
  height: 100%;
  padding-inline: var(--upx-pad-x);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 16px;
}
.upx-collapse { display: contents; }   /* desktop: con của nó tham gia grid */

/* ---------- Logo ---------- */
.upx-logo {
  justify-self: start;
  display: inline-flex; align-items: flex-end; gap: 8px;
  white-space: nowrap;
}
/* Mark cao 31px: thân chữ U (41/73 viewBox) = 17.5px = cap-height Inter 24px.
   → đáy chữ U = baseline chữ, đỉnh nhánh U = đỉnh chữ in hoa; mũi tên vươn lên trên. */
.upx-logo { position: relative; top: -6.8px; }  /* đưa trục giữa của CHỮ (cap-height) về đúng trục giữa thanh menu — như AnalystBuilder; mũi tên vươn lên trên */
.upx-logo__mark { height: 31px; width: auto; display: block; flex: none; }
.upx-logo__word {
  font-weight: 800; font-size: 24px; letter-spacing: -0.02em; line-height: 1;
  margin-bottom: -0.17em;            /* hiệu chỉnh đo bằng pixel: đáy chữ = đáy chữ U */
}
.upx-logo__up { color: var(--upx-ink); }
.upx-logo__atics { color: var(--upx-blue); }

/* ---------- Menu ---------- */
.upx-menu { justify-self: center; }
.upx-menu ul { display: flex; align-items: center; gap: var(--upx-link-gap); }

.upx-link {
  display: inline-flex; align-items: center; gap: var(--upx-icon-gap);
  height: var(--upx-link-h);
  justify-content: center;
  /* HỘP CỐ ĐỊNH: inactive = text + 2×(px + slot/2); active = icon-slot + text + 2×px → bằng nhau.
     Nên bật/tắt icon KHÔNG làm đổi độ rộng hay vị trí các mục khác. */
  padding: 0 calc(var(--upx-link-px) + var(--upx-slot) / 2);
  border-radius: var(--upx-radius);
  font-weight: 500; white-space: nowrap;
  color: var(--upx-text-muted);
  transition: color .15s, background-color .15s;
}
.upx-link:hover { color: var(--upx-text); background: var(--upx-pill); }

.upx-ico {
  display: none;                      /* chỉ hiện khi active */
  width: var(--upx-icon); height: var(--upx-icon); flex: none;
  fill: none; stroke: var(--upx-blue); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.upx-link[aria-current="page"] {
  color: var(--upx-text); background: var(--upx-pill);
}
.upx-link[aria-current="page"] { padding-inline: var(--upx-link-px); }
.upx-link[aria-current="page"] .upx-ico { display: block; }

/* ---------- Data Profile: gradient border ---------- */
@property --upx-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

/* Data Profile luôn hiển thị (không phụ thuộc trạng thái login) */

.upx-link--profile {
  --upx-fill: var(--upx-bg);
  border: 1.5px solid transparent;
  --upx-bw: 1.5px;
  padding: 0 calc(var(--upx-link-px) + var(--upx-slot) / 2 - var(--upx-bw));  /* border-box: tổng rộng vẫn bằng quy tắc chung */
  background:
    linear-gradient(var(--upx-fill), var(--upx-fill)) padding-box,
    conic-gradient(from var(--upx-angle), var(--upx-grad-1), var(--upx-grad-2), var(--upx-grad-3), var(--upx-grad-1)) border-box;
  color: var(--upx-text);
  animation: upx-spin 6s linear infinite;
}
.upx-link--profile[aria-current="page"] { padding-inline: calc(var(--upx-link-px) - var(--upx-bw)); }
.upx-link--profile:hover,
.upx-link--profile[aria-current="page"] { --upx-fill: var(--upx-pill); background:
    linear-gradient(var(--upx-fill), var(--upx-fill)) padding-box,
    conic-gradient(from var(--upx-angle), var(--upx-grad-1), var(--upx-grad-2), var(--upx-grad-3), var(--upx-grad-1)) border-box; }
@keyframes upx-spin { to { --upx-angle: 360deg; } }

/* ---------- Actions ---------- */
.upx-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.upx-login {
  display: inline-flex; align-items: center; height: var(--upx-link-h);
  padding: 0 var(--upx-link-px);
  font-weight: 600; color: var(--upx-blue); white-space: nowrap;
  border-radius: var(--upx-radius);
}
.upx-login:hover { background: var(--upx-blue-soft); }
.upx-cta {
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--upx-link-h); padding: 0 12px;
  border-radius: var(--upx-radius);
  background: var(--upx-blue); color: #fff !important;
  font-weight: 600; white-space: nowrap;
  transition: background-color .15s;
}
.upx-cta:hover { background: var(--upx-blue-hover); }

/* ---------- Language switch EN | VI ---------- */
.upx-lang {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  height: var(--upx-link-h); padding: 2px;
  border: 1px solid var(--upx-border); border-radius: var(--upx-radius);
}
.upx-lang__btn {
  height: 100%; min-width: 30px; padding: 0 7px; border: 0; border-radius: 6px;
  background: transparent; color: var(--upx-text-muted);
  font: 600 12px/1 var(--upx-font); letter-spacing: .02em; cursor: pointer;
  transition: color .15s, background-color .15s;
}
.upx-lang__btn:hover { color: var(--upx-text); }
.upx-lang__btn[aria-pressed="true"] { background: var(--upx-blue-soft); color: var(--upx-blue); cursor: default; }

/* ---------- Hamburger (ẩn ở desktop) ---------- */
.upx-burger {
  display: none; width: 40px; height: 40px; padding: 0; margin-right: -8px;
  align-items: center; justify-content: center;
  background: none; border: 0; border-radius: var(--upx-radius);
  color: var(--upx-ink); cursor: pointer;
}
.upx-burger:hover { background: var(--upx-pill); }
.upx-burger svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.upx-burger .upx-x { display: none; }
.upx-nav.is-open .upx-burger .upx-x { display: block; }
.upx-nav.is-open .upx-burger .upx-bars { display: none; }

/* ---------- Compact: 1480–1599 (founder 2026-11-17: Pricing added, 9 items) ---------- */
@media (max-width: 1599px) {
  :root { --upx-link-px: 4px; --upx-link-gap: 6px; }
  .upx-actions { gap: 4px; }
}

/* ---------- Mobile / tablet: ≤ 1479 → hamburger ---------- */
@media (max-width: 1479px) {
  .upx-nav__inner { display: flex; justify-content: space-between; }
  .upx-burger { display: inline-flex; }

  .upx-collapse {
    display: none;
    position: absolute; left: 0; right: 0; top: 100%;
    max-height: calc(100dvh - var(--upx-nav-h));
    overflow-y: auto;
    padding: 12px var(--upx-pad-x) 20px;
    background: var(--upx-bg);
    border-bottom: 1px solid var(--upx-border);
    box-shadow: 0 12px 24px -12px rgba(16, 24, 40, .18);
  }
  .upx-nav.is-open .upx-collapse { display: block; }

  .upx-menu, .upx-actions { justify-self: stretch; }
  .upx-menu ul { flex-direction: column; align-items: stretch; gap: 4px; }
  .upx-link, .upx-link[aria-current="page"] { height: 44px; font-size: 16px; padding-inline: 12px; width: 100%; justify-content: flex-start; }
  .upx-link--profile, .upx-link--profile[aria-current="page"] { padding-inline: 10.5px; }
  .upx-ico { width: 18px; height: 18px; }

  .upx-actions {
    flex-direction: column; align-items: stretch; gap: 8px;
    margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--upx-border);
  }
  .upx-lang { height: 44px; padding: 3px; }
  .upx-lang__btn { flex: 1; font-size: 14px; }
  .upx-login, .upx-cta { height: 44px; font-size: 16px; justify-content: center; }
  .upx-login { border: 1px solid var(--upx-border); }
}

@media (prefers-reduced-motion: reduce) {
  .upx-link--profile { animation: none; }
  .upx-nav * { transition: none !important; }
}

/* ---------- WordPress hardening (không thuộc handoff gốc) ---------- */
/* Handoff gốc: `.upx-nav a{color:inherit}` (0,1,1) thắng `.upx-link{color:muted}` (0,1,0) nên bản preview thực tế
   hiển thị chữ menu + Login theo màu body (#101828). Giữ ĐÚNG hiển thị đã duyệt, nhưng khoá thành token để không
   phụ thuộc màu chữ của theme. Muốn đúng chữ trong spec (xám #475467 / Login xanh): đổi 2 token dưới đây. */
:root{--upx-link-ink:#101828;--upx-login-ink:#101828}
.upx-nav a.upx-link{color:var(--upx-link-ink)}
.upx-nav a.upx-login{color:var(--upx-login-ink)}
.upx-nav{margin:0;width:100%}
.upx-nav a,.upx-nav a:hover,.upx-nav a:focus{text-decoration:none!important;box-shadow:none}
/* border-bottom:0 chống gạch chân của theme — dùng :where() (specificity 0) để KHÔNG đè viền gradient của Data Profile và viền Login ở mobile */
:where(.upx-nav) a{border-bottom:0}
.upx-nav ul,.upx-nav li{list-style:none;margin:0;padding:0}
.upx-nav button{font-family:var(--upx-font);text-transform:none;text-shadow:none;box-shadow:none;-webkit-appearance:none;appearance:none}
.upx-nav .upx-lang__btn{border:0;background:transparent;margin:0}
.upx-nav .upx-lang__btn[aria-pressed="true"]{background:var(--upx-blue-soft);color:var(--upx-blue)}
.upx-nav .upx-burger{background:none;border:0}
.upx-nav .upx-burger:hover{background:var(--upx-pill)}
.upx-nav svg{max-width:none}
.upx-nav .upx-link,.upx-nav .upx-login,.upx-nav .upx-cta{margin:0;letter-spacing:normal;text-transform:none}
/* thanh quản trị WP (đăng nhập) đẩy navbar xuống để không bị che */
body.admin-bar .upx-nav{top:32px}
@media (max-width:782px){body.admin-bar .upx-nav{top:46px}}
@media (max-width:600px){body.admin-bar .upx-nav{top:0}}
@media (max-width:1479px){body.admin-bar .upx-collapse{max-height:calc(100dvh - var(--upx-nav-h) - 32px)}}
/* ẩn header của theme (tuỳ chọn trong Settings → UPATICS) */
body.upx-hide-theme-header #masthead,body.upx-hide-theme-header .site-header,body.upx-hide-theme-header header.wp-block-template-part,
body.upx-hide-theme-header #site-header,body.upx-hide-theme-header #header,body.upx-hide-theme-header .ast-main-header-wrap,
body.upx-hide-theme-header .entry-header,body.upx-hide-theme-header .page-header,body.upx-hide-theme-header .entry-title{display:none!important}
/* Astra: ngăn kéo menu mobile của theme nằm ngoài màn hình gây cuộn ngang ~13px ở 1000–1200px */
body.upx-hide-theme-header .ast-mobile-popup-drawer,body.upx-hide-theme-header #ast-mobile-header,body.upx-hide-theme-header #ast-desktop-header{display:none!important}
body.upx-standalone{margin:0;padding:0;background:#FAF9F6}
/* 2026-11-15 Fable SITE-05: on pages that print the navbar inside the theme content (sign-in, sign-up) the theme capped it at 1240px, so the signed-out VI bar overflowed at 1400-1700px */
.upx-nav .upx-nav__inner{max-width:none!important;margin-left:0!important;margin-right:0!important}
/* SITE-16: 44px hit areas without changing the bar's look */
.upx-lang__btn{position:relative}
.upx-lang__btn::after{content:"";position:absolute;left:0;right:0;top:50%;height:44px;transform:translateY(-50%)}
@media (min-width:1480px){.upx-link,.upx-login{position:relative}.upx-link::after,.upx-login::after{content:"";position:absolute;left:0;right:0;top:50%;height:44px;transform:translateY(-50%)}}
.upx-burger{width:44px;height:44px;margin-right:-10px}
