/* Joy, the OffscreenJoy shopping companion. Uses the site's "Kolam" tokens from styles.css. */
.joy-launch { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 36; display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px 6px 6px; min-height: 52px; border: 0; border-radius: 999px; background: var(--ink); color: var(--white); font: 700 .95rem/1 var(--sans); box-shadow: var(--shadow-lg); cursor: pointer; transition: transform .2s ease, opacity .2s ease; }
.joy-launch:hover { transform: translateY(-2px); }
.joy-launch:focus-visible, .joy :focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.joy-launch.wa-up { bottom: calc(152px + env(safe-area-inset-bottom)); }
.joy-launch[hidden] { display: none; }
.joy-launch.joy-tuck { opacity: 0; pointer-events: none; transform: translateY(12px); }
@media (min-width: 900px) { .joy-launch { bottom: 24px; } .joy-launch.wa-up { bottom: 92px; } }
.joy-ava { width: 40px; height: 40px; border-radius: 50%; background: var(--marigold); display: grid; place-items: center; flex: none; }
.joy-ava svg { width: 24px; height: 24px; }
/* Launcher animation (option A): bob, pulsing ring, flickering flame, online dot, alternating text */
.joy-launch { animation: joy-bob 3.2s ease-in-out infinite; padding-right: 18px; box-shadow: 0 10px 26px rgba(36,48,110,.3); }
.joy-launch::before { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 3px solid var(--marigold); opacity: 0; pointer-events: none; animation: joy-ring 2.4s ease-out infinite; }
.joy-launch:hover { animation-play-state: paused; }
.joy-launch.joy-tuck { animation: none; }
.joy-launch .joy-flame { transform-origin: 12px 14px; animation: joy-flicker 1.6s ease-in-out infinite; }
.joy-launch .joy-on { position: absolute; top: 5px; left: 37px; width: 12px; height: 12px; border-radius: 50%; background: #3CC274; border: 2px solid var(--ink); }
.joy-msgs { display: grid; justify-items: start; height: 1.15em; overflow: hidden; }
.joy-msgs b { grid-area: 1 / 1; font-weight: 700; white-space: nowrap; animation: joy-swap 8s ease-in-out infinite; }
.joy-msgs b:nth-child(2) { animation-delay: -4s; }
@keyframes joy-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes joy-ring { 0% { opacity: .9; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.18); } }
@keyframes joy-flicker { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.08, .94) rotate(-3deg); } 60% { transform: scale(.95, 1.06) rotate(3deg); } }
@keyframes joy-swap { 0%, 42% { transform: translateY(0); opacity: 1; } 50%, 92% { transform: translateY(-120%); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
/* Reduce Motion: nothing moves, but the ring still glows softly and the two lines cross-fade */
@media (prefers-reduced-motion: reduce) {
  .joy-launch, .joy-launch .joy-flame { animation: none; }
  /* !important: styles.css switches every animation off under Reduce Motion */
  .joy-launch::before { animation: joy-glow 2.4s ease-in-out infinite !important; }
  .joy-msgs b { animation: joy-fade 8s ease-in-out infinite !important; }
  .joy-msgs b:nth-child(2) { animation-delay: -4s !important; }
}
@keyframes joy-glow { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
@keyframes joy-fade { 0%, 42% { opacity: 1; } 50%, 92% { opacity: 0; } 100% { opacity: 1; } }
.joy-launch .joy-dot { position: absolute; top: 4px; left: 36px; width: 12px; height: 12px; border-radius: 50%; background: var(--cta); border: 2px solid var(--ink); }

.joy-nudge { position: fixed; right: 16px; bottom: calc(146px + env(safe-area-inset-bottom)); z-index: 36; max-width: min(320px, calc(100vw - 32px)); background: var(--white); color: var(--ink); border: 1px solid var(--line); border-radius: 16px 16px 4px 16px; box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: .92rem; line-height: 1.4; display: grid; gap: 10px; animation: joy-pop .25s ease-out; }
.joy-nudge .row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 900px) { .joy-nudge { bottom: 88px; } }

/* Panel: a comfortable side panel on desktop, full screen on phones */
.joy { position: fixed; z-index: 85; right: 16px; bottom: 16px; width: 400px; height: min(680px, calc(100vh - 32px)); display: flex; flex-direction: column; background: var(--canvas); color: var(--ink); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 30px 70px rgba(36,48,110,.28); overflow: hidden; font-family: var(--sans); animation: joy-in .22s ease-out; }
.joy[hidden] { display: none; }
@media (max-width: 640px) {
  .joy { inset: 0; top: var(--joy-top, 0px); bottom: auto; width: auto; height: 100%; height: var(--joy-vh, 100dvh); border-radius: 0; border: 0; }
  body.joy-open { overflow: hidden; }
}
@keyframes joy-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes joy-pop { from { opacity: 0; transform: translateY(6px); } }

.joy-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--white); border-bottom: 1px solid var(--line); flex: none; }
.joy-head b { display: block; font: 700 1.05rem/1.2 var(--serif); }
.joy-head small { color: var(--sage); font-size: .78rem; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.joy-head small::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sage); flex: none; }
.joy-head .sp { flex: 1; min-width: 0; }
.joy-icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--sand); color: var(--ink); display: grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: none; }
.joy-icon-btn:hover { background: var(--sand-deep); }

.joy-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.joy-log > * { flex-shrink: 0; }
.joy-b { max-width: 88%; padding: 9px 13px; border-radius: 18px; font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; animation: joy-pop .2s ease-out; }
.joy-b.bot { align-self: flex-start; background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.joy-b.me { align-self: flex-end; background: var(--ink); color: var(--white); border-bottom-right-radius: 5px; }
.joy-b ul { margin: 4px 0; padding-left: 18px; }
.joy-b p { margin: 0 0 6px; } .joy-b p:last-child { margin: 0; }
.joy-b a { color: inherit; text-decoration: underline; }
.joy-typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.joy-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .35; animation: joy-blink 1.1s infinite; }
.joy-typing i:nth-child(2) { animation-delay: .18s; } .joy-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes joy-blink { 50% { opacity: 1; transform: translateY(-2px); } }
.joy-sys { align-self: center; font-size: .8rem; color: var(--muted); text-align: center; max-width: 90%; }
.joy-err { align-self: stretch; background: #FDECE8; color: #7A2412; border-radius: 12px; padding: 10px 12px; font-size: .88rem; }

.joy-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.joy-chip { border: 1.5px solid var(--line); background: var(--white); color: var(--ink); border-radius: 999px; padding: 7px 12px; font: 600 .86rem/1.2 var(--sans); cursor: pointer; text-align: left; }
.joy-chip:hover { border-color: var(--sage); color: var(--sage); }
.joy-welcome { display: grid; gap: 10px; }

.joy-foot { flex: none; border-top: 1px solid var(--line); background: var(--white); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.joy-form { display: flex; gap: 8px; align-items: flex-end; }
.joy-form textarea { flex: 1; min-width: 0; resize: none; border: 1.5px solid var(--line); border-radius: 22px; padding: 10px 14px; font: 1rem/1.4 var(--sans); color: var(--ink); background: var(--canvas); max-height: 120px; min-height: 44px; }
.joy-form textarea:focus { outline: none; border-color: var(--ink); }
.joy-send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--cta); color: var(--white); display: grid; place-items: center; cursor: pointer; flex: none; }
.joy-send:disabled { opacity: .45; cursor: default; }
.joy-fine { font-size: 11px; line-height: 1.35; color: var(--ink); opacity: .68; text-align: center; margin: 6px 0 0; }

/* Cards */
.joy-card { align-self: stretch; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; gap: 10px; animation: joy-pop .25s ease-out; min-width: 0; }
.joy-card h4 { margin: 0; font: 700 1rem/1.25 var(--serif); }
.joy-card .muted { color: var(--muted); font-size: .84rem; }
.joy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.joy-row .btn { flex: 1 1 auto; min-height: 42px; padding: 8px 14px; font-size: .9rem; }
.joy-scroll { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; margin: 0 -2px; scrollbar-width: thin; }
.joy-scroll > * { scroll-snap-align: start; }

.joy-prods { align-self: stretch; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; scrollbar-width: thin; }
.joy-prod { flex: 0 0 min(300px, 86%); scroll-snap-align: start; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.joy-prods.single .joy-prod { flex-basis: 100%; }
.joy-prod.best { border: 2px solid var(--marigold); }
.joy-best { position: absolute; top: -1px; left: 12px; background: var(--marigold); color: var(--ink); font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 0 0 8px 8px; }
.joy-prod-top { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding-top: 6px; }
.joy-prod-top img { width: 76px; height: 107px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--sand); }
.joy-price { font-size: .9rem; }
.joy-price s { color: var(--muted); margin-right: 4px; }
.joy-price strong { color: var(--cta); font-size: 1.15rem; }
.joy-offer { display: inline-block; font-size: .72rem; font-weight: 700; background: var(--marigold-soft); color: var(--ink); border-radius: 999px; padding: 1px 8px; }
.joy-why { font-size: .86rem; background: var(--sage-soft); color: var(--ink); border-radius: 10px; padding: 7px 9px; }
.joy-why b { color: var(--sage); }
.joy-list { margin: 0; padding-left: 18px; font-size: .86rem; display: grid; gap: 3px; }
.joy-thumbs { display: flex; gap: 6px; }
.joy-thumbs button { padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--sand); cursor: zoom-in; flex: 1 1 0; max-width: 64px; aspect-ratio: 440 / 622; }
.joy-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.joy-more { display: none; gap: 8px; }
.joy-prod.open .joy-more { display: grid; }
.joy-prod .btn { min-height: 42px; padding: 8px 12px; font-size: .88rem; }
.joy-prod .joy-row { margin-top: auto; }

.joy-gal { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.joy-gal button { flex: 0 0 auto; width: 132px; padding: 0; border: 0; background: none; text-align: left; cursor: zoom-in; scroll-snap-align: start; color: var(--ink); }
.joy-gal img { width: 132px; height: 187px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--sand); display: block; }
.joy-gal img.wide { object-fit: contain; }
.joy-gal span { display: block; font-size: .78rem; font-weight: 700; margin-top: 4px; line-height: 1.25; }
.joy-gal small { display: block; font-size: .72rem; color: var(--muted); }

.joy-cmp { overflow-x: auto; }
.joy-cmp table { border-collapse: collapse; width: 100%; min-width: 360px; font-size: .82rem; }
.joy-cmp th, .joy-cmp td { text-align: left; vertical-align: top; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.joy-cmp th { font-weight: 700; }
.joy-cmp thead th { font: 700 .86rem/1.2 var(--serif); }
.joy-cmp td ul { margin: 0; padding-left: 14px; }
.joy-cmp .pick { background: var(--marigold-soft); }
.joy-cmp img { width: 44px; height: 62px; object-fit: cover; border-radius: 4px; display: block; margin-bottom: 4px; }

.joy-buy { border: 2px solid var(--cta); }
.joy-buy ul { margin: 0; padding-left: 18px; font-size: .86rem; }
.joy-buy .tot { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; border-top: 1px dashed var(--line); padding-top: 8px; }
.joy-buy .tot strong { font-size: 1.3rem; color: var(--cta); }
.joy-safe { font-size: .76rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.joy-idea { background: var(--marigold-soft); border-color: transparent; }
.joy-idea ol { margin: 0; padding-left: 18px; font-size: .9rem; display: grid; gap: 4px; }
.joy-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.joy-meta span { font-size: .75rem; font-weight: 700; background: var(--white); border-radius: 999px; padding: 2px 9px; }
.joy-faq details { border-top: 1px solid var(--line); padding: 8px 0 0; }
.joy-faq details:first-of-type { border: 0; padding: 0; }
.joy-faq summary { font-weight: 700; cursor: pointer; font-size: .9rem; }
.joy-faq p { margin: 6px 0 0; font-size: .88rem; }
.joy-fact { border-left: 4px solid var(--sage); }
.joy-fact a { font-size: .78rem; color: var(--sage); font-weight: 700; }
.joy-input { display: flex; gap: 8px; }
.joy-input input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; font: 1rem var(--sans); }
.joy-ok { color: var(--sage); font-weight: 700; font-size: .9rem; }
.joy-ok .joy-dl { display: inline-block; margin-top: 10px; font-size: .95rem; }
.joy-status { display: inline-block; font-size: .78rem; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.joy-status.paid { background: var(--sage-soft); color: var(--sage); }
.joy-status.unpaid, .joy-status.none, .joy-status.error { background: var(--sand); color: var(--ink); }
.joy-copy { font: 700 .95rem var(--sans); user-select: all; background: var(--sand); padding: 6px 10px; border-radius: 8px; overflow-wrap: anywhere; }

/* Lightbox for samples */
.joy-lb { position: absolute; inset: 0; z-index: 3; background: rgba(20,26,58,.985); display: flex; flex-direction: column; color: var(--white); animation: joy-pop .18s ease-out; }
.joy-lb[hidden] { display: none; }
.joy-lb-top { display: flex; align-items: center; gap: 10px; padding: 12px; padding-top: calc(12px + env(safe-area-inset-top)); }
.joy-lb-top .sp { flex: 1; min-width: 0; font-size: .9rem; }
.joy-lb-top b { display: block; }
.joy-lb-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 12px; touch-action: pan-y pinch-zoom; }
.joy-lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; background: var(--white); }
.joy-lb-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.joy-lb .joy-icon-btn { background: rgba(255,255,255,.14); color: var(--white); }
.joy-lb .count { font-size: .85rem; opacity: .85; }

@media (prefers-reduced-motion: reduce) { .joy, .joy-b, .joy-card, .joy-nudge, .joy-lb { animation: none; } .joy-typing i { animation: none; opacity: .7; } .joy-log { scroll-behavior: auto; } }

/* 👍 / 👎 under a reply */
.joy-rate { display: flex; gap: 4px; margin: -4px 0 4px 4px; font-size: .78rem; color: var(--muted, #545A78); }
.joy-rate button { border: 1px solid var(--line, #E6DCC8); background: #fff; border-radius: 999px; padding: 2px 8px; font-size: .85rem; cursor: pointer; line-height: 1.4; }
.joy-rate button:hover { background: var(--sand, #F4EDDD); }

/* "Ask Joy" buttons placed in the page */
.joy-entry { margin: 18px auto 0; }
.joy-entry-btn { font: inherit; font-weight: 700; color: var(--ink, #24306E); background: #fff; border: 1.5px dashed var(--line, #E6DCC8); border-radius: 999px; padding: 9px 16px; cursor: pointer; }
.joy-entry-btn:hover, .joy-entry-btn:focus-visible { border-style: solid; border-color: var(--ink, #24306E); }
/* Opened from inside the checkout drawer: sit above it */
.joy.joy-over { z-index: 95; }
/* After payment: help card under the downloads */
.joy-dl-card { margin: 14px 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; background: var(--marigold-soft, #FCEFD2); border: 1.5px solid var(--marigold, #F2B33D); border-radius: 16px; padding: 14px 16px; }
.joy-dl-ic { font-size: 1.6rem; line-height: 1; }
.joy-dl-tx { display: grid; gap: 2px; font-size: .92rem; line-height: 1.35; color: var(--ink, #24306E); }
.joy-dl-tx b { font-size: 1rem; }
.joy-dl-card .btn { grid-column: 1 / -1; width: 100%; margin-top: 6px; }
.joy-entry-card { margin: 24px 0 0; background: var(--marigold-soft, #FCEFD2); border-radius: 16px; padding: 16px 18px; display: grid; gap: 10px; justify-items: start; }

/* Welcome gift (coupon) */
.joy-gift { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px dashed var(--marigold); border-radius: 14px; background: #FFF8E6; font-size: .86rem; line-height: 1.35; }
.joy-gift .sp { display: grid; gap: 2px; flex: 1; min-width: 0; }
.joy-gift strong { letter-spacing: .04em; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; }
.joy-gift-ic { font-size: 1.3rem; }
.joy-gift-copy { flex-shrink: 0; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: 700 .82rem/1 var(--sans); cursor: pointer; min-height: 34px; }
.joy-gift-copy.done { border-color: var(--sage); color: var(--sage); }
/* Price breakdown on the order card */
.joy-sum { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted, #555); }
.joy-sum.save { color: var(--sage); font-weight: 700; }
/* "How would you use this?" under a zoomed page */
.joy-lb-use { margin: 0 12px; background: var(--white); color: var(--ink); border-radius: 12px; padding: 8px 12px; font-size: .86rem; line-height: 1.4; max-height: 40vh; overflow: auto; }
.joy-lb-use summary { font-weight: 700; cursor: pointer; }
.joy-lb-use p { margin: 6px 0 0; }
