/* ==========================================================================
   Premium layer: light/dark themes, glass + clay surfaces, orb, micro-interactions
   ========================================================================== */
:root[data-theme="light"] {
  --bg: #f3f5fb; --bg-2: #ffffff; --card: #ffffff; --card-2: #eef1f9;
  --line: rgba(15, 23, 42, .09); --line-2: rgba(15, 23, 42, .16);
  --text: #0f172a; --muted: #5a647a;
  --shadow: 0 24px 50px -24px rgba(30, 41, 90, .35);
}
:root[data-theme="light"] body::before { background: radial-gradient(900px 500px at 85% -10%, rgba(139, 92, 246, .16), transparent 60%), radial-gradient(800px 500px at -10% 10%, rgba(59, 130, 246, .14), transparent 60%); }
:root[data-theme="light"] a { color: #2457d6; }
:root[data-theme="light"] a:hover { color: #1b43a8; }
:root[data-theme="light"] .btn-primary, :root[data-theme="light"] .btn-primary:hover { color: #fff; }
:root[data-theme="light"] .site-header { background: rgba(255, 255, 255, .78); }
:root[data-theme="light"] .nav-links a:hover, :root[data-theme="light"] .nav-links a.active { background: rgba(15, 23, 42, .06); }
:root[data-theme="light"] .glass { background: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .6)); }
:root[data-theme="light"] .eyebrow { background: rgba(15, 23, 42, .04); }
:root[data-theme="light"] .btn:hover { border-color: rgba(15, 23, 42, .35); }
:root[data-theme="light"] input, :root[data-theme="light"] select, :root[data-theme="light"] textarea { color-scheme: light; }
:root[data-theme="light"] tbody tr:hover { background: rgba(15, 23, 42, .03); }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { color-scheme: dark; }

/* theme toggle */
.theme-toggle { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--text); cursor: pointer; font-size: 1.05rem; line-height: 1; display: inline-grid; place-items: center; transition: transform .2s, background .2s; }
.theme-toggle:hover { transform: rotate(18deg) scale(1.06); }
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: inline; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }

/* demo banner */
.demo-banner { background: linear-gradient(90deg, #f59e0b, #f97316); color: #1a1100; text-align: center; font-weight: 600; font-size: .85rem; padding: .4rem 1rem; }

/* hero orb (Three.js if available, CSS fallback otherwise) */
.hero { position: relative; overflow: hidden; }
.orb-wrap { position: absolute; width: min(520px, 90vw); aspect-ratio: 1; right: -90px; top: -80px; z-index: 0; pointer-events: none; opacity: .95; }
.hero-grid { position: relative; z-index: 1; }
.orb-fallback { position: absolute; inset: 14%; border-radius: 50%; background: radial-gradient(circle at 32% 28%, #c7d2fe, #6366f1 48%, #312e81 80%); box-shadow: 0 30px 80px -10px rgba(99, 102, 241, .6), inset -20px -30px 60px rgba(0, 0, 0, .35); animation: orbfloat 7s ease-in-out infinite; }
#orb { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .8s; }
#orb.on { opacity: 1; }
#orb.on + .orb-fallback { display: none; }
@keyframes orbfloat { 50% { transform: translateY(-14px) scale(1.03); } }

/* claymorphism surfaces */
.clay { background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 1.6rem; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .10), inset 0 -8px 18px rgba(0, 0, 0, .18), 0 22px 40px -22px rgba(0, 0, 0, .65); transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s; }
:root[data-theme="light"] .clay { box-shadow: inset 0 2px 0 #fff, inset 0 -8px 18px rgba(80, 100, 180, .10), 0 22px 40px -22px rgba(40, 60, 140, .35); }
.clay:hover { transform: translateY(-5px) rotate(-.2deg); }
.clay .ico-big { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 1.6rem; background: var(--grad); color: #fff; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -6px 12px rgba(0, 0, 0, .25), 0 12px 24px -10px rgba(99, 102, 241, .8); margin-bottom: 1rem; }
.clay ul { padding-left: 1.1rem; color: var(--muted); }
.clay li { margin: .25rem 0; }
.duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1.4rem; }

/* micro-interactions */
.btn { position: relative; overflow: hidden; }
.btn:active { transform: translateY(0) scale(.97); }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-120%); transition: transform .6s; }
.btn-primary:hover::after { transform: translateX(120%); }
.card { transition: transform .22s, border-color .22s, box-shadow .22s; }
.card:hover { transform: translateY(-3px); border-color: var(--line-2); }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } .orb-fallback { animation: none; } * { scroll-behavior: auto !important; } }

/* code + docs */
pre.code { background: #0b1020; color: #dbe4ff; border: 1px solid var(--line-2); border-radius: 14px; padding: 1rem 1.1rem; overflow: auto; font: 500 .84rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: .6rem 0 1.2rem; }
.tabs-code { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.tabs-code button { cursor: pointer; border: 1px solid var(--line-2); background: var(--card-2); color: var(--text); border-radius: 10px; padding: .3rem .8rem; font: 600 .8rem var(--font); }
.tabs-code button.on { background: var(--grad); color: #fff; border-color: transparent; }
.snip { display: none; }
.snip.on { display: block; }
.docs-layout { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; align-items: start; }
.docs-nav { position: sticky; top: 90px; display: flex; flex-direction: column; gap: .2rem; }
.docs-nav a { color: var(--muted); padding: .35rem .7rem; border-radius: 8px; font-weight: 500; font-size: .9rem; }
.docs-nav a:hover { color: var(--text); background: rgba(127, 127, 160, .12); }
.docs-body section { margin-bottom: 2.4rem; scroll-margin-top: 90px; }
.docs-body code { background: rgba(127, 127, 160, .16); padding: .1rem .35rem; border-radius: 6px; font-size: .88em; }
.docs-body pre code { background: none; padding: 0; }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--grad); color: #fff; margin-right: .4rem; }
@media (max-width: 860px) { .docs-layout { grid-template-columns: 1fr; } .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; } .orb-wrap { right: -200px; top: -60px; opacity: .3; } }