/* MemorySprout legal H5
   Design Read: trust-first legal reading for overseas users + App embed.
   Dials: VARIANCE 3 / MOTION 2 / DENSITY 4
   References: Apple Legal / Google Privacy (single-column, lang switch, quiet chrome).
   Tokens align with MemorySprout design system. */

:root {
  --bg: #fff8f4;
  --surface: #ffffff;
  --ink: #211a12;
  --muted: #66564d;
  --tertiary: #897970;
  --accent: #296b40;
  --accent-soft: #d1f2d8;
  --primary: #9d4400;
  --line: #e7d8ce;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Helvetica Neue",
    sans-serif;
  --measure: 40rem;
  --pad: clamp(1rem, 4vw, 1.75rem);
  --header-h: 3.25rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171815;
    --surface: #24251f;
    --ink: #f5f1e8;
    --muted: #b9b5aa;
    --tertiary: #8e8a80;
    --accent: #8fb982;
    --accent-soft: #2d3a2c;
    --primary: #c46a32;
    --line: #3a3b34;
  }
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

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

/* --- Top bar: title + language switch only --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@supports not (backdrop-filter: blur(12px)) {
  .topbar {
    background: var(--bg);
  }
}

.topbar-inner {
  width: min(100%, calc(var(--measure) + 2 * var(--pad)));
  margin: 0 auto;
  padding: 0.55rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--header-h);
}

.brand {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.brand strong {
  color: var(--ink);
  font-weight: 650;
}

/* Segmented language control (Apple-style) */
.lang-switch {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  gap: 0.15rem;
}

.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.55rem 0.85rem;
  min-height: 36px;
  min-width: 44px;
  border-radius: 999px;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--ink);
}

.lang-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell {
  width: min(100%, calc(var(--measure) + 2 * var(--pad)));
  margin: 0 auto;
  padding: 1.25rem var(--pad) 3.5rem;
}

h1 {
  margin: 0.25rem 0 0.75rem;
  font-size: clamp(1.5rem, 5vw, 1.875rem);
  line-height: 1.25;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.meta {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.meta p {
  margin: 0.2rem 0;
}

article h2 {
  margin: 2rem 0 0.65rem;
  font-size: 1.125rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: 700;
  scroll-margin-top: calc(var(--header-h) + 0.75rem);
}

article p,
article li {
  max-width: 65ch;
}

article p {
  margin: 0 0 0.85rem;
}

article ul {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  max-width: 65ch;
}

article li {
  margin: 0.3rem 0;
}

article li::marker {
  color: var(--accent);
}

.footer {
  margin-top: 2.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--tertiary);
  font-size: 0.8125rem;
}

.footer p {
  margin: 0.3rem 0;
  max-width: none;
}

/* Public-only: link to the other legal doc (hidden in app embed) */
.web-only-nav {
  margin-top: 1.5rem;
  font-size: 0.875rem;
}

.web-only-nav a {
  text-decoration: none;
  font-weight: 600;
}

.lang-panel[hidden] {
  display: none !important;
}

/* App embed: one document only; language comes from App, no web chrome */
html.app-embed .topbar,
html.app-embed .web-only-nav,
html.app-embed .web-only-footer-links {
  display: none !important;
}

html.app-embed body {
  /* Prevent accidental pull-to-refresh feel inside WKWebView */
  overscroll-behavior: none;
}

@media (max-width: 480px) {
  body {
    font-size: 1rem;
  }

  .lang-switch button {
    padding: 0.5rem 0.7rem;
  }
}
