/* Album notes and directory share the existing type and palette. */
.ib-v58-album-notes { padding-block: clamp(24px, 4vw, 42px); }
.ib-v58-album-notes h2 { margin-block: 0 8px; color: inherit; }
.ib-v58-album-notes p { max-width: 68ch; margin-block: 8px 12px; }
.ib-v58-locale { color: inherit; text-decoration: underline; text-underline-offset: .2em; }

/* Portfolio motion. Keep the title, portrait and cards legible on first paint. */
.portfolio-home body.motion-reveal #hero-title .word {
  overflow: visible;
}

.portfolio-home body.motion-reveal #hero-title .word span {
  animation: ib-title-settle 540ms cubic-bezier(.2,.75,.25,1) backwards;
}

.portfolio-home body.motion-reveal #hero-title .word:nth-child(2) span {
  animation-delay: 45ms;
}

.portfolio-home body.motion-reveal #hero-title .word:nth-child(3) span {
  animation-delay: 90ms;
}

.portfolio-home body.motion-reveal .hero .portrait-wrap,
.portfolio-home body.motion-reveal .hero .portrait-caption {
  animation: none;
}

.portfolio-home body.motion-reveal .hero .portrait-photo {
  animation: ib-portrait-settle 680ms cubic-bezier(.2,.75,.25,1) backwards;
}

.portfolio-home body.motion-reveal .hero .portrait-wrap::before {
  animation: ib-frame-settle 680ms cubic-bezier(.2,.75,.25,1) backwards;
}

.portfolio-home #work :is(.project,.collection-tile).reveal {
  opacity: 1;
  transform: none;
  transition: none;
}

.portfolio-home #work :is(.project,.collection-tile).reveal.visible {
  animation: ib-card-settle 330ms cubic-bezier(.2,.75,.25,1);
}

.portfolio-home #work :is(.project,.collection-tile).reveal:focus-within {
  animation: none;
}

.portfolio-home .hero.paused :is(#hero-title .word span,.portrait-photo),
.portfolio-home .hero.paused .portrait-wrap::before {
  animation-play-state: paused;
}

@media (min-width: 761px) {
  .portfolio-home[lang="ar"] body.motion-reveal #hero-title .word + .word {
    display: inline-block;
    vertical-align: baseline;
  }

  .portfolio-home[lang="ar"] body.motion-reveal #hero-title .word:nth-child(3) {
    margin-inline-start: .16em;
  }
}

@keyframes ib-title-settle {
  from { transform: translateY(12px); }
  to { transform: none; }
}

@keyframes ib-portrait-settle {
  from { transform: translateY(7px); }
  to { transform: none; }
}

@keyframes ib-frame-settle {
  from { transform: translateY(3px) scale(.985); }
  to { transform: none; }
}

@keyframes ib-card-settle {
  from { transform: translateY(7px); }
  to { transform: none; }
}

@media (max-width: 760px), (pointer: coarse) {
  .portfolio-home body.motion-reveal .hero .portrait-photo,
  .portfolio-home body.motion-reveal .hero .portrait-wrap::before,
  .portfolio-home #work :is(.project,.collection-tile).reveal.visible {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-home body.motion-reveal :is(#hero-title .word span,.portrait-photo),
  .portfolio-home body.motion-reveal .hero .portrait-wrap::before,
  .portfolio-home #work :is(.project,.collection-tile).reveal.visible {
    animation: none;
    transform: none;
  }
}

/* Reserve space for related albums before their deferred script runs. */
.follow-albums[aria-busy="true"]:empty {
  box-sizing: border-box;
  min-block-size: 100vh;
}

/* Keep project navigation visible within narrow album and viewer widths. */
@media (max-width: 900px) {
  :is(body:has(.gallery-wrap), body:has(.topbar.ib-album-header)) :is(.top.ib-album-header, .topbar.ib-album-header, .ib-album-viewer-header) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 6px;
    row-gap: 0;
  }

  :is(body:has(.gallery-wrap), body:has(.topbar.ib-album-header)) :is(.top.ib-album-header, .topbar.ib-album-header, .ib-album-viewer-header) > .ib-section-rail {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-width: 0;
  }

  :is(body:has(.gallery-wrap), body:has(.topbar.ib-album-header)) :is(.top.ib-album-header, .topbar.ib-album-header, .ib-album-viewer-header) > .ib-section-rail a {
    text-align: center;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  :is(body:has(.gallery-wrap), body:has(.topbar.ib-album-header)) :is(.top.ib-album-header, .topbar.ib-album-header, .ib-album-viewer-header) > :is(.logo, .brand) {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  :is(body:has(.gallery-wrap), body:has(.topbar.ib-album-header)) :is(.top.ib-album-header, .topbar.ib-album-header, .ib-album-viewer-header) > :is(.topright, .back-link, .ib-viewer-close) {
    grid-column: 2;
    grid-row: 1;
  }
}
