/* Shared case topline component.
   Source of truth for GIS, UI Kit and UI Kit Draft. */

:is(.case-page, .ui-case .editorial-case) .case-hero__topline {
  display: grid;
  width: 100%;
  min-height: 50px;
  padding: 0;
  align-items: center;
  grid-template-columns: 216px 145px minmax(0, 1fr) 145px max-content;
  gap: 0;
}

/* GIS hosts the component in a full-width hero; UI Kit already hosts it
   inside its 1880px case shell. Both resolve to the same desktop canvas. */
.case-page .case-hero__topline.case-shell {
  width: min(1880px, calc(100% - 40px));
  margin-inline: auto;
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back,
:is(.case-page, .ui-case .editorial-case) .case-topline__status,
:is(.case-page, .ui-case .editorial-case) .case-chip {
  display: inline-flex;
  box-sizing: border-box;
  height: 50px;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-family: 'Anton', Impact, sans-serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

:is(.case-page, .ui-case .editorial-case) .case-topline__label {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
  transform-origin: center;
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back {
  width: 216px;
  max-width: none;
  padding: 0 18px 0 0;
  grid-column: 1;
  order: 0;
  flex: none;
  justify-content: flex-start;
  gap: 10px;
  overflow: hidden;
  background: #f5f5f5;
  color: #bebcbc;
  text-decoration: none;
  transition: transform 220ms var(--ease);
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back:hover {
  transform: translateY(-2px);
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back:focus-visible {
  outline: 2px solid #000;
  outline-offset: 4px;
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back-icon {
  display: grid;
  box-sizing: border-box;
  width: 50px;
  height: 50px;
  margin: 0;
  flex: 0 0 50px;
  place-items: center;
  border-radius: 50%;
  background: #bebcbc;
  transition: background 220ms var(--ease);
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back-icon img {
  display: block;
  width: 50px;
  height: 50px;
  max-width: none;
  transform: none;
}

:is(.case-page, .ui-case .editorial-case) .case-topline__back:hover .case-topline__back-icon {
  background: #fcf88a;
}

:is(.case-page, .ui-case .editorial-case) .case-topline__status {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding-inline: 24px;
  grid-column: 3;
  order: 0;
  flex: none;
  justify-self: stretch;
  background: #ff1349;
  color: #fff;
}

:is(.case-page, .ui-case .editorial-case) .case-tags {
  display: flex;
  width: max-content;
  min-width: 0;
  max-width: none;
  height: 50px;
  grid-column: 5;
  order: 0;
  flex: none;
  justify-self: end;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
}

:is(.case-page, .ui-case .editorial-case) .case-chip {
  width: auto;
  padding-inline: 24px;
  background: #f5f5f5;
  color: #000;
}

:is(.case-page, .ui-case .editorial-case) .case-chip--accent {
  background: #fcf88a;
}

:is(.case-page, .ui-case .editorial-case) .case-chip--dark {
  background: #000;
  color: #fff;
}

/* Content-specific pill widths from the approved desktop layouts. */
.case-page .case-tags .case-chip:nth-child(1) { width: 129px; }
.case-page .case-tags .case-chip:nth-child(2) { width: 248px; }
.case-page .case-tags .case-chip:nth-child(3) { width: 162px; }
.case-page .case-tags .case-chip:nth-child(4) { width: 144px; }

.ui-case .editorial-case .case-tags .case-chip:nth-child(1) { width: 197px; }
.ui-case .editorial-case .case-tags .case-chip:nth-child(2) { width: 240px; }
.ui-case .editorial-case .case-tags .case-chip:nth-child(3) { width: 94px; }

/* Wide tablet: back + tags stay in one row, status moves below. */
@media (min-width: 1001px) and (max-width: 1200px) {
  :is(.case-page, .ui-case .editorial-case) .case-hero__topline {
    grid-template-columns: 216px minmax(0, 1fr);
    row-gap: 10px;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__back {
    grid-column: 1;
    grid-row: 1;
  }

  :is(.case-page, .ui-case .editorial-case) .case-tags {
    grid-column: 2;
    grid-row: 1;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__status {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Narrow tablet: each logical group gets a dedicated row. */
@media (min-width: 701px) and (max-width: 1000px) {
  :is(.case-page, .ui-case .editorial-case) .case-hero__topline {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__back,
  :is(.case-page, .ui-case .editorial-case) .case-topline__status,
  :is(.case-page, .ui-case .editorial-case) .case-tags {
    grid-column: 1;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__back { grid-row: 1; }
  :is(.case-page, .ui-case .editorial-case) .case-topline__status { grid-row: 2; }

  :is(.case-page, .ui-case .editorial-case) .case-tags {
    width: 100%;
    height: auto;
    grid-row: 3;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  :is(.case-page, .ui-case .editorial-case) .case-chip {
    width: auto !important;
  }
}

/* Mobile: each logical group gets its own row; tags can wrap. */
@media (max-width: 700px) {
  :is(.case-page, .ui-case .editorial-case) .case-hero__topline {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__back,
  :is(.case-page, .ui-case .editorial-case) .case-topline__status,
  :is(.case-page, .ui-case .editorial-case) .case-tags {
    grid-column: 1;
    width: 100%;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__back {
    grid-row: 1;
    width: 216px;
    justify-self: start;
  }

  :is(.case-page, .ui-case .editorial-case) .case-topline__status {
    grid-row: 2;
  }

  :is(.case-page, .ui-case .editorial-case) .case-tags {
    height: auto;
    grid-row: 3;
    justify-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  :is(.case-page, .ui-case .editorial-case) .case-chip {
    width: auto !important;
    height: 42px;
    min-height: 42px;
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(.case-page, .ui-case .editorial-case) .case-topline__back,
  :is(.case-page, .ui-case .editorial-case) .case-topline__back-icon {
    transition: none;
  }
}
