/* ==========================================================================
   Premium layer: glass surfaces, 3D depth, live dashboard, notification panel.
   Loaded last, additive. Motion uses transform / opacity / clip-path only and
   is switched off by prefers-reduced-motion (see bottom + base.css).
   ========================================================================== */

/* ---- Ambient depth behind the dashboard ------------------------------------- */
.dash { position: relative; isolation: isolate; }
.dash::before {
  content: "";
  position: absolute;
  inset: -28px 0 auto;
  height: min(1100px, 140vh);
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(560px 360px at 88% 6%, color-mix(in srgb, var(--primary) 24%, transparent), transparent 70%),
    radial-gradient(520px 360px at 6% 42%, color-mix(in srgb, var(--c1) 13%, transparent), transparent 70%),
    radial-gradient(480px 320px at 72% 78%, color-mix(in srgb, var(--c3) 11%, transparent), transparent 70%);
  animation: ambient-drift 22s ease-in-out infinite alternate;
}
@keyframes ambient-drift { to { transform: translate3d(0, 18px, 0) scale(1.03); } }

/* ---- Glass surfaces ------------------------------------------------------------ */
.glass {
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  backdrop-filter: blur(18px) saturate(1.35);
  border-color: color-mix(in srgb, var(--border) 65%, rgba(255, 255, 255, .55));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), var(--shadow-sm), 0 22px 44px -32px rgba(20, 30, 0, .45);
}
:root[data-theme="black"] .glass {
  border-color: rgba(255, 255, 255, .07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), var(--shadow-sm), 0 26px 50px -30px rgba(0, 0, 0, .9);
}
:root[data-theme="white"] .glass { box-shadow: inset 0 1px 0 #fff, var(--shadow-sm), 0 22px 44px -30px rgba(16, 24, 40, .3); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .glass { background: var(--surface); } }

/* ---- 3D tilt + glare (driven by js/core/depth.js) --------------------------- */
[data-tilt] { --px: 0; --py: 0; will-change: transform; }
.glare {
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(380px circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .34), transparent 46%);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity .35s ease;
  z-index: 2;
}
.is-tilting > .glare { opacity: 1; }

.hero-card[data-tilt] {
  transform: perspective(1100px) rotateX(calc(var(--py) * -3.5deg)) rotateY(calc(var(--px) * 4.5deg));
  transition: transform .7s var(--ease), box-shadow .4s ease;
  box-shadow: var(--shadow), 0 30px 60px -34px rgba(0, 0, 0, .55);
}
.hero-card.is-tilting { transition: transform .12s ease-out, box-shadow .4s ease; box-shadow: var(--shadow-lg); }

a.stat { color: inherit; text-decoration: none; overflow: hidden; }
a.stat:hover { text-decoration: none; }
.stat[data-tilt] {
  --lift: 0px;
  transform: perspective(800px) rotateX(calc(var(--py) * -6deg)) rotateY(calc(var(--px) * 6deg)) translateY(var(--lift));
  transition: transform .6s var(--ease), box-shadow .3s ease, border-color .3s;
}
.stat[data-tilt]:hover {
  --lift: -3px;
  transform: perspective(800px) rotateX(calc(var(--py) * -6deg)) rotateY(calc(var(--px) * 6deg)) translateY(var(--lift));
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.stat.is-tilting { transition: transform .1s ease-out, box-shadow .3s ease; }
.stat .stat-ico { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 6px 14px -8px color-mix(in srgb, var(--primary-ink) 60%, transparent); }

/* ---- Hero: floating 3D orb ------------------------------------------------------------ */
.hero-card .hero-art { display: none; }
/* The orb sits in the balance row as a normal flex item (never on top of text). It scales with
   the card and is dropped on very narrow cards, where there is no room beside the amount. */
.hero-card { container-type: inline-size; }
.hero-amount { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: clamp(2.1rem, 12.5cqi, 3.5rem); }
.hero-amount .mv { min-width: 0; }
.hero-orb {
  position: relative;
  flex: none;
  width: 86px; height: 86px;
  margin: -16px 4px -16px 0;   /* overlaps the row's own padding only, so the line keeps text height */
  pointer-events: none;
  transform: translate3d(calc(var(--px, 0) * -8px), calc(var(--py, 0) * -6px), 0);
  transition: transform .7s var(--ease);
}
@container (max-width: 380px) { .hero-orb { width: 62px; height: 62px; margin: -12px 2px -12px 0; } }
@container (max-width: 290px) { .hero-orb { display: none; } }
.is-tilting .hero-orb { transition: transform .15s ease-out; }
.hero-orb i { position: absolute; display: block; border-radius: 50%; }
.hero-orb i:nth-child(1) {
  inset: 14%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .38) 24%,
    color-mix(in srgb, var(--hero-fg) 14%, transparent) 62%, color-mix(in srgb, var(--hero-fg) 30%, transparent) 100%);
  box-shadow: inset -10px -14px 24px rgba(0, 0, 0, .16), 0 20px 32px -14px rgba(0, 0, 0, .38);
  animation: orb-float 7s ease-in-out infinite;
}
.hero-orb i:nth-child(2) {
  inset: 38% -9%;
  border: 2px solid color-mix(in srgb, var(--hero-fg) 34%, transparent);
  border-top-color: transparent;
  animation: orb-ring 7s ease-in-out infinite;
}
.hero-orb i:nth-child(3) {
  width: 18%; height: 18%; left: 2%; top: 4%;
  background: radial-gradient(circle at 35% 30%, #fff, color-mix(in srgb, var(--hero-fg) 38%, transparent));
  box-shadow: 0 8px 14px -6px rgba(0, 0, 0, .4);
  animation: orb-sat 9s ease-in-out infinite;
}
@keyframes orb-float { 50% { transform: translateY(-8px); } }
@keyframes orb-ring { 0%, 100% { transform: rotate(-16deg); } 50% { transform: rotate(-16deg) translateY(-8px); } }
@keyframes orb-sat { 50% { transform: translate(12px, 10px); } }

.hero-next { color: var(--hero-fg); text-decoration: none; transition: background-color var(--dur), transform var(--dur) var(--ease); }
.hero-next:hover { text-decoration: none; background: color-mix(in srgb, var(--hero-chip) 100%, rgba(255, 255, 255, .14)); transform: translateX(2px); }
.hero-next > span { flex: 1; min-width: 0; }
.hero-eye { cursor: pointer; transition: transform var(--dur) var(--ease), background-color var(--dur); }
.hero-eye:hover { transform: scale(1.06); }
.hero-eye:active { transform: scale(.94); }

/* Value changed live: soft ring + number pop */
.bump-up, .bump-down { animation: ring-pulse 1.1s ease-out; }
.bump-up { --ring: var(--success); }
.bump-down { --ring: var(--danger); }
.bump-up .stat-value, .bump-down .stat-value, .bump-up .hero-amount, .bump-down .hero-amount { animation: num-pop .6s var(--ease); transform-origin: 0 50%; }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ring) 55%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
@keyframes num-pop { 35% { transform: scale(1.045); } }

/* ---- Live status chip ------------------------------------------------------------- */
.live-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 12px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--border);
  font-size: .78rem; font-weight: 700; color: var(--text-2);
  white-space: nowrap;
}
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.live-chip[data-mode="realtime"] .live-dot { background: var(--success); }
.live-chip[data-mode="polling"] .live-dot { background: var(--info); }
.live-chip[data-mode="offline"] .live-dot { background: var(--danger); }
.live-chip[data-mode="realtime"] .live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--success);
  animation: live-ping 2s ease-out infinite;
}
@keyframes live-ping { 0% { transform: scale(1); opacity: .6; } 80%, 100% { transform: scale(2.8); opacity: 0; } }
.ph-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Alerts strip ---------------------------------------------------------------- */
.dash-alerts { display: grid; gap: 10px; margin-bottom: 16px; }
@media (min-width: 900px) { .dash-alerts { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); } }
.dash-alert {
  --al: var(--info);
  position: relative;
  display: flex; align-items: stretch;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--al) 30%, var(--border));
  background: color-mix(in srgb, var(--al) 8%, var(--surface));
  box-shadow: var(--shadow-sm);
  animation: alert-in .5s var(--ease) both;
  transition: opacity .25s ease, transform .25s ease;
}
.dash-alert.lvl-success { --al: var(--success); }
.dash-alert.lvl-warning { --al: var(--warning); }
.dash-alert.is-leaving { opacity: 0; transform: translateX(18px); }
@keyframes alert-in { from { opacity: 0; transform: translateY(-6px); } }
.da-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 14px; color: var(--text); text-decoration: none; }
.da-main:hover { text-decoration: none; }
.da-main .grow { min-width: 0; }
.da-main .grow > * { display: block; }
.da-main strong { font-size: .92rem; }
.da-main .grow > span { font-size: .83rem; color: var(--text-2); }
.da-main > .icon:last-child { color: var(--text-muted); flex: none; transition: transform var(--dur) var(--ease); }
.da-main:hover > .icon:last-child { transform: translateX(3px); }
.da-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 11px; background: color-mix(in srgb, var(--al) 16%, transparent); color: var(--al); }
.da-x { flex: none; width: 42px; border: 0; background: none; color: var(--text-muted); display: grid; place-items: center; border-radius: 0 14px 14px 0; cursor: pointer; transition: background-color var(--dur), color var(--dur); }
.da-x:hover { background: color-mix(in srgb, var(--al) 12%, transparent); color: var(--text); }

/* ---- Overview chart --------------------------------------------------------------- */
.dash-mid-b { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .dash-mid-b { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ov-summary { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.ov-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.ov-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--text-2);
  font: inherit; font-size: .8rem; font-weight: 650;
  cursor: pointer;
  transition: opacity var(--dur), border-color var(--dur), transform .15s var(--ease), background-color var(--dur);
}
.ov-chip:hover { border-color: var(--k); transform: translateY(-1px); }
.ov-chip:active { transform: scale(.96); }
.ov-chip[aria-pressed="false"] { opacity: .5; background: transparent; }
.ov-chip[aria-pressed="false"] .ov-v { display: none; }
.ov-key { width: 14px; height: 3px; border-radius: 2px; background: var(--k); flex: none; }
.ov-key.dashed { background: repeating-linear-gradient(90deg, var(--k) 0 4px, transparent 4px 7px); }
.ov-v { color: var(--text); font-weight: 800; }
.ov-v:empty { display: none; }
.ov-chart { min-height: 290px; }
.mc-lbl { fill: var(--chart-label); font-size: 11px; font-weight: 600; }
.mc-line, .mc-area, .mc-end { transition: opacity .35s ease; }
.mchart .is-off { opacity: 0 !important; }
.mc-intro .mc-line, .mc-intro .mc-area { animation: mc-reveal 1.3s var(--ease) backwards; }
.mc-intro .mc-end { animation: mc-fade .4s ease 1.1s backwards; }
@keyframes mc-reveal { from { clip-path: inset(0 100% 0 0); } }
@keyframes mc-fade { from { opacity: 0; } }
.mc-dot { transition: opacity .15s; }
.mchart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 8px; }

/* ---- Earnings + investment performance ------------------------------------------- */
.earn-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.earn-kv > div { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 80%, transparent); border: 1px solid var(--border); min-width: 0; }
.earn-kv span { display: block; font-size: .74rem; font-weight: 650; color: var(--text-muted); }
.earn-kv strong { display: block; font-size: .95rem; overflow-wrap: anywhere; }

.ip-list { display: flex; flex-direction: column; gap: 2px; }
.ip-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; color: var(--text); text-decoration: none; transition: background-color var(--dur), transform var(--dur) var(--ease); }
.ip-row:hover { background: var(--surface-2); text-decoration: none; transform: translateX(2px); }
.ip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ip-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.ip-top .num { font-weight: 800; flex: none; }
.ip-track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ip-fill {
  display: block; height: 100%; width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--success) 45%, var(--surface)), var(--success));
  transform-origin: 0 50%;
  animation: ip-grow 1s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 80ms + .15s);
}
.ip-fill.down { background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 45%, var(--surface)), var(--danger)); }
@keyframes ip-grow { from { transform: scaleX(0); } }
.ip-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .76rem; color: var(--text-muted); }
.ip-meta span:last-child { text-align: right; }

/* ---- Notification bell panel --------------------------------------------------- */
.bell-pop { width: min(380px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.popover:not([hidden]) { animation: pop-in .18s var(--ease); transform-origin: top right; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.bell-head strong { display: block; }
.bell-head .muted { display: block; font-size: .78rem; }
.bell-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.bell-item { display: flex; gap: 12px; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 12px; background: none; color: var(--text); font: inherit; cursor: pointer; transition: background-color var(--dur); }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.bell-item.unread:hover { background: color-mix(in srgb, var(--primary) 15%, transparent); }
.bell-item .grow { min-width: 0; }
.bi-title { display: block; font-weight: 700; font-size: .88rem; }
.bi-body { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .82rem; color: var(--text-2); }
.bi-time { display: block; margin-top: 2px; font-size: .74rem; color: var(--text-muted); }
.bell-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; border-top: 1px solid var(--border); font-weight: 700; font-size: .86rem; }
.bell-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); }
.bell-empty p { margin-top: 6px; }
.bell-load { display: grid; gap: 8px; padding: 6px; }
.bell-load .skeleton { display: block; height: 54px; border-radius: 12px; }
@media (max-width: 560px) {
  .bell-pop { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h) + var(--safe-top) + 6px); width: auto; }
}

/* ---- Notifications page --------------------------------------------------------- */
.notif { transition: opacity .25s ease, transform .25s ease; }
.notif.is-leaving { opacity: 0; transform: translateX(20px); }
.notif.is-busy { opacity: .6; pointer-events: none; }

/* ---- Global press feedback ------------------------------------------------------ */
.icon-btn:active, .user-btn:active { transform: translateY(1px) scale(.98); }
.icon-btn { transition: transform .15s var(--ease), background-color var(--dur), color var(--dur); }
.icon-btn:hover .icon { transform: rotate(-8deg); }
.icon-btn .icon { transition: transform var(--dur) var(--ease); }
.btn:disabled { cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .dash::before, .hero-orb i, .live-dot::after { animation: none !important; }
  [data-tilt], .stat[data-tilt]:hover { transform: none !important; }
}
