/* Shared stylesheet for the static /legal pages. Tokens mirror the retired
   web/src/index.css palette (cream paper, warm ink). */

:root {
  --background: #FDFBF6;
  --foreground: #1C1A17;
  --muted: #F0EDE9;
  --muted-foreground: #6B6459;
  --border: #D8D0C3;
  --border-control: #837A6C;
  --primary: #E8833A;
  --primary-ink: #A24F2C;
  --ring: #E8833A;
  --tab-active: #FDFBF6;

  --font-sans: 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', 'Nimbus Sans',
    'Segoe UI', 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo',
    'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono',
    'Pretendard Variable', Pretendard, 'Apple SD Gothic Neo', 'Noto Sans KR', monospace;
  --font-serif: 'Roboto Serif Variable', 'Roboto Serif', Georgia, serif;
  /* Japanese fonts ahead of the Hangul ones, so kanji and kana get Japanese glyph forms. */
  --font-sans-ja: 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', 'Nimbus Sans',
    'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP',
    'Noto Sans CJK JP', 'Yu Gothic UI', 'Yu Gothic', Meiryo, -apple-system,
    'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --font-mono-ja: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono',
    'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Noto Sans CJK JP',
    'Yu Gothic', Meiryo, 'Apple SD Gothic Neo', 'Noto Sans KR', monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --background: #1C1A17;
    --foreground: #FDFBF6;
    --muted: #333231;
    --muted-foreground: #D8D0C3;
    --border: #3A3630;
    --border-control: #8C857A;
    --primary: #FFB689;
    --primary-ink: #FFB689;
    --ring: #FFB689;
    --tab-active: #2A2826;
    color-scheme: dark;
  }
}

:root.dark {
  --background: #1C1A17;
  --foreground: #FDFBF6;
  --muted: #333231;
  --muted-foreground: #D8D0C3;
  --border: #3A3630;
  --border-control: #8C857A;
  --primary: #FFB689;
  --primary-ink: #FFB689;
  --ring: #FFB689;
  --tab-active: #2A2826;
  color-scheme: dark;
}

/* Language: English is the no-JS default; the inline script adds .lang-ko, .lang-ja or .lang-es. */
:root:not(.lang-ko) .ko,
:root:not(.lang-ja) .ja,
:root:not(.lang-es) .es,
:root.lang-ko .en,
:root.lang-ja .en,
:root.lang-es .en,
:root:not(.js) .lang-switch {
  display: none;
}

/* Japanese: swap the font tokens while the page is in Japanese, and give the
   日本語 button its Japanese stack in the other languages too. */
:root.lang-ja {
  --font-sans: var(--font-sans-ja);
  --font-mono: var(--font-mono-ja);
}

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

html {
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
  accent-color: var(--primary);
  scrollbar-color: var(--border-control) transparent;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
}

::selection {
  background-color: color-mix(in srgb, var(--primary) 32%, transparent);
  color: var(--foreground);
}

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

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.page {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
  font-size: 1.125rem;
  line-height: 1.625;
}

/* Masthead */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.home {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--muted-foreground);
  text-decoration: none;
}

/* The logo: the d2 apple beside the hand-drawn "daytwo" (tools/draw_logo.py), as two registered
   layers painted through masks. The coral plate stays coral; the ink takes the text colour, so it
   follows the light and dark themes, as the app's lockup does. The box is the lockup's own aspect
   ratio (104.62 × 26.5). */
.wordmark {
  position: relative;
  display: block;
  height: 1.7rem;
  aspect-ratio: 104.62 / 26.5;
}

.wordmark::before,
.wordmark::after {
  content: '';
  position: absolute;
  inset: 0;
  -webkit-mask: var(--layer) no-repeat center / contain;
  mask: var(--layer) no-repeat center / contain;
}

.wordmark::before {
  --layer: url('/lockup-fill.svg');
  background-color: #ff7f50;
}

.wordmark::after {
  --layer: url('/lockup-ink.svg');
  background-color: var(--foreground);
}

.lang-switch {
  display: inline-flex;
  height: 2rem;
  padding: 3px;
  border-radius: 10px;
  background: var(--muted);
}

.lang-switch button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem 0.375rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-foreground);
  font: 500 0.875rem/1.375rem var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
}

/* 44x44 touch target around a 32px strip. */
.lang-switch button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-width: 2.75rem;
  min-height: 2.75rem;
  transform: translate(-50%, -50%);
}

.lang-switch button:lang(ja) { font-family: var(--font-sans-ja); }

.lang-switch button:hover { color: var(--foreground); }

.lang-switch button[aria-pressed='true'] {
  background: var(--tab-active);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgb(28 26 23 / 0.08);
}

:root.dark .lang-switch button[aria-pressed='true'] { border-color: var(--border-control); }
@media (prefers-color-scheme: dark) {
  :root:not(.light) .lang-switch button[aria-pressed='true'] { border-color: var(--border-control); }
}

/* Page title and meta registers */
.title {
  margin-top: 2.5rem;
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

.document .title { margin-bottom: 0.5rem; }
.index .title { margin-bottom: 1rem; }

.meta {
  margin-bottom: 3rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
}

:lang(ko) .meta, .meta:lang(ko),
:lang(ja) .meta, .meta:lang(ja) { letter-spacing: 0.06em; }

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.75rem;
}

/* Contents */
.toc h2 { margin-bottom: 0.75rem; }

.toc ul {
  padding: 0;
  list-style: none;
  font-size: 1rem;
  line-height: 1.5rem;
}

.toc a,
.row,
.links a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
}

.toc a { padding-block: 0.5rem; }

/* Document sections */
section > h2 {
  margin: 2.5rem 0 0.75rem;
  scroll-margin-top: 2rem;
}

.prose { overflow-wrap: break-word; }
.prose > * + * { margin-top: 1rem; }
.prose ul { list-style: disc; padding-left: 1.5rem; }
.prose ol { list-style: decimal; padding-left: 1.5rem; }
.prose li { padding-left: 0.25rem; }
.prose li + li { margin-top: 0.5rem; }

/* Delete-account page */
.stack > * + * { margin-top: 1.5rem; }
.stack > .title { margin-top: 2.5rem; }
.stack ol { padding-left: 1.5rem; list-style: decimal; }
.stack li + li { margin-top: 0.75rem; }

.confirm {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  background: var(--primary-ink);
  color: var(--background);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.375rem;
  text-decoration: none;
}

.button:hover { background: color-mix(in srgb, var(--primary-ink) 90%, var(--foreground)); }

/* Footer */
.links {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.5rem;
  margin-top: 4rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.375rem;
}
