/* Lesson page extras: modern nav, side rails (mission map + Pip the Python),
   floating code background, confetti and reaction toasts. */
:root { --fun-navy: #0b2239; --fun-amber: #f59e0b; --fun-teal: #0d9488; --fun-coral: #f2777a; }

/* ---------- nav ---------- */
.fnav { position: sticky; top: 0; z-index: 60; background: rgba(255,255,255,.86); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(0,0,0,.07); }
.fnav-in { max-width: 1280px; margin: 0 auto; height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 18px; font-family: Inter, system-ui, sans-serif; font-size: 14px; }
.fnav-brand { display: flex; align-items: center; gap: 10px; color: #1c1917; text-decoration: none; font-weight: 700; font-family: Fraunces, Georgia, serif; font-size: 17px; }
.fnav-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #fff; font-size: 13px; background: linear-gradient(135deg, #b45309, #0d9488); }
.fnav-links { display: flex; gap: 4px; flex: 1; }
.fnav a.fnav-link { color: #57534e; text-decoration: none; padding: 7px 12px; border-radius: 8px; transition: background .15s, color .15s; }
.fnav a.fnav-link:hover { background: #fff7ed; color: #1c1917; }
.fnav-right { display: flex; align-items: center; gap: 8px; }
.fnav-bell { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; color: #57534e; text-decoration: none; }
.fnav-bell:hover { background: #fff7ed; }
.fnav-badge { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 10px; display: grid; place-items: center; }
.fnav-xp { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: linear-gradient(135deg, #fef3c7, #fde68a); color: #78350f; font-weight: 700; font-size: 13px; }
.fnav-out { background: none; border: 1px solid #e7e5e4; border-radius: 999px; padding: 6px 14px; color: #57534e; cursor: pointer; font: inherit; }
.fnav-out:hover { border-color: #b45309; color: #b45309; }
@media (max-width: 700px) { .fnav-links { display: none; } .fnav-name { display: none; } .fnav-in { justify-content: space-between; } }

/* ---------- floating code background ---------- */
.fun-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.fun-glyph { position: absolute; bottom: -60px; font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; opacity: .13; animation: fun-rise linear infinite; white-space: nowrap; }
@keyframes fun-rise { to { transform: translateY(-115vh) rotate(25deg); } }
body.lesson-doc > header, body.lesson-doc > .bar, body.lesson-doc > .wrap { position: relative; z-index: 1; }
body.lesson-doc > .fnav { position: sticky; z-index: 60; }

/* ---------- side rails ---------- */
.rail { display: none; }
@media (min-width: 1340px) {
  .rail { display: block; position: fixed; top: 84px; z-index: 5; width: clamp(210px, calc((100vw - 880px) / 2 - 44px), 300px); max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: none; font-family: Inter, system-ui, sans-serif; }
  .rail::-webkit-scrollbar { display: none; }
  .rail-left { left: max(16px, calc(50vw - 440px - 22px - clamp(210px, calc((100vw - 880px) / 2 - 44px), 300px))); }
  .rail-right { right: max(16px, calc(50vw - 440px - 22px - clamp(210px, calc((100vw - 880px) / 2 - 44px), 300px))); }
}
.rcard { background: rgba(255,255,255,.92); border: 1px solid #efe6da; border-radius: 18px; padding: 16px; box-shadow: 0 14px 34px -24px rgba(11,34,57,.45); margin-bottom: 14px; backdrop-filter: blur(6px); }
.rtitle { margin: 0 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #b45309; }

/* progress ring */
.ring-wrap { display: flex; align-items: center; gap: 14px; }
.rail .ring-label { position: relative; width: 86px; height: 86px; flex: none; }
.rail svg.ring { display: block; width: 86px !important; height: 86px !important; max-width: none; }
.ring { width: 86px; height: 86px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .ring-bg { stroke: #f5efe6; }
.ring .ring-fg { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.22,1,.36,1); }
.ring-label { position: relative; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 19px; color: #1c1917; }
.rstats { display: grid; gap: 4px; font-size: 13px; color: #57534e; }
.rstats b { color: #1c1917; font-size: 15px; }

/* mission map */
.map { list-style: none; margin: 0; padding: 0; position: relative; }
.map::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: #f1e8dc; }
.map li { position: relative; }
.map a { display: flex; gap: 10px; align-items: flex-start; padding: 6px 6px 6px 0; border-radius: 10px; color: #57534e; text-decoration: none; font-size: 13px; line-height: 1.35; transition: color .15s, background .15s; }
.map a:hover { color: #1c1917; background: #fff7ed; }
.map .dot { position: relative; z-index: 1; flex: none; width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: #fff; border: 2px solid #e7dccd; color: #a8a29e; transition: all .3s; }
.map li.is-current a { color: #1c1917; font-weight: 600; }
.map li.is-current .dot { border-color: var(--fun-amber); color: #b45309; box-shadow: 0 0 0 4px rgba(245,158,11,.18); animation: fun-pulse 1.6s ease-in-out infinite; }
.map li.is-seen .dot { background: var(--fun-teal); border-color: var(--fun-teal); color: #fff; }
@keyframes fun-pulse { 50% { box-shadow: 0 0 0 7px rgba(245,158,11,.05); } }

/* Pip the Python */
.pip-card { text-align: center; background: linear-gradient(160deg, #0b2239, #123a5a 60%, #0e4f5c); color: #f8fafc; border: 0; }
.pip-card .rtitle { color: #fcd34d; }
.pip { width: 140px; height: 120px; margin: 0 auto; display: block; animation: pip-bob 3s ease-in-out infinite; transform-origin: 50% 90%; }
.pip.is-happy { animation: pip-jump .6s ease 2; }
.pip.is-sad { animation: pip-shake .5s ease 1; }
.pip .eye-lid { transform-box: fill-box; transform-origin: center; animation: pip-blink 4.5s infinite; }
.pip .tongue { transform-box: fill-box; transform-origin: left center; animation: pip-tongue 3.2s infinite; }
@keyframes pip-bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
@keyframes pip-jump { 40% { transform: translateY(-22px) scale(1.06); } }
@keyframes pip-shake { 25% { transform: translateX(-7px) rotate(-4deg); } 75% { transform: translateX(7px) rotate(4deg); } }
@keyframes pip-blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
@keyframes pip-tongue { 0%, 70%, 100% { transform: scaleX(0); } 78%, 86% { transform: scaleX(1); } }
.bubble { position: relative; margin: 6px 4px 0; padding: 10px 12px; border-radius: 14px; background: #fff; color: #1c1917; font-size: 13.5px; line-height: 1.4; min-height: 40px; transition: transform .25s; }
.bubble::before { content: ""; position: absolute; top: -7px; left: 50%; margin-left: -7px; border: 7px solid transparent; border-top: 0; border-bottom-color: #fff; }
.bubble.pop { animation: bubble-pop .35s ease; }
@keyframes bubble-pop { 50% { transform: scale(1.06); } }

/* fun fact */
.fact { font-size: 13.5px; line-height: 1.5; color: #44403c; min-height: 60px; transition: opacity .35s; }
.fact-next { margin-top: 8px; background: none; border: 0; padding: 0; color: #0d9488; font-weight: 600; font-size: 12.5px; cursor: pointer; }

/* badges */
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge { aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: #f5f5f4; filter: grayscale(1); opacity: .45; transition: all .4s; cursor: default; }
.badge.on { filter: none; opacity: 1; background: linear-gradient(135deg, #fef3c7, #fde68a); box-shadow: 0 8px 18px -10px rgba(245,158,11,.9); animation: badge-in .6s ease; }
@keyframes badge-in { 0% { transform: scale(.4) rotate(-20deg); } 70% { transform: scale(1.15) rotate(6deg); } }

/* ---------- toasts (all screen sizes) ---------- */
.fun-toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 10px; border-radius: 999px; background: #0b2239; color: #fff; font: 600 14px Inter, system-ui, sans-serif; box-shadow: 0 18px 40px -16px rgba(0,0,0,.5); transform: translate(-50%, 140%); transition: transform .4s cubic-bezier(.22,1,.36,1); }
.fun-toast.show { transform: translate(-50%, 0); }
.fun-toast .ft-emoji { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; background: #fde68a; font-size: 18px; }
.xp-fly { position: fixed; z-index: 85; pointer-events: none; font: 800 18px Inter, system-ui, sans-serif; color: #b45309; text-shadow: 0 2px 0 #fff; animation: xp-fly 1.1s ease-out forwards; }
@keyframes xp-fly { to { transform: translateY(-70px); opacity: 0; } }
.fun-confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; }

/* ---------- answer reactions ---------- */
.fx-layer { position: fixed; inset: 0; z-index: 88; pointer-events: none; overflow: hidden; }
.fx-p { position: absolute; line-height: 1; animation-timing-function: ease-in; animation-fill-mode: both; }
.fx-fall { top: -40px; animation-name: fx-fall; }
.fx-rise { bottom: -50px; animation-name: fx-rise; animation-timing-function: ease-out; }
.fx-burst { animation-name: fx-burst; animation-timing-function: cubic-bezier(.2,.8,.3,1); }
@keyframes fx-fall { to { transform: translate(var(--sway), 110vh) rotate(200deg); } }
@keyframes fx-rise { 90% { opacity: 1; } to { transform: translate(var(--sway), -115vh); opacity: 0; } }
@keyframes fx-burst { 0% { transform: translate(-50%,-50%) scale(.2); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(180deg); opacity: 0; } }

.fx-rain-tint { background: linear-gradient(180deg, rgba(59,130,246,.16), transparent 70%); animation: fx-fade 2.6s ease forwards; }
.fx-sun { animation: fx-fade 2.6s ease forwards; background: radial-gradient(circle at 50% 0%, rgba(253,224,71,.45), rgba(253,224,71,.08) 45%, transparent 70%); }
.fx-rays { position: absolute; left: 50%; top: -60vmax; width: 120vmax; height: 120vmax; margin-left: -60vmax; border-radius: 50%;
  background: repeating-conic-gradient(rgba(253,224,71,.28) 0 8deg, transparent 8deg 20deg); animation: fx-spin 2.6s linear; }
.fx-sunface { position: absolute; left: 50%; top: 12vh; font-size: 90px; transform: translateX(-50%); animation: fx-sunpop 2.6s ease; }
.fx-rainbow { animation: fx-fade 2.6s ease forwards; }
.fx-rainbow::before { content: ""; position: absolute; left: 50%; bottom: -70vmin; width: 140vmin; height: 140vmin; margin-left: -70vmin; border-radius: 50%;
  background: radial-gradient(circle, transparent 54%, #ef4444 54% 56%, #f97316 56% 58%, #facc15 58% 60%, #22c55e 60% 62%, #3b82f6 62% 64%, #8b5cf6 64% 66%, transparent 66%);
  opacity: .55; animation: fx-grow 2.6s ease; }
@keyframes fx-grow { 0% { transform: translateY(30vmin) scale(.7); } 30%, 100% { transform: none; } }
@keyframes fx-fade { 0% { opacity: 0; } 15%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fx-spin { to { transform: rotate(40deg); } }
@keyframes fx-sunpop { 0% { transform: translateX(-50%) scale(.3) translateY(40px); opacity: 0; } 25% { transform: translateX(-50%) scale(1.1); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }

.fx-red { box-shadow: inset 0 0 120px 20px rgba(239,68,68,.35); animation: fx-fade 1.2s ease forwards; }
.fx-grey { background: linear-gradient(180deg, rgba(100,116,139,.28), transparent 60%); animation: fx-fade 1.2s ease forwards; }
.fx-kitty { inset: auto auto 90px 50%; overflow: visible; display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 12px; border-radius: 999px;
  background: #fff1f2; border: 2px solid #fda4af; color: #9f1239; font: 600 15px Inter, system-ui, sans-serif; box-shadow: 0 18px 40px -16px rgba(190,18,60,.45);
  white-space: nowrap; animation: fx-kitty 3s cubic-bezier(.22,1,.36,1) forwards; }
.fx-kface { font-size: 42px; line-height: 1; display: inline-block; animation: fx-tilt .9s ease-in-out 3; }
@keyframes fx-kitty { 0% { transform: translate(-50%, 160px); } 12%, 85% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, 30px); opacity: 0; } }
@keyframes fx-tilt { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.fx-shake { animation: fx-shake .45s ease; }
@keyframes fx-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (max-width: 520px) { .fx-kitty { white-space: normal; width: calc(100vw - 32px); font-size: 14px; } }

@media not all {
  .fun-glyph, .pip, .pip .eye-lid, .pip .tongue, .map li.is-current .dot { animation: none !important; }
  .fun-bg { display: none; }
}
@media print { .rail, .fun-bg, .fun-toast, .fnav { display: none !important; } }

/* ---------- dock: extras tucked behind hover buttons ---------- */
.fun-dock { position: fixed; left: 16px; bottom: 16px; z-index: 40; display: flex; flex-direction: column; gap: 8px; font-family: Inter, system-ui, sans-serif; }
.dock-item { position: relative; }
.dock-btn { width: 42px; height: 42px; border-radius: 999px; border: 1px solid #ece3d6; background: #fff; font-size: 19px; cursor: pointer; box-shadow: 0 6px 18px -10px rgba(0,0,0,.35); transition: transform .15s; }
.dock-btn:hover, .dock-item.open .dock-btn { transform: scale(1.08); border-color: var(--fun-amber, #f59e0b); }
.dock-pop { position: absolute; left: 52px; bottom: 0; width: 270px; max-height: 70vh; overflow-y: auto; opacity: 0; visibility: hidden; transform: translateX(-6px); transition: opacity .15s, transform .15s, visibility .15s; }
.dock-pop::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 12px; } /* hover bridge */
.dock-item.open .dock-pop { opacity: 1; visibility: visible; transform: none; }
@media (hover: hover) { .dock-item:hover .dock-pop, .dock-item:focus-within .dock-pop { opacity: 1; visibility: visible; transform: none; } }
.dock-pop .rail { display: block; position: static; width: auto; max-height: none; }
@media (max-width: 620px) { .dock-pop { width: min(270px, calc(100vw - 84px)); } }
@media print { .fun-dock { display: none !important; } }
.dock-pop .rcard { margin-bottom: 8px; background: #fff; }
