/* ════════════════════════════════════
   Legal Pages — Shared Styles
   Identical to SPA (src/index.css)
   ════════════════════════════════════ */

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Theme Variables (from src/index.css + .home-page) ── */
:root {
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Page Transitions (matches SPA) ── */
@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: vt-fade-out 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
::view-transition-new(root) {
  animation: vt-fade-in 350ms cubic-bezier(0.0, 0, 0.2, 1) 80ms both;
}
@keyframes vt-fade-out {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to   { opacity: 0; transform: scale(0.98) translateY(-4px); }
}
@keyframes vt-fade-in {
  from { opacity: 0; transform: scale(1.01) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes page-enter {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Language Visibility ── */
[data-lang="en"] .lang-ja { display: none !important; }
[data-lang="ja"] .lang-en { display: none !important; }
html:not([data-lang]) .lang-ja { display: none !important; }

/* ── Base (matches .home-page light + dark gradients) ── */
body {
  font-family: 'Inter', 'Outfit', 'Noto Sans JP', sans-serif;
  background: linear-gradient(160deg, #faf5ed 0%, #f6efe4 30%, #f4efe5 70%, #f5f0e8 100%);
  color: #1a1a2e;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
  transition: background 0.5s ease, color 0.5s ease, opacity 0.28s ease, transform 0.28s ease;
  min-height: 100vh;
  animation: page-enter 0.3s ease-out;
}

/* Language switching fade (matches .home-lang-switching) */
body.lang-switching {
  opacity: 0 !important;
  transform: translateY(6px) !important;
}

/* Page exit transition (for link navigation) */
body.page-exiting {
  opacity: 0 !important;
  transform: scale(0.98) !important;
}

[data-theme="dark"] body {
  background: linear-gradient(160deg, #0b1120 0%, #111827 50%, #0b1120 100%);
  color: #e2e8f0;
}

/* Japanese typography (matches .home-page[data-lang="ja"]) */
[data-lang="ja"] body {
  font-family: 'Inter', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Meiryo', system-ui, sans-serif;
}

/* ══════════════════════════════════════
   HEADER  (identical to .home-header)
   ══════════════════════════════════════ */
.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .legal-header {
  background: rgba(11, 17, 32, 0.8);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* ── Brand (identical to .home-header-brand) ── */
.legal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.legal-brand-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #6366f1;
  border-radius: 10px;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  flex-shrink: 0;
}

.legal-brand-logo:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.legal-brand-logo svg { color: #fff; }

.legal-brand-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  white-space: nowrap;
  color: #6366f1;
}

.legal-brand-ext {
  color: #6366f1;
  font-weight: 600;
}

[data-theme="dark"] .legal-brand-text {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .legal-brand-ext {
  color: #818cf8 !important;
}

/* ══════════════════════════════════════
   HEADER BUTTONS  (identical to .convert-header-btn)
   ══════════════════════════════════════ */
.legal-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.legal-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.legal-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

.legal-btn--primary {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1a2e;
  font-weight: 600;
}

.legal-btn--primary:hover {
  background: rgba(0, 0, 0, 0.14);
}

[data-theme="dark"] .legal-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .legal-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

[data-theme="dark"] .legal-btn--primary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .legal-btn--primary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.legal-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   THEME ICON ANIMATION  (from SPA)
   ══════════════════════════════════════ */
.theme-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  position: relative;
}

.theme-icon-wrap.icon-spin-out {
  animation: icon-spin-out 250ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.theme-icon-wrap.icon-spin-in {
  animation: icon-spin-in 450ms cubic-bezier(0, 0, 0.2, 1.4) forwards;
}

.theme-icon-wrap.icon-spin-in::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid rgba(99, 102, 241, 0.5);
  animation: icon-halo 500ms ease-out forwards;
  pointer-events: none;
}

@keyframes icon-spin-out {
  0%   { transform: rotate(0deg) scale(1); opacity: 1; filter: drop-shadow(0 0 0 transparent); }
  40%  { filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.7)); }
  100% { transform: rotate(180deg) scale(0); opacity: 0; filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.3)); }
}

@keyframes icon-spin-in {
  0%   { transform: rotate(-180deg) scale(0); opacity: 0; filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.5)); }
  40%  { filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.8)); }
  65%  { transform: rotate(15deg) scale(1.2); opacity: 1; filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4)); }
  100% { transform: rotate(0deg) scale(1); opacity: 1; filter: drop-shadow(0 0 0 transparent); }
}

@keyframes icon-halo {
  0%   { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.8); opacity: 0; }
}

/* ══════════════════════════════════════
   HEADER GLOW PULSE  (from SPA)
   ══════════════════════════════════════ */
.legal-header.theme-header-glow {
  animation: header-glow-pulse 800ms ease-out forwards;
}

@keyframes header-glow-pulse {
  0%  { box-shadow: 0 1px 0 0 rgba(99, 102, 241, 0); border-bottom-color: rgba(99, 102, 241, 0); }
  30% { box-shadow: 0 2px 20px 0 rgba(99, 102, 241, 0.35), 0 0 40px 0 rgba(99, 102, 241, 0.15); border-bottom-color: rgba(99, 102, 241, 0.6); }
  100%{ box-shadow: 0 1px 0 0 rgba(99, 102, 241, 0); border-bottom-color: rgba(0, 0, 0, 0.08); }
}

[data-theme="dark"] .legal-header.theme-header-glow {
  animation: header-glow-pulse-dark 800ms ease-out forwards;
}

@keyframes header-glow-pulse-dark {
  0%  { box-shadow: 0 1px 0 0 rgba(165, 180, 252, 0); border-bottom-color: rgba(165, 180, 252, 0); }
  30% { box-shadow: 0 2px 20px 0 rgba(165, 180, 252, 0.3), 0 0 40px 0 rgba(165, 180, 252, 0.12); border-bottom-color: rgba(165, 180, 252, 0.5); }
  100%{ box-shadow: 0 1px 0 0 rgba(165, 180, 252, 0); border-bottom-color: rgba(255, 255, 255, 0.06); }
}

/* ══════════════════════════════════════
   THEME TRANSITION EFFECTS  (from SPA)
   ══════════════════════════════════════ */

/* Glow burst at button origin */
.theme-burst {
  position: fixed;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  top: 0;
  left: 0;
  transform: translate(calc(var(--burst-x) - 40px), calc(var(--burst-y) - 40px));
  background: radial-gradient(circle, rgba(99, 102, 241, 0.6), rgba(99, 102, 241, 0) 70%);
  animation: burst-flash 600ms ease-out forwards;
}

@keyframes burst-flash {
  0%   { opacity: 1; scale: 0.3; }
  50%  { opacity: 0.8; scale: 2.5; }
  100% { opacity: 0; scale: 4; }
}

/* Chromatic ripple ring shockwave */
.theme-ripple-ring {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  left: var(--ripple-x);
  top: var(--ripple-y);
  width: 0;
  height: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2.5px solid #6366f1;
  box-shadow: 0 0 20px 4px rgba(99, 102, 241, 0.2);
  animation:
    ripple-expand 900ms cubic-bezier(0.22, 1, 0.36, 1) forwards,
    ripple-chromatic 900ms ease forwards;
}

.theme-ripple-ring--dark {
  border-color: #a5b4fc;
  box-shadow: 0 0 20px 4px rgba(165, 180, 252, 0.25);
}

@keyframes ripple-expand {
  0%   { width: 0; height: 0; opacity: 1; border-width: 3px; }
  60%  { opacity: 0.5; }
  100% { width: 300vmax; height: 300vmax; opacity: 0; border-width: 0.5px; }
}

@keyframes ripple-chromatic {
  0%   { border-color: #6366f1; box-shadow: 0 0 24px 4px rgba(99, 102, 241, 0.3); }
  30%  { border-color: #8b5cf6; box-shadow: 0 0 24px 4px rgba(139, 92, 246, 0.25); }
  60%  { border-color: #06b6d4; box-shadow: 0 0 24px 4px rgba(6, 182, 212, 0.2); }
  100% { border-color: #6366f1; box-shadow: 0 0 20px 4px rgba(99, 102, 241, 0.08); }
}

/* Sparkle particles */
.theme-sparkle {
  position: fixed;
  z-index: 10001;
  pointer-events: none;
  border-radius: 50%;
  background: #818cf8;
  box-shadow: 0 0 6px 2px rgba(129, 140, 248, 0.6);
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: sparkle-fly var(--sparkle-dur) ease-out forwards;
  animation-delay: var(--sparkle-delay);
}

.theme-sparkle--dark {
  background: #c7d2fe;
  box-shadow: 0 0 6px 2px rgba(199, 210, 254, 0.6);
}

@keyframes sparkle-fly {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  60%  { opacity: 0.8; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--sparkle-dx)), calc(-50% + var(--sparkle-dy))) scale(0); }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .theme-ripple-ring,
  .theme-burst,
  .theme-sparkle { display: none !important; }
  .theme-icon-wrap.icon-spin-out,
  .theme-icon-wrap.icon-spin-in { animation: none !important; filter: none !important; }
  .theme-icon-wrap.icon-spin-in::after { display: none !important; }
  .legal-header.theme-header-glow { animation: none !important; }
}

/* ══════════════════════════════════════
   CONTENT CONTAINER
   ══════════════════════════════════════ */
.legal-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

/* ── Typography (light: #1a1a2e tones, dark: #e2e8f0 tones — matches .home-page) ── */
.legal-container h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 8px;
}
[data-theme="dark"] .legal-container h1 { color: #f1f5f9; }

.legal-container .updated {
  color: rgba(0, 0, 0, 0.4);
  font-size: 0.9rem;
  margin-bottom: 32px;
}
[data-theme="dark"] .legal-container .updated { color: rgba(255, 255, 255, 0.4); }

.legal-container h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-top: 32px;
  margin-bottom: 12px;
}
[data-theme="dark"] .legal-container h2 { color: #e2e8f0; }

.legal-container p,
.legal-container li {
  color: rgba(0, 0, 0, 0.6);
  margin-bottom: 12px;
}
[data-theme="dark"] .legal-container p,
[data-theme="dark"] .legal-container li { color: rgba(255, 255, 255, 0.6); }

.legal-container ul { padding-left: 24px; }
.legal-container li { margin-bottom: 8px; }

.legal-container strong { color: #1a1a2e; }
[data-theme="dark"] .legal-container strong { color: #f1f5f9; }

.legal-container a {
  color: #6366f1;
  text-decoration: none;
  transition: color var(--transition-fast);
}
[data-theme="dark"] .legal-container a { color: #818cf8; }
.legal-container a:hover { text-decoration: underline; }

.legal-container code {
  background: rgba(0, 0, 0, 0.05);
  color: #7c3aed;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
[data-theme="dark"] .legal-container code {
  background: rgba(255, 255, 255, 0.08);
  color: #a78bfa;
}

/* ── Table (tokushoho) ── */
.legal-container table { width: 100%; border-collapse: collapse; margin-top: 24px; }
.legal-container th,
.legal-container td { padding: 14px 16px; text-align: left; border-bottom: 1px solid rgba(0, 0, 0, 0.08); }
[data-theme="dark"] .legal-container th,
[data-theme="dark"] .legal-container td { border-bottom-color: rgba(255, 255, 255, 0.06); }
.legal-container th {
  color: rgba(0, 0, 0, 0.5);
  font-weight: 600;
  width: 200px;
  white-space: nowrap;
  vertical-align: top;
  background: rgba(0, 0, 0, 0.03);
}
[data-theme="dark"] .legal-container th { color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.04); }
.legal-container td { color: rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .legal-container td { color: rgba(255, 255, 255, 0.6); }

/* ══════════════════════════════════════
   FOOTER  (identical to .home-footer)
   ══════════════════════════════════════ */
.legal-footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 0.8rem;
  color: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

[data-theme="dark"] .legal-footer {
  color: rgba(255, 255, 255, 0.35);
}

.legal-footer-links {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.72rem;
  flex-wrap: wrap;
  justify-content: center;
}

.legal-footer-links a {
  color: rgba(0, 0, 0, 0.35);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.legal-footer-links a:hover {
  color: rgba(0, 0, 0, 0.6);
  text-decoration: underline;
}

[data-theme="dark"] .legal-footer-links a {
  color: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .legal-footer-links a:hover {
  color: rgba(255, 255, 255, 0.5);
}

.legal-footer-sep {
  color: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .legal-footer-sep {
  color: rgba(255, 255, 255, 0.15);
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 768px) {
  .legal-header { padding: 12px 16px; }

  /* Hide button text labels, keep icons */
  .legal-btn span:not(.theme-icon-wrap) { display: none; }
  .legal-btn { padding: 8px 10px; }

  .legal-container { padding: 24px 16px 48px; }
  .legal-container h1 { font-size: 1.5rem; }
  .legal-container th { width: 120px; font-size: 0.85rem; }
  .legal-container td { font-size: 0.92rem; }
}
