/* =========================================================================
   Carousels - Our Community (peek cards) + Our History (timeline)
   Matches the St John's Figma: near-black ground, terracotta accent,
   EB Garamond, fine hairlines with diamond terminals.
   ========================================================================= */

/* Our History - translucent Agnus Dei crest bleeding off the left edge */
[data-screen-label="History"] { overflow: hidden; }
[data-screen-label="History"] > .container { position: relative; z-index: 1; }
.history-emblem {
  position: absolute; left: clamp(-260px, -10vw, -120px); top: 50%;
  transform: translateY(-50%);
  width: clamp(420px, 48vw, 760px); aspect-ratio: 1069 / 1129;
  background-size: contain; background-repeat: no-repeat; background-position: center;
  opacity: 0; z-index: 0; pointer-events: none;
  transition: opacity 1.4s ease 0.2s;
}
.history-emblem.in { opacity: .1; }
@media (prefers-reduced-motion: reduce) { .history-emblem { transition: none; } }
@media (max-width: 760px) { .history-emblem { left: -34vw; width: 92vw; opacity: 0; } .history-emblem.in { opacity: .07; } }

/* ===================================================================== */
/*  OUR COMMUNITY - peek / coverflow card carousel                       */
/* ===================================================================== */
.community-carousel { position: relative; margin-top: clamp(36px, 5vw, 60px); }

.cc-viewport { overflow: hidden; padding-block: 6px; }
.cc-track {
  display: flex;
  gap: clamp(16px, 1.8vw, 26px);
  align-items: stretch;
  will-change: transform;
  transition: transform .8s cubic-bezier(.22,.7,.18,1);
}

.cc-card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(220px, 26vw, 360px);
  height: clamp(380px, 46vw, 460px);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--hair-soft);
  transition: width .8s cubic-bezier(.22,.7,.18,1), border-color .5s;
}
.cc-card.is-active {
  width: clamp(320px, 50vw, 620px);
  cursor: default;
  border-color: var(--accent-soft);
}

.cc-media {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  transform: scale(1.04);
  transition: opacity .8s ease, transform 6s ease, filter .6s ease;
}
.cc-card:not(.is-active):hover .cc-media { transform: scale(1.1); }
.cc-card.is-active .cc-media { opacity: .14; filter: grayscale(.2); }

.cc-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8,8,8,.92) 0%, rgba(8,8,8,.35) 46%, rgba(8,8,8,.08) 100%);
  transition: opacity .6s ease;
}
.cc-card.is-active .cc-scrim {
  background: radial-gradient(120% 90% at 18% 12%, rgba(227,153,95,.07), transparent 60%);
}

/* caption for collapsed (image) cards */
.cc-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: clamp(20px, 2.2vw, 30px);
  transition: opacity .4s ease;
}
.cc-cap-sub {
  font-family: var(--label); font-size: .72rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 .55em;
}
.cc-cap-title {
  font-family: var(--display); font-weight: 500; color: var(--ink);
  font-size: clamp(1.35rem, 2vw, 1.85rem); line-height: 1.08; margin: 0;
  max-width: 16ch;
}
.cc-card.is-active .cc-cap { opacity: 0; pointer-events: none; }

/* expanded detail for the active card */
.cc-detail {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(30px, 3.4vw, 52px);
  opacity: 0; transform: translateY(14px);
  transition: opacity .55s ease .12s, transform .65s cubic-bezier(.2,.7,.2,1) .12s;
  pointer-events: none;
}
.cc-card.is-active .cc-detail { opacity: 1; transform: none; pointer-events: auto; }

.cc-detail .cc-sched {
  font-family: var(--label); font-size: .78rem; letter-spacing: .24em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 1.1em;
  display: flex; align-items: center; gap: .9em;
}
.cc-detail .cc-sched::before {
  content: ""; width: 30px; height: 1px; background: var(--accent); flex: 0 0 auto;
}
.cc-detail .cc-title {
  font-family: var(--display); font-weight: 500; color: var(--ink);
  font-size: clamp(1.9rem, 3vw, 2.9rem); line-height: 1.02; margin: 0 0 .5em;
}
.cc-detail .cc-desc {
  color: var(--ink-soft); font-size: clamp(1rem, 1.12vw, 1.16rem);
  line-height: 1.62; margin: 0; max-width: 46ch;
}
.cc-detail .cc-contact {
  font-family: var(--label); font-size: .92rem; letter-spacing: .04em;
  color: var(--ink-mute); margin: 1.5em 0 0;
  padding-top: 1.2em; border-top: 1px solid var(--hair-soft);
}
.cc-detail .cc-contact strong { color: var(--ink-soft); font-weight: 500; }

/* corner arrow button */
.cc-go {
  position: absolute; right: clamp(16px, 1.6vw, 22px); top: clamp(16px, 1.6vw, 22px);
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(20,20,20,.4); border: 1px solid var(--accent-soft);
  color: var(--accent); cursor: pointer; z-index: 3;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: background .3s, color .3s, transform .4s, border-color .3s;
}
.cc-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.cc-card:not(.is-active):hover .cc-go { background: var(--accent); color: #1b1208; border-color: var(--accent); transform: rotate(0deg); }
.cc-card.is-active .cc-go { border-color: var(--accent); }
.cc-card.is-active .cc-go:hover { background: var(--accent); color: #1b1208; }

/* footer: arrows, progress, link */
.cc-foot {
  display: flex; align-items: center; gap: 28px;
  margin-top: clamp(28px, 3vw, 44px);
}
.cc-arrows { display: flex; gap: 12px; }
.cc-arrow {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--hair); color: var(--ink-soft);
  cursor: pointer; transition: border-color .28s, color .28s, background .28s;
}
.cc-arrow:hover { border-color: var(--accent); color: var(--accent); }
.cc-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.cc-progress { flex: 1; height: 1px; background: var(--hair-soft); position: relative; max-width: 320px; }
.cc-progress span {
  position: absolute; top: 0; left: 0; height: 1px; background: var(--accent);
  transition: width .6s cubic-bezier(.2,.7,.2,1), left .6s cubic-bezier(.2,.7,.2,1);
}
.cc-count {
  font-family: var(--label); font-size: .92rem; letter-spacing: .14em;
  color: var(--ink-mute); white-space: nowrap;
}
.cc-count b { color: var(--accent); font-weight: 500; }
.cc-foot .cc-all { margin-left: auto; }

@media (max-width: 760px) {
  .cc-card { width: 80vw; height: 420px; }
  .cc-card.is-active { width: 84vw; }
  .cc-foot .cc-all { display: none; }
  .cc-detail .cc-desc { font-size: 1rem; }
}

/* ===================================================================== */
/*  OUR HISTORY - timeline carousel                                      */
/* ===================================================================== */
.history-timeline { margin-top: clamp(30px, 4vw, 52px); }

/* --- the time axis --- */
.ht-axis { position: relative; padding-top: 8px; }
.ht-line {
  position: absolute; left: 0; right: 0; top: 7px; height: 1px;
  background: var(--hair);
}
.ht-line::before, .ht-line::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px;
  background: var(--hair); transform: translateY(-50%) rotate(45deg);
}
.ht-line::before { left: -3px; } .ht-line::after { right: -3px; }

.ht-points {
  position: relative; display: flex; justify-content: space-between; gap: 8px;
}
.ht-point {
  background: none; border: 0; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  flex: 1; min-width: 0;
}
.ht-dot {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--hair);
  transition: background .35s, border-color .35s, transform .35s, box-shadow .35s;
}
.ht-plabel {
  font-family: var(--label); font-size: clamp(.74rem, .92vw, .95rem);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; transition: color .35s;
}
.ht-point:hover .ht-plabel { color: var(--ink-soft); }
.ht-point:hover .ht-dot { border-color: var(--accent-soft); }
.ht-point.is-active .ht-dot {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.18); box-shadow: 0 0 0 5px rgba(227,153,95,.16);
}
.ht-point.is-active .ht-plabel { color: var(--accent); }

/* --- thumbnail stage --- */
.ht-stage {
  position: relative; margin-top: clamp(34px, 4.5vw, 60px);
  display: flex; align-items: center; gap: clamp(14px, 2vw, 30px);
}
.ht-thumbs-vp { overflow: hidden; flex: 1; }
.ht-thumbs {
  display: flex; gap: clamp(14px, 1.6vw, 24px);
  will-change: transform;
  transition: transform .8s cubic-bezier(.22,.7,.18,1);
}
.ht-thumb {
  flex: 0 0 auto;
  width: clamp(150px, 18vw, 230px);
  height: clamp(190px, 23vw, 300px);
  padding: 0; border: 1px solid var(--hair-soft); cursor: pointer;
  overflow: hidden; position: relative;
  -webkit-appearance: none; appearance: none;
  background: var(--bg-2);
  filter: grayscale(1) brightness(.6); opacity: .62;
  transition: filter .6s ease, opacity .6s ease, transform .7s cubic-bezier(.22,.7,.18,1), border-color .5s, box-shadow .6s;
}
.ht-thumb img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block; pointer-events: none;
}
.ht-thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8,8,8,.55), transparent 55%);
  opacity: 0; transition: opacity .5s;
}
.ht-thumb:hover { opacity: .85; filter: grayscale(.4) brightness(.8); }
.ht-thumb.is-active {
  filter: none; opacity: 1;
  transform: scale(1.07);
  border-color: var(--accent);
  box-shadow: 0 22px 50px -24px rgba(0,0,0,.8);
  cursor: default;
}
.ht-thumb.is-active::after { opacity: 1; }

.ht-arrow {
  flex: 0 0 auto;
  width: clamp(50px, 4vw, 64px); height: clamp(50px, 4vw, 64px); border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--hair); color: var(--ink-soft);
  cursor: pointer; transition: border-color .28s, color .28s, background .28s;
  z-index: 4;
}
.ht-arrow:hover { border-color: var(--accent); color: var(--accent); }
.ht-arrow svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.3; }

/* --- detail panels (one per milestone, cross-faded) --- */
.ht-detail-wrap { margin-top: clamp(36px, 4.5vw, 60px); }
.ht-panel { display: none; }
.ht-panel.is-active { display: block; animation: htFade .6s cubic-bezier(.2,.7,.2,1) both; }
@keyframes htFade {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.ht-detail {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 4vw, 70px); align-items: start;
}
.ht-era {
  font-family: var(--label); font-style: italic; color: var(--accent);
  font-size: clamp(1.4rem, 2.4vw, 2.1rem); margin: 0 0 .25em; letter-spacing: .01em;
}
.ht-date {
  font-family: var(--display); font-weight: 500; color: var(--ink);
  font-size: clamp(2.6rem, 5.5vw, 4.4rem); line-height: 1; margin: 0;
  letter-spacing: .01em;
}
.ht-desc {
  color: var(--ink-soft); font-size: clamp(1.04rem, 1.2vw, 1.22rem);
  line-height: 1.66; margin: 0 0 1.6em; max-width: 56ch;
}
.ht-img {
  width: 100%; max-width: 480px; height: auto; border-radius: 2px;
  border: 1px solid var(--hair-soft); margin: 0 0 1.6em;
}
@media (max-width: 900px) { .ht-img { max-width: 100%; } }

@media (max-width: 900px) {
  .ht-detail { grid-template-columns: 1fr; gap: 20px; }
  .ht-plabel { display: none; }
  .ht-points { justify-content: space-around; }
}
@media (max-width: 640px) {
  .ht-thumb { width: 64vw; height: 300px; }
}

/* ===================================================================== */
/*  ADVANCED ENTRANCE & STATE CHOREOGRAPHY                               */
/*  All gated behind motion preference; triggered by the scroll-reveal   */
/*  .in class (carousels carry .reveal) and the .is-active state.        */
/* ===================================================================== */
@media (prefers-reduced-motion: no-preference) {

  /* let the inner elements carry the motion; the wrapper only fades */
  .community-carousel.reveal, .history-timeline.reveal { transform: none; }

  /* ---- Our Community: cards rise in sequence -------------------------- */
  .community-carousel.in .cc-card {
    animation: ccCardRise .85s cubic-bezier(.2,.75,.2,1) both;
  }
  .community-carousel.in .cc-track > .cc-card:nth-child(1) { animation-delay: .06s; }
  .community-carousel.in .cc-track > .cc-card:nth-child(2) { animation-delay: .15s; }
  .community-carousel.in .cc-track > .cc-card:nth-child(3) { animation-delay: .24s; }
  .community-carousel.in .cc-track > .cc-card:nth-child(4) { animation-delay: .33s; }
  .community-carousel.in .cc-track > .cc-card:nth-child(5) { animation-delay: .42s; }
  .community-carousel.in .cc-track > .cc-card:nth-child(6) { animation-delay: .51s; }
  @keyframes ccCardRise {
    from { opacity: 0; translate: 0 54px; }
    to   { opacity: 1; translate: 0 0; }
  }

  /* footer chrome eases up last */
  .community-carousel.in .cc-foot {
    animation: ccCardRise .8s cubic-bezier(.2,.75,.2,1) both; animation-delay: .6s;
  }

  /* active card: its detail lines stagger up on every activation */
  .cc-card.is-active .cc-detail { transition: opacity .4s ease; transform: none; }
  .cc-card.is-active .cc-sched   { animation: ccLineRise .7s cubic-bezier(.2,.75,.2,1) both; animation-delay: .08s; }
  .cc-card.is-active .cc-title   { animation: ccLineRise .75s cubic-bezier(.2,.75,.2,1) both; animation-delay: .15s; }
  .cc-card.is-active .cc-desc    { animation: ccLineRise .8s cubic-bezier(.2,.75,.2,1) both; animation-delay: .24s; }
  .cc-card.is-active .cc-contact { animation: ccLineRise .8s cubic-bezier(.2,.75,.2,1) both; animation-delay: .34s; }
  @keyframes ccLineRise {
    from { opacity: 0; translate: 0 22px; }
    to   { opacity: 1; translate: 0 0; }
  }

  /* active card image: a slow, barely-there drift behind the text */
  .cc-card.is-active .cc-media { animation: ccDrift 18s ease-in-out infinite alternate; }
  @keyframes ccDrift {
    from { transform: scale(1.04); }
    to   { transform: scale(1.13) translate(2%, -1.5%); }
  }

  /* ---- Our History: the time axis draws itself --------------------- */
  .history-timeline .ht-line {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.25s cubic-bezier(.2,.7,.2,1) .15s;
  }
  .history-timeline.in .ht-line { clip-path: inset(0 0 0 0); }

  /* dots pop in along the line (scale prop leaves transform free for active) */
  .history-timeline .ht-dot {
    scale: 0;
    transition: scale .55s cubic-bezier(.2,.9,.3,1.5), background .35s, border-color .35s, transform .35s, box-shadow .35s;
  }
  .history-timeline.in .ht-dot { scale: 1; }
  .history-timeline.in .ht-points .ht-point:nth-child(1) .ht-dot { transition-delay: .35s; }
  .history-timeline.in .ht-points .ht-point:nth-child(2) .ht-dot { transition-delay: .45s; }
  .history-timeline.in .ht-points .ht-point:nth-child(3) .ht-dot { transition-delay: .55s; }
  .history-timeline.in .ht-points .ht-point:nth-child(4) .ht-dot { transition-delay: .65s; }
  .history-timeline.in .ht-points .ht-point:nth-child(5) .ht-dot { transition-delay: .75s; }
  .history-timeline.in .ht-points .ht-point:nth-child(6) .ht-dot { transition-delay: .85s; }
  .history-timeline.in .ht-points .ht-point:nth-child(7) .ht-dot { transition-delay: .95s; }

  /* labels fade up under their dots */
  .history-timeline .ht-plabel { opacity: 0; translate: 0 8px; transition: opacity .6s ease, translate .6s cubic-bezier(.2,.7,.2,1), color .35s; }
  .history-timeline.in .ht-plabel { opacity: 1; translate: 0 0; }
  .history-timeline.in .ht-points .ht-point:nth-child(1) .ht-plabel { transition-delay: .42s; }
  .history-timeline.in .ht-points .ht-point:nth-child(2) .ht-plabel { transition-delay: .52s; }
  .history-timeline.in .ht-points .ht-point:nth-child(3) .ht-plabel { transition-delay: .62s; }
  .history-timeline.in .ht-points .ht-point:nth-child(4) .ht-plabel { transition-delay: .72s; }
  .history-timeline.in .ht-points .ht-point:nth-child(5) .ht-plabel { transition-delay: .82s; }
  .history-timeline.in .ht-points .ht-point:nth-child(6) .ht-plabel { transition-delay: .92s; }
  .history-timeline.in .ht-points .ht-point:nth-child(7) .ht-plabel { transition-delay: 1.02s; }

  /* thumbnails rise in (translate prop leaves transform free for active scale) */
  .history-timeline.in .ht-thumb { animation: htThumbRise .9s cubic-bezier(.2,.75,.2,1) both; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(1) { animation-delay: .30s; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(2) { animation-delay: .40s; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(3) { animation-delay: .50s; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(4) { animation-delay: .60s; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(5) { animation-delay: .70s; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(6) { animation-delay: .80s; }
  .history-timeline.in .ht-thumbs > .ht-thumb:nth-child(7) { animation-delay: .90s; }
  @keyframes htThumbRise {
    from { opacity: 0; translate: 0 50px; }
    to   { opacity: 1; translate: 0 0; }
  }
  /* arrows fade in with the thumbs */
  .history-timeline.in .ht-arrow { animation: htThumbRise .8s cubic-bezier(.2,.75,.2,1) both; animation-delay: .55s; }

  /* active detail panel: era, date, body stagger; the big date wipes up */
  .ht-panel.is-active { animation: none; }
  .ht-panel.is-active .ht-era  { animation: htItemRise .65s cubic-bezier(.2,.75,.2,1) both; animation-delay: .04s; }
  .ht-panel.is-active .ht-date { animation: htDateWipe .85s cubic-bezier(.2,.7,.2,1) both; animation-delay: .12s; }
  .ht-panel.is-active .ht-desc { animation: htItemRise .7s cubic-bezier(.2,.75,.2,1) both; animation-delay: .24s; }
  .ht-panel.is-active .ht-body .btn,
  .ht-panel.is-active .ht-body > div { animation: htItemRise .7s cubic-bezier(.2,.75,.2,1) both; animation-delay: .34s; }
  @keyframes htItemRise {
    from { opacity: 0; translate: 0 18px; }
    to   { opacity: 1; translate: 0 0; }
  }
  @keyframes htDateWipe {
    from { opacity: 0; clip-path: inset(0 0 100% 0); translate: 0 6px; }
    to   { opacity: 1; clip-path: inset(0 0 0 0); translate: 0 0; }
  }
}
