/*
 * .story-card — Customer Success Story / Case Study card
 * (template-parts/cards/story-card.php).
 * Figma: Story 337:14217, Case 337:14218, wide 337:13089; M 337:13939.
 *
 * Shares sizes and fluid values with the resource card v2 (index.css):
 * 220 → 300 px photo, 20 → 30 px paddings, same type pill and links.
 * The Figma card is a fixed 480 → 640 px box with the links at the bottom.
 * The dark body of the Figma first card is the hover / focus state
 * (plan, open question 1: default answer).
 */

.story-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: clamp(30rem, 26.4455rem + 15.1659vw, 40rem);
  overflow: hidden;
  border-radius: 0.625rem;
  background-color: var(--nv-mist);

  /* .listing--cloud .story-card — white on the cloud band (Figma 1574:15167), mist on white sections (1574:14076, 1574:14468) */
  .listing--cloud & {
    background-color: var(--nv-white);
  }

  /* .story-card:has(.story-card__link:focus-visible) */
  &:has(.story-card__link:focus-visible) {
    outline: 0.125rem solid var(--nv-green);
    outline-offset: 0.25rem;
  }
}

/* .story-card__media — photo with the metric on top and the focus area chip */
.story-card__media {
  position: relative;
  flex-shrink: 0;
  height: clamp(13.75rem, 11.9728rem + 7.5829vw, 18.75rem);
  overflow: hidden;
  background-color: var(--nv-navy);

  /* .story-card__media::after — tint under the metric */
  &::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(19, 33, 50, 0.8) 0%, rgba(19, 33, 50, 0.2) 50%);
    pointer-events: none;
  }
}

/* .story-card__image */
.story-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

/* .story-card__metric — "25%  operational efficiency": the number's cap 29 → 35 px under the
   photo edge (Figma 337:14217 / M 337:13939), the label on its baseline, one row */
.story-card__metric {
  position: absolute;
  top: clamp(1.8125rem, 1.6792rem + 0.5687vw, 2.1875rem);
  left: clamp(1.25rem, 1.0278rem + 0.9479vw, 1.875rem);
  right: clamp(1.25rem, 1.0278rem + 0.9479vw, 1.875rem);
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.625rem;
}

/* .story-card__metric-value */
.story-card__metric-value {
  flex-shrink: 0;
  margin-block: -0.14em;
  color: var(--nv-green);
  font-size: clamp(3rem, 2.2891rem + 3.0332vw, 5rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* .story-card__metric-label */
.story-card__metric-label {
  min-width: 0;
  max-width: 8.5rem;
  margin-block: -0.14em;
  color: var(--nv-white);
  font-weight: 500;
  font-size: clamp(1rem, 0.9111rem + 0.3792vw, 1.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* .story-card__chip — focus area, same look as the resource topic badge */
.story-card__chip {
  position: absolute;
  bottom: clamp(1.25rem, 1.0278rem + 0.9479vw, 1.875rem);
  left: clamp(1.25rem, 1.0278rem + 0.9479vw, 1.875rem);
  z-index: 1;
  isolation: isolate;
  border-radius: 0.625rem;
  padding: calc(0.9375rem - 0.14em) 0.9375rem;
  color: var(--nv-white);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;

  /* .story-card__chip::before — blur on a pseudo element (WebKit + radius) */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: rgba(19, 33, 50, 0.7);
    -webkit-backdrop-filter: blur(0.625rem);
    backdrop-filter: blur(0.625rem);
  }
}

/* .story-card__body */
.story-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: clamp(1.875rem, 1.5417rem + 1.4219vw, 2.8125rem);
  padding: clamp(1.25rem, 1.0278rem + 0.9479vw, 1.875rem);
  transition: background-color 0.3s ease;
}

/* .story-card__content */
.story-card__content {
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 1.0278rem + 0.9479vw, 1.875rem);
}

/* .story-card__labels — type pill + client logo; 8 px on phones so the two-line pill and the
   108 px logo share the 255 px of a slider card (Figma M overflows the padding instead) */
.story-card__labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;

  /* @media (width >= 48em) .story-card__labels */
  @media (width >= 48em) {
    gap: 0.625rem;
  }
}

/* .story-card__type */
.story-card__type {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  height: 2.5rem;
  border-radius: 3.125rem;
  padding: 0 clamp(0.625rem, 0.5139rem + 0.4740vw, 0.9375rem);
  background: linear-gradient(90deg, var(--nv-navy) 0%, var(--nv-blue) 100%);

  /* .story-card__type:has(.story-card__type-icon) — icon circle hugs the left edge */
  &:has(.story-card__type-icon) {
    padding-left: 0.125rem;
  }

  /* .story-card--wide .story-card__type — the listing card has room for the full 15 px (Figma 1574:14966) */
  .story-card--wide & {
    padding-right: 0.9375rem;
  }
}

/* .story-card__type-icon */
.story-card__type-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: var(--nv-white);

  & img {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* .story-card__type-text */
.story-card__type-text {
  color: var(--nv-white);
  font-weight: 500;
  font-size: clamp(0.875rem, 0.7861rem + 0.3792vw, 1.125rem);
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;

  /* .story-card__labels:has(.story-card__logo) .story-card__type-text —
     two lines next to the client logo on phones (Figma M 337:13961) */
  .story-card__labels:has(.story-card__logo) & {
    width: min-content;
    max-width: 6rem;
    white-space: normal;

    /* .story-card--wide .story-card__labels:has(.story-card__logo) .story-card__type-text — 96 px box as in
       Figma, phones only: its extra class would beat the width: auto below */
    @media (width < 48em) {
      .story-card--wide & {
        width: 6rem;
      }
    }

    /* @media (width >= 48em) .story-card__labels:has(.story-card__logo) .story-card__type-text */
    @media (width >= 48em) {
      width: auto;
      max-width: none;
      white-space: nowrap;
    }
  }
}

/* .story-card__logo — client logo, 108 × 40 */
.story-card__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 6.75rem;
  height: 2.5rem;
  border: 1px solid var(--nv-blue);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--nv-white);

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

/* .story-card__industry — green rhomb + industry name */
.story-card__industry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--nv-blue);
  font-weight: 500;
  font-size: clamp(0.875rem, 0.8305rem + 0.1896vw, 1rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  transition: color 0.3s ease;

  /* .story-card__industry::before */
  &::before {
    content: "";
    flex-shrink: 0;
    width: 0.5rem;
    height: 0.5rem;
    background: url("../../img/icons/rhomb.svg") center / contain no-repeat;
  }

  /* @media (width >= 48em) .story-card__industry — trimmed to cap / baseline (the phone
     frame keeps a 22 px row) */
  @media (width >= 48em) {
    margin-block: -0.14em;
  }
}

/* .story-card__title */
.story-card__title {
  color: var(--nv-navy);
  font-weight: 500;
  font-size: clamp(1.4375rem, 1.2375rem + 0.8531vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  transition: color 0.3s ease;

  & h3 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  /* @media (width >= 48em) .story-card__title — 120 %, trimmed to cap / baseline (640 px card) */
  @media (width >= 48em) {
    margin-block: -0.24em;
    line-height: 1.2;
  }
}

/* .story-card__links — main link (stretched over the card) + PDF */
.story-card__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  margin-top: auto;

  /* @media (width >= 48em) .story-card__links — "Read" and "PDF" packed left, 20 px apart (Figma 1574:14468) */
  @media (width >= 48em) {
    justify-content: flex-start;
    gap: 1.25rem;
  }
}

/* .story-card__link */
.story-card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  width: fit-content;

  /* .story-card__link::after — the whole card is clickable */
  &::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
  }

  & span {
    font-weight: 600;
    font-size: clamp(0.875rem, 0.7861rem + 0.3792vw, 1.125rem);
    line-height: 1;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--nv-navy) 0%, var(--nv-blue) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

/* .story-card__link-icon */
.story-card__link-icon {
  flex-shrink: 0;
  width: clamp(1.25rem, 1.1611rem + 0.3792vw, 1.5rem);
  height: clamp(1.25rem, 1.1611rem + 0.3792vw, 1.5rem);
}

/* .story-card__download */
.story-card__download {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  color: var(--nv-blue);
  transition: color 0.3s ease;

  &:focus-visible {
    outline: 0.125rem solid var(--nv-green);
    outline-offset: 0.25rem;
  }
}

/* .story-card__download-text */
.story-card__download-text {
  font-weight: 600;
  font-size: clamp(0.875rem, 0.7861rem + 0.3792vw, 1.125rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;

  /* .story-card__download-text span — phones: "PDF" only, "Download" stays for screen readers */
  & span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;

    /* @media (width >= 48em) .story-card__download-text span */
    @media (width >= 48em) {
      position: static;
      width: auto;
      height: auto;
      overflow: visible;
      clip-path: none;
    }
  }
}

/* .story-card__download-icon */
.story-card__download-icon {
  flex-shrink: 0;
  width: clamp(1.25rem, 1.1611rem + 0.3792vw, 1.5rem);
  height: clamp(1.25rem, 1.1611rem + 0.3792vw, 1.5rem);
}

/* .story-card:hover / :focus-within — dark body (Figma 337:14217) */
.story-card:focus-within .story-card__body {
  background-color: var(--nv-navy);
}

.story-card:focus-within :is(.story-card__title, .story-card__industry, .story-card__download) {
  color: var(--nv-white);
}

.story-card:focus-within .story-card__link span {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--nv-green);
}

/* @media (hover: hover) .story-card:hover */
@media (hover: hover) and (pointer: fine) {
  .story-card:hover .story-card__body {
    background-color: var(--nv-navy);
  }

  .story-card:hover :is(.story-card__title, .story-card__industry, .story-card__download) {
    color: var(--nv-white);
  }

  .story-card:hover .story-card__link span {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--nv-green);
  }

  .story-card:hover .story-card__image {
    transform: scale(1.05);
  }

  .story-card .story-card__download:hover {
    color: var(--nv-green);
  }
}

/* @media (prefers-reduced-motion: reduce) .story-card */
@media (prefers-reduced-motion: reduce) {
  .story-card__image,
  .story-card__body,
  .story-card__title,
  .story-card__industry,
  .story-card__download {
    transition: none;
  }
}
