/* =========================================================
   Base — reset, typography, layout helpers, buttons, fields
   ========================================================= */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

body.is-locked { overflow: hidden; }

main { flex: 1 0 auto; }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, address { margin: 0; }
address { font-style: normal; }
ul[class], ol[class] { list-style: none; padding: 0; }
img, svg, picture { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

::selection { background: var(--brand); color: var(--on-brand); }

/* ---------- Two languages ----------
   Text written twice in a page (English and Khmer) is marked
   data-lang="en" / data-lang="km"; only the chosen one shows. */
html:not([lang="km"]) [data-lang="km"],
html[lang="km"] [data-lang="en"] { display: none !important; }

/* Khmer script needs more line height and no letter-spacing. */
body:lang(km) { line-height: 1.85; }
:lang(km) { letter-spacing: 0 !important; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.section { padding-block: var(--section-y); }
.section--tight { padding-block: calc(var(--section-y) * 0.62); }
.section--band { background: var(--bg-2); }

/* A section title sits on a heavy rule, like the headings on a spec sheet. */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px 24px;
  margin-bottom: clamp(20px, 2.6vw, 32px);
  padding-bottom: 12px;
  border-bottom: 2px solid var(--text);
}
.section-head__text { max-width: 64ch; }
.section-head__text .lede { margin-top: 8px; }

.sr-only {
  position: absolute;
  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: 12px; top: -60px;
  z-index: 300;
  padding: 10px 16px;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  transition: top 0.15s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Typography ---------- */
.display,
.h1,
.h2 {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.002em;
  text-wrap: balance;
}
.display { font-size: clamp(3.2rem, 7.6vw + 0.4rem, 6.5rem); line-height: 0.9; }
.h1 { font-size: clamp(2.4rem, 3.6vw + 1.1rem, 4rem); line-height: 0.98; }
.h2 { font-size: clamp(1.85rem, 1.9vw + 1.2rem, 2.75rem); line-height: 1.02; }
.h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.3; }

/* Khmer headings: same weight, room for the stacked marks. */
.display:lang(km) { font-size: clamp(2.1rem, 4.6vw + 0.6rem, 3.9rem); line-height: 1.4; }
.h1:lang(km) { font-size: clamp(1.75rem, 2.4vw + 1rem, 2.75rem); line-height: 1.45; }
.h2:lang(km) { font-size: clamp(1.4rem, 1.2vw + 1.05rem, 1.95rem); line-height: 1.5; }
.h3:lang(km) { line-height: 1.6; }

.text-warm {
  background: var(--grad-warm);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* Small upper-case label */
.label {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--text-3);
}
.label:lang(km) { font-size: 0.875rem; line-height: 1.6; }

.lede { font-size: clamp(1.0625rem, 0.5vw + 0.95rem, 1.25rem); line-height: 1.55; color: var(--text-2); }
.lede:lang(km) { line-height: 1.85; }
.muted { color: var(--text-3); }
.small { font-size: 0.875rem; }

.link {
  color: var(--brand);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.link:hover { color: var(--brand-hover); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}
.link-arrow .icon { width: 18px; height: 18px; transition: transform 0.2s var(--ease); }
.link-arrow:hover { color: var(--brand); }
.link-arrow:hover .icon { transform: translateX(4px); }

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 22px;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn:lang(km) { font-size: 1rem; line-height: 1.5; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { border-color: var(--text); color: var(--text); background: transparent; }
.btn--ghost:hover { background: var(--text); color: var(--bg); }
.btn--sm { min-height: 40px; padding: 6px 16px; font-size: 1rem; }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  color: var(--text);
  transition: background-color 0.18s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Text fields ---------- */
.field { position: relative; display: block; }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 1rem;                 /* 16px stops iOS zooming on focus */
}
.field input::placeholder { color: var(--text-3); }
.field input:hover { border-color: var(--text-3); }
.field input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px var(--brand-soft); }
.field--search .icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-3);
  pointer-events: none;
}
.field--search input { padding-left: 42px; }
.field--sm input { height: 40px; font-size: 0.9375rem; }
@media (max-width: 1023.98px) { .field--sm input { font-size: 1rem; } }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
