/* Homepage "Our work. Their growth." project showcase (components/section-projects.php, data in config/projects.php).
 *
 * Desktop (64rem and up): the flagship on the left (about 58%) and the other projects stacked on the right.
 * Tablet (40rem to 63.999rem): the flagship full width, the other projects in two columns.
 * Phones (under 40rem): the flagship in full, then the other projects in a native scroll-snapping row with a peek of the
 * next card (the controls come from column-slider.js). Showcase image shapes: the flagship fills its column on desktop,
 * 16:9 on tablets and 4:3 on phones; every other project is 16:9 on every screen. */
.pj {
  background-color: #f7f7f7;
  padding: var(--sectionPadding);
}
.pj__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2.25rem, 5vw, 3.5rem);
  margin: auto;
  max-width: 80rem;
  width: 100%;
  scroll-margin-top: 6rem;
}

/* ------------------------------------------------------------------ introduction (split on wider screens) */
.pj__intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
}
.pj__flex .cs-title {
  margin: 0;
  max-width: 20ch;
}
.pj__lead {
  position: relative;
  margin: 1rem 0 0;
  max-width: 40rem;
  font-size: var(--bodyFontSize);
  line-height: 1.55em;
  color: var(--bodyTextColor);
}
@media only screen and (min-width: 48rem) {
  .pj__intro {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .pj__flex {
    flex: none;
    max-width: 40rem;
    width: 40vw;
  }
  .pj__lead {
    margin: 0;
    padding: 0.75rem 0 0.75rem 1.5rem;
  }
  .pj__lead:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    background: var(--primary);
    opacity: 0.2;
    height: 100%;
    width: 1px;
  }
}

/* ------------------------------------------------------------------ project cards */
.pj__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
  width: 100%;
}
.pj-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pj-card__media {
  position: relative;
  overflow: hidden;
  border-radius: 1rem;
  background-color: #0b2a4a;
  aspect-ratio: 16 / 9;
  width: 100%;
}
.pj-card--feature .pj-card__media {
  aspect-ratio: 4 / 3;
}
.pj-card__img {
  position: absolute;
  inset: 0;
  display: block;
  height: 100%;
  width: 100%;
  object-fit: cover;
}
.pj-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 1.1rem;
}
.pj-card__name {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  line-height: 1.15em;
  font-weight: 700;
  color: var(--headerColor);
}
.pj-card--feature .pj-card__name {
  font-size: 1.75rem;
}
.pj-tags {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  line-height: 1.5em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0b6ea6;
}
.pj-tags li {
  margin: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}
.pj-tags li:not(:last-child):after {
  content: "\00b7";
  margin: 0 0.55em;
  color: inherit;
}
.pj-card__text {
  margin: 0;
  max-width: 36rem;
  font-size: 1rem;
  line-height: 1.6em;
  color: var(--bodyTextColor);
}
.pj-card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 1rem;
  text-decoration: none;
  font-family: var(--navFont);
  font-size: 0.9375rem;
  line-height: 1.2em;
  font-weight: 700;
  color: var(--linkOnLight, #0a74b5);
}
.pj-card__text + .pj-card__link {
  margin-top: 1rem;
  padding-top: 0;
}
.pj-card__link:after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.pj-card__link:focus-visible {
  outline: none;
}
.pj-card:focus-within {
  outline: 2px solid var(--secondary);
  outline-offset: 6px;
  border-radius: 1rem;
}
.pj-card--link:hover .pj-card__cta {
  text-decoration: underline;
  text-decoration-color: var(--secondary);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}
.pj-card__arrow {
  flex: none;
}
.pj-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ the other projects */
.pj-slider {
  min-width: 0;
}
.pj-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pj-item {
  display: flex;
  margin: 0;
  min-width: 0;
}
.pj-slider-nav {
  display: none;
}

/* Hover (only for projects that have a case study) */
@media (hover: hover) {
  .pj-card--link:hover .pj-card__img {
    transform: scale(1.04);
  }
  .pj-card--link:hover .pj-card__arrow {
    transform: translateX(4px);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .pj-card__img {
    transition: transform 0.7s ease;
  }
  .pj-card__arrow {
    transition: transform 0.25s;
  }
  .pj-slider-dot {
    transition: width 0.25s, opacity 0.25s;
  }
}

/* ------------------------------------------------------------------ phones: the other projects swipe sideways */
@media only screen and (max-width: 39.999rem) {
  .pj-slider {
    margin: 0 -1rem;
    width: calc(100% + 2rem);
  }
  .pj-secondary {
    position: relative;
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 1rem 0.75rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 1rem;
    scrollbar-width: none;
  }
  .pj-secondary::-webkit-scrollbar {
    display: none;
  }
  .pj-item {
    flex: 0 0 calc((100% + 0.25rem) / 1.12);
    scroll-snap-align: start;
  }
  .pj-item:only-child {
    flex-basis: 100%;
  }
  .pj-slider-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 0.5rem;
  }
  .pj-slider-nav[hidden] {
    display: none;
  }
  .pj-card__name,
  .pj-card--feature .pj-card__name {
    font-size: 1.375rem;
  }
}
.pj-slider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: transparent;
  height: 2.75rem;
  width: 2.75rem;
  color: var(--primary);
  cursor: pointer;
}
.pj-slider-btn[aria-disabled="true"] {
  opacity: 0.3;
  cursor: default;
}
.pj-slider-btn:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 3px;
}
.pj-slider-dots {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pj-slider-dot {
  display: block;
  border-radius: 0.25rem;
  background: var(--primary);
  opacity: 0.25;
  height: 0.5rem;
  width: 0.5rem;
}
.pj-slider-dot.is-active {
  opacity: 1;
  width: 1.5rem;
}
.pj-slider-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ tablet and desktop */
@media only screen and (min-width: 40rem) {
  .pj__grid {
    gap: 2rem;
  }
  .pj-secondary {
    gap: 2rem;
  }
  .pj-card--feature .pj-card__media {
    aspect-ratio: 16 / 9;
  }
}
/* BathroomKing artwork (square: logo at the top, laptop and phone below). On phones and tablets the frame is 6:5 and shows the
   upper-middle of the picture so the logo and both devices stay in view; on desktop the frame is close to square and the picture
   is anchored to the left, so the crown is never clipped when the column gets narrower. */
.pj-card--bathroomking .pj-card__media {
  aspect-ratio: 6 / 5;
}
.pj-card--bathroomking .pj-card__img {
  object-position: center 25%;
}
@media only screen and (min-width: 64rem) {
  .pj-card--bathroomking {
    container-type: inline-size;
  }
  .pj-card--bathroomking .pj-card__media {
    aspect-ratio: auto;
    /* never taller than 1.08 x its width, so a tall right-hand column cannot crop the square artwork heavily */
    max-height: 108cqw;
  }
  .pj-card--bathroomking .pj-card__img {
    object-position: 15% 40%;
  }
}

/* Narrower right-hand column: slightly tighter labels so they stay on one line where possible. */
@media only screen and (min-width: 64rem) and (max-width: 79.999rem) {
  .pj-tags {
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
  }
}
@media only screen and (min-width: 64rem) {
  .pj__grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    column-gap: clamp(1.75rem, 3vw, 3rem);
    align-items: stretch;
  }
  .pj-card--feature .pj-card__media {
    flex: 1 1 auto;
    aspect-ratio: auto;
    min-height: 26rem;
  }
  .pj-card--feature .pj-card__body {
    flex: none;
  }
  .pj-card--feature .pj-card__name {
    font-size: clamp(1.75rem, 2.4vw, 2.25rem);
  }
  .pj-secondary {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: 1fr;
    height: 100%;
  }
}

/* Three or more other projects: stacking them beside the flagship would make it too tall, so on desktop the flagship runs
   full width and the others sit in a row beneath it. */
@media only screen and (min-width: 64rem) {
  .pj__grid--many {
    grid-template-columns: minmax(0, 1fr);
  }
  .pj__grid--many .pj-card--feature .pj-card__media {
    flex: none;
    aspect-ratio: 21 / 9;
    min-height: 0;
  }
  .pj__grid--many .pj-secondary {
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    grid-auto-rows: auto;
    height: auto;
  }
}

/* ------------------------------------------------------------------ dark mode */
html.dark-mode .pj {
  background-color: rgba(0, 0, 0, 0.2);
}
html.dark-mode .pj__flex .cs-title,
html.dark-mode .pj-card__name {
  color: #fff;
}
html.dark-mode .pj__lead,
html.dark-mode .pj-card__text {
  color: rgba(255, 255, 255, 0.84);
}
html.dark-mode .pj__lead:before {
  background: #fff;
}
html.dark-mode .pj-tags,
html.dark-mode .pj-tags li {
  color: var(--secondary);
}
html.dark-mode .pj-card__link {
  color: var(--secondary);
}
html.dark-mode .pj-card__media {
  background-color: #0a1824;
}
html.dark-mode .pj-slider-btn {
  border-color: var(--bodyTextColorWhite);
  color: var(--bodyTextColorWhite);
}
html.dark-mode .pj-slider-dot {
  background: var(--bodyTextColorWhite);
}
html.dark-mode .pj-slider-dot.is-active {
  background: var(--secondary);
}
