/* How It Works — premium ecosystem composition */

.hiw-section {
  --hiw-blue: #2a67fd;
  --hiw-blue-soft: #4b7fff;
  --hiw-green: #87bd3f;
  --hiw-ink: #101828;
  --hiw-muted: #667085;
  --hiw-line: #e5e7eb;
  --hiw-soft: #f5f7fb;
  --hiw-card-w: 12.75rem;
  --hiw-devices-inset: 14.75rem;
  --hiw-browser-zoom: 0.52;
  --hiw-phone-w: 12.75rem;
  position: relative;
  isolation: isolate;
  background: #fff;
}

.hiw-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 5.5rem 0 2.75rem;
  overflow: hidden;
}

.hiw-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.hiw-bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 42% at 42% 48%, rgba(42, 103, 253, 0.09), transparent 62%),
    radial-gradient(ellipse 40% 36% at 68% 42%, rgba(135, 189, 63, 0.07), transparent 58%),
    linear-gradient(180deg, #f7f9ff 0%, #ffffff 46%, #f8fafc 100%);
}

.hiw-bg-grid {
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(42, 103, 253, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 103, 253, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 65% 55% at 50% 45%, #000 20%, transparent 72%);
}

.hiw-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.4;
}

.hiw-bg-orb--a {
  width: 26rem;
  height: 26rem;
  top: 18%;
  left: 22%;
  background: rgba(42, 103, 253, 0.14);
}

.hiw-bg-orb--b {
  width: 18rem;
  height: 18rem;
  top: 22%;
  right: 18%;
  background: rgba(135, 189, 63, 0.1);
}

.hiw-bg-orb--c {
  width: 16rem;
  height: 16rem;
  bottom: 12%;
  left: 48%;
  background: rgba(42, 103, 253, 0.06);
}

/* Chapter intro — same language as Web / Driver experience */
.hiw-chapter {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 5.5rem 1.5rem 3rem;
  pointer-events: none;
  will-change: opacity, transform;
  transform-origin: center 42%;
}

.hiw-chapter-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  max-width: 40rem;
}

.hiw-chapter-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(42, 103, 253, 0.1);
  color: var(--hiw-blue);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hiw-badge-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--hiw-blue);
  box-shadow: 0 0 0 3px rgba(42, 103, 253, 0.16);
}

.hiw-chapter-title {
  margin: 0;
  font-size: clamp(2rem, 4.6vw, 3.35rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  color: var(--hiw-ink);
}

.hiw-chapter-title-accent {
  color: var(--hiw-blue);
}

.hiw-chapter-sub {
  margin: 0;
  max-width: 34rem;
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  line-height: 1.55;
  color: var(--hiw-muted);
}

.hiw-brand-word {
  font-family: var(--font-footer-watermark);
  font-style: italic;
  font-weight: 400;
  color: var(--hiw-blue);
  letter-spacing: -0.02em;
}

.hiw-chapter-scroll {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #98a2b3;
}

.hiw-chapter-scroll-arrow {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  animation: hiw-chapter-bounce 1.4s ease-in-out infinite;
}

@keyframes hiw-chapter-bounce {
  0%,
  100% {
    transform: translateY(0) rotate(45deg);
  }
  50% {
    transform: translateY(4px) rotate(45deg);
  }
}

.hiw-story {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  will-change: opacity;
}

.hiw-container {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  flex: 1;
}

.hiw-story-head {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  max-width: min(56rem, 100%);
  margin: 0 auto;
  padding: 0 0.5rem;
  will-change: transform;
}

.hiw-story-title {
  margin: 0;
  font-size: clamp(1.28rem, 1.55vw + 0.55rem, 1.72rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--hiw-ink);
  white-space: nowrap;
}

.hiw-story-head .hiw-chapter-sub {
  font-size: clamp(0.88rem, 1.2vw, 0.98rem);
  max-width: 36rem;
}

/* Stage */
.hiw-stage {
  position: relative;
  width: 100%;
  height: min(44rem, calc(100dvh - 12.5rem));
  flex: 1;
}

.hiw-connectors-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.hiw-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.7;
}

.hiw-devices {
  position: absolute;
  left: var(--hiw-devices-inset);
  right: var(--hiw-devices-inset);
  top: 3.75rem;
  bottom: 5.5rem;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.hiw-devices-inner {
  position: relative;
  width: 100%;
  max-width: 52rem;
  height: 100%;
  will-change: transform;
  transform-origin: center center;
}

.hiw-device--browser {
  position: absolute;
  left: 0;
  top: 50%;
  translate: 0 -46%;
  z-index: 1;
}

.hiw-device--phone {
  position: absolute;
  right: 0;
  top: 50%;
  translate: 0 -48%;
  z-index: 6;
}

.hiw-section .hiw-te-browser.te-browser {
  zoom: var(--hiw-browser-zoom);
}

.hiw-section .hiw-de-phone.de-phone {
  width: var(--hiw-phone-w);
  filter: drop-shadow(0 22px 40px rgba(16, 24, 40, 0.22));
}

.hiw-cards {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  will-change: transform;
}

.hiw-cards .hiw-card {
  pointer-events: auto;
}

.hiw-card {
  position: absolute;
  z-index: 8;
  width: var(--hiw-card-w);
}

/*
  Organic constellation — top arc fills the browser crown;
  side rails + bottom arc sit clear of the device cluster.
*/
.hiw-card--nw {
  /* Access Control — fills the left crown above the dashboard */
  left: 16%;
  top: -1.2%;
  rotate: -1.2deg;
}
.hiw-card--n {
  /* Company Setup — sits over browser center, not the phone gap */
  left: 33%;
  top: 0;
  rotate: 0.6deg;
}
.hiw-card--ne {
  right: 0.5%;
  top: 2.5%;
  rotate: 1.4deg;
}

.hiw-card--w1 {
  left: 0.25%;
  top: 12%;
  rotate: 1deg;
}
.hiw-card--e1 {
  right: 0.25%;
  top: 19%;
  rotate: -1.1deg;
}

.hiw-card--w2 {
  left: 1%;
  top: 28%;
  rotate: -1deg;
}
.hiw-card--e2 {
  right: 0.75%;
  top: 39%;
  rotate: 1.2deg;
}

.hiw-card--w3 {
  left: 0.25%;
  top: 44%;
  rotate: 0.8deg;
}
.hiw-card--e3 {
  right: 0.25%;
  top: 59%;
  rotate: -1.4deg;
}

.hiw-card--w4 {
  left: 1%;
  top: 60%;
  rotate: -0.9deg;
}

/* Bottom arc — pulled left to sit under Access Control / Company Setup */
.hiw-card--s {
  left: 8%;
  top: auto;
  bottom: 0.6%;
  rotate: 0.7deg;
}
.hiw-card--se {
  left: 24%;
  top: auto;
  bottom: 1.2%;
  rotate: -0.5deg;
}

.hiw-card-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.65rem 0.72rem;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(229, 231, 235, 0.98);
  box-shadow:
    0 10px 28px rgba(16, 24, 40, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.hiw-card:hover .hiw-card-inner {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(42, 103, 253, 0.28);
  box-shadow: 0 16px 36px rgba(42, 103, 253, 0.12);
}

.hiw-card-icon {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.6rem;
  display: grid;
  place-items: center;
  background: rgba(42, 103, 253, 0.1);
  color: var(--hiw-blue);
  flex-shrink: 0;
}

.hiw-card strong {
  display: block;
  font-size: 0.76rem;
  color: var(--hiw-ink);
  letter-spacing: -0.01em;
  margin-bottom: 0.08rem;
}

.hiw-card p {
  margin: 0;
  font-size: 0.64rem;
  line-height: 1.35;
  color: var(--hiw-muted);
}

/* Wide desktop — roomier constellation (MacBook 14 / 15+) */
@media (min-width: 1440px) {
  .hiw-section {
    --hiw-card-w: 13.35rem;
    --hiw-devices-inset: 15.75rem;
    --hiw-browser-zoom: 0.52;
    --hiw-phone-w: 12.75rem;
  }

  .hiw-devices {
    top: 4.35rem;
    bottom: 6.1rem;
  }

  .hiw-devices-inner {
    max-width: 54rem;
  }

  .hiw-card-inner {
    padding: 0.7rem 0.78rem;
    gap: 0.55rem;
  }

  .hiw-card strong {
    font-size: 0.78rem;
  }

  .hiw-card p {
    font-size: 0.66rem;
  }

  .hiw-card--nw { left: 15.5%; top: -1.4%; }
  .hiw-card--n { left: 32%; top: 0; }
  .hiw-card--ne { right: 0.35%; top: 2%; }
  .hiw-card--w1 { left: 0; top: 11%; }
  .hiw-card--w2 { left: 1.15%; top: 27%; }
  .hiw-card--w3 { left: 0.15%; top: 43%; }
  .hiw-card--w4 { left: 1%; top: 59%; }
  .hiw-card--e1 { right: 0; top: 17%; }
  .hiw-card--e2 { right: 0.65%; top: 37%; }
  .hiw-card--e3 { right: 0; top: 57%; }
  .hiw-card--s { left: 8%; bottom: 0.4%; }
  .hiw-card--se { left: 24%; bottom: 1.1%; }
}

/* Mid desktop constellation — keep devices smaller so cards stay clear */
@media (min-width: 1281px) and (max-width: 1439px) {
  .hiw-section {
    --hiw-card-w: 11.5rem;
    --hiw-devices-inset: 12.85rem;
    --hiw-browser-zoom: 0.42;
    --hiw-phone-w: 10.85rem;
  }

  .hiw-container {
    width: min(1240px, calc(100% - 1.5rem));
  }

  .hiw-story-title {
    white-space: nowrap;
    font-size: clamp(1.15rem, 1.45vw + 0.35rem, 1.45rem);
  }

  .hiw-stage {
    height: min(40rem, calc(100dvh - 11.5rem));
  }

  .hiw-devices {
    top: 3.5rem;
    bottom: 5.65rem;
  }

  .hiw-devices-inner {
    max-width: 42rem;
  }

  .hiw-card-inner {
    padding: 0.55rem 0.6rem;
    gap: 0.45rem;
  }

  .hiw-card-icon {
    width: 1.7rem;
    height: 1.7rem;
  }

  .hiw-card strong {
    font-size: 0.7rem;
  }

  .hiw-card p {
    font-size: 0.58rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hiw-card--nw { left: 14%; top: -1%; }
  .hiw-card--n { left: 31%; top: 0; }
  .hiw-card--ne { right: 0.35%; top: 2%; }
  .hiw-card--w1 { left: 0.1%; top: 11%; }
  .hiw-card--e1 { right: 0.1%; top: 17%; }
  .hiw-card--w2 { left: 0.5%; top: 27%; }
  .hiw-card--e2 { right: 0.4%; top: 37%; }
  .hiw-card--w3 { left: 0.1%; top: 43%; }
  .hiw-card--e3 { right: 0.1%; top: 57%; }
  .hiw-card--w4 { left: 0.5%; top: 59%; }
  .hiw-card--s { left: 7%; bottom: 0.35%; }
  .hiw-card--se { left: 23%; bottom: 1%; }
}

/* Compact laptop band — still constellation, tighter fit */
@media (min-width: 1281px) and (max-width: 1360px) {
  .hiw-section {
    --hiw-card-w: 10.7rem;
    --hiw-devices-inset: 11.85rem;
    --hiw-browser-zoom: 0.38;
    --hiw-phone-w: 10rem;
  }

  .hiw-devices-inner {
    max-width: 38rem;
  }

  .hiw-story-title {
    font-size: clamp(1.05rem, 1.3vw + 0.3rem, 1.28rem);
  }

  .hiw-card--nw { left: 13%; }
  .hiw-card--n { left: 30%; }
  .hiw-card--s { left: 6%; }
  .hiw-card--se { left: 22%; }
}

/* Phone / tablet / small laptop — static stack. */
@media (max-width: 1280px) {
  .hiw-section {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .hiw-sticky {
    position: relative !important;
    top: auto;
    min-height: 0 !important;
    height: auto !important;
    padding: 3rem 0 3.25rem;
    overflow: visible !important;
    display: block;
  }

  .hiw-chapter {
    display: none !important;
  }

  .hiw-story {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    min-height: 0;
    display: block !important;
    visibility: visible !important;
  }

  .hiw-container {
    width: min(720px, calc(100% - 1.5rem));
    gap: 1.25rem;
    display: flex;
    flex-direction: column;
  }

  .hiw-story-head {
    max-width: 36rem;
    transform: none !important;
  }

  .hiw-story-title {
    white-space: normal;
  }

  .hiw-connectors-wrap,
  .hiw-connectors {
    display: none !important;
  }

  .hiw-stage {
    position: relative;
    height: auto !important;
    min-height: 0 !important;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
    overflow: visible !important;
  }

  .hiw-devices {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    order: 1;
    width: 100%;
    height: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transform: none !important;
  }

  .hiw-devices-inner {
    position: relative !important;
    width: 100%;
    height: auto !important;
    max-width: none;
    display: flex;
    justify-content: center;
    transform: none !important;
  }

  .hiw-device--browser {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    translate: none !important;
    width: 100%;
    display: flex;
    justify-content: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide phone mockup on stacked layout — keep browser only */
  .hiw-device--phone {
    display: none !important;
  }

  .hiw-section .hiw-te-browser.te-browser {
    zoom: 0.42;
    margin-inline: auto;
    transform: none !important;
  }

  .hiw-cards {
    position: relative !important;
    inset: auto !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    order: 2;
    z-index: 2;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    width: 100%;
    height: auto !important;
    pointer-events: auto;
    overflow: visible !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .hiw-card {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: none !important;
    rotate: none !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: auto;
    display: block !important;
  }

  .hiw-card-inner {
    display: flex !important;
    grid-template-columns: unset;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem 0.9rem;
    background: #fff !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 16px rgba(16, 24, 40, 0.05);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .hiw-card--mobile .hiw-card-icon {
    display: none !important;
  }

  .hiw-card-check {
    flex-shrink: 0;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ecfdf3;
    border: 1.5px solid #12b76a;
    color: #12b76a;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    box-sizing: border-box;
  }

  .hiw-card strong {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: #344054;
    line-height: 1.3;
  }

  .hiw-card p {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--hiw-muted);
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
  }
}

@media (min-width: 641px) and (max-width: 1280px) {
  .hiw-container {
    width: min(760px, calc(100% - 2rem));
  }

  .hiw-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .hiw-section .hiw-te-browser.te-browser {
    zoom: 0.48;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hiw-chapter-scroll-arrow {
    animation: none;
  }

  .hiw-chapter,
  .hiw-story {
    will-change: auto;
  }

  .hiw-te-browser,
  .hiw-de-phone,
  .hiw-card-inner {
    animation: none !important;
  }
}
