/* ==========================================================================
   V.BuildCC — "Our People" (includes/team-view.php, assets/js/team.js).
   Loaded after home.css and about.css; uses their tokens, so light / dark and
   English / Khmer follow the rest of the site.
     .tm-grid, .tm-card     TeamSection, TeamCard
     .tm-tools, .tm-chip    TeamFilter
     .tm-drawer, .tm-overlay  TeamProfileDrawer (right-side slide-over): .tm-hero, .tm-block, .tm-proj
   ========================================================================== */

.tm {
  --tm-green: #84C434;                         /* accent (fills, rules, focus) */
  --tm-ink: var(--vb-green-ink);               /* green for text: ≥ 4.5:1 on the panel */
  --tm-radius: 16px;
  --tm-ease: cubic-bezier(0.2, 0, 0, 1);
}
.tm-drawer, .tm-overlay { --tm-green: #84C434; --tm-ink: var(--vb-green-ink); --tm-ease: cubic-bezier(0.2, 0, 0, 1); }

.tm-container { max-width: calc(1200px + 2 * clamp(1.25rem, 3vw, 2rem)); }

/* ---------- filter ---------- */
.tm-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}
.tm-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--vb-border-strong);
  border-radius: 999px;
  background: var(--vb-card);
  color: var(--vb-text);
  font: 600 0.9rem/1.3 var(--font-heading);
  cursor: pointer;
  transition: background-color 0.18s var(--tm-ease), border-color 0.18s var(--tm-ease), color 0.18s var(--tm-ease);
}
.tm-chip:hover { border-color: var(--tm-green); }
.tm-chip[aria-pressed="true"] { background: var(--vb-green-dark); border-color: var(--vb-green-dark); color: #fff; }
:root[data-theme="dark"] .tm-chip[aria-pressed="true"] { background: var(--tm-green); border-color: var(--tm-green); color: #14210A; }
.tm-chip__n { font: 600 0.75rem/1 var(--font-body); opacity: 0.7; font-variant-numeric: tabular-nums; }
.tm-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 300px;
  min-width: 220px;
  color: var(--vb-text-muted);
}
.tm-search svg { position: absolute; left: 0.9rem; pointer-events: none; }
.tm-search input {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 1rem 0.5rem 2.6rem;
  border: 1px solid var(--vb-border-strong);
  border-radius: 999px;
  background: var(--vb-card);
  color: var(--vb-text);
  font: 400 0.95rem/1.4 var(--font-body);
}
.tm :focus-visible, .tm-drawer :focus-visible { outline: 3px solid var(--tm-green); outline-offset: 2px; }
.tm-search input:focus-visible { outline-offset: 0; border-color: var(--tm-green); }

/* ---------- grid: 4 large desktop · 3 laptop · 2 tablet · 1 phone ---------- */
.tm-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}
/* fewer people than columns: keep the card size (no stretched cards), aligned with the heading */
.tm-grid--1 { grid-template-columns: minmax(0, 282px); }
.tm-grid--2 { grid-template-columns: repeat(2, minmax(0, 282px)); }
.tm-grid--3 { grid-template-columns: repeat(3, minmax(0, 282px)); }
.tm-card[hidden] { display: none; }

/* ---------- card ---------- */
.tm-card { display: flex; min-width: 0; }
.tm-card__link {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--vb-card);
  border: 1px solid var(--vb-border);
  border-radius: var(--tm-radius);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow 0.28s var(--tm-ease), border-color 0.28s var(--tm-ease), transform 0.28s var(--tm-ease);
}
.tm-card__photo {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;                          /* reserved before the image loads: no layout shift */
  background: #EEF1EC;
  overflow: hidden;
}
:root[data-theme="dark"] .tm-card__photo { background: #232D26; }
.tm-card__photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.5s var(--tm-ease);
}
.tm-card__initials, .tm-drawer__initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 clamp(2.5rem, 6vw, 4rem)/1 var(--font-heading);
  color: var(--vb-text-subtle);
}
.tm-badge {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #26352B;
  font: 600 0.72rem/1.4 var(--font-heading);
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.12);
}
.tm-card__body { display: flex; flex-direction: column; flex: 1; gap: 0.2rem; padding: 1rem 1.15rem 1.1rem; }
.tm-card__name { font: 700 1.05rem/1.35 var(--font-heading); color: var(--vb-text); overflow-wrap: anywhere; }
.tm-card__role { font-size: 0.9rem; line-height: 1.45; font-weight: 600; color: var(--tm-ink); }
.tm-card__dept { font-size: 0.85rem; line-height: 1.45; color: var(--vb-text-muted); }
.tm-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.75rem;
  font: 600 0.875rem/1.3 var(--font-heading);
  color: var(--vb-text);
}
.tm-card__cta .vb-arrow { color: var(--tm-ink); transition: transform 0.28s var(--tm-ease); }
.tm-card__link:hover, .tm-card__link:focus-visible { border-color: var(--vb-green-line); box-shadow: var(--vb-shadow-md); }
.tm-card__link:hover .tm-card__photo img, .tm-card__link:focus-visible .tm-card__photo img { transform: scale(1.03); }
.tm-card__link:hover .tm-card__cta .vb-arrow, .tm-card__link:focus-visible .tm-card__cta .vb-arrow { transform: translateX(4px); }
.tm-card__link:hover .tm-card__cta, .tm-card__link:focus-visible .tm-card__cta { color: var(--tm-ink); }

.tm-empty { text-align: center; padding: 2.5rem 1rem; color: var(--vb-text-muted); }
.tm-empty p { margin-bottom: 1rem; }

/* Khmer: taller lines, no tracking, slightly larger small text */
html.lang-km :is(.tm-card__name, .tm-drawer__name) { line-height: 1.55; }
html.lang-km :is(.tm-drawer__role, .tm-hero__company, .tm-group__title, .tm-years, .tm-proj__role, .tm-proj__cta, .tm-action, .tm-navbtn) { line-height: 1.7; }
html.lang-km :is(.tm-card__role, .tm-card__dept, .tm-card__cta, .tm-chip, .tm-badge) { line-height: 1.7; letter-spacing: normal; }
html.lang-km :is(.tm-badge, .tm-chip__n) { font-size: 0.8rem; }

/* ==========================================================================
   TeamProfileDrawer — floats over the page, slides in from the right.
   Sticky header (title, copy link, close) · scrolling profile · sticky navigation.
   ========================================================================== */
.tm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;                               /* above the header (1000) and the chat button (9990) */
  background: rgba(15, 23, 32, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s var(--tm-ease), visibility 0s linear 0.28s;
}
.tm-overlay.is-open { opacity: 1; visibility: visible; transition: opacity 0.28s var(--tm-ease); }

.tm-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10001;
  width: clamp(520px, 40vw, 600px);             /* 520 → 600px; 560px on a 1400px screen */
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;                                /* header and navigation keep their height; the profile scrolls between them */
  flex-direction: column;
  background: var(--vb-bg);
  color: var(--vb-text);
  box-shadow: -18px 0 48px -18px rgba(15, 23, 32, 0.35), -1px 0 0 var(--vb-border);
  transform: translateX(100%);
  visibility: hidden;                           /* out of the tab order and the accessibility tree when closed */
  transition: transform 0.28s var(--tm-ease), visibility 0s linear 0.28s;
  overscroll-behavior: contain;
}
.tm-drawer.is-open { transform: none; visibility: visible; transition: transform 0.28s var(--tm-ease); }
.tm-drawer:focus { outline: none; }

/* ---------- sticky header ---------- */
.tm-drawer__bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 56px;
  padding: 0.4rem 0.75rem 0.4rem 1.5rem;
  border-bottom: 1px solid var(--vb-border);
  background: var(--vb-bg);
}
.tm-drawer__title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-right: auto;
  min-width: 0;
  font: 700 0.8125rem/1.3 var(--font-heading);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--vb-text);
}
.tm-drawer__count { font: 500 0.8rem/1 var(--font-body); letter-spacing: 0; text-transform: none; color: var(--vb-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tm-drawer__copied { font-size: 0.8rem; line-height: 1.3; color: var(--tm-ink); font-weight: 600; text-align: right; }
html.lang-km .tm-drawer__title { letter-spacing: normal; text-transform: none; font-size: 0.95rem; line-height: 1.6; }
.tm-iconbtn {
  flex: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--vb-text);
  cursor: pointer;
  transition: background-color 0.18s var(--tm-ease), color 0.18s var(--tm-ease);
}
.tm-iconbtn:hover { background: var(--vb-bg-alt); }
.tm-iconbtn__a, .tm-iconbtn__b { display: inline-flex; }
.tm-iconbtn__b { display: none; }
.tm-iconbtn.is-done { color: var(--tm-ink); background: var(--vb-green-tint); }
.tm-iconbtn.is-done .tm-iconbtn__a { display: none; }
.tm-iconbtn.is-done .tm-iconbtn__b { display: inline-flex; }

/* ---------- scrolling profile ---------- */
.tm-drawer__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.tm-drawer__scroll:focus { outline: none; }
.tm-drawer__content { padding: 1.5rem 1.5rem 1.75rem; transition: opacity 0.15s var(--tm-ease); }
.tm-drawer__content.is-switching { opacity: 0; }
.tm-drawer__draft {
  margin-bottom: 1.1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #F3D9A4;
  border-radius: 10px;
  background: #FFF7E6;
  color: #8A5300;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* profile hero: compact portrait beside the name */
.tm-hero { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.tm-hero__photo {
  aspect-ratio: 4 / 5;
  border-radius: 14px;
  overflow: hidden;
  background: #EEF1EC;
  box-shadow: 0 0 0 1px var(--vb-border);
}
:root[data-theme="dark"] .tm-hero__photo { background: #232D26; }
.tm-hero__photo img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center top; }
.tm-hero__photo .tm-drawer__initials { font-size: 2.5rem; }
.tm-hero__info { min-width: 0; }
.tm-drawer__name {
  font: 700 clamp(1.3rem, 1.9vw, 1.5rem)/1.25 var(--font-heading);
  letter-spacing: -0.015em;
  color: var(--vb-text);
  overflow-wrap: anywhere;
}
html.lang-km .tm-drawer__name { letter-spacing: normal; }
.tm-drawer__role { margin-top: 0.25rem; font: 600 0.975rem/1.45 var(--font-heading); color: var(--tm-ink); }
.tm-hero__company { margin-top: 0.2rem; font-size: 0.85rem; line-height: 1.5; color: var(--vb-text-muted); }
.tm-drawer__meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.tm-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--vb-border);
  border-radius: 999px;
  background: var(--vb-bg-alt);
  color: var(--vb-text);
  font-size: 0.8rem;
  line-height: 1.4;
  font-weight: 500;
}
.tm-tag--lead { border-color: var(--vb-green-line); background: var(--vb-green-tint); color: var(--tm-ink); font-weight: 600; }
.tm-tag--lead::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tm-green); }
html.lang-km .tm-tag { line-height: 1.7; font-size: 0.85rem; }

/* titled blocks, separated by a soft rule */
.tm-block { margin-top: 1.5rem; padding-top: 1.35rem; border-top: 1px solid var(--vb-border); }
.tm-block__title {
  margin-bottom: 0.75rem;
  font: 700 0.75rem/1.4 var(--font-heading);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--vb-text-muted);
}
html.lang-km .tm-block__title { letter-spacing: normal; text-transform: none; font-size: 0.9rem; line-height: 1.7; }
.tm-text {
  max-width: 62ch;                              /* comfortable reading width */
  font-size: 0.975rem;
  line-height: 1.7;
  color: var(--vb-text);
  white-space: pre-line;                        /* line breaks typed in the admin are kept */
  overflow-wrap: anywhere;
}
.tm-text + .tm-group, .tm-years + .tm-text, .tm-years + .tm-group, .tm-group + .tm-group { margin-top: 1rem; }
html.lang-km :is(.tm-text, .tm-list li) { line-height: 1.95; }
.tm-pills { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tm-years {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: 10px;
  background: var(--vb-green-tint);
  color: var(--tm-ink);
  font: 700 0.9rem/1.4 var(--font-heading);
}
.tm-years + .tm-text, .tm-years + .tm-group { display: block; }
.tm-group__title { margin-bottom: 0.4rem; font: 600 0.875rem/1.4 var(--font-heading); color: var(--vb-text); }
.tm-list { list-style: none; display: grid; gap: 0.35rem; }
.tm-list li { position: relative; padding-left: 1.05rem; font-size: 0.94rem; line-height: 1.6; color: var(--vb-text-muted); overflow-wrap: anywhere; }
.tm-list li::before { content: ''; position: absolute; left: 0; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--tm-green); }
html.lang-km .tm-list li::before { top: 0.8em; }

/* selected projects */
.tm-projects { list-style: none; display: grid; gap: 0.6rem; }
.tm-proj {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid var(--vb-border);
  border-radius: 14px;
  background: var(--vb-card);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s var(--tm-ease), box-shadow 0.2s var(--tm-ease);
}
.tm-proj:hover, .tm-proj:focus-visible { border-color: var(--vb-green-line); box-shadow: var(--vb-shadow-sm); }
.tm-proj__thumb { display: block; aspect-ratio: 4 / 3; border-radius: 9px; overflow: hidden; background: var(--vb-bg-alt); }
.tm-proj__thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.tm-proj__body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.tm-proj__cat { font: 600 0.72rem/1.4 var(--font-heading); letter-spacing: 0.06em; text-transform: uppercase; color: var(--tm-ink); }
html.lang-km .tm-proj__cat { letter-spacing: normal; text-transform: none; font-size: 0.8rem; line-height: 1.7; }
.tm-proj__title { font: 700 0.95rem/1.35 var(--font-heading); color: var(--vb-text); overflow-wrap: anywhere; }
html.lang-km .tm-proj__title { line-height: 1.6; }
.tm-proj__role { font-size: 0.84rem; line-height: 1.5; color: var(--vb-text-muted); }
.tm-proj__role-label { font-weight: 600; }
.tm-proj__cta { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.25rem; font: 600 0.8rem/1.3 var(--font-heading); color: var(--vb-text); }
.tm-proj__cta svg { color: var(--tm-ink); transition: transform 0.2s var(--tm-ease); }
.tm-proj:hover .tm-proj__cta svg, .tm-proj:focus-visible .tm-proj__cta svg { transform: translateX(3px); }

/* professional contact */
.tm-drawer__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tm-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  max-width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--vb-border-strong);
  border-radius: 12px;
  background: var(--vb-card);
  color: var(--vb-text);
  font: 600 0.875rem/1.3 var(--font-heading);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.tm-action svg { flex: none; }
.tm-action:hover { border-color: var(--tm-green); }
.tm-action--primary { background: var(--tm-green); border-color: var(--tm-green); color: #1B2A12; }
.tm-action--primary:hover { background: #79B62E; border-color: #79B62E; }

/* ---------- sticky navigation ---------- */
.tm-drawer__nav {
  flex: none;
  display: flex;
  gap: 0.6rem;
  padding: 0.65rem 1.5rem calc(0.65rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--vb-border);
  background: var(--vb-bg);
}
.tm-drawer__nav[hidden], .tm-navbtn[hidden] { display: none; }
.tm-navbtn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--vb-border-strong);
  border-radius: 12px;
  background: var(--vb-card);
  color: var(--vb-text);
  font: 600 0.9rem/1.3 var(--font-heading);
  cursor: pointer;
  transition: border-color 0.18s var(--tm-ease), background-color 0.18s var(--tm-ease);
}
.tm-navbtn--next { flex-direction: row-reverse; margin-left: auto; }
.tm-navbtn:only-child, .tm-navbtn[hidden] + .tm-navbtn, .tm-navbtn:has(+ .tm-navbtn[hidden]) { flex: 0 1 50%; }
.tm-navbtn:hover { border-color: var(--tm-green); background: var(--vb-bg-alt); }
.tm-navbtn svg { color: var(--tm-ink); }

/* page behind the open drawer: no scrolling (the scrollbar's width is kept by team.js, so nothing shifts) */
html.tm-lock, html.tm-lock body { overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 1199px) {
  .tm-grid, .tm-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tm-grid--1 { grid-template-columns: minmax(0, 282px); }
  .tm-grid--2 { grid-template-columns: repeat(2, minmax(0, 282px)); }
}
@media (max-width: 899px) {
  .tm-grid, .tm-grid--2, .tm-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-grid--1 { grid-template-columns: minmax(0, 300px); }
  .tm-search { flex: 1 1 100%; }
}
@media (max-width: 640px) {
  /* phone: full-screen slide-over, smaller portrait, larger close button */
  .tm-drawer { width: 100vw; max-width: 100vw; box-shadow: none; }
  .tm-drawer__bar { padding: 0.35rem 0.5rem 0.35rem 1.15rem; }
  .tm-drawer__bar .tm-iconbtn { width: 48px; height: 48px; }
  .tm-drawer__content { padding: 1.15rem 1.15rem 1.5rem; }
  .tm-drawer__nav { padding-inline: 1.15rem; }
  .tm-hero { grid-template-columns: 96px minmax(0, 1fr); gap: 1rem; }
  .tm-proj { grid-template-columns: 84px minmax(0, 1fr); gap: 0.75rem; }
  /* chips scroll sideways in one row */
  .tm-chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * clamp(1.25rem, 3vw, 2rem)); padding: 2px clamp(1.25rem, 3vw, 2rem) 6px; scrollbar-width: none; }
  .tm-chips::-webkit-scrollbar { display: none; }
  .tm-chip { flex: none; }
}
@media (max-width: 559px) {
  .tm-grid, .tm-grid--1, .tm-grid--2, .tm-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .tm-card__link { max-width: 420px; margin-inline: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-drawer, .tm-drawer.is-open, .tm-overlay, .tm-overlay.is-open, .tm-drawer__content { transition: none; }
  .tm-card__link, .tm-card__photo img, .tm-card__cta .vb-arrow, .tm-chip, .tm-proj, .tm-proj__cta svg, .tm-iconbtn, .tm-navbtn { transition: none; }
  .tm-card__link:hover .tm-card__photo img, .tm-card__link:focus-visible .tm-card__photo img { transform: none; }
  .tm-card__link:hover .tm-card__cta .vb-arrow, .tm-card__link:focus-visible .tm-card__cta .vb-arrow { transform: none; }
}
