/* =========================================================
   Layrax — Legal pages (privacy / terms / cookie)
   + Cookie consent banner + footer legal links
   Depends on variables from css/style.css (:root)
   ========================================================= */

/* ---------- Legal page header ---------- */
.legal-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-card-border);
}
.legal-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-dark);
  text-decoration: none;
}
.legal-brand svg { width: 28px; height: 28px; }
.legal-nav { display: flex; align-items: center; gap: 16px; }
.legal-lang {
  background: none;
  border: 1px solid var(--color-card-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--color-text-dark);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition), color var(--transition);
}
.legal-lang:hover { border-color: var(--color-brand); color: var(--color-brand); }
.legal-back {
  font-size: 0.9rem;
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 500;
}
.legal-back:hover { text-decoration: underline; }

/* ---------- Legal page body ---------- */
.legal-main { padding: 56px 0 80px; background: var(--color-white); }
.legal-container { max-width: 820px; margin: 0 auto; }

/* Anti-flash: show zh by default, flip when the inline head script set data-pref-lang="en".
   js/legal.js takes over and sets display explicitly after load. */
.legal-body { display: none; }
.legal-body[data-lang='zh'] { display: block; }
html[data-pref-lang='en'] .legal-body[data-lang='zh'] { display: none; }
html[data-pref-lang='en'] .legal-body[data-lang='en'] { display: block; }

.legal-body h1 {
  font-size: 2rem;
  line-height: 1.25;
  color: var(--color-dark);
  margin: 0 0 8px;
}
.legal-updated {
  font-size: 0.85rem;
  color: var(--color-text-muted-dark);
  margin: 0 0 32px;
}
.legal-body h2 {
  font-size: 1.2rem;
  color: var(--color-dark);
  margin: 36px 0 12px;
}
.legal-body h3 {
  font-size: 1.02rem;
  color: var(--color-dark);
  margin: 22px 0 10px;
}
.legal-body p {
  font-size: 0.95rem;
  line-height: 1.75;
  color: #44445a;
  margin: 0 0 14px;
}
.legal-body ul,
.legal-body ol {
  margin: 0 0 16px;
  padding-left: 1.4em;
}
.legal-body li {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #44445a;
  margin: 0 0 8px;
}
.legal-body a { color: var(--color-brand); text-decoration: none; }
.legal-body a:hover { text-decoration: underline; }
.legal-body strong { color: var(--color-dark); font-weight: 600; }

/* Placeholder highlight for entity / filing info the owner must fill in */
.legal-placeholder {
  color: #b5471b;
  background: rgba(181, 71, 27, 0.08);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 500;
}

/* ---------- Legal page footer ---------- */
.legal-footer {
  background: var(--color-dark);
  color: rgba(160, 160, 176, 0.7);
  padding: 24px 0;
  font-size: 0.85rem;
}
.legal-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Footer legal links (shared by index footer & legal footer) ---------- */
.footer__legal { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer__legal a {
  color: rgba(160, 160, 176, 0.8);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color var(--transition);
}
.footer__legal a:hover { color: #fff; }

/* ---------- Cookie consent preferences panel ---------- */
.cc-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(15, 15, 26, 0.16);
  padding: 22px 24px;
}
.cc-panel[hidden] { display: none; }
.cc-panel__text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text-dark);
  margin: 0 0 16px;
}
.cc-panel__text a { color: var(--color-brand); text-decoration: none; }
.cc-panel__text a:hover { text-decoration: underline; }
.cc-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cc-btn {
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 20px;
  white-space: nowrap;
  transition: transform var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}
.cc-btn--primary {
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-button);
}
.cc-btn--primary:hover { transform: translateY(-1px); }
.cc-btn--ghost {
  background: #fff;
  color: var(--color-text-dark);
  border: 1px solid var(--color-card-border);
}
.cc-btn--ghost:hover { border-color: var(--color-brand); color: var(--color-brand); }
.cc-btn--link {
  background: none;
  border: none;
  color: var(--color-text-muted-dark);
  padding: 10px 8px;
  font-weight: 500;
}
.cc-btn--link:hover { color: var(--color-brand); }

/* preferences detail (collapsible) */
.cc-prefs {
  margin-top: 16px;
  border-top: 1px solid var(--color-card-border);
  padding-top: 12px;
  display: none;
}
.cc-prefs[data-open='true'] { display: block; }
.cc-cat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
}
.cc-cat + .cc-cat { border-top: 1px dashed var(--color-card-border); }
.cc-cat__info { flex: 1; }
.cc-cat__name { font-weight: 600; font-size: 0.92rem; color: var(--color-dark); margin: 0 0 2px; }
.cc-cat__desc { font-size: 0.82rem; line-height: 1.55; color: var(--color-text-muted-dark); margin: 0; }

/* toggle switch */
.cc-toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.cc-toggle input { opacity: 0; width: 0; height: 0; }
.cc-toggle__slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #c7c7d4;
  border-radius: 999px;
  transition: background var(--transition);
}
.cc-toggle__slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.cc-toggle input:checked + .cc-toggle__slider { background: var(--color-brand); }
.cc-toggle input:checked + .cc-toggle__slider::before { transform: translateX(18px); }
.cc-toggle input:disabled + .cc-toggle__slider { opacity: 0.75; cursor: not-allowed; }
.cc-toggle input:checked:disabled + .cc-toggle__slider { background: #8e87f5; }

/* "Cookie Settings" reopen button in footer */
.cc-settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  color: rgba(160, 160, 176, 0.8);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color var(--transition);
}
.cc-settings-btn:hover { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .legal-main { padding: 36px 0 64px; }
  .legal-body h1 { font-size: 1.6rem; }
  .cc-panel { left: 12px; right: 12px; bottom: 12px; padding: 18px; }
  .cc-actions { flex-direction: column; align-items: stretch; }
  .cc-actions .cc-btn { width: 100%; text-align: center; }
  .cc-cat { align-items: center; }
  .legal-footer__inner { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .footer__legal { gap: 10px; font-size: 0.8rem; }
}
