/* ==========================================================================
   Student app motion layer (index.html only; admin never loads this file).
   Motion plays when something first comes into view in a session, then stays
   still: lively on arrival, calm for everyday use. Only transform and opacity
   move. Reduced-motion users get everything instantly.
   ========================================================================== */
@property --smp { syntax: "<number>"; inherits: true; initial-value: 0; }

:root { --sm-out: cubic-bezier(0.23, 1, 0.32, 1); --sm-move: cubic-bezier(0.77, 0, 0.175, 1); --sm-teal: #3FB8A9; }
html[data-theme="light"] { --sm-teal: #1F8577; }

/* ---------- 1. Arrivals: cards rise in as they come into view ---------- */
[data-sm-r] { opacity: 0; transform: translateY(14px) scale(0.985); }
[data-sm-r].sm-in { opacity: 1; transform: none; transition: opacity .45s var(--sm-out), transform .6s var(--sm-out); transition-delay: var(--smd, 0ms); }
[data-sm-r].sm-now { opacity: 1; transform: none; transition: none; }

/* ---------- 2. Rings (class progress, batch seal, win rate) ---------- */
.sm-ring { position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--smp) * 1%), color-mix(in srgb, var(--line) 85%, transparent) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); }
.sm-ringbox { --p: 0; --c: var(--gold); position: relative; display: grid; place-items: center; flex: none; }
.sm-ringbox > b { position: absolute; font-family: var(--mono); font-size: .9rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.sm-ringbox.go { animation: smRing 1.2s var(--sm-out) forwards; }
.sm-ringbox.set { --smp: var(--p); }
@keyframes smRing { from { --smp: 0; } to { --smp: var(--p); } }

/* the head of the ring: a small bead that rides to the finish */
.sm-bead { position: absolute; inset: 0; transform: rotate(calc(var(--smp) * 3.6deg)); pointer-events: none; }
.sm-bead::after { content: ""; position: absolute; top: -1px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  background: var(--c, var(--gold)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--gold)) 25%, transparent); }

/* ---------- 3. "For you" header: progress ring + streak lamps ---------- */
.sm-fy { display: flex; align-items: center; gap: 16px; padding: 4px 0 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.sm-fy-txt { flex: 1; min-width: 0; }
.sm-fy-txt p { margin: 0; }
.sm-fy-k { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-family: var(--mono); }
.sm-fy-v { font-size: 1rem; font-weight: 600; color: var(--text); margin-top: 2px !important; }

.sm-lamps { display: flex; gap: 6px; margin-top: 8px; }
.sm-lamp { width: 14px; height: 18px; position: relative; }
.sm-lamp::before { /* the bowl */ content: ""; position: absolute; left: 1px; right: 1px; bottom: 0; height: 6px; border-radius: 0 0 8px 8px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.sm-lamp::after { /* the flame */ content: ""; position: absolute; left: 50%; bottom: 5px; width: 8px; height: 11px; margin-left: -4px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 70%, #FFE6A3 0 22%, var(--gold) 55%, #D3672A 100%); opacity: 0; transform: scale(0.4) translateY(4px); transform-origin: 50% 100%; }
.sm-lamp.lit::before { background: color-mix(in srgb, var(--gold) 70%, #6b4a10); }
.sm-lamp.lit::after { opacity: 1; transform: none; transition: opacity .3s var(--sm-out), transform .45s cubic-bezier(.3, 1.5, .5, 1); transition-delay: var(--ld, 0ms); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--gold) 60%, transparent)); }
.sm-lamps.wait .sm-lamp.lit::after { opacity: 0; transform: scale(0.4) translateY(4px); }
.sm-lamps.wait .sm-lamp.lit::before { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.streak-strip .sm-lamps { margin: 8px 0 0; }

/* ---------- 4. Quick tiles: icons draw themselves once ---------- */
.hq-b .hq-ic svg.sm-draw * { stroke-dasharray: 1; stroke-dashoffset: 1; animation: smDraw .9s var(--sm-out) forwards; animation-delay: calc(var(--i, 0) * 70ms + 200ms); }
@keyframes smDraw { to { stroke-dashoffset: 0; } }

/* ---------- 5. Home rows: the icon chip glints once as it arrives ---------- */
.hf .hf-ic { position: relative; }
.hf.sm-glint .hf-ic::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1.5px solid var(--tint, var(--gold));
  animation: smGlint .9s var(--sm-out) forwards; animation-delay: var(--smd, 0ms); opacity: 0; }
@keyframes smGlint { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.45); } }

/* ---------- 6. Bars that fill (batch, weekly goal, Q2 growth, trade P&L) ---------- */
.progress-bar span.sm-fill, .grow-bar i.sm-fill { transform-origin: left center; animation: smFill 1.1s var(--sm-out) both; animation-delay: var(--smd, 120ms); }
@keyframes smFill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.sm-yoy { display: block; height: 4px; margin: 6px 0 2px auto; width: 100%; max-width: 160px; border-radius: 4px; background: color-mix(in srgb, var(--line) 80%, transparent); overflow: hidden; }
.sm-yoy i { display: block; height: 100%; width: calc(var(--w, 0) * 1%); margin-left: auto; border-radius: 4px; background: var(--ok); transform-origin: right center; transform: scaleX(0); }
.sm-yoy.dn i { background: var(--danger); }
.sm-yoy.go i { transform: none; transition: transform .9s var(--sm-out); transition-delay: var(--smd, 0ms); }

.rows > .row { position: relative; }
.sm-pnl { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--w, 0) * 1%); border-radius: 0 3px 3px 0; background: var(--ok); opacity: .85; transform-origin: left center; transform: scaleX(0); }
.sm-pnl.dn { background: var(--danger); }
.sm-pnl.go { transform: none; transition: transform .8s var(--sm-out); transition-delay: var(--smd, 0ms); }

/* ---------- 7. Journal: a timeline spine that grows as you scroll ---------- */
#noteList.sm-tl { position: relative; padding-left: 20px; }
#noteList.sm-tl::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px;
  background: linear-gradient(var(--gold), color-mix(in srgb, var(--gold) 10%, transparent)); transform-origin: top; transform: scaleY(var(--tl, 0)); transition: transform .25s linear; }
#noteList.sm-tl > .jnote { position: relative; overflow: visible; }
#noteList.sm-tl > .jnote::before { content: ""; position: absolute; left: -19px; top: 22px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); border: 2px solid var(--gold); transform: scale(0); transition: transform .4s cubic-bezier(.3, 1.6, .5, 1); }
#noteList.sm-tl > .jnote.sm-in::before, #noteList.sm-tl > .jnote.sm-now::before { transform: none; }
#noteList.sm-tl > .jnote.jref::before { background: var(--gold); }

/* chart cards draw from left to right */
.chart-card .sm-wipe { clip-path: inset(0 100% 0 0); }
.chart-card .sm-wipe.go { clip-path: inset(0 0 0 0); transition: clip-path 1.1s var(--sm-move); }

/* win-rate stat gets a small ring */
.stat.sm-has-ring { position: relative; }
.stat .sm-ringbox.sm-mini { position: absolute; top: 14px; right: 14px; }
.stat .sm-mini .sm-ring { width: 36px; height: 36px; -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); }

/* ---------- 8. Classes ---------- */
.seal.sm-seal { position: relative; }
.seal.sm-seal > .sm-ringbox { position: absolute; inset: -9px; }
.seal.sm-seal > .sm-ringbox .sm-ring { position: absolute; inset: 0; width: auto; height: auto; }
.lesson .done-tick.sm-pop { display: inline-block; animation: smPop .5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--smd, 0ms); }
@keyframes smPop { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: none; } }
.lesson.sm-next { position: relative; background: linear-gradient(90deg, var(--gold-soft), transparent 70%); }
.lesson.sm-next::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--gold); }
.lesson.sm-next .lesson-title::after { content: "Up next"; display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 4px; font-size: .68rem; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 50%, transparent); vertical-align: 2px; }
.lesson.sm-next .lesson-num { animation: smNudge 1.6s var(--sm-out) .6s 2; }
@keyframes smNudge { 0%, 100% { transform: none; } 40% { transform: translateX(4px); } }

/* ---------- 9. Analysis: where Nifty sits between the levels ---------- */
.sm-map { margin-top: 14px; padding: 12px 12px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--ink); }
.sm-map-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 0 6px; }
.sm-map-h b { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sm-map-h span { font-size: .78rem; color: var(--muted); text-align: right; }
.sm-map-h span strong { color: var(--text); font-family: var(--mono); font-weight: 600; }
.sm-map svg { display: block; width: 100%; height: auto; overflow: visible; }
.sm-map .tk { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.sm-map .zone { fill: color-mix(in srgb, var(--gold) 14%, transparent); }
.sm-map .lv { stroke-width: 2; }
.sm-map .lv.s { stroke: var(--ok); } .sm-map .lv.r { stroke: var(--danger); }
.sm-map text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.sm-map text.s { fill: var(--ok); } .sm-map text.r { fill: var(--danger); }
.sm-map .px { fill: var(--gold); }
.sm-map .pxg { transform: translateX(var(--x0, 0px)); }
.sm-map.go .pxg { transform: translateX(var(--x1, 0px)); transition: transform 1.3s var(--sm-move) .25s; }
.sm-map .zone { transform-box: fill-box; transform-origin: center; transform: scaleX(0); }
.sm-map.go .zone { transform: none; transition: transform .8s var(--sm-out) .1s; }
.sm-map .lvg { opacity: 0; transform: translateY(-6px); }
.sm-map.go .lvg { opacity: 1; transform: none; transition: opacity .4s var(--sm-out), transform .5s var(--sm-out); transition-delay: var(--smd, 0ms); }
.sm-map-n { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.sm-map-n b { color: var(--text); font-weight: 600; }

/* bias badge shines once */
.bias.sm-shine { position: relative; overflow: hidden; }
.bias.sm-shine::after { content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 50%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent); transform: skewX(-18deg); animation: smShine 1.1s var(--sm-move) .5s forwards; }
@keyframes smShine { to { left: 130%; } }

/* ---------- 10. Q2 results ---------- */
.rcard .tag.sm-pop { animation: smPop .45s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--smd, 0ms) + 150ms); }
.qc.sm-ping i { position: relative; }
.qc.sm-ping i::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: smPing 1.2s var(--sm-out) .5s 2; }
@keyframes smPing { 0% { opacity: .8; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.8); } }

/* ---------- 11. Paper trading: capital meter ---------- */
.sm-cap { margin: -2px 0 12px; }
.sm-cap-t { display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: color-mix(in srgb, var(--line) 85%, transparent); }
.sm-cap-t i { display: block; height: 100%; width: 100%; transform-origin: left center; transform: scaleX(var(--f, 0)); background: linear-gradient(90deg, var(--sm-teal), var(--gold)); transition: transform .7s var(--sm-out); }
.sm-cap-l { display: flex; justify-content: space-between; margin-top: 5px; font-size: .74rem; color: var(--muted); font-family: var(--mono); }

/* ---------- 12. Press feedback on student buttons ---------- */
.hq-b, .lesson, .rcard, .fy, .sm-press { transition: transform .14s var(--sm-out); }
.hq-b:active, .lesson:active, .fy:active { transform: scale(0.97); }

@media (prefers-reduced-motion: reduce) {
  [data-sm-r], [data-sm-r].sm-in { opacity: 1; transform: none; transition: none; }
  .sm-ringbox.go { animation: none; --smp: var(--p); }
  .hq-b .hq-ic svg.sm-draw * { animation: none; stroke-dashoffset: 0; }
  .hf.sm-glint .hf-ic::after, .bias.sm-shine::after, .qc.sm-ping i::after { display: none; }
  .progress-bar span.sm-fill, .grow-bar i.sm-fill, .done-tick.sm-pop, .rcard .tag.sm-pop, .lesson.sm-next .lesson-num { animation: none; }
  .sm-yoy i, .sm-pnl, .sm-map .zone, .sm-map .lvg { transform: none; opacity: 1; transition: none; }
  .sm-map .pxg { transform: translateX(var(--x1, 0px)); transition: none; }
  .chart-card .sm-wipe { clip-path: none; transition: none; }
  #noteList.sm-tl::before { transform: none; transition: none; }
  .sm-lamp.lit::after { transition: none; }
}
