/* ===== Mandali app home: the 3D stage (student app only) ===== */

/* ---------- Hero becomes a stage: 3D candle field behind, text layers in front ---------- */
.hx.h3 { perspective: 820px; touch-action: pan-y; }
.hx-stage { display: none; }
.hx.h3-on .hx-stage { display: block; flex: none; height: clamp(210px, 34svh, 320px); }
.hx.h3-on { min-height: 0; }
.hx.h3-on .hx-grid { display: none; }
.hx.h3-on .hx-sw { display: none; }             /* the 3D field is the chart now */
.hx.h3-on .hx-q { grid-template-columns: minmax(0, 1fr); border-top-color: transparent; }

.h3-canvas { position: absolute; inset: 0; z-index: 0; opacity: 0; transition: opacity .9s var(--ease-out); }
.h3-canvas canvas { display: block; width: 100% !important; height: 100% !important; }
.hx.h3-on .h3-canvas { opacity: 1; }
/* soft scrims keep the words readable over the scene (no boxed panels) */
.hx.h3-on .hx-bg::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--hx-bg2) 92%, transparent) 0%, color-mix(in srgb, var(--hx-bg2) 55%, transparent) 24%, transparent 42%),
    linear-gradient(0deg, color-mix(in srgb, var(--hx-bg1) 96%, transparent) 0%, color-mix(in srgb, var(--hx-bg1) 70%, transparent) 22%, transparent 44%); }
.hx.h3-on .hx-h, .hx.h3-on .hx-px, .hx.h3-on .hx-ch, .hx.h3-on .hx-k {
  text-shadow: 0 1px 2px color-mix(in srgb, var(--hx-bg1) 70%, transparent), 0 0 18px color-mix(in srgb, var(--hx-bg1) 85%, transparent); }
.hx.h3-on .hx-px { font-size: 2.05rem; }
.hx.h3-on .hx-sa { position: relative; }

/* depth layers: each moves by its own depth with finger, tilt and scroll */
.h3-l { position: relative; z-index: 2; will-change: transform;
  transform: translate3d(calc(var(--h3x, 0) * var(--dz, 1) * -5px), calc(var(--h3y, 0) * var(--dz, 1) * -3px + var(--h3s, 0) * var(--dz, 1) * -16px), 0); }
.hx.h3-intro .h3-l { animation: h3In 1.05s var(--ease-out) both; animation-delay: calc(650ms + var(--di, 0) * 130ms); }
@keyframes h3In { from { opacity: 0; transform: translate3d(0, 22px, -180px); } to { opacity: 1; } }

/* a thin "drag to turn" hint the first time */
.hx.h3-on.h3-intro::after { content: "Drag sideways to turn"; position: absolute; z-index: 3; right: 14px; top: 50%; padding: 4px 9px; border-radius: 999px;
  font: 600 10.5px "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; color: var(--hx-soft); background: color-mix(in srgb, var(--hx-bg1) 70%, transparent);
  border: 1px solid var(--hx-line); animation: h3Hint 2.6s var(--ease-out) both; pointer-events: none; }
@keyframes h3Hint { 0%, 55% { opacity: 0; transform: translateX(8px); } 70%, 90% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- Quick tiles: tilt toward the finger, icon lifted off the card ---------- */
.hq { perspective: 700px; }
.hq-b.h3-tile { position: relative; transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .4s var(--ease-out), box-shadow .2s var(--ease-out); }
.hq-b.h3-tile.h3-act { transition: transform .08s linear, box-shadow .2s var(--ease-out); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 45%, var(--line)), 0 14px 28px -18px rgba(0,0,0,.6); }
.hq-b.h3-tile:active { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(.97); }
.hq-b.h3-tile .hq-ic { transform: translateZ(16px); transition: transform .4s var(--ease-out); }
.hq-b.h3-tile.h3-act .hq-ic { transform: translateZ(26px); }
.hq-b.h3-tile > span:last-child { transform: translateZ(8px); }
.hq-b.h3-tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s var(--ease-out);
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--gold) 26%, transparent), transparent 60%); }
.hq-b.h3-tile.h3-act::after { opacity: 1; }

/* ---------- Home rows swing up from depth the first time ---------- */
.h3-pre { opacity: 0; transform: perspective(900px) rotateX(-22deg) translateY(20px); transform-origin: 50% 0; }
.h3-pre.h3-swing { animation: h3Swing .75s var(--ease-out) both; animation-delay: var(--h3d, 0ms); }
@keyframes h3Swing { from { opacity: 0; transform: perspective(900px) rotateX(-22deg) translateY(20px); } to { opacity: 1; transform: none; } }

@media (max-width: 380px) { .hx.h3-on .hx-px { font-size: 1.85rem; } }
@media (min-width: 760px) { .hx.h3-on .hx-stage { height: clamp(220px, 30svh, 300px); } }

@media (prefers-reduced-motion: reduce) {
  .h3-l { transform: none; will-change: auto; }
  .hx.h3-intro .h3-l, .hx.h3-on.h3-intro::after { animation: none; }
  .hq-b.h3-tile, .hq-b.h3-tile .hq-ic { transform: none; transition: none; }
  .h3-pre { opacity: 1; transform: none; }
}

/* labels pinned to points in the 3D scene */
.h3-tag { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .4s var(--ease-out);
  font: 600 10.5px/1 "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; letter-spacing: .02em; will-change: transform; }
.h3-tag.on { opacity: 1; }
.h3-tag.last { margin: -26px 0 0 -4px; padding: 4px 7px; border-radius: 6px; color: #06231B; background: var(--hx-up); box-shadow: 0 6px 18px -8px var(--hx-up); }
.h3-tag.last.dn { color: #2A0906; background: var(--hx-dn); box-shadow: 0 6px 18px -8px var(--hx-dn); }
.h3-tag.last::after { content: ""; position: absolute; left: 4px; bottom: -4px; border: 4px solid transparent; border-top-color: var(--hx-up); border-bottom: 0; }
.h3-tag.last.dn::after { border-top-color: var(--hx-dn); }
.h3-tag.prev { margin: -24px 0 0 0; padding: 3px 7px; border-radius: 6px; color: var(--hx-gold); background: color-mix(in srgb, var(--hx-bg1) 82%, transparent); border: 1px solid color-mix(in srgb, var(--hx-gold) 35%, transparent); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .h3-tag { transition: none; } }
.h3-tag.last.flip { margin-left: 0; translate: -100% 0; }
.h3-tag.last.flip::after { left: auto; right: 4px; }
.h3-tag.last.below { margin-top: 14px; }
.h3-tag.last.below::after { bottom: auto; top: -4px; border-top: 0; border-bottom: 4px solid var(--hx-up); }
.h3-tag.last.below.dn::after { border-bottom-color: var(--hx-dn); }
.h3-tag.wall { margin: -22px 0 0 0; padding: 3px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--hx-bg1) 80%, transparent); }
.h3-tag.wall.pw { color: var(--hx-up); border: 1px solid color-mix(in srgb, var(--hx-up) 40%, transparent); }
.h3-tag.wall.cw { color: var(--hx-dn); border: 1px solid color-mix(in srgb, var(--hx-dn) 40%, transparent); }

/* ===== Market now chart: controls, scale and read-outs (2 Dec 2026) ===== */
.hx.h3-on .hx-stage { position: relative; z-index: 3; height: clamp(270px, 42svh, 380px); touch-action: pan-y; cursor: crosshair; }
@media (min-width: 760px) { .hx.h3-on .hx-stage { height: clamp(280px, 38svh, 380px); } }
.h3-ctl { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 2px 0 6px; cursor: default; -webkit-overflow-scrolling: touch; }
.h3-ctl::-webkit-scrollbar { display: none; }
.h3-ctl { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); padding-right: 24px; }
.h3-ctl button { all: unset; box-sizing: border-box; flex: none; height: 30px; padding: 0 10px; border-radius: 999px; font: 600 12px/30px var(--sans, system-ui); color: color-mix(in srgb, var(--hx-ink) 78%, transparent);
  background: color-mix(in srgb, var(--hx-ink) 7%, transparent); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; transition: background-color 150ms ease, color 150ms ease, transform 120ms cubic-bezier(.23,1,.32,1); }
.h3-ctl button:active { transform: scale(.96); }
.h3-ctl button:focus-visible { outline: 2px solid var(--hx-gold); outline-offset: 1px; }
.h3-ctl .h3-seg { display: inline-flex; flex: none; padding: 2px; gap: 2px; border-radius: 999px; background: color-mix(in srgb, var(--hx-ink) 7%, transparent); }
.h3-ctl .h3-seg button { height: 26px; line-height: 26px; padding: 0 9px; background: transparent; }
.h3-ctl .h3-seg button[aria-pressed="true"] { background: var(--hx-gold); color: #10131c; }
.h3-ctl .tg[aria-pressed="true"] { color: var(--hx-gold); background: color-mix(in srgb, var(--hx-gold) 16%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--hx-gold) 40%, transparent) inset; }
.h3-labs { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.h3-lb { position: absolute; left: 0; top: 0; white-space: nowrap; opacity: 0; transition: opacity 200ms ease; font: 500 10.5px/1 var(--mono, ui-monospace, monospace); font-variant-numeric: tabular-nums; }
.h3-lb.on { opacity: 1; }
.h3-lb.yt { margin-top: -6px; color: color-mix(in srgb, var(--hx-ink) 60%, transparent); }
.h3-lb.sg { margin-top: -6px; color: var(--hx-gold); font-weight: 600; }
.h3-lb.px { margin-top: -10px; padding: 4px 6px; border-radius: 6px; font-weight: 700; font-size: 11px; color: #1a0705; background: var(--hx-dn); box-shadow: 0 6px 16px -6px var(--hx-dn); }
.h3-lb.px.up { color: #04211a; background: var(--hx-up); box-shadow: 0 6px 16px -6px var(--hx-up); }
.h3-lb.px.tick { animation: h3tick 900ms cubic-bezier(.23,1,.32,1); }
@keyframes h3tick { 0% { scale: 1.18; filter: brightness(1.4); } 100% { scale: 1; filter: none; } }
.h3-lb.tm { margin-left: 0; translate: -50% 0; color: color-mix(in srgb, var(--hx-ink) 60%, transparent); }
.h3-lb.left { translate: -100% -120%; color: color-mix(in srgb, var(--hx-ink) 65%, transparent); font-size: 10px; }
.h3-lb.lv { translate: 0 -120%; padding: 2px 5px; border-radius: 5px; font-size: 10px; background: color-mix(in srgb, var(--hx-bg1) 78%, transparent); }
.h3-lb.lv.pc { color: var(--hx-gold); }
.h3-lb.lv.pw { color: var(--hx-up); }
.h3-lb.lv.cw { color: var(--hx-dn); }
.h3-lb.hl { translate: -50% 0; font-size: 10px; font-weight: 600; color: color-mix(in srgb, var(--hx-ink) 85%, transparent); }
.h3-lb.hl.h { translate: -50% -150%; }
.h3-lb.hl.l { translate: -50% 60%; }
.h3-lb.xh { translate: -50% -100%; z-index: 3; padding: 6px 8px; border-radius: 8px; font-size: 11.5px; font-weight: 600; color: var(--hx-ink); background: color-mix(in srgb, var(--hx-bg1) 92%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--hx-gold) 45%, transparent) inset, 0 10px 24px -10px rgba(0,0,0,.6); white-space: pre; }
.h3-lb.xh.dn { color: var(--hx-dn); } .h3-lb.xh.up { color: var(--hx-up); }
html[data-theme="light"] .h3-ctl .h3-seg button[aria-pressed="true"] { color: #fff; }
@media (prefers-reduced-motion: reduce) { .h3-lb.px.tick { animation: none; } }

.h3-lb.lv.dl { translate: 0 30%; }
