/* ============================================================================
   ANIMATIONS & VISUAL POLISH
   Loaded after style.css. Tasteful, professional motion.
   Fully disabled under prefers-reduced-motion.
   ==========================================================================*/

/* ---------- Scroll reveal ---------- */
/* Only hide when JS is confirmed alive (html.js), so a JS failure never
   leaves the page blank. */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1);
  will-change: opacity, transform;
}
.js .reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; }
.reveal.d2 { transition-delay: .16s; }
.reveal.d3 { transition-delay: .24s; }
.reveal.d4 { transition-delay: .32s; }

/* ---------- Brand logo svg ---------- */
.brand .logo { background: none !important; padding: 0; }
.logo-svg { display: block; filter: drop-shadow(0 3px 8px rgba(15,118,110,.35)); }

/* ---------- Hero artwork ---------- */
.hero-art-col { display: flex; flex-direction: column; gap: 8px; }
.hero-art { position: relative; display: grid; place-items: center; margin: -20px 0 -10px; }
@media (max-width: 820px) { .hero-art { display: none; } }
.hero-svg { width: 100%; max-width: 520px; height: auto; overflow: visible; }
.hero-svg .mol-chain path {
  stroke-dasharray: 900; stroke-dashoffset: 900;
  animation: draw 2.4s cubic-bezier(.4,0,.2,1) forwards .2s;
}
.hero-svg .mol-atom { transform-origin: center; transform-box: fill-box;
  animation: atompop .6s cubic-bezier(.2,1.4,.4,1) both; animation-delay: var(--d); }
.hero-svg .mol-atoms { animation: floaty 7s ease-in-out infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes atompop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* soft drifting gradient blobs behind hero */
.hero::before { animation: blobshift 18s ease-in-out infinite alternate; }
@keyframes blobshift {
  0% { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(-18px,14px,0) scale(1.06); }
}

/* animated accent underline on hero heading word */
.hero h1 span { position: relative; }
.hero h1 span::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .06em; height: .14em;
  background: linear-gradient(90deg, var(--brand), var(--amber));
  border-radius: 4px; transform: scaleX(0); transform-origin: left;
  animation: underline 1s cubic-bezier(.4,0,.2,1) forwards 1.1s;
}
@keyframes underline { to { transform: scaleX(1); } }

/* ---------- Story illustrations ---------- */
.story-visual { overflow: hidden; font-size: 0 !important; padding: 20px !important; }
.ill-svg { width: 100%; max-width: 220px; height: auto; }
.ill-float { transform-origin: center; transform-box: fill-box; animation: floaty 6s ease-in-out infinite; }
.ill-pulse {
  stroke-dasharray: 220; stroke-dashoffset: 220;
  animation: dashloop 3.5s linear infinite;
}
.ill-needle { animation: needle 4s ease-in-out infinite; transform-origin: 100px 143px; transform-box: view-box; }
.ill-bubble circle { animation: bubble 3s ease-in-out infinite; }
.ill-bubble circle:nth-child(2){ animation-delay:.6s } .ill-bubble circle:nth-child(3){ animation-delay:1.2s }
@keyframes dashloop { to { stroke-dashoffset: -220; } }
@keyframes needle { 0%,100%{ transform: rotate(-18deg);} 50%{ transform: rotate(20deg);} }
@keyframes bubble { 0%{ transform: translateY(6px); opacity:0;} 40%{opacity:.6} 100%{ transform: translateY(-16px); opacity:0;} }

/* ---------- Divider ---------- */
.divider-svg { width: 100%; height: 34px; display: block; margin: 8px 0; }

/* ---------- Category / tool icons ---------- */
.cat-icon-svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 5px; }
.tool-icon-svg { width: 26px; height: 26px; }
.card .icon svg { width: 24px; height: 24px; }

/* icon chip in catalog cat-tag */
.cat-tag { display: inline-flex; align-items: center; }

/* ---------- Header shadow on scroll ---------- */
.site-header { transition: box-shadow .25s ease, background .25s ease; }
.site-header.scrolled { box-shadow: 0 4px 24px rgba(16,48,47,.10); }

/* ---------- Card micro-interaction upgrade ---------- */
.card-hover { position: relative; overflow: hidden; }
.card-hover::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(180px circle at var(--mx,50%) var(--my,0%), var(--brand-soft), transparent 60%);
  opacity: 0; transition: opacity .4s ease;
}
.card-hover:hover::before { opacity: .5; }
.pep-card .cat-tag { transition: transform .2s ease; }
.pep-card:hover .cat-tag { transform: translateY(-1px); }

/* ---------- Tool tiles: animated top accent ---------- */
.feature-tiles .card { position: relative; overflow: hidden; }
.feature-tiles .card::after {
  content:""; position:absolute; top:0; left:0; right:0; height:3px;
  background: linear-gradient(90deg, var(--brand), var(--amber));
  transform: scaleX(0); transform-origin: left; transition: transform .35s ease;
}
.feature-tiles .card:hover::after { transform: scaleX(1); }
.feature-tiles .icon { transition: transform .35s cubic-bezier(.2,1.4,.4,1); }
.feature-tiles .card:hover .icon { transform: translateY(-3px) rotate(-4deg); }

/* ---------- Stat counter emphasis ---------- */
.stat b { transition: transform .3s ease; }

/* ---------- Buttons: sheen ---------- */
.btn-primary, .btn-amber { position: relative; overflow: hidden; }
.btn-primary::after, .btn-amber::after {
  content:""; position:absolute; top:0; left:-120%; width:60%; height:100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
  transform: skewX(-18deg); transition: left .6s ease;
}
.btn-primary:hover::after, .btn-amber:hover::after { left: 130%; }

/* ---------- Modal atoms decoration ---------- */
.modal-head { position: relative; overflow: hidden; }
.modal-head::before {
  content:""; position:absolute; right:-30px; top:-30px; width:130px; height:130px;
  background: radial-gradient(circle, var(--brand-soft), transparent 70%); opacity:.7; pointer-events:none;
}

/* ---------- Calendar cell pop ---------- */
.cal-cell { transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.cal-cell:not(.empty):hover { transform: translateY(-2px); }
.cal-cell .mk { animation: mkin .3s ease both; }
@keyframes mkin { from { transform: scale(0);} to { transform: scale(1);} }

/* ---------- Calculator result pulse on change ---------- */
.result-big { transition: transform .2s ease; }
.result-big.bump { animation: bump .35s ease; }
@keyframes bump { 0%{transform:scale(1)} 40%{transform:scale(1.09)} 100%{transform:scale(1)} }
.syringe .fill { background: repeating-linear-gradient(45deg, rgba(255,255,255,.85), rgba(255,255,255,.85) 8px, rgba(255,255,255,.65) 8px, rgba(255,255,255,.65) 16px) !important; }

/* ---------- Page load fade for hero text ---------- */
.hero .eyebrow, .hero h1, .hero .lead, .hero-cta, .stat-row {
  animation: riseIn .8s cubic-bezier(.2,.7,.2,1) both;
}
.hero h1 { animation-delay:.05s } .hero .lead { animation-delay:.15s }
.hero-cta { animation-delay:.25s } .stat-row { animation-delay:.35s }
@keyframes riseIn { from { opacity:0; transform: translateY(18px);} to { opacity:1; transform:none;} }

/* ---------- Per-category color accents ---------- */
.pep-card {
  --cat: var(--brand);
  border-top: 3px solid transparent;
  position: relative;
}
.pep-card::before { background: radial-gradient(180px circle at var(--mx,50%) var(--my,0%),
  color-mix(in srgb, var(--cat) 22%, transparent), transparent 60%) !important; }
.pep-card .cat-tag {
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 14%, transparent);
}
.pep-card .cat-icon-svg { color: var(--cat); }
/* Secondary category badge: outlined rather than filled, so the primary
   category still reads first at a glance. */
.cat-tag.cat-tag-sec {
  color: var(--cat); background: transparent;
  border: 1px solid color-mix(in srgb, var(--cat) 50%, var(--line));
}
.cat-tag.cat-tag-sec .cat-icon-svg { color: var(--cat); }
.pep-card { transition: transform .14s ease, box-shadow .14s ease, border-color .2s ease; }
.pep-card:hover { border-top-color: var(--cat); }
.pep-card .pep-foot span:last-child { color: var(--cat) !important; }

/* colored category chips */
.chip-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.chip[data-cat]:not([data-cat="All"]):hover { border-color: var(--cat); }
.chip.active[style*="--cat"] { background: var(--cat) !important; border-color: var(--cat) !important; color: #fff; }
.chip.active .chip-dot { background: #fff !important; }

/* modal accent picks up category color */
#pep-modal .modal { --cat: var(--brand); }
#pep-modal .modal-head::before { background: radial-gradient(circle,
  color-mix(in srgb, var(--cat) 30%, transparent), transparent 70%) !important; }
#pep-modal-head .cat-tag { color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, transparent); }
#pep-modal-head .cat-icon-svg { color: var(--cat); }
#pep-modal .modal-head { border-top: 4px solid var(--cat); border-radius: 18px 18px 0 0; }

/* ---------- Category color continuity on pricing tables ---------- */
.price-card {
  --cat: var(--brand);
  border-left: 4px solid var(--cat);
}
.price-card .cat-tag {
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 14%, transparent);
}
.price-card .cat-icon-svg { color: var(--cat); }
.price-card .table-scroll { border-color: color-mix(in srgb, var(--cat) 30%, var(--line)); }
.price-card table.data th {
  background: color-mix(in srgb, var(--cat) 12%, var(--surface-2));
  color: color-mix(in srgb, var(--cat) 75%, var(--ink));
  border-bottom-color: color-mix(in srgb, var(--cat) 35%, var(--line));
}
.price-card table.data tr:hover td { background: color-mix(in srgb, var(--cat) 7%, transparent); }
/* recolor the "Best price" badge to the category hue */
.price-card .badge.best {
  background: color-mix(in srgb, var(--cat) 16%, transparent);
  color: var(--cat);
}
/* jump-target highlight when arriving from a "Compare prices" link */
.price-card:target {
  box-shadow: 0 0 0 2px var(--cat), var(--shadow-lg);
  animation: targetflash 1.4s ease;
}
@keyframes targetflash {
  0% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--cat) 40%, transparent), var(--shadow-lg); }
  100% { box-shadow: 0 0 0 2px var(--cat), var(--shadow-lg); }
}

/* ---------- Molecular header backdrop (interior pages) ---------- */
.page-head-bg {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  color: var(--brand);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
          mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
}
.molecule-field {
  position: absolute; top: -20px; left: 0; width: 100%; height: 220px;
  opacity: .14;
}
.molecule-field .mf-node { transform-box: fill-box; transform-origin: center;
  animation: mfpulse 4.5s ease-in-out infinite; animation-delay: var(--d); }
.molecule-field .mf-bonds { animation: mfdrift 20s ease-in-out infinite alternate; }
@keyframes mfpulse { 0%,100% { opacity:.5; transform: scale(1);} 50% { opacity:1; transform: scale(1.5);} }
@keyframes mfdrift { from { transform: translateX(0);} to { transform: translateX(-24px);} }
/* pages that get the backdrop: make the intro section a positioning context */
body[data-page] > section.section:first-of-type { position: relative; }
body[data-page] > section.section:first-of-type > .wrap { position: relative; z-index: 1; }

/* ---------- Tracker day-panel states ---------- */
.log-item.skipped { background: var(--surface-2); opacity: .8; }
.log-item .log-state { font-size: .85rem; font-weight: 700; padding: .3rem .1rem; }
.log-item .log-state.done { color: var(--good); }
.log-item .log-state.skip { color: var(--muted); }
.check-btn.primary { background: var(--brand); color: #fff; border-color: transparent; }
.check-btn.primary:hover { background: var(--brand-dark); }
.link-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: .8rem; text-decoration: underline; padding: .2rem .3rem;
}
.link-btn:hover { color: var(--ink); }

/* ---------- Calculator dose guide ---------- */
.dose-guide {
  margin-top: 12px; padding: 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.guide-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tier-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tier-row:has(.tier:only-child) { grid-template-columns: 1fr; }
.tier {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font: inherit;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
button.tier:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tier-name { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.tier-range { font-size: .95rem; font-weight: 700; color: var(--ink); }
.tier.t-start .tier-name { color: var(--good); }
.tier.t-maint .tier-name { color: var(--brand); }
.tier.t-aggr  .tier-name { color: var(--amber); }
.tier.t-start { border-left: 3px solid var(--good); }
.tier.t-maint { border-left: 3px solid var(--brand); }
.tier.t-aggr  { border-left: 3px solid var(--amber); }
.tier.is-here { box-shadow: 0 0 0 2px var(--brand); border-color: var(--brand); }
.tier.t-start.is-here { box-shadow: 0 0 0 2px var(--good); border-color: var(--good); }
.tier.t-aggr.is-here  { box-shadow: 0 0 0 2px var(--amber); border-color: var(--amber); }
.place { margin-top: 10px; padding: 8px 11px; border-radius: 8px; font-size: .85rem; }
.place-ok { background: var(--good-soft); color: var(--good); }
.place-warn { background: var(--amber-soft); color: var(--amber); }
.guide-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .82rem; color: var(--ink-soft); }
.guide-note { margin-top: 8px; font-size: .82rem; color: var(--muted); }

/* ---------- Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
  .hero-svg .mol-chain path { stroke-dashoffset: 0 !important; }
  .hero h1 span::after { transform: scaleX(1) !important; }
}
