/* Field Work Pro — landing page.
   Custom properties lifted 1:1 from src/theme/tokens.ts (light + dark palettes,
   spacing, radius, typeScale). No webfont: the system stack renders Vietnamese
   diacritics correctly and a font download is the largest avoidable cost on a
   mobile-data first paint. */

:root {
  --text: #111827;
  --text-secondary: #4B5563;
  --bg: #FFFFFF;
  --surface: #F3F4F6;
  --border: #E5E7EB;
  --primary: #2563EB;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;

  /* Text-safe derivations. The app renders these tones as icons and pills on
     --background; this page also uses them as 13px text and as meaningful
     borders, which WCAG AA holds to 4.5:1 and 3:1. Each value is the next step
     of the same colour ramp, measured on BOTH --bg and --surface:
       --text-secondary #4B5563  7.56 / 6.87   (was #6B7280: 4.83 / 4.39 — failed)
       --success-text   #15803D  5.02 / 4.56   (was #16A34A: 3.30 — failed)
       --warning-text   #B45309  5.02 / 4.56   (was #D97706: 3.19 — failed)
       --danger-text    #B91C1C  6.47 / 5.88   (was #DC2626: 4.83 / 4.39) */
  --success-text: #15803D;
  --warning-text: #B45309;
  --danger-text: #B91C1C;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #F9FAFB;
    --text-secondary: #9CA3AF;
    --bg: #0B0F14;
    --surface: #1F2937;
    --border: #374151;
    --primary: #3B82F6;
    --success: #22C55E;
    --danger: #EF4444;
    --warning: #F59E0B;
    /* Dark tones already clear AA as text: success 8.43/6.44, warning
       8.95/6.83, danger 5.11 on --bg. Danger is used only on --bg (on
       --surface it would be 3.90) — do not move a danger chip into a card. */
    --success-text: #22C55E;
    --warning-text: #F59E0B;
    --danger-text: #EF4444;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 var(--sp-md);
}

/* ---------- typography (typeScale: 24/18/16/13) ---------- */

h1 { font-size: 24px; font-weight: 700; line-height: 1.25; margin: 0 0 var(--sp-sm); }
h2 { font-size: 18px; font-weight: 600; line-height: 1.3; margin: var(--sp-xl) 0 var(--sp-md); }
h3 { font-size: 16px; font-weight: 600; margin: 0 0 var(--sp-xs); }
p  { margin: 0 0 var(--sp-md); }
small, .caption { font-size: 13px; color: var(--text-secondary); }

a { color: var(--primary); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

ul, ol { margin: 0 0 var(--sp-md); padding-left: 1.35em; }
li { margin-bottom: var(--sp-sm); }

/* ---------- header ---------- */

header.site {
  border-bottom: 1px solid var(--border);
  padding: var(--sp-md) 0;
}
.brand { display: flex; align-items: center; gap: var(--sp-md); }
.brand img { width: 48px; height: 48px; border-radius: var(--r-md); flex: none; }
.brand .name { font-size: 18px; font-weight: 700; }
.brand .tag { font-size: 13px; color: var(--text-secondary); }

/* ---------- hero ---------- */

.hero { padding: var(--sp-xl) 0 var(--sp-lg); }
.badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: var(--sp-md);
}
.lede { font-size: 18px; color: var(--text-secondary); }

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: var(--sp-md) var(--sp-xl);
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--r-md);
  transition: filter .15s ease;
}
.cta:hover { filter: brightness(1.08); }
.meta { margin-top: var(--sp-sm); font-size: 13px; color: var(--text-secondary); }

/* ---------- in-app browser banner ---------- */

#iab { display: none; }
#iab.show { display: block; }
#iab .box {
  border: 1px solid var(--warning-text);
  border-left: 4px solid var(--warning-text);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  margin: var(--sp-md) 0;
}
#iab .row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-md); }
#iab img { width: 104px; height: 104px; flex: none; background: #fff; border-radius: var(--r-sm); }
.btn {
  min-height: 44px;
  padding: var(--sp-sm) var(--sp-md);
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
}

/* ---------- sections & cards ---------- */

section { border-top: 1px solid var(--border); }
section:first-of-type { border-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-md);
}
.grid { display: grid; gap: var(--sp-md); }
@media (min-width: 720px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
}

.trust { list-style: none; padding: 0; }
.trust li { display: flex; gap: var(--sp-sm); }
.trust .mark { color: var(--success-text); font-weight: 700; flex: none; }

/* ---------- status chips (tones from src/domain/status.ts) ---------- */

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-sm); padding: 0; list-style: none; }
.chip {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.chip.neutral { color: var(--text-secondary); }
.chip.success { color: var(--success-text); }
.chip.danger  { color: var(--danger-text); }
.chip.warning { color: var(--warning-text); }

/* ---------- install guide ---------- */

.step {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-sm);
  background: var(--surface);
}
.step > summary {
  cursor: pointer;
  padding: var(--sp-md);
  font-weight: 600;
  list-style-position: inside;
}
.step > div { padding: 0 var(--sp-md) var(--sp-md); }
.step.critical { border-left: 4px solid var(--warning-text); }
kbd {
  font: inherit;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  white-space: nowrap;
}

/* ---------- permissions table ---------- */

.perm { width: 100%; border-collapse: collapse; font-size: 15px; }
.perm th, .perm td {
  text-align: left;
  vertical-align: top;
  padding: var(--sp-sm);
  border-bottom: 1px solid var(--border);
}
.perm th { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.perm code { font-size: 13px; }
@media (max-width: 560px) {
  .perm thead { display: none; }
  .perm tr { display: block; border-bottom: 1px solid var(--border); padding: var(--sp-sm) 0; }
  .perm td { display: block; border: 0; padding: 2px var(--sp-xs); }
  .perm td:first-child { font-weight: 700; }
}

/* ---------- footer ---------- */

footer.site {
  border-top: 1px solid var(--border);
  margin-top: var(--sp-xl);
  padding: var(--sp-lg) 0 var(--sp-xl);
  font-size: 13px;
  color: var(--text-secondary);
}
footer.site code { overflow-wrap: anywhere; }

/* ---------- a11y / motion / print ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  header.site, .hero, #iab, footer.site, #openall { display: none; }
  section:not(#cai-dat) { display: none; }
  .step > div { display: block !important; }
  body { color: #000; background: #fff; }
}
