:root {
  --section-scroll-offset: 98px;
  --section-motion: cubic-bezier(.22, 1, .36, 1);
  --text-body: clamp(16px, .84vw, 17px);
  --text-ui: clamp(14px, .74vw, 15px);
  --text-meta: 12px;
}

body {
  font-size: var(--text-body);
  line-height: 1.65;
}

.nav-links,
.header-cta,
.button,
.text-link,
.project-meta,
.job-meta,
.insight-grid a,
.contact-form button {
  font-size: var(--text-ui);
}

.nav-links {
  align-items: center;
  gap: clamp(16px, 1.55vw, 28px);
  white-space: nowrap;
}

.nav-item-tools {
  position: relative;
}

.nav-tools-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
}

.nav-tools-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s ease;
}

.nav-item-tools.is-open .nav-tools-toggle::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.nav-tools-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  width: 150px;
  padding: 8px;
  background: #fff;
  border-top: 3px solid var(--blue);
  box-shadow: 0 18px 40px rgba(8, 38, 63, .18);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}

.nav-tools-menu a {
  display: block;
  padding: 10px 12px;
}

.nav-item-tools:hover .nav-tools-menu,
.nav-item-tools:focus-within .nav-tools-menu,
.nav-item-tools.is-open .nav-tools-menu {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.home-nav-ready .header-cta {
  display: none;
}

.nav-connect {
  background: var(--blue);
  color: #fff !important;
  text-transform: uppercase;
  letter-spacing: .1em;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 132px;
  min-height: 44px;
  padding: 0 16px !important;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
}

.nav-connect span {
  font-size: 16px;
  line-height: 1;
}

.nav-connect::after {
  display: none;
}

.nav-connect:hover,
.nav-connect:focus-visible {
  background: var(--blue-dark);
  color: #fff !important;
}

.mobile-menu-toggle,
.mobile-menu,
.mobile-menu-backdrop {
  display: none;
}

/* Giữ logo mới trong cả nhịp render tĩnh và lúc framework hydrate trang. */
.site-header .brand-logo,
footer .footer-logo {
  content: url('../brand/KML_logo.png?v=2');
}

.brand-logo {
  width: 196px;
  max-height: 58px;
  object-fit: contain;
}

/* Footer tối giản theo yêu cầu: chỉ giữ bản quyền. */
footer {
  display: block;
  padding: 20px max(5vw, 50vw - 650px);
}

footer .footer-brand,
footer .footer-links,
footer .footer-contact,
footer .footer-bottom a {
  display: none;
}

footer .footer-bottom {
  border: 0;
  display: block;
  padding: 0;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: none;
  font-size: 13px;
}

/* Surfaces riêng biệt giúp ba hub đọc rõ ngay cả khi không hover. */
.hub-gateway > a {
  background: #fff;
  color: var(--ink);
}

.hub-gateway > a:nth-child(3) {
  background: var(--ice);
}

.hub-gateway > a:nth-child(4) {
  background: var(--blue-deep);
  color: #fff;
}

.hub-gateway > a > span {
  color: var(--blue);
}

.hub-gateway > a small {
  color: #627585;
}

.hub-gateway > a strong {
  color: inherit;
}

.hub-gateway > a p {
  color: #526474;
}

.hub-gateway > a:nth-child(4) > span,
.hub-gateway > a:nth-child(4) small {
  color: var(--blue-soft);
}

.hub-gateway > a:nth-child(4) p {
  color: rgba(255, 255, 255, .76);
}

/* Tăng cỡ và độ tương phản của nội dung gateway để đọc rõ từ xa. */
.gateway-intro p {
  color: rgba(255, 255, 255, .92);
  letter-spacing: .12em;
  font-size: 14px;
  font-weight: 700;
}

.gateway-intro strong {
  font-size: clamp(23px, 1.55vw, 28px);
  line-height: 1.25;
}

.hub-gateway > a > span {
  font-size: 13px;
  font-weight: 800;
}

.hub-gateway > a small,
.hub-gateway > a:nth-child(4) small {
  color: #4c6b82;
  letter-spacing: .09em;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.hub-gateway > a strong {
  font-size: clamp(20px, 1.35vw, 24px);
  font-weight: 700;
  line-height: 1.2;
}

.hub-gateway > a p,
.hub-gateway > a:nth-child(4) p {
  color: #41596b;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
}

.hub-gateway > a:nth-child(4) small {
  color: #b9dcf6;
}

.hub-gateway > a:nth-child(4) p {
  color: rgba(255, 255, 255, .9);
}

.hub-gateway > a:nth-child(2):hover,
.hub-gateway > a:nth-child(2):focus-visible {
  background: #f5faff;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--blue);
  transform: translateY(-7px);
}

.hub-gateway > a:nth-child(3):hover,
.hub-gateway > a:nth-child(3):focus-visible {
  background: #d6e9f9;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--blue);
  transform: translateY(-7px);
}

.hub-gateway > a:nth-child(4):hover,
.hub-gateway > a:nth-child(4):focus-visible {
  background: var(--blue-dark);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
  transform: translateY(-7px);
}

.hub-gateway > a:nth-child(2):hover small,
.hub-gateway > a:nth-child(2):focus-visible small,
.hub-gateway > a:nth-child(3):hover small,
.hub-gateway > a:nth-child(3):focus-visible small {
  color: #315f87;
}

.hub-gateway > a:nth-child(2):hover p,
.hub-gateway > a:nth-child(2):focus-visible p,
.hub-gateway > a:nth-child(3):hover p,
.hub-gateway > a:nth-child(3):focus-visible p {
  color: #344e62;
}

.hub-gateway > a:nth-child(4):hover small,
.hub-gateway > a:nth-child(4):focus-visible small,
.hub-gateway > a:nth-child(4):hover > span,
.hub-gateway > a:nth-child(4):focus-visible > span {
  color: var(--blue-soft);
}

.hub-gateway > a:nth-child(4):hover p,
.hub-gateway > a:nth-child(4):focus-visible p {
  color: rgba(255, 255, 255, .9);
}

.library-links a {
  transition: background .28s var(--section-motion), color .28s var(--section-motion), transform .28s var(--section-motion), box-shadow .28s var(--section-motion);
}

.library-links a:hover,
.library-links a:focus-visible {
  background: var(--blue-deep);
  color: #fff;
  box-shadow: inset 5px 0 0 var(--blue-soft);
  transform: translateX(8px);
}

.library-links a:hover span,
.library-links a:focus-visible span {
  color: var(--blue-soft);
}

/* Nội dung xuất hiện tuần tự khi section vừa đi vào vùng xem. */
.scroll-effects main > section:not(.hero) > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .72s var(--section-motion), transform .9s var(--section-motion);
}

.scroll-effects main > section:not(.hero).is-visible > * {
  opacity: 1;
  transform: none;
}

.scroll-effects main > section:not(.hero).is-visible > :nth-child(2) { transition-delay: .18s; }
.scroll-effects main > section:not(.hero).is-visible > :nth-child(3) { transition-delay: .36s; }
.scroll-effects main > section:not(.hero).is-visible > :nth-child(4) { transition-delay: .54s; }
.scroll-effects main > section:not(.hero).is-visible > :nth-child(5) { transition-delay: .72s; }

.project-grid.is-carousel {
  display: block;
}

.project-slider-viewport {
  width: 100%;
  overflow: hidden;
}

.project-slider-track {
  display: flex;
  gap: 18px;
  transition: transform .6s var(--section-motion);
  will-change: transform;
}

.project-grid.is-carousel .project-card,
.project-grid.is-carousel .project-card:last-child {
  flex: 0 0 calc((100% - 36px) / 3);
  width: auto;
}

.eyebrow,
.section-kicker span,
.section-kicker p,
.gateway-intro p,
.hub-gateway small,
.hub-gateway p,
.project-search small,
.project-search label span,
.project-title p,
.status,
.data-note,
.career-banner > div > p,
.insight-grid article > span,
.connect-paths span,
.contact-form label span,
.contact-form small,
.footer-brand p,
.footer-bottom {
  font-size: var(--text-meta);
}

.hero-lead,
.heading-copy > p,
.library-copy > p:not(.eyebrow),
.proof-lead,
.connect-copy > p:not(.eyebrow) {
  font-size: var(--text-body);
  line-height: 1.75;
}

.hub-gateway strong,
.library-links strong,
.proof-list h3,
.career-benefits strong,
.jobs-heading span,
.job-title h3 {
  font-size: clamp(16px, .95vw, 19px);
}

.project-search > div strong,
.project-search select,
.proof-list p,
.jobs-heading p,
.job-title p,
.connect-paths strong,
.footer-contact p,
.footer-links {
  font-size: var(--text-ui);
}

html {
  scroll-padding-top: var(--section-scroll-offset);
}

body {
  overflow-x: clip;
}

main > section {
  scroll-margin-top: var(--section-scroll-offset);
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.scroll-effects main > section {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity .72s var(--section-motion), transform .9s var(--section-motion);
  will-change: opacity, transform;
}

.scroll-effects main > section.is-visible {
  opacity: 1;
  transform: none;
}

.site-header.is-scrolled {
  position: fixed;
  top: 14px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 18px 50px rgba(8, 38, 63, .18);
  backdrop-filter: blur(14px);
  animation: header-in .35s var(--section-motion) both;
}

.nav-links a.is-active {
  color: var(--blue);
}

.nav-links a.is-active::after {
  right: 0;
}

@keyframes header-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 1060px) {
  html {
    scroll-snap-type: y mandatory;
  }

  html.is-section-scrolling {
    scroll-snap-type: none;
  }

  main > section {
    width: 100%;
    height: 100vh;
    height: 100svh;
    min-height: 100vh;
    min-height: 100svh;
    scroll-margin-top: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: none;
  }

  main > section::-webkit-scrollbar {
    display: none;
  }

  .hub-gateway {
    grid-template-rows: clamp(340px, 46vh, 440px);
    align-content: center;
    align-items: stretch;
    box-shadow: none;
  }

  .gateway-intro {
    justify-content: center;
    gap: 20px;
    min-height: 0;
    height: 100%;
    padding: clamp(28px, 3vw, 42px);
  }

  .hub-gateway > a {
    align-content: center;
    min-height: 0;
    height: 100%;
    padding: clamp(24px, 2.4vw, 36px);
  }

  .brand-library-section,
  .project-hub {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .brand-library-section {
    gap: clamp(24px, 3vh, 38px);
  }

  .brand-library-section .section-kicker,
  .project-hub .section-kicker {
    width: 100%;
    margin-bottom: 0;
  }

  .brand-library {
    width: 100%;
  }

  .project-hub {
    padding-top: calc(var(--section-scroll-offset) + clamp(28px, 4vh, 56px));
    padding-bottom: clamp(36px, 6vh, 64px);
    gap: clamp(20px, 2.6vh, 32px);
  }

  .project-hub .hub-heading {
    width: 100%;
    margin-bottom: 0;
  }

  .project-search,
  .project-hub .data-note {
    display: none;
  }

  .recruitment-hub {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(18px, 2.4vh, 28px);
    padding-top: clamp(42px, 6vh, 72px);
    padding-bottom: clamp(34px, 5vh, 62px);
  }

  .recruitment-hub .section-kicker,
  .recruitment-hub .hub-heading {
    width: 100%;
    margin-bottom: 0;
  }

  .recruitment-hub .career-banner {
    min-height: clamp(350px, 48vh, 470px);
    position: relative;
  }

  .recruitment-hub .jobs-heading,
  .recruitment-hub .job-list {
    display: none;
  }

  .recruitment-more {
    position: absolute;
    top: clamp(28px, 4vh, 42px);
    right: clamp(28px, 3.5vw, 54px);
    z-index: 2;
    min-height: 52px;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    gap: 24px;
    background: var(--blue);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-size: var(--text-ui);
    font-weight: 700;
  }

  .project-grid {
    width: 100%;
  }

  .project-image-wrap {
    height: clamp(290px, 43vh, 430px);
  }

  .project-meta {
    padding: 16px 20px;
  }

  .distribution-proof {
    align-items: stretch;
  }

  .proof-image {
    min-height: 0;
    height: 100%;
  }

  .proof-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: clamp(64px, 9vh, 100px);
    padding-bottom: clamp(52px, 8vh, 90px);
  }

  /* Chừa vùng header rồi mới căn giữa nội dung section Kết nối. */
  .connect {
    align-items: center;
    padding-top: calc(var(--section-scroll-offset) + clamp(28px, 4vh, 56px));
    padding-bottom: clamp(36px, 6vh, 64px);
  }

  .recruitment-hub {
    padding-top: calc(var(--section-scroll-offset) + clamp(28px, 4vh, 56px));
    padding-bottom: clamp(36px, 6vh, 64px);
  }

  .insights {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: calc(var(--section-scroll-offset) + clamp(28px, 4vh, 56px));
    padding-bottom: clamp(36px, 6vh, 64px);
  }
}

@media (max-width: 640px) {
  :root { --section-scroll-offset: 82px; }
  .site-header.is-scrolled { top: 8px; }
  .home-nav-ready .header-cta { display: flex; }
  .project-grid.is-carousel .project-card,
  .project-grid.is-carousel .project-card:last-child { flex-basis: 100%; }
}

/* Tablet và mobile dùng luồng scroll tự nhiên, không ép từng section full màn hình. */
@media (max-width: 1059px) {
  html,
  html.is-section-scrolling {
    scroll-snap-type: none;
  }

  main > section {
    height: auto;
    min-height: 0;
    overflow: visible;
    scroll-snap-align: none;
    scroll-snap-stop: normal;
  }

  .site-header {
    z-index: 60;
  }

  .nav-links,
  .home-nav-ready .header-cta {
    display: none;
  }

  .mobile-menu-toggle {
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--line);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    display: inline-flex;
  }

  .mobile-menu-toggle span {
    width: 19px;
    height: 2px;
    background: var(--blue-deep);
    transition: transform .25s var(--section-motion), opacity .2s ease;
  }

  .mobile-menu-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .mobile-menu-toggle.is-open span:nth-child(2) { opacity: 0; }
  .mobile-menu-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .mobile-menu-backdrop {
    position: fixed;
    z-index: 98;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 26, 44, .46);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    display: block;
  }

  .mobile-menu-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    position: fixed;
    z-index: 99;
    top: 0;
    right: 0;
    width: min(340px, 82vw);
    height: 100dvh;
    padding: 24px 28px 32px;
    background: #fff;
    box-shadow: -18px 0 44px rgba(8, 38, 63, .2);
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    transition: opacity .3s ease, transform .38s var(--section-motion);
    display: flex;
  }

  .mobile-menu.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .mobile-menu a {
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    padding: 14px 0;
    font-size: 16px;
    font-weight: 600;
  }

  .mobile-menu-header {
    border-bottom: 2px solid var(--blue);
    justify-content: space-between;
    align-items: center;
    margin: 0 -28px 18px;
    padding: 0 28px 16px;
    display: flex;
  }

  .mobile-menu-header > span {
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-menu-close {
    width: 38px;
    height: 38px;
    color: var(--blue-deep);
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
  }

  .mobile-tools-toggle {
    width: 100%;
    color: var(--ink);
    border: 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
  }

  .mobile-tools-toggle span {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .25s var(--section-motion);
  }

  .mobile-tools-toggle[aria-expanded="true"] span {
    transform: rotate(225deg) translate(-2px, -2px);
  }

  .mobile-tools-menu {
    display: grid;
    grid-template-columns: 1fr;
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s var(--section-motion);
  }

  .mobile-tools-menu.is-open {
    max-height: 160px;
  }

  .mobile-tools-menu a {
    color: var(--muted);
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.35;
    border-bottom: 1px solid rgba(17, 54, 86, .1);
  }

  .mobile-tools-menu a:last-child {
    border-bottom: 0;
  }

  .mobile-menu-connect {
    width: 100%;
    min-width: 0;
    background: linear-gradient(135deg, var(--blue), #195d9c);
    color: #fff !important;
    border: 0 !important;
    border-radius: 2px;
    align-self: stretch;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 54px;
    margin-top: 16px;
    margin-bottom: 0;
    padding: 14px 18px !important;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-size: 14px !important;
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(17, 80, 138, .2);
    transition: transform .25s var(--section-motion), box-shadow .25s var(--section-motion), background .25s var(--section-motion);
  }

  .mobile-menu-connect:hover,
  .mobile-menu-connect:focus-visible {
    background: linear-gradient(135deg, #195d9c, var(--blue-dark));
    box-shadow: 0 14px 28px rgba(17, 80, 138, .28);
    transform: translateY(-2px);
  }

  .mobile-menu-connect span {
    position: absolute;
    right: 18px;
  }

  .recruitment-more {
    position: static;
    align-self: flex-start;
    min-height: 48px;
    margin-top: 8px;
    padding: 0 20px;
    background: var(--blue);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: .09em;
    align-items: center;
    gap: 18px;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
  }
}

@media (min-width: 641px) and (max-width: 1050px) {
  .project-grid.is-carousel .project-card,
  .project-grid.is-carousel .project-card:last-child { flex-basis: calc((100% - 18px) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-snap-type: none; }
  .scroll-effects main > section {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .scroll-effects main > section:not(.hero) > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .site-header.is-scrolled { animation: none; }
}
