/* =========================================================
   Temia legal pages (terms.html, privacy.html)
   Load after css/styles.css and css/temia-updates.css.
   Uses only the site's existing tokens (--navy, --amber, --paper, --line, --r …).
   Every selector is scoped to .legal-page / .lg-*, so other pages are unaffected.

   1. Page and title band
   2. Layout: contents + document
   3. Articles, clauses and lists
   4. Tables
   5. Footer, back-to-top
   6. Responsive and print
   ========================================================= */

/* ---------- 1. Page and title band ---------- */
.legal-page { background: var(--paper); }
.legal-page .nav a { padding-inline: 10px; }
html { scroll-padding-top: 88px; }

.lg-hero { background: var(--white); border-bottom: 1px solid var(--line); padding-top: calc(64px + clamp(36px, 5vw, 64px)); padding-bottom: clamp(28px, 3.6vw, 44px); }
.lg-hero-in { display: grid; gap: 14px; justify-items: start; }
.lg-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-4); }
.lg-crumbs a { color: var(--ink-3); text-decoration: none; }
.lg-crumbs a:hover { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }
.lg-crumbs [aria-current] { color: var(--navy); font-weight: 500; }
.lg-title {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: clamp(28px, 3.6vw, 42px); line-height: 1.3; font-weight: 700; letter-spacing: .02em; color: var(--navy);
}
.lg-title { word-break: keep-all; overflow-wrap: anywhere; }
.lg-title::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--amber); margin-bottom: 18px; }
.lg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.lg-chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 48px; background: var(--p10); color: var(--navy); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.lg-switch { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 48px; border: 1px solid var(--sh20); color: var(--ink-2); font-size: 13px; font-weight: 500; text-decoration: none; transition: border-color .2s, color .2s, background-color .2s; }
.lg-switch .ico { width: 16px; height: 16px; }
.lg-switch:hover { border-color: var(--navy); color: var(--navy); background: var(--p5); }
/* Shown only when the site is switched to English: the legal text itself stays Japanese */
.lg-lang-note { display: none; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r); background: var(--t10); color: #5C4300; font-size: 13.5px; line-height: 1.5; }
.lg-lang-note::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex: none; }
html[lang="en"] .lg-lang-note { display: inline-flex; }

/* ---------- 2. Layout: contents + document ---------- */
.lg-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: clamp(24px, 3.4vw, 48px); align-items: start; padding-top: clamp(28px, 3.6vw, 48px); padding-bottom: clamp(56px, 7vw, 96px); }

.lg-toc { position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow: auto; overscroll-behavior: contain; }
.lg-toc-box { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); }
.lg-toc-box summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; font-size: 12.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; border-bottom: 1px solid var(--line); }
.lg-toc-box summary::-webkit-details-marker { display: none; }
.lg-toc-count { min-width: 26px; height: 22px; padding: 0 8px; border-radius: 11px; background: var(--paper); color: var(--navy); font-size: 12px; text-align: center; line-height: 22px; letter-spacing: 0; }
.lg-toc ol { list-style: none; margin: 0; padding: 8px; display: grid; gap: 1px; }
.lg-toc a { display: grid; grid-template-columns: 4.2em minmax(0, 1fr); gap: 6px; padding: 7px 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink-2); font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif; font-size: 13.5px; line-height: 1.5; position: relative; transition: background-color .15s, color .15s; }
.lg-toc a .lg-art-no { color: var(--ink-4); font-variant-numeric: tabular-nums; }
.lg-toc a:hover { background: var(--paper); color: var(--navy); }
.lg-toc a.is-active { background: var(--p10); color: var(--navy); font-weight: 500; }
.lg-toc a.is-active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--amber); }
.lg-toc a.is-active .lg-art-no { color: var(--navy); }

.lg-doc {
  min-width: 0; max-width: 860px;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15.5px; line-height: 1.95; letter-spacing: .02em; color: var(--ink);
  font-feature-settings: "palt" 0; line-break: strict; overflow-wrap: anywhere;
}
/* Long legal text reads best with ordinary line breaking (the site uses phrase breaking for short marketing copy) */
.lg-doc p, .lg-doc li, .lg-doc td, .lg-doc th { word-break: normal; line-break: strict; text-wrap: wrap; }
.lg-doc h2 { word-break: keep-all; }
.lg-doc a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.lg-doc a:hover { color: var(--navy); }
.lg-preamble { background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: var(--r); padding: clamp(18px, 2.4vw, 26px) clamp(18px, 2.6vw, 30px); margin-bottom: 18px; }
.lg-preamble p + p { margin-top: .8em; }

/* ---------- 3. Articles, clauses and lists ---------- */
.lg-article { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(20px, 2.6vw, 30px) clamp(18px, 2.8vw, 34px); margin-bottom: 14px; scroll-margin-top: 88px; }
.lg-article:target { border-color: var(--p40); box-shadow: 0 0 0 3px var(--p10); }
.lg-article h2 { margin: 0 0 14px; font-family: inherit; font-size: clamp(17px, 1.6vw, 19px); line-height: 1.5; font-weight: 700; letter-spacing: .02em; color: var(--navy); }
.lg-anchor { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; color: inherit !important; text-decoration: none !important; }
.lg-art-no { font-variant-numeric: tabular-nums; }
.lg-article h2 .lg-art-no { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-sm); background: var(--navy); color: var(--white); font-size: 13.5px; font-weight: 600; letter-spacing: .04em; transform: translateY(-1px); }
.lg-anchor:hover .lg-art-title { text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.lg-article > p + p, .lg-article > p + .lg-clause, .lg-article > .lg-clause + p { margin-top: .7em; }
.lg-article > p + .lg-items, .lg-article > p + .lg-table { margin-top: .6em; }

.lg-clause { display: grid; grid-template-columns: 2em minmax(0, 1fr); gap: 0 4px; }
.lg-clause + .lg-clause { margin-top: .75em; }
.lg-cn { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.lg-cb { min-width: 0; }
.lg-cb > * + * { margin-top: .6em; }

.lg-items { list-style: none; margin: 0; padding: 12px 16px; display: grid; gap: 6px; background: var(--paper); border-radius: var(--r); }
.lg-items li { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); gap: 0 4px; }
.lg-items .lg-n { color: var(--s80); font-weight: 500; font-variant-numeric: tabular-nums; }
.lg-items li.dot { grid-template-columns: 1.2em minmax(0, 1fr); }
.lg-items li.dot .lg-n { color: var(--amber); font-weight: 700; }
.lg-items li.plain { grid-template-columns: minmax(0, 1fr); }
.lg-bullets { padding-block: 14px; }

.lg-close { display: grid; justify-items: end; gap: 2px; padding: 18px 4px 0; color: var(--ink-2); }

/* ---------- 4. Tables ---------- */
.lg-table { margin: .9em 0 .4em; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--white); }
.lg-table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.7; }
.lg-table th { text-align: left; font-weight: 700; color: var(--navy); background: var(--p5); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lg-table td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.lg-table tbody tr:first-child td { border-top: 0; }
.lg-table td:first-child { font-weight: 500; color: var(--navy); }

/* ---------- 5. Footer, back-to-top ---------- */
.lg-footer.section { padding-block: 0 28px; }
.lg-footer .lockup { margin-top: clamp(40px, 5vw, 56px); }
.lg-footer .foot-link[aria-current="page"] { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
a.foot-link { text-decoration: none; }

.lg-top {
  position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); z-index: 40;
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: var(--white); box-shadow: var(--shadow-soft);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .25s, transform .25s, background-color .2s;
}
.lg-top.is-on { opacity: 1; transform: none; pointer-events: auto; }
.lg-top:hover { background: var(--blue); }
.lg-top:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

/* ---------- 6. Responsive and print ---------- */
@media (max-width: 1100px) {
  .lg-grid { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .lg-grid { grid-template-columns: minmax(0, 1fr); }
  .lg-toc { position: static; max-height: none; overflow: visible; }
  .lg-toc-box summary { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--navy); }
  .lg-toc-box summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--s80); border-bottom: 2px solid var(--s80); transform: rotate(45deg); margin: -4px 4px 0 auto; transition: transform .2s; }
  .lg-toc-box[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
  .lg-toc-box:not([open]) summary { border-bottom: 0; }
  .lg-toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg-doc { max-width: none; }
}
@media (max-width: 640px) {
  .lg-toc ol { grid-template-columns: minmax(0, 1fr); }
  .lg-doc { font-size: 15px; line-height: 1.9; }
  .lg-article, .lg-preamble { border-radius: 6px; }
  .lg-items { padding: 10px 12px; }
  .lg-items li { grid-template-columns: 2.4em minmax(0, 1fr); }
  /* Tables become label/value cards */
  .lg-table { border: 0; background: transparent; overflow: visible; }
  .lg-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lg-table table, .lg-table tbody, .lg-table tr, .lg-table td { display: block; width: 100%; }
  .lg-table tr { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 0; }
  .lg-table tr + tr { margin-top: 8px; }
  .lg-table td { border: 0; padding: 6px 14px; }
  .lg-table td::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 500; color: var(--ink-4); line-height: 1.5; }
}
@media (prefers-reduced-motion: reduce) {
  .lg-top, .lg-toc a, .lg-switch { transition: none; }
}
@media print {
  .topbar, .lg-toc, .lg-top, .lg-footer, .lg-lang-note, .lg-switch { display: none !important; }
  .legal-page, .lg-hero { background: #fff; }
  .lg-hero { padding-top: 0; border: 0; }
  .lg-grid { display: block; padding: 0; }
  .lg-article, .lg-preamble { border: 0; padding: 0; margin-bottom: 1.2em; break-inside: avoid-page; }
  .lg-article h2 .lg-art-no { background: none; color: inherit; padding: 0; }
  .lg-doc a { color: inherit; text-decoration: none; }
}

/* ---------- 7. Japanese text and English translation ----------
   The site's EN / 日本語 switch sets <html lang>. Japanese is the default whenever lang is not "en". */
html[lang="en"] .legal-page .lg-ja { display: none !important; }
html:not([lang="en"]) .legal-page .lg-en { display: none !important; }
.lg-en.lg-l, .lg-doc .lg-en { font-family: "Poppins", "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: 0; }
.lg-doc .lg-en { line-height: 1.8; }
.lg-title .lg-en { font-family: "Poppins", "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: -0.01em; word-break: normal; }
.lg-toc a > .lg-ja, .lg-toc a > .lg-en { display: contents; }
.lg-anchor > .lg-ja, .lg-anchor > .lg-en { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.lg-toc a .lg-en .lg-art-no { white-space: nowrap; }
.lg-toc .lg-en, .lg-toc a { font-family: inherit; }
html[lang="en"] .lg-toc a { font-family: "Poppins", "Segoe UI", Helvetica, Arial, sans-serif; font-size: 13px; }
.lg-lang-note { max-width: 62ch; }
