/* Library home: motion and the interactive parts added in 2026-11 (shared/home.js builds them).
   Hero glow + floating tool icons, quick-search chips, "Surprise me", shelves (My tools / New / Popular),
   the sign-in welcome bar, card reveal + tilt + save-heart, the numbers strip and the back-to-search button.
   Motion uses only transform/opacity; "prefers-reduced-motion" (shared/edu.css) switches all of it off. */

/* ---------- hero ---------- */
.lib-hero { position: relative; isolation: isolate; padding-top: 26px; }
.hero-fx { position: absolute; inset: -12px -16px 0; z-index: -1; pointer-events: none; overflow: hidden; border-radius: 28px; }
.hero-fx .blob { position: absolute; width: 46%; aspect-ratio: 1; border-radius: 50%; opacity: .55; will-change: transform; }
.hero-fx .b1 { inset-inline-start: -8%; top: -42%; background: radial-gradient(closest-side, color-mix(in srgb, var(--primary) 34%, transparent), transparent); animation: hero-drift 19s ease-in-out infinite alternate; }
.hero-fx .b2 { inset-inline-end: -10%; top: -30%; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 30%, transparent), transparent); animation: hero-drift 23s ease-in-out -6s infinite alternate-reverse; }
.hero-fx .b3 { inset-inline-start: 28%; top: 18%; width: 40%; background: radial-gradient(closest-side, color-mix(in srgb, var(--c3) 22%, transparent), transparent); animation: hero-drift 27s ease-in-out -11s infinite alternate; }
@keyframes hero-drift { from { transform: translate3d(-6%, -4%, 0) scale(1); } to { transform: translate3d(8%, 10%, 0) scale(1.18); } }

/* floating tool icons around the hero (wide screens only): each one opens that tool */
.hero-orbit { display: none; }
@media (min-width: 1100px) and (hover: hover) {
  .hero-orbit { display: block; position: absolute; inset: 0; pointer-events: none; }
  .orb { position: absolute; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; font-size: 1.6rem; line-height: 1; text-decoration: none;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); pointer-events: auto;
    animation: orb-in .6s cubic-bezier(.2, .8, .2, 1) both, orb-float 6s ease-in-out infinite alternate; transition: box-shadow .2s, border-color .2s; }
  .orb:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); animation-play-state: running, paused; }
  .orb::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); inset-inline-start: 50%; transform: translateX(-50%) translateY(-4px); white-space: nowrap; max-width: 230px; overflow: hidden; text-overflow: ellipsis;
    background: var(--text); color: var(--bg); font-size: .78rem; font-weight: 700; padding: 4px 9px; border-radius: 7px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 3; }
  [dir="rtl"] .orb::after { transform: translateX(50%) translateY(-4px); }
  .orb:hover::after { opacity: 1; transform: translateX(-50%); }
  [dir="rtl"] .orb:hover::after { transform: translateX(50%); }
  .orb:nth-child(1) { inset-inline-start: 1%; top: 10%; animation-delay: .05s, -1s; }
  .orb:nth-child(2) { inset-inline-start: 7.5%; top: 47%; animation-delay: .15s, -3s; animation-duration: .6s, 7.5s; }
  .orb:nth-child(3) { inset-inline-start: 0; top: 80%; animation-delay: .25s, -2s; animation-duration: .6s, 5.5s; }
  .orb:nth-child(4) { inset-inline-start: 13%; top: 14%; animation-delay: .35s, -4s; animation-duration: .6s, 8s; }
  .orb:nth-child(5) { inset-inline-end: 1%; top: 12%; animation-delay: .1s, -2.5s; animation-duration: .6s, 7s; }
  .orb:nth-child(6) { inset-inline-end: 7.5%; top: 50%; animation-delay: .2s, -.5s; }
  .orb:nth-child(7) { inset-inline-end: 0; top: 82%; animation-delay: .3s, -3.5s; animation-duration: .6s, 8.5s; }
  .orb:nth-child(8) { inset-inline-end: 13%; top: 16%; animation-delay: .4s, -1.5s; animation-duration: .6s, 5s; }
}
@keyframes orb-in { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }
@keyframes orb-float { from { translate: 0 -7px; rotate: -4deg; } to { translate: 0 8px; rotate: 5deg; } }

.lib-kicker { animation: fx-up .5s .05s both; }
.lib-hero h1 { animation: fx-up .5s .1s both; }
.lib-hero h1 b { display: inline-block; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lib-sub { animation: fx-up .5s .16s both; }
.lib-search { animation: fx-up .5s .22s both; transition: border-color .15s, box-shadow .2s, transform .2s; }
.lib-search:focus-within { box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 16%, transparent), var(--shadow-lg); transform: translateY(-1px); }
.lib-search kbd { align-self: center; margin-inline-end: 10px; color: var(--muted); font-size: .8rem; }
@media (max-width: 760px), (hover: none) { .lib-search kbd { display: none; } }
@keyframes fx-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* quick searches + "Surprise me" */
.lib-quick { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; max-width: 760px; margin: 12px auto 0; animation: fx-up .5s .28s both; }
.lib-quick .q-label { color: var(--muted); font-size: .86rem; font-weight: 700; }
.lib-quick .chip { padding: 5px 12px; font-size: .86rem; background: color-mix(in srgb, var(--surface) 80%, transparent); }
.lib-quick .chip:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.lib-quick .chip[aria-pressed="true"]:hover { color: var(--primary-ink); }
.q-dice { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)) !important; background: var(--accent-soft) !important; color: var(--text) !important; }
.q-dice .die { display: inline-block; transition: transform .5s cubic-bezier(.2, .8, .2, 1.3); }
.q-dice:hover .die { transform: rotate(180deg) scale(1.15); }
@media (max-width: 600px) {
  .lib-quick { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 10px -16px 0; padding: 0 16px 2px; }
  .lib-quick::-webkit-scrollbar { display: none; }
  .lib-quick > * { flex: none; }
}

/* surprise dialog */
.sp { text-align: center; padding: 6px 4px 2px; }
.sp-ic { font-size: 4rem; line-height: 1.1; height: 4.6rem; display: grid; place-items: center; }
.sp-ic.rolling { animation: sp-roll .14s linear infinite; }
@keyframes sp-roll { from { transform: translateY(-8px) rotate(-6deg); opacity: .5; } to { transform: translateY(8px) rotate(6deg); opacity: 1; } }
.sp-ic.landed { animation: sp-land .45s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes sp-land { from { transform: scale(.5); } to { transform: none; } }
.sp h3 { font-size: 1.3rem; margin: 6px 0 4px; }
.sp p { color: var(--muted); margin: 0 auto 14px; max-width: 46ch; min-height: 3em; }
.sp .row { justify-content: center; }

/* ---------- welcome / sign-in bar ---------- */
.welcome { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 14px auto 0; max-width: 860px; padding: 9px 10px 9px 16px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); background: linear-gradient(100deg, var(--primary-soft), color-mix(in srgb, var(--accent-soft) 70%, var(--surface)));
  animation: fx-up .5s .34s both; }
.welcome .w-ic { font-size: 1.35rem; line-height: 1; animation: w-wave 2.4s ease-in-out 1s 2; transform-origin: 70% 80%; }
@keyframes w-wave { 0%, 60%, 100% { transform: none; } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-10deg); } }
.welcome .w-txt { flex: 1 1 240px; min-width: 0; margin: 0; font-weight: 600; font-size: .95rem; }
.welcome .w-proof { display: block; font-weight: 500; color: var(--muted); font-size: .82rem; }
.welcome .btn { flex: none; }
.welcome .w-x { flex: none; width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); border-radius: 50%; cursor: pointer; font-size: 1rem; }
.welcome .w-x:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); }
@media (max-width: 600px) { .welcome { padding: 9px 8px 9px 12px; gap: 8px; } .welcome .w-txt { flex-basis: calc(100% - 80px); font-size: .9rem; } .welcome .btn { order: 3; } .welcome .w-x { margin-inline-start: auto; } }

/* ---------- shelves: My tools · New · Popular ---------- */
.shelves { margin: 18px 0 2px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.shelf { min-width: 0; }
.shelf h2 { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; margin: 0 0 8px; }
.shelf h2 .sh-hint { font-weight: 500; font-size: .8rem; color: var(--muted); }
.shelf-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--border) transparent; -webkit-overflow-scrolling: touch; }
@media (max-width: 760px) { .shelf-row { margin: 0 -16px; padding-inline: 16px; scroll-padding-inline: 16px; scrollbar-width: none; } .shelf-row::-webkit-scrollbar { display: none; } }
.mini { position: relative; flex: none; scroll-snap-align: start; display: flex; align-items: center; gap: 10px; width: 232px; min-height: 60px; padding: 9px 12px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; box-shadow: 0 1px 2px rgba(20, 30, 35, .04);
  transition: transform .16s, box-shadow .16s, border-color .16s; }
.mini:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--cat, var(--primary)) 55%, var(--border)); box-shadow: var(--shadow); }
.mini .m-ic { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.35rem; line-height: 1;
  background: color-mix(in srgb, var(--cat, var(--primary)) 14%, var(--surface)); transition: transform .25s cubic-bezier(.2, .8, .2, 1.4); }
.mini:hover .m-ic { transform: scale(1.12) rotate(-6deg); }
.mini .m-t { min-width: 0; font-weight: 700; font-size: .9rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini .m-new { position: absolute; top: -7px; inset-inline-end: 10px; font-size: .64rem; font-weight: 800; letter-spacing: .04em; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff; }
:root[lang="ur"] .mini .m-t, :root[lang="ur"] .shelf h2 { line-height: 2; }

/* ---------- the grid: reveal, tilt, save-heart ---------- */
.apps > .app-cell { position: relative; display: flex; min-width: 0; }
.app-cell > .app-card { flex: 1 1 auto; min-width: 0; }
.app-cell.rv { opacity: 0; transform: translateY(18px) scale(.985); }
.app-cell.rv.in { opacity: 1; transform: none; transition: opacity .45s ease-out, transform .5s cubic-bezier(.2, .8, .2, 1); transition-delay: var(--d, 0ms); }
.app-card { overflow: hidden; }
.app-card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--cat, var(--primary)) 16%, transparent), transparent 70%); }
.app-card:hover::before { opacity: 1; }
.app-card > * { position: relative; }
.app-card .ic { display: inline-block; transition: transform .3s cubic-bezier(.2, .8, .2, 1.5); }
.app-card:hover .ic { transform: scale(1.25) rotate(-8deg); }
.app-card .app-open span[aria-hidden] { display: inline-block; transition: transform .2s; }
.app-card:hover .app-open span[aria-hidden] { transform: translate(2px, -2px); }
@media (hover: hover) and (pointer: fine) {
  .app-cell.tilt > .app-card { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-3px); transition: transform .08s linear, box-shadow .15s, border-color .15s; }
}
.app-fav { position: absolute; top: 9px; inset-inline-end: 50%; margin-inline-end: -17px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer; display: grid; place-items: center; opacity: .55; transition: opacity .15s, background .15s, color .15s, transform .15s; }
.app-cell:hover .app-fav, .app-fav:focus-visible, .app-fav[aria-pressed="true"] { opacity: 1; }
.app-fav:hover { background: var(--accent-soft); color: var(--accent); transform: scale(1.12); }
.app-fav[aria-pressed="true"] { color: var(--accent); }
.app-fav.pop { animation: edu-star .4s ease-out; }
mark.hit { background: color-mix(in srgb, var(--accent) 26%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- numbers strip ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 40px; }
.stat { text-align: center; padding: 18px 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.stat b { display: block; font-size: clamp(1.5rem, 4vw, 2.3rem); line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--primary); }
.stat:nth-child(2) b { color: var(--accent); } .stat:nth-child(3) b { color: var(--c3); } .stat:nth-child(4) b { color: var(--success); }
.stat span { display: block; margin-top: 4px; color: var(--muted); font-weight: 600; font-size: .88rem; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; } }

/* sections lower on the page fade up as they come into view */
.fx-rise { opacity: 0; transform: translateY(22px); }
.fx-rise.in { opacity: 1; transform: none; transition: opacity .6s ease-out, transform .6s cubic-bezier(.2, .8, .2, 1); }

/* ---------- back to search ---------- */
.to-top { position: fixed; inset-inline-end: 18px; bottom: 18px; z-index: 40; display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(16px) scale(.9); pointer-events: none; transition: opacity .2s, transform .25s cubic-bezier(.2, .8, .2, 1.3); }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--primary-hover); }
@media (max-width: 600px) { .to-top { inset-inline-end: 12px; bottom: 12px; padding: 0 14px; } .to-top .tt-txt { display: none; } }
@media print { .to-top, .welcome, .hero-fx, .lib-quick, .app-fav { display: none !important; } .app-cell.rv, .fx-rise { opacity: 1 !important; transform: none !important; } }
