/* Thumbdial — legal pages (privacy policy, terms): a long-form reading layout on the page ground.
   Markup: pages/legal.mjs. Sections are the legacy legal HTML untouched; everything here styles plain p/ul/ol/table.
   ≥1100px: sticky side TOC (scrollspy from r3.js → aria-current="location") + text column with hanging numerals.
   <1100px: collapsible TOC above the text. Print: text only, black on white. */

.is-legal { --measure: 36em; --hang: 64px; } /* 36em at 18px Geist ≈ 68–72 characters a line */

/* ------------------------------------------------------------------ hero */
.lg-hero { padding-block: clamp(48px, 7vw, 104px) 0; }
.lg-hero h1 { max-width: 20ch; }
:lang(de) .lg-hero h1, :lang(fr) .lg-hero h1 { max-width: 24ch; }
:lang(ja) .lg-hero h1 { font-size: clamp(30px, 3.4vw, 48px); line-height: 1.25; max-width: 24em; }
.lg-date { margin-top: 20px; font-size: 15px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.lg-date time { color: var(--ink); font-weight: 600; }
.lg-ruler { --n: 48; margin-top: 40px; color: var(--ink3); }

/* Draft banner (only on --legal-draft builds): an alert, impossible to miss. */
.lg-hero .legal-draft { display: block; margin-top: 24px; max-width: 72ch; padding: 14px 18px 14px 20px; border-radius: 12px;
  font-size: 15px; line-height: 1.45; color: #7A0F0F; background: #FBE3E1; box-shadow: inset 0 0 0 1px #E3A29C, inset 4px 0 0 #C62828; }
.lg-hero .legal-draft .legal-missing { background: none; color: inherit; padding: 0; }
@media (prefers-color-scheme: dark) {
  .lg-hero .legal-draft { color: #FFD9D4; background: #3A1513; box-shadow: inset 0 0 0 1px #6E2622, inset 4px 0 0 #FF6B5E; }
}

/* ------------------------------------------------------------------ layout */
.lg { padding-block: clamp(32px, 4vw, 56px) clamp(80px, 9vw, 128px); }
@media (min-width: 1100px) {
  .lg { display: grid; grid-template-columns: 264px minmax(0, 1fr); column-gap: clamp(40px, 4vw, 64px); align-items: start; }
}

/* ------------------------------------------------------------------ TOC */
.lg-toc { font-size: 15px; line-height: 1.35; }
.lg-toc summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.lg-toc summary::-webkit-details-marker { display: none; }
.lg-toc h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.lg-toc summary svg { width: 18px; height: 18px; flex: none; stroke: currentColor; stroke-width: 1.6; transition: transform .2s var(--e-travel); }
.lg-toc details[open] summary svg { transform: rotate(180deg); }
.lg-toc ol { list-style: none; counter-reset: toc; }
.lg-toc li { counter-increment: toc; }
.lg-toc ol a { position: relative; display: grid; grid-template-columns: 2.1em minmax(0, 1fr); padding: 6px 0 6px 14px; color: var(--ink3); text-decoration: none; }
.lg-toc ol a::before { content: counter(toc); font-variant-numeric: tabular-nums; color: var(--ink3); }
.lg-toc ol a:hover { color: var(--ink); }
.lg-toc ol a[aria-current] { color: var(--ink); font-weight: 600; }
/* The current item: a 2px orange tick on the hairline rail. */
.lg-toc ol a[aria-current]::after { content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background: var(--accent); }
.lg-toc a:focus-visible { outline-offset: 0; }
:lang(ja) .lg-toc ol a { word-break: auto-phrase; }
.lg-side__top { display: none; }

@media (max-width: 1099px) {
  .lg-toc { max-width: var(--measure); margin-bottom: 32px; border-block: 1px solid var(--hair); }
  .lg-toc summary { min-height: 56px; cursor: pointer; }
  .lg-toc ol { padding-bottom: 16px; border-inline-start: 1px solid var(--hair); margin-bottom: 8px; }
  .lg-toc ol a { padding-block: 8px; }
}
@media (min-width: 760px) and (max-width: 1099px) { .lg-side { padding-inline-start: var(--hang); } }
@media (min-width: 1100px) {
  .lg-side { position: sticky; top: calc(var(--hd) + 32px); max-height: calc(100svh - var(--hd) - 56px); overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; padding-bottom: 8px; }
  .lg-toc summary { pointer-events: none; padding-bottom: 12px; }
  .lg-toc summary svg { display: none; }
  .lg-toc ol { border-inline-start: 1px solid var(--hair); }
  .lg-side__top { display: block; margin-top: 20px; padding-inline-start: 14px; font-size: 14px; color: var(--ink3); }
}

/* ------------------------------------------------------------------ reading column */
.lg-body { counter-reset: sec; font-size: 18px; line-height: 1.6; color: var(--ink2); min-width: 0; }
@media (min-width: 760px) { .lg-body { padding-inline-start: var(--hang); } }
:lang(ja) .lg-body, :lang(ja) .lg-toc, :lang(ja) .lg-date {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif; }
:lang(ja) .lg-body { font-size: 17px; line-height: 1.9; --measure: 38em; }

.lg-body section > :where(p, ul, ol, h3, h4), .lg-sum, .lg-intro { max-width: var(--measure); }
.lg-body section > * + * { margin-top: 1em; }
.lg-body section > h2 + * { margin-top: 0; }
.lg-body strong { font-weight: 600; color: var(--ink); }
.lg-body a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); overflow-wrap: anywhere; }
.lg-body a:hover { text-decoration-thickness: 2px; text-decoration-color: currentColor; }
.lg-body code { font: .88em/1 var(--f-mono); padding: .1em .3em; border-radius: 4px; background: var(--bg-2); color: var(--ink); overflow-wrap: anywhere; }
.lg-body section ul, .lg-body section ol { padding-inline-start: 1.25em; }
.lg-body section li + li { margin-top: .55em; }
.lg-body section li::marker { color: var(--ink3); }
.lg-body section ol { font-variant-numeric: tabular-nums; }

/* Section headings with hanging numerals. <a class="lg-anc"> precedes each section: its ::before is the numeral, and
   the "#" permalink on hover/focus (of the numeral or the heading). */
.lg-body section > h2 { font-size: clamp(22px, 2vw, 28px); line-height: 1.2; letter-spacing: -.02em; color: var(--ink); margin-bottom: 16px; }
:lang(ja) .lg-body section > h2 { line-height: 1.45; letter-spacing: 0; }
.lg-anc { counter-increment: sec; position: relative; display: block; height: 0; margin-top: clamp(56px, 6vw, 80px); text-decoration: none; color: var(--ink3); }
.lg-anc::before { content: counter(sec); position: absolute; top: 0; left: calc(-1 * var(--hang)); width: calc(var(--hang) - 16px); text-align: end;
  font-size: clamp(22px, 2vw, 28px); line-height: 1.2; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; border-radius: 6px; }
:lang(ja) .lg-anc::before { line-height: 1.45; font-family: var(--f-sans); }
.lg-anc:hover, .lg-anc:focus-visible, .lg-anc:has(+ section > h2:hover) { color: var(--ink); }
.lg-anc:hover::before, .lg-anc:focus-visible::before, .lg-anc:has(+ section > h2:hover)::before { content: "#"; }
.lg-anc:focus-visible { outline: none; }
.lg-anc:focus-visible::before { outline: 2px solid #6AA8FF; outline-offset: 2px; }
@media (max-width: 759px) {
  .lg-body section > h2 { padding-inline-start: 1.6em; }
  .lg-anc::before { left: 0; width: auto; min-width: 1.6em; text-align: start; }
  .lg-sum + .lg-anc, .lg-intro + .lg-anc { margin-top: 48px; }
}

/* Summary (privacy) and intro (terms): calm, hairline-bounded, no card. */
.lg-sum { padding-block: 24px 28px; border-block: 1px solid var(--hair); }
.lg-sum h2 { font-size: 19px; line-height: 1.3; letter-spacing: -.012em; color: var(--ink); margin-bottom: 12px; }
.lg-sum ul { list-style: none; display: grid; gap: 10px; }
.lg-sum li { position: relative; padding-inline-start: 26px; }
.lg-sum li::before { content: ""; position: absolute; left: 0; top: 14px; width: 12px; height: 1px; background: var(--ink3); }
:lang(ja) .lg-sum li::before { top: 16px; }
.lg-intro { font-size: clamp(19px, 1.5vw, 21px); line-height: 1.5; color: var(--ink); padding-bottom: 28px; border-bottom: 1px solid var(--hair); }

/* Tables: hairline sheets (ink rule on top, hairlines between rows). They take the full column, wider than the measure. */
.lg-body table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; border-top: 1px solid var(--line); border-bottom: 1px solid var(--hair); }
.lg-body th, .lg-body td { padding: 12px 20px 12px 0; text-align: start; vertical-align: top; overflow-wrap: break-word; hyphens: auto; }
.lg-body th:last-child, .lg-body td:last-child { padding-inline-end: 0; }
.lg-body th { font-size: 13px; font-weight: 600; color: var(--ink); vertical-align: bottom; padding-block: 10px; }
.lg-body td { border-top: 1px solid var(--hair); }
.lg-body td:first-child { color: var(--ink); }
:lang(ja) .lg-body table { line-height: 1.7; }
/* Small screens: the table scrolls sideways inside the column; the page never does. */
@media screen and (max-width: 759px) {
  .lg-body table { display: block; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    background: linear-gradient(to right, var(--bg) 40%, transparent) left / 24px 100% no-repeat local,
                linear-gradient(to left, var(--bg) 40%, transparent) right / 24px 100% no-repeat local,
                linear-gradient(to right, color-mix(in srgb, var(--ink) 14%, transparent), transparent) left / 10px 100% no-repeat scroll,
                linear-gradient(to left, color-mix(in srgb, var(--ink) 14%, transparent), transparent) right / 10px 100% no-repeat scroll; }
  .lg-body th, .lg-body td { min-width: 9em; }
  /* Wide sheets (the provider table) keep readable columns and scroll; two-column sheets fit the screen. */
  .lg-body table:has(th:nth-child(4)) :is(th, td) { min-width: 10.5em; }
  .lg-body table:has(th:nth-child(4)) :is(th, td):nth-child(-n+2) { min-width: 8.5em; }
  .lg-body table:has(th:nth-child(4)) :is(th, td):last-child { min-width: 20em; }
}

.lg-end { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--hair); font-size: 15px; color: var(--ink3); }

/* ------------------------------------------------------------------ print: the text, black on white */
@media print {
  @page { margin: 18mm 16mm 20mm; }
  .is-legal { --bg: #fff; --bg-2: #f2f2f2; --ink: #000; --ink2: #000; --ink3: #333; --hair: #999; --line: #000; --hang: 2.4em; }
  body.is-legal { background: #fff; color: #000; }
  .lg-side, .lg-end, .lg-ruler { display: none !important; }
  .lg-hero { padding: 0; }
  .lg-hero h1 { font-size: 24pt; line-height: 1.1; letter-spacing: -.02em; max-width: none; }
  .lg-date { font-size: 10pt; margin-top: 8pt; }
  .lg-hero .legal-draft { color: #000; background: none; box-shadow: none; border: 1.5pt solid #000; border-radius: 0; font-size: 10pt; }
  .lg { display: block; padding: 12pt 0 0; }
  .lg-body { font-size: 10.5pt; line-height: 1.5; color: #000; padding-inline-start: var(--hang); }
  :lang(ja) .lg-body { font-size: 10pt; line-height: 1.75; }
  .lg-body section > :where(p, ul, ol), .lg-sum, .lg-intro { max-width: none; }
  .lg-body a { color: #000; text-decoration: underline; }
  .lg-body a[href^="http"]::after { content: " (" attr(href) ")"; display: inline-block; max-width: 100%; font-size: .85em; overflow-wrap: anywhere; }
  .lg-sum, .lg-intro { font-size: 10.5pt; padding-block: 8pt; break-inside: avoid; }
  .lg-sum li::before { top: .72em; }
  .lg-anc { margin-top: 18pt; color: #000; }
  .lg-anc::before { content: counter(sec) !important; font-size: 13pt; }
  .lg-body section > h2 { font-size: 13pt; margin-bottom: 6pt; padding-inline-start: 0; break-after: avoid; page-break-after: avoid; }
  .lg-body p, .lg-body li { orphans: 3; widows: 3; }
  .lg-body li { break-inside: avoid; }
  .lg-body table { display: table; overflow: visible; background: none; font-size: 8.5pt; break-inside: auto; }
  .lg-body thead { display: table-header-group; }
  .lg-body tr { break-inside: avoid; page-break-inside: avoid; }
  .lg-body th, .lg-body td { min-width: 0; padding: 4pt 8pt 4pt 0; }
}
/* touch: 44px rows in the collapsed TOC */
@media (max-width: 1099px) { .lg-toc ol a { min-height: 44px; align-content: center; } }
