/* Supporting work under the existing watsonx feature. */
.home-bento {
  --bento-gap: clamp(10px, 1.15cqi, 16px);
  --bento-ease: cubic-bezier(.2, .75, .2, 1);
  container: home-bento / inline-size;
  inline-size: min(calc(100% - 2 * var(--route02-x)), 1370px);
  margin: clamp(36px, 5vw, 72px) auto 0;
  scroll-margin-block-start: calc(var(--nav-h) + var(--space-4));
  color: var(--text);
}

.home-bento .gallery-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--bento-gap);
  align-items: start;
}

.home-bento .gallery-focus-row { display: contents; }

.home-bento .gallery-collections {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--bento-gap);
  scroll-margin-block-start: calc(var(--nav-h) + var(--space-4));
}

.home-bento .gallery-tile {
  --caption-accent: var(--blue);
  /* The hero's indigo keeps the shared accents deep enough for white text. */
  --caption-tone: color-mix(in srgb, var(--caption-accent) 36%, #22214a);
  --hover-tone: var(--caption-tone);
  position: relative;
  isolation: isolate;
  display: block;
  min-inline-size: 0;
  overflow: visible;
  background: transparent;
  color: inherit;
  text-decoration: none;
}

.home-bento .gallery-tile::before {
  --caption-blur: clamp(3px, .8cqi, 8px);
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: color-mix(in srgb, var(--hover-tone) 90%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.home-bento :is(.gallery-pci, .gallery-star)::before {
  --caption-blur: clamp(1.5px, .38cqi, 4px);
}

@supports (backdrop-filter: blur(1px)) {
  .home-bento .gallery-tile::before {
    background: color-mix(in srgb, var(--hover-tone) 60%, transparent);
    backdrop-filter: blur(var(--caption-blur)) saturate(1.12) brightness(.55);
  }
}

.home-bento .gallery-art {
  display: grid;
  aspect-ratio: var(--art-ratio, 6 / 5);
  overflow: clip;
  background: var(--art-ground, var(--bg));
}

.home-bento .gallery-art img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
  object-fit: contain;
}

.home-bento .gallery-cloud { --art-ground: #161616; }
.home-bento .gallery-patterns { --art-ground: #16d6d2; }
.home-bento :is(.gallery-cloud, .gallery-patterns) { --art-ratio: 4 / 3; }
.home-bento .gallery-pikapp { --art-ground: #f3f3f3; --art-ratio: 5 / 3; }
.home-bento .gallery-pci { --art-ratio: 1584 / 1224; }
.home-bento .gallery-ability { --art-ground: #fcc56e; --art-ratio: 1584 / 1224; }
.home-bento .gallery-star { --art-ground: #253a2b; --art-ratio: 5 / 4; }
.home-bento .gallery-illustration { --art-ground: #011f41; --art-ratio: 1; }
.home-bento .gallery-graphic { --art-ground: #005b76; --art-ratio: 1; }
.home-bento :is(.gallery-pci, .gallery-star) { --caption-accent: var(--pink); }
.home-bento :is(.gallery-illustration, .gallery-graphic) { --caption-accent: var(--purple); }

/* Pull the active overlay from the thumbnail while keeping the nameplate on-brand. */
.home-bento .gallery-cloud { --hover-tone: #40305e; }
.home-bento .gallery-patterns { --hover-tone: #07535a; }
.home-bento .gallery-pikapp { --hover-tone: #144874; }
.home-bento .gallery-pci { --hover-tone: #753812; }
.home-bento .gallery-ability { --hover-tone: #634811; }
.home-bento .gallery-star { --hover-tone: #732c32; }
.home-bento .gallery-illustration { --hover-tone: #172b61; }
.home-bento .gallery-graphic { --hover-tone: #00546b; }

.home-bento .gallery-star-page { display: none; }

.home-bento .gallery-cloud:hover .gallery-art img { transform: none; }

.home-bento .gallery-ability .gallery-art {
  container-type: size;
  place-items: center;
}

.home-bento .gallery-ability .gallery-art img {
  inline-size: min(100cqw, 100cqh);
  block-size: auto;
  clip-path: inset(0 0 0 .45%);
}

.home-bento .gallery-graphic .gallery-art {
  position: relative;
  container: bento-sgla / size;
}

.home-bento .gallery-graphic .gallery-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, #ca6f60 25%, #ba4230 25% 50%, #b52024 50% 75%, #86161a 75%) left / 50% 100% no-repeat,
    linear-gradient(to bottom, #ffd77a 25%, #f6ca5e 25% 50%, #f6952f 50% 75%, #f2702a 75%) right / 50% 100% no-repeat;
}

.home-bento .gallery-graphic .gallery-art img { position: relative; }

@container bento-sgla (aspect-ratio < 1) {
  .home-bento .gallery-graphic .gallery-art::before {
    background:
      linear-gradient(to right, #ca6f60 33.333%, #92d0e6 33.333% 66.667%, #ffd77a 66.667%) top / 100% 50% no-repeat,
      linear-gradient(to right, #86161a 33.333%, #006480 33.333% 66.667%, #f2702a 66.667%) bottom / 100% 50% no-repeat;
  }
}

.home-bento .gallery-caption {
  --caption-inset: clamp(8px, 1.4cqi, 20px);
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  align-items: end;
  padding: var(--caption-inset);
  overflow: clip;
  pointer-events: none;
  color: #fff;
}

.home-bento .gallery-copy {
  display: grid;
  grid-template-rows: auto 0fr;
  min-inline-size: 0;
}

.home-bento .gallery-title {
  position: relative;
  isolation: isolate;
  justify-self: start;
  margin: 0;
  color: inherit;
  font: 600 clamp(1rem, 2.1cqi, 1.5rem) / 1.12 Barlow, system-ui, sans-serif;
  letter-spacing: -.012em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.home-bento .gallery-title::before {
  --title-fade: clamp(16px, 2.5cqi, 32px);
  content: "";
  position: absolute;
  z-index: -1;
  inset-inline: calc(-1 * var(--caption-inset)) calc(-1 * var(--title-fade));
  inset-block: calc(-1 * var(--title-fade)) calc(-1 * var(--caption-inset));
  background: color-mix(in srgb, var(--caption-tone) 84%, transparent);
  mask-image:
    linear-gradient(to bottom, transparent, #000 var(--title-fade)),
    linear-gradient(to left, transparent, #000 var(--title-fade));
  mask-composite: intersect;
}

.home-bento .gallery-info {
  min-block-size: 0;
  overflow: clip;
  opacity: 0;
}

.home-bento .gallery-summary {
  max-inline-size: 44ch;
  margin: 0;
  padding-block-start: var(--space-2);
  font: 400 clamp(.8125rem, 1.55cqi, 1rem) / 1.27 Barlow, system-ui, sans-serif;
}

.home-bento .gallery-meta {
  display: block;
  padding-block-start: var(--space-2);
  color: color-mix(in srgb, white 84%, var(--caption-accent));
  font: 400 clamp(.6875rem, 1.7cqi, var(--text-caption)) / 1.25 'Source Code Pro', ui-monospace, monospace;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.home-bento :is(.gallery-pikapp, .gallery-star) {
  grid-column: 1 / -1;
}

.home-bento .gallery-tile:focus-visible { z-index: 1; }

@media (forced-colors: active) {
  .home-bento .gallery-caption { color: CanvasText; }
  .home-bento .gallery-title::before { inset: -2px -4px; background: Canvas; mask-image: none; }
  .home-bento .gallery-tile::before { background: Canvas; backdrop-filter: none; }
  .home-bento .gallery-meta { color: inherit; }
}

@media (hover: hover) and (pointer: fine) {
  @media (500px <= width <= 880px) {
    .home-bento {
      --bento-inset: clamp(8px, 12vw - 56px, var(--route02-x));
      inline-size: calc(100% - 2 * var(--bento-inset));
    }
  }

  @container home-bento (width > 440px) {
    .home-bento .gallery-layout { grid-template-columns: minmax(0, 1fr); }
    .home-bento .gallery-focus-row {
      --row-width: calc(100cqi - 2 * var(--bento-gap));
      --row-height: calc(var(--row-width) * 5 / 18);
      display: grid;
      grid-template-columns: minmax(0, var(--first, 1fr))
        minmax(0, var(--second, 1fr)) minmax(0, var(--third, 1fr));
      gap: var(--bento-gap);
      align-items: start;
    }

    .home-bento .home-bento-pair {
      --row-width: calc(100cqi - var(--bento-gap));
      --row-height: calc(var(--row-width) * 1224 / (2 * 1584));
      grid-template-columns: minmax(0, var(--first, 1fr)) minmax(0, var(--second, 1fr));
    }

    .home-bento .gallery-collections { --row-height: calc(var(--row-width) / 3); }

    .home-bento[data-bento-ready] .home-bento-pair {
      --first: .94fr;
      --second: 1.06fr;
    }

    .home-bento .gallery-focus-row .gallery-art {
      aspect-ratio: auto;
      block-size: var(--row-height);
    }

    .home-bento :is(.gallery-pikapp, .gallery-star) {
      grid-column: auto;
    }

    .home-bento[data-bento-ready] .gallery-title { opacity: 0; }
    .home-bento[data-bento-ready] .gallery-title::before { display: none; }

    .home-bento .gallery-tile[data-bento-active]:not([data-tag-dismissed]) .gallery-copy {
      grid-template-rows: auto 1fr;
    }

    .home-bento .gallery-tile[data-bento-active]:not([data-tag-dismissed])::before {
      opacity: 1;
      visibility: visible;
    }

    .home-bento[data-bento-ready] .gallery-tile[data-bento-active]:not([data-tag-dismissed]) :is(.gallery-title, .gallery-info) {
      opacity: 1;
    }

    .home-bento .gallery-pikapp .gallery-art img {
      inline-size: min(100%, calc(1.4 * var(--row-height)));
      justify-self: center;
      object-fit: cover;
    }
  }

  @container home-bento (440px < width <= 620px) {
    .home-bento .gallery-layout { --bento-gap: 7px; }
    .home-bento .gallery-focus-row:first-child { --row-height: max(164px, calc(var(--row-width) * .31)); }
    .home-bento .gallery-collections { --row-height: calc(var(--row-width) * .375); }

    .home-bento :is(.gallery-cloud, .gallery-patterns) .gallery-art > :is(img, .ibm-cloud-motion) {
      scale: 1.12;
    }
  }
}

@media (hover: hover) and (pointer: fine) and ((prefers-reduced-motion: reduce) or (forced-colors: active)) {
  @container home-bento (width > 440px) {
    .home-bento :is(.gallery-focus-row, .gallery-copy, .gallery-title, .gallery-info),
    .home-bento .gallery-tile::before { transition: none; }

    /* Let the longest caption set the height before interaction starts. */
    .home-bento .gallery-focus-row { align-items: stretch; }
    .home-bento .gallery-tile { display: grid; grid-template-columns: minmax(0, 1fr); }
    .home-bento :is(.gallery-art, .gallery-caption) { grid-area: 1 / 1; }

    .home-bento .gallery-focus-row .gallery-art {
      contain: size;
      block-size: auto;
      min-block-size: var(--row-height);
    }

    .home-bento .gallery-caption { position: relative; inset: auto; }
    .home-bento .gallery-copy { grid-template-rows: auto 1fr; }
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  @container home-bento (width > 440px) {
    .home-bento[data-bento-ready] .gallery-focus-row {
      transition: grid-template-columns 360ms var(--bento-ease);
    }

    .home-bento .gallery-focus-row[data-expanded="0"] { --first: 1.42fr; --second: .79fr; --third: .79fr; }
    .home-bento .gallery-focus-row[data-expanded="1"] { --first: .79fr; --second: 1.42fr; --third: .79fr; }
    .home-bento .gallery-focus-row[data-expanded="2"] { --first: .79fr; --second: .79fr; --third: 1.42fr; }

    .home-bento[data-bento-ready] .home-bento-pair[data-expanded="0"] { --first: 1fr; --second: 1fr; }
    .home-bento[data-bento-ready] .home-bento-pair[data-expanded="1"] { --first: .76fr; --second: 1.24fr; }

    /* The full cover and the facing page use their original print proportions. */
    .home-bento .gallery-collections[data-expanded="0"] {
      --first: 1.487045fr;
      --second: .7564775fr;
      --third: .7564775fr;
    }

    .home-bento .gallery-copy { transition: grid-template-rows 180ms var(--bento-ease); }
    .home-bento .gallery-tile::before { transition: opacity 180ms ease, visibility 180ms; }
    .home-bento :is(.gallery-title, .gallery-info) { transition: opacity 100ms ease; }

    .home-bento .gallery-tile[data-bento-active]:not([data-tag-dismissed]) .gallery-copy { transition-delay: 90ms; }
    .home-bento .gallery-tile[data-bento-active]:not([data-tag-dismissed]) :is(.gallery-title, .gallery-info) { transition-delay: 170ms; }

    .home-bento .gallery-pikapp[data-bento-active] .gallery-art img {
      mask-image: linear-gradient(to right, transparent, #000 7%, #000 97%, transparent);
    }

    .home-bento[data-bento-ready] .gallery-pci .gallery-art img {
      object-fit: cover;
      transform: scale(1.025);
      transition: transform 360ms var(--bento-ease);
    }
    .home-bento[data-bento-ready] .home-bento-pair[data-expanded]:not([data-expanded="-1"]) .gallery-pci .gallery-art img {
      transform: scale(1);
    }

    .home-bento[data-bento-ready] .gallery-star .gallery-art {
      --cover-width: calc(var(--row-height) * 720 / 968);
      --cover-left: 50%;
      --cover-translate: -50%;
      --cover-zoom: 1.35;
      position: relative;
      isolation: isolate;
    }

    .home-bento[data-bento-ready] .gallery-star .gallery-art > img {
      position: absolute;
      z-index: 1;
      inset-block-start: 0;
      inset-inline-start: var(--cover-left);
      inline-size: var(--cover-width);
      block-size: 100%;
      transform-origin: top center;
      transform: translateX(var(--cover-translate)) scale(var(--cover-zoom));
      transition: inset-inline-start 360ms var(--bento-ease), transform 360ms var(--bento-ease);
    }

    .home-bento .gallery-collections:is([data-expanded="1"], [data-expanded="2"]) .gallery-star .gallery-art {
      --cover-zoom: 1.063;
    }

    .home-bento .gallery-collections[data-expanded="0"] .gallery-star .gallery-art {
      --cover-left: 0%;
      --cover-translate: 0%;
      --cover-zoom: 1;
    }

    .home-bento[data-bento-ready] .gallery-star-page {
      display: block;
      position: absolute;
      inset-block: 0;
      inset-inline: var(--cover-width) 0;
      overflow: clip;
      opacity: 0;
      transition: opacity 180ms ease;
    }

    .home-bento .gallery-star-page img {
      inline-size: calc(var(--row-height) * 1100 / 740);
      max-inline-size: none;
      block-size: 100%;
      object-fit: fill;
    }

    .home-bento .gallery-collections[data-expanded="0"] .gallery-star-page {
      opacity: 1;
      transition-delay: 85ms;
    }
  }

  @container home-bento (440px < width <= 620px) {
    /* Match the wider reveal to the taller cover and excerpt. */
    .home-bento .gallery-collections[data-expanded="0"] {
      --first: 1.673554fr;
      --second: .663223fr;
      --third: .663223fr;
    }

    .home-bento[data-bento-ready] .gallery-collections[data-expanded="-1"] .gallery-star .gallery-art {
      --cover-zoom: 1.2;
    }

    .home-bento .gallery-collections:is([data-expanded="1"], [data-expanded="2"]) .gallery-star .gallery-art {
      --cover-zoom: 1;
    }
  }
}
