/* ==========================================================================
   REVE Chat Version 4 homepage: customer stories (#stories), the one dark section.
   Design: Stories in reve-chat-website src/creative/Rest.jsx (https://reve-chat-website.vercel.app/#stories).
   Markup: template-parts/rc-v4-homepage/stories.php, behaviour: js/rc-v4-homepage/stories.js.
   Shared pieces (container, section padding, heading, buttons, reveal) come from css/rc-v4-base.css.
   Desktop: heading, a row of four story tabs, then the story (big outcome figure left, copy right).
   Up to 860px: the story comes first and the tabs become a dark pill bar that floats at the bottom of the screen.
   ========================================================================== */

.rc-stories {
  --rc-stories-color: #ff3d86;            /* colour of the open story (set by PHP/JS) */
  --rc-stories-text: #f4f2fb;
  --rc-stories-text-2: rgba(244, 242, 251, 0.78);
  --rc-stories-text-3: rgba(244, 242, 251, 0.6);
  --rc-stories-line: rgba(255, 255, 255, 0.11);
  overflow: clip;
  background: #07060d;
  color: var(--rc-stories-text);
}
.rc-stories :focus-visible { outline-color: var(--rc-violet-light); }

/* coloured light behind the story; follows the open story's colour */
.rc-stories .rc-stories-glow {
  position: absolute; inset: auto -10% -30% 25%; height: 80%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--rc-stories-color) 55%, transparent), transparent);
  filter: blur(40px); opacity: 0.55; transition: background 0.8s; pointer-events: none;
}
.rc-stories .rc-stories-container { position: relative; }

/* ---------- heading: title on top; description left and "View all case studies" right (stacked up to 860px) ---------- */
.rc-stories .rc-stories-title { max-width: 15ch; color: var(--rc-stories-text); }
.rc-stories .rc-stories-title em { color: var(--rc-violet-light); }
.rc-stories .rc-stories-head-aside { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; max-width: 440px; }
.rc-stories .rc-stories-subtitle { color: var(--rc-stories-text-2); }
.rc-stories .rc-stories-all-link {
  display: inline-flex; align-items: center; gap: 6px; padding-bottom: 2px; border-bottom: 1px solid currentColor;
  font-family: var(--rc-font); font-size: 15px; font-weight: 500; line-height: 1.55; color: var(--rc-stories-text);
  transition: gap 0.2s var(--rc-ease);
}
.rc-stories .rc-stories-all-link:hover { gap: 10px; color: var(--rc-stories-text); }

@media (min-width: 768px) {
  .rc-stories .rc-stories-title { max-width: none; }
}
@media (min-width: 861px) {
  .rc-stories .rc-stories-head {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 40px; row-gap: 16px; align-items: end; max-width: none;
  }
  .rc-stories .rc-stories-title { grid-column: 1 / -1; }
  .rc-stories .rc-stories-head-aside { display: contents; }
  .rc-stories .rc-stories-subtitle { grid-column: 1; grid-row: 2; max-width: 56ch; }
  .rc-stories .rc-stories-all-link { grid-column: 2; grid-row: 2; align-self: end; justify-self: end; }
}

/* ---------- story tabs (desktop: four columns under a hairline; the open one gets a coloured top bar) ---------- */
.rc-stories .rc-stories-tabs {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  border-top: 1px solid var(--rc-stories-line); margin-bottom: 32px;
}
.rc-stories .rc-stories-tab {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 18px 16px 16px 20px; text-align: left; font-size: 16px; line-height: 1.55; color: var(--rc-stories-text-3);
  transition: color 0.25s, background-color 0.25s;
}
.rc-stories .rc-stories-tab::before {
  content: ''; position: absolute; left: 0; top: -1px; width: 0; height: 3px;
  background: var(--rc-stories-tab-color); transition: width 0.5s var(--rc-ease);
}
.rc-stories .rc-stories-tab:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.rc-stories .rc-stories-tab.is-on {
  background: linear-gradient(180deg, color-mix(in srgb, var(--rc-stories-tab-color) 14%, transparent), transparent); color: #fff;
}
.rc-stories .rc-stories-tab.is-on::before { width: 100%; }
.rc-stories .rc-stories-tab-brand {
  display: block; font-size: clamp(18px, 1.55vw, 22px); font-weight: 500; line-height: 1.55; letter-spacing: -0.012em;
}
.rc-stories .rc-stories-tab-area {
  display: block; font-family: var(--rc-font-label); font-size: 11px; font-weight: 400; line-height: 1.55;
  letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7;
}

/* ---------- the open story ---------- */
.rc-stories .rc-stories-story {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 80px); align-items: center;
  animation: rc-stories-swap 0.6s var(--rc-ease);
}
@keyframes rc-stories-swap { from { opacity: 0; transform: translateY(14px) scale(0.985); } }

/* outcome: label pill, big serif figure, what it means, a note pill */
.rc-stories .rc-stories-metric-label,
.rc-stories .rc-stories-metric-note {
  display: inline-block; margin-top: 14px; padding: 6px 12px; border: 1px solid var(--rc-stories-line); border-radius: 999px;
  font-size: 13px; font-weight: 400; line-height: 1.55; color: var(--rc-stories-text-2);
}
.rc-stories .rc-stories-metric-label {
  margin-bottom: 12px; font-family: var(--rc-font-label); letter-spacing: 0.12em; text-transform: uppercase;
}
.rc-stories .rc-stories-metric-value {
  display: block; font-family: var(--rc-font-serif); font-style: italic; font-weight: 400;
  font-size: clamp(110px, 17vw, 250px); line-height: 0.9; letter-spacing: -0.05em;
  color: var(--rc-stories-color); text-shadow: 0 0 80px color-mix(in srgb, var(--rc-stories-color) 40%, transparent);
}
.rc-stories .rc-stories-metric-text { margin-top: 16px; max-width: 380px; font-size: 18px; line-height: 1.45; color: #fff; }

/* copy: customer, title, description, products used, button */
.rc-stories .rc-stories-copy { gap: 16px; }
.rc-stories .rc-stories-customer {
  gap: 12px; width: 100%; padding-bottom: 16px; border-bottom: 1px solid var(--rc-stories-line);
  font-family: var(--rc-font-text); font-size: 16px; line-height: 1.55;
}
.rc-stories .rc-stories-customer-name { display: block; font-size: 22px; font-weight: 600; letter-spacing: -0.012em; }
.rc-stories .rc-stories-customer-area {
  display: block; padding: 4px 12px; border-radius: 999px; font-size: 13px; color: #fff;
  background: color-mix(in srgb, var(--rc-stories-color) 18%, transparent);
}
.rc-stories .rc-stories-story-title {
  font-family: var(--rc-font); font-size: clamp(24px, 2.4vw, 34px); font-weight: 500; line-height: 1.12; letter-spacing: -0.014em;
  color: var(--rc-stories-text);
}
.rc-stories .rc-stories-story-text { font-family: var(--rc-font-text); font-size: 16.5px; line-height: 1.7; color: var(--rc-stories-text-2); }
.rc-stories .rc-stories-used { gap: 3px; font-family: var(--rc-font-text); font-size: 14px; line-height: 1.55; color: var(--rc-stories-text); }
.rc-stories .rc-stories-used-label {
  display: block; font-family: var(--rc-font-label); font-size: 10.5px; font-weight: 400; line-height: 1.55;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--rc-stories-text-3);
}
.rc-stories .rc-stories-cta { margin-top: 8px; }

/* ---------- section rhythm: 80 / 64 / 48 ---------- */
@media (max-width: 1000px) { .rc-stories.rc-section { padding: 64px 0; } }
@media (max-width: 700px) { .rc-stories.rc-section { padding: 48px 0; } }

/* ---------- up to 860px: story first, tab bar underneath that floats 12px above the bottom of the screen ---------- */
@media (max-width: 860px) {
  .rc-stories .rc-stories-all-link { min-height: 44px; padding-block: 10px; }
  .rc-stories .rc-stories-cta { min-height: 44px; }

  .rc-stories .rc-stories-panel { display: flex; flex-direction: column; gap: 20px; }
  /* every story takes the height of the tallest one, so switching tabs never shifts the page */
  .rc-stories .rc-stories-story { order: 1; grid-template-columns: minmax(0, 1fr); min-height: 712px; }

  .rc-stories .rc-stories-tabs {
    order: 2; position: sticky; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
    display: flex; flex-direction: row; gap: 4px; padding: 6px; margin: 0;
    overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; background: rgba(18, 16, 32, 0.88);
    -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
    box-shadow: 0 16px 36px -14px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
  .rc-stories .rc-stories-tabs::-webkit-scrollbar { display: none; }
  .rc-stories .rc-stories-tab {
    flex: none; display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px;
    height: 44px; min-height: 44px; padding: 0 18px; border-radius: 999px; background: transparent;
    font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; text-align: center; scroll-snap-align: center;
    color: rgba(255, 255, 255, 0.66); transition: background-color 0.25s, color 0.25s, box-shadow 0.25s;
  }
  .rc-stories .rc-stories-tab::before,
  .rc-stories .rc-stories-tab-area { display: none; }
  .rc-stories .rc-stories-tab-brand {
    display: inline-flex; align-items: center; gap: 8px; font-size: inherit; font-weight: inherit; letter-spacing: inherit;
  }
  /* colour dot in front of each customer name */
  .rc-stories .rc-stories-tab-brand::before {
    content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--rc-stories-tab-color); opacity: 0.7;
  }
  .rc-stories .rc-stories-tab:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
  .rc-stories .rc-stories-tab.is-on,
  .rc-stories .rc-stories-tab.is-on:hover { background: #fff; color: var(--rc-ink); box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.6); }
  .rc-stories .rc-stories-tab.is-on .rc-stories-tab-brand::before { opacity: 1; }
}
@media (max-width: 420px) { .rc-stories .rc-stories-story { min-height: 764px; } }
@media (max-width: 350px) { .rc-stories .rc-stories-story { min-height: 792px; } }
@media (max-width: 335px) { .rc-stories .rc-stories-story { min-height: 840px; } }

@media (prefers-reduced-motion: reduce) {
  .rc-stories .rc-stories-story { animation: none; }
  .rc-stories .rc-stories-glow,
  .rc-stories .rc-stories-tab,
  .rc-stories .rc-stories-tab::before { transition: none; }
}
