/* Confiance Group — Client Stories listing + story page
   (Figma: Client Stories · Desktop, Client Stories Listing · Desktop)
   Story cards reuse .story / .story-photo / .story-body from style.css. */

/* ---------- shared: looping media with a pause control ---------- */

/* Photos stand in for the looping videos: a slow drift plays until paused.
   Swap the <img> for a muted, looping <video> when the footage arrives. */
.loop-media { position: relative; overflow: hidden; }
.loop-media > img:first-child {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: loop-drift 18s ease-in-out infinite alternate;
}
.loop-media.is-paused > img:first-child { animation-play-state: paused; }
@keyframes loop-drift {
  from { scale: 1; translate: 0 0; }
  to { scale: 1.08; translate: -1.5% -1%; }
}
.loop-toggle {
  position: absolute;
  right: 19px;
  bottom: 14px;
  z-index: 2;
  width: 49px;
  height: 49px;
  border-radius: 50%;
}
.loop-toggle img { width: 49px; height: 49px; transition: opacity 0.2s ease; }
.loop-toggle:hover img { opacity: 0.85; }
.loop-toggle:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
/* paused: the same circle with a play glyph */
.loop-toggle .icon-play { display: none; }
.loop-media.is-paused .loop-toggle .icon-pause { display: none; }
.loop-media.is-paused .loop-toggle .icon-play { display: block; }

.btn-video img { width: 24px; height: 24px; }

/* ---------- listing: intro ---------- */

.stories-intro { padding: 250px calc(120px + var(--edge)) 190px; }
.stories-intro-inner { position: relative; min-height: 319px; }
.stories-intro-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 624px;
  max-width: 100%;
  padding-top: 20px;
}
.stories-intro-copy h1 { color: var(--text-heading); }
.stories-intro-copy p { width: 560px; max-width: 100%; color: var(--text-body); }

/* the photo collage on the right (positions from the mockup's 1200px card) */
.collage { position: absolute; inset: 0; pointer-events: none; }
.collage img {
  position: absolute;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(8, 49, 42, 0.14);
}
.collage-a { left: 67.92%; top: 29px; width: 313px; height: 313px; }
.collage-b { left: 54.42%; top: 253px; width: 266px; height: 164px; }
.collage-c { left: 89.58%; top: -94px; width: 186px; height: 246px; }
.collage-d { left: 57.83%; top: -94px; width: 184px; height: 184px; }

/* landing: the photos drop into place one by one (timing modelled on Apple's
   education success stories hero). js/stories.js adds .is-ready, then .is-playing
   once the photos have loaded. Each slides down from above its slot while fading in. */
.collage.is-ready img { opacity: 0; }
.collage.is-playing img {
  animation: collage-in var(--dur) cubic-bezier(0.25, 0.46, 0.45, 0.94) var(--delay) both;
}
.collage-a { --from: -50%; --delay: 0s;    --dur: 2s; }
.collage-d { --from: -45%; --delay: 0.5s;  --dur: 2.25s; }
.collage-c { --from: -75%; --delay: 1s;    --dur: 1.25s; }
.collage-b { --from: -60%; --delay: 1.5s;  --dur: 1.5s; }
@keyframes collage-in {
  from { opacity: 0; translate: 0 var(--from); }
  to { opacity: 1; translate: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .collage.is-ready img { opacity: 1; }
  .collage.is-playing img { animation: none; }
}

/* ---------- listing: inspiration (alternating video cards) ---------- */

.inspiration {
  display: flex;
  flex-direction: column;
  gap: 64px; /* room between the title and the stories */
  padding: 80px calc(120px + var(--edge));
  background: var(--bg-mist);
}
.inspiration h2 { width: 820px; max-width: 100%; color: var(--text-heading); }
.inspiration-list { display: flex; flex-direction: column; gap: 80px; }
.feature {
  display: flex;
  align-items: center;
  gap: 80px;
}
.feature.is-flipped { flex-direction: row-reverse; }
.feature-media {
  flex: none;
  width: 600px;
  height: 450px;
  border-radius: 20px;
}
/* a light shade at the top keeps the client logo readable */
.feature-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(102, 102, 102, 0) 45%);
  pointer-events: none;
}
.feature-logo { position: absolute; z-index: 2; pointer-events: none; }
.feature-logo-a { left: 25px; top: 31px; width: 72px; height: 34.5px; }
.feature-logo-b { right: -6px; top: -12px; width: 178px; height: 100px; }
.feature-body {
  flex: 1 0 0;
  min-width: 1px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 40px;
  padding: 20px 8px;
}
.feature-copy { display: flex; flex-direction: column; gap: 8px; }
.feature-solution { font-weight: 600; font-size: 17px; line-height: 1.6; color: var(--bg-accent); }
.feature-copy h3 { font-size: 26px; letter-spacing: -0.13px; color: var(--text-link); }
.feature-copy p { color: var(--text-body); }
.feature-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* ---------- listing: all stories ---------- */

.all-stories { padding: 56px calc(120px + var(--edge)) 96px; }
.all-stories-head { display: flex; flex-direction: column; gap: 40px; margin-bottom: 64px; }
.all-stories-head h2 { width: 620px; max-width: 100%; color: var(--text-heading); }

.story-filters { display: flex; flex-wrap: wrap; gap: 16px; }
/* filter menus: a pill trigger opening the same menu card as the Contact page's
   topic dropdown. js/stories.js builds them from the hidden <select>s. */
.story-filter-select { display: none; }
.filter-dd { position: relative; }
.story-filter {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 47px;
  padding: 10px 24px;
  border: 1.5px solid var(--text-link);
  border-radius: 999px;
  background: var(--bg-base);
  color: var(--text-link);
  font-size: 17px;
  line-height: 1.3;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
/* green outline pill: same hover as the green outline buttons */
.story-filter { transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; }
.story-filter:hover { background-color: var(--bg-deep); border-color: var(--bg-deep); color: #ffffff; }
.story-filter:hover img { filter: var(--icon-to-white); }
.story-filter:focus-visible { outline: 2px solid var(--bg-accent); outline-offset: 3px; }
.story-filter img { width: 24px; height: 24px; transition: rotate 0.2s ease; }
.story-filter[aria-expanded="true"] img { rotate: 180deg; }

.filter-listbox {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: 5;
  min-width: max(100%, 240px);
  padding: 8px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 0 0 1px var(--border-subtle), 0 24px 48px rgba(8, 49, 42, 0.16);
  display: flex;
  flex-direction: column;
}
.filter-listbox[hidden] { display: none; }
.filter-option {
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--bg-ink);
  font-size: 17px;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  transition: background-color 0.12s ease;
}
.filter-option:hover,
.filter-option:focus-visible { background: var(--bg-mist); outline: none; }
.filter-option[aria-selected="true"] { background: var(--bg-soft); }

.story-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 64px 32px;
}
.story-list .story[hidden] { display: none; }
.story-list-empty { grid-column: 1 / -1; color: var(--text-muted); }
/* listing cards: client name in body colour */
.story-list .story-client { color: var(--text-body); }
.story-list .story-body h3 { font-size: 26px; letter-spacing: -0.13px; }
.story-more-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.story-list-empty[hidden] { display: none; }
/* .story-reset: outline button (btn-outline-light), no link styling */

/* the editorial layout (wide card) only applies to the
   unfiltered list; once a filter is set every story becomes a regular card */
.story-list:not(.is-filtered) .story-wide { grid-column: 1 / -1; gap: 24px; }
.story-list:not(.is-filtered) .story-wide .story-photo { aspect-ratio: 874.5 / 374.79; border-radius: 20px; }
.story-list:not(.is-filtered) .story-wide .story-body {
  flex-direction: row;
  align-items: flex-start;
  gap: 80px;
  padding: 0 20px;
}
.story-list:not(.is-filtered) .story-wide .story-meta { flex: none; width: 377px; }
.story-wide .story-more { display: none; }
.story-list:not(.is-filtered) .story-wide .story-more {
  flex: 1 0 0;
  align-self: flex-end; /* description + buttons sit on the bottom line of the title column */
  min-width: 1px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}
.story-list:not(.is-filtered) .story-wide .story-body > .btn { display: none; }


.story-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; }

/* ---------- story page ---------- */

.story-head { padding: 150px var(--gutter) 40px; display: flex; justify-content: center; }
.story-head-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 820px;
  max-width: 100%;
}
.story-head-logo { width: 155px; height: 155px; display: grid; place-items: center; }
.story-head-logo img { width: 131.75px; height: 63px; }
.story-head h1 { text-align: center; color: var(--bg-deep); }
.story-facts { display: flex; width: 100%; margin-top: 16px; }
.story-facts > div {
  flex: 1 0 0;
  min-width: 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
}
.story-facts > div + div { border-left: 1px solid var(--divider); }
.story-facts dt { font-weight: 400; font-size: 14px; line-height: 1.3; color: #6c6c6c; }
.story-facts dd { font-weight: 600; font-size: 17px; line-height: 1.6; color: var(--text-body); }

.story-hero { position: relative; aspect-ratio: 1440 / 810; max-height: 90vh; width: 100%; overflow: hidden; }
.story-hero img { width: 100%; height: 100%; object-fit: cover; }
.story-hero::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.story-hero .btn {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 1;
}

.story-main { display: flex; flex-direction: column; gap: 64px; padding: 64px 0 96px; }
.glance { display: flex; flex-direction: column; gap: 24px; }
.glance h2 { font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1.2; color: var(--text-heading); }
.glance-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.glance-stats > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 24px;
  border-radius: 14px;
  background: var(--bg-mist);
}
.glance-stats dt { order: 2; color: var(--text-body); }
.glance-stats dd { order: 1; color: var(--text-heading); }

.story-body-copy { display: flex; flex-direction: column; gap: 64px; }
.story-body-copy section { display: flex; flex-direction: column; gap: 16px; }
.story-body-copy section.is-outcome { gap: 28px; }
.story-body-copy h2 { max-width: 720px; color: var(--text-heading); }
.approach { display: flex; flex-direction: column; gap: 16px; }
.approach li { display: flex; gap: 10px; }
.approach li::before { content: "•"; flex: none; color: var(--text-muted); }
.approach strong { font-weight: 700; }
.approach strong span { color: var(--bg-accent); }

.client-quote {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 0;
  padding: 40px;
  border-radius: 16px;
  background: var(--bg-ink);
  color: #ffffff;
}
.client-quote blockquote { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.4; }
.client-quote figcaption { display: flex; flex-direction: column; gap: 2px; }
.client-quote cite { font-style: normal; font-weight: 700; font-size: 15px; }
.client-quote figcaption span { font-size: 13px; color: #c9d3cf; }

.story-figure { margin: 0; }
.story-figure img { width: 100%; aspect-ratio: 420 / 280; object-fit: cover; border-radius: 12px; }

/* more stories: a carousel that starts on the article column and runs off the right edge */
.more-stories {
  --start: max(var(--gutter), (100% - 840px) / 2);
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 100px 0 96px;
  background: var(--bg-deep);
  color: #ffffff;
}
.more-stories h2 { padding-left: var(--start); }
.more-track {
  display: flex;
  gap: 40px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--start);
  padding: 0 var(--gutter) 4px var(--start);
  scrollbar-width: none;
}
.more-track::-webkit-scrollbar { display: none; }
.more-track .story { flex: 0 0 486px; scroll-snap-align: start; }
.more-track .story-body { background: none; }
.more-track .story-client { color: #ffffff; }
.more-track .story-body h3 { font-size: 26px; letter-spacing: -0.13px; color: #ffffff; }
.more-nav { display: flex; justify-content: center; gap: 8px; }
.more-nav button { width: 48px; height: 48px; border-radius: 50%; transition: opacity 0.2s ease; }
.more-nav button img { width: 48px; height: 48px; }
.more-nav .more-prev img { rotate: 180deg; }
.more-nav button:disabled { opacity: 0.35; cursor: default; }
.more-nav button:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }

.cta-flush { padding: 0; }
.cta-flush .cta-card { border-radius: 0; padding: 112px calc(80px + var(--edge)); }

/* ---------- video dialog ---------- */

.video-modal {
  width: min(960px, calc(100% - 32px));
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--bg-ink);
  color: #ffffff;
  overflow: hidden;
}
.video-modal::backdrop { background: rgba(4, 20, 17, 0.9); }
.video-modal-frame { position: relative; aspect-ratio: 16 / 9; }
.video-modal-frame img { width: 100%; height: 100%; object-fit: cover; filter: brightness(0.45); }
.video-modal-frame p {
  position: absolute;
  inset: auto 0 50% 0;
  translate: 0 50%;
  padding: 0 32px;
  text-align: center;
}
/* close: the white × icon on its own over the top-right corner of the video */
.video-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.video-modal-close:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
.video-modal-close img { width: 24px; height: 24px; filter: brightness(0) invert(1); transition: rotate 0.3s ease; }
.video-modal-close:hover img { rotate: 90deg; }

/* ---------- smaller screens ---------- */

@media (max-width: 1024px) {
  .stories-intro { padding: 150px var(--gutter) 80px; }
  .stories-intro-inner { min-height: 0; display: flex; flex-direction: column; gap: 48px; }
  .collage { position: relative; height: 380px; }
  .collage-a { left: 22%; top: 60px; }
  .collage-b { left: 0; top: 230px; }
  .collage-c { left: auto; right: 0; top: 0; }
  .collage-d { left: 8%; top: 0; }
  .inspiration { padding: 72px var(--gutter); }
  .feature, .feature.is-flipped { flex-direction: column; align-items: stretch; gap: 24px; }
  .feature-media { width: 100%; height: auto; aspect-ratio: 600 / 450; }
  .all-stories { padding: 56px var(--gutter) 80px; }
  .story-list:not(.is-filtered) .story-wide .story-body { flex-direction: column; gap: 20px; }
  .story-list:not(.is-filtered) .story-wide .story-meta { width: auto; }
  .story-head { padding-top: 130px; }
  .more-track .story { flex-basis: 380px; }
}

@media (max-width: 640px) {
  .collage { height: 300px; }
  .collage img { scale: 0.75; transform-origin: 0 0; }
  .story-list { grid-template-columns: 1fr; }
  .story-facts { flex-direction: column; }
  .story-facts > div + div { border-left: 0; border-top: 1px solid var(--divider); }
  .glance-stats { grid-template-columns: 1fr; }
  .client-quote { padding: 28px; }
  .client-quote blockquote { font-size: 21px; }
  .more-track .story { flex-basis: 82%; }
}

@media (prefers-reduced-motion: reduce) {
  .loop-media > img:first-child,
  .loop-toggle { display: none; }
}

/* ---------- dark mode ---------- */

@media (prefers-color-scheme: dark) {
  .story-filter { border-color: var(--text-heading); color: var(--text-heading); }
  .story-filter img { filter: brightness(0) invert(1); opacity: 0.85; }
  .story-filter:hover { background-color: var(--text-heading); border-color: var(--text-heading); color: var(--bg-ink); }
  .story-filter:hover img { filter: brightness(0); }
  .filter-listbox { background: var(--bg-mist); }
  .filter-option { color: var(--text-body); }
  .filter-option:hover, .filter-option:focus-visible { background: rgba(255, 255, 255, 0.06); }
  .filter-option[aria-selected="true"] { background: rgba(143, 224, 198, 0.16); }
  .story-head h1, .story-body-copy h2 { color: var(--text-heading); }
  .client-quote { background: var(--bg-mist); }
  .collage img { box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4); }
}

/* video dialog fades in (js/stories.js adds .is-in) */
.video-modal { opacity: 0; translate: 0 12px; transition: opacity 0.25s ease, translate 0.25s ease; }
.video-modal.is-in { opacity: 1; translate: 0 0; }
.video-modal-frame video { width: 100%; height: 100%; display: block; background: #000; }


/* story page: client name in place of a logo (no client logos supplied yet) */
.story-head-client { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.2; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-heading); }

/* ---------- client stories mobile (≤640px) ---------- */
@media (max-width: 640px) {
  /* every section: 40px above and below */
  body .stories-intro { padding-top: 112px; padding-bottom: 40px; }
  body .inspiration, body .all-stories, body section.more-stories { padding-top: 40px; padding-bottom: 40px; }

  /* hero: title → description 16px */
  body .stories-intro-copy { gap: 16px; }
  body .stories-intro-copy > * { margin: 0; }

  /* hero collage per the reference: arrival top-left, shop top-right, Thrive large centre (behind), factory bottom-left */
  body .collage { position: relative; inset: auto; width: 335px; max-width: 100%; height: 371px; margin: 32px auto 0; }
  body .collage img { position: absolute; border-radius: 16px; object-fit: cover; }
  body .collage-a { left: 84px;  top: 103px; width: 234px; height: 234px; z-index: 1; }
  body .collage-d { left: 0;     top: 0;     width: 138px; height: 138px; z-index: 2; }
  body .collage-c { left: 238px; top: 9px;   width: 97px;  height: 130px; z-index: 2; }
  body .collage-b { left: 6px;   top: 277px; width: 153px; height: 94px;  z-index: 2; }

  /* filter dropdowns: 13px */
  body .story-filter, body .story-filter span, body .filter-dd button, body .filter-dd li, body .filter-dd [role="option"] { font-size: 13px; }

  /* cards: 16px inside, 8px between company, title and description; titles 20px */
  body .story-body, body .feature-body { gap: 16px; padding-top: 16px; }
  body .story-meta, body .feature-copy { display: flex; flex-direction: column; gap: 8px; }
  body .story-meta > *, body .feature-copy > * { margin: 0; }
  body .story-list .story-body h3, body .feature-copy h3, body .story h3.t-subheading { font-size: 20px; line-height: 1.3; }
  body .story-list { display: flex; flex-direction: column; gap: 40px; }
}
@media (max-width: 640px) { body .filter-option { font-size: 13px; } }
@media (max-width: 640px) { body .collage img { scale: 1; transform-origin: 0 0; } }

@media (max-width: 640px) {
  /* filter menus: as wide as their longest option, never wider than the screen */
  body .filter-listbox { width: max-content; min-width: 100%; max-width: calc(100vw - 2 * var(--gutter)); right: auto; }
  body .filter-option { padding-top: 8px; padding-bottom: 8px; }

  /* story detail: company name centred, title case, 13px Source Sans 3 */
  body .story-head-client { font-family: var(--font-body); font-weight: 600; font-size: 13px; line-height: 1.4; letter-spacing: 0; text-transform: none; text-align: center; }
  body .story-head { padding: 112px var(--gutter) 40px; }
  body .story-main { padding-top: 40px; padding-bottom: 40px; gap: 40px; }
  body .story-body-copy { gap: 40px; }

  /* more stories: horizontal only, arrows closer to the cards */
  body .more-track { overflow-y: hidden; padding-bottom: 0; gap: 16px; }
  body section.more-stories { gap: 16px; }
}

/* story detail: company name in black, as written (title case), all sizes */
body .story-head-client { color: #000000; text-transform: none; }
@media (prefers-color-scheme: dark) { body .story-head-client { color: #ffffff; } }

/* hero <picture> wrapper: lay out as if the img were a direct child */
.story-hero picture { display: contents; }
