/* ==========================================================================
   Hexmodal Case Study Pop-up — module.css
   Scoped under .hxcs. Same tokens as the install map, KPI counters and
   platform demo: Red Hat Display, Hexmodal blue, liquid glass.
   ========================================================================== */
.hxcs {
  --hxc-accent: #4253F1;
  --hxc-font: inherit;
  --hxc-ink: #121212;
  --hxc-ink-2: #3F403C;
  --hxc-ink-3: #6E6E6E;
  --hxc-radius: 30px;
  --hxc-pill: 999px;
  --hxc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --hxc-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --hxc-card-w: 250px;
  --hxc-card-ratio: 1.294;
  font-family: var(--hxc-font);
  color: var(--hxc-ink-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.hxcs *, .hxcs *::before, .hxcs *::after { box-sizing: border-box; }
.hxcs__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Overlay ---------- */
.hxcs__overlay {
  position: fixed; inset: 0; z-index: 2147483000;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 32px);
  -webkit-tap-highlight-color: transparent;
}
.hxcs__overlay[hidden] { display: none; }
.hxcs__backdrop {
  position: absolute; inset: 0;
  background: rgba(18, 18, 18, 0.42);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  opacity: 0; transition: opacity 520ms var(--hxc-ease-out);
}
.hxcs__glow { position: absolute; inset: 0; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 900ms var(--hxc-ease-out); }
.hxcs__glow span {
  position: absolute; width: 46vmax; aspect-ratio: 1; border-radius: 50%; filter: blur(60px); opacity: 0.32;
  background: radial-gradient(circle at 40% 40%, var(--hxc-accent) 0%, rgba(66, 83, 241, 0) 66%);
  animation: hxc-drift 16s ease-in-out infinite alternate;
}
.hxcs__glow span:nth-child(1) { left: -14vmax; top: -10vmax; }
.hxcs__glow span:nth-child(2) { right: -16vmax; bottom: -14vmax; opacity: 0.22; animation-delay: -7s; background: radial-gradient(circle at 50% 50%, #7FD3FF 0%, rgba(127, 211, 255, 0) 66%); }
@keyframes hxc-drift { from { transform: translate3d(-4%, -3%, 0) scale(1); } to { transform: translate3d(6%, 5%, 0) scale(1.14); } }

.hxcs__overlay.is-open .hxcs__backdrop, .hxcs__overlay.is-open .hxcs__glow { opacity: 1; }

/* ---------- Dialog (liquid glass) ---------- */
.hxcs__dialog {
  position: relative; isolation: isolate;
  width: min(100%, 440px);
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow: auto; overscroll-behavior: contain;
  padding: clamp(28px, 4vw, 40px);
  border-radius: var(--hxc-radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.74) 50%, rgba(255, 255, 255, 0.86) 100%);
  -webkit-backdrop-filter: blur(26px) saturate(190%) brightness(1.04);
  backdrop-filter: blur(26px) saturate(190%) brightness(1.04);
  box-shadow:
    inset 0 1.5px 1px rgba(255, 255, 255, 0.95),
    inset 0 -1.5px 1px rgba(255, 255, 255, 0.5),
    inset 0 -50px 80px -50px rgba(66, 83, 241, 0.16),
    0 0 0 0.5px rgba(18, 18, 18, 0.08),
    0 2px 6px rgba(18, 18, 18, 0.05),
    0 40px 90px -30px rgba(18, 18, 18, 0.5),
    0 60px 120px -50px rgba(66, 83, 241, 0.55);
  opacity: 0; transform: translate3d(0, 28px, 0) scale(0.96);
  transition: opacity 560ms var(--hxc-ease-out), transform 720ms var(--hxc-ease-spring), width 700ms var(--hxc-ease-out), height 700ms var(--hxc-ease-out);
  scrollbar-width: thin;
}
.hxcs__dialog::before {
  content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; padding: 1.2px; pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.25) 26%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.25) 74%, rgba(255, 255, 255, 0.9) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}
.hxcs__dialog::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(90% 55% at 16% 0%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 60%);
}
.hxcs__overlay.is-open .hxcs__dialog { opacity: 1; transform: none; }
.hxcs__overlay.is-library .hxcs__dialog { width: min(100%, 920px); }
.hxcs__dialog.is-morphing { overflow: hidden; }

.hxcs__x {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer; color: var(--hxc-ink-2);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 1), 0 0 0 0.5px rgba(18, 18, 18, 0.08), 0 6px 14px -8px rgba(18, 18, 18, 0.4);
  transition: transform 260ms var(--hxc-ease-spring), background 200ms;
}
.hxcs__x:hover { transform: scale(1.08) rotate(90deg); background: #fff; }
.hxcs__x:focus-visible { outline: 2px solid var(--hxc-accent); outline-offset: 2px; }

/* ---------- Steps ---------- */
.hxcs__step { display: none; }
.hxcs__step.is-current { display: block; animation: hxc-step-in 640ms var(--hxc-ease-out) both; animation-delay: 120ms; }
.hxcs__step.is-leaving { display: block; animation: hxc-step-out 240ms ease-in both; }
@keyframes hxc-step-in { from { opacity: 0; transform: translate3d(0, 10px, 0); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes hxc-step-out { from { opacity: 1; } to { opacity: 0; transform: scale(0.985); filter: blur(4px); } }

.hxcs__eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 7px 13px 7px 10px;
  border-radius: var(--hxc-pill); font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--hxc-ink-2);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.95), 0 0 0 0.5px rgba(18, 18, 18, 0.07);
}
.hxcs__eyebrow i { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--hxc-accent); }
.hxcs__eyebrow i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--hxc-accent); animation: hxc-ping 2.2s var(--hxc-ease-out) infinite; }
@keyframes hxc-ping { 0% { transform: scale(1); opacity: 0.5; } 80%, 100% { transform: scale(3); opacity: 0; } }

.hxcs__mark { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 18px; border-radius: 50%; color: var(--hxc-accent); background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.55)); box-shadow: inset 0 1px 1px #fff, inset 0 -6px 12px -8px rgba(66, 83, 241, 0.3), 0 0 0 0.5px rgba(18, 18, 18, 0.06), 0 10px 20px -12px var(--hxc-accent); }
.hxcs__title { margin: 0; padding-right: 28px; font-family: inherit; font-weight: 700; font-size: clamp(24px, 2.6vw, 30px); line-height: 1.12; letter-spacing: -0.022em; color: var(--hxc-ink); text-wrap: balance; }
.hxcs__title em { font-style: normal; color: var(--hxc-accent); }
.hxcs__body { margin: 10px 0 0; font-size: 15px; line-height: 1.5; color: var(--hxc-ink-2); text-wrap: pretty; }
.hxcs__sub { margin: 10px auto 0; max-width: 620px; font-size: 16px; line-height: 1.5; color: var(--hxc-ink-2); }

/* ---------- Email form ---------- */
.hxcs__form { margin-top: 22px; }
.hxcs__field { position: relative; display: flex; flex-direction: column; gap: 10px; }
.hxcs__field-icon { display: none; }
.hxcs__input {
  width: 100%; height: 50px; padding: 0 18px; border: 0; outline: none; border-radius: var(--hxc-pill);
  font-family: inherit; font-size: 16px; color: var(--hxc-ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 1px #fff, 0 0 0 0.5px rgba(18, 18, 18, 0.12), 0 12px 30px -22px rgba(18, 18, 18, 0.5);
  transition: box-shadow 240ms var(--hxc-ease-out), background 240ms;
}
.hxcs__input:focus { background: #fff; box-shadow: inset 0 1px 1px #fff, 0 0 0 2px var(--hxc-accent), 0 18px 40px -22px rgba(66, 83, 241, 0.6); }
.hxcs__input::placeholder { color: var(--hxc-ink-3); }
.hxcs__btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 0 0 auto;
  width: 100%; height: 50px; padding: 0 20px; border: 0; border-radius: var(--hxc-pill); cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; text-decoration: none; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--hxc-accent) 88%, #fff) 0%, var(--hxc-accent) 55%, color-mix(in srgb, var(--hxc-accent) 85%, #000) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 10px 22px -10px var(--hxc-accent);
  transition: transform 260ms var(--hxc-ease-spring), box-shadow 260ms var(--hxc-ease-out), filter 200ms;
}
@supports not (color: color-mix(in srgb, red, blue)) { .hxcs__btn { background: var(--hxc-accent); } }
.hxcs__btn:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 16px 30px -12px var(--hxc-accent); filter: brightness(1.05); }
.hxcs__btn:active { transform: translateY(0) scale(0.985); }
.hxcs__btn:focus-visible { outline: 2px solid var(--hxc-ink); outline-offset: 2px; }
.hxcs__btn-spin { display: none; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; border-radius: 50%; animation: hxc-spin 800ms linear infinite; }
@keyframes hxc-spin { to { transform: rotate(360deg); } }
.hxcs__form.is-busy .hxcs__btn-spin { display: block; }
.hxcs__form.is-busy .hxcs__btn-label { opacity: 0.75; }
.hxcs__form.is-busy .hxcs__btn { pointer-events: none; }
.hxcs__error { min-height: 0; margin: 8px 0 0 6px; font-size: 13.5px; line-height: 1.4; color: #C7382F; }
.hxcs__error:empty { display: none; }
.hxcs__form.is-shake .hxcs__input { animation: hxc-shake 420ms var(--hxc-ease-out); }
@keyframes hxc-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }
.hxcs__note { margin: 12px 0 0; text-align: center; font-size: 12.5px; line-height: 1.45; color: var(--hxc-ink-3); }


/* ---------- Library ---------- */
.hxcs__lib-head { text-align: center; max-width: 640px; margin: 0 auto; padding: 0 28px; }
.hxcs__lib-head .hxcs__eyebrow { margin-bottom: 12px; }
.hxcs__title--lib { padding-right: 0; font-size: clamp(21px, 2.4vw, 28px); }

.hxcs__flow {
  position: relative; margin: 14px calc(-1 * clamp(28px, 4vw, 40px)) 0; padding: 0;
  height: calc(var(--hxc-card-w) * var(--hxc-card-ratio) + 76px);
  outline: none; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
.hxcs__flow.is-dragging { cursor: grabbing; }
.hxcs__flow:focus-visible .hxcs__card.is-active .hxcs__cover { box-shadow: 0 0 0 3px var(--hxc-accent), 0 30px 60px -24px rgba(18, 18, 18, 0.55); }
.hxcs__stage {
  position: absolute; inset: 0;
  perspective: 1100px; perspective-origin: 50% 42%;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
}
.hxcs__card {
  position: absolute; left: 50%; top: 12px; margin: 0;
  width: var(--hxc-card-w);
  transform-style: preserve-3d; will-change: transform, opacity;
  cursor: pointer;
}
.hxcs__card.is-active { cursor: default; }
.hxcs__cover {
  position: relative; overflow: hidden; border-radius: 16px;
  aspect-ratio: 1 / var(--hxc-card-ratio);
  background: #fff;
  box-shadow: 0 0 0 0.5px rgba(18, 18, 18, 0.1), 0 30px 60px -24px rgba(18, 18, 18, 0.55);
  transition: box-shadow 400ms var(--hxc-ease-out);
}
.hxcs__cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.hxcs__cover::after { /* glass sheen that moves with the card angle */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.35) 48%, rgba(255, 255, 255, 0) 62%);
  opacity: var(--sheen, 0); transition: opacity 300ms;
}
.hxcs__cover {
  -webkit-box-reflect: below 4px linear-gradient(to bottom, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.16) 100%);
}
.hxcs__cover-fallback {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; height: 100%; padding: 22px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--hxc-accent) 12%, #fff) 0%, #fff 55%, color-mix(in srgb, var(--hxc-accent) 8%, #fff) 100%);
}
.hxcs__cover-kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hxc-accent); }
.hxcs__cover-fallback strong { font-size: 22px; line-height: 1.1; letter-spacing: -0.02em; color: var(--hxc-ink); }
.hxcs__cover-fallback em { font-style: normal; font-size: 14px; line-height: 1.4; color: var(--hxc-ink-2); }
.hxcs__cover-tag {
  position: absolute; left: 50%; top: calc(100% + 22px); transform: translateX(-50%) translateY(6px);
  padding: 9px 16px; border-radius: var(--hxc-pill); white-space: nowrap;
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; line-height: 1; color: var(--hxc-ink);
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 1px #fff, 0 0 0 0.5px rgba(18, 18, 18, 0.08), 0 12px 24px -14px rgba(18, 18, 18, 0.5);
  opacity: 0; transition: opacity 320ms var(--hxc-ease-out), transform 480ms var(--hxc-ease-spring);
}
.hxcs__card.is-active .hxcs__cover-tag { opacity: 1; transform: translateX(-50%) translateY(0); }

.hxcs__nav {
  position: absolute; top: calc(50% - 22px - 22px); z-index: 3;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer; color: var(--hxc-ink);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 1px #fff, 0 0 0 0.5px rgba(18, 18, 18, 0.1), 0 12px 26px -14px rgba(18, 18, 18, 0.55);
  transition: transform 260ms var(--hxc-ease-spring), background 200ms, opacity 200ms;
}
.hxcs__nav--prev { left: clamp(10px, 2.5vw, 28px); }
.hxcs__nav--next { right: clamp(10px, 2.5vw, 28px); }
.hxcs__nav:hover { background: #fff; transform: scale(1.08); }
.hxcs__nav:active { transform: scale(0.96); }
.hxcs__nav[disabled] { opacity: 0.35; cursor: default; transform: none; }
.hxcs__nav:focus-visible { outline: 2px solid var(--hxc-accent); outline-offset: 2px; }

.hxcs__dots { display: flex; justify-content: center; gap: 7px; margin: 6px 0 0; }
.hxcs__dots button {
  width: 8px; height: 8px; padding: 0; border: 0; border-radius: var(--hxc-pill); cursor: pointer;
  background: rgba(18, 18, 18, 0.18);
  transition: width 360ms var(--hxc-ease-out), background 240ms;
}
.hxcs__dots button.is-active { width: 26px; background: var(--hxc-accent); }
.hxcs__dots button:focus-visible { outline: 2px solid var(--hxc-accent); outline-offset: 3px; }

/* Active case study details */
.hxcs__details { position: relative; margin-top: 22px; }
.hxcs__detail {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px 32px; align-items: center;
  padding: 20px 4px 0; border-top: 1px solid rgba(18, 18, 18, 0.08);
}
.hxcs__detail:not(.is-active) { position: absolute; inset: 0; opacity: 0; pointer-events: none; visibility: hidden; }
.hxcs__detail.is-active { animation: hxc-detail-in 460ms var(--hxc-ease-out) both; }
@keyframes hxc-detail-in { from { opacity: 0; transform: translate3d(0, 10px, 0); } to { opacity: 1; transform: none; } }
.hxcs__detail-tag { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--hxc-accent); }
.hxcs__detail-title { margin: 0; font-family: inherit; font-size: clamp(17px, 1.7vw, 20px); font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; color: var(--hxc-ink); text-wrap: balance; }
.hxcs__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.hxcs__stats li { display: flex; flex-direction: column; gap: 2px; }
.hxcs__stats li::before { content: none; }
.hxcs__stats strong { font-size: clamp(18px, 1.8vw, 22px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; color: var(--hxc-accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hxcs__stats span { font-size: 12px; line-height: 1.3; color: var(--hxc-ink-3); }
.hxcs__btn--read { width: auto; margin-top: 14px; height: 42px; font-size: 14px; }

/* ---------- Editor preview: inline, not fixed ---------- */
.hxcs--editor .hxcs__editor-note { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: rgba(66, 83, 241, 0.08); font-size: 13px; line-height: 1.45; color: var(--hxc-ink-2); }
.hxcs--editor .hxcs__overlay { position: relative; inset: auto; z-index: auto; display: block; padding: 24px; border-radius: 24px; overflow: hidden; background: linear-gradient(135deg, #EEF0FF, #F7F7F7); }
.hxcs--editor .hxcs__overlay[hidden] { display: block; }
.hxcs--editor .hxcs__backdrop { display: none; }
.hxcs--editor .hxcs__glow { opacity: 1; }
.hxcs--editor .hxcs__dialog { width: min(100%, 920px); max-height: none; margin: 0 auto; opacity: 1; transform: none; overflow: visible; }
.hxcs--editor .hxcs__step { display: block !important; animation: none !important; }
.hxcs--editor .hxcs__step--library { margin-top: 36px; padding-top: 28px; border-top: 1px dashed rgba(18, 18, 18, 0.2); }
.hxcs--editor .hxcs__x { pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hxcs { --hxc-card-w: 220px; }
  .hxcs__detail { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 640px) {
  .hxcs { --hxc-card-w: min(58vw, 230px); }
  .hxcs__overlay { padding: 0; align-items: flex-end; }
  .hxcs__dialog { width: 100%; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); padding: 28px 22px 30px; border-radius: 28px 28px 0 0; transform: translate3d(0, 40px, 0); }
  .hxcs__overlay.is-library .hxcs__dialog { width: 100%; }
  .hxcs__dialog::before { border-radius: 28px 28px 0 0; }
  .hxcs__title { font-size: 23px; padding-right: 30px; }
  .hxcs__title--lib { font-size: 19px; }
  .hxcs__flow { margin: 14px -20px 0; height: calc(var(--hxc-card-w) * var(--hxc-card-ratio) + 70px); }
  .hxcs__nav { display: none; }
  .hxcs__stage { perspective: 900px; }
  .hxcs__lib-head { padding: 0 10px; }
  .hxcs__detail { padding: 16px 0 0; gap: 12px; }
  .hxcs__detail-main { display: contents; }
  .hxcs__detail-tag { order: 0; margin: 0; }
  .hxcs__detail-title { order: 1; }
  .hxcs__stats { order: 2; }
  .hxcs__btn--read { order: 3; margin-top: 4px; }
  .hxcs__stats { gap: 8px; }
  .hxcs__btn--read { width: 100%; }
  .hxcs__lib-head { padding: 0 24px 0 4px; text-align: left; }
  .hxcs--editor .hxcs__overlay { padding: 14px; align-items: stretch; }
  .hxcs--editor .hxcs__dialog { border-radius: 24px; }
}
@media (max-height: 700px) and (min-width: 641px) {
  .hxcs { --hxc-card-w: 200px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .hxcs *, .hxcs *::before, .hxcs *::after { animation: none !important; transition-duration: 1ms !important; }
  .hxcs__dialog { transform: none; }
}
