/**
 * Styles for the static legal and support pages served beside the Flutter web
 * app (/privacy/, /terms/, /support/, /delete-account/).
 *
 * These pages are deliberately plain HTML and CSS with no Flutter, no
 * framework and no build step: an App Review reviewer, a store crawler or a
 * learner on a slow connection must be able to read them instantly, and they
 * have to keep working even when the app bundle does not.
 *
 * Colours mirror `lib/theme.dart` (AppColors light and dark) so the pages look
 * like the app they belong to.
 */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --wash: #f7fbf4;
  --ink: #3c3c3c;
  --muted: #777777;
  --teal: #58cc02;
  --teal-ink: #46a302;
  --coral: #ff4b4b;
  --coral-soft: #ffdfe0;
  --gold-soft: #fff5d0;
  --gold-line: #ffd84d;
  --gold-ink: #7a5c00;
  --line: #e5e5e5;
  --radius: 18px;
}

:root[data-theme='dark'] {
  --bg: #131f24;
  --surface: #202f36;
  --wash: #1b2a30;
  --ink: #f1f7fb;
  --muted: #afafaf;
  --teal: #58cc02;
  --teal-ink: #7ee63a;
  --coral: #ff4b4b;
  --coral-soft: #3a2224;
  --gold-soft: #33290e;
  --gold-line: #8a6d16;
  --gold-ink: #ffd98a;
  --line: #37464f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Nunito, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body.lang-km {
  font-family: 'Noto Sans Khmer', Nunito, -apple-system, sans-serif;
}

/* ── Header ──────────────────────────────────────────────────────── */

.legal-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.legal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 900;
  font-size: 19px;
  margin-right: auto;
}

.legal-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.legal-nav-links {
  display: flex;
  gap: 18px;
}

.legal-nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
}

.legal-nav-links a:hover,
.legal-nav-links a[aria-current='page'] {
  color: var(--teal-ink);
}

/* Theme and language sit together at the end of the bar, as they do in the
   app's top bar. */
.legal-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Light / dark switch, same shape as ThemeToggle in the app. */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.16s ease,
    border-color 0.16s ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--teal-ink);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--teal-ink);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* One icon shows the theme you are in, as the app's toggle does. The moon is
   hidden until a theme is resolved onto <html>, so the no-JS default is the
   sun rather than both. */
.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme='dark'] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme='dark'] .theme-toggle .icon-moon {
  display: block;
}

/* Labels the switches for screen readers without taking space in the bar. */
.sr-only {
  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;
  border: 0;
}

/* Segmented EN / ខ្មែរ control, same shape as LanguageSwitcher in the app. */
.lang {
  display: inline-flex;
  background: var(--wash);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.lang-opt {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.lang-opt.is-on {
  background: var(--teal);
  color: #fff;
}

.lang-opt:focus-visible {
  outline: 3px solid var(--teal-ink);
  outline-offset: 2px;
}

/* ── Document ────────────────────────────────────────────────────── */

.legal-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 22px 88px;
}

.legal-head {
  padding-bottom: 26px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 34px;
}

.legal-head h1 {
  font-size: clamp(30px, 5.4vw, 44px);
  line-height: 1.12;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.legal-meta b {
  color: var(--ink);
  font-weight: 800;
}

.legal-toc {
  background: var(--wash);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 0 0 38px;
}

.legal-toc h2 {
  font-size: 13px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.legal-toc ol {
  margin: 0;
  padding-left: 20px;
  columns: 2;
  column-gap: 30px;
}

.legal-toc li {
  margin: 0 0 6px;
  break-inside: avoid;
}

.legal-toc a {
  color: var(--teal-ink);
  text-decoration: none;
  font-weight: 700;
}

.legal-toc a:hover {
  text-decoration: underline;
}

.legal-main h2 {
  font-size: clamp(21px, 3vw, 26px);
  margin: 42px 0 14px;
  scroll-margin-top: 80px;
}

.legal-main h3 {
  font-size: 18px;
  margin: 28px 0 10px;
}

.legal-main p,
.legal-main li {
  font-size: 17px;
  line-height: 1.72;
}

.legal-main p {
  margin: 0 0 16px;
}

.legal-main ul,
.legal-main ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.legal-main li {
  margin-bottom: 9px;
}

.legal-main a {
  color: var(--teal-ink);
  font-weight: 700;
}

.legal-main strong,
.legal-main b {
  font-weight: 800;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 22px;
  font-size: 16px;
}

.legal-table th,
.legal-table td {
  text-align: left;
  vertical-align: top;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  line-height: 1.6;
}

.legal-table th {
  width: 34%;
  font-weight: 800;
  background: var(--wash);
}

.legal-table tr:first-child th,
.legal-table tr:first-child td {
  border-top: 1px solid var(--line);
}

.legal-note {
  border-left: 5px solid var(--teal);
  background: var(--wash);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 0 0 24px;
}

.legal-note p:last-child {
  margin-bottom: 0;
}

.legal-warn {
  border-left-color: var(--coral);
  background: var(--coral-soft);
}

/**
 * A fact only the operator or their lawyer can supply. Deliberately loud: it
 * must be impossible to publish one of these without noticing.
 * `pnpm check:legal` fails while any remain.
 */
.pending {
  display: inline-block;
  background: var(--gold-soft);
  border: 2px dashed var(--gold-line);
  border-radius: 8px;
  padding: 1px 8px;
  font-size: 0.92em;
  font-weight: 800;
  color: var(--gold-ink);
}

.legal-pending-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--gold-soft);
  border: 2px solid var(--gold-line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 30px;
}

.legal-pending-banner p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.6;
}

.legal-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0 0 26px;
}

.legal-steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 0 52px;
  margin-bottom: 20px;
  min-height: 36px;
}

.legal-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  font-size: 17px;
  display: grid;
  place-items: center;
}

.legal-related {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin: 52px 0 0;
  padding-top: 34px;
  border-top: 2px solid var(--line);
}

.legal-related a {
  display: block;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.legal-related a:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
}

.legal-related span {
  display: block;
  font-weight: 400;
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

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

.legal-footer {
  border-top: 1px solid var(--line);
  padding: 28px 22px 44px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.legal-footer p {
  margin: 0 0 8px;
}

.legal-footer a {
  color: var(--muted);
  font-weight: 700;
}

/* Khmer needs taller lines and no negative tracking. */
.lang-km .legal-main p,
.lang-km .legal-main li,
.lang-km .legal-table td,
.lang-km .legal-table th,
.lang-km .legal-head h1 {
  line-height: 2;
  letter-spacing: 0;
}

@media (max-width: 620px) {
  .legal-nav-links {
    display: none;
  }

  .theme-toggle {
    width: 34px;
    height: 34px;
  }

  .theme-toggle svg {
    width: 18px;
    height: 18px;
  }

  .legal-toc ol {
    columns: 1;
  }

  .legal-table th {
    width: 40%;
  }

  .legal-main {
    padding: 28px 18px 72px;
  }
}
