/* ---------------------------------------------------------------------------
   The legal pages (/privacy, /terms and their translations). Static HTML
   written by scripts/build-legal.mjs, with the same ground colours, family and
   theme state as the rest of the site (DESIGN.md). `boot-theme.js` resolves
   [data-theme] before first paint; `legal-lang.js` picks the language.
   --------------------------------------------------------------------------- */


/* Mona Sans, variable (wdth 75–125, wght 200–900), served from /fonts so no
   request leaves the site. SIL Open Font License. */
@font-face {
  font-family: 'Mona Sans';
  font-style: normal;
  font-weight: 200 900;
  font-stretch: 75% 125%;
  font-display: swap;
  src: url('/fonts/mona-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Mona Sans';
  font-style: normal;
  font-weight: 200 900;
  font-stretch: 75% 125%;
  font-display: swap;
  src: url('/fonts/mona-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --display: 'Mona Sans', -apple-system, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --read: var(--display);
  --label: var(--display);
}

[data-theme='light'] {
  --wall: #eef0f2;
  --surface: #f8f9fa;
  --ink: #0d1014;
  --ink-muted: #474e58;
  --ink-faint: #5f6670;
  --line: rgba(13, 16, 20, 0.11);
  --line-strong: rgba(13, 16, 20, 0.22);
}

[data-theme='dark'] {
  --wall: #0f1114;
  --surface: #1b1f24;
  --ink: #eceef1;
  --ink-muted: #a8aeb7;
  --ink-faint: #8a919a;
  --line: rgba(236, 238, 241, 0.09);
  --line-strong: rgba(236, 238, 241, 0.2);
}

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

body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--read);
  font-optical-sizing: auto;
  font-size: 1.0625rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible,
.theme-switch button:focus-visible,
.lang-menu summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 2;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--wall);
  font-family: var(--label);
  font-size: 0.75rem;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
  outline-color: var(--wall);
  outline-offset: -6px;
}

.site-header,
main,
footer {
  width: min(760px, calc(100% - 2.5rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-family: var(--display);
  font-size: 1.0625rem;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.logo__mark {
  flex: none;
  width: 26px;
  height: 26px;
  margin-right: 0.5rem;
}

.logo span {
  color: var(--ink-faint);
}

/* Theme control. `boot-theme.js` wires [data-theme-set] up by delegation, so
   these pages need no JavaScript of their own. */
.theme-switch {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.theme-switch button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.theme-switch button svg {
  width: 16px;
  height: 16px;
}

.theme-switch button:hover {
  color: var(--ink);
}

/* Language menu. A <details> of plain links, so it works without JavaScript;
   `legal-lang.js` closes it on Escape or an outside click and remembers the
   pick. */
.site-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-menu {
  position: relative;
}

.lang-menu summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding-inline: 14px 12px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-faint);
  font-size: 0.875rem;
  font-weight: 540;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
}

.lang-menu summary::-webkit-details-marker {
  display: none;
}

.lang-menu summary:hover,
.lang-menu[open] summary {
  color: var(--ink);
}

.lang-menu summary svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.lang-menu__chevron {
  transition: rotate 200ms ease;
}

.lang-menu[open] .lang-menu__chevron {
  rotate: 180deg;
}

.lang-menu__list {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 3;
  width: max-content;
  min-width: 13rem;
  max-width: calc(100vw - 2.5rem);
  margin: 0;
  padding: 6px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  list-style: none;
}

.lang-menu__list li + li {
  margin-top: 0;
}

.lang-menu__list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding-inline: 14px;
  border-radius: 14px;
  color: var(--ink-muted);
  /* Each name carries its own lang, so it picks its own script's face. */
  font-family: var(--display);
  font-size: 0.9375rem;
  text-decoration: none;
}

.lang-menu__list a:hover {
  background: var(--wall);
  color: var(--ink);
}

.lang-menu__list a:focus-visible {
  outline-offset: -2px;
  border-radius: 14px;
}

.lang-menu__list a[aria-current='page'] {
  color: var(--ink);
  font-weight: 620;
}

.lang-menu__list a[aria-current='page']::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* On a phone the globe alone names the control; the label is in aria-label. */
@media (max-width: 520px) {
  .lang-menu__current {
    display: none;
  }

  .lang-menu summary {
    padding-inline: 14px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lang-menu__chevron {
    transition: none;
  }
}

[data-theme-choice='light'] .theme-switch [data-theme-set='light'],
[data-theme-choice='system'] .theme-switch [data-theme-set='system'],
[data-theme-choice='dark'] .theme-switch [data-theme-set='dark'] {
  background: var(--surface);
  color: var(--ink);
}

.policy {
  padding-block: 64px 24px;
}

.policy-header {
  padding-bottom: 32px;
}

h1,
h2 {
  font-family: var(--display);
  text-wrap: balance;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 760;
  font-stretch: 118%;
  line-height: 0.92;
  letter-spacing: -0.04em;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

p {
  max-width: 68ch;
  margin: 0 0 16px;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.effective-date {
  font-family: var(--label);
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

.translation-notice {
  margin-top: 24px;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.875rem;
  line-height: 1.55;
}

.policy-summary {
  margin-top: 32px;
  font-size: 1.1875rem;
  line-height: 1.5;
}

section {
  padding-block: 40px;
  border-top: 1px solid var(--line);
}

ul {
  max-width: 64ch;
  padding-inline-start: 22px;
  color: var(--ink-muted);
}

li + li {
  margin-top: 8px;
}

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-block: 32px;
  border-top: 1px solid var(--line);
  font-family: var(--label);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

footer p {
  margin: 0;
  color: inherit;
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}

/* ── Scripts other than Latin ────────────────────────────────────────────────
   Mona Sans sets the Latin words (iCloud, App Store) in every language; each
   script falls through to the system face made for it. Tracking and the tight
   display leading are tuned for Latin capitals, so CJK, Hangul and Arabic set
   them back to neutral. Arabic letters must never be tracked: it breaks the
   joins between them. */
:lang(ja) {
  --display: 'Mona Sans', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', Meiryo, 'Noto Sans JP', sans-serif;
}

:lang(zh-Hans) {
  --display: 'Mona Sans', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

:lang(zh-Hant) {
  --display: 'Mona Sans', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
}

:lang(ko) {
  --display: 'Mona Sans', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
}

:lang(ar) {
  --display: 'Mona Sans', 'SF Arabic', 'Geeza Pro', 'Segoe UI', 'Noto Sans Arabic', sans-serif;
}

:is(:lang(ja), :lang(zh), :lang(ko), :lang(ar)) :is(h1, h2) {
  letter-spacing: 0;
}

:is(:lang(ja), :lang(zh), :lang(ko)) h1 {
  font-size: clamp(2.25rem, 7vw, 3.5rem);
  line-height: 1.15;
}

:is(:lang(ja), :lang(zh)) body {
  line-height: 1.8;
}

:lang(ko) body {
  line-height: 1.75;
  word-break: keep-all;
}

:lang(ja) :is(h1, h2, p) {
  word-break: auto-phrase;
}

:lang(ar) h1 {
  line-height: 1.25;
}

:lang(ar) body {
  line-height: 1.85;
}
