/* Design pass 2026-11-19 (web): stat numbers, tonal tiles, progress language, states, celebrations.
   Tokens only (material-themes.css). No JS. Motion = transform/opacity, once on entry. */

@property --ring-p { syntax: "<number>"; inherits: false; initial-value: 0; }

/* #2 Tonal tile: surface ladder, no shadow in the flow, concentric radii (inner = outer - gap). */
.tile {
    --tile-r: 24px; --tile-gap: 8px;
    background: var(--color-base-100);
    border-radius: var(--tile-r);
    padding: 16px;
}
.tile-nested { background: var(--color-surface-high, var(--color-base-300)); border-radius: calc(var(--tile-r) - var(--tile-gap)); padding: 12px; }
@media (prefers-contrast: more) { .tile, .tile-nested { outline: 1px solid var(--color-border-strong); outline-offset: -1px; } }
/* #4 dark craft: one surface step plus a 7% white inner top line (web only); big fills use container tone. */
:is([data-theme="dark"], [data-theme$="-dark"]) .tile { box-shadow: inset 0 1px 0 rgb(255 255 255 / .07); }

/* #1 Stat numbers */
.stat-label { font-size: .75rem; line-height: 1rem; font-weight: 600; color: color-mix(in oklab, var(--color-base-content) 68%, transparent); }
.stat-value { font-variant-numeric: tabular-nums; font-size: 1.875rem; line-height: 2.25rem; font-weight: 800; color: var(--color-base-content); letter-spacing: -.01em; }
.stat-value-hero { color: var(--color-primary); }
.stat-unit { font-size: .8125rem; font-weight: 500; margin-inline-start: .25rem; color: color-mix(in oklab, var(--color-base-content) 68%, transparent); }
.delta-chip { display: inline-flex; align-items: center; gap: .125rem; font-variant-numeric: tabular-nums; font-size: .75rem; font-weight: 700; padding: .0625rem .5rem; border-radius: 9999px; background: var(--color-base-200); color: var(--color-base-content); }
.delta-chip[data-sign="+"] { color: var(--color-success); }
.delta-chip[data-sign="-"] { color: var(--color-error); }

/* #3 Ring (effort): primary arc on a track, sweeps once. */
.ring { --size: 56px; --w: 6px; width: var(--size); height: var(--size); border-radius: 9999px; position: relative; flex: none;
    background: conic-gradient(var(--color-primary) calc(var(--ring-p) * 1%), var(--color-surface-highest, var(--color-base-300)) 0);
    -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - var(--w)), #000 calc(100% - var(--w) + 1px));
            mask: radial-gradient(farthest-side, #0000 calc(100% - var(--w)), #000 calc(100% - var(--w) + 1px));
    animation: ring-sweep var(--duration-slow, 420ms) var(--ease-spatial, cubic-bezier(.2,0,0,1)) both; }
@keyframes ring-sweep { from { --ring-p: 0; } }

/* #3 Segmented bar (mastery): 10 segments, 4px tall, 2px gaps. */
.seg-bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; height: 4px; }
.seg-bar > i { border-radius: 2px; background: var(--color-surface-high, var(--color-base-300)); }
.seg-bar > i.on { background: var(--color-primary); animation: seg-in var(--duration-base, 280ms) var(--ease-spatial, ease-out) both; animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes seg-in { from { opacity: 0; transform: scaleY(.4); } }

/* #3 Sparkline (trend): 7 bars, today in primary, others secondary; no axes. */
.spark { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; align-items: end; height: 32px; }
.spark > i { height: calc(var(--h, 0) * 1%); min-height: 3px; border-radius: 3px; background: var(--color-secondary); transform-origin: bottom; animation: spark-in var(--duration-base, 280ms) var(--ease-spatial, ease-out) both; animation-delay: calc(var(--i, 0) * 24ms); }
.spark > i:last-child { background: var(--color-primary); }
@keyframes spark-in { from { transform: scaleY(0); } }

/* #10 States: skeleton (no shimmer), labelled progress, empty and error panels. */
.skeleton-tile { border-radius: var(--tile-r, 24px); background: var(--color-surface-high, var(--color-base-300)); min-height: 5rem; }
.skeleton-tile.pulse { animation: sk-pulse 1.4s ease-in-out infinite; }
@keyframes sk-pulse { 50% { opacity: .6; } }
.state-panel { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; padding: 1.5rem 1rem; border-radius: 24px; background: var(--color-base-100); }
.state-panel .state-why { font-size: .875rem; color: color-mix(in oklab, var(--color-base-content) 75%, transparent); max-width: 32ch; }

/* #6 Celebrations. Tier 1 tick <=180ms; tier 2 milestone <=1s, 8 particles; Reduce Motion = static badge. */
.cel-tick { animation: cel-pop 180ms var(--ease-spatial, ease-out) both; }
@keyframes cel-pop { 40% { transform: scale(1.12); } }
.cel-milestone { position: relative; display: inline-flex; }
.cel-milestone > b { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 9999px; background: var(--color-primary); opacity: 0;
    animation: cel-burst 900ms var(--ease-spatial, ease-out) both; animation-delay: calc(var(--k) * 12ms);
    --a: calc(var(--k) * 45deg); }
@keyframes cel-burst { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-34px); } }
.cel-badge { display: none; }
@media (prefers-reduced-motion: reduce) {
    .ring, .seg-bar > i.on, .spark > i, .cel-tick, .skeleton-tile.pulse { animation: none; }
    .cel-milestone > b { display: none; }
    .cel-badge { display: inline-flex; }
}

/* #7 Pathway segmented list. Unit capsule r28 / 12px padding / 2px gaps; leaves r16 (28 - 12), min 48px, the
   only interactive-looking rows; headers are plain disclosure buttons; current leaf morphs to r8 with a rail. */
.unit-capsule { background: var(--color-surface-high, var(--color-base-300)); border-radius: 28px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.tree-head { background: none; border: 0; border-radius: 12px; min-height: 36px; cursor: pointer; color: inherit; }
.tree-head:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.tree-leaf { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; border-radius: 16px; width: 100%;
    transition: border-radius var(--duration-base, 280ms) var(--ease-spatial, ease-out); }
.tree-leaf::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: 0; pointer-events: none; transition: opacity var(--duration-fast, 160ms); }
.tree-leaf:hover::before { opacity: .08; }
.tree-item:focus-visible { outline: none; }
.tree-item:focus-visible > .tree-leaf { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.tree-item:focus-visible > .tree-leaf::before, .tree-leaf:active::before { opacity: .12; }
.tree-leaf.is-current { border-radius: 8px; box-shadow: inset 3px 0 0 var(--color-primary);
    background: color-mix(in oklab, var(--color-primary) 16%, var(--color-surface-high, var(--color-base-300))); }
/* 20px status ring: empty = not started, partial arc = in progress, filled check = done. Shape differs per state. */
.tree-status { --ring-p: 0; width: 20px; height: 20px; flex: none; border-radius: 9999px; display: grid; place-items: center; box-sizing: border-box;
    border: 2px solid color-mix(in oklab, var(--color-base-content) 55%, transparent); }
.tree-status > i { display: none; font-size: 12px; line-height: 1; }
.tree-status[data-state="partial"] { border: 0;
    background: conic-gradient(var(--color-primary) calc(var(--ring-p) * 1%), var(--color-surface-highest, var(--color-base-300)) 0);
    -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 calc(100% - 2px)); }
.tree-status[data-state="done"] { border: 0; background: var(--color-primary); color: var(--color-primary-content); }
.tree-status[data-state="done"] > i { display: block; }
@media (prefers-reduced-motion: reduce) { .tree-leaf, .tree-leaf::before { transition: none; } }

/* ── Dodi nudge (bubble beside the tutor launcher) ───────────────────────────── */
.dodi-nudge { position: fixed; right: calc(24px + 64px + 14px); bottom: 22px; z-index: 61; width: max-content; max-width: min(260px, calc(100vw - 120px)); pointer-events: none; }
@media (max-width: 639px) { .dodi-nudge { right: calc(16px + 56px + 12px); bottom: 18px; } }
@media (max-width: 399px) { .dodi-nudge { display: none; } }
.dodi-nudge__bubble { position: relative; pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; gap: 8px; padding: 10px 34px 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.35;
    background: var(--color-surface-high, var(--color-base-300)); color: var(--color-base-content); border: 1px solid color-mix(in srgb, var(--color-base-content) 10%, transparent);
    transform-origin: right bottom; opacity: 0; transform: scale(0.86) translateX(10px); transition: opacity 180ms ease-out, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.dodi-nudge__bubble::after { content: ""; position: absolute; right: -6px; bottom: 20px; width: 12px; height: 12px; transform: rotate(45deg); background: inherit;
    border-right: 1px solid color-mix(in srgb, var(--color-base-content) 10%, transparent); border-top: 1px solid color-mix(in srgb, var(--color-base-content) 10%, transparent); border-radius: 0 3px 0 0; }
.dodi-nudge.is-on .dodi-nudge__bubble { opacity: 1; transform: none; }
.dodi-nudge__text { margin: 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.dodi-nudge__cta { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
    background: color-mix(in srgb, var(--color-primary) 16%, var(--color-surface-high, var(--color-base-300))); color: var(--color-base-content); border: 1px solid color-mix(in srgb, var(--color-primary) 45%, transparent); }
.dodi-nudge__cta:focus-visible, .dodi-nudge__x:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.dodi-nudge__x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 11px; cursor: pointer;
    background: transparent; color: color-mix(in srgb, var(--color-base-content) 60%, transparent); border: 0; }
.dodi-nudge__x:hover { background: color-mix(in srgb, var(--color-base-content) 10%, transparent); }
@media (prefers-reduced-motion: reduce) { .dodi-nudge__bubble { transform: none; transition: opacity 120ms linear; } }
