/* ==========================================================================
   KAMPUJA — Design System
   Single stylesheet for the whole site. No frameworks, no vendor CSS.
   Sections: 1 Tokens · 2 Reset · 3 Typography · 4 Layout · 5 Header
             6 Footer · 7 Buttons · 8 Components · 9 Pages · 10 Utilities
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* --- Colour -----------------------------------------------------------
     Warm neutral ground. Orange is the single accent and is used sparingly:
     primary actions, focus rings, and small brand moments only.
     Contrast checked against --paper for WCAG AA.                       */
  --paper:        #FDFCFA;   /* page ground, warm near-white              */
  --surface:      #F6F3ED;   /* quiet secondary band                      */
  --surface-2:    #EFEBE2;   /* pressed / nested surface                  */
  --ink:          #17150F;   /* primary text            ~17:1 on paper    */
  --ink-2:        #57534C;   /* secondary text          ~7.5:1            */
  --ink-3:        #6F6A61;   /* meta / labels           ~5.3:1            */
  --line:         #E5E0D6;   /* hairline borders                          */
  --line-strong:  #D3CCBE;

  --accent:        #E2641C;  /* brand orange — graphics, large type, rings */
  --accent-strong: #B4470E;  /* action bg + inline links  ~5.5:1 on white  */
  --accent-tint:   #FBF0E6;  /* faint accent wash                          */
  --on-accent:     #FFFFFF;

  /* --- Type -------------------------------------------------------------
     System stack: zero network cost, excellent rendering everywhere.
     Khmer fallbacks are listed so Khmer content renders correctly the day
     it is added, without any layout change. To swap in a self-hosted
     variable font later, change --font-sans in this one place only.     */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial,
    "Noto Sans Khmer", "Khmer OS Battambang", "Khmer OS",  /* Khmer-ready */
    sans-serif;

  /* Fluid scale. clamp() keeps mobile restrained and desktop generous.   */
  --t-display: clamp(2.375rem, 1.55rem + 3.5vw, 4.25rem);
  --t-h1:      clamp(2rem,    1.45rem + 2.4vw, 3.25rem);
  --t-h2:      clamp(1.625rem, 1.3rem + 1.5vw, 2.5rem);
  --t-h3:      clamp(1.1875rem, 1.1rem + 0.4vw, 1.4375rem);
  --t-h4:      1.0625rem;
  --t-lead:    clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  --t-body:    1.0625rem;
  --t-small:   0.9375rem;
  --t-micro:   0.8125rem;

  --lh-tight: 1.12;
  --lh-head:  1.22;
  /* Generous leading — required headroom for Khmer ascenders/descenders. */
  --lh-body:  1.7;

  --track-tight: -0.022em;
  --track-wide:   0.09em;

  /* --- Space (4px base) ------------------------------------------------- */
  --s-1: 0.25rem;  --s-2: 0.5rem;   --s-3: 0.75rem;  --s-4: 1rem;
  --s-5: 1.5rem;   --s-6: 2rem;     --s-7: 2.5rem;   --s-8: 3rem;
  --s-9: 4rem;     --s-10: 5rem;    --s-11: 6.5rem;  --s-12: 8rem;

  /* Section rhythm — one variable drives vertical cadence sitewide.      */
  --section-y: clamp(4rem, 2.5rem + 6vw, 8rem);

  /* --- Measure ---------------------------------------------------------- */
  --wrap:        1120px;  /* general content                               */
  --wrap-prose:  680px;   /* legal + long-form reading measure             */
  --gutter:      clamp(1.25rem, 0.75rem + 2.2vw, 2.5rem);

  /* --- Form ------------------------------------------------------------- */
  --radius:    10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --border: 1px solid var(--line);

  /* Shadow is used almost nowhere. One soft ambient value only.          */
  --shadow: 0 1px 2px rgb(23 21 15 / 0.04), 0 12px 32px -12px rgb(23 21 15 / 0.10);

  --header-h: 64px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* --------------------------------------------------------------------------
   2. RESET
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Guards against any child forcing a sideways scroll on small screens. */
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; height: auto; }

h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select { font: inherit; color: inherit; }

/* Visible, high-contrast focus for keyboard users on every interactive el. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--accent-tint); color: var(--ink); }

/* Screen-reader-only, and the skip link that becomes visible on focus.    */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; top: var(--s-3); left: var(--s-3);
  z-index: 200;
  transform: translateY(-200%);
  background: var(--ink); color: var(--paper);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  font-size: var(--t-small); font-weight: 500;
}
.skip-link:focus { transform: translateY(0); }

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   -------------------------------------------------------------------------- */
.display, h1, h2, h3 {
  letter-spacing: var(--track-tight);
  text-wrap: balance;      /* tidier headline wrapping where supported */
  font-weight: 600;
}

.display { font-size: var(--t-display); line-height: var(--lh-tight); }
h1        { font-size: var(--t-h1);      line-height: var(--lh-tight); }
h2        { font-size: var(--t-h2);      line-height: var(--lh-head); }
h3        { font-size: var(--t-h3);      line-height: 1.3; letter-spacing: -0.012em; }
h4        { font-size: var(--t-h4); font-weight: 600; line-height: 1.4; letter-spacing: 0; }

.lead {
  font-size: var(--t-lead);
  color: var(--ink-2);
  line-height: 1.6;
  text-wrap: pretty;
}

.muted  { color: var(--ink-2); }
.meta   { color: var(--ink-3); font-size: var(--t-small); }

/* Small uppercase section label. Tracked out, never larger than micro.    */
.eyebrow {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s-4);
}
.eyebrow--accent { color: var(--accent-strong); }

.prose p + p { margin-top: var(--s-4); }

/* --------------------------------------------------------------------------
   4. LAYOUT
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--prose { max-width: var(--wrap-prose); }

.section       { padding-block: var(--section-y); }
.section--tight { padding-block: calc(var(--section-y) * 0.62); }
.section--surface { background: var(--surface); }
.section + .section--surface,
.section--surface + .section { border-top: var(--border); }

/* Section heading block — constrained measure, consistent everywhere.     */
.section-head { max-width: 44ch; margin-bottom: var(--s-8); }
.section-head p { margin-top: var(--s-4); }
.section-head--center { margin-inline: auto; text-align: center; }

.grid { display: grid; gap: var(--s-6); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* Asymmetric split used for hero and feature rows. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 1rem + 4vw, 5rem);
  align-items: center;
}
@media (max-width: 860px) { .split { grid-template-columns: minmax(0, 1fr); } }

.rule { border: 0; border-top: var(--border); margin: 0; }

/* --------------------------------------------------------------------------
   5. HEADER + NAVIGATION
   -------------------------------------------------------------------------- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
/* Hairline appears only once the page has scrolled — quiet at rest. */
.header.is-scrolled { border-bottom-color: var(--line); }

.header__inner {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-6);
}

/* --- Wordmark -------------------------------------------------------------
   Typographic wordmark. When the real KAMPUJA logo lands, replace the
   contents of .wordmark with the SVG (see assets/img/README-ASSETS.md).  */
.wordmark {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  margin-right: auto;
}
.wordmark__dot { color: var(--accent); }

.nav { display: flex; align-items: center; gap: var(--s-6); }

.nav__link {
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink-2);
  padding-block: var(--s-2);
  transition: color 0.15s var(--ease);
}
.nav__link:hover { color: var(--ink); }
.nav__link[aria-current="page"] { color: var(--ink); font-weight: 600; }

.nav__toggle { display: none; }

/* Mobile navigation: the links move into a panel below the bar.          */
@media (max-width: 820px) {
  .nav__toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;               /* comfortable touch target */
    margin-right: calc(var(--s-3) * -1);
    background: none; border: 0; border-radius: var(--radius);
    cursor: pointer; color: var(--ink);
  }
  .nav__toggle svg { width: 22px; height: 22px; }
  .nav__toggle .icon-close { display: none; }
  .nav__toggle[aria-expanded="true"] .icon-open  { display: none; }
  .nav__toggle[aria-expanded="true"] .icon-close { display: block; }

  .header__inner { gap: var(--s-4); }

  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper);
    border-bottom: var(--border);
    padding: var(--s-3) var(--gutter) var(--s-6);
    box-shadow: var(--shadow);
  }
  .nav[hidden] { display: none; }

  .nav__link {
    padding-block: var(--s-4);
    font-size: 1.0625rem;
    border-bottom: var(--border);
    color: var(--ink);
  }
  .nav .btn { margin-top: var(--s-5); justify-content: center; }
}

/* --------------------------------------------------------------------------
   6. FOOTER
   -------------------------------------------------------------------------- */
.footer {
  border-top: var(--border);
  background: var(--surface);
  padding-block: var(--s-9) var(--s-7);
}
.footer__top {
  display: flex; flex-wrap: wrap; gap: var(--s-6);
  justify-content: space-between; align-items: flex-start;
}
.footer__nav { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); }
.footer__nav a {
  font-size: var(--t-small); color: var(--ink-2);
  padding-block: var(--s-1);
  transition: color 0.15s var(--ease);
}
.footer__nav a:hover { color: var(--ink); }
.footer__bottom {
  margin-top: var(--s-8); padding-top: var(--s-5);
  border-top: var(--border);
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  justify-content: space-between;
  font-size: var(--t-micro); color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   7. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  min-height: 46px;                     /* touch target */
  padding: var(--s-3) var(--s-6);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: var(--t-small); font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
              color 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--accent-strong); color: var(--on-accent); }
.btn--primary:hover { background: #9C3D0B; }

.btn--secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--surface); border-color: var(--ink-3); }

.btn--ghost { padding-inline: 0; color: var(--accent-strong); min-height: 0; }
.btn--ghost:hover { text-decoration: underline; text-underline-offset: 3px; }

.btn--lg { min-height: 52px; padding-inline: var(--s-7); font-size: var(--t-body); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

/* On narrow screens stacked buttons of different label lengths read as
   ragged. Give paired CTAs equal full width instead.                   */
@media (max-width: 480px) {
  .hero .btn-row, .panel .btn-row { flex-direction: column; align-items: stretch; }
  .hero .btn-row .btn, .panel .btn-row .btn { width: 100%; }
}

/* Inline text link */
.link {
  color: var(--accent-strong); font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent-strong) 35%, transparent);
  transition: text-decoration-color 0.15s var(--ease);
}
.link:hover { text-decoration-color: currentColor; }

/* --------------------------------------------------------------------------
   8. COMPONENTS
   -------------------------------------------------------------------------- */

/* --- Value / feature item -------------------------------------------------
   Deliberately NOT a card. Typography and a short top rule carry it.     */
.item { padding-top: var(--s-5); border-top: 2px solid var(--ink); }
.item--quiet { border-top-color: var(--line-strong); }
.item__title { margin-bottom: var(--s-3); }
.item p { color: var(--ink-2); }

/* --- Numbered step -------------------------------------------------------- */
.step { display: grid; grid-template-columns: auto 1fr; gap: var(--s-4); align-items: start; }
.step__n {
  font-size: var(--t-small); font-weight: 600;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  padding-top: 0.15em;
}
.step h3 { margin-bottom: var(--s-2); }
.step p { color: var(--ink-2); }

/* --- Product media placeholder -------------------------------------------
   NO fabricated UI is drawn inside these frames. They are empty, warm
   surfaces sized to real device proportions so that dropping a genuine
   screenshot in changes nothing about the layout.
   REPLACE: put <img> inside .media-frame — it will fill and crop cleanly. */
.media {
  position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  gap: clamp(0.75rem, 0.2rem + 2vw, 1.75rem);
}
.media-frame {
  position: relative;
  width: 100%; max-width: 268px;
  aspect-ratio: 9 / 19.5;              /* modern handset proportion */
  border-radius: 34px;
  background: linear-gradient(168deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.media-frame > img { width: 100%; height: 100%; object-fit: cover; }
/* Secondary frame sits lower and smaller to build a calm composition.    */
.media-frame--aside {
  max-width: 206px;
  border-radius: 26px;
  margin-bottom: clamp(1.5rem, 0.5rem + 4vw, 3.5rem);
  opacity: 0.94;
}
@media (max-width: 520px) {
  .media-frame--aside { display: none; }   /* one frame reads better small */
  .media-frame { max-width: 232px; }
}

/* Wide 16:10 media slot for the business page. */
.media-wide {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-lg);
  background: linear-gradient(168deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line-strong);
  overflow: hidden;
}
.media-wide > img { width: 100%; height: 100%; object-fit: cover; }

/* --- Panel: quiet bounded block for CTAs and contact ---------------------- */
.panel {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
}
.panel--accent { background: var(--accent-tint); border-color: #F0DCC9; }

/* --- FAQ: native disclosure, no JavaScript -------------------------------- */
.faq { border-top: var(--border); }
.faq__item { border-bottom: var(--border); }
.faq__item summary {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) 0;
  font-size: var(--t-h4); font-weight: 600;
  cursor: pointer;
  list-style: none;
  min-height: 44px;
}
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary::after {
  content: "";
  flex: none;
  width: 11px; height: 11px;
  margin-top: 0.45em;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
}
.faq__item[open] summary::after { transform: rotate(225deg); }
.faq__item summary:hover { color: var(--accent-strong); }
.faq__answer { padding-bottom: var(--s-5); color: var(--ink-2); max-width: 62ch; }
.faq__answer p + p { margin-top: var(--s-3); }

/* --- Support topic list --------------------------------------------------- */
.topics { display: grid; gap: 0; border-top: var(--border); }
.topics li { border-bottom: var(--border); }
.topics li > * { display: block; padding: var(--s-4) 0; color: var(--ink-2); }

/* --- Legal document ------------------------------------------------------- */
.doc { max-width: var(--wrap-prose); }
.doc h2 {
  font-size: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  margin-top: var(--s-9); margin-bottom: var(--s-4);
  padding-top: var(--s-5); border-top: var(--border);
}
.doc h2:first-of-type { margin-top: var(--s-7); }
.doc h3 { margin-top: var(--s-6); margin-bottom: var(--s-3); font-size: var(--t-h4); }
.doc p, .doc ul { color: var(--ink-2); }
.doc p + p, .doc ul + p, .doc p + ul { margin-top: var(--s-4); }
.doc ul { display: grid; gap: var(--s-2); padding-left: var(--s-5); list-style: disc; }
.doc li::marker { color: var(--ink-3); }

/* Table of contents for legal pages. */
.toc { margin-top: var(--s-6); padding-top: var(--s-5); border-top: var(--border); }
.toc ol {
  counter-reset: toc;
  display: grid; gap: var(--s-2);
  margin-top: var(--s-4);
}
.toc li { counter-increment: toc; }
.toc a { font-size: var(--t-small); color: var(--ink-2); }
.toc a::before {
  content: counter(toc) ". ";
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.toc a:hover { color: var(--accent-strong); }

/* --- Owner-content notice -------------------------------------------------
   Marks a legal/operational block whose final wording must come from the
   business owner. Honest and legible rather than hidden — see the Run 2
   report for the full list.                                              */
.pending {
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  padding: var(--s-4) var(--s-5);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--t-small);
  color: var(--ink-2);
  margin-top: var(--s-4);
}
.pending strong { color: var(--ink); }

/* --- 404 ------------------------------------------------------------------ */
.error-page {
  min-height: calc(100svh - var(--header-h) - 220px);
  display: flex; align-items: center;
  padding-block: var(--s-10);
}

/* --------------------------------------------------------------------------
   9. PAGE-SPECIFIC
   -------------------------------------------------------------------------- */

/* --- Home hero ------------------------------------------------------------ */
.hero { padding-block: clamp(3rem, 1.5rem + 6vw, 6.5rem) clamp(3rem, 1.5rem + 5vw, 5.5rem); }
.hero__copy { max-width: 20ch; }
.hero .lead { max-width: 46ch; margin-top: var(--s-5); }
.hero .btn-row { margin-top: var(--s-7); }
.hero__note { margin-top: var(--s-5); font-size: var(--t-micro); color: var(--ink-3); }
@media (max-width: 860px) {
  .hero__copy { max-width: 100%; }
  .hero .media { margin-top: var(--s-9); }
}

/* --- Page hero (inner pages) ---------------------------------------------- */
.page-hero {
  padding-block: clamp(2.5rem, 1.5rem + 4vw, 5rem) clamp(2rem, 1.25rem + 3vw, 3.5rem);
  border-bottom: var(--border);
}
.page-hero .lead { max-width: 52ch; margin-top: var(--s-5); }

/* --- Business feature rows ------------------------------------------------ */
.feature-row + .feature-row { margin-top: var(--s-10); padding-top: var(--s-10); border-top: var(--border); }
.feature-row:nth-child(even) .feature-row__media { order: -1; }
@media (max-width: 860px) {
  .feature-row:nth-child(even) .feature-row__media { order: 0; }
  .feature-row + .feature-row { margin-top: var(--s-9); padding-top: var(--s-9); }
}

/* --- Business bridge ------------------------------------------------------ */
.bridge__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-6); margin-top: var(--s-7); }
.bridge__list li { padding-top: var(--s-3); border-top: var(--border); font-weight: 500; }
@media (max-width: 480px) { .bridge__list { grid-template-columns: minmax(0, 1fr); } }

/* --------------------------------------------------------------------------
   10. UTILITIES + MOTION
   -------------------------------------------------------------------------- */
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mt-7 { margin-top: var(--s-7); }
.mt-8 { margin-top: var(--s-8); }
.center { text-align: center; }
.stack { display: grid; gap: var(--s-5); }

/* Honour the OS-level reduced-motion setting: remove all transitions
   and smooth scrolling rather than merely shortening them.               */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .header, .footer, .btn-row, .skip-link { display: none; }
  body { background: #fff; color: #000; }
}
