/* A tool page that opens on its own work (build.mjs, renderGalleryToolContent), set like the home page: paper, ink,
   large headings and one pale rule where a part begins. The wall in the middle is the home page's own (.home-covers). */
.tool-page .tool-gallery-main { max-width: none; width: auto; margin: 0; padding: 0 var(--page-gutter); counter-reset: none; }
.tool-gallery-main .tool-detail-flow { margin: 0; padding: 0; }
.tool-gallery-main [data-gallery] [hidden] { display: none !important; }
.tool-gallery-main [data-gallery].is-drop { outline: 3px dashed var(--paper); outline-offset: -12px; }

/* The first screen: the words on the left, one large before-and-after as tall as the window on the right. */
.gallery-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: calc(100vh - var(--header-height)); height: calc(100svh - var(--header-height)); min-height: 640px; margin-right: calc(var(--page-gutter) * -1); }
.gallery-words { display: flex; min-width: 0; flex-direction: column; justify-content: space-between; gap: 20px; padding: 12px 40px 40px 0; }
.tool-gallery-main .gallery-words .tool-detail-navigation { display: flex; margin: 0; padding: 0; border: 0; background: none; }
.tool-gallery-main .gallery-intro h1 { max-width: none; margin: 0; font-size: clamp(36px, 3.4vw, 50px); font-weight: 600; letter-spacing: -0.045em; line-height: 1.02; text-wrap: balance; }
.gallery-intro h1 span { display: block; text-wrap: balance; }
.tool-gallery-main .gallery-intro.is-long h1 { font-size: clamp(30px, 2.55vw, 40px); }
.tool-gallery-main .gallery-lede { max-width: 22em; margin: 22px 0 28px; color: var(--muted); font-size: var(--text-sub); line-height: 1.5; }
.gallery-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.tool-gallery-main .gallery-button { display: inline-flex; min-height: 52px; align-items: center; justify-content: center; margin: 0; padding: 0 26px; border: 1.5px solid #111110; border-radius: 0; background: transparent; color: #111110; font-family: inherit; font-size: var(--text-small); font-weight: 600; line-height: 1.2; letter-spacing: 0; cursor: pointer; }
.tool-gallery-main .gallery-button.is-primary { background: #111110; color: #fff; }
.tool-gallery-main .gallery-button:disabled { opacity: .5; cursor: default; }
.tool-gallery-main .gallery-text-button { padding: 0; border: 0; border-radius: 0; background: none; color: inherit; font-family: inherit; cursor: pointer; }
.tool-gallery-main .gallery-intro :is(.tool-preflight, .tool-launch-status, .gallery-status) { margin: 14px 0 0; }
.tool-gallery-main .gallery-intro :is(.tool-launch-status, .gallery-status):empty { display: none; }
.tool-gallery-main .gallery-status { max-width: 28em; color: var(--muted); font-size: var(--text-small); line-height: 1.5; }

/* With their own photo, the two buttons take one line and the two quieter ways take the next. */
.is-own .gallery-actions::after { content: ""; order: 1; flex-basis: 100%; height: 0; margin-top: -10px; }
.is-own .gallery-text-button { order: 2; }

.gallery-looks { display: flex; gap: 12px; }
html:not(.js) .gallery-looks { display: none; }
.tool-gallery-main .gallery-look { width: 60px; height: 75px; margin: 0; padding: 0; border: 0; border-radius: 0; background: #e8e6dd; cursor: pointer; }
.gallery-look :is(img, canvas) { display: block; width: 100%; height: 100%; object-fit: cover; }
.tool-gallery-main .gallery-look[aria-pressed="true"] { outline: 2px solid #111110; outline-offset: 3px; }
.tool-gallery-main :is(.gallery-look, .gallery-button, .gallery-text-button):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.gallery-compare { --x: 42%; position: relative; height: 100%; min-height: 0; aspect-ratio: 4 / 5; max-width: 45vw; overflow: hidden; background: #e8e6dd; }
.gallery-compare :is(img, canvas) { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-compare .gallery-before { clip-path: inset(0 calc(100% - var(--x)) 0 0); }
/* A visitor's own photo is shown whole, whatever its shape; so is a result that cannot be cut at the sides. */
.is-own .gallery-compare canvas, .gallery-compare.is-whole :is(img, canvas) { object-fit: contain; }
.gallery-compare i { position: absolute; top: 0; bottom: 0; left: var(--x); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); pointer-events: none; }
.gallery-compare i::after { content: ""; position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50% !important; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23111110' stroke-width='2'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 22px no-repeat; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.gallery-compare input[hidden] + i { display: none; }
.gallery-compare input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; touch-action: pan-y; }
.gallery-compare:has(input:focus-visible) i::after { outline: 3px solid var(--accent); outline-offset: 2px; }

/* The wall: the home page's, with its pictures opening in a viewer. */
.tool-gallery-main .home-covers { margin-top: clamp(56px, 6vw, 88px); }
.tool-gallery-main .gallery-head h2 { max-width: none; margin: 0; }

.gallery-viewer { width: fit-content; max-width: min(94vw, 1100px); max-height: 94vh; max-height: 94dvh; margin: auto; padding: 16px; border: 0; background: #f4f3ee; color: #121210; }
.gallery-viewer::backdrop { background: rgba(10, 10, 8, .84); }
.gallery-viewer img { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(94vh - 130px); max-height: calc(94dvh - 130px); margin: 0 auto; }
.gallery-viewer-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; min-width: min(560px, 86vw); padding-top: 12px; }
.gallery-viewer-bar > div { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-gallery-main .gallery-viewer .gallery-button { min-height: 44px; padding: 0 16px; }

/* Under the wall: a large heading on the left, the words on the right. */
.tool-page .tool-gallery-main .gallery-section { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px 48px; margin: 0; padding: clamp(56px, 6vw, 88px) 0; border: 0; border-top: 1px solid var(--rule); }
.tool-page .tool-gallery-main .gallery-section > h2 { max-width: 9em; margin: 0; font-size: var(--text-display); font-weight: 600; letter-spacing: -0.04em; line-height: 1.04; text-wrap: balance; }
.tool-page .tool-gallery-main .gallery-prose :is(p, li) { max-width: 36em; margin: 0 0 18px; padding: 0; border: 0; color: var(--muted); font-size: var(--text-sub); line-height: 1.6; }
.tool-page .tool-gallery-main .gallery-prose h3 { margin: 32px 0 8px; font-size: var(--text-sub); font-weight: 600; line-height: 1.35; }
.tool-page .tool-gallery-main .gallery-prose ul { margin: 0 0 18px; padding-left: 20px; }
.tool-page .tool-gallery-main .gallery-prose .faq-item { margin: 0 0 36px; padding: 0; border: 0; }
.tool-page .tool-gallery-main .gallery-prose .faq-item h3 { margin: 0 0 8px; }
.tool-page .tool-gallery-main .gallery-prose .faq-item p { margin: 0; }
.tool-page .tool-gallery-main .gallery-fold { max-width: 36em; margin: 28px 0 0; border-block: 1px solid var(--rule); }
.tool-gallery-main .gallery-fold summary { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 16px; list-style: none; cursor: pointer; }
.tool-gallery-main .gallery-fold summary::-webkit-details-marker { display: none; }
.tool-gallery-main .gallery-fold summary::after { content: "+"; font-size: 22px; line-height: 1; }
.tool-gallery-main .gallery-fold[open] summary::after { content: "−"; }
.tool-page .tool-gallery-main .gallery-fold summary h3 { margin: 0; }
.tool-page .tool-gallery-main .gallery-steps .step-grid { display: grid; grid-template-columns: minmax(0, 36em); gap: 36px; margin: 0; counter-reset: gallery-step; }
.tool-page .tool-gallery-main .gallery-steps article { margin: 0; padding: 0; border: 0; counter-increment: gallery-step; }
.tool-page .tool-gallery-main .gallery-steps h3 { margin: 0 0 8px; font-size: var(--text-sub); font-weight: 600; line-height: 1.35; }
.tool-page .tool-gallery-main .gallery-steps h3::before { content: counter(gallery-step) ". "; }
.tool-page .tool-gallery-main .gallery-steps p { margin: 0; color: var(--muted); font-size: var(--text-sub); line-height: 1.6; }
.tool-gallery-main .tool-detail-flow > :is(.tool-guide-link, .tool-ios-promotion) { width: auto; margin-inline: 0; }
/* The other tools run the width of the page: four pictures and their names. */
.tool-page .tool-gallery-main .related-tools { display: block; margin: 0; padding: clamp(56px, 6vw, 88px) 0; border: 0; border-top: 1px solid var(--rule); }
.tool-page .tool-gallery-main .related-tools > header { display: block; margin: 0 0 28px; padding: 0; }
.tool-page .tool-gallery-main .related-tools > header::before { content: none; }
.tool-page .tool-gallery-main .related-tools h2 { max-width: none; margin: 0; font-size: var(--text-display); font-weight: 600; letter-spacing: -0.04em; line-height: 1.04; }
.tool-page .tool-gallery-main .related-tool-index { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row; gap: 16px; margin: 0; padding: 0; overflow: visible; }
.tool-gallery-main .related-tool-link small { display: none; }

/* Just wide enough for two columns: the picture gives up some width so each line of the title stays one line. */
@media (min-width: 1024px) and (max-width: 1199px) {
  .gallery-compare { max-width: 38vw; }
  .tool-gallery-main .gallery-intro h1 { font-size: 34px; }
  .tool-gallery-main .gallery-intro.is-long h1 { font-size: 28px; }
}

/* Narrower than the sidebar's width the first screen is one column: words, then the picture. A visitor's own photo
   moves up under the title, with the looks and then the buttons below it. */
@media (max-width: 1023px) {
  .gallery-hero { display: flex; height: auto; min-height: 0; flex-direction: column; margin: 0; padding-bottom: 8px; }
  .gallery-words, .gallery-intro { display: contents; }
  .tool-gallery-main .gallery-words .tool-detail-navigation { order: 0; padding: 12px 0; }
  .tool-gallery-main .gallery-intro h1 { order: 1; font-size: 40px; }
  .tool-gallery-main .gallery-intro.is-long h1 { order: 1; font-size: 31px; }
  .tool-gallery-main .gallery-lede { order: 2; margin: 12px 0 16px; font-size: 16px; }
  .gallery-actions { order: 3; }
  .gallery-actions .gallery-button { flex: 1 1 100%; }
  .tool-gallery-main .gallery-intro :is(.tool-preflight, .tool-launch-status, .gallery-status) { order: 3; }
  .gallery-compare { order: 4; width: calc(100% + var(--page-gutter) * 2); height: auto; max-width: none; flex: none; margin: 16px calc(var(--page-gutter) * -1) 0; }
  .gallery-looks { order: 5; padding: 20px 3px 4px; }
  /* A tall photo gives up some height (it is still shown whole) so the looks and Download stay in reach under it. */
  .is-own .gallery-compare { order: 2; aspect-ratio: var(--own-ratio, 4 / 5); max-height: calc(100svh - var(--header-height) - 190px); min-height: 240px; scroll-margin-top: var(--header-height); }
  .is-own .gallery-looks { order: 3; }
  .is-own .gallery-actions { order: 4; margin-top: 16px; }
  .tool-gallery-main .is-own .gallery-intro :is(.tool-preflight, .tool-launch-status, .gallery-status) { order: 4; }
  .tool-page .tool-gallery-main .gallery-section { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 44px 0; }
  .tool-page .tool-gallery-main .gallery-prose :is(p, li), .tool-page .tool-gallery-main .gallery-steps p { font-size: 16px; }
  .tool-page .tool-gallery-main .related-tools { padding: 44px 0; }
}
@media (min-width: 621px) and (max-width: 1023px) {
  .gallery-compare { width: min(100%, 560px); align-self: flex-start; margin-inline: 0; }
  .gallery-actions .gallery-button { flex: 0 0 auto; }
}
@media (max-width: 800px) {
  .tool-page .tool-gallery-main .related-tool-index { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .gallery-viewer { max-width: 100vw; padding: 12px; }
  .gallery-viewer img { max-height: calc(94vh - 220px); max-height: calc(94dvh - 220px); }
  .gallery-viewer-bar > div { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .gallery-viewer-bar .is-primary { grid-column: 1 / -1; }
}
