/* ======================================================================================
   Homepage (index.html) only. Loaded after styles.css, which supplies the shared design tokens: the Inter type scale
   (--fs-hero, --fs-h2, ... from .type-inter, scaling fluidly like the case study pages) and --gutter (from .project-light).
   Every rule here is scoped with an .hm- class, so nothing can reach the three case study pages.

   Same grid as the case studies (project-1 is the reference): content container 1400px wide with the shared fluid side
   gutter (20px on phones up to 40px), hero title 72px from the top (56px on phones), title / underline / description
   spacing 24px / 28px, Inter 600 title with the project hero size and line height.
   ====================================================================================== */

body.hm-page {
  background: #FFFFFF;
  color: #303039;
  overflow-x: clip;
  --hm-ink: #303039;           /* dark graphite */
  --hm-ink-soft: #4B4B56;      /* descriptions */
  --hm-accent: #8273B5;        /* muted lavender */
  --hm-accent-deep: #6B5CA0;   /* hover */
  --hm-line: #E7E7EC;
  --hm-link: #696974;          /* secondary actions (contrast on white: about 5.6 : 1) */
  --hm-fs-ui: clamp(15px, calc(15px + (100vw - 375px) * 0.0046), 18px);
}

.hm-wrap {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------------------------------------------------------------- hero ---------- */
.hm-hero {
  position: relative;
  isolation: isolate;
  overflow: clip;
  background: #FFFFFF;
  --pw: clamp(290px, 31vw, 440px);        /* portrait width */
  --pr: clamp(0px, 5.5vw, 80px);          /* portrait distance from the content edge */
  --hm-fw: 1.25;                          /* how far left of the portrait the city stays hidden (in portrait widths) */
  --hm-e: max(var(--gutter), calc((100% - 1400px) / 2 + var(--gutter)));   /* distance from the page edge to the content edge */
}

/* the city picture: its own layer, behind everything. White fades on the left (under the text) and at the bottom
   keep it a soft atmosphere that dissolves into the page. */
.hm-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
/* the city picture, at the same scale as before (125% of the hero's height, no filter or overlay): it is positioned so the vanishing point of
   the street (62.5% across the picture) sits behind the centre of the portrait, whatever the screen width. Where the picture ends before the
   page edge on a very wide screen, its last stretch fades out (mask). */
.hm-bg::before {
  content: "";
  position: absolute;
  top: -7.5%;
  height: 125%;
  aspect-ratio: 1672 / 941;
  left: calc(100% - var(--hm-e) - var(--pw) / 2);    /* the portrait's centre */
  transform: translateX(-62.5%);
  background: url("images/hero-city.webp") center / 100% 100% no-repeat;
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 88%, transparent 100%);
          mask-image: linear-gradient(to right, #000 0%, #000 88%, transparent 100%);
  clip-path: inset(0 0 calc(17.5% / 1.25 + 2px) 0);    /* stops 2px short of the hero's bottom edge (already fully white there): no sub-pixel line */
}
/* the white fades: on the left (a clean text area: fully white to --hm-fw portrait-widths left of the content edge, clear again about 0.6 portrait-widths later) and at the bottom */
.hm-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, #FFFFFF 0%, rgba(255, 255, 255, 0.9) 6%, rgba(255, 255, 255, 0.55) 16%, rgba(255, 255, 255, 0.2) 27%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(to right, #FFFFFF 0%, #FFFFFF calc(100% - var(--hm-e) - var(--pw) * var(--hm-fw)), rgba(255, 255, 255, 0.85) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.15)), rgba(255, 255, 255, 0.5) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.33)), rgba(255, 255, 255, 0.2) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.47)), rgba(255, 255, 255, 0) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.63)));
}

.hm-hero-inner {
  position: relative;
  padding-top: clamp(56px, 9vw, 72px);
  padding-bottom: clamp(48px, 6vw, 72px);
  min-height: calc(var(--pw) * 1.053 + 12px);       /* tall enough for the portrait (ratio 1222 x 1287) */
}

.hm-hero-text {
  position: relative;
  z-index: 2;
  max-width: calc(100% - var(--pw) * 0.9 - var(--pr));
}

.hm-name {
  font-size: var(--fs-hero);
  font-weight: var(--w-hero, 600);
  line-height: var(--lh-hero, 1.25);
  letter-spacing: -0.01em;
  color: var(--hm-ink);
  text-wrap: balance;
}

.hm-underline {
  display: block;
  width: 100px;
  height: 0;
  margin-top: 24px;
  border-top: 5px solid var(--hm-accent);
}

.hm-tagline {
  margin-top: 28px;
  max-width: 680px;
  font-size: var(--fs-hero-sub);
  font-weight: 400;
  line-height: 1.25;
  color: var(--hm-ink-soft);
  text-wrap: pretty;
}
.hm-br { display: none; }
@media (min-width: 1100px) { .hm-br { display: inline; } .hm-tagline { max-width: none; } }

/* ------------------------------------------------------ hero actions ---------- */
/* one row on a wide screen; where it has to wrap, the items simply wrap with the same even gap */
.hm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px clamp(26px, 2.8vw, 40px);
  margin-top: clamp(32px, 3.6vw, 44px);
  list-style: none;
}
.hm-actions li { display: flex; align-items: center; }

.hm-btn,
.hm-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: inherit;
  font-size: var(--hm-fs-ui);
  font-weight: 500;
  line-height: 1.2;
  color: var(--hm-ink);
  text-decoration: none;
  white-space: nowrap;
  min-height: 46px;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.hm-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 0 clamp(20px, 2.2vw, 28px);
  border-radius: 999px;
  background: var(--hm-accent);
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(130, 115, 181, 0.22);
}
@media (hover: hover) {
  .hm-btn:hover { background: var(--hm-accent-deep); box-shadow: 0 8px 22px rgba(107, 92, 160, 0.26); }
  .hm-link:hover { color: var(--hm-accent-deep); }
}
.hm-link { color: var(--hm-link); }

.hm-ic { width: 1.3em; height: 1.3em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hm-ic--fill { fill: currentColor; stroke: none; }
.hm-btn .hm-ic { width: 1.1em; height: 1.1em; }

.hm-btn:focus-visible,
.hm-link:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: 4px; }
.hm-link:focus-visible { border-radius: 8px; }

/* -------------------------------------------------------------- portrait ------- */
.hm-portrait {
  position: absolute;
  z-index: 1;
  right: var(--gutter);                /* was calc(var(--gutter) + var(--pr)): moved right by --pr (up to 80px on large screens, less on smaller ones) */
  bottom: 0;
  width: var(--pw);
  pointer-events: none;
}
.hm-portrait img {
  display: block;
  width: 100%;
  height: auto;            /* the picture's own ratio: never stretched */
  /* the lower body dissolves into the page; the face (the upper 60%) is never touched */
  -webkit-mask-image: linear-gradient(to top, transparent 0%, #000 22%);
          mask-image: linear-gradient(to top, transparent 0%, #000 22%);
}
@media (max-width: 1099px) { .hm-hero { --hm-fw: 1; } }

/* tablets and phones: the text first, then the portrait on the city picture, centred and clearly visible */
@media (max-width: 719px) {
  .hm-hero { --pw: min(56vw, 300px); --pm: clamp(6px, 2.4vw, 16px); }      /* the portrait is about 27% smaller */
  .hm-hero-inner { min-height: 0; padding-bottom: 0; }
  .hm-hero-text { max-width: none; }

  /* two rows: the video button alone, then the three secondary links on one line (smaller type and tighter gaps so they always fit) */
  .hm-actions { gap: 0 clamp(10px, 3.6vw, 20px); margin-top: clamp(24px, 6vw, 32px); }
  .hm-actions li:first-child { flex: 0 0 100%; margin-bottom: 4px; }
  .hm-actions .hm-link { font-size: clamp(12px, calc(12px + (100vw - 320px) * 0.04), 15px); gap: 0.4em; min-height: 44px; }
  .hm-actions .hm-link .hm-ic { width: 1.15em; height: 1.15em; }

  /* the portrait and the city form their own block under the actions, on a clean white page */
  .hm-portrait { position: relative; right: auto; bottom: auto; margin: var(--pm) auto 0; transform: translateX(6%); }
  .hm-bg { inset: auto 0 0 0; height: calc(var(--pw) * 1.053 + var(--pm)); overflow: hidden; }   /* starts exactly under the action links */
  .hm-bg::before { top: -10%; left: calc(50% + var(--pw) * 0.06); }       /* behind the centre of the (centred) portrait */
  .hm-bg::before { clip-path: inset(calc(10% / 1.25 + 2px) 0 calc(15% / 1.25 + 2px) 0); }   /* keeps the picture 2px inside the white fades, so a sub-pixel rounding can never leave a thin line at the band's edge */
  .hm-bg::after {
    background:
      linear-gradient(to top, #FFFFFF 0%, rgba(255, 255, 255, 0.9) 7%, rgba(255, 255, 255, 0.55) 20%, rgba(255, 255, 255, 0) 38%),
      linear-gradient(to bottom, #FFFFFF 0%, rgba(255, 255, 255, 0.85) 10%, rgba(255, 255, 255, 0.4) 24%, rgba(255, 255, 255, 0) 42%);
  }
}

/* ------------------------------------------------------------------ cases ----- */
.hm-cases {
  position: relative;                 /* above the hero's soft bottom fade, which it overlaps a little */
  z-index: 2;
  margin-top: 0;
  padding-top: clamp(8px, 2vw, 20px);
  padding-bottom: clamp(64px, 8vw, 112px);
}
.hm-h2 {
  font-size: calc(var(--fs-h2) * 0.88);
  font-weight: 500;
  line-height: var(--lh-h2, 1.2);
  color: var(--hm-ink);
  margin-bottom: clamp(22px, 2.6vw, 32px);
}

.hm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: 1fr;                /* every card has the same height, in a row and when stacked */
  gap: clamp(16px, 1.6vw, 22px);
}
@media (min-width: 720px) { .hm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* two-column hero and up: the section sits a little higher (about 36px on a large screen) */
@media (min-width: 720px) { .hm-cases { margin-top: calc(-1 * clamp(16px, 2.5vw, 36px)); } }

.hm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  container-type: inline-size;        /* the card's own width drives its type and padding (cq units) */
  overflow: hidden;
  background: #FFFFFF;
  border: 1px solid var(--hm-line);
  border-radius: 16px;
  color: var(--hm-ink);
  text-decoration: none;
  transition: transform 250ms ease, box-shadow 250ms ease, border-color 250ms ease;
  -webkit-tap-highlight-color: transparent;
}
/* hover and keyboard focus look the same: the whole card lifts 4px, a soft lavender-tinted shadow and a muted lavender border appear.
   Only the card itself moves; its photograph, graphics and text stay exactly where they are. */
@media (hover: hover) {
  .hm-card:hover {
    transform: translateY(-4px);
    border-color: #CFC8E3;
    box-shadow: 0 18px 38px rgba(130, 115, 181, 0.15), 0 4px 12px rgba(130, 115, 181, 0.07);
  }
}
.hm-card:focus-visible {
  transform: translateY(-4px);
  border-color: #CFC8E3;
  box-shadow: 0 18px 38px rgba(130, 115, 181, 0.15), 0 4px 12px rgba(130, 115, 181, 0.07);
}
.hm-card:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: 4px; }

/* the photograph fills the upper part and dissolves into the white content area (a fade on the photo itself, so the
   journey graphic on top of it is never washed out) */
.hm-media {
  position: relative;
  flex: none;
  aspect-ratio: 100 / 56;
  --mh: 56cqw;                       /* the image area's height (it follows the aspect ratio); the journey graphics are sized to fit inside it */
  overflow: hidden;
  container-type: inline-size;
}
@media (max-width: 719px) { .hm-media { aspect-ratio: 2.15 / 1; --mh: 46.5cqw; } }
@media (max-width: 559px) { .hm-media { aspect-ratio: 100 / 62; --mh: 62cqw; } }

.hm-stage {
  position: absolute;
  inset: 0;
}

.hm-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 58%, rgba(0, 0, 0, 0.55) 78%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 58%, rgba(0, 0, 0, 0.55) 78%, transparent 100%);
}
.hm-journey { position: absolute; display: block; overflow: visible; }

/* project-1: the road photograph; the completed journey line over it */
.hm-photo--p1 { object-position: 78% 62%; }
.hm-media--p1 .hm-journey { left: 50%; top: 7%; width: min(90%, 540px, calc((var(--mh) * 0.93 - 8px) * 1.815)); height: auto; transform: translateX(-50%); }

/* project-2: the right-hand part of the city photograph (skyline, walkway, glass building) */
.hm-photo--p2 { object-position: 84% 50%; }

/* project-3: the bridge photograph and the completed journey graphic share one scale, so the line stays on the bridge exactly as
   on the case study (svg x 0 = picture x 1298, svg y 0 = picture y 246, 1.084 picture px per svg unit). The whole graphic fits the card. */
.hm-media--p3 .hm-stage {
  --g: min(0.85px, calc((100cqw - 14px) / 531), calc((var(--mh) - 8px) / 299));
  --P: calc(var(--g) / 1.084);
  --sx: calc((100cqw - 531 * var(--g)) / 2);
  --T: calc(6 * var(--P));
}
.hm-photo--p3 {
  object-fit: initial;
  background: url("images/Hero-Picture%203%20new%201.webp") calc(var(--sx) - 1298 * var(--P)) calc(var(--T) - 215 * var(--P)) / calc(2172 * var(--P)) auto no-repeat;
}
.hm-media--p3 .hm-journey {
  left: var(--sx);
  top: calc(var(--T) + 31 * var(--P));
  width: calc(531 * var(--g));
  height: calc(265 * var(--g));
}

/* ----------------------------------------------------------- card content ----- */
.hm-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: clamp(4px, 1.2cqw, 6px) clamp(22px, 7.2cqw, 32px) clamp(18px, 5cqw, 24px);
}
.hm-card-title {
  font-size: clamp(18px, 6.5cqw, 28.8px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--hm-ink);
  text-wrap: balance;
}
.hm-tl { display: block; }            /* each title is set on two lines, as in the design */
.hm-card-meta {
  margin-top: clamp(10px, 3cqw, 14px);
  font-size: clamp(13.5px, 3.7cqw, 17px);
  font-weight: 400;
  line-height: 1.4;
  color: #747480;                     /* subtle secondary text */
}
.hm-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-top: auto;
  padding-top: clamp(16px, 4.4cqw, 20px);
  font-size: clamp(15px, 4cqw, 17.5px);
  font-weight: 500;
  line-height: 1.2;
  color: var(--hm-accent);
  transition: color 250ms ease;
}
@media (hover: hover) { .hm-card:hover .hm-cta { color: var(--hm-accent-deep); } }
.hm-card:focus-visible .hm-cta { color: var(--hm-accent-deep); }
.hm-cta .hm-ic { width: 1.25em; height: 1.25em; stroke-width: 1.8; transition: transform 250ms ease; }
@media (hover: hover) { .hm-card:hover .hm-cta .hm-ic { transform: translateX(4px); } }
.hm-card:focus-visible .hm-cta .hm-ic { transform: translateX(4px); }

@media (max-width: 640px) {
  .hm-underline { width: 72px; border-top-width: 4px; }
}

/* --------------------------------------------------------- reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  .hm-card, .hm-cta .hm-ic, .hm-btn, .hm-link, .hm-cta { transition: none; }
  .hm-card:hover, .hm-card:focus-visible { transform: none; }
  .hm-card:hover .hm-cta .hm-ic, .hm-card:focus-visible .hm-cta .hm-ic { transform: none; }
}

/* ---- tablets (720 - 1199px): the same two-row actions as on a phone, and a portrait / city composition like the desktop one ----
   Actions: the video button alone, then the three secondary links on one line (their size scales with the width so they always fit
   in the text column).
   Composition: the portrait is lifted a little off the bottom edge (so it no longer sits low against the cards) and the city picture is
   sized to the portrait, in the same proportion as on the desktop (the picture is 1.28 x the portrait's height, reaching 0.1 of it above
   and 0.18 below), with its vanishing point behind the portrait's centre. The top of the picture, and its bottom, dissolve into white. */
@media (min-width: 720px) and (max-width: 1199px) {
  .hm-hero { --ph: calc(var(--pw) * 1.053); --lift: calc(var(--pw) * 0.12); }

  .hm-actions { gap: 0 clamp(14px, 2.4vw, 26px); }
  .hm-actions li:first-child { flex: 0 0 100%; margin-bottom: 4px; }
  .hm-actions .hm-link { font-size: clamp(14px, calc(14px + (100vw - 720px) * 0.0366), 18px); gap: 0.4em; }
  .hm-actions .hm-link .hm-ic { width: 1.2em; height: 1.2em; }

  .hm-portrait { bottom: var(--lift); }
  .hm-bg::before {
    top: auto;
    height: calc(var(--ph) * 1.28);
    bottom: calc(var(--lift) - var(--ph) * 0.18);
    clip-path: inset(0 0 calc(max(0px, var(--ph) * 0.18 - var(--lift)) + 2px) 0);
  }
  .hm-bg::after {
    background:
      linear-gradient(to top, rgba(255, 255, 255, 0) calc(var(--lift) + var(--ph) * 0.85), rgba(255, 255, 255, 0.25) calc(var(--lift) + var(--ph) * 0.93), rgba(255, 255, 255, 0.55) calc(var(--lift) + var(--ph) * 1), rgba(255, 255, 255, 0.85) calc(var(--lift) + var(--ph) * 1.05), #FFFFFF calc(var(--lift) + var(--ph) * 1.1)),
      linear-gradient(to top, #FFFFFF 0%, rgba(255, 255, 255, 0.9) 6%, rgba(255, 255, 255, 0.55) 16%, rgba(255, 255, 255, 0.2) 27%, rgba(255, 255, 255, 0) 38%),
      linear-gradient(to right, #FFFFFF 0%, #FFFFFF calc(100% - var(--hm-e) - var(--pw) * var(--hm-fw)), rgba(255, 255, 255, 0.85) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.15)), rgba(255, 255, 255, 0.5) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.33)), rgba(255, 255, 255, 0.2) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.47)), rgba(255, 255, 255, 0) calc(100% - var(--hm-e) - var(--pw) * (var(--hm-fw) - 0.63)));
  }
}

/* portrait tablets (three narrow cards in a row): a tighter gap, padding and type, scaled to the card width */
@media (min-width: 720px) and (max-width: 959px) {
  .hm-grid { gap: clamp(10px, 1.7vw, 14px); }
  .hm-card { border-radius: 14px; }
  .hm-body { padding: 4px clamp(13px, 6.4cqw, 18px) clamp(14px, 6cqw, 18px); }
  .hm-card-title { font-size: clamp(14px, 6.6cqw, 19px); line-height: 1.18; }
  .hm-card-meta { margin-top: 8px; font-size: clamp(11.5px, 4.9cqw, 13.5px); }
  .hm-cta { padding-top: 12px; font-size: clamp(12.5px, 5.6cqw, 14.5px); }
}

/* ---------------------------------------------------------------- email popover ----- */
/* a small card opened from the Email link; fixed to the viewport (placed by the script), above every other layer */
.hm-pop {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: min(288px, calc(100vw - 24px));
  padding: 8px;
  background: #FFFFFF;
  border: 1px solid #E2DFEC;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(48, 48, 57, 0.12), 0 4px 14px rgba(130, 115, 181, 0.1);
  font-family: var(--font);
  color: var(--hm-ink);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
}
.hm-pop.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
}
.hm-pop-addr {
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--hm-line);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--hm-ink);
  overflow-wrap: anywhere;
  -webkit-user-select: text;
          user-select: text;                 /* the address stays selectable, whatever the clipboard does */
}
.hm-pop-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;                        /* touch-friendly */
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  color: var(--hm-link);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.hm-pop-item .hm-ic { width: 18px; height: 18px; }
@media (hover: hover) { .hm-pop-item:hover { background: rgba(130, 115, 181, 0.09); color: var(--hm-accent-deep); } }
.hm-pop-item:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: -2px; background: rgba(130, 115, 181, 0.09); color: var(--hm-accent-deep); }
.hm-pop-ic-ok { display: none; }
.hm-pop-item.is-done { color: var(--hm-accent-deep); }
.hm-pop-item.is-done .hm-pop-ic-copy { display: none; }
.hm-pop-item.is-done .hm-pop-ic-ok { display: block; }
.hm-pop-note { margin: 0; font-size: 13px; line-height: 1.35; color: var(--hm-ink-soft); }
.hm-pop-note:not(:empty) { padding: 6px 10px 4px; }
.hm-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  .hm-pop, .hm-pop.is-open { transition: none; transform: none; }
  .hm-pop-item { transition: none; }
}
