/* ==========================================================================
   313 Diamond Pivot Project — Motion
   Everything that moves lives here. Two safety rules:
   1. Nothing is hidden unless JavaScript is running (.js on <html>).
   2. Nothing moves for visitors whose device asks for reduced motion.
   Tune speed with --ease-lux and the durations below.
   ========================================================================== */

:root {
  --ease-lux: cubic-bezier(0.16, 1, 0.3, 1);   /* slow, settled finish */
  --dur-reveal: 900ms;
  --dur-photo: 1300ms;
}

/* ---------- Always-on, response-to-action motion ---------- */
@media (prefers-reduced-motion: no-preference) {

  /* Header tightens once the page scrolls */
  .site-header { transition: box-shadow var(--dur-base) var(--ease-out); }
  .site-header__bar { transition: min-height var(--dur-base) var(--ease-out), padding var(--dur-base) var(--ease-out); }
  .brand img { transition: width var(--dur-base) var(--ease-out); }
  .site-header.is-scrolled { box-shadow: 0 10px 30px rgb(16 22 42 / 0.28); }
  .site-header.is-scrolled .site-header__bar { min-height: 4rem; padding-block: var(--space-2); }
  .site-header.is-scrolled .brand img { width: 44px; }

  /* Desktop nav: underline draws in from the left */
  @media (min-width: 75em) {
    .nav__list a {
      text-decoration: none;
      background: linear-gradient(var(--ice), var(--ice)) left bottom / 0 2px no-repeat;
      transition: background-size 350ms var(--ease-lux), color var(--dur-fast);
    }
    .nav__list a:hover { background-size: 100% 2px; }
    .nav__list a[aria-current="page"] { background-image: linear-gradient(var(--rose), var(--rose)); background-size: 100% 2px; }
  }

  /* Primary buttons: a single light glint across the face on hover */
  .btn--donate, .btn--ink { position: relative; overflow: hidden; isolation: isolate; }
  .btn--donate::after, .btn--ink::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.42) 50%, transparent 65%);
    transform: translateX(-120%);
    clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  }
  .btn--ink::after { background: linear-gradient(105deg, transparent 35%, rgb(207 166 160 / 0.45) 50%, transparent 65%); }
  .btn--donate:hover::after, .btn--ink:hover::after { transform: translateX(120%); transition: transform 750ms var(--ease-lux); }

  /* Cards lift slightly on hover */
  .event, .reason, .card { transition: transform 450ms var(--ease-lux), box-shadow 450ms var(--ease-lux); }
  .event:hover, .reason:hover, .card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px -18px rgb(16 22 42 / 0.45); }

  /* Connect Now gem: facets shimmer slowly, like light moving through a stone */
  .gem-art polygon { animation: facet-shimmer 6s ease-in-out infinite; }
  .gem-art polygon:nth-of-type(2) { animation-delay: -1s; }
  .gem-art polygon:nth-of-type(3) { animation-delay: -2.2s; }
  .gem-art polygon:nth-of-type(4) { animation-delay: -3.1s; }
  .gem-art polygon:nth-of-type(5) { animation-delay: -4s; }
  .gem-art polygon:nth-of-type(6) { animation-delay: -0.6s; }
  .gem-art polygon:nth-of-type(7) { animation-delay: -2.7s; }
  .gem-art polygon:nth-of-type(8) { animation-delay: -4.6s; }
  .gem-art { animation: gem-float 8s ease-in-out infinite; }
}
@keyframes facet-shimmer { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35) saturate(1.1); } }
@keyframes gem-float { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-10px) rotate(1.5deg); } }

/* ---------- Entrance choreography (only with JS and full motion) ---------- */
@media (prefers-reduced-motion: no-preference) {

  /* Page load: headline lines rise out of a mask, one after another */
  .js .hero__title span,
  .js .page-hero__title,
  .js .hotline-hero .page-hero__title,
  .js .hotline-number {
    animation: line-rise 1100ms var(--ease-lux) both;
  }
  .js .hero__title span:nth-child(2) { animation-delay: 160ms; }
  .js .hotline-number { animation-delay: 180ms; }
  .js .hero__lead, .js .page-hero__lead, .js .hotline-hours, .js .hotline-hero__kicker { animation: fade-up 1000ms var(--ease-lux) 380ms both; }
  .js .hero__head .actions, .js .hotline-hero__text > .btn, .js .page-hero__inner .actions { animation: fade-up 1000ms var(--ease-lux) 520ms both; }
  .js .breadcrumb { animation: fade-up 800ms var(--ease-lux) both; }

  /* Hero photo settles from a slow push-in */
  .js .hero__photo img { animation: settle 2400ms var(--ease-lux) both; }
  .js .hero__caption { animation: fade-up 900ms var(--ease-lux) 900ms both; }

  /* Scroll reveals: added by main.js as elements come into view */
  .js .rv { opacity: 0; transform: translateY(28px); }
  .js .rv.is-in {
    opacity: 1; transform: none;
    transition: opacity var(--dur-reveal) var(--ease-lux), transform var(--dur-reveal) var(--ease-lux);
    transition-delay: var(--d, 0ms);
  }

  /* Photo settings: a Leading curtain lifts, the image settles, then one rose-gold glint */
  .js .setting.rv { opacity: 1; transform: none; }
  .js .setting.rv::after {
    content: ""; position: absolute; inset: 0; z-index: 2; background: var(--leading);
    transform-origin: top; transform: scaleY(1);
  }
  .js .setting.rv::before {
    content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
    background: linear-gradient(115deg, transparent 38%, rgb(237 194 181 / 0.55) 50%, transparent 62%);
    transform: translateX(-130%);
  }
  .js .setting.rv img { transform: scale(1.12); }
  .js .setting.rv.is-in::after { transform: scaleY(0); transition: transform var(--dur-photo) var(--ease-lux) var(--d, 0ms); }
  .js .setting.rv.is-in img { transform: scale(1); transition: transform 2200ms var(--ease-lux) var(--d, 0ms); }
  .js .setting.rv.is-in::before { transform: translateX(130%); transition: transform 1600ms var(--ease-lux) calc(var(--d, 0ms) + 700ms); }

  /* Facet bands bolt on, left to right, as they arrive */
  /* 1px left visible so the browser can detect the band entering view */
  .js .facet-band.rv { opacity: 1; transform: none; clip-path: inset(0 calc(100% - 1px) 0 0); }
  .js .facet-band.rv.is-in { clip-path: inset(0 0 0 0); transition: clip-path 900ms steps(14, end) var(--d, 0ms); }

  /* Phase numerals rise inside their tiles */
  .js .phase.rv .phase__num { transform: translateY(40%); opacity: 0; }
  .js .phase.rv.is-in .phase__num { transform: none; opacity: 1; transition: transform 1100ms var(--ease-lux) calc(var(--d, 0ms) + 150ms), opacity 900ms var(--ease-lux) calc(var(--d, 0ms) + 150ms); }

  /* Milestone markers drop in after their rule */
  .js .milestone.rv::before { transform: translateY(-14px) scale(0.4); opacity: 0; }
  .js .milestone.rv.is-in::before { transform: none; opacity: 1; transition: transform 700ms var(--ease-lux) calc(var(--d, 0ms) + 300ms), opacity 500ms calc(var(--d, 0ms) + 300ms); }

  /* Pull quote: the rose-gold rule draws down, then the words appear */
  .js .pull-quote.rv { border-left-color: transparent; position: relative; }
  .js .pull-quote.rv::before { content: ""; position: absolute; left: -4px; top: 0; bottom: 0; width: 4px; background: var(--rose-gold); transform: scaleY(0); transform-origin: top; }
  .js .pull-quote.rv.is-in::before { transform: scaleY(1); transition: transform 1100ms var(--ease-lux) var(--d, 0ms); }
}

@keyframes line-rise {
  from { opacity: 0; transform: translateY(0.45em); clip-path: inset(0 0 100% 0); }
  to   { opacity: 1; transform: none; clip-path: inset(0 0 -10% 0); }
}
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes settle  { from { transform: scale(1.08); } to { transform: scale(1); } }

/* ---------- Calendar month change + flyer viewer ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .cal-month.is-active { animation: fade-up 600ms var(--ease-lux) both; }
  .lightbox[open] { animation: fade-up 500ms var(--ease-lux) both; }
  .lightbox[open]::backdrop { animation: backdrop-in 400ms ease both; }
  .flyer-thumb picture { transition: transform 450ms var(--ease-lux), box-shadow 450ms var(--ease-lux); }
  .flyer-thumb:hover picture { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 18px 30px -16px rgb(16 22 42 / 0.5); }
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
