/* Batch 15a: corporate archive galleries only. Existing layouts remain intact. */
.joud-group .group-section > .group-gallery,
.joud-public .joud-group .group-section > .group-gallery {
  grid-column: 1 / -1;
  grid-row: auto;
  min-width: 0;
  width: 100%;
  border-top: 1px solid #d8e4eb;
  padding-top: clamp(20px, 3vw, 32px);
}
.joud-group .group-gallery-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 18px;
  color: var(--group-muted);
  font-size: 12px;
  line-height: 1.6;
}
.joud-group .group-gallery-heading p { font-weight: 700; color: var(--group-ink); }
.joud-group .group-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 18px;
  align-items: start;
}
.joud-group .group-gallery-item { min-width: 0; }
.joud-group .group-gallery-link {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 12px;
  border: 1px solid #dce5e9;
  border-radius: 10px;
  background: #f6f7f5;
  color: var(--group-ink);
  text-decoration: none;
  overflow: hidden;
}
.joud-group .group-gallery-link:hover { border-color: #85a9ba; background: #eef4f5; }
.joud-group .group-gallery-link img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}
.joud-group .group-gallery-enlarge {
  position: absolute;
  inset-inline-end: 8px;
  inset-block-end: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #d8e4eb;
  border-radius: 50%;
  background: #fffffff2;
  font-size: 18px;
  line-height: 1;
}
.joud-group .group-gallery-item figcaption {
  margin-top: 10px;
  color: var(--group-muted);
  font: inherit;
  font-size: 12px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.joud-group .group-surface-blue > .group-gallery { border-color: #ffffff38; }
.joud-group .group-surface-blue .group-gallery-heading,
.joud-group .group-surface-blue .group-gallery-item figcaption { color: #d8e7ee; }
.joud-group .group-surface-blue .group-gallery-heading p { color: #fff; }
.joud-group .group-gallery-dialog {
  width: min(1120px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: clamp(14px, 3vw, 28px);
  border: 1px solid #b6cbd6;
  border-radius: 14px;
  color: var(--group-ink);
  background: #f9fbfc;
  overflow: auto;
  overscroll-behavior: contain;
  text-align: start;
}
.joud-group .group-gallery-dialog:not([open]) { display: none; }
.joud-group .group-gallery-dialog::backdrop { background: #102a3cdb; }
.joud-group .group-gallery-dialog-bar,
.joud-group .group-gallery-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.joud-group .group-gallery-dialog-bar { margin-bottom: 16px; }
.joud-group .group-gallery-dialog-bar p { font-size: 13px; font-variant-numeric: tabular-nums; }
.joud-group .group-gallery-dialog button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid #b6cbd6;
  border-radius: 7px;
  background: #fff;
  color: #163448;
  font: 650 13px/1.4 system-ui, sans-serif;
  white-space: normal;
  cursor: pointer;
}
.joud-group .group-gallery-dialog button:hover { background: #eaf3f7; }
.joud-group .group-gallery-dialog button:disabled { opacity: .4; cursor: default; }
.joud-group .group-gallery-dialog button:focus-visible { outline: 3px solid #c18300; outline-offset: 3px; }
.joud-group .group-gallery-dialog [data-gallery-close] { margin-inline-start: auto; }
.joud-group .group-gallery-dialog [data-gallery-close] span { font-size: 23px; line-height: 1; }
.joud-group .group-gallery-dialog-figure { min-width: 0; }
.joud-group .group-gallery-dialog-figure img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: max(160px, calc(100vh - 240px));
  max-height: max(160px, calc(100dvh - 240px));
  margin-inline: auto;
  object-fit: contain;
  background: #fff;
}
.joud-group .group-gallery-dialog-figure figcaption {
  margin-top: 16px;
  color: var(--group-muted);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.joud-group .group-gallery-dialog-actions { margin-top: 20px; }
.joud-group .group-gallery-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 980px) {
  .joud-group .group-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .joud-group .group-gallery-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .joud-group .group-gallery-link { aspect-ratio: 4 / 3; }
  .joud-group .group-gallery-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  }
  .joud-group .group-gallery-dialog-actions button { flex: 1 1 110px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .joud-group .group-gallery-dialog { padding-block: 12px; }
  .joud-group .group-gallery-dialog-bar { margin-bottom: 10px; }
  .joud-group .group-gallery-dialog-actions { margin-top: 12px; }
}
@media print {
  .joud-group .group-gallery-dialog,
  .joud-group .group-gallery-enlarge,
  .joud-group .group-gallery-heading span { display: none; }
  .joud-group .group-gallery-item { break-inside: avoid; }
}

/* Batch 15D: keep the dialog heading hidden despite legacy page h2 rules. */
.joud-group .group-gallery-dialog .group-gallery-sr-only,
.joud-public #main-content .group-gallery-dialog .group-gallery-sr-only {
  position: absolute;
  float: none;
  width: 1px;
  height: 1px;
  min-width: 0;
  min-height: 0;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Keep Close, position and navigation visible on short landscape screens.
   Only the figure can scroll; the complete photograph remains contained. */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .joud-group .group-gallery-dialog[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow: hidden;
  }
  .joud-group .group-gallery-dialog-bar,
  .joud-group .group-gallery-dialog-actions {
    min-width: 0;
    margin-block: 0;
  }
  .joud-group .group-gallery-dialog-figure {
    display: grid;
    grid-template-rows: minmax(64px, 1fr) auto;
    gap: 8px;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .joud-group .group-gallery-dialog-figure img {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .joud-group .group-gallery-dialog-figure figcaption {
    margin-top: 0;
  }
}
