/* =========================================================================
   Help JB Heal — design system additions on top of Tailwind (play CDN)
   ========================================================================= */

:root {
  --rose: #f43f5e;
  --rose-soft: #ffe4e9;
  --amber: #f59e0b;
  --ink: #1e293b;
  --paper: #fff9f7;
}

* { -webkit-tap-highlight-color: transparent; }
[x-cloak] { display: none !important; }

body {
  font-family: "Nunito", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background-color: var(--paper);
  background-image:
    radial-gradient(900px 420px at 8% -6%, #ffe9ee 0%, transparent 60%),
    radial-gradient(760px 380px at 96% 4%, #fff4de 0%, transparent 62%);
  background-repeat: no-repeat;
}
.font-display { font-family: "Baloo 2", "Nunito", sans-serif; }

/* ---------- gradients & texture ---------------------------------------- */
.text-gradient {
  background: linear-gradient(94deg, #f43f5e 0%, #fb7185 42%, #f59e0b 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-glow::before {
  content: ""; position: absolute; inset: -30% -10% auto -10%; height: 460px;
  background: radial-gradient(closest-side, rgba(244,63,94,.20), transparent);
  filter: blur(10px); pointer-events: none;
}

/* ---------- cards ------------------------------------------------------- */
.card {
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(244,63,94,.10);
  box-shadow: 0 14px 40px -22px rgba(30,41,59,.28);
  backdrop-filter: blur(9px);
}
.card-dark {
  background: linear-gradient(160deg, #1e293b 0%, #172033 55%, #241a24 100%);
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: 0 20px 50px -26px rgba(0,0,0,.75);
}
.hover-lift { transition: transform .25s cubic-bezier(.2,.8,.3,1), box-shadow .25s; }
.hover-lift:hover { transform: translateY(-5px); box-shadow: 0 26px 54px -26px rgba(244,63,94,.42); }

/* ---------- buttons ---------------------------------------------------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:.55rem;
  font-weight:700; border-radius:9999px; transition:all .22s ease; cursor:pointer; }
.btn-primary {
  background: linear-gradient(120deg, #f43f5e, #fb7185 55%, #f59e0b 130%);
  color:#fff; box-shadow: 0 12px 26px -12px rgba(244,63,94,.85);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-2px); }
.btn-ghost { background: rgba(255,255,255,.9); color: var(--ink); border:1px solid rgba(30,41,59,.10); }
.btn-ghost:hover { border-color: rgba(244,63,94,.45); color: var(--rose); }
.pulse-ring { position: relative; }
.pulse-ring::after {
  content:""; position:absolute; inset:0; border-radius:inherit;
  box-shadow: 0 0 0 0 rgba(244,63,94,.55); animation: ring 2.4s infinite;
}
@keyframes ring { 70% { box-shadow: 0 0 0 16px rgba(244,63,94,0);} 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0);} }

/* ---------- progress --------------------------------------------------- */
.progress-track { background: rgba(30,41,59,.09); border-radius:9999px; overflow:hidden; }
.progress-fill {
  background: linear-gradient(90deg,#f43f5e,#fb7185 60%,#fbbf24);
  border-radius:9999px; width:0; transition: width 1.5s cubic-bezier(.2,.9,.2,1);
  position:relative; overflow:hidden;
}
.progress-fill::after {
  content:""; position:absolute; inset:0;
  background: linear-gradient(115deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  animation: shine 2.6s linear infinite;
}
@keyframes shine { from { transform: translateX(-100%);} to { transform: translateX(200%);} }

/* ---------- meters ----------------------------------------------------- */
.meter { height:9px; border-radius:9999px; background: rgba(30,41,59,.09); overflow:hidden; }
.meter > i { display:block; height:100%; border-radius:9999px; width:0;
  transition: width 1.3s cubic-bezier(.2,.9,.2,1); }
.meter-energy > i { background: linear-gradient(90deg,#fbbf24,#f97316); }
.meter-appetite > i { background: linear-gradient(90deg,#34d399,#10b981); }
.meter-comfort  > i { background: linear-gradient(90deg,#fb7185,#f43f5e); }

/* ---------- badges ----------------------------------------------------- */
.badge-gold {
  background: linear-gradient(120deg,#fde68a,#fbbf24 50%,#f59e0b);
  color:#5b3a04; font-weight:800; box-shadow:0 4px 14px -6px rgba(245,158,11,.9);
}
.badge-rose { background: var(--rose-soft); color:#be123c; font-weight:800; }
.dot-live { width:8px;height:8px;border-radius:9999px;background:#22c55e;box-shadow:0 0 0 0 rgba(34,197,94,.6); animation: ring 2s infinite; }

/* ---------- chat ------------------------------------------------------- */
.chat-shell { transition: opacity .28s ease, transform .28s cubic-bezier(.2,.9,.2,1); }
.chat-shell.closed { opacity:0; transform: translateY(18px) scale(.96); pointer-events:none; }
.bubble { max-width: 86%; padding:.62rem .9rem; border-radius:1.15rem; line-height:1.45; font-size:.9rem;
  box-shadow: 0 8px 18px -14px rgba(30,41,59,.5); white-space: pre-wrap; word-break: break-word; }
.bubble-bot  { background:#fff; border:1px solid rgba(244,63,94,.16); border-bottom-left-radius:.3rem; }
.bubble-user { background: linear-gradient(120deg,#f43f5e,#fb7185); color:#fff; border-bottom-right-radius:.3rem; }
.bubble-admin{ background: linear-gradient(120deg,#0f172a,#334155); color:#fff; border-bottom-left-radius:.3rem; }
.bubble img { border-radius:.85rem; margin-top:.4rem; max-height:170px; object-fit:cover; }
.typing i { display:inline-block; width:6px;height:6px;border-radius:9999px;background:#f43f5e;margin:0 1px;animation:bob 1.1s infinite; }
.typing i:nth-child(2){animation-delay:.16s} .typing i:nth-child(3){animation-delay:.32s}
@keyframes bob { 0%,60%,100%{transform:translateY(0);opacity:.45} 30%{transform:translateY(-5px);opacity:1} }

/* ---------- misc ------------------------------------------------------- */
.scroll-thin::-webkit-scrollbar { width:7px; height:7px; }
.scroll-thin::-webkit-scrollbar-thumb { background: rgba(244,63,94,.32); border-radius:99px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }
.no-scrollbar::-webkit-scrollbar { display:none; }

.heart-particle {
  position: fixed; pointer-events:none; font-size:22px; z-index: 9999;
  animation: floatUp 1.5s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity:1; transform: translate(0,0) scale(.6) rotate(0deg); }
  60% { opacity:1; }
  100% { opacity:0; transform: translate(var(--dx,0), -150px) scale(1.35) rotate(var(--dr,20deg)); }
}
.pop { animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { 0%{transform:scale(.6)} 60%{transform:scale(1.14)} 100%{transform:scale(1)} }
.fade-in { animation: fadeIn .5s ease both; }
@keyframes fadeIn { from{opacity:0; transform: translateY(10px)} to{opacity:1; transform:none} }

.reveal { opacity:0; transform: translateY(22px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.9,.2,1); }
.reveal.in { opacity:1; transform:none; }

.stage-line { position:absolute; left:23px; top:0; bottom:0; width:2px;
  background: linear-gradient(#f43f5e55, #f59e0b55); }
.comment-thread { border-left: 2px dashed rgba(244,63,94,.28); }

.marquee { display:flex; gap:1.25rem; animation: slide 34s linear infinite; }
.marquee:hover { animation-play-state: paused; }
@keyframes slide { from{transform:translateX(0)} to{transform:translateX(-50%)} }

.ba-wrap { position:relative; overflow:hidden; }
.ba-wrap img { transition: transform .6s ease; }
.ba-wrap:hover .after-img { transform: scale(1.06); }

.lightbox { position:fixed; inset:0; background: rgba(15,23,42,.9); backdrop-filter: blur(6px); z-index: 95; }

/* =========================================================================
   RESPONSIVE / MOBILE LAYER
   Viewport honesty, safe areas, touch targets, keyboard-aware chat sheet.
   ========================================================================= */

/* ---------- smooth scrolling, anchor offsets & no horizontal bleed ------ */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.75rem;          /* anchor jumps clear the sticky header */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@supports (overflow: clip) {
  /* `clip` (not `hidden`) and root-only, so position: sticky keeps working */
  html { overflow-x: clip; }
}
@supports (min-height: 100dvh) { body { min-height: 100dvh; } }

section[id] { scroll-margin-top: 4.75rem; }

/* momentum scrolling, and inner panes must not rubber-band the whole page */
.scroll-thin,
#jb-chat-messages, #jb-chat-quick, #thread, #session-list, #donation-list,
#health-list, #media-list, #admin-comments, #comments-list, #donor-wall, #tabs {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* a flex child only scrolls if it is allowed to shrink */
#jb-chat-messages, #thread { min-height: 0; }

/* ---------- touch ergonomics ------------------------------------------- */
@media (pointer: coarse) {
  .btn, button, label, select, a { touch-action: manipulation; }
  .btn { min-height: 2.5rem; }                  /* comfortable tap target */
  /* every secondary control gets a real thumb-sized hit area too */
  #jb-chat-quick button,
  #quick-replies button { min-height: 2.25rem; white-space: nowrap; }
  [data-amt] { min-height: 2.5rem; }
  .tab-btn { min-height: 2.5rem; }
}
:focus-visible { outline: 2px solid rgba(244,63,94,.5); outline-offset: 2px; }

/* ---------- safe areas (notch, home indicator, keyboard) --------------- */
@supports (padding: env(safe-area-inset-bottom)) {
  header.sticky { padding-top: env(safe-area-inset-top); }
  #jb-chat-panel > header { padding-top: max(.75rem, env(safe-area-inset-top)); }
  #jb-chat-form, #reply-form { padding-bottom: max(.625rem, env(safe-area-inset-bottom)); }
}

/* ---------- media / long strings never widen the page ------------------ */
img, video, svg { max-width: 100%; }
.break-anywhere { overflow-wrap: anywhere; word-break: break-word; }

/* ---------- phones: iOS never auto-zooms, chat becomes a real sheet ---- */
@media (max-width: 639.98px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea,
  select { font-size: 16px !important; }

  /* full-height sheet that tracks the *dynamic* viewport, so the input row
     always clears the on-screen keyboard and the home indicator */
  #jb-chat-panel {
    inset: 0;
    width: 100%;
    height: 100vh;          /* fallback */
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  #jb-chat-panel.closed { transform: translateY(100%); opacity: 0; }

  /* the sheet owns the screen — never let the page scroll behind it */
  body.jb-chat-open { overflow: hidden; }
}

@media print { .no-print { display:none !important; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration:.01ms !important; transition-duration:.01ms !important; }
}

/* =========================================================================
   MEDIA GALLERY — editorial masonry, refined hover, cinematic viewer
   ========================================================================= */
/* Editorial masonry: tiles flow down each column carrying their own curated
   proportions, and are never split across a column break.
   2 columns on phones/tablets → 3 on laptops → 4 on wide editorial screens. */
.jb-masonry { column-count: 2; column-gap: 1rem; }
.jb-tile {
  break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid;
  margin: 0 0 1rem; cursor: zoom-in;
  /* restates the reveal transition so the staggered entrance keeps working */
  transition: opacity .7s ease, transform .7s cubic-bezier(.2,.9,.2,1);
}
@media (min-width: 640px) {
  .jb-masonry { column-gap: 1.375rem; }
  .jb-tile { margin-bottom: 1.375rem; }
}
@media (min-width: 1024px) { .jb-masonry { column-count: 3; column-gap: 1.5rem; } .jb-tile { margin-bottom: 1.5rem; } }
@media (min-width: 1280px) { .jb-masonry { column-count: 4; } }

.jb-frame {
  position: relative; overflow: hidden; border-radius: 1.25rem; background: #f8fafc;
  box-shadow: 0 1px 2px rgba(15,23,42,.05);
  transition: box-shadow .6s cubic-bezier(.2,.8,.2,1);
}
.jb-tile:hover .jb-frame,
.jb-tile:focus-visible .jb-frame { box-shadow: 0 34px 62px -34px rgba(244,63,94,.5); }

.jb-tile-img { transition: transform 1.1s cubic-bezier(.2,.8,.2,1); will-change: transform; }
.jb-tile:hover .jb-tile-img,
.jb-tile:focus-visible .jb-tile-img { transform: scale(1.055); }

/* refined overlay — invisible at rest, eases in together with the caption */
.jb-tile-veil {
  opacity: 0; transition: opacity .5s ease;
  background: linear-gradient(to top,
    rgba(15,23,42,.88) 0%, rgba(15,23,42,.45) 42%, rgba(15,23,42,.1) 72%, rgba(15,23,42,0) 100%);
}
.jb-tile:hover .jb-tile-veil,
.jb-tile:focus-visible .jb-tile-veil { opacity: 1; }

/* caption + meta rise out of the fold on hover */
.jb-tile-meta {
  opacity: 0; transform: translateY(12px);
  transition: transform .55s cubic-bezier(.2,.9,.2,1), opacity .45s ease;
}
.jb-tile:hover .jb-tile-meta,
.jb-tile:focus-visible .jb-tile-meta { opacity: 1; transform: none; }

/* the category kicker stays put but steps back once the caption arrives */
.jb-tile-tag { transition: opacity .45s ease; }
.jb-tile:hover .jb-tile-tag { opacity: .6; }

.jb-play { transition: transform .45s cubic-bezier(.2,.9,.2,1); }
.jb-tile:hover .jb-play { transform: scale(1.09); }

.jb-tile:focus-visible { outline: 2px solid var(--rose); outline-offset: 4px; border-radius: 1.25rem; }
.jb-filter { transition: background-color .25s ease, color .25s ease, box-shadow .25s ease; }

/* touch devices have no hover — keep the veil and captions permanently on */
@media (hover: none) {
  .jb-tile-veil { opacity: 1; }
  .jb-tile-meta { opacity: 1; transform: none; }
}

/* ---------- fullscreen viewer ------------------------------------------ */
body.jb-lb-open { overflow: hidden; }
.lb-btn { transition: background-color .2s ease, transform .2s ease; }
.lb-btn:hover { transform: scale(1.07); }
.lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-media { animation: lbIn .38s cubic-bezier(.2,.9,.2,1) both; }
@keyframes lbIn { from { opacity:0; transform: scale(.975); } to { opacity:1; transform:none; } }

@media (max-width: 639.98px) {
  /* id-qualified so these beat the Tailwind utility classes on the same nodes */
  #jb-lightbox .lb-btn { width: 2.75rem; height: 2.75rem; }
  #jb-lightbox .lb-media { max-height: 72vh; }
}

@media (prefers-reduced-motion: reduce) {
  .jb-tile-img, .jb-tile-meta, .jb-tile-tag, .jb-play, .jb-frame, .lb-media {
    transition: none !important; animation: none !important;
  }
  .jb-tile:hover .jb-tile-img { transform: none; }
  /* nothing animates in, so the captions must simply be there */
  .jb-tile-veil, .jb-tile-meta { opacity: 1; transform: none; }
}

/* =========================================================================
   WELCOME OVERLAY — Shawn's letter (first thing on page load)
   ========================================================================= */

/* overlay fade — Alpine applies jb-wf + a start/end opacity class */
.jb-wf { transition: opacity .5s ease; }
.jb-wf-0 { opacity: 0; }
.jb-wf-1 { opacity: 1; }

/* warm glassmorphism letter panel */
.jb-welcome-panel {
  max-height: 88vh;
  border-radius: 1.75rem;
  background:
    linear-gradient(155deg, rgba(255,255,255,.94) 0%, rgba(255,246,240,.90) 52%, rgba(255,238,241,.92) 100%);
  border: 1px solid rgba(255,255,255,.78);
  -webkit-backdrop-filter: blur(26px) saturate(1.45);
  backdrop-filter: blur(26px) saturate(1.45);
  box-shadow: 0 44px 96px -44px rgba(30,41,59,.62), 0 0 0 1px rgba(244,63,94,.08);
  animation: jbWelcomeIn .62s cubic-bezier(.2,.9,.2,1) both;
}
@keyframes jbWelcomeIn {
  from { opacity: 0; transform: translateY(24px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* freeze the page behind the overlay */
body.jb-welcome-open { overflow: hidden; }

/* letter typography */
.jb-letter p { font-size: .95rem; line-height: 1.8; color: #475569; }
.jb-letter p + p { margin-top: .9rem; }
.jb-letter .jb-lead { font-size: 1.02rem; color: #334155; font-weight: 600; }
.jb-letter .jb-beat { font-weight: 800; color: var(--rose); }
.jb-letter .jb-signoff { margin-top: 1.6rem; font-weight: 700; color: #334155; }
.jb-letter .jb-signature {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.35rem; font-weight: 800; color: #1e293b; margin-top: .15rem;
}

/* the "read the rest" block expands smoothly in place */
.jb-letter-more {
  display: grid; grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows .62s cubic-bezier(.22,1,.36,1), opacity .45s ease;
}
.jb-letter-more > div { overflow: hidden; }
.jb-letter-more.open { grid-template-rows: 1fr; opacity: 1; }

/* read-more chevron */
.jb-chev { display: inline-flex; transition: transform .35s cubic-bezier(.2,.9,.2,1); }
.jb-chev.is-open { transform: rotate(180deg); }

/* scrollable letter body */
.jb-welcome-scroll { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.jb-welcome-scroll::-webkit-scrollbar { width: 8px; }
.jb-welcome-scroll::-webkit-scrollbar-thumb { background: rgba(244,63,94,.28); border-radius: 9999px; }
.jb-welcome-scroll::-webkit-scrollbar-track { background: transparent; }

/* footer clears the home indicator */
.jb-welcome-foot { padding-bottom: 1rem; }
@supports (padding: env(safe-area-inset-bottom)) {
  .jb-welcome-foot { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

/* keyboard focus stays obvious inside the overlay */
#jb-welcome .btn:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }

/* phones: bottom sheet that tracks the dynamic viewport */
@media (max-width: 639.98px) {
  .jb-welcome-panel {
    max-height: 94dvh;
    border-radius: 1.75rem 1.75rem 0 0;
  }
  .jb-letter p { font-size: .94rem; line-height: 1.75; }
}

@media (prefers-reduced-motion: reduce) {
  .jb-welcome-panel { animation: none; }
  .jb-letter-more { transition: none; }
  .jb-chev { transition: none; }
  .jb-wf { transition: none; }
}
