/* ==========================================================================
   OBSIDIAN ATELIER v2.0 — radar.shihao.uk/research/ (ShihaoSights Research Hub)
   Carbon Obsidian (#050507) + Champagne Titanium (#DEC392) + Ice Specular
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root,
html[data-theme="dark"] {
  --bg: #050507 !important;
  --paper: rgba(13, 14, 19, 0.78) !important;
  --surface: rgba(13, 14, 19, 0.78) !important;
  --surface-sunken: rgba(20, 22, 29, 0.90) !important;
  --ink: #f5f5f7 !important;
  --muted: #989ba6 !important;
  --line: rgba(255, 255, 255, 0.085) !important;
  --line-strong: rgba(255, 255, 255, 0.16) !important;
  --accent: #dec392 !important;
  --accent-soft: rgba(222, 195, 146, 0.12) !important;
  --accent-line: rgba(222, 195, 146, 0.34) !important;
  --navy: #f5f5f7 !important;
  --amber: #f3dfb8 !important;
  --amber-soft: rgba(222, 195, 146, 0.14) !important;
  --amber-ink: #f3dfb8 !important;
  --notice-bg: rgba(222, 195, 146, 0.09) !important;
  --notice-line: rgba(222, 195, 146, 0.26) !important;
  --notice-ink: #f3dfb8 !important;
  --ok: #34d399 !important;
  --ok-soft: rgba(52, 211, 153, 0.14) !important;
  --danger: #fb7185 !important;
  --chip-bg: rgba(255, 255, 255, 0.07) !important;
  --focus: #dec392 !important;
  --radius: 16px !important;
  --font-sans: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", -apple-system, sans-serif !important;
  --a-display: "Space Grotesk", "Noto Sans SC", "PingFang SC", -apple-system, sans-serif;
  --a-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --a-rim: rgba(255, 255, 255, 0.10);
  --a-border-hover: rgba(222, 195, 146, 0.44);
  --a-nav-bg: rgba(5, 5, 7, 0.82);
  --a-surface-strong: rgba(18, 20, 26, 0.95);
  --a-grad: linear-gradient(125deg, #f3e3c3 0%, #dec392 50%, #c49b5c 100%);
  --a-text-grad: linear-gradient(180deg, #ffffff 18%, rgba(235, 236, 242, 0.72) 100%);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #faf9f6 !important;
  --paper: rgba(255, 255, 255, 0.88) !important;
  --surface: rgba(255, 255, 255, 0.88) !important;
  --surface-sunken: #f2efe9 !important;
  --ink: #111216 !important;
  --muted: #52555f !important;
  --line: rgba(17, 18, 22, 0.09) !important;
  --line-strong: rgba(17, 18, 22, 0.17) !important;
  --accent: #8f6b32 !important;
  --accent-soft: rgba(143, 107, 50, 0.10) !important;
  --accent-line: rgba(143, 107, 50, 0.32) !important;
  --navy: #111216 !important;
  --amber: #8f6b32 !important;
  --amber-soft: rgba(180, 83, 9, 0.10) !important;
  --amber-ink: #78350f !important;
  --notice-bg: rgba(180, 83, 9, 0.07) !important;
  --notice-line: rgba(180, 83, 9, 0.22) !important;
  --notice-ink: #78350f !important;
  --ok: #059669 !important;
  --ok-soft: rgba(5, 150, 105, 0.12) !important;
  --danger: #dc2626 !important;
  --chip-bg: rgba(17, 18, 22, 0.06) !important;
  --focus: #8f6b32 !important;
  --radius: 16px !important;
  --font-sans: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", -apple-system, sans-serif !important;
  --a-display: "Space Grotesk", "Noto Sans SC", "PingFang SC", -apple-system, sans-serif;
  --a-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --a-rim: rgba(255, 255, 255, 0.95);
  --a-border-hover: rgba(143, 107, 50, 0.44);
  --a-nav-bg: rgba(250, 249, 246, 0.84);
  --a-surface-strong: rgba(255, 255, 255, 0.96);
  --a-grad: linear-gradient(125deg, #8f6b32 0%, #b08542 52%, #6d4f22 100%);
  --a-text-grad: linear-gradient(180deg, #0b0c10 10%, #3b3e47 100%);
  color-scheme: light;
}

body {
  background: var(--bg) !important;
  color: var(--ink) !important;
  overflow-x: hidden;
  transition: background-color 0.35s ease, color 0.35s ease;
}

body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: -2;
  background:
    radial-gradient(720px circle at 16% 6%, rgba(222, 195, 146, 0.09), transparent 62%),
    radial-gradient(640px circle at 88% 18%, rgba(125, 211, 252, 0.06), transparent 60%);
}

body::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 900; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* Global Header */
.global {
  background: var(--a-nav-bg) !important;
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-bottom: 1px solid var(--line) !important;
}

.brand {
  font-family: var(--a-display) !important;
  letter-spacing: -0.03em !important;
}

.brand span {
  background: var(--a-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
}

.global nav a {
  padding: 6px 12px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.global nav a:hover {
  background: var(--accent-soft);
  color: var(--ink) !important;
  text-decoration: none;
}

.global nav a.selected {
  background: var(--accent-soft);
  border: 1px solid rgba(222, 195, 146, 0.30);
  color: var(--accent) !important;
}

.edition {
  font-family: var(--a-mono);
  font-size: 11px !important;
  letter-spacing: 0.14em !important;
}

.atelier-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
}

.atelier-mini-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border-radius: 999px !important;
  border: 1px solid var(--line-strong) !important;
  background: var(--surface) !important;
  color: var(--muted) !important;
  font-family: var(--a-mono);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.atelier-mini-btn:hover { border-color: var(--a-border-hover) !important; color: var(--accent) !important; }
.atelier-mini-btn svg { width: 15px; height: 15px; }
.atelier-mini-btn .icon-sun { display: none; }
html[data-theme="light"] .atelier-mini-btn .icon-sun { display: block; }
html[data-theme="light"] .atelier-mini-btn .icon-moon { display: none; }

/* Left Rail */
.rail {
  background: rgba(8, 9, 13, 0.55);
  border-right: 1px solid var(--line) !important;
}

html[data-theme="light"] .rail { background: rgba(242, 239, 233, 0.55); }

.research-title { font-family: var(--a-display) !important; letter-spacing: -0.025em; }
.rail nav a { border-radius: 10px !important; transition: all 0.2s ease; }
.rail nav a:hover { background: var(--accent-soft); color: var(--ink) !important; text-decoration: none; }
.rail nav a.active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(222, 195, 146, 0.26);
}

/* Hero & Display */
.hero h1 {
  font-family: var(--a-display) !important;
  font-size: clamp(28px, 3.6vw, 40px) !important;
  letter-spacing: -0.035em !important;
  background: var(--a-text-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow { font-family: var(--a-mono); letter-spacing: 0.14em !important; }

/* Anodized Glass Cards */
.card, .panel, .stat, .report-body, .vault-card {
  --mx: 50%;
  --my: 50%;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  background: var(--surface) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line) !important;
  border-radius: 16px !important;
  box-shadow: 0 22px 54px -26px rgba(0, 0, 0, 0.65), inset 0 1px 0 var(--a-rim);
  isolation: isolate;
  transition: border-color 0.28s ease, box-shadow 0.32s ease, transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}

.prism-card::before {
  content: "";
  position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: radial-gradient(280px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.72), rgba(222, 195, 146, 0.56) 36%, rgba(125, 211, 252, 0.24) 65%, transparent 84%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 4;
}

.prism-card::after {
  content: "";
  position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(360px circle at var(--mx) var(--my), rgba(222, 195, 146, 0.08), transparent 68%);
  opacity: 0;
  transition: opacity 0.32s ease;
  pointer-events: none;
  z-index: 1;
}

.prism-card:hover { border-color: var(--a-border-hover) !important; }
.prism-card:hover::before, .prism-card:hover::after { opacity: 1; }
.prism-card.prism-tilt-active { transform: perspective(1050px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(-3px); }
.prism-card > * { position: relative; z-index: 2; }

.stat strong {
  font-family: var(--a-display);
  background: var(--a-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
}

button.primary {
  background: var(--a-grad) !important;
  color: #0b0c10 !important;
  border-color: transparent !important;
  font-weight: 600;
}

html[data-theme="light"] button.primary { color: #fff !important; }

.tabs a.active {
  background: var(--a-grad) !important;
  color: #0b0c10 !important;
  font-weight: 600;
}
html[data-theme="light"] .tabs a.active { color: #fff !important; }

th { font-family: var(--a-mono); color: var(--accent) !important; }
tbody tr:hover { background: var(--accent-soft); }
#toast { background: var(--a-surface-strong) !important; color: var(--ink) !important; border: 1px solid var(--a-border-hover); }

/* Precision Cursor Ring & Ambient Spotlight + ⌘K Command Palette */
#prism-cursor-glow {
  position: fixed; top: 0; left: 0; width: 580px; height: 580px; border-radius: 50%;
  pointer-events: none; z-index: 1; opacity: 0; transform: translate3d(-999px, -999px, 0);
  background: radial-gradient(circle, rgba(222, 195, 146, 0.08) 0%, rgba(125, 211, 252, 0.03) 40%, transparent 68%);
  transition: opacity 0.45s ease;
}
#prism-cursor-glow.is-active { opacity: 1; }

#atelier-cursor-ring {
  position: fixed; top: 0; left: 0; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(222, 195, 146, 0.42); pointer-events: none; z-index: 950; opacity: 0;
  transform: translate3d(-99px, -99px, 0);
  transition: width 0.26s cubic-bezier(0.16, 1, 0.3, 1), height 0.26s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.22s ease, background-color 0.22s ease, opacity 0.3s ease;
}
#atelier-cursor-ring.is-visible { opacity: 1; }
#atelier-cursor-ring.is-hover { width: 48px; height: 48px; border-color: rgba(222, 195, 146, 0.72); background: rgba(222, 195, 146, 0.06); }
#atelier-cursor-ring.is-down { width: 22px; height: 22px; border-color: #7dd3fc; }

#atelier-cmdk {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(3, 4, 6, 0.74); backdrop-filter: blur(14px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: min(14vh, 110px) 16px 24px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
#atelier-cmdk.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.cmdk-dialog { width: min(580px, 100%); border-radius: 18px; background: var(--a-surface-strong); border: 1px solid var(--a-border-hover); box-shadow: 0 36px 90px -20px rgba(0, 0, 0, 0.82), inset 0 1px 0 var(--a-rim); overflow: hidden; }
.cmdk-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.cmdk-input { flex: 1; border: 0 !important; background: transparent !important; color: var(--ink) !important; font-size: 14.5px; outline: none; padding: 0 !important; }
.cmdk-kbd { font-family: var(--a-mono); font-size: 11px; color: var(--muted); padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line-strong); }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.cmdk-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-radius: 11px; color: var(--ink) !important; text-decoration: none; border: 1px solid transparent; cursor: pointer; background: transparent; width: 100%; text-align: left; }
.cmdk-item:hover, .cmdk-item.is-selected { background: var(--accent-soft); border-color: rgba(222, 195, 146, 0.30); }
.cmdk-item-title { font-size: 13.5px; font-weight: 600; }
.cmdk-item-sub { font-family: var(--a-mono); font-size: 11px; color: var(--muted); }
.cmdk-item-tag { font-family: var(--a-mono); font-size: 10.5px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }

@media (prefers-reduced-motion: reduce) {
  #prism-cursor-glow, #atelier-cursor-ring { display: none !important; }
}
