/* ============================================================
   TGC: the rituals, as pit boards

   Default (phones, reduced motion, no JS): a native snap scroller.
   Desktop with motion: scripts/tgc-rituals.js adds .rituals--pin and
   the stage pins while the rail scrubs sideways.
   ============================================================ */

.rituals {
  border-block: 1px solid var(--line);
  /* rail edges line up with .shell's content edge */
  --rpad: max(var(--gutter), calc((100% - 1720px) / 2 + var(--gutter)));
}
.rituals__stage { padding-block: var(--space-section); }
/* match .shell's side-nav reserve (sections-b.css) */
@media (min-width: 1280px) {
  .rituals { --rpad-start: calc(var(--rpad) + 5.5rem); }
}

/* ---------- head + progress ---------- */
.rituals__head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: clamp(1.4rem, 3vw, 2.4rem);
}
.rituals__title { font-size: var(--text-section); margin: 0.8rem 0 0; max-width: 20ch; }
.rituals__prog { display: grid; gap: 0.55rem; justify-items: end; }
.rituals__prog b { color: var(--accent); font-weight: 700; }
.rituals__segs { display: flex; gap: 4px; }
.rituals__segs i {
  width: clamp(28px, 4vw, 52px); height: 4px;
  background: var(--line);
  position: relative; overflow: hidden;
}
.rituals__segs i::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--d3) var(--ease-out);
}
.rituals__segs i.is-done::after { transform: scaleX(1); }

/* ---------- the rail (snap scroller by default) ---------- */
.rituals__rail {
  position: relative;   /* offsetParent for the travel maths */
  display: flex; gap: clamp(0.75rem, 1.4vw, 1.25rem);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-inline: var(--rpad);
  scroll-padding-inline: var(--rpad);
  padding-inline-start: var(--rpad-start, var(--rpad));
  scroll-padding-inline-start: var(--rpad-start, var(--rpad));
  padding-bottom: 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.rituals__rail:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- a card ---------- */
.ritual {
  flex: 0 0 clamp(270px, 82vw, 460px);
  aspect-ratio: 3 / 4;
  scroll-snap-align: start;
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(1rem, 2vw, 1.6rem);
  background: #0d0d0d;
  border: 1px solid var(--line);
  color: #f2f2f0;
}
.ritual__media { position: absolute; inset: 0; z-index: -2; margin: 0; overflow: hidden; transition: transform 900ms var(--ease-out); }
.ritual__media img {
  position: absolute; top: 0; left: -6%;
  width: 112%; max-width: none; height: 100%;
  object-fit: cover;
  opacity: 0.5;
  filter: grayscale(0.6) contrast(1.1) brightness(0.85);
  transition: opacity var(--d3) var(--ease-out), filter var(--d3) var(--ease-out);
}
.ritual.is-on .ritual__media img { opacity: 0.88; filter: grayscale(0) contrast(1.08); }
.ritual:hover .ritual__media { transform: scale(1.04); }
/* the board: dark top for the timing strip, dark foot for the copy */
.ritual::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(5,5,5,.78) 0%, rgba(5,5,5,0) 26%, rgba(5,5,5,0) 42%, rgba(5,5,5,.94) 80%);
}
/* lit edge on the live card */
.ritual::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 3px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--d3) var(--ease-out);
}
.ritual.is-on::after, .ritual:hover::after { transform: scaleX(1); }

/* timing strip */
.ritual__board { display: flex; align-items: center; gap: 0.75rem; }
.ritual__lap {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 70%, calc(100% - 7px) 100%, 0 100%);
  transition: background-color var(--d3), color var(--d3);
}
.ritual.is-on .ritual__lap { background: var(--accent); color: #050505; }
.ritual__sectors { display: flex; flex: 1; gap: 3px; max-width: 12rem; }
.ritual__sectors i {
  flex: 1; position: relative;
  font: 500 0.6rem/1 var(--font-mono); font-style: normal; letter-spacing: 0.08em;
  color: rgba(242,242,240,.55);
  padding-bottom: 6px;
}
.ritual__sectors i::before, .ritual__sectors i::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(242,242,240,.18);
}
.ritual__sectors i::after {
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 420ms var(--ease-out);
}
.ritual.is-on .ritual__sectors i::after { transform: scaleX(1); }
.ritual.is-on .ritual__sectors i:nth-child(2)::after { transition-delay: 160ms; }
.ritual.is-on .ritual__sectors i:nth-child(3)::after { transition-delay: 320ms; }

/* giant number */
.ritual__no {
  position: absolute; z-index: -1;
  right: clamp(0.6rem, 1.4vw, 1.2rem); top: clamp(2.8rem, 6vh, 4rem);
  font-size: clamp(5rem, 3rem + 7vw, 10.5rem); font-weight: 700;
  line-height: 0.8; letter-spacing: -0.06em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--accent);
  transition: color var(--d3) var(--ease-out);
}
.ritual.is-on .ritual__no { color: color-mix(in srgb, var(--accent) 88%, transparent); }

/* copy */
.ritual__copy { display: grid; gap: 0.7rem; }
.ritual__title {
  font-family: var(--display-face); font-weight: 700; text-transform: uppercase;
  font-size: clamp(1.7rem, 1rem + 2.4vw, 3.2rem); line-height: 0.92;
  margin: 0;
}
.ritual__body { margin: 0; max-width: 36ch; font-size: clamp(0.9rem, 0.85rem + 0.2vw, 1rem); color: rgba(242,242,240,.78); }
.ritual__cap { margin: 0; color: rgba(242,242,240,.45); font-size: 0.62rem; }

/* ---------- desktop: pinned stage, scrubbed rail ---------- */
.rituals--pin .rituals__stage {
  height: 100vh; height: 100svh;
  display: flex; flex-direction: column;
  padding-block: clamp(4.5rem, 10vh, 7rem) clamp(1.5rem, 4vh, 3rem);
  overflow: clip;
}
.rituals--pin .rituals__rail {
  flex: 1; min-height: 0;
  overflow: visible;
  scroll-snap-type: none;
  padding-bottom: 0;
  will-change: transform;
}
.rituals--pin .ritual {
  flex: 0 0 auto;
  height: 100%; max-height: 680px;
  aspect-ratio: 4 / 5;
}
/* the crowd shot is the wide one */
.rituals--pin .ritual:nth-child(3) { aspect-ratio: 5 / 4; }
