/* ==========================================================================
   Metaphysics OS · Wave0
   1) Compliance Strip  : 18+ / Pro Max / 練習推演（非命中率・非定數）常駐微列
   2) meta-workspace    : 曜石（obsidian）／珍珠（pearl）只換內容區內膽
   3) 本站殼層雜項      : 隱藏 legacy 浮動語言球（頂欄已有 EN）

   Rules baked in
   - 0 new site hex: every colour below already exists in this site
     (index.html :root / body.theme-light) or in fleet-nocturnal-beacon-tokens.
   - Top bar + footer stay Fleet-dark in both themes: they live outside
     .meta-workspace and only read --fleet-* tokens.
   - Pearl never paints body / html; only .meta-workspace.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1 · COMPLIANCE STRIP
   Sits inside <main class="meta-workspace"> as its first child so it clears
   the fixed Fleet topbar. Sticky under the bar; never dismissible.
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   1 · COMPLIANCE STRIP
   Fixed directly under the Fleet topbar: always present, never dismissible.
   It is a shell surface, so it keeps Fleet-dark colours in both themes.
   -------------------------------------------------------------------------- */

body[data-realm="metaphysics"] {
  --meta-strip-h: 42px;
}

/* Main already clears the fixed Fleet bar via #bliss-chrome-spacer. */
body[data-realm="metaphysics"] .main-container.meta-workspace {
  padding-top: 0 !important;
}

.meta-compliance {
  position: fixed;
  top: 68px;
  left: 50%;
  z-index: 8500;
  width: min(calc(100% - 48px), 1352px);
  margin: 0;
  transform: translateX(-50%);
  border: 1px solid var(--fleet-line-soft);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-topbar-bg-solid);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  backdrop-filter: blur(12px) saturate(120%);
  color: var(--fleet-body);
  font-family: var(--fleet-ui);
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
}

.meta-compliance__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--meta-strip-h);
  padding: 5px 10px;
  flex-wrap: wrap;
}

.meta-compliance__tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-height: 20px;
  padding: 0 7px;
  border-radius: var(--fleet-r-chip);
  border: 1px solid rgba(var(--fleet-amber-rgb), 0.42);
  background: rgba(var(--fleet-amber-rgb), 0.08);
  color: var(--fleet-amber-soft);
  font-family: var(--fleet-ui-en);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.meta-compliance__tag--plan {
  border-color: rgba(var(--fleet-violet-rgb), 0.42);
  background: rgba(var(--fleet-violet-rgb), 0.08);
  color: var(--fleet-violet-hi);
}

.meta-compliance__line {
  margin: 0;
  min-width: 0;
  color: var(--fleet-muted-strong);
  font-size: 11px;
  letter-spacing: 0.01em;
}

.meta-compliance__line b {
  color: var(--fleet-text);
  font-weight: 600;
}

.meta-compliance__more {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-chip);
  background: transparent;
  color: var(--fleet-body);
  font-family: var(--fleet-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.meta-compliance__more:hover,
.meta-compliance__more:focus-visible {
  border-color: rgba(var(--fleet-hall-glow-rgb), 0.4);
  color: var(--fleet-text);
}

.meta-compliance__theme {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 2px;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-chip);
  background: rgba(248, 250, 252, 0.02);
}

.meta-compliance__theme-label {
  padding: 0 4px;
  color: var(--fleet-muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.meta-compliance__theme-btn {
  min-width: 38px;
  min-height: 22px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--fleet-muted-strong);
  font-family: var(--fleet-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.meta-compliance__theme-btn.is-active {
  border-color: rgba(var(--fleet-hall-glow-rgb), 0.28);
  background: rgba(var(--fleet-hall-glow-rgb), 0.10);
  color: var(--fleet-amber-soft);
}

.meta-compliance__detail {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--fleet-line-soft);
  background: rgba(8, 12, 19, 0.72);
  border-radius: 0 0 var(--fleet-r-control) var(--fleet-r-control);
}

.meta-compliance__detail[hidden] {
  display: none !important;
}

.meta-compliance__detail p {
  margin: 0 0 6px;
  color: var(--fleet-muted-strong);
  font-size: 11px;
  line-height: 1.7;
}

.meta-compliance__detail p:last-child {
  margin-bottom: 0;
}

.meta-compliance__detail b {
  color: var(--fleet-text);
  font-weight: 700;
}

.meta-compliance__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding-top: 6px;
}

.meta-compliance__links a {
  color: var(--fleet-amber-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   2 · META WORKSPACE (inner liner)
   -------------------------------------------------------------------------- */

.meta-workspace {
  position: relative;
  isolation: isolate;
}

.meta-workspace[data-meta-theme="obsidian"] {
  /* Theme 1 · 深邃曜石 — the existing site look, unchanged. */
  --mw-paper: transparent;
}

/* Theme 2 · 溫潤珍珠 (warm pearl, never pure white).
   Palette values are copied from this site's own body.theme-light block. */
.meta-workspace[data-meta-theme="pearl"] {
  --bg: #F6EFF1;
  --bg2: #FDFBFC;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-line: rgba(109, 40, 217, 0.22);
  --gold: #8F6E14;
  --rosegold: #6d28d9;
  --cyan: #6d28d9;
  --violet: #F4EAEB;
  --text: #2F1E21;
  --muted: #6E5356;
  --muted2: rgba(110, 83, 86, 0.45);
  --ok: #91a884;
  --danger: #c6535a;
  --wood: #91a884;
  --fire: #75413e;
  --earth: #d49b55;
  --metal: #4a292c;
  --water: #9b858c;
  --realm-accent: #6d28d9;
  --realm-gold: #8F6E14;
  --realm-void: #F6EFF1;

  border-radius: 20px 20px 0 0;
  background:
    radial-gradient(120% 70% at 50% -18%, #FDFBFC 0%, rgba(253, 251, 252, 0) 62%),
    linear-gradient(180deg, #FDFBFC 0%, #F6EFF1 52%, #F4EAEB 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 -1px 0 rgba(47, 30, 33, 0.06),
    0 18px 44px rgba(0, 0, 0, 0.35);
  color: var(--text);
}

/* --- pearl: structural surfaces --- */

.meta-workspace[data-meta-theme="pearl"] .glass-panel {
  border-color: rgba(109, 40, 217, 0.18) !important;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.92) 0%, rgba(246, 239, 241, 0.95) 100%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    0 12px 30px rgba(47, 30, 33, 0.10) !important;
}

.meta-workspace[data-meta-theme="pearl"] .glass-card,
.meta-workspace[data-meta-theme="pearl"] .desk-window {
  border-color: rgba(47, 30, 33, 0.10) !important;
  background: rgba(255, 255, 255, 0.62) !important;
  box-shadow: 0 10px 26px rgba(47, 30, 33, 0.08) !important;
}

.meta-workspace[data-meta-theme="pearl"] .glass-card:hover {
  box-shadow: 0 12px 28px rgba(47, 30, 33, 0.14) !important;
}

.meta-workspace[data-meta-theme="pearl"] .sec-title {
  border-bottom-color: rgba(47, 30, 33, 0.10);
  color: var(--muted);
}

.meta-workspace[data-meta-theme="pearl"] .mw-command {
  border-color: rgba(109, 40, 217, 0.22);
  background:
    radial-gradient(ellipse 80% 90% at 10% -20%, rgba(167, 139, 250, 0.15), transparent 55%),
    linear-gradient(160deg, #FDFBFC, #F6EFF1);
  box-shadow: 0 14px 34px rgba(47, 30, 33, 0.10);
}

/* The title is a clipped gradient in obsidian; on pearl it needs flat ink. */
.meta-workspace[data-meta-theme="pearl"] .mw-title {
  background: none !important;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: #2F1E21;
  color: #2F1E21;
}

.meta-workspace[data-meta-theme="pearl"] .mw-eyebrow {
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-lede {
  color: rgba(47, 30, 33, 0.72);
}

.meta-workspace[data-meta-theme="pearl"] .mw-live-chip {
  border-color: rgba(143, 110, 20, 0.38);
  background: rgba(143, 110, 20, 0.08);
  color: #8F6E14;
}

.meta-workspace[data-meta-theme="pearl"] .mw-launch i {
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-launch b {
  color: #2F1E21;
}

.meta-workspace[data-meta-theme="pearl"] .mw-launch small {
  color: rgba(47, 30, 33, 0.55);
}

.meta-workspace[data-meta-theme="pearl"] .mw-ctx-pill {
  border-color: rgba(47, 30, 33, 0.14);
  background: rgba(255, 255, 255, 0.62);
  color: rgba(47, 30, 33, 0.72);
}

.meta-workspace[data-meta-theme="pearl"] .mw-ctx-pill.gold {
  border-color: rgba(143, 110, 20, 0.35);
  background: rgba(143, 110, 20, 0.08);
  color: #8F6E14;
}

.meta-workspace[data-meta-theme="pearl"] .mw-ctx-pill.violet {
  border-color: rgba(109, 40, 217, 0.28);
  background: rgba(109, 40, 217, 0.07);
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-ctx-btn {
  border-color: rgba(109, 40, 217, 0.3);
  background: rgba(109, 40, 217, 0.08);
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-prog {
  color: rgba(47, 30, 33, 0.6);
}

/* Surface rail / empty state / next chips drew their own dark gradients. */
.meta-workspace[data-meta-theme="pearl"] .mw-surface-rail {
  border-color: rgba(109, 40, 217, 0.2);
  background: linear-gradient(100deg, rgba(109, 40, 217, 0.06), rgba(255, 255, 255, 0.5));
}

.meta-workspace[data-meta-theme="pearl"] .mw-surface-rail .mw-rail-copy strong {
  color: #2F1E21;
}

.meta-workspace[data-meta-theme="pearl"] .mw-surface-rail .mw-rail-copy span {
  color: rgba(47, 30, 33, 0.6);
}

.meta-workspace[data-meta-theme="pearl"] .mw-rail-chip {
  border-color: rgba(109, 40, 217, 0.26);
  background: rgba(255, 255, 255, 0.6);
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-empty {
  border-color: rgba(109, 40, 217, 0.3);
  background: rgba(109, 40, 217, 0.05);
}

.meta-workspace[data-meta-theme="pearl"] .mw-empty h5 {
  color: #2F1E21;
}

.meta-workspace[data-meta-theme="pearl"] .mw-empty p {
  color: rgba(47, 30, 33, 0.62);
}

.meta-workspace[data-meta-theme="pearl"] .mw-next-strip {
  border-top-color: rgba(47, 30, 33, 0.10);
}

.meta-workspace[data-meta-theme="pearl"] .mw-next-chip {
  border-color: rgba(109, 40, 217, 0.28);
  background: rgba(109, 40, 217, 0.07);
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-explore i {
  color: rgba(47, 30, 33, 0.22);
}

.meta-workspace[data-meta-theme="pearl"] .mw-explore i.on {
  color: #6d28d9;
}

.meta-workspace[data-meta-theme="pearl"] .mw-command::before {
  opacity: 0.45;
}

.meta-workspace[data-meta-theme="pearl"] .mw-step {
  border-color: rgba(47, 30, 33, 0.10);
  background: rgba(255, 255, 255, 0.55);
}

.meta-workspace[data-meta-theme="pearl"] .mw-step-body strong {
  color: #2F1E21;
}

.meta-workspace[data-meta-theme="pearl"] .mw-step-body span {
  color: rgba(47, 30, 33, 0.55);
}

.meta-workspace[data-meta-theme="pearl"] .mw-launch {
  border-color: rgba(47, 30, 33, 0.10);
  background: rgba(255, 255, 255, 0.55);
}

.meta-workspace[data-meta-theme="pearl"] .mw-tab-shell {
  background: rgba(253, 251, 252, 0.9);
  border-color: rgba(47, 30, 33, 0.10);
}

.meta-workspace[data-meta-theme="pearl"] .mw-context {
  background: rgba(253, 251, 252, 0.92);
  border-color: rgba(47, 30, 33, 0.10);
  color: var(--text);
}

.meta-workspace[data-meta-theme="pearl"] .mw-ctx-pill {
  color: var(--muted);
}

.meta-workspace[data-meta-theme="pearl"] .mw-crumb,
.meta-workspace[data-meta-theme="pearl"] .mw-crumb strong {
  color: var(--muted);
}

.meta-workspace[data-meta-theme="pearl"] .mw-crumb strong {
  color: var(--rosegold);
}

.meta-workspace[data-meta-theme="pearl"] .mw-tab-group-label {
  color: rgba(47, 30, 33, 0.5);
}

.meta-workspace[data-meta-theme="pearl"] .tab-btn {
  color: var(--muted);
}

.meta-workspace[data-meta-theme="pearl"] .tab-btn.active {
  color: #FDFBFC;
}

.meta-workspace[data-meta-theme="pearl"] .depth-btn {
  color: var(--muted);
}

.meta-workspace[data-meta-theme="pearl"] .btn-ghost {
  border-color: rgba(47, 30, 33, 0.16);
  color: var(--muted);
}

.meta-workspace[data-meta-theme="pearl"] .hud-alert.info {
  background: rgba(109, 40, 217, 0.05);
  border-color: rgba(109, 40, 217, 0.18);
  color: var(--rosegold);
}

.meta-workspace[data-meta-theme="pearl"] .magic-input,
.meta-workspace[data-meta-theme="pearl"] .magic-select {
  color: var(--text);
}

/* --- pearl: Tailwind utilities used by the site's markup ---
   The site writes most secondary copy as text-white/40-60 on near-black.
   On pearl paper those become ink at matching emphasis. */

/* Deliberately NOT themed: engine-rendered instrument cards keep their own
   dark ground (`.mcf-sui` in js/compute/mcf-structural-ui.js, `.mcf-oj` in
   js/mcf-observatory-journey.js, SVG/canvas charts). They are instruments,
   not paper; their inline white/amber type is calibrated for a dark plate. */

.meta-workspace[data-meta-theme="pearl"] [class*="text-white"] {
  color: rgba(47, 30, 33, 0.86) !important;
}

.meta-workspace[data-meta-theme="pearl"] [class*="text-white/9"] {
  color: rgba(47, 30, 33, 0.92) !important;
}

.meta-workspace[data-meta-theme="pearl"] [class*="text-white/7"],
.meta-workspace[data-meta-theme="pearl"] [class*="text-white/6"],
.meta-workspace[data-meta-theme="pearl"] [class*="text-white/5"] {
  color: rgba(47, 30, 33, 0.68) !important;
}

.meta-workspace[data-meta-theme="pearl"] [class*="text-white/4"],
.meta-workspace[data-meta-theme="pearl"] [class*="text-white/3"],
.meta-workspace[data-meta-theme="pearl"] [class*="text-white/2"] {
  color: rgba(47, 30, 33, 0.52) !important;
}

.meta-workspace[data-meta-theme="pearl"] [class*="border-white"] {
  border-color: rgba(47, 30, 33, 0.12) !important;
}

.meta-workspace[data-meta-theme="pearl"] [class*="bg-white/"] {
  background-color: rgba(255, 255, 255, 0.58) !important;
}

.meta-workspace[data-meta-theme="pearl"] [class*="bg-black/"] {
  background-color: rgba(47, 30, 33, 0.045) !important;
}

/* Keep SVG / canvas instruments on their own painted ground: they draw their
   own fills and would lose contrast if the paper bleeds through. */
.meta-workspace[data-meta-theme="pearl"] svg [class*="text-white"],
.meta-workspace[data-meta-theme="pearl"] canvas + * {
  color: inherit;
}

/* --------------------------------------------------------------------------
   3 · SITE-SCOPED SHELL HYGIENE
   -------------------------------------------------------------------------- */

/* The hero layout had two language switches: the Fleet topbar EN slot and
   this floating legacy pill (fixed at top:16px, half-hidden behind the bar).
   Keep one control (topbar). */
#meta-lang-float {
  display: none !important;
}

/* Wave0: the 640×211 "今日由呢度開始" card was the oversize 18+ banner.
   Its compliance copy now lives in the persistent strip (above), so the card
   is retired on this site only. Nothing is deleted; #bliss-plain-start stays
   in the shared layer for the other 13 sites. */
body[data-realm="metaphysics"] #bliss-plain-start,
body[data-realm="metaphysics"] #bliss-plain-reopen {
  display: none !important;
}

/* The strip takes 34px, so the two sticky rails under it move down. */
body[data-realm="metaphysics"] #mw-context {
  top: calc(68px + var(--meta-strip-h) + 4px) !important;
}

body[data-realm="metaphysics"] .mw-tab-shell {
  top: calc(68px + var(--meta-strip-h) + 4px + 56px) !important;
}

@media (max-width: 720px) {
  body[data-realm="metaphysics"] {
    --meta-strip-h: 70px;
  }

  .meta-compliance {
    top: 58px;
    width: calc(100% - 24px);
    border-radius: var(--fleet-r-chip);
  }

  .meta-compliance__inner {
    gap: 6px;
    padding: 5px 8px;
  }

  .meta-compliance__line {
    order: 3;
    flex: 1 1 100%;
    font-size: 10.5px;
  }

  .meta-compliance__theme {
    margin-left: auto;
  }

  .meta-compliance__theme-label {
    display: none;
  }

  body[data-realm="metaphysics"] #mw-context {
    top: calc(58px + var(--meta-strip-h) + 4px) !important;
  }

  body[data-realm="metaphysics"] .mw-tab-shell {
    top: calc(58px + var(--meta-strip-h) + 4px) !important;
  }
}

@media (max-width: 430px) {
  .meta-compliance__theme-btn {
    min-width: 34px;
    padding: 0 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .meta-compliance,
  .meta-compliance * {
    transition: none !important;
  }
}

@media print {
  .meta-compliance {
    position: static;
    border: 0;
    background: transparent;
    color: #000;
  }

  .meta-compliance__theme,
  .meta-compliance__more {
    display: none !important;
  }
}
