/*
 * WorldAsset policy & support pages — the one stylesheet for every page.
 * Content values mirror the app's tokens (frontend/libs/constants/designTokens.ts,
 * roleThemes.agent, SettingItem) for visual brand consistency.
 * Pages are generated by frontend/scripts/legal-web/build.ts; edit the generator, not the HTML.
 */

:root {
  color-scheme: light;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-900: #7f1d1d;
  --yellow-50: #fefce8;
  --yellow-600: #ca8a04;
  --blue-50: #eff6ff;
  --blue-600: #2563eb;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-700: #b45309;
  --green-50: #f0fdf4;
  --green-600: #16a34a;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-900: #111827;

  --primary: var(--red-600);
  --primary-dark: var(--red-700);
  --canvas: var(--gray-50);
  --surface: #ffffff;
  --text: var(--gray-900);
  --text-body: var(--gray-600);
  --text-caption: var(--gray-500);
  --text-muted: var(--gray-400);
  --border: var(--gray-200);
  --divider: var(--gray-100);

  --radius-card: 16px;
  --radius-tile: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --page-width: 720px;
  --font: 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}

a {
  color: var(--primary);
  text-underline-offset: 2px;
}

a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 8px;
}

p,
ul,
ol,
h1,
h2,
h3 {
  margin: 0;
}

strong {
  color: var(--text);
  font-weight: 600;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: var(--gray-100);
  border-radius: 6px;
  padding: 1px 5px;
}

.i {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wrap {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ─── Site header (web only; the app shows its own header instead) ────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 4px 24px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.site-nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-body);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current='page'] {
  color: var(--primary);
  font-weight: 500;
  border-bottom-color: var(--primary);
}

/* Narrow screens: links move to their own scrollable row under the brand. */
@media (max-width: 719px) {
  .site-header-inner {
    flex-wrap: wrap;
    padding-top: 10px;
  }

  .site-nav {
    width: 100%;
    margin-left: 0;
    gap: 18px;
  }
}

.page-head {
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 24px;
  line-height: 1.35;
  font-weight: 600;
}

.page-head p {
  margin-top: 4px;
  color: var(--text-caption);
  font-size: 14px;
}

/* ─── Content ──────────────────────────────────────────────────────────── */

.content {
  padding-top: 16px;
  padding-bottom: 24px;
}

.meta-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-tile);
  color: var(--text-caption);
  font-size: 12px;
  line-height: 1.5;
}

.meta-pill .i {
  font-size: 15px;
}

/* Settings-style group: small label above a bordered card. */
.group {
  margin-bottom: 20px;
}

.group-title {
  padding: 0 4px;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--text-body);
}

.group-desc {
  padding: 0 4px;
  margin: -4px 0 8px;
  font-size: 12px;
  color: var(--text-caption);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card {
  margin-top: 12px;
}

.card-body {
  padding: 16px;
}

.prose {
  color: var(--text-body);
}

.prose > * + * {
  margin-top: 10px;
}

.prose ul,
.prose ol {
  padding-left: 20px;
}

.prose li + li {
  margin-top: 6px;
}

.prose li::marker {
  color: var(--gray-400);
}

/* Summary card: icon heading + dot bullets (BulletRow in the old screen). */
.summary-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--text);
  text-wrap: balance;
}

.summary-head .i {
  font-size: 18px;
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 3px;
}

.dots {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
  color: var(--text-body);
}

.dots li {
  position: relative;
  padding-left: 16px;
}

.dots li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
}

/* Rows: mirror SettingItem (icon tile + title + caption, inset divider). */
.rows {
  list-style: none;
  padding: 0;
}

.row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 54px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
}

.row + .row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 64px;
  right: 16px;
  height: 1px;
  background: var(--divider);
}

.tile {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-tile);
  background: var(--gray-50);
  color: var(--text-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tile.danger {
  background: var(--red-50);
  color: var(--red-600);
}

.tile.role-agent {
  background: var(--red-50);
  color: var(--red-600);
}

.tile.role-unit {
  background: var(--yellow-50);
  color: var(--yellow-600);
}

.tile.role-regional {
  background: var(--blue-50);
  color: var(--blue-600);
}

.tile.role-admin {
  background: var(--red-50);
  color: var(--red-900);
}

.row-text {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.row-title {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--text);
}

.row-title.danger {
  color: var(--red-600);
}

.row-desc {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-caption);
}

.row-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-caption);
}

.row-link {
  align-items: center;
}

.row-link:active {
  background: var(--gray-50);
}

.row-link .chevron {
  font-size: 18px;
  color: var(--text-muted);
}

@media (hover: hover) {
  .row-link:hover {
    background: var(--gray-50);
  }
}

/* Status-style chip (pill with tinted background, like the app). */
.chip {
  flex-shrink: 0;
  align-self: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.chip.success {
  background: var(--green-50);
  color: var(--green-600);
}

.chip.warning {
  background: var(--amber-50);
  color: var(--amber-700);
}

.chip.danger {
  background: var(--red-50);
  color: var(--red-600);
}

/* Numbered steps. */
.steps {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
  counter-reset: step;
  color: var(--text-body);
}

.steps li {
  position: relative;
  padding-left: 36px;
  min-height: 24px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--red-50);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Warning callout. */
.callout {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius-card);
  background: var(--amber-50);
  border: 1px solid var(--amber-100);
  color: var(--amber-700);
}

.callout .i {
  font-size: 18px;
  margin-top: 2px;
}

.callout strong {
  display: block;
  color: var(--amber-700);
}

/* Buttons: mirror DT.components.buttonPrimary / buttonSecondary. */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.card-body + .actions,
.rows + .actions {
  padding-top: 0;
}

.btn {
  flex: 1 1 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: var(--radius-tile);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
}

.btn .i {
  font-size: 18px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:active {
  background: var(--gray-50);
}

/* Disclosure (FAQ + English summary), no script needed. */
details > summary {
  list-style: none;
  cursor: pointer;
}

details > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text);
}

.disclosure > summary .label {
  flex: 1;
  min-width: 0;
}

.disclosure > summary .chevron {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.disclosure[open] > summary .chevron {
  transform: rotate(90deg);
}

.disclosure > .card-body {
  padding-top: 0;
}

.faq .disclosure + .disclosure {
  border-top: 1px solid var(--divider);
}

.faq .disclosure > .card-body {
  padding-left: 16px;
}

.en .label small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-caption);
}

/* Empty state (404). */
.empty {
  padding: 32px 20px;
  text-align: center;
}

.empty .tile {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  font-size: 26px;
  background: var(--gray-100);
  margin-bottom: 12px;
}

.empty h1 {
  font-size: 16px;
  font-weight: 600;
}

.empty p {
  margin: 6px auto 0;
  max-width: 420px;
  color: var(--text-caption);
}

.empty .actions {
  justify-content: center;
  padding: 20px 0 0;
}

.empty .btn {
  flex: 0 1 auto;
}

/* ─── Footer ───────────────────────────────────────────────────────────── */

.site-footer {
  padding-top: 8px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin-bottom: 8px;
}

.footer-links a {
  color: var(--text-caption);
  text-decoration: none;
  padding: 4px 0;
}

.footer-links a:hover {
  color: var(--primary);
}

@media (min-width: 640px) {
  body {
    font-size: 15px;
  }

  .content {
    padding-top: 32px;
  }

  .page-head h1 {
    font-size: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .disclosure > summary .chevron {
    transition: none;
  }
}

.row-link .row-title,
.row-link .row-desc {
  display: block;
}
