/* ==========================================================================
   Home page
   ========================================================================== */

/* --------------------------------------------------------------------------
   Hero
   Title, intro and actions stacked on the left, then two photographs:
   trading (wide) and property services (narrower), in a 7/5 split.
   -------------------------------------------------------------------------- */

.hero {
  padding-block: calc(var(--header-height) + var(--space-8)) var(--space-8);
}

.hero__inner {
  display: grid;
  gap: clamp(3rem, 2rem + 4vw, 5rem);
}

.hero__content {
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  text-align: center;
}

.hero__title {
  font-size: clamp(2rem, 1.45rem + 2.6vw, 3.5rem);
}

/* Each sentence sits in its own mask so it can slide up into view */
.hero__line {
  display: block;
  overflow: clip;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.hero__line-inner {
  display: block;
}

.hero__lead {
  max-width: 40rem;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* --------------------------------------------------------------------------
   Showcase: one frame where the photos take turns, on a loop.
   showcase.js drives the wipes; without JavaScript the first photo shows.
   -------------------------------------------------------------------------- */

.showcase__stage {
  position: relative;
  overflow: clip;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);

  /* Close to the photos' own 3:2 shape, so very little is cropped */
  @media (width >= 48rem) {
    aspect-ratio: 3 / 2;
  }

  @media (width >= 64rem) {
    aspect-ratio: 16 / 9;
  }
}

.showcase__slide {
  position: absolute;
  inset: 0;
  overflow: clip;

  &:not(:first-child) {
    clip-path: inset(0 0 0 100%);
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.showcase__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

/* Captions share one spot and cross-fade */
.showcase__captions {
  display: grid;
}

.showcase__caption {
  grid-area: 1 / 1;
  font-size: var(--fs-sm);
  color: var(--ink-700);
  opacity: 0;
  translate: 0 0.375rem;
  transition:
    opacity var(--duration-base) ease,
    translate var(--duration-base) var(--ease-out);

  &.is-active {
    opacity: 1;
    translate: 0 0;
  }
}

/* Progress tabs and pause button need JavaScript, so they only appear with it */
.showcase__controls {
  display: none;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;

  .js & {
    display: flex;
  }
}

.showcase__tab {
  display: grid;
  align-items: center;
  width: 2.75rem;
  height: 1.75rem;
}

.showcase__track {
  height: 2px;
  overflow: clip;
  border-radius: 2px;
  background: var(--line);
}

.showcase__progress {
  display: block;
  height: 100%;
  background: var(--brand-green);
  transform-origin: left;
  transform: scaleX(0);

  [aria-current="true"] & {
    transform: scaleX(1);
  }
}

.showcase__pause {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-left: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink-700);
  transition:
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease;

  &:hover {
    border-color: var(--ink-700);
    color: var(--ink-900);
  }

  svg {
    width: 0.75rem;
    height: 0.75rem;
  }

  &[data-state="playing"] .showcase__icon-play,
  &[data-state="paused"] .showcase__icon-pause {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Areas We Serve: expanding panels with animated line icons
   Desktop with a mouse: the open panel is wider, shows its details and
   animates its icon; hovering or focusing the other panel swaps them
   (pure CSS via :has). Touch and small screens: a swipeable row with
   every panel fully open.
   -------------------------------------------------------------------------- */

.areas__title {
  margin-bottom: var(--space-7);
}

/* Phones: stacked. Tablets: side by side, both open. Desktop with a mouse: expanding. */
.panels {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);

  @media (width >= 48rem) {
    flex-direction: row;
  }
}

.panel {
  /* 1 = open (wide, details visible), 0 = closed. Everything open by default. */
  --open: 1;

  position: relative;
  isolation: isolate;
  flex: 1 1 0;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-tint);

  /* Closed panels fade toward neutral */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--surface-alt);
    opacity: calc((1 - var(--open)) * 0.85);
    transition: opacity 0.8s var(--ease-out);
  }

  /* The link covers the whole panel, so show its focus ring on the panel */
  &:has(.panel__link:focus-visible) {
    outline: 2px solid var(--focus-ring);
    outline-offset: 4px;
  }
}

.panel--trading {
  --panel-tint: #eef5e6;
  --accent: var(--brand-green);
  --accent-soft: var(--brand-lime);
}

.panel--software {
  --panel-tint: #e8f0f7;
  --accent: var(--brand-blue);
  --accent-soft: var(--brand-teal);
}

.panel__content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-6);
  height: 100%;
  padding: var(--space-6);
}

.panel__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.panel__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--accent);
}

.panel__icon {
  flex-shrink: 0;
  width: clamp(8.5rem, 6.5rem + 5vw, 12rem);
  height: auto;
  color: var(--accent);
  transform-origin: top right;
  scale: calc(0.85 + var(--open) * 0.15);
  transition: scale 0.8s var(--ease-out);
}

.panel__bottom {
  display: grid;
  /* Column follows the panel width, not the fixed-width details inside it */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.panel__title {
  max-width: 16ch;
  font-size: clamp(1.5rem, 1.1rem + 1vw, 2rem);
}

.panel__details {
  display: grid;
  justify-items: start;
  gap: var(--space-5);
  color: var(--ink-700);
  opacity: var(--open);
  translate: 0 calc((1 - var(--open)) * 1rem);
  transition:
    opacity var(--duration-base) ease,
    translate 0.6s var(--ease-out);
}

.panel__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-900);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.35em;

  /* Stretch the click area over the whole panel */
  &::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  &:focus-visible {
    outline: none;
  }
}

.panel__arrow {
  width: 1em;
  height: 1em;
  color: var(--accent);
  transition: translate var(--duration-fast) var(--ease-out);

  .panel:hover & {
    translate: 4px 0;
  }
}

/* ---- Icon: container ship ---- */

.icon-ship__container {
  fill: var(--panel-tint);
}

.icon-ship__container--accent {
  fill: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.icon-ship__hull {
  fill: var(--panel-tint);
}

.icon-ship__vessel {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: ship-rock 3.2s ease-in-out infinite alternate;
}

/* One wave period is 20 units, so shifting by 20 loops seamlessly */
.icon-ship__wave {
  animation: wave-drift 2.4s linear infinite;
}

.icon-ship__wave--back {
  color: var(--accent-soft);
  animation-duration: 3.6s;
  animation-direction: reverse;
}

@keyframes ship-rock {
  from { translate: 0 0; rotate: -1.5deg; }
  to { translate: 0 -3px; rotate: 1.5deg; }
}

@keyframes wave-drift {
  to { translate: 20px 0; }
}

/* ---- Icon: field operations (property → app checklist) ----
   One 6s loop: the three checklist items tick off one after another,
   hold, then fade and start again. Base styles show the finished
   checklist, which is what reduced-motion visitors see. */

/* The pin's pulse grows past the top of the drawing area */
.icon-ops {
  overflow: visible;
}

.icon-ops__pin-body {
  fill: var(--surface);
}

.icon-ops__pin-dot {
  fill: currentColor;
  stroke: none;
}

.icon-ops__pin {
  animation: ops-pin 1.6s ease-in-out infinite alternate;
}

.icon-ops__pulse {
  color: var(--accent-soft);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  animation: ops-pulse 2.4s ease-out infinite;
}

.icon-ops__link {
  color: var(--accent-soft);
  stroke-width: 2;
  stroke-dasharray: 2 6;
  animation: ops-flow 0.9s linear infinite;
}

.icon-ops__card {
  animation: ops-float 3.2s ease-in-out infinite alternate;
}

.icon-ops__card-body {
  fill: var(--surface);
}

.icon-ops__dot {
  fill: var(--accent-soft);
  stroke: none;
}

.icon-ops__bar {
  stroke: color-mix(in srgb, var(--accent) 22%, transparent);
  stroke-width: 3;
}

.icon-ops__bar--short {
  stroke: color-mix(in srgb, var(--accent) 12%, transparent);
  stroke-width: 2;
}

.icon-ops__box {
  fill: currentColor;
  animation: ops-box 6s ease-out infinite backwards;
}

.icon-ops__tick {
  stroke: var(--surface);
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: ops-tick 6s ease-out infinite backwards;
}

.icon-ops__box--2,
.icon-ops__tick--2 {
  animation-delay: 0.7s;
}

.icon-ops__box--3,
.icon-ops__tick--3 {
  animation-delay: 1.4s;
}

@keyframes ops-pin {
  to { translate: 0 -4px; }
}

@keyframes ops-pulse {
  from { scale: 1; opacity: 0.8; }
  to { scale: 2; opacity: 0; }
}

/* One dash + gap is 8 units, so two cycles loop seamlessly */
@keyframes ops-flow {
  to { stroke-dashoffset: -16; }
}

@keyframes ops-float {
  to { translate: 0 -3px; }
}

@keyframes ops-box {
  0%, 12% { fill: transparent; }
  20%, 84% { fill: currentColor; }
  92%, 100% { fill: transparent; }
}

@keyframes ops-tick {
  0%, 12% { stroke-dashoffset: 1; opacity: 1; }
  20%, 84% { stroke-dashoffset: 0; opacity: 1; }
  92%, 100% { stroke-dashoffset: 0; opacity: 0; }
}

/* ---- Expanding layout: wide screens with a real hover ---- */

@media (hover: hover) and (width >= 64rem) {
  .panel {
    --open: 0;

    flex: calc(1 + var(--open) * 0.85) 1 0;
    /* Let a closed panel shrink past its (hidden) fixed-width details */
    min-width: 0;
    /* Tall enough for the longest open or closed state, so the row height
       stays put while panels swap */
    min-height: 32rem;
    transition: flex-grow 0.8s var(--ease-out);

    /* Icons rest while their panel is closed */
    .panel__icon * {
      animation-play-state: paused;
    }
  }

  /* First panel is open until another one is hovered or focused */
  .panel:first-child {
    --open: 1;

    .panel__icon * {
      animation-play-state: running;
    }
  }

  .panels:has(.panel:is(:hover, :focus-within)) .panel {
    --open: 0;

    .panel__icon * {
      animation-play-state: paused;
    }
  }

  .panels:has(.panel:is(:hover, :focus-within)) .panel:is(:hover, :focus-within) {
    --open: 1;

    .panel__icon * {
      animation-play-state: running;
    }
  }

  .panel__details {
    /* Fixed width so the text never re-wraps while the panel resizes */
    width: 32rem;
    /* Fade in after the panel has started to open; fade out immediately */
    transition-delay: calc(var(--open) * 0.15s);
  }
}

/* --------------------------------------------------------------------------
   Why work with us: the message on the left, a buyer/KHYGEN chat inside a
   phone on the right, over a looping background video.
   Phones: the message stacks above the phone mockup.
   -------------------------------------------------------------------------- */

.why {
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding-block: clamp(4rem, 2.5rem + 5vw, 6rem);
  background: var(--surface-dark);
  color: var(--surface);

  /* Deep green tint keeps the text and phone readable over any footage */
  &::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(
      to bottom,
      rgb(11 31 23 / 0.86),
      rgb(11 31 23 / 0.72) 50%,
      rgb(11 31 23 / 0.88)
    );
  }
}

.why__video {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.why__inner {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: var(--space-7);

  /* Message in the left half, phone centred in the right half */
  @media (width >= 48rem) {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);

    .why__head {
      justify-self: start;
    }
  }
}

.why__head {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  max-width: 34rem;
  text-align: center;

  @media (width >= 48rem) {
    justify-items: start;
    text-align: left;
  }

  .btn {
    margin-top: var(--space-3);
  }
}

.why__title {
  max-width: 16ch;
}

.why__lead {
  color: rgb(255 255 255 / 0.78);
}

/* ---- Phone ---- */

.phone {
  width: min(100%, 19rem);
  aspect-ratio: 9 / 18.5;
  padding: 0.55rem;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 2.75rem;
  background: #16231e;
  box-shadow:
    inset 0 0 0 1.5px rgb(255 255 255 / 0.06),
    0 40px 90px rgb(0 0 0 / 0.45);
}

.phone__screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: clip;
  border-radius: 2.25rem;
  background: var(--surface-alt);
  color: var(--ink-900);
}

.phone__status {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: 2.5rem;
  padding: 0.35rem 1.5rem 0;
  font-size: 0.75rem;
  font-weight: 600;
}

.phone__island {
  position: absolute;
  top: 0.55rem;
  left: 50%;
  width: 5.25rem;
  height: 1.4rem;
  border-radius: var(--radius-pill);
  background: #0b1310;
  translate: -50% 0;
}

.phone__indicators {
  width: 2.6rem;
  height: auto;
}

.phone__composer {
  flex-shrink: 0;
  margin: var(--space-2) var(--space-4) 0;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--ink-500);
}

.phone__home {
  flex-shrink: 0;
  width: 7rem;
  height: 0.3rem;
  margin: var(--space-3) auto var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--ink-900);
}

/* ---- Chat inside the phone ---- */

/* Light brand green for KHYGEN's replies, distinct from the buyer's white bubbles */
.chat {
  --chat-reply: color-mix(in srgb, var(--brand-lime) 32%, var(--surface));
}

.chat__header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.chat__avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);

  /* The logo's triangle mark */
  img {
    width: 1.3rem;
    height: 1.3rem;
  }
}

.chat__name {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}

.chat__status {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-500);
}

/* Messages scroll inside the phone; older ones fade out under the header */
.chat__scroller {
  /* chat.js measures rows from here */
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(to bottom, transparent, #000 var(--space-5));

  &::-webkit-scrollbar {
    display: none;
  }

  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: -2px;
  }
}

.chat__messages {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
}

.chat__row {
  position: relative;
  display: flex;
}

.chat__row--us {
  justify-content: flex-end;
}

.chat__bubble {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;

  .chat__row--buyer & {
    border-bottom-left-radius: 0.3rem;
    background: var(--surface);
    box-shadow: 0 1px 2px rgb(15 26 23 / 0.08);
  }

  .chat__row--us & {
    border-bottom-right-radius: 0.3rem;
    background: var(--chat-reply);
  }
}

/* "Typing…" dots shown in the reply's spot just before it appears */
.chat__typing {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  gap: 4px;
  padding: 0.8rem 0.9rem;
  border-radius: 1rem 1rem 0.3rem;
  background: var(--chat-reply);
  opacity: 0;

  span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-green);
    animation: typing-dot 1s ease-in-out infinite;
  }

  span:nth-child(2) { animation-delay: 0.15s; }
  span:nth-child(3) { animation-delay: 0.3s; }
}

@keyframes typing-dot {
  0%, 60%, 100% { translate: 0 0; opacity: 0.5; }
  30% { translate: 0 -4px; opacity: 1; }
}

/* Messages wait hidden (keeping their space) until the conversation plays */
@media (prefers-reduced-motion: no-preference) {
  .js [data-chat] .chat__bubble {
    visibility: hidden;
  }
}

/* --------------------------------------------------------------------------
   The trade route: a journey in four chapters
   Default (phones, touch tablets, reduced motion, no JavaScript): stacked.
   Desktop with a mouse: pinned, the cards slide sideways (journey.js).
   -------------------------------------------------------------------------- */

.journey {
  padding-block: var(--section-y);
}

.journey__head {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
  margin-bottom: var(--space-7);

  h2 { max-width: 18ch; }
}

/* The route line only exists in the horizontal layout */
.journey__rail {
  display: none;
}

.journey__track {
  position: relative;
  display: grid;
  gap: var(--space-4);
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;

  @media (width >= 48rem) {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Phones: a vertical route line down the left, a dot per chapter */
  @media (width < 48rem) {
    padding-left: 1.75rem;

    &::before {
      content: "";
      position: absolute;
      top: 2.25rem;
      bottom: 2.25rem;
      left: 0.45rem;
      width: 2px;
      border-radius: 2px;
      background: linear-gradient(to bottom, var(--brand-blue), var(--brand-teal), var(--brand-lime));
    }
  }
}

.journey-card {
  position: relative;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: var(--space-3);
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-tint);

  @media (width < 48rem) {
    &::before {
      content: "";
      position: absolute;
      top: 2rem;
      left: calc(-1.75rem + 0.5rem - 6px);
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 0 3px var(--surface);
    }
  }
}

.journey-card--source {
  --panel-tint: #e8f0f7;
  --accent: var(--brand-blue);
  --accent-soft: var(--brand-teal);
}

.journey-card--ship {
  --panel-tint: #e5f2f1;
  --accent: var(--brand-teal);
  --accent-soft: var(--brand-blue);
}

.journey-card--arrive {
  --panel-tint: #e7f1eb;
  --accent: var(--brand-green);
  --accent-soft: var(--brand-teal);
}

.journey-card--deliver {
  --panel-tint: #eef5e6;
  --accent: var(--brand-green);
  --accent-soft: var(--brand-lime);
}

.journey-card__icon {
  width: 8rem;
  height: auto;
  margin-bottom: var(--space-3);
  color: var(--accent);
}

.journey-card__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--accent);
}

.journey-card__title {
  font-size: var(--fs-lg);
}

.journey-card__text {
  color: var(--ink-700);
}

.journey-card__link {
  margin-top: var(--space-3);
}

/* ---- Icon: factory (smoke rises, windows flicker) ---- */

.icon-factory__body {
  fill: var(--surface);
}

.icon-factory__window {
  fill: var(--accent-soft);
  animation: factory-window 3.2s ease-in-out infinite;
}

.icon-factory__window--late {
  animation-delay: 1.6s;
}

.icon-factory__smoke {
  color: var(--accent-soft);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  animation: factory-smoke 3s ease-out infinite;
}

.icon-factory__smoke--late {
  animation-delay: 1.5s;
}

@keyframes factory-window {
  0%, 100% { fill-opacity: 1; }
  50% { fill-opacity: 0.25; }
}

@keyframes factory-smoke {
  0% { translate: 0 6px; scale: 0.5; opacity: 0; }
  25% { opacity: 0.9; }
  100% { translate: 8px -12px; scale: 1.6; opacity: 0; }
}

/* ---- Icon: port crane (lowers a container onto the stack) ---- */

.icon-crane__load {
  fill: color-mix(in srgb, var(--accent-soft) 40%, transparent);
  animation: crane-lower 3.6s ease-in-out infinite;
}

.icon-crane__cable {
  transform-box: fill-box;
  transform-origin: top;
  animation: crane-cable 3.6s ease-in-out infinite;
}

.icon-crane__stack {
  fill: var(--surface);
}

/* The load drops 16 units; the 9-unit cable stretches to 25 units with it */
@keyframes crane-lower {
  0%, 15%, 100% { translate: 0 0; }
  50%, 70% { translate: 0 16px; }
}

@keyframes crane-cable {
  0%, 15%, 100% { scale: 1 1; }
  50%, 70% { scale: 1 2.78; }
}

/* ---- Icon: delivery (routes flow out from the pin to each point) ---- */

.icon-deliver__route {
  color: var(--accent-soft);
  stroke-width: 2;
  stroke-dasharray: 3 6;
  animation: deliver-flow 0.9s linear infinite;
}

.icon-deliver__point {
  fill: var(--surface);
  transform-box: fill-box;
  transform-origin: center;
  animation: deliver-point 2.4s ease-in-out infinite;
}

.icon-deliver__point--2 { animation-delay: 0.3s; }
.icon-deliver__point--3 { animation-delay: 0.6s; }
.icon-deliver__point--4 { animation-delay: 0.9s; }

.icon-deliver__pin {
  animation: ops-pin 1.6s ease-in-out infinite alternate;
}

.icon-deliver__pin-body {
  fill: var(--surface);
}

.icon-deliver__pin-dot {
  fill: currentColor;
  stroke: none;
}

/* One dash + gap is 9 units, so two cycles loop seamlessly */
@keyframes deliver-flow {
  to { stroke-dashoffset: -18; }
}

@keyframes deliver-point {
  0%, 40%, 100% { scale: 1; fill: var(--surface); }
  15% { scale: 1.35; fill: var(--accent-soft); }
}

/* ---- Horizontal journey: desktop with a mouse, motion allowed ---- */

@media (hover: hover) and (width >= 64rem) and (prefers-reduced-motion: no-preference) {
  /* The pinned view fills the screen, so the journey can always scroll to
     its end, even when nothing follows the section */
  .js .journey {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100svh;
    padding-block: var(--space-9) var(--space-8);
  }

  .js .journey__head {
    margin-bottom: var(--space-6);
  }

  .js .journey__rail {
    --progress: 0;

    position: relative;
    display: block;
    height: 6rem;
    margin-bottom: var(--space-4);
  }

  .js .journey__viewport {
    overflow: clip;
  }

  .js .journey__track {
    display: flex;
    gap: var(--space-5);
    width: max-content;
    margin: 0;
    /* Line the first card up with the page container */
    padding-inline: max(var(--gutter), calc((100% - var(--container)) / 2));
  }

  .js .journey-card {
    flex-shrink: 0;
    width: clamp(22rem, 30vw, 27rem);
    transition: opacity var(--duration-base) ease;
  }

  /* Chapters the ship has not reached yet wait dimmed */
  .js .journey.is-horizontal .journey-card:not(.is-reached) {
    opacity: 0.45;
    filter: saturate(0.4);
  }

  .js .journey-card {
    transition:
      opacity var(--duration-base) ease,
      filter var(--duration-base) ease;
  }
}

/* Shorter laptop screens: compact the pinned view so it fits on one screen */
@media (hover: hover) and (width >= 64rem) and (height < 54rem) and (prefers-reduced-motion: no-preference) {
  .js .journey {
    padding-block: var(--space-8) var(--space-6);
  }

  .js .journey__head {
    margin-bottom: var(--space-5);

    h2 { font-size: var(--fs-xl); }
  }

  .js .journey__rail {
    margin-bottom: var(--space-4);
  }

  .js .journey-card {
    padding: var(--space-5);
  }

  .js .journey-card__icon {
    width: 6.5rem;
    margin-bottom: 0;
  }
}

.journey__rail {
  --rail-line: 1.625rem;
}

.journey__line {
  position: absolute;
  inset: var(--rail-line) 0 auto;
  height: 2px;
  border-radius: 2px;
  background: var(--line);

  &::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-teal), var(--brand-lime));
    transform-origin: left;
    scale: var(--progress) 1;
  }
}

/* Stage names sit under the line; each dot lands exactly on the line */
.journey__stage {
  --stage-color: var(--brand-blue);

  position: absolute;
  top: 0;
  left: calc(var(--at) * 100%);
  translate: calc(var(--at) * -100%) 0;
  /* Below the ship badge (half of it hangs under the line), plus breathing room */
  padding-top: calc(var(--rail-line) * 2 + 1.125rem);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-500);
  transition: color var(--duration-base) ease;

  &::before {
    content: "";
    position: absolute;
    top: calc(var(--rail-line) + 1px);
    left: calc(var(--at) * 100%);
    width: 12px;
    height: 12px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    translate: -50% -50%;
    transition:
      background-color var(--duration-base) ease,
      border-color var(--duration-base) ease;
  }

  &.is-reached {
    color: var(--ink-900);

    &::before {
      border-color: var(--stage-color);
      background: var(--stage-color);
    }
  }
}

.journey__stage:nth-of-type(2) { --stage-color: var(--brand-teal); }
.journey__stage:nth-of-type(3) { --stage-color: var(--brand-green); }
.journey__stage:nth-of-type(4) { --stage-color: var(--brand-lime); }

.journey__ship {
  position: absolute;
  top: calc(var(--rail-line) + 1px);
  left: calc(var(--progress) * 100%);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--brand-teal);
  translate: -50% -50%;

  svg {
    width: 2.1rem;
    height: 2.1rem;
    overflow: visible;
  }
}

.journey__ship-vessel {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: journey-bob 1.6s ease-in-out infinite alternate;
}

.journey__ship-hull,
.journey__ship-box {
  fill: var(--surface);
}

.journey__ship-box--accent {
  fill: color-mix(in srgb, var(--brand-lime) 55%, var(--surface));
}

@keyframes journey-bob {
  from { translate: 0 0; rotate: -2deg; }
  to { translate: 0 -1.5px; rotate: 2deg; }
}

/* --------------------------------------------------------------------------
   Work with KHYGEN: two photo cards
   Each photo has a calm wall on the left, so the text sits straight on it.
   Phone: text first, the photo slides up under it.
   Tablet: cards stack, text over the photo.
   Desktop: two cards side by side.
   -------------------------------------------------------------------------- */

.work {
  padding-block: clamp(3rem, 1.8rem + 5vw, 6rem);
}

.work__inner {
  display: grid;
  gap: var(--space-5);

  @media (width >= 75rem) {
    grid-template-columns: 1fr 1fr;
  }
}

.work-card {
  display: grid;
  /* Keeps the photo's natural width from stretching the card */
  grid-template-columns: minmax(0, 1fr);
  overflow: clip;
  border-radius: var(--radius-md);
  /* Same tone as the wall in both photos, so the edges never show */
  background: var(--surface-alt);

  @media (width >= 48rem) {
    aspect-ratio: 5 / 2;
  }

  @media (width >= 75rem) {
    aspect-ratio: 3 / 2;
  }
}

.work-card__media {
  margin: 0;

  /* Phone: under the text, overlapping the empty wall at the top of the photo */
  grid-row: 2;
  margin-top: calc(-1 * var(--space-8));

  @media (width >= 48rem) {
    position: relative;
    grid-area: 1 / 1;
    margin-top: 0;
  }

  img {
    width: 100%;
    object-fit: cover;
    /* Keep the subject (bottom right) in frame however the card is cropped */
    object-position: 100% 75%;
    /* Phone: fade the top edge into the card so no seam shows */
    mask-image: linear-gradient(to bottom, transparent, #000 35%);

    /* Over the photo, the card's ratio (not the photo's) sets the height */
    @media (width >= 48rem) {
      position: absolute;
      inset: 0;
      height: 100%;
      mask-image: none;
    }
  }
}

.work-card__body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  grid-row: 1;
  padding: clamp(var(--space-5), 3vw, var(--space-7));

  @media (width >= 48rem) {
    grid-area: 1 / 1;
    /* Stay on the wall, clear of the subject on the right */
    max-width: 50%;
  }
}

.work-card__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--brand-green);
}

.work-card__label--careers {
  color: var(--brand-blue);
}

.work-card__title {
  font-size: var(--fs-lg);
}

.work-card__text {
  font-size: var(--fs-sm);
  color: var(--ink-700);
}

.work-card__cta {
  margin-top: var(--space-3);

  /* Pinned to the bottom when the text sits over the photo */
  @media (width >= 48rem) {
    margin-top: auto;
  }

  /* The outline button needs a solid face over the wooden desk */
  &.btn--secondary:not(:hover) {
    background: var(--surface);
  }
}
