/* ---------- visual polish (v0.7.31+): depth tokens, mesh background, card tiers, motion scale ---------- */
:root {
  --surface-0: var(--bg); --surface-1: var(--panel); --surface-2: color-mix(in srgb, var(--panel) 88%, var(--brand));
  --shadow-1: 0 1px 2px rgba(60, 40, 140, .06), 0 4px 12px rgba(60, 40, 140, .06);
  --shadow-2: 0 2px 4px rgba(60, 40, 140, .06), 0 12px 28px rgba(60, 40, 140, .12);
  --shadow-3: 0 4px 8px rgba(60, 40, 140, .08), 0 24px 60px rgba(60, 40, 140, .18);
  --glow-brand: 0 0 0 0 transparent;
  --mesh-1: color-mix(in srgb, var(--brand) 14%, transparent);
  --mesh-2: color-mix(in srgb, var(--pink) 10%, transparent);
  --mesh-3: color-mix(in srgb, var(--teal) 10%, transparent);
  --glass: color-mix(in srgb, var(--panel) 78%, transparent);
  --dur-1: .15s; --dur-2: .3s; --dur-3: .6s;
  --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 32px rgba(0, 0, 0, .4);
    --shadow-3: 0 4px 10px rgba(0, 0, 0, .35), 0 28px 70px rgba(0, 0, 0, .5);
    --glow-brand: 0 0 32px color-mix(in srgb, var(--brand) 35%, transparent);
    --mesh-1: color-mix(in srgb, var(--brand) 22%, transparent);
    --mesh-2: color-mix(in srgb, var(--pink) 12%, transparent);
    --mesh-3: color-mix(in srgb, var(--teal) 10%, transparent);
  }
}
:root[data-theme="dark"] {
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 32px rgba(0, 0, 0, .4);
  --shadow-3: 0 4px 10px rgba(0, 0, 0, .35), 0 28px 70px rgba(0, 0, 0, .5);
  --glow-brand: 0 0 32px color-mix(in srgb, var(--brand) 35%, transparent);
  --mesh-1: color-mix(in srgb, var(--brand) 22%, transparent);
  --mesh-2: color-mix(in srgb, var(--pink) 12%, transparent);
  --mesh-3: color-mix(in srgb, var(--teal) 10%, transparent);
}

/* soft gradient mesh behind everything (fixed layer, so it never repaints on scroll) */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 45vmax at 85% -10%, var(--mesh-1), transparent 70%),
    radial-gradient(50vmax 40vmax at -10% 30%, var(--mesh-2), transparent 70%),
    radial-gradient(55vmax 45vmax at 70% 110%, var(--mesh-3), transparent 70%);
}
.sidebar { background: color-mix(in srgb, var(--bg2) 82%, transparent); backdrop-filter: blur(14px); }

/* ---------- card tiers: hero (one focal point) > primary > default > quiet ---------- */
.card { box-shadow: var(--shadow-1); border-color: color-mix(in srgb, var(--line) 80%, transparent); }
.action-card { transition: transform var(--dur-1) var(--ease-out), border-color var(--dur-1), box-shadow var(--dur-2) var(--ease-out); }
.action-card:hover { box-shadow: var(--shadow-2); }

.hero { box-shadow: var(--shadow-3), var(--glow-brand); }
.hero::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(80% 120% at 0% 0%, rgba(255, 255, 255, .22), transparent 55%); }
.hero h1 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -.025em; }
.hero > * { position: relative; }

.next-step { box-shadow: var(--shadow-2), var(--glow-brand); }

.progress-note, .tipbox { background: color-mix(in srgb, var(--panel) 55%, transparent); box-shadow: none; border-style: dashed; }
.progress-note { font-size: 14px; color: var(--ink2); padding: 16px 18px; }
.progress-note > b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: color-mix(in srgb, var(--brand) var(--am), var(--ink)); margin-bottom: 2px; }
.progress-note p { margin: 6px 0; }
.progress-note > p:first-of-type { color: var(--ink); font-weight: 700; }
.progress-note details { margin-top: 8px; }
.progress-note summary { display: inline-block; cursor: pointer; font-weight: 800; font-size: 13px; padding: 4px 12px; border-radius: 99px; background: var(--soft); color: var(--ink); }
.progress-note details[open] summary { margin-bottom: 4px; }

/* display type: section headings get a small brand accent */
.section-title h2 { font-size: 21px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.section-title h2::before { content: ''; width: 8px; height: 8px; border-radius: 3px; flex: none; background: linear-gradient(135deg, var(--brand), var(--pink)); }

/* ---------- empty progress bars: an inviting track instead of a dead grey line ---------- */
:is(.action-card, .course-head, .unit-card) .bar:has(> i[style^="width:0%"]) {
  background: repeating-linear-gradient(-45deg, var(--soft) 0 8px, color-mix(in srgb, var(--brand) 12%, var(--soft)) 8px 16px);
  background-size: 200% 100%; animation: barIdle 6s linear infinite;
}
@keyframes barIdle { to { background-position: -45px 0; } }

/* ---------- Jump-to tiles: break only at the slashes, never mid-word ---------- */
.jump a > span:last-child { overflow-wrap: normal; }

/* ---------- Carby's speech bubble: glassy, and on phone pinned under the top bar inside the gutters ---------- */
.cb-bubble { background: color-mix(in srgb, var(--panel) 96%, transparent); backdrop-filter: blur(12px); box-shadow: var(--shadow-3); border-color: color-mix(in srgb, var(--brand) 70%, transparent); }
@media (max-width: 640px) {
  #carby-buddy { position: static; }
  .cb-bubble { top: calc(100% + 6px); left: 10px; right: 10px; width: auto; max-width: none; font-size: 13px; padding: 9px 12px; }
  .cb-bubble::before { left: 22px; }
}

/* ---------- Home hero (v0.7.32): drifting gradient, molecules, big waving Carby, next step as the main button ---------- */
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
.hero2 { grid-template-columns: auto 1fr; grid-template-areas: "carby main" "next next"; gap: 14px 26px; padding: 26px 28px 24px; background-size: 220% 220%; animation: hero-pan 18s ease-in-out infinite alternate; }
.hero2::after { animation: hero-spin 40s linear infinite; }
.hero2 > :not(.hero-mols) { position: relative; z-index: 1; }
.hero2 .mascot { animation: none; }
.hero2 h1 { font-size: 34px; }
.hero-main { grid-area: main; min-width: 0; }
.hero-carby { grid-area: carby; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,255,255,.34), rgba(255,255,255,0)); filter: drop-shadow(0 8px 14px rgba(20,10,60,.28)); }
.hero-carby .c2-shadow { display: inline; }
.hero-carby .c2-bob { animation: c2bob 3s ease-in-out infinite; }
.hero-carby .armR { animation: hero-wave 9s ease-in-out .7s infinite; }
.hero-mols { position: absolute; inset: 0; pointer-events: none; color: #fff; z-index: 0; }
.hero-mols .hm { position: absolute; width: 70px; opacity: .17; animation: hm-drift 22s ease-in-out infinite alternate; }
.hero-mols .hm0 { left: 42%; top: -14px; width: 92px; }
.hero-mols .hm1 { right: 6%; top: 34%; animation-duration: 27s; animation-delay: -6s; }
.hero-mols .hm2 { left: 3%; bottom: -10px; width: 58px; animation-duration: 19s; animation-delay: -3s; }
.hero-mols .hm3 { left: 62%; bottom: 22%; width: 84px; animation-duration: 31s; animation-delay: -12s; }
.hero-mols .hm4 { right: 24%; top: 6%; width: 46px; animation-duration: 24s; animation-delay: -9s; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.hero .ring.sm { width: 74px; height: 74px; --c: #fff; background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255,255,255,.22) 0); }
.hero .ring.sm::before { inset: 6px; background: rgba(30,14,80,.32); }
.hero .ring.sm > span { font-size: 18px; color: #fff; line-height: 1.15; }
.hero .ring.sm > span small { font-size: 9.5px; color: rgba(255,255,255,.85); letter-spacing: .02em; line-height: 1.2; margin-top: 1px; }
.ring.count { animation: ring-fill 1.1s var(--ease-out) .15s both; }
.hero2 .next-step { grid-area: next; margin-top: 4px; background: var(--panel); border-color: transparent; box-shadow: var(--shadow-3); }
.hero2 .next-step:hover { transform: translateY(-3px); box-shadow: var(--shadow-3), 0 0 0 3px rgba(255,255,255,.55); }
.hero2 .next-step .btn.primary { animation: cta-pulse 2.8s ease-in-out 1.5s infinite; }
@keyframes hero-pan { from { background-position: 0% 30%; } to { background-position: 100% 70%; } }
@keyframes hero-spin { to { transform: rotate(390deg); } }
@keyframes hm-drift { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(18px, -14px) rotate(14deg); } 100% { transform: translate(-12px, 10px) rotate(-10deg); } }
@keyframes hero-wave { 0%, 3% { transform: rotate(0); } 6% { transform: rotate(-115deg); } 9% { transform: rotate(-88deg); } 12% { transform: rotate(-120deg); } 15% { transform: rotate(-88deg); } 18% { transform: rotate(-115deg); } 22%, 100% { transform: rotate(0); } }
@keyframes ring-fill { from { --p: 0; } }
@keyframes cta-pulse { 0%, 100% { box-shadow: 0 4px 0 var(--brand-d), 0 0 0 0 color-mix(in srgb, var(--brand) 45%, transparent); } 50% { box-shadow: 0 4px 0 var(--brand-d), 0 0 0 9px color-mix(in srgb, var(--brand) 0%, transparent); } }
@media (max-width: 640px) {
  .hero2 { gap: 12px 14px; padding: 18px 16px; }
  .hero-carby { width: 92px; height: 92px; align-self: start; }
  .hero2 h1 { font-size: 23px; }
  .hero-stats { gap: 8px; }
  .hero .ring.sm { width: 64px; height: 64px; }
  .hero .ring.sm > span { font-size: 16px; }
  .hero .ring.sm > span small { font-size: 8.5px; }
  .hero-mols .hm { width: 48px; }
}

/* ---------- motion safety ---------- */
@media (prefers-reduced-motion: reduce) {
  :is(.action-card, .course-head, .unit-card) .bar:has(> i[style^="width:0%"]) { animation: none; }
  .hero2, .hero2::after, .hero-mols .hm, .hero-carby .c2-bob, .hero-carby .armR, .ring.count, .hero2 .next-step .btn.primary { animation: none; }
}
